Creating Voice, Mixer and Sample Instance
AMCerasoli

Hi guys,

I'm having some problems when creating my own voice, mixer and sample instance. I remember I did it once, but I can't do it now :-/. Before I show the code, I want to ask if it's a good idea to create two voices each one with its own mixer?. This is because I want to attach certain samples to a "music" mixer and others to a "sfx" mixer, so I can adjust the gain of each mixer without touching all the samples that are attached to it. Ohhh shit... I have just realized that the gain option is for A5.1... Well but anyways I want to know why it's not working?, I know I'm missing something.

#SelectExpand
1 ALLEGRO_VOICE *voice = al_create_voice(44100, 2 ALLEGRO_AUDIO_DEPTH_INT16, 3 ALLEGRO_CHANNEL_CONF_2); 4 5 ALLEGRO_MIXER *mixer = al_create_mixer(44100, 6 ALLEGRO_AUDIO_DEPTH_FLOAT32, 7 ALLEGRO_CHANNEL_CONF_2); 8 9 al_attach_mixer_to_voice(mixer, voice); 10 ALLEGRO_SAMPLE *sam = al_load_sample("sam.ogg"); 11 ALLEGRO_SAMPLE_INSTANCE *sam_ins = al_create_sample_instance(sam); 12 13 if(!al_play_sample_instance(sam_ins)) 14 std::cout<<"error"; 15 16 al_rest(1);

I always get an error in that last step, the rest don't have error checking but I have already check them and they work fine.

Thanks.

Edit: I got it, I was missing al_attach_sample_instance_to_mixer(), this is like in a real studio when you need to connect all those wires... ;D

Thread #609313. Printed from Allegro.cc