diff --git a/miniaudio.h b/miniaudio.h index 531b80ea..ab88da3f 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -4742,6 +4742,9 @@ typedef struct ma_result ma_waveform_init(ma_waveform_type type, double amplitude, double frequency, ma_uint32 sampleRate, ma_waveform* pWaveform); ma_uint64 ma_waveform_read_pcm_frames(ma_waveform* pWaveform, void* pFramesOut, ma_uint64 frameCount, ma_format format, ma_uint32 channels); +ma_result ma_waveform_set_amplitude(ma_waveform* pWaveform, double amplitude); +ma_result ma_waveform_set_frequency(ma_waveform* pWaveform, double frequency); +ma_result ma_waveform_set_sample_rate(ma_waveform* pWaveform, ma_uint32 sampleRate); #ifdef __cplusplus } @@ -37894,6 +37897,36 @@ ma_result ma_waveform_init(ma_waveform_type type, double amplitude, double frequ return MA_SUCCESS; } +ma_result ma_waveform_set_amplitude(ma_waveform* pWaveform, double amplitude) +{ + if (pWaveform == NULL) { + return MA_INVALID_ARGS; + } + + pWaveform->amplitude = amplitude; + return MA_SUCCESS; +} + +ma_result ma_waveform_set_frequency(ma_waveform* pWaveform, double frequency) +{ + if (pWaveform == NULL) { + return MA_INVALID_ARGS; + } + + pWaveform->frequency = frequency; + return MA_SUCCESS; +} + +ma_result ma_waveform_set_sample_rate(ma_waveform* pWaveform, ma_uint32 sampleRate) +{ + if (pWaveform == NULL) { + return MA_INVALID_ARGS; + } + + pWaveform->deltaTime = 1.0 / sampleRate; + return MA_SUCCESS; +} + static float ma_waveform_sine_f32(double time, double frequency, double amplitude) { return (float)(ma_sin(MA_TAU_D * time * frequency) * amplitude);