How to get sound level from an ofSoundPlayer object?

Hi, I know how to obtain levels from micIn (audioInput example), how would I get information on sound levels from just a single sound channel?

I know there is a function in the FMOD api like getSpectrum. Is there a way to do this without performing any fft?

Hi, I’ve used a single band FFT to get audio level and works fine. The ofSoundPlayer class wraps up the fmod fft functionality to make it even easier to use, you can see how its done in the ofSoundPlayer Example.

Thanks memo! I’m writing a class which extends ofSoundPlayer at the mo to make it easier to add the effects that come with FMOD. Here’s a little snippet of the header file:

class ofSoundPlayerExtended : public ofSoundPlayer {  
	void addLPF();					  
	void setParametersLPF(float cutoff, float resonance);  
	void bypassLPF(bool bypass);  
	void killLPF();  
	void addHPF();  
	void setParametersHPF(float cutoff, float resonance);  
	void bypassHPF(bool bypass);  
	void killHPF();  
	//a bit different  
	void addEQband();  
	void setParametersEQ(int bandID, float freq, float q, float gain);  
	void bypassEQ(bool bypass);  
	void killEQ();  
	void addReverb();  
	void setParametersReverb(float roomSize, float damp, bool freeze);  
	void setParametersReverbWetDry(float wet, float dry);  
	void bypassReverb(bool bypass);  
	void killReverb();  
	void addEcho();  
	void setParametersEcho(float delay, float decayRatio);  
	void setParametersEchoDryWet(float dry, float wet);  
	void bypassEcho(bool bypass);  
	void killEcho();	  
	void addFlange();  
	void setParametersFlange(float depth, float rate);  
	void setParametersFlangeWetDry(float wet, float dry);  
	void bypassFlange(bool bypass);  
	void killFlange();  
	void addChorus();  
	void setParametersChorus(float delay, float rate, float depth, float feedback);  
	void setParametersChorusDryWet(float dryMix, float wetMix1, float wetMix2, float wetMix3);  
	void bypassChorus(bool bypass);  
	void killChorus();  
	void addDistortion();  
	void setParametersDistortion(float level);  
	void bypassDistortion(bool bypass);  
	void killDistortion();  
	void addPitchShift();  
	void setParametersPitchShift(float value/*0.5 to 2.0*/, int fftSize=1024/*256, 512, 1024, 2048, 4096.  Default = 1024*/);  
	void bypassPitchShift(bool bypass);  
	void killPitchShift();  
	void killAllFX();  
	FMOD_SYSTEM	*sysPtr;							  
	FMOD_DSP       *dspLowPass;  
    FMOD_DSP       *dspHighPass;  
    FMOD_DSP       *dspEcho;  
    FMOD_DSP       *dspFlange;  
    FMOD_DSP       *dspChorus;  
    FMOD_DSP       *dspReverb;  
    FMOD_DSP       *dspDistortion;  
    FMOD_DSP       *dspPitchShift;  
	int				numEqbands;  
	struct dspEQbands {  
		FMOD_DSP	*band1;  
		FMOD_DSP	*band2;  
		FMOD_DSP	*band3;  
		FMOD_DSP	*band4;  
		FMOD_DSP	*band5;  

I’ve never really written any code for other people to use so I’m trying to be super careful, making it nice and easy to use. Any pointers would be really appreciated. Quite indecisive about public/private/protected.


I’m trying to do a similar thing, I have multiple soundPlayer objects around and I would like to read the current volume of each one separately(not the volume I set using setVolume, I mean the actual current volume of the audio playing from that soundPlayer object). I looked at the ofSoundGetSpectrum but it seems like it is returning the fft of all the soundPlayer objects playing in that moment.

How to access their volume/fft, individually?


1 Like

Anyone ever figure this out? FFT of multiple soundPlayer objects is exactly what I’m looking for… ???

1 Like