Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Quick help with audio

This thread is locked; no one can reply to it. rss feed Print
Quick help with audio
Jason Marmon
Member #14,859
January 2013

I'm making a pong game where a boop sound is played whenever the ball collides with the paddle. For some reason, I get an error when playing the sound.

ALLEGRO_SAMPLE*boopSound=al_load_sample("boop.wav");
ALLEGRO_PLAYMODE noLoop=ALLEGRO_PLAYMODE_ONCE;
ALLEGRO_SAMPLE_ID sampleID;
...
al_play_sample(boopSound,255,127,1200,noLoop, &sampleID);

any thoughts on why this isn't working?

Trent Gamblin
Member #261
April 2000
avatar

Check that boopSound isn't NULL. Check if you initialized the acodec addon.

Jason Marmon
Member #14,859
January 2013

Thanks for the reply. I didn't initialized the acodec addon. However, now that I've added "al_init_acodec_addon()", no sound plays when the program runs (I did check to see if boopSound was null).

Matthew Leverton
Supreme Loser
January 1999
avatar

Your parameters are wrong. They should be 1.0, 0.0, 1.0. Check the docs.

Jason Marmon
Member #14,859
January 2013

Figured out the problem - I was looking at an outdated guide. Here's the new code:
al_play_sample(boopSound,1.0,ALLEGRO_AUDIO_PAN_NONE,1.0,noLoop, &sampleID);
EDIT: I see now Matthew responded with the fix; a belated thanks for your help Matthew :)

Go to: