You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to get the buffer values from live input or from ofxAudioFile too.
Then I can make some external processing, apart of FFT (bundled on ofxSoundObjects).
On ofxGist I am doing this to process live input, but I'll like to use ofxSoundObject to avoid the manual handle of ofSoundStream settings.
void ofApp::processAudio(float * input, int bufferSize, int nChannels) {
//convert float array to vector
vector<float>buffer;
buffer.assign(&input[0], &input[bufferSize]);
gist.processAudio(buffer, bufferSize, nChannels, sampleRate);
}
Did this have any sense or I am missing something?
The text was updated successfully, but these errors were encountered:
Hola Manuel! :)
That way of handling audio data is kinda (old), I recommend you to use an ofSoundBuffer, which is in a very broad way, just a vector of floats ( the data), some other properties like samplerate, number of channels etc, and a big bunch of really useful functions for dealing with the audio data. Take a look at the inline documentation in ofSoundBuffer.h which is quite complete.
So, the idea of ofxSoundObjects it that you extend the class and make your own object to process audio however you want (actually the point of the included SoundObjects is simply to demonstrate this)
So, you can do something like
#include"ofxSoundObjects.h"classofxGistSoundObject: publicofxSoundObject {
public:ofxGistSoundObject:ofxSoundObject(OFX_SOUND_OBJECT_PROCESSOR){
ofxGist * gist = nullptr;// make sure that you set this properly. It could be a pointer or an instance, it is up to you.voidprocess(ofSoundBuffer &input, ofSoundBuffer &output) {
output = input; // copy the input data to the output. This will copy settings and all. It goes at the "expense" of copying the audio data as well. which in this case I think you need. Otherwise just copy the settings and not the data. // I am assuming that your gist.processAudio(buffer, bufferSize, nChannels, sampleRate); function operates destructively over the audio samples, this is why I copied the audio data, so the input does not get corrupted.if(gist){// just make sure we dont have a nullptr
gist->processAudio(output.getBuffer().data(), output.getNumFrames(), output.getNumChannels(), output.getSampleRate());
}
}
}
Notice that I am assuming that your gist.processAudio(...) function will modify the data in the passed buffer, otherwise you need to put that data back into the output buffer.
Now simply make an instance of ofxGistSoundObject and connect as any of the other objects in the examples :).
Hope this helps
I would like to get the buffer values from live input or from ofxAudioFile too.
Then I can make some external processing, apart of FFT (bundled on ofxSoundObjects).
On ofxGist I am doing this to process live input, but I'll like to use ofxSoundObject to avoid the manual handle of ofSoundStream settings.
Did this have any sense or I am missing something?
The text was updated successfully, but these errors were encountered: