how to use OF for audio playback?

hi.

i’ve two questions about audio in OF.

  1. what is the difference between ofAudio, ofAudioStream, ofSoundPlayer, ofSoundStream and which one should i use for playback?

  2. i used it like that

  
  
ofSoundPlayer sndPlayer;  
sndPlayer.loadSound("somesound.mp3");  
sndPlayer.play();  
  

and with multiple or simultaneous calls of the play-method for different sounds it behaved strangly. did someone else experience that?

thanks for help
didi

Hi,

As far as I know there’s only ofSoundPlayer and ofSoundStream. Where have you seen ofAudio or ofAudioStream?

ofSoundPlayer uses FMOD to play back sample files.
ofSoundStream uses rtAudio to do I/O on audio streams.

I haven’t had any problems with either of them…but I haven’t used ofSoundPlayer extensively.

you should use one ofSoundPlayer object per sound you want to play – see the example for usage.

can you show us what code you are having trouble with, perhaps upload code and sound files?

thanks!
zach

@grimus:
thanks for the clearification.

the ofAudio stuff was already in my downloaded openFrameworks source code archive (pre-release v0.02). and since i compile my own version of openFrameworks library i stumbled across those files. maybe they are some leftovers …

@zach:
i’m sorry, i don’t have that piece of code anymore. i removed it right away.
as far as i can remember i tried to play the same soundfile from different pieces of code. and when this happenend concurrently audio got messed up.

one ofSoundPlayer object per sound

might be the cause. i don’t know anymore if i used multiple ofSoundPlayers. i guess not …

thanks
didi

the ofAudio stuff was already in my downloaded openFrameworks source code archive (pre-release v0.02). and since i compile my own version of openFrameworks library i stumbled across those files. maybe they are some leftovers …

we’ve been going through name changes, you can download the 0.01 code and 0.02 code to compare, but we’ve renamed the audio classes to be more clear.

same soundfile from different pieces of code. and when this happenend concurrently audio got messed up.

I’d need to see what you mean about concurrently –

at any rate, there are two styles of playing a sample of audio with fmod (ofSoundPlayer), which you can adjust with this:

  
  
blah.setMultiPlay(....);  
  

with multiplay = false, if you try to play twice, one will end the current sound and play the sound again when you press play (ie, start from the beginning, only one version of the sound plays at a time), the other will play multiple version on top of each other. you can see both of these styles in the sound player example.

I haven’t had alot of problems with ofSoundPlayer, so I am curious to know what the issues are. If you come across an issue, please save the code and post it so we can know…

hope that helps!

thanks!!
zach

hmm, now with a cleaner implementation it works well.
maybe it had something to do with a wrong usage of “multiplay” and the fact of not having different soundplayers per sample.
anyway, i’ll get back to you if i encounter problems …

thx for your help
didi