al_play_sample
bool al_play_sample(ALLEGRO_SAMPLE *spl, float gain, float pan, float speed,
ALLEGRO_PLAYMODE loop, ALLEGRO_SAMPLE_ID *ret_id)
Introduced in 5.0.0
Plays a sample on one of the sample instances created by al_reserve_samples. Returns true on success, false on failure. Playback may fail because all the reserved sample instances are currently used.
Parameters:
- gain - relative volume at which the sample is played; 1.0 is normal.
- pan - 0.0 is centred, -1.0 is left, 1.0 is right, or ALLEGRO_AUDIO_PAN_NONE.
- speed - relative speed at which the sample is played; 1.0 is normal.
- loop - ALLEGRO_PLAYMODE_ONCE, ALLEGRO_PLAYMODE_LOOP, or ALLEGRO_PLAYMODE_BIDIR
- ret_id - if non-NULL the variable which this points to will be assigned an id representing the sample being played.
See also: ALLEGRO_PLAYMODE, ALLEGRO_AUDIO_PAN_NONE, ALLEGRO_SAMPLE_ID, al_stop_sample, al_stop_samples.
Examples: ex_audio_simple, ex_haiku
Most helpful discussions:
- SpeedHack 2014 is this weekend! (1)
- [A5] Checking if a sample is playing? (1)
- From A4 to A5: questions (console window, key presses,timers/sprite animation) (1)
- [A5/OSX] Sound not playing (1)
- Having Trouble with exit(1) - Stalling Program
- Allegro GTK3 and Mac
- Footsteps sound effect
- Game Crashing and I'm not sure why?
- Creating executable files in Visual Studio
- Audio seems overly complicated :(
Other recent discussions:
- Text input using allegro 5
- Sound Delay
- Creating a Allegro 5 equivalent to _kbhit()
- How to play video in allegro 5
- Why is this code crashing???
- Audio addon: pause sample
- step calculation for sampled sin sample
- Successful but silent audio playback
- Creating new samples using std::vector
- Enemy AI Movement