I ask a lot of questions here (being still the coding noob I am :o) and I'm grateful for all answers I get so I thought I try to give a little back when I can.
I just did a bitcrusher thing and it seems to work fine (using schwa's Bitter to check), maybe someone finds it useful.
"Inspired" from this thread (Borogove's post, thanks)
http://ift.tt/2doJPws
I just did a bitcrusher thing and it seems to work fine (using schwa's Bitter to check), maybe someone finds it useful.
Code:
// Bitcrusher.h
#pragma once
#include <math.h>
class Bitcrusher
{
public:
Bitcrusher();
double process(double);
void setNumberOfBits(int);
private:
int mBits;
};
Code:
// Bitcrusher.cpp
#include "Bitcrusher.h"
Bitcrusher::Bitcrusher() {
}
double Bitcrusher::process(double in) {
double x = pow(2.0, mBits);
double quant = .5 * x;
double dequant = 1.0 / quant;
double out = dequant * (int)(in * quant);
return out;
}
void Bitcrusher::setNumberOfBits(int bits) {
mBits = bits;
}
http://ift.tt/2doJPws
A bitcrusher class
Aucun commentaire:
Enregistrer un commentaire