|
Sound troubles |
DavyKager
Member #8,299
February 2007
|
Hi! Last month I downloaded and installed Allegro, and it must been said that it's really cool! However, I'm stuck on how to let my sounds play. Maybe someone here can help me? I'm trying to build an audiogame, which is my first project, so I'm not used to work with Allegro and C++. I get the keyboard input in a while-loop. That works great, but in this case the sounds are in the while-loop too. And that cause them to constantly restart on every loop... Can anyone please give me some hints or tips how to deal with this? |
Johan Halmén
Member #1,550
September 2001
|
Show some code. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest. |
Arthur Kalliokoski
Second in Command
February 2005
|
I think you'd want this They all watch too much MSNBC... they get ideas. |
DavyKager
Member #8,299
February 2007
|
Well, let me give some example code. Assume that I've loaded a sample and initialized Allegro before. This will start a new sample every loop, which is of course not the thing I wanted to do. I know that there are some sounds in the Allegro demo game, but I can't find out how it all works. |
ngiacomelli
Member #5,114
October 2004
|
Quote: which is of course not the thing I wanted to do. A quick look at the manual here at Allegro.cc shows that play_sample is used in exsample.c (which can be found in your allegro examples folder). Here's a snippet that sould make everything clear:
|
DavyKager
Member #8,299
February 2007
|
That's cool, but then I have to start all my samples at volume 0 and adjust them later when they're needed. And since it's an audiogame, that would be loads of sounds. |
Thomas Fjellstrom
Member #476
June 2000
|
or you have a list/array of your playing sounds, and use adjust_sample on the ones you want to change at any given time. -- |
Ariesnl
Member #2,902
November 2002
|
use FMOD.. it's free if you're not gonna make money Perhaps one day we will find that the human factor is more complicated than space and time (Jean luc Picard) |
Thomas Fjellstrom
Member #476
June 2000
|
How does FMOD help? He's asking a rather basic question about how to use sounds... -- |
Johan Halmén
Member #1,550
September 2001
|
Your problem is not related to sound functions. It is related to program logic. You have a thing you want to do once, not every loop. No matter if it is a sound or drawing a rectangle or whatnot. Set a flag when you play the sound. Check if flag is set before you try to play the sound again. If you don't get it, try to deal with simpler program logic first. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest. |
DavyKager
Member #8,299
February 2007
|
I was already thinking about using a flag, but I didn't see that in the demos/examples, so I thought there was another way. |
Audric
Member #907
January 2001
|
See Voice control in the manual, this is the API to control more finely the sounds while they are being played. |
ImLeftFooted
Member #3,935
October 2003
|
Sounds::loop("engine sound"); Sounds::PlayInfo pi; pi.pan = 0.5; pi.vol = 1.0; pi.frequency = 1.0; Sounds::adjust("engine sound", pi);
|
|