// adjust parameters while playing void adjust_sfx(int index,int pan,bool loop) { if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1) return; voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY); voice_set_pan(sfx_voice[index],pan); }
void SOUNDCLIP::set_panning(int newPanning) { if (!is_playing()) { return; } int voice = get_voice(); if (voice >= 0) { voice_set_pan(voice, newPanning); panning = newPanning; } }
// plays an sfx sample void sfx(int index,int pan,bool loop, bool restart) { if(!sfx_init(index)) return; voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY); voice_set_pan(sfx_voice[index],pan); int pos = voice_get_position(sfx_voice[index]); if(restart) voice_set_position(sfx_voice[index],0); if(pos<=0) voice_start(sfx_voice[index]); }
bool JamulSoundPlay(int voice, long pan, long vol, byte playFlags) { // if this copy is in use, can't play it if (voice_get_position(voice) > 0) { if (playFlags & SOUND_CUTOFF) { voice_set_position(voice, 0); // keep going to handle the rest of the stuff } else return FALSE; // can't play if it's playing } // set the pan and volume and start the voice voice_set_volume(voice, vol); voice_set_pan(voice, pan); voice_start(voice); return TRUE; }
void cSoundPlayer::playSound(SAMPLE *sample, int pan, int vol) { if (maximumVoices < 0) return; assert(sample); if (vol < 0) return; assert(pan >= 0 && pan < 256); assert(vol > 0 && vol <= 256); // allocate voice int voice = allocate_voice(sample); if (voice != -1) { voice_set_playmode(voice,0); voice_set_volume(voice, vol); voice_set_pan(voice, pan); voice_start(voice); for (int i = 0; i < maximumVoices; i++) { if (voices[i] == -1) { voices[i] = voice; break; } } } }
/* (`allegro_init()' is already defined by Allegro itself.) */ static int allegro_init_sound(const char *param, int *speed, int *fragsize, int *fragnr, int *channels) { unsigned int i; /* No stereo capability. */ *channels = 1; if (allegro_startup(*speed) < 0) return 1; fragment_size = *fragsize * sizeof(SWORD); buffer_len = fragment_size * *fragnr; buffer = create_sample(16, 0, *speed, buffer_len / sizeof(SWORD)); for (i = 0; i < buffer_len / 2; i++) *((WORD *)buffer->data + i) = 0x8000; voice = allocate_voice(buffer); if (voice < 0) { log_debug("Cannot allocate Allegro voice!\n"); destroy_sample(buffer); return 1; } buffer_offset = 0; been_suspended = 1; written_samples = 0; voice_set_playmode(voice, PLAYMODE_LOOP); voice_set_volume(voice, 255); voice_set_pan(voice, 128); return 0; }
void saSetPan( int channel, int data ) { voice_set_pan(hVoice[channel],data); }