Hello. For my Engineering 112 class, we have to get into groups and make a game. I thought I’d make a sound class during spring break whilst being bored. Anyways, for some reason, sounds don’t want to play if I make them a certain way (see zip file or link to code for better understanding…)
Here’s how it works: I have a class, SoundObject, which is used to make objects of different sounds. Then I have another class, SoundSystem, the initializes FMOD and can also act as an interface between SoundObject. How I have it setup, is that you can add a SoundObject to a vector of SoundObjects with the SoundSystem. It then adds to a hash map with the filename and the vector entry. I did this so it would be easy to manipulate sounds. All you would have to do to play a sound, for instance, would be PlaySound(“filename”).
The problem is is that for some reason if I create SoundObjects this way, it won’t play. FSOUND_Stream_Play() returns -1, even though the FSOUND_STREAM is successfully created. Though if I create SoundObjects individually, everything works.
Here’s a link to the code: [url:h136lyna]http://rafb.net/paste/results/Uh2VgD81.html[/url:h136lyna]
And a link to the project files: [url:h136lyna]http://www.xilo-online.com/scrabble.zip[/url:h136lyna]
Any help would be greatly appreciated.
- xilo asked 13 years ago
I know… I was lazy and didn’t feel like putting them in now… I just went through the debugger instead. I’m not stupid; I DO know how to read the api. 😡 Like I said, playing only fails when I add songs via SoundSystem. A SoundObject gets successfully created along with an FMOD_STREAM, but playing fails for some reason and returns a -1.
It does, however, work if I individually create SoundObjects myself.
I figured it out. Turns out all my problems had to deal with a lack of pointers to SoundObjects. Someone kick me, please. 😮
Now to figure out this pointer problem…
It’s all in the pair, map, and vectors…
All fixed and working good
- xilo answered 13 years ago
Please login first to submit.