I am stuck on something so simple…
I can’t get playSound to work. I’m writing an OpenGl program, and have been generating sine tones(DSP’s) based on events with great success. Now I want to play an audio file (to eventually analyze the spectrum of), and the program runs but the audio file doesn’t play…
I’ve tried:
- creating and playing the sound in my main function,
…
FMOD::Channel* sChannel;
FMOD::Sound* sound;
Asystem->createSound(“jaguar.mp3”, FMOD_DEFAULT, 0, &sound);
Asystem->playSound(sound, 0, false, &sChannel);
//and waiting for user input
std::cout << "Press return to quit." << std::endl;
std::cin.get();
…
- creating a Sound class, a newSound function, and unpausing the sound’s channel in my glut Display func (called once per frame)
class Sound {
FMOD::Channel *soundchannel;
FMOD::DSP *sounddsp;
FMOD::Sound *sound;
public:
FMOD::Channel* getChannel() {
return soundchannel;
}
Sound(FMOD::Channel* sc, FMOD::DSP* sdsp, FMOD::Sound* sound):
soundchannel(sc), sounddsp(sdsp), sound(sound)
{};
};
std::vector soundVec;
void newSound(){
FMOD_RESULT result;
FMOD::Channel* sChannel;
FMOD::DSP* sDSP;
FMOD::Sound* sound;
result = Asystem->createDSPByType(
FMOD_DSP_TYPE_OSCILLATOR,
&sDSP
);
Asystem->createSound("jaguar.mp3", FMOD_DEFAULT, 0, &sound);
Asystem->playSound(sound, 0, false, &sChannel);
sChannel->setVolume(.8);
Sound newSound = Sound(sChannel, sDSP, sound);
soundVec.push_back(newSound);
}
display(){
…
for (int i = 0; i < soundVec.size(); i++){
FMOD::Channel* cchannel = soundVec[i].getChannel();
cchannel->setPaused(false);
}
…
Asystem-> update();
}
and have also, in fear that I wasn’t specifying the filepath of the audio file, copied the .wav file (taken from the fmod examples) into the sub folder containing my project as well as it’s parent folder
I’ve had no success, and am seriously bummed out that I’m stuck on what’s probably the simplest possible thing to do with FMOD.
I know there are more interesting questions to answer, but any help would really be so appreciated.
Jake