Hi,
I am trying to get a binary sequence from an audio stream.
In short, I would need to speak into a mic and having as output a sequence of 1 and 0 according to the audio signal.
if there are no sound I shouldn’t get any number
At the moment it seems that I keep on receiving data…
I thought it was a straightforward thing to do but I might be lost.
I started with the standard ofSoundStream then switched to ofxFFT.
here is the code that I am using. If anybody had a suggestion that would be great!
thanks.
void ofApp::setup(){
ofSetBackgroundAuto(true);
///...FFT/////
fftLive.setMirrorData(false);
fftLive.setup();
}
//--------------------------------------------------------------
void ofApp::update(){
fftLive.update();
myBinary = fftLive.getFftRawData();
audioData = new float[myBinary.size()];
fftLive.getFftPeakData(audioData, myBinary.size());
delete[] audioData;
}
//--------------------------------------------------------------
void ofApp::draw(){
if (fftLive.getFftNormData().size()>0) {
ofDrawBitmapStringHighlight(ofToBinary(audioData),0,100);
ofDrawBitmapStringHighlight("binary Size "+ofToString(myBinary),0,120);
}
ofSetColor(255);
int w = OFX_FFT_WIDTH;
int h = OFX_FFT_HEIGHT;
int x = 20;
int y = ofGetHeight() - h - 20;
fftLive.draw(x, y, w, h);
}