From b52bec5810e1ea9e366cd64567de65ef68b60eb7 Mon Sep 17 00:00:00 2001 From: Micheal Reed Date: Wed, 18 Nov 2020 12:32:54 -0600 Subject: [PATCH 1/2] Added API to change waveform type dynamically --- miniaudio.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/miniaudio.h b/miniaudio.h index 7c1c0395..c0a934a4 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -1145,7 +1145,7 @@ miniaudio supports generation of sine, square, triangle and sawtooth waveforms. ma_waveform_read_pcm_frames(&waveform, pOutput, frameCount); ``` -The amplitude, frequency and sample rate can be changed dynamically with `ma_waveform_set_amplitude()`, `ma_waveform_set_frequency()` and +The amplitude, frequency, type, and sample rate can be changed dynamically with `ma_waveform_set_amplitude()`, `ma_waveform_set_frequency()`, ma_waveform_set_type(), and `ma_waveform_set_sample_rate()` respectively. You can invert the waveform by setting the amplitude to a negative value. You can use this to control whether or not a sawtooth has a positive or negative @@ -6103,6 +6103,7 @@ MA_API ma_uint64 ma_waveform_read_pcm_frames(ma_waveform* pWaveform, void* pFram MA_API ma_result ma_waveform_seek_to_pcm_frame(ma_waveform* pWaveform, ma_uint64 frameIndex); MA_API ma_result ma_waveform_set_amplitude(ma_waveform* pWaveform, double amplitude); MA_API ma_result ma_waveform_set_frequency(ma_waveform* pWaveform, double frequency); +MA_API ma_result ma_waveform_set_type(ma_waveform* pWaveform, ma_waveform_type type); MA_API ma_result ma_waveform_set_sample_rate(ma_waveform* pWaveform, ma_uint32 sampleRate); @@ -47479,6 +47480,18 @@ MA_API ma_result ma_waveform_set_frequency(ma_waveform* pWaveform, double freque return MA_SUCCESS; } +MA_API ma_result ma_waveform_set_type(ma_waveform* pWaveform, ma_waveform_type type) +{ + if (pWaveform == NULL) { + return MA_INVALID_ARGS; + } + + pWaveform->config.type = type; + ma_waveform__update_advance(pWaveform); + + return MA_SUCCESS; +} + MA_API ma_result ma_waveform_set_sample_rate(ma_waveform* pWaveform, ma_uint32 sampleRate) { if (pWaveform == NULL) { From 3e513864975e5a63b295dc8faecf2e5011adc9c1 Mon Sep 17 00:00:00 2001 From: Micheal Reed Date: Thu, 19 Nov 2020 15:32:49 -0600 Subject: [PATCH 2/2] Removed advanced update. --- miniaudio.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/miniaudio.h b/miniaudio.h index c0a934a4..4d4cec61 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -47487,8 +47487,6 @@ MA_API ma_result ma_waveform_set_type(ma_waveform* pWaveform, ma_waveform_type t } pWaveform->config.type = type; - ma_waveform__update_advance(pWaveform); - return MA_SUCCESS; }