Reproducir sonido en Allegro

 Un sencillo ejemplo para reproducir un fichero  .wav 

En sólo cuatro (4) pasos. Necesitaremos un fichero de audio de formato "wav"

Fácil, ¿eh?  Riendo

-------------------------------------------code starts here ---------------------------------  

 

 #include <stdio.h>
#include <stdlib.h>
#include <allegro.h> //   <--- OJO, no olvidar cargar el binario en Proyecto-> Propiedades-> parámetros

int main(int argc, char *argv[])
{  int  x;
  // Inicializamos Allegro
allegro_init();

// Instalamos driver de sonido, si devuelve un 0 es porque funciona correctamente
    x = install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL);
  if (x != 0 ) { printf("\nError con el driver de sonido");  return 1;  }

// cargamos el "sample"  - fichero de sonido digital -
 SAMPLE *sample = load_wav("sonido.wav");
 if (!sample) {    printf("Error leyendo  el fichero de sonido\n"); return 2; }
 
 // Hacemos sonar el sample                // 100 = volumen   128 = sonido balanceado   0 = sin bucle
    play_sample(sample,100,128,1000,0);
    
    
  system("PAUSE");    
  return 0;
}

END_OF_MAIN();    // famoso código final con allegro
--------------------------------------------end code-----------------------------------