diff --git a/source/olcSoundWaveEngine.vcxproj b/source/olcSoundWaveEngine.vcxproj index 5ca0955..adf0916 100644 --- a/source/olcSoundWaveEngine.vcxproj +++ b/source/olcSoundWaveEngine.vcxproj @@ -1,245 +1,253 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {4ae3b973-fddc-4efe-8955-299b51dfd990} - olcSoundWaveEngine - 10.0 - - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpp17 - - - Console - true - - - - - - - - - - - ..\Demos\HeaderMaker.exe olc_swe_template.h olcSoundWaveEngine.h - - - Creating Deployable Single Header - olcSoundWaveEngine.h - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpp17 - - - Console - true - true - true - - - - - - - - - - - ..\Demos\HeaderMaker.exe olc_swe_template.h olcSoundWaveEngine.h - - - Creating Deployable Single Header - olcSoundWaveEngine.h - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpp17 - - - Console - true - - - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {4ae3b973-fddc-4efe-8955-299b51dfd990} + olcSoundWaveEngine + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + + + Console + true + + + + + + + + + + + ..\Demos\HeaderMaker.exe olc_swe_template.h olcSoundWaveEngine.h + + + Creating Deployable Single Header - olcSoundWaveEngine.h + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + + + Console + true + true + true + + + + + + + + + + + ..\Demos\HeaderMaker.exe olc_swe_template.h olcSoundWaveEngine.h + + + Creating Deployable Single Header - olcSoundWaveEngine.h + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + + + Console + true + + + + + + + + + + ..\Demos\HeaderMaker.exe olc_swe_template.h olcSoundWaveEngine.h -copy olcSoundWaveEngine.h ..\olcSoundWaveEngine.h - - - Creating Deployable Single Header - olcSoundWaveEngine.h - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpp17 - - - Console - true - true - true - - - - - - - - - - - ..\Demos\HeaderMaker.exe olc_swe_template.h olcSoundWaveEngine.h - - - Creating Deployable Single Header - olcSoundWaveEngine.h - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +copy olcSoundWaveEngine.h ..\olcSoundWaveEngine.h + + + Creating Deployable Single Header - olcSoundWaveEngine.h + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + + + Console + true + true + true + + + + + + + + + + + ..\Demos\HeaderMaker.exe olc_swe_template.h olcSoundWaveEngine.h + + + Creating Deployable Single Header - olcSoundWaveEngine.h + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/source/olcSoundWaveEngine.vcxproj.filters b/source/olcSoundWaveEngine.vcxproj.filters index 22e1b1e..55f2686 100644 --- a/source/olcSoundWaveEngine.vcxproj.filters +++ b/source/olcSoundWaveEngine.vcxproj.filters @@ -1,123 +1,147 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + \ No newline at end of file diff --git a/source/swe_synth_delay.cpp b/source/swe_synth_delay.cpp new file mode 100644 index 0000000..cfffbb8 --- /dev/null +++ b/source/swe_synth_delay.cpp @@ -0,0 +1,23 @@ +#pragma once +#include "swe_synth_delay.h" + + +namespace olc::sound::synth +{ + ///[OLC_HM] START SYNTH_DELAY_CPP + namespace modules + { + template + void Delay::Update(uint32_t nChannel, double dTime, double dTimeStep) + { + state[input_index] = input.value * decay.value; + input_index = (input_index + 1) % state.size(); + + //Determine where we should sample from based on the desired delay amount + size_t out_dist = std::min(state.size() - 1, static_cast(delay.value * max_delay * samplerate)); + output_index = (input_index - out_dist + state.size()) % state.size(); + output = state[output_index]; + } + } + ///[OLC_HM] END SYNTH_DELAY_CPP +} diff --git a/source/swe_synth_delay.h b/source/swe_synth_delay.h new file mode 100644 index 0000000..b3471fb --- /dev/null +++ b/source/swe_synth_delay.h @@ -0,0 +1,26 @@ +#pragma once +#include "swe_prefix.h" +#include "swe_synth_modular.h" + +namespace olc::sound::synth +{ + ///[OLC_HM] START SYNTH_DELAY_H + namespace modules + { + template + class Delay : public olc::sound::synth::Module { + public: + olc::sound::synth::Property input = 0.0; + olc::sound::synth::Property output = 0.0; + olc::sound::synth::Property decay = 1.0; + olc::sound::synth::Property delay = 1.0; + std::array state{0.0}; + virtual void Update(uint32_t nChannel, double dTime, double dTimeStep) override; + private: + double max_delay = static_cast(max_ms) / 1000.0; + size_t input_index = 0; + size_t output_index = 1; + }; + } + ///[OLC_HM] END SYNTH_DELAY_H +} diff --git a/source/swe_synth_first_order_filter.cpp b/source/swe_synth_first_order_filter.cpp new file mode 100644 index 0000000..9d5b4e9 --- /dev/null +++ b/source/swe_synth_first_order_filter.cpp @@ -0,0 +1,18 @@ +#pragma once +#include "swe_synth_first_order_filter.h" + + +namespace olc::sound::synth +{ + ///[OLC_HM] START SYNTH_FIRST_ORDER_FILTER_CPP + namespace modules + { + void FirstOrderFilter::Update(uint32_t nChannel, double dTime, double dTimeStep) + { + double new_state = input.value + pole.value * state.value; + output = new_state - zero.value * state.value; + state = new_state; + } + } + ///[OLC_HM] END SYNTH_FIRST_ORDER_FILTER_CPP +} \ No newline at end of file diff --git a/source/swe_synth_first_order_filter.h b/source/swe_synth_first_order_filter.h new file mode 100644 index 0000000..66fe329 --- /dev/null +++ b/source/swe_synth_first_order_filter.h @@ -0,0 +1,22 @@ +#pragma once +#include "swe_prefix.h" +#include "swe_synth_modular.h" + +namespace olc::sound::synth +{ + ///[OLC_HM] START SYNTH_FIRST_ORDER_FILTER_H + namespace modules + { + class FirstOrderFilter : public olc::sound::synth::Module { + public: + FirstOrderFilter(double p, double z) : pole(p), zero(z) {}; + olc::sound::synth::Property pole; + olc::sound::synth::Property zero; + olc::sound::synth::Property state = 0.0; + olc::sound::synth::Property input = 0.0; + olc::sound::synth::Property output = 0.0; + virtual void Update(uint32_t nChannel, double dTime, double dTimeStep) override; + }; + } + ///[OLC_HM] END SYNTH_FIRST_ORDER_FILTER_H +} \ No newline at end of file diff --git a/source/swe_synth_n_mixer.cpp b/source/swe_synth_n_mixer.cpp new file mode 100644 index 0000000..aaa2b24 --- /dev/null +++ b/source/swe_synth_n_mixer.cpp @@ -0,0 +1,23 @@ +#pragma once +#include "swe_synth_n_mixer.h" + + +namespace olc::sound::synth +{ + ///[OLC_HM] START SYNTH_N_MIXER_CPP + namespace modules + { + template + void Mixer::Update(uint32_t nChannel, double dTime, double dTimeStep) + { + double out = 0.0; + + for (size_t i = 0; i < N; i++) { + out += amplitude[i].value * inputs[i].value; + } + + output = out / N; + } + } + ///[OLC_HM] END SYNTH_N_MIXER_CPP +} \ No newline at end of file diff --git a/source/swe_synth_n_mixer.h b/source/swe_synth_n_mixer.h new file mode 100644 index 0000000..1cbfd31 --- /dev/null +++ b/source/swe_synth_n_mixer.h @@ -0,0 +1,23 @@ +#pragma once +#include "swe_prefix.h" +#include "swe_synth_modular.h" + +namespace olc::sound::synth +{ + ///[OLC_HM] START SYNTH_N_MIXER_H + namespace modules + { + template + class Mixer : public Module + { + public: + std::array inputs = {}; + std::array amplitude = {}; + Property output; + + virtual void Update(uint32_t nChannel, double dTime, double dTimeStep) override; + + }; + } + ///[OLC_HM] END SYNTH_N_MIXER_H +} \ No newline at end of file diff --git a/source/swe_synth_pinkifier.cpp b/source/swe_synth_pinkifier.cpp new file mode 100644 index 0000000..97a3b27 --- /dev/null +++ b/source/swe_synth_pinkifier.cpp @@ -0,0 +1,22 @@ +#pragma once +#include "swe_synth_pinkifier.h" + + +namespace olc::sound::synth +{ + ///[OLC_HM] START SYNTH_PINKIFIER_CPP + namespace modules + { + void Pinkifier::Update(uint32_t nChannel, double dTime, double dTimeStep) + { + f1.input = input; + f1.Update(nChannel, dTime, dTimeStep); + f2.input = f1.output; + f2.Update(nChannel, dTime, dTimeStep); + f3.input = f2.output; + f3.Update(nChannel, dTime, dTimeStep); + output = f3.output; + } + } + ///[OLC_HM] END SYNTH_PINKIFIER_CPP +} \ No newline at end of file diff --git a/source/swe_synth_pinkifier.h b/source/swe_synth_pinkifier.h new file mode 100644 index 0000000..9955616 --- /dev/null +++ b/source/swe_synth_pinkifier.h @@ -0,0 +1,23 @@ +#pragma once +#include "swe_prefix.h" +#include "swe_synth_modular.h" +#include "swe_synth_first_order_filter.h" + +namespace olc::sound::synth +{ + ///[OLC_HM] START SYNTH_PINKIFIER_H + namespace modules + { + class Pinkifier : public olc::sound::synth::Module { + FirstOrderFilter f1 = { 0.99572754 , 0.98443604}; + FirstOrderFilter f2 = { 0.94790649 , 0.83392334 }; + FirstOrderFilter f3 = { 0.53567505 , 0.07568359 }; + + public: + olc::sound::synth::Property input = 0.0; + olc::sound::synth::Property output = 0.0; + virtual void Update(uint32_t nChannel, double dTime, double dTimeStep) override; + }; + } + ///[OLC_HM] END SYNTH_PINKIFIER_H +} \ No newline at end of file