Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Sample Instances and Mixers

This thread is locked; no one can reply to it. rss feed Print
Sample Instances and Mixers
KirbyDS11
Member #15,167
June 2013
avatar

I am having a problem with sample instances.
I tried to play the sample instance by using this code.

The program will start up fine but then an error message saying allegro audio test.exe has stopped working.
I then ran it in debug mode and found out that al_get_default_mixer() was causing the program to crash.
Then I tried to make a mixer with this code.

#SelectExpand
1al_install_audio(); 2al_init_acodec_addon(); 3 4ALLEGRO_SAMPLE *music=al_load_sample("song.ogg"); 5ALLEGRO_SAMPLE_INSTANCE *song=al_create_sample_instance(music); 6al_set_sample_instance_playmode(song,ALLEGRO_PLAYMODE_LOOP); 7ALLEGRO_MIXER *mixer=al_create_mixer(44100,ALLEGRO_AUDIO_DEPTH_FLOAT32 8 ,ALLEGRO_CHANNEL_CONF_2); 9al_attach_sample_instance_to_mixer(song,mixer); 10 11al_reserve_samples(1); 12 13al_play_sample_instance(song);

When I ran this code It did not crash but the song was not played.
With that said what did I do wrong with this code? ???

Woops

l j
Member #10,584
January 2009
avatar

al_reserve_samples is used for the default mixer and is not required if you use your own mixer, I think.

If you're trying to use your own mixer, you must first create an ALLEGRO_VOICE and attach your mixer to it.

KirbyDS11
Member #15,167
June 2013
avatar

Thank you
It work perfectly now. :)

Woops

Go to: