get individual samples in ofSoundPlayer, FMOD Ex, ofxSndObj?

Hi Folks,

I’m trying to realize a sound project in oF which

  1. reads a sound file (e.g. *.wav or *.mp3),
  2. “manually” process and modify the individual samples in[i]
    like for( int i=0; i<LEN;i++) out[i] = some_own_function( in[i], params);
  3. and then play that modified signal and write it to a file.

in my humble impression, it seems to me that none of ofSoundPlayer, FMOD Ex, ofxSndObj is able to provide the complete list of functionality required for this.

You may access samples using ofSoundStream // audio_requested() - but there is no way to read and play files. - On the other hand, you may read files using the other classes - however, then there is no way to access the individual samples… :slight_smile: methodius

There are a number of ways to do this, but unfortunately OF will not do this for you in an easy fashion.

You can do it using FMODex, with something like Sound::readData()

Or you can use something like libsndfile to load the data to a buffer then play it in ofSoundStream()
see:
http://forum.openframeworks.cc/t/saving-audio-file-to-disk/1136/5
http://forum.openframeworks.cc/t/simplest-way-to-get-per-sample-access-to-audio-file/2670/0

or you could use the OpenAL addon and extract the audio from the sample buffer using GetSamples()
http://forum.openframeworks.cc/t/new-openal-based-ofsoundplayer/2920/0

You might also want to look at the new Maximilian addon…it’s got lots of cool stuff including sample loading:
http://forum.openframeworks.cc/t/maximilian—some-c+±objects-for-dsp-and-synthesis./3416/0

Loading a sample into ofSoundStream is something that really should exist…perhaps as an addon. It’s not that difficult but would take a little time, if you write any related code please post :slight_smile:
If I get around to it I’m thinking of porting some of the cool sample stuff from Maximilian to some simpler ofSoundStream code.

Hi grimus,

thanx for your fast and helpful reply!

Just for my clarification:
[…]

You can do it using FMODex, with something like Sound::readData()

well, thats sounds great. Unfortunately, I did not find it in the oF documentation - where should I look for Sound::readData() ?

[…]

Loading a sample into ofSoundStream is something that really should exist…perhaps as an addon. It’s not that difficult but would take a little time, if you write any related code please post :slight_smile: methodius

Actually, Sound::readData() is in the FMOD SDK documentation. You will need to go to the FMOD website www.fmod.org and download the appropriate SDK for your operating system. The FMOD manual has the info on readData(). You would then need to modify the OF soundplayer code to include this. So it’s not an easy fix unfortunately, I just wanted to point out that it is possible… sorry :frowning:

Hi again,

I wrote some code to load a sample into ofSoundStream…this should do the trick for you.
http://forum.openframeworks.cc/t/example-of-playing-back-a-sample-in-ofsoundstream/3502/0