From f5dc957137df48e2c9f1d4487d1092dd1113aad3 Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Sat, 6 Jul 2024 14:55:44 -0400 Subject: [PATCH] gh-67: Addresses several warning revealed by MSVC. --- libsignaletic/include/libsignaletic.h | 2 +- libsignaletic/src/libsignaletic.c | 20 ++++++++++---------- libsignaletic/tests/test-libsignaletic.c | 14 +++++++------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/libsignaletic/include/libsignaletic.h b/libsignaletic/include/libsignaletic.h index 646645f..148863b 100644 --- a/libsignaletic/include/libsignaletic.h +++ b/libsignaletic/include/libsignaletic.h @@ -1068,7 +1068,7 @@ float sig_DelayLine_allpass(struct sig_DelayLine* self, float sample, size_t readPos, float g); float sig_DelayLine_linearAllpass(struct sig_DelayLine* self, - float sample, size_t readPos, float g); + float sample, float readPos, float g); float sig_DelayLine_cubicAllpass(struct sig_DelayLine* self, float sample, float readPos, float g); diff --git a/libsignaletic/src/libsignaletic.c b/libsignaletic/src/libsignaletic.c index 0aaa6c3..077af8f 100644 --- a/libsignaletic/src/libsignaletic.c +++ b/libsignaletic/src/libsignaletic.c @@ -83,33 +83,33 @@ inline float sig_linearMap(float value, return (value - fromMin) * (toMax - toMin) / (fromMax - fromMin) + toMin; } -inline uint16_t sig_unipolarToUint12(float sample) { +extern inline uint16_t sig_unipolarToUint12(float sample) { return (uint16_t) (sample * 4095.0f); } -inline uint16_t sig_bipolarToUint12(float sample) { +extern inline uint16_t sig_bipolarToUint12(float sample) { float normalized = sample * 0.5 + 0.5; return (uint16_t) (normalized * 4095.0f); } -inline uint16_t sig_bipolarToInvUint12(float sample) { +extern inline uint16_t sig_bipolarToInvUint12(float sample) { return sig_bipolarToUint12(-sample); } -inline float sig_uint16ToBipolar(uint16_t sample) { +extern inline float sig_uint16ToBipolar(uint16_t sample) { float normalized = (float) (sample / 65535.0f); float scaled = normalized * 2.0f - 1.0f; return scaled; } -inline float sig_uint16ToUnipolar(uint16_t sample) { +extern inline float sig_uint16ToUnipolar(uint16_t sample) { float normalized = (float) (sample / 65535.0f); return normalized; } -inline float sig_invUint16ToBipolar(uint16_t sample) { +extern inline float sig_invUint16ToBipolar(uint16_t sample) { return -sig_uint16ToBipolar(sample); } @@ -922,7 +922,7 @@ inline float sig_DelayLine_allpass(struct sig_DelayLine* self, float sample, } inline float sig_DelayLine_linearAllpass(struct sig_DelayLine* self, - float sample, size_t readPos, float g) { + float sample, float readPos, float g) { sig_DelayLine_allpass_IMPL(self, sample, readPos, g, sig_DelayLine_linearReadAt); } @@ -3114,8 +3114,8 @@ void sig_dsp_TiltEQ_init(struct sig_dsp_TiltEQ* self, void sig_dsp_TiltEQ_generate(void* signal) { struct sig_dsp_TiltEQ* self = (struct sig_dsp_TiltEQ*) signal; - float amp = 8.656170; // 6.0f / log(2) - float gfactor = 5.0; // Proportional gain. + float amp = 8.656170f; // 6.0f / log(2) + float gfactor = 5.0f; // Proportional gain. float sr3 = self->sr3; float lpOut = self->lpOut; @@ -3328,7 +3328,7 @@ void sig_dsp_Comb_generate(void* signal) { readPos = maxDelayLength - 1; } - delayTime = sig_fmaxf(delayTime, 0.00001); // Delay time can't be zero. + delayTime = sig_fmaxf(delayTime, 0.00001f); // Delay time can't be zero. float read = sig_DelayLine_linearReadAt(self->delayLine, readPos); float outputSample = sig_filter_smooth(read, self->previousSample, lpfCoefficient); diff --git a/libsignaletic/tests/test-libsignaletic.c b/libsignaletic/tests/test-libsignaletic.c index 677c9e2..2245e78 100644 --- a/libsignaletic/tests/test-libsignaletic.c +++ b/libsignaletic/tests/test-libsignaletic.c @@ -211,7 +211,7 @@ void test_sig_fillWithSilence(void) { testAssertBufferIsSilent(&allocator, buffer, 16); } -void test_sig_AudioSettings_new() { +void test_sig_AudioSettings_new(void) { struct sig_AudioSettings* s = sig_AudioSettings_new(&allocator); TEST_ASSERT_EQUAL_FLOAT_MESSAGE(sig_DEFAULT_AUDIOSETTINGS.sampleRate, @@ -226,7 +226,7 @@ void test_sig_AudioSettings_new() { sig_AudioSettings_destroy(&allocator, s); } -void test_sig_samplesToSeconds() { +void test_sig_samplesToSeconds(void) { struct sig_AudioSettings* s = sig_AudioSettings_new(&allocator); size_t expected = 48000; @@ -787,17 +787,17 @@ void testClockDetector_SingleWaveform(sig_waveform_generator waveform, WaveformPlayer_destroy(clockPlayer); } -void test_sig_dsp_ClockDetector_square() { +void test_sig_dsp_ClockDetector_square(void) { // Square wave, 2Hz for two seconds. testClockDetector_SingleWaveform(sig_waveform_square, 2.0f, 2.0f); } -void test_sig_dsp_ClockDetector_sine() { +void test_sig_dsp_ClockDetector_sine(void) { // Sine wave, 10 Hz. testClockDetector_SingleWaveform(sig_waveform_sine, 2.0f, 10.0f); } -void test_sig_dsp_ClockDetector_slowDown() { +void test_sig_dsp_ClockDetector_slowDown(void) { float bufferDuration = 2.0f; size_t bufferLen = (size_t) (audioSettings->sampleRate * bufferDuration); size_t halfBufferLen = bufferLen / 2; @@ -827,14 +827,14 @@ void test_sig_dsp_ClockDetector_slowDown() { sig_test_BufferPlayer_destroy(&allocator, clockPlayer); } -void test_sig_dsp_ClockDetector_stop() { +void test_sig_dsp_ClockDetector_stop(void) { float bufferDuration = 122.0f; float clockDuration = 1.0f; size_t bufferLen = (size_t) (audioSettings->sampleRate * bufferDuration); size_t clockSectionLen = (size_t) (audioSettings->sampleRate * clockDuration); size_t silentSectionLen = (size_t) - audioSettings->sampleRate * (bufferDuration - clockDuration); + (audioSettings->sampleRate * (bufferDuration - clockDuration)); float clockFreq = 10.0f; struct sig_Buffer* waveformBuffer = sig_Buffer_new(&allocator, bufferLen);