diff --git a/CMakeLists.txt b/CMakeLists.txt index 638bf8f..6417fd3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,8 @@ set(CLANG_TIDY_COMMAND "${CLANG_TIDY_EXE}") set(CMAKE_OSX_DEPLOYMENT_TARGET "13") set(CLANG_COMPILER_OPTION ${CLANG_COMPILER_OPTION} -Wall -Wpedantic -Werror) -set(MSVC_COMPILER_OPTION /W4 /WX /analyze) +set(MSVC_COMPILER_OPTION /W4 /analyze) +set(GCC_COMPILER_OPTION ${CLANG_COMPILER_OPTION}) include_directories(include) diff --git a/include/bowed_string.h b/include/bowed_string.h index 4fa05a4..5643ac2 100644 --- a/include/bowed_string.h +++ b/include/bowed_string.h @@ -83,7 +83,7 @@ class BowedString /// @brief Tick the string. /// @param input Energy coming from the bridge. Optional. /// @return The output sample at the bridge. - float Tick(float input = 0.f); + float Tick(float input); /// @brief Set the finger pressure. /// @param pressure 0 is no pressure, 1 is full pressure. @@ -105,6 +105,7 @@ class BowedString float samplerate_; float freq_; float velocity_ = 0.f; + float bow_force_ = 0.f; bool note_on_ = false; constexpr static float max_velocity_ = 0.2f; @@ -112,5 +113,10 @@ class BowedString OnePoleFilter decay_filter_; OnePoleFilter noise_lp_filter_; + + // Smoothing filters + OnePoleFilter velocity_filter_; + OnePoleFilter force_filter_; + OnePoleFilter bow_position_filter_; }; } // namespace sfdsp \ No newline at end of file diff --git a/include/string_ensemble.h b/include/string_ensemble.h index a912a4a..2d34b2a 100644 --- a/include/string_ensemble.h +++ b/include/string_ensemble.h @@ -23,36 +23,6 @@ class StringEnsemble void TuneStrings(uint8_t string_num, float frequencies); - /// @brief Set the frequency of the string - /// @param string_number The string number to set the frequency of - /// @param f The frequency of the string in Hz - void SetFrequency(uint8_t string_number, float f); - - /// @brief Returns the frequency of the string in Hz - /// @param string_number The string number to get the frequency of - /// @return The frequency of the string in Hz - float GetFrequency(uint8_t string_number) const; - - /// @brief Set the velocity of the bow for a given string - /// @param string_number The string number to set the velocity of - /// @param v The velocity of the bow for the given string - void SetVelocity(uint8_t string_number, float v); - - /// @brief Get the velocity of the bow for a given string - /// @param string_number The string number to get the velocity of - /// @return The velocity of the bow for the given string - float GetVelocity(uint8_t string_number) const; - - /// @brief Set the force of the bow for a given string - /// @param string_number The string number to set the force of - /// @param f The force of the bow for the given string - void SetForce(uint8_t string_number, float f); - - /// @brief Get the force of the bow for a given string - /// @param string_number The string number to get the force of - /// @return The force of the bow for the given string - float GetForce(uint8_t string_number) const; - /// @brief Lift the finger off the string. Pitch of the string goes back to the open string pitch. /// @param string_number void FingerOff(uint8_t string_number); @@ -61,10 +31,18 @@ class StringEnsemble /// @param t void SetBridgeTransmission(float t); + float GetBridgeTransmission() const; + float Tick(); + void ProcessBlock(float* out, size_t size); + + const BowedString& operator[](uint8_t string_number) const; + + BowedString& operator[](uint8_t string_number); + private: - std::array strings_; + std::array strings_; std::array openTuning_; float bridgeTransmission_ = 0.1f; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 67c8940..8f2565c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,8 +21,11 @@ add_library(dsp STATIC ${LIB_SOURCES}) target_include_directories(dsp PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) -if(NOT MSVC) +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") target_compile_options(dsp PRIVATE ${CLANG_COMPILER_OPTION}) -else() +elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") target_compile_options(dsp PRIVATE ${MSVC_COMPILER_OPTION}) +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + MESSAGE("GNU") + target_compile_options(dsp PRIVATE ${GCC_COMPILER_OPTION}) endif() diff --git a/src/basic_oscillators.cpp b/src/basic_oscillators.cpp index cfaca1a..e4c192a 100644 --- a/src/basic_oscillators.cpp +++ b/src/basic_oscillators.cpp @@ -10,6 +10,10 @@ namespace sfdsp float Sine(float phase) { + while (phase < 0.f) + { + phase += 1.f; + } phase = std::fmod(phase, 1.f); float idx = phase * SIN_LUT_SIZE; int idx0 = static_cast(idx); diff --git a/src/bowed_string.cpp b/src/bowed_string.cpp index fd46bb1..b5a0e0b 100644 --- a/src/bowed_string.cpp +++ b/src/bowed_string.cpp @@ -36,6 +36,13 @@ void BowedString::Init(float samplerate, float tuning) decay_filter_.SetGain(1.f); noise_lp_filter_.SetPole(0.8f); + + // Smoothing filter + constexpr float smoothingDb = -24.f; + constexpr float smoothingTimeMs = 10.f; + velocity_filter_.SetDecayFilter(smoothingDb, smoothingTimeMs, samplerate); + force_filter_.SetDecayFilter(smoothingDb, smoothingTimeMs, samplerate); + bow_position_filter_.SetDecayFilter(smoothingDb, smoothingTimeMs, samplerate); } void BowedString::SetFrequency(float f) @@ -74,12 +81,12 @@ void BowedString::SetVelocity(float v) void BowedString::SetForce(float f) { - bow_table_.SetForce(f); + bow_force_ = f; } float BowedString::GetForce() const { - return bow_table_.GetForce(); + return bow_force_; } void BowedString::SetBowPosition(float pos) @@ -136,6 +143,9 @@ float BowedString::NextOut() float BowedString::Tick(float input) { + float vel = velocity_filter_.Tick(velocity_); + bow_table_.SetForce(force_filter_.Tick(bow_force_)); + float bridge, nut; waveguide_.NextOut(nut, bridge); @@ -145,7 +155,7 @@ float BowedString::Tick(float input) float bow_output = 0.f; if (note_on_) { - float velocity_delta = velocity_ - (vsl_plus + vsr_plus); + float velocity_delta = vel - (vsl_plus + vsr_plus); constexpr float noise_db = -30; const float noise_gain = std::pow(10.f, noise_db / 20.f); diff --git a/src/string_ensemble.cpp b/src/string_ensemble.cpp index 39a4d52..001e0e1 100644 --- a/src/string_ensemble.cpp +++ b/src/string_ensemble.cpp @@ -1,12 +1,10 @@ #include "string_ensemble.h" -#include - using namespace sfdsp; void StringEnsemble::Init(float samplerate, const std::array& frequencies) { - for (auto i = 0; i < kStringCount; ++i) + for (size_t i = 0; i < kStringCount; ++i) { strings_[i].Init(samplerate, frequencies[i]); } @@ -32,95 +30,73 @@ void StringEnsemble::TuneStrings(uint8_t string_number, float frequencies) strings_[string_number].SetFrequency(frequencies); } -void StringEnsemble::SetFrequency(uint8_t string_number, float f) +void StringEnsemble::FingerOff(uint8_t string_number) { assert(string_number < kStringCount); - assert(f > 0.f); - strings_[string_number].SetFrequency(f); + + strings_[string_number].SetFrequency(openTuning_[string_number]); } -float StringEnsemble::GetFrequency(uint8_t string_number) const +void StringEnsemble::SetBridgeTransmission(float t) { - assert(string_number < kStringCount); + assert(t >= 0.f && t <= 1.f); - return strings_[string_number].GetFrequency(); + bridgeTransmission_ = t; } -void StringEnsemble::SetVelocity(uint8_t string_number, float v) +float StringEnsemble::GetBridgeTransmission() const { - assert(string_number < kStringCount); - - strings_[string_number].SetVelocity(v); + return bridgeTransmission_; } -float StringEnsemble::GetVelocity(uint8_t string_number) const +float StringEnsemble::Tick() { - assert(string_number < kStringCount); - - return strings_[string_number].GetVelocity(); + float out = 0; + ProcessBlock(&out, 1); + return out; } -void StringEnsemble::SetForce(uint8_t string_number, float f) +void StringEnsemble::ProcessBlock(float* out, size_t size) { - assert(string_number < kStringCount); - - strings_[string_number].SetForce(f); + assert(out != nullptr); - if (f > 0.f) + for (size_t i = 0; i < size; ++i) { - strings_[string_number].SetNoteOn(true); - } - else - { - strings_[string_number].SetNoteOn(false); + std::array string_outs; + + float transmission = 0.f; + float output = 0.f; + for (size_t j = 0; i < kStringCount; ++j) + { + string_outs[j] = strings_[j].NextOut(); + output += string_outs[j]; + transmission += string_outs[j] * bridgeTransmission_; + string_outs[j] *= (1.f - bridgeTransmission_); + } + + // filter the bridge output + transmission = transmission_filter_.Tick(transmission) * 0.25f; + + for (size_t j = 0; i < kStringCount; ++j) + { + strings_[j].Tick(string_outs[j] + transmission); + } + + out[i] = 0.1248f * body_filters_[5].Tick(body_filters_[4].Tick(body_filters_[3].Tick( + body_filters_[2].Tick(body_filters_[1].Tick(body_filters_[0].Tick(output)))))); } } -float StringEnsemble::GetForce(uint8_t string_number) const +const BowedString& StringEnsemble::operator[](uint8_t string_number) const { assert(string_number < kStringCount); - return strings_[string_number].GetForce(); + return strings_[string_number]; } -void StringEnsemble::FingerOff(uint8_t string_number) +BowedString& StringEnsemble::operator[](uint8_t string_number) { assert(string_number < kStringCount); - strings_[string_number].SetFrequency(openTuning_[string_number]); -} - -void StringEnsemble::SetBridgeTransmission(float t) -{ - assert(t >= 0.f && t <= 1.f); - - bridgeTransmission_ = t; -} - -float StringEnsemble::Tick() -{ - std::array string_outs; - - float transmission = 0.f; - float output = 0.f; - for (auto i = 0; i < kStringCount; ++i) - { - string_outs[i] = strings_[i].NextOut(); - output += string_outs[i]; - transmission += string_outs[i] * bridgeTransmission_; - string_outs[i] *= (1.f - bridgeTransmission_); - } - - // filter the bridge output - transmission = transmission_filter_.Tick(transmission) * 0.25f; - - for (size_t i = 0; i < kStringCount; ++i) - { - strings_[i].Tick(string_outs[i] + transmission); - } - - float out = 0.1248f * body_filters_[5].Tick(body_filters_[4].Tick(body_filters_[3].Tick( - body_filters_[2].Tick(body_filters_[1].Tick(body_filters_[0].Tick(output)))))); - - return out; + return strings_[string_number]; } diff --git a/src/waveguide_gate.cpp b/src/waveguide_gate.cpp index 4704f09..2c1069a 100644 --- a/src/waveguide_gate.cpp +++ b/src/waveguide_gate.cpp @@ -46,16 +46,6 @@ void WaveguideGate::SetCoeff(float c) coeff_ = c; } -void PrintDelayline(const sfdsp::Delayline& line) -{ - printf(" "); - for (auto i = 0; i < 4; ++i) - { - printf("%5.2f ", line[i + 1]); - } - printf("\n"); -} - void WaveguideGate::Process(Delayline& left_traveling_line, Delayline& right_traveling_line) { if (delay_ == 0 || delay_ >= left_traveling_line.GetDelay() - 2) diff --git a/tests/basic_oscillators_tests.cpp b/tests/basic_oscillators_tests.cpp index 6cb304f..6e06a1b 100644 --- a/tests/basic_oscillators_tests.cpp +++ b/tests/basic_oscillators_tests.cpp @@ -11,7 +11,7 @@ TEST(BasicOscillatorsTest, Sine) { float inc = 1.f / 1024; - for (auto i = 0.f; i < TWO_PI; i += inc) + for (auto i = -TWO_PI; i < TWO_PI * 4; i += inc) { auto s = sfdsp::Sine(i); auto t = std::sin(i * TWO_PI); diff --git a/tests/rms_tests.cpp b/tests/rms_tests.cpp index bda32ef..54af076 100644 --- a/tests/rms_tests.cpp +++ b/tests/rms_tests.cpp @@ -25,7 +25,7 @@ TEST_P(RMSTest, PureSine) float phase = 0.f; - for (auto i = 0; i < kLoopLength; i++) + for (size_t i = 0; i < kLoopLength; i++) { auto s = kAmplitude * std::sin(phase * TWO_PI); phase = std::fmod(phase + kPhaseInc, 1.f); diff --git a/tests/test_utils.cpp b/tests/test_utils.cpp index 6e30cd5..3215d46 100644 --- a/tests/test_utils.cpp +++ b/tests/test_utils.cpp @@ -1,5 +1,7 @@ #include "test_utils.h" +#include + void PrintWaveguide(sfdsp::Waveguide& wave, size_t delay_size) { std::vector right_samples, left_samples; diff --git a/tests/waveguide_gates_tests.cpp b/tests/waveguide_gates_tests.cpp index 65cc1bb..cf6b2da 100644 --- a/tests/waveguide_gates_tests.cpp +++ b/tests/waveguide_gates_tests.cpp @@ -28,7 +28,7 @@ TEST(WaveguideGatesTest, OpenGates) sfdsp::WaveguideGate gate(true, kGatePos, kCoeff); // Looping for 2 * kDelay should bring us back to initial state - for (auto i = 0; i < kDelay * 2; ++i) + for (size_t i = 0; i < kDelay * 2; ++i) { gate.Process(left_traveling_line, right_traveling_line); @@ -39,7 +39,7 @@ TEST(WaveguideGatesTest, OpenGates) right_traveling_line.Tick(left_sample * -1.f); } - for (auto i = 1; i <= kDelaySize; ++i) + for (size_t i = 1; i <= kDelaySize; ++i) { if (i == 2) { @@ -77,7 +77,7 @@ TEST(WaveguideGatesTest, HalfOpenGates) sfdsp::WaveguideGate gate(true, kGatePos, kCoeff); // Looping for 2 * kDelay should bring us back to initial state - for (auto i = 0; i < kDelay * 2; ++i) + for (size_t i = 0; i < kDelay * 2; ++i) { gate.Process(left_traveling_line, right_traveling_line); @@ -87,12 +87,12 @@ TEST(WaveguideGatesTest, HalfOpenGates) left_traveling_line.Tick(right_sample * -1.f); right_traveling_line.Tick(left_sample * -1.f); - printf("Iteration %d\n", i); + printf("Iteration %zu\n", i); PrintDelayline(right_traveling_line); PrintDelayline(left_traveling_line); } - for (auto i = 1; i <= kDelaySize; ++i) + for (size_t i = 1; i <= kDelaySize; ++i) { if (i == 2 || i == 9) { @@ -133,7 +133,7 @@ TEST(WaveguideGatesTest, ClosedGates) sfdsp::WaveguideGate gate(true, kGatePos, kCoeff); // Looping for kDelay should bring us back to initial state - for (auto i = 0; i < kDelay; ++i) + for (size_t i = 0; i < kDelay; ++i) { gate.Process(left_traveling_line, right_traveling_line); @@ -143,12 +143,12 @@ TEST(WaveguideGatesTest, ClosedGates) left_traveling_line.Tick(right_sample * -1.f); right_traveling_line.Tick(left_sample * -1.f); - printf("Iteration %d\n", i); + printf("Iteration %zu\n", i); PrintDelayline(right_traveling_line); PrintDelayline(left_traveling_line); } - for (auto i = 1; i <= kDelaySize; ++i) + for (size_t i = 1; i <= kDelaySize; ++i) { if (i == 2 || i == 8) { @@ -189,7 +189,7 @@ TEST(WaveguideGatesTest, FractionalGates) sfdsp::WaveguideGate gate(true, kGatePos, kCoeff); // Looping for kGatePos*2 should bring us back to initial state - for (auto i = 0; i < kGatePos * 2; ++i) + for (size_t i = 0; i < kGatePos * 2; ++i) { gate.Process(left_traveling_line, right_traveling_line); @@ -199,7 +199,7 @@ TEST(WaveguideGatesTest, FractionalGates) left_traveling_line.Tick(right_sample * -1.f); right_traveling_line.Tick(left_sample * -1.f); - printf("Iteration %d\n", i); + printf("Iteration %zu\n", i); PrintDelayline(right_traveling_line); PrintDelayline(left_traveling_line); } @@ -236,7 +236,7 @@ TEST(WaveguideGatesTest, MovingGate) PrintDelayline(left_traveling_line); sfdsp::WaveguideGate gate(false, kGatePos, kCoeff); - for (auto i = 0; i < 2; ++i) + for (size_t i = 0; i < 2; ++i) { gate.Process(left_traveling_line, right_traveling_line); @@ -246,7 +246,7 @@ TEST(WaveguideGatesTest, MovingGate) left_traveling_line.Tick(right_sample); right_traveling_line.Tick(left_sample); - printf("Iteration %d\n", i); + printf("Iteration %zu\n", i); PrintDelayline(right_traveling_line); PrintDelayline(left_traveling_line); } @@ -255,7 +255,7 @@ TEST(WaveguideGatesTest, MovingGate) gate.SetDelay(kGatePos + 0.25f); printf("\nMoving the delay\n"); - for (auto i = 0; i < 1; ++i) + for (size_t i = 0; i < 1; ++i) { gate.Process(left_traveling_line, right_traveling_line); @@ -265,14 +265,14 @@ TEST(WaveguideGatesTest, MovingGate) left_traveling_line.Tick(right_sample); right_traveling_line.Tick(left_sample); - printf("Iteration %d\n", i); + printf("Iteration %zu\n", i); PrintDelayline(right_traveling_line); PrintDelayline(left_traveling_line); } gate.SetDelay(kGatePos + 0.5f); printf("\nMoving the delay\n"); - for (auto i = 0; i < 1; ++i) + for (size_t i = 0; i < 1; ++i) { gate.Process(left_traveling_line, right_traveling_line); @@ -282,14 +282,14 @@ TEST(WaveguideGatesTest, MovingGate) left_traveling_line.Tick(right_sample); right_traveling_line.Tick(left_sample); - printf("Iteration %d\n", i); + printf("Iteration %zu\n", i); PrintDelayline(right_traveling_line); PrintDelayline(left_traveling_line); } gate.SetDelay(kGatePos + 0.75f); printf("\nMoving the delay\n"); - for (auto i = 0; i < 1; ++i) + for (size_t i = 0; i < 1; ++i) { gate.Process(left_traveling_line, right_traveling_line); @@ -299,14 +299,14 @@ TEST(WaveguideGatesTest, MovingGate) left_traveling_line.Tick(right_sample); right_traveling_line.Tick(left_sample); - printf("Iteration %d\n", i); + printf("Iteration %zu\n", i); PrintDelayline(right_traveling_line); PrintDelayline(left_traveling_line); } gate.SetDelay(kGatePos + 1.f); printf("\nMoving the delay\n"); - for (auto i = 0; i < 10; ++i) + for (size_t i = 0; i < 10; ++i) { gate.Process(left_traveling_line, right_traveling_line); @@ -316,7 +316,7 @@ TEST(WaveguideGatesTest, MovingGate) left_traveling_line.Tick(right_sample); right_traveling_line.Tick(left_sample); - printf("Iteration %d\n", i); + printf("Iteration %zu\n", i); PrintDelayline(right_traveling_line); PrintDelayline(left_traveling_line); } @@ -362,7 +362,7 @@ TEST(DISABLED_WaveguideGatesTest, SineWave) std::array output; float currentGatePos = kGatePos; - for (auto i = 0; i < outSize; ++i) + for (size_t i = 0; i < outSize; ++i) { if (currentGatePos >= 12.f) { @@ -393,7 +393,7 @@ TEST(DISABLED_WaveguideGatesTest, SineWave) left_traveling_line.Tick(x); output[i] = right_traveling_line.NextOut(); - // printf("Iteration %d, gatePos: %f\n", i, currentGatePos); + // printf("Iteration %zu, gatePos: %f\n", i, currentGatePos); // PrintDelayline(right_traveling_line); // PrintDelayline(left_traveling_line); } diff --git a/tests/waveguide_tests.cpp b/tests/waveguide_tests.cpp index 6600d3c..331a198 100644 --- a/tests/waveguide_tests.cpp +++ b/tests/waveguide_tests.cpp @@ -203,7 +203,7 @@ TEST(WaveguideTests, GainTest) // Left Right // ▲ -6 -5 -4 -3 -2 -1 ◀ - for (int i = 1; i <= DELAY_SIZE; ++i) + for (size_t i = 1; i <= DELAY_SIZE; ++i) { float out = wave.TapOut(i); ASSERT_THAT(out, ::testing::Eq(-1 * (input[DELAY_SIZE - i] * 2))); @@ -221,7 +221,7 @@ TEST(WaveguideTests, GainTest) // Left Right // ▲ 1 2 3 4 5 6 ◀ - for (int i = 1; i <= DELAY_SIZE; ++i) + for (size_t i = 1; i <= DELAY_SIZE; ++i) { float out = wave.TapOut(i); ASSERT_THAT(out, ::testing::Eq(input[i - 1] * 2)); diff --git a/tools/arpegiator.h b/tools/arpegiator.h index 878b55c..9b1049d 100644 --- a/tools/arpegiator.h +++ b/tools/arpegiator.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include diff --git a/tools/bowedstring_tests.cpp b/tools/bowedstring_tests.cpp index dbb01b2..1c5e190 100644 --- a/tools/bowedstring_tests.cpp +++ b/tools/bowedstring_tests.cpp @@ -6,7 +6,7 @@ void SimpleBowedString::Init(size_t samplerate) { samplerate_ = samplerate; string_.Init(static_cast(samplerate)); - string_.SetFrequency(392.f); + string_.SetFrequency(220.f); string_.SetForce(0.5f); string_.SetVelocity(1.f); string_.SetNoteOn(true); @@ -16,7 +16,8 @@ void SimpleBowedString::Init(size_t samplerate) float SimpleBowedString::Tick() { - return string_.Tick(); + float bridge = string_.NextOut(); + return string_.Tick(bridge); } float SimpleBowedString::Tick(float) @@ -60,7 +61,8 @@ float CrescendoBowedStringTester::Tick() ++current_frame_; string_.SetVelocity(current_velocity_); string_.SetForce(current_force_); - return string_.Tick(); + float bridge = string_.NextOut(); + return string_.Tick(bridge); } float CrescendoBowedStringTester::Tick(float) @@ -93,7 +95,9 @@ float OscVelocityBowedStringTester::Tick() string_.SetVelocity(param); string_.SetForce(param); - return string_.Tick(); + + float bridge = string_.NextOut(); + return string_.Tick(bridge); } float OscVelocityBowedStringTester::Tick(float) @@ -130,7 +134,8 @@ float PitchSlideBowedStringTester::Tick() } ++current_frame_; - return string_.Tick(); + float bridge = string_.NextOut(); + return string_.Tick(bridge); } float PitchSlideBowedStringTester::Tick(float) @@ -161,7 +166,8 @@ float VibratoBowedStringTester::Tick() phase_ += phase_dt_; string_.SetFrequency(freq); - return string_.Tick(); + float bridge = string_.NextOut(); + return string_.Tick(bridge); } float VibratoBowedStringTester::Tick(float) @@ -220,7 +226,8 @@ float ScaleBowedStringTester::Tick() } ++current_frame_; - return string_.Tick(); + float bridge = string_.NextOut(); + return string_.Tick(bridge); } float ScaleBowedStringTester::Tick(float) @@ -263,7 +270,8 @@ float FingerPressBowedStringTester::Tick() string_.SetBowPosition(0.30f); } - return string_.Tick(); + float bridge = string_.NextOut(); + return string_.Tick(bridge); } float FingerPressBowedStringTester::Tick(float) diff --git a/tools/phaseshapers_tests.cpp b/tools/phaseshapers_tests.cpp index 9f9fe3f..bb7c7c7 100644 --- a/tools/phaseshapers_tests.cpp +++ b/tools/phaseshapers_tests.cpp @@ -5,10 +5,10 @@ void PhaseShaperTest::Init(size_t samplerate) samplerate_ = samplerate; phaseshaper_.Init(static_cast(samplerate)); phaseshaper_.SetWaveform(current_waveform_); - phaseshaper_.SetMod(0.f); + phaseshaper_.SetMod(0.5f); phaseshaper_.SetFreq(220.f); - frame_per_wave_ = (samplerate / 220) * 8; + frame_per_wave_ = samplerate_; // 4 periods per waveform frame_count_ = frame_per_wave_ * static_cast(sfdsp::Phaseshaper::Waveform::NUM_WAVES); name_ = "phaseshaper.wav"; diff --git a/tools/player/CMakeLists.txt b/tools/player/CMakeLists.txt index 38fbe03..00886a9 100644 --- a/tools/player/CMakeLists.txt +++ b/tools/player/CMakeLists.txt @@ -17,5 +17,5 @@ set_target_properties(player PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}") if(NOT MSVC) target_compile_options(player PRIVATE ${CLANG_COMPILER_OPTION}) else() - target_compile_options(dsp PRIVATE /W4 /WX) + target_compile_options(dsp PRIVATE ${MSVC_COMPILER_OPTION}) endif() diff --git a/tools/stringensemble_tests.cpp b/tools/stringensemble_tests.cpp index 920443b..7c436d9 100644 --- a/tools/stringensemble_tests.cpp +++ b/tools/stringensemble_tests.cpp @@ -3,8 +3,8 @@ void StringEnsembleTest::Init(size_t samplerate) { ensemble_.Init(static_cast(samplerate), sfdsp::kDefaultFrequencies); - ensemble_.SetForce(2, 0.05f); - ensemble_.SetVelocity(2, 0.5f); + ensemble_[2].SetForce(0.05f); + ensemble_[2].SetVelocity(0.5f); name_ = "stringensemble.wav"; } diff --git a/tools/violonist/violonist.cpp b/tools/violonist/violonist.cpp index 8486efe..60f8a36 100644 --- a/tools/violonist/violonist.cpp +++ b/tools/violonist/violonist.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -29,7 +30,7 @@ constexpr std::array Frequencies{196.f, 293.7f, 440.f, 659.3f, 1567.f}; bool Run(TestConfig config); -int main(int argc, char** argv) +int main(int, char**) { for (auto force : Forces) {