Mail Archives: djgpp/1999/07/16/13:20:30
Sound uses a type SAMPLE wich works very similar to the way BITMAP does.
Try this:
SAMPLE *my_sample;
my_sample = load_sample( SND1 );
play_sample(my_sample);
I think that's right. Unfortunately there's no way to tell when the sound
is finished playing, so you might have to do another readkey() after this.
If you really don't want to have that readkey() at the end you could try
adding a delay equal to the length of the sample but that is really
sketchy so don't do it.
Mark
> Im confused with using sound in my program here is the source that i wrote:
>
> #include <iostream.h>
> #include "allegro.h"
>
> //Availible Res: 300x200, 640x480, 800x600, 1024x768, 1152x864
>
> #define WIDTH 640
> #define HEIGHT 480
> #define PIC1 "omega.bmp"
> #define SND1 "test.wav"
>
> int main()
> {
>
>
> BITMAP *allegro;
> PALLETE pal;
>
> allegro_init();
> install_keyboard();
> set_gfx_mode(GFX_AUTODETECT, WIDTH, HEIGHT, 0, 0);
> install_sound (DIGI_AUTODETECT, MIDI_AUTODETECT, NULL);
>
>
> // Load Bitmap Into Memory
> allegro = load_bitmap(PIC1, pal);
> set_palette(pal);
>
> //Display Bitmap
> blit(allegro, screen, 0, 0, 0, 0, WIDTH, HEIGHT);
>
> readkey();
> load_sample( SND1 );
> play_sample(SND1 *, 255, 128, 1000, 0);
> stop_sample(SND1 *);
> fade_out(3);
> destroy_bitmap(allegro);
>
> return 0;
> }
>
>
> can someone please tell me what is wrong? i want to get the sound to play at
> the end of the program after a key is pressed. everything else works great
>
- Raw text -