|
Sample Instances and Mixers |
KirbyDS11
Member #15,167
June 2013
|
I am having a problem with sample instances. 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);
7al_attach_sample_instance_to_mixer(song,al_get_default_mixer());
8
9al_reserve_samples(1);
10
11al_play_sample_instance(song);
The program will start up fine but then an error message saying allegro audio test.exe has stopped working. 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. Woops |
l j
Member #10,584
January 2009
|
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
|
Thank you Woops |
|