/* Function: al_set_sample_instance_gain */ bool al_set_sample_instance_gain(ALLEGRO_SAMPLE_INSTANCE *spl, float val) { ASSERT(spl); if (spl->parent.u.ptr && spl->parent.is_voice) { _al_set_error(ALLEGRO_GENERIC_ERROR, "Could not set gain of sample attached to voice"); return false; } if (spl->gain != val) { spl->gain = val; /* If attached to a mixer already, need to recompute the sample * matrix to take into account the gain. */ if (spl->parent.u.mixer) { ALLEGRO_MIXER *mixer = spl->parent.u.mixer; maybe_lock_mutex(spl->mutex); _al_kcm_mixer_rejig_sample_matrix(mixer, spl); maybe_unlock_mutex(spl->mutex); } } return true; }
/* Function: al_set_sample_instance_pan */ bool al_set_sample_instance_pan(ALLEGRO_SAMPLE_INSTANCE *spl, float val) { ASSERT(spl); if (spl->parent.u.ptr && spl->parent.is_voice) { _al_set_error(ALLEGRO_GENERIC_ERROR, "Could not set panning of sample attached to voice"); return false; } if (val != ALLEGRO_AUDIO_PAN_NONE && (val < -1.0 || val > 1.0)) { _al_set_error(ALLEGRO_GENERIC_ERROR, "Invalid pan value"); return false; } if (spl->pan != val) { spl->pan = val; /* If attached to a mixer already, need to recompute the sample * matrix to take into account the panning. */ if (spl->parent.u.mixer) { ALLEGRO_MIXER *mixer = spl->parent.u.mixer; maybe_lock_mutex(spl->mutex); _al_kcm_mixer_rejig_sample_matrix(mixer, spl); maybe_unlock_mutex(spl->mutex); } } return true; }
/* Function: al_set_audio_stream_pan */ bool al_set_audio_stream_pan(ALLEGRO_AUDIO_STREAM *stream, float val) { ASSERT(stream); if (stream->spl.parent.u.ptr && stream->spl.parent.is_voice) { _al_set_error(ALLEGRO_GENERIC_ERROR, "Could not set gain of stream attached to voice"); return false; } if (val != ALLEGRO_AUDIO_PAN_NONE && (val < -1.0 || val > 1.0)) { _al_set_error(ALLEGRO_GENERIC_ERROR, "Invalid pan value"); return false; } if (stream->spl.pan != val) { stream->spl.pan = val; /* If attached to a mixer already, need to recompute the sample * matrix to take into account the panning. */ if (stream->spl.parent.u.mixer) { ALLEGRO_MIXER *mixer = stream->spl.parent.u.mixer; ALLEGRO_MUTEX *stream_mutex = maybe_lock_mutex(stream->spl.mutex); _al_kcm_mixer_rejig_sample_matrix(mixer, &stream->spl); maybe_unlock_mutex(stream_mutex); } } return true; }