|
[A5] Audio Streams |
Desmond Taylor
Member #11,943
May 2010
|
I have read the manual over and over for audio streams and cannot work it out at all. Can someone link me to a tutorial or write me a basic one that I can start from. I learn quickly so a short example can do the trick. I do however wan't to use streams as I only want the sounds for SFX and Music. Thanks in advance since Im going out soon. |
Evert
Member #794
November 2000
|
Have you taken a look at the examples that come with Allegro? |
Desmond Taylor
Member #11,943
May 2010
|
I have downloaded the Binary. There is no examples :/ Edit: I've tried ALLEGRO_SAMPLE too and still no joy. Here's my test class. 1/**
2# The header contains all the headers needed for allegro.
3: allegro.h
4: allegro_image.h
5: allegro_font.h
6: allegro_ttf.h
7: allegro_audio.h
8: allegro_acodec.h
9**/
10#include "audio.hpp"
11
12ALLEGRO_SAMPLE* sample;
13
14Audio::Audio()
15{
16 al_install_audio();
17 al_init_acodec_addon();
18
19 sample = al_load_sample( "sfx/sfx002.wav" );
20 if ( !sample ) printf( "Not Loaded!\n" ); // It does load as this isn't printed to the console.
21}
22
23Audio::~Audio()
24{
25 al_destroy_sample( sample );
26
27 al_uninstall_audio();
28}
29
30void Audio::play()
31{
32 float gain = 1.0; // Normal Gain
33 float pan = 0.0; // Centered
34 float speed = 1.0; // Normal Speed
35 ALLEGRO_PLAYMODE loop = ALLEGRO_PLAYMODE_ONCE; // Only play once.
36
37 // Now pass the values into al_play_sample()
38 al_play_sample( sample, gain, pan, speed, loop, NULL );
39}
Edit 2 It fails to play I've added this and it fails 1void Audio::play()
2{
3 float gain = 1.0; // Normal Gain
4 float pan = 0.0; // Centered
5 float speed = 1.0; // Normal Speed
6 ALLEGRO_PLAYMODE loop = ALLEGRO_PLAYMODE_ONCE; // Only play once.
7
8 // Now pass the values into al_play_sample()
9 if ( !al_play_sample( sample, gain, pan, speed, loop, NULL ) )
10 printf( "Failed to play sample!\n" );
11 else
12 printf( "Playing sample!\n" );
13}
|
Matthew Leverton
Supreme Loser
January 1999
|
You need to call al_reserve_samples(). Download the source package and check out the examples folder. |
Desmond Taylor
Member #11,943
May 2010
|
Funny enough I was just reading that in the manual and I was just about to post on here saying I missed out al_reserve_samples() but thanks anyway's it's now working |
|