Explorar el Código

Merge pull request #762 from ftk/pitchfix

Fix audio pitch
pull/765/head
Ray hace 5 años
cometido por GitHub
padre
commit
854e5d2f7e
No se encontró ninguna clave conocida en la base de datos para esta firma ID de clave GPG: 4AEE18F83AFDEB23
Se han modificado 1 ficheros con 4 adiciones y 2 borrados
  1. +4
    -2
      src/raudio.c

+ 4
- 2
src/raudio.c Ver fichero

@ -712,11 +712,13 @@ void SetAudioBufferPitch(AudioBuffer *audioBuffer, float pitch)
return;
}
audioBuffer->pitch = pitch;
kt">float pitchMul = pitch / audioBuffer->pitch;
// Pitching is just an adjustment of the sample rate. Note that this changes the duration of the sound - higher pitches
// will make the sound faster; lower pitches make it slower.
mal_uint32 newOutputSampleRate = (mal_uint32)((((float)audioBuffer->dsp.src.config.sampleRateOut / (float)audioBuffer->dsp.src.config.sampleRateIn) / pitch) * audioBuffer->dsp.src.config.sampleRateIn);
mal_uint32 newOutputSampleRate = (mal_uint32)((float)audioBuffer->dsp.src.config.sampleRateOut / pitchMul);
audioBuffer->pitch *= (float)audioBuffer->dsp.src.config.sampleRateOut / newOutputSampleRate;
mal_dsp_set_output_sample_rate(&audioBuffer->dsp, newOutputSampleRate);
}

Cargando…
Cancelar
Guardar