├── Libraries ├── ReadMe.txt ├── clap │ └── include │ │ └── clap │ │ ├── id.h │ │ ├── private │ │ ├── std.h │ │ └── macros.h │ │ ├── color.h │ │ ├── ext │ │ ├── draft │ │ │ ├── preset-load.h │ │ │ ├── check-for-update.h │ │ │ ├── midi-mappings.h │ │ │ ├── track-info.h │ │ │ ├── cv.h │ │ │ ├── quick-controls.h │ │ │ ├── ambisonic.h │ │ │ ├── voice-info.h │ │ │ ├── transport-control.h │ │ │ ├── tuning.h │ │ │ ├── file-reference.h │ │ │ └── surround.h │ │ ├── event-registry.h │ │ ├── tail.h │ │ ├── thread-check.h │ │ ├── latency.h │ │ ├── log.h │ │ ├── timer-support.h │ │ ├── state.h │ │ ├── note-name.h │ │ ├── render.h │ │ ├── posix-fd-support.h │ │ ├── thread-pool.h │ │ ├── audio-ports-config.h │ │ ├── note-ports.h │ │ └── audio-ports.h │ │ ├── fixedpoint.h │ │ ├── string-sizes.h │ │ ├── stream.h │ │ ├── version.h │ │ ├── audio-buffer.h │ │ ├── host.h │ │ ├── plugin-factory.h │ │ ├── plugin-invalidation.h │ │ ├── process.h │ │ ├── clap.h │ │ ├── entry.h │ │ ├── plugin-features.h │ │ └── plugin.h └── vstsdk2.4 │ └── ReadMe.txt ├── Source ├── DSPCode │ ├── GlobalFunctions.cpp │ ├── rosic_RealFunctions.cpp │ ├── rosic_NumberManipulations.h │ ├── rosic_NumberManipulations.cpp │ ├── rosic_FunctionTemplates.cpp │ ├── rosic_EllipticQuarterBandFilter.cpp │ ├── rosic_AcidPattern.cpp │ ├── rosic_MidiNoteEvent.cpp │ ├── rosic_DecayEnvelope.cpp │ ├── rosic_Complex.cpp │ ├── rosic_BlendOscillator.cpp │ ├── rosic_MidiNoteEvent.h │ ├── rosic_AcidSequencer.cpp │ ├── rosic_LeakyIntegrator.cpp │ ├── rosic_LeakyIntegrator.h │ ├── GlobalDefinitions.h │ ├── rosic_TeeBeeFilter.cpp │ ├── rosic_DecayEnvelope.h │ ├── rosic_BiquadFilter.h │ ├── rosic_EllipticQuarterBandFilter.h │ ├── rosic_OnePoleFilter.cpp │ ├── rosic_OnePoleFilter.h │ ├── rosic_AcidPattern.h │ ├── rosic_AnalogEnvelope.cpp │ ├── rosic_BiquadFilter.cpp │ ├── rosic_RealFunctions.h │ ├── rosic_BlendOscillator.h │ ├── rosic_FourierTransformerRadix2.h │ └── rosic_Complex.h └── VSTPlugIn │ ├── StringConversions.c │ └── Open303VST.h ├── Build ├── VisualStudio2008 │ ├── Open303.suo │ ├── Open303.layout │ ├── Open303.sln │ ├── Open303.vcproj.XYZ-3B339B6A6CF.xyz.user │ └── Open303.cbp ├── VisualStudio2019 │ ├── Open303.suo │ ├── Open303.sln │ └── Open303.vcxproj.filters └── CodeBlocks │ ├── Open303.workspace │ ├── Open303.layout │ ├── Open303.cbp │ └── Open303.depend ├── Notes └── ToDo.txt ├── .gitignore ├── ReadMe.md ├── ReadMe.old.txt └── License.txt /Libraries/ReadMe.txt: -------------------------------------------------------------------------------- 1 | Folder for the VST or CLAP SDKs. -------------------------------------------------------------------------------- /Source/DSPCode/GlobalFunctions.cpp: -------------------------------------------------------------------------------- 1 | #include "GlobalFunctions.h" 2 | 3 | 4 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_RealFunctions.cpp: -------------------------------------------------------------------------------- 1 | #include "rosic_RealFunctions.h" 2 | using namespace rosic; 3 | 4 | -------------------------------------------------------------------------------- /Build/VisualStudio2008/Open303.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RobinSchmidt/Open303/HEAD/Build/VisualStudio2008/Open303.suo -------------------------------------------------------------------------------- /Build/VisualStudio2019/Open303.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RobinSchmidt/Open303/HEAD/Build/VisualStudio2019/Open303.suo -------------------------------------------------------------------------------- /Notes/ToDo.txt: -------------------------------------------------------------------------------- 1 | 2 | -Implement CLAP version 3 | -Avoid memory allocation in Open303VST::processEvents 4 | -Clean up the coding style 5 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_NumberManipulations.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RobinSchmidt/Open303/HEAD/Source/DSPCode/rosic_NumberManipulations.h -------------------------------------------------------------------------------- /Source/DSPCode/rosic_NumberManipulations.cpp: -------------------------------------------------------------------------------- 1 | #include "rosic_NumberManipulations.h" 2 | using namespace rosic; 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_FunctionTemplates.cpp: -------------------------------------------------------------------------------- 1 | #include "rosic_FunctionTemplates.h" 2 | using namespace rosic; 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Build/VisualStudio2008/Open303.layout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Build/VisualStudio2008/.vs 2 | Build/VisualStudio2019/.vs 3 | Build/VisualStudio2019/Debug 4 | Build/VisualStudio2019/Release 5 | Libraries/vstsdk2.4/pluginterfaces 6 | Libraries/vstsdk2.4/public.sdk 7 | 8 | 9 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/id.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "private/std.h" 4 | #include "private/macros.h" 5 | 6 | typedef uint32_t clap_id; 7 | 8 | static const CLAP_CONSTEXPR clap_id CLAP_INVALID_ID = UINT32_MAX; 9 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/private/std.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | # include 5 | # include 6 | #else 7 | # include 8 | # include 9 | # include 10 | #endif 11 | -------------------------------------------------------------------------------- /Build/CodeBlocks/Open303.workspace: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /ReadMe.md: -------------------------------------------------------------------------------- 1 | This is a clone and continuation of my old SVN repo here: 2 | 3 | https://sourceforge.net/projects/open303/ 4 | 5 | I initally copied over all the code and am now trying to turn it into a CLAP plugin because VST2 is 6 | now deprecated and this simple GUI-less plugin seems like a good start for learning the new plugin 7 | SDK. -------------------------------------------------------------------------------- /Libraries/clap/include/clap/color.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "private/std.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct clap_color { 10 | uint8_t alpha; 11 | uint8_t red; 12 | uint8_t green; 13 | uint8_t blue; 14 | } clap_color_t; 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/draft/preset-load.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../plugin.h" 4 | 5 | static const char CLAP_EXT_PRESET_LOAD[] = "clap.preset-load.draft/0"; 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | typedef struct clap_plugin_preset_load { 12 | // Loads a preset in the plugin native preset file format from a path. 13 | // [main-thread] 14 | bool (*from_file)(const clap_plugin_t *plugin, const char *path); 15 | } clap_plugin_preset_load_t; 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /Libraries/vstsdk2.4/ReadMe.txt: -------------------------------------------------------------------------------- 1 | If you want to build a VST 2.4 plugin, you will need to put the contents of the vstsdk2.4 folder 2 | from the Steinberg VST SDK into this folder. As of 2022, VST 2.4 is a deprecated legacy plugin 3 | format and the SDK is not available from Steinberg anymore and I am not allowed to redistribute it 4 | as part of this repo. This folder serves as a dummy just so you know where you need to put the 5 | relevant files, in case you happen to have them still lying around somewhere because you are are old 6 | enough for that. 7 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/fixedpoint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "private/std.h" 4 | #include "private/macros.h" 5 | 6 | /// We use fixed point representation of beat time and seconds time 7 | /// Usage: 8 | /// double x = ...; // in beats 9 | /// clap_beattime y = round(CLAP_BEATTIME_FACTOR * x); 10 | 11 | // This will never change 12 | static const CLAP_CONSTEXPR int64_t CLAP_BEATTIME_FACTOR = 1LL << 31; 13 | static const CLAP_CONSTEXPR int64_t CLAP_SECTIME_FACTOR = 1LL << 31; 14 | 15 | typedef int64_t clap_beattime; 16 | typedef int64_t clap_sectime; 17 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/string-sizes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | enum { 8 | // String capacity for names that can be displayed to the user. 9 | CLAP_NAME_SIZE = 256, 10 | 11 | // String capacity for describing a path, like a parameter in a module hierarchy or path within a 12 | // set of nested track groups. 13 | // 14 | // This is not suited for describing a file path on the disk, as NTFS allows up to 32K long 15 | // paths. 16 | CLAP_PATH_SIZE = 1024, 17 | }; 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_EllipticQuarterBandFilter.cpp: -------------------------------------------------------------------------------- 1 | #include "rosic_EllipticQuarterBandFilter.h" 2 | using namespace rosic; 3 | 4 | //------------------------------------------------------------------------------------------------- 5 | // construction/destruction: 6 | 7 | EllipticQuarterBandFilter::EllipticQuarterBandFilter() 8 | { 9 | reset(); 10 | } 11 | 12 | //------------------------------------------------------------------------------------------------- 13 | // parameter settings: 14 | 15 | void EllipticQuarterBandFilter::reset() 16 | { 17 | for(int i=0; i<12; i++) 18 | w[i] = 0.0; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/event-registry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../plugin.h" 4 | 5 | static CLAP_CONSTEXPR const char CLAP_EXT_EVENT_REGISTRY[] = "clap.event-registry"; 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | typedef struct clap_host_event_registry { 12 | // Queries an event space id. 13 | // The space id 0 is reserved for CLAP's core events. See CLAP_CORE_EVENT_SPACE. 14 | // 15 | // Return false and sets *space to UINT16_MAX if the space name is unknown to the host. 16 | // [main-thread] 17 | bool (*query)(const clap_host_t *host, const char *space_name, uint16_t *space_id); 18 | } clap_host_event_registry_t; 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/tail.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../plugin.h" 4 | 5 | static CLAP_CONSTEXPR const char CLAP_EXT_TAIL[] = "clap.tail"; 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | typedef struct clap_plugin_tail { 12 | // Returns tail length in samples. 13 | // Any value greater or equal to INT32_MAX implies infinite tail. 14 | // [main-thread,audio-thread] 15 | uint32_t (*get)(const clap_plugin_t *plugin); 16 | } clap_plugin_tail_t; 17 | 18 | typedef struct clap_host_tail { 19 | // Tell the host that the tail has changed. 20 | // [audio-thread] 21 | void (*changed)(const clap_host_t *host); 22 | } clap_host_tail_t; 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/stream.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "private/std.h" 4 | #include "private/macros.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef struct clap_istream { 11 | void *ctx; // reserved pointer for the stream 12 | 13 | // returns the number of bytes read; 0 indicates end of file and -1 a read error 14 | int64_t (*read)(const struct clap_istream *stream, void *buffer, uint64_t size); 15 | } clap_istream_t; 16 | 17 | typedef struct clap_ostream { 18 | void *ctx; // reserved pointer for the stream 19 | 20 | // returns the number of bytes written; -1 on write error 21 | int64_t (*write)(const struct clap_ostream *stream, const void *buffer, uint64_t size); 22 | } clap_ostream_t; 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/thread-check.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../plugin.h" 4 | 5 | static CLAP_CONSTEXPR const char CLAP_EXT_THREAD_CHECK[] = "clap.thread-check"; 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | // This interface is useful to do runtime checks and make 12 | // sure that the functions are called on the correct threads. 13 | // It is highly recommended to implement this extension 14 | typedef struct clap_host_thread_check { 15 | // Returns true if "this" thread is the main thread. 16 | // [thread-safe] 17 | bool (*is_main_thread)(const clap_host_t *host); 18 | 19 | // Returns true if "this" thread is one of the audio threads. 20 | // [thread-safe] 21 | bool (*is_audio_thread)(const clap_host_t *host); 22 | } clap_host_thread_check_t; 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/latency.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../plugin.h" 4 | 5 | static CLAP_CONSTEXPR const char CLAP_EXT_LATENCY[] = "clap.latency"; 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | // The audio ports scan has to be done while the plugin is deactivated. 12 | typedef struct clap_plugin_latency { 13 | // Returns the plugin latency. 14 | // [main-thread] 15 | uint32_t (*get)(const clap_plugin_t *plugin); 16 | } clap_plugin_latency_t; 17 | 18 | typedef struct clap_host_latency { 19 | // Tell the host that the latency changed. 20 | // The latency is only allowed to change if the plugin is deactivated. 21 | // If the plugin is activated, call host->request_restart() 22 | // [main-thread] 23 | void (*changed)(const clap_host_t *host); 24 | } clap_host_latency_t; 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/log.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../plugin.h" 4 | 5 | static CLAP_CONSTEXPR const char CLAP_EXT_LOG[] = "clap.log"; 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | enum { 12 | CLAP_LOG_DEBUG = 0, 13 | CLAP_LOG_INFO = 1, 14 | CLAP_LOG_WARNING = 2, 15 | CLAP_LOG_ERROR = 3, 16 | CLAP_LOG_FATAL = 4, 17 | 18 | // These severities should be used to report misbehaviour. 19 | // The plugin one can be used by a layer between the plugin and the host. 20 | CLAP_LOG_HOST_MISBEHAVING = 5, 21 | CLAP_LOG_PLUGIN_MISBEHAVING = 6, 22 | }; 23 | typedef int32_t clap_log_severity; 24 | 25 | typedef struct clap_host_log { 26 | // Log a message through the host. 27 | // [thread-safe] 28 | void (*log)(const clap_host_t *host, clap_log_severity severity, const char *msg); 29 | } clap_host_log_t; 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/timer-support.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../plugin.h" 4 | 5 | static CLAP_CONSTEXPR const char CLAP_EXT_TIMER_SUPPORT[] = "clap.timer-support"; 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | typedef struct clap_plugin_timer_support { 12 | // [main-thread] 13 | void (*on_timer)(const clap_plugin_t *plugin, clap_id timer_id); 14 | } clap_plugin_timer_support_t; 15 | 16 | typedef struct clap_host_timer_support { 17 | // Registers a periodic timer. 18 | // The host may adjust the period if it is under a certain threshold. 19 | // 30 Hz should be allowed. 20 | // [main-thread] 21 | bool (*register_timer)(const clap_host_t *host, uint32_t period_ms, clap_id *timer_id); 22 | 23 | // [main-thread] 24 | bool (*unregister_timer)(const clap_host_t *host, clap_id timer_id); 25 | } clap_host_timer_support_t; 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /Build/VisualStudio2008/Open303.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual C++ Express 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Open303", "Open303.vcproj", "{863D9E7E-5322-49C8-89BA-A761DC0EE438}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {863D9E7E-5322-49C8-89BA-A761DC0EE438}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {863D9E7E-5322-49C8-89BA-A761DC0EE438}.Debug|Win32.Build.0 = Debug|Win32 14 | {863D9E7E-5322-49C8-89BA-A761DC0EE438}.Release|Win32.ActiveCfg = Release|Win32 15 | {863D9E7E-5322-49C8-89BA-A761DC0EE438}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/private/macros.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Define CLAP_EXPORT 4 | #if !defined(CLAP_EXPORT) 5 | # if defined _WIN32 || defined __CYGWIN__ 6 | # ifdef __GNUC__ 7 | # define CLAP_EXPORT __attribute__((dllexport)) 8 | # else 9 | # define CLAP_EXPORT __declspec(dllexport) 10 | # endif 11 | # else 12 | # if __GNUC__ >= 4 || defined(__clang__) 13 | # define CLAP_EXPORT __attribute__((visibility("default"))) 14 | # else 15 | # define CLAP_EXPORT 16 | # endif 17 | # endif 18 | #endif 19 | 20 | #if defined(__cplusplus) && __cplusplus >= 201103L 21 | # define CLAP_HAS_CXX11 22 | # define CLAP_CONSTEXPR constexpr 23 | #else 24 | # define CLAP_CONSTEXPR 25 | #endif 26 | 27 | #if defined(__cplusplus) && __cplusplus >= 201703L 28 | # define CLAP_HAS_CXX17 29 | # define CLAP_NODISCARD [[nodiscard]] 30 | #else 31 | # define CLAP_NODISCARD 32 | #endif 33 | 34 | #if defined(__cplusplus) && __cplusplus >= 202002L 35 | # define CLAP_HAS_CXX20 36 | #endif 37 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/draft/check-for-update.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../plugin.h" 4 | 5 | static CLAP_CONSTEXPR const char CLAP_EXT_CHECK_FOR_UPDATE[] = "clap.check_for_update.draft/0"; 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | typedef struct clap_check_for_update_info { 12 | const char *version; // latest version 13 | const char *release_date; // YYYY-MM-DD 14 | const char *url; // url to a download page which the user can visit 15 | 16 | bool is_preview; // true if this version is a preview release 17 | } clap_check_for_update_info_t; 18 | 19 | typedef struct clap_plugin_check_for_update { 20 | // [main-thread] 21 | void (*check)(const clap_plugin_t *plugin, bool include_preview); 22 | } clap_plugin_check_for_update; 23 | 24 | typedef struct clap_host_check_for_update { 25 | // [main-thread] 26 | void (*on_new_version)(const clap_host_t *host, const clap_check_for_update_info_t *update_info); 27 | } clap_host_check_for_update_t; 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/draft/midi-mappings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../plugin.h" 4 | 5 | static CLAP_CONSTEXPR const char CLAP_EXT_MIDI_MAPPINGS[] = "clap.midi-mappings.draft/0"; 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | enum { 12 | CLAP_MIDI_MAPPING_CC7, 13 | CLAP_MIDI_MAPPING_CC14, 14 | CLAP_MIDI_MAPPING_RPN, 15 | CLAP_MIDI_MAPPING_NRPN, 16 | }; 17 | typedef int32_t clap_midi_mapping_type; 18 | 19 | typedef struct clap_midi_mapping { 20 | int32_t channel; 21 | int32_t number; 22 | clap_id param_id; 23 | } clap_midi_mapping_t; 24 | 25 | typedef struct clap_plugin_midi_mappings { 26 | // [main-thread] 27 | uint32_t (*count)(const clap_plugin_t *plugin); 28 | 29 | // [main-thread] 30 | bool (*get)(const clap_plugin_t *plugin, uint32_t index, clap_midi_mapping_t *mapping); 31 | } clap_plugin_midi_mappings_t; 32 | 33 | typedef struct clap_host_midi_mappings { 34 | // [main-thread] 35 | void (*changed)(const clap_host_t *host); 36 | } clap_host_midi_mappings_t; 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/state.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../plugin.h" 4 | #include "../stream.h" 5 | 6 | static CLAP_CONSTEXPR const char CLAP_EXT_STATE[] = "clap.state"; 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | typedef struct clap_plugin_state { 13 | // Saves the plugin state into stream. 14 | // Returns true if the state was correctly saved. 15 | // [main-thread] 16 | bool (*save)(const clap_plugin_t *plugin, const clap_ostream_t *stream); 17 | 18 | // Loads the plugin state from stream. 19 | // Returns true if the state was correctly restored. 20 | // [main-thread] 21 | bool (*load)(const clap_plugin_t *plugin, const clap_istream_t *stream); 22 | } clap_plugin_state_t; 23 | 24 | typedef struct clap_host_state { 25 | // Tell the host that the plugin state has changed and should be saved again. 26 | // If a parameter value changes, then it is implicit that the state is dirty. 27 | // [main-thread] 28 | void (*mark_dirty)(const clap_host_t *host); 29 | } clap_host_state_t; 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/version.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "private/macros.h" 4 | #include "private/std.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef struct clap_version { 11 | // This is the major ABI and API design 12 | // Version 0.X.Y correspond to the development stage, API and ABI are not stable 13 | // Version 1.X.Y correspont to the release stage, API and ABI are stable 14 | uint32_t major; 15 | uint32_t minor; 16 | uint32_t revision; 17 | } clap_version_t; 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | #define CLAP_VERSION_MAJOR ((uint32_t)1) 24 | #define CLAP_VERSION_MINOR ((uint32_t)0) 25 | #define CLAP_VERSION_REVISION ((uint32_t)3) 26 | #define CLAP_VERSION_INIT {CLAP_VERSION_MAJOR, CLAP_VERSION_MINOR, CLAP_VERSION_REVISION} 27 | 28 | static const CLAP_CONSTEXPR clap_version_t CLAP_VERSION = CLAP_VERSION_INIT; 29 | 30 | CLAP_NODISCARD static inline CLAP_CONSTEXPR bool 31 | clap_version_is_compatible(const clap_version_t v) { 32 | // versions 0.x.y were used during development stage and aren't compatible 33 | return v.major >= 1; 34 | } 35 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/draft/track-info.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../plugin.h" 4 | #include "../../color.h" 5 | #include "../../string-sizes.h" 6 | 7 | static CLAP_CONSTEXPR const char CLAP_EXT_TRACK_INFO[] = "clap.track-info.draft/0"; 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | typedef struct clap_track_info { 14 | clap_id id; 15 | int32_t index; 16 | char name[CLAP_NAME_SIZE]; 17 | char path[CLAP_PATH_SIZE]; // Like "/group1/group2/drum-machine/drum-pad-13" 18 | int32_t channel_count; 19 | const char *audio_port_type; 20 | clap_color_t color; 21 | bool is_return_track; 22 | } clap_track_info_t; 23 | 24 | typedef struct clap_plugin_track_info { 25 | // [main-thread] 26 | void (*changed)(const clap_plugin_t *plugin); 27 | } clap_plugin_track_info_t; 28 | 29 | typedef struct clap_host_track_info { 30 | // Get info about the track the plugin belongs to. 31 | // [main-thread] 32 | bool (*get)(const clap_host_t *host, clap_track_info_t *info); 33 | } clap_host_track_info_t; 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/note-name.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../plugin.h" 4 | #include "../string-sizes.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | static CLAP_CONSTEXPR const char CLAP_EXT_NOTE_NAME[] = "clap.note-name"; 11 | 12 | typedef struct clap_note_name { 13 | char name[CLAP_NAME_SIZE]; 14 | int16_t port; // -1 for every port 15 | int16_t key; // -1 for every key 16 | int16_t channel; // -1 for every channel 17 | } clap_note_name_t; 18 | 19 | typedef struct clap_plugin_note_name { 20 | // Return the number of note names 21 | // [main-thread] 22 | uint32_t (*count)(const clap_plugin_t *plugin); 23 | 24 | // Returns true on success and stores the result into note_name 25 | // [main-thread] 26 | bool (*get)(const clap_plugin_t *plugin, uint32_t index, clap_note_name_t *note_name); 27 | } clap_plugin_note_name; 28 | 29 | typedef struct clap_host_note_name { 30 | // Informs the host that the note names have changed. 31 | // [main-thread] 32 | void (*changed)(const clap_host_t *host); 33 | } clap_host_note_name_t; 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /Build/VisualStudio2019/Open303.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.28917.181 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Open303", "Open303.vcxproj", "{863D9E7E-5322-49C8-89BA-A761DC0EE438}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {863D9E7E-5322-49C8-89BA-A761DC0EE438}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {863D9E7E-5322-49C8-89BA-A761DC0EE438}.Debug|Win32.Build.0 = Debug|Win32 16 | {863D9E7E-5322-49C8-89BA-A761DC0EE438}.Release|Win32.ActiveCfg = Release|Win32 17 | {863D9E7E-5322-49C8-89BA-A761DC0EE438}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {9D157C5A-318A-42E5-9CF6-0CC46E733493} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /ReadMe.old.txt: -------------------------------------------------------------------------------- 1 | Open303 is a free and open source emulation of the famous Roland TB-303 bass synthesizer for the VST plugin interface (VST is a trademark of Steinberg Media Technologies GmbH). 2 | 3 | In order to compile it from the source code, you need the VST-SDK v2.4 from Steinberg and drop it into the folder 'Libraries', such that the directory vstsdk2.4 (from the SDK) exists as direct subfolder of 'Libraries'. 4 | 5 | Compilation with Microsoft Visual Studio 2008: 6 | Load the solution-file Open303.sln (in the folder 'Build/VisualStudio2008') with Microsoft Visual Studio 2008 and try to build the plugin. If it works, you will find the results of the compilation (the final .dll and some intermediate files) in the subfolder 'Debug' or 'Release' of 'Build/VisualStudio2008', depending on whether you selected a debug- or release-build. 7 | 8 | Compilation with CodeBlocks: 9 | Load the CodeBlocks project file Open303.cbp (in the folder 'Build/CodeBlocks') - and build away. The results will be found in the subfolder bin/Debug or bin/Release. On my setup, i get 15 compiler warnings which are all rooted in source files of the VST-SDK (not the Open303 code itself) - so i guess we may safely ignore them. 10 | 11 | 12 | good luck, Robin Schmidt -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | The Open303 source code is released under the terms of the MIT license: 2 | 3 | The MIT License 4 | 5 | Copyright (c) 2009 Robin Schmidt (www.rs-met.com) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. -------------------------------------------------------------------------------- /Libraries/clap/include/clap/audio-buffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "private/std.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | // Sample code for reading a stereo buffer: 10 | // 11 | // bool isLeftConstant = (buffer->constant_mask & (1 << 0)) != 0; 12 | // bool isRightConstant = (buffer->constant_mask & (1 << 1)) != 0; 13 | // 14 | // for (int i = 0; i < N; ++i) { 15 | // float l = data32[0][isLeftConstant ? 0 : i]; 16 | // float r = data32[1][isRightConstant ? 0 : i]; 17 | // } 18 | // 19 | // Note: checking the constant mask is optional, and this implies that 20 | // the buffer must be filled with the constant value. 21 | // Rationale: if a buffer reader doesn't check the constant mask, then it may 22 | // process garbage samples and in result, garbage samples may be transmitted 23 | // to the audio interface with all the bad consequences it can have. 24 | // 25 | // The constant mask is a hint. 26 | typedef struct clap_audio_buffer { 27 | // Either data32 or data64 pointer will be set. 28 | float **data32; 29 | double **data64; 30 | uint32_t channel_count; 31 | uint32_t latency; // latency from/to the audio interface 32 | uint64_t constant_mask; 33 | } clap_audio_buffer_t; 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/render.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../plugin.h" 4 | 5 | static CLAP_CONSTEXPR const char CLAP_EXT_RENDER[] = "clap.render"; 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | enum { 12 | // Default setting, for "realtime" processing 13 | CLAP_RENDER_REALTIME = 0, 14 | 15 | // For processing without realtime pressure 16 | // The plugin may use more expensive algorithms for higher sound quality. 17 | CLAP_RENDER_OFFLINE = 1, 18 | }; 19 | typedef int32_t clap_plugin_render_mode; 20 | 21 | // The render extension is used to let the plugin know if it has "realtime" 22 | // pressure to process. 23 | // 24 | // If this information does not influence your rendering code, then don't 25 | // implement this extension. 26 | typedef struct clap_plugin_render { 27 | // Returns true if the plugin has an hard requirement to process in real-time. 28 | // This is especially useful for plugin acting as a proxy to an hardware device. 29 | // [main-thread] 30 | bool (*has_hard_realtime_requirement)(const clap_plugin_t *plugin); 31 | 32 | // Returns true if the rendering mode could be applied. 33 | // [main-thread] 34 | bool (*set)(const clap_plugin_t *plugin, clap_plugin_render_mode mode); 35 | } clap_plugin_render_t; 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/host.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "version.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct clap_host { 10 | clap_version_t clap_version; // initialized to CLAP_VERSION 11 | 12 | void *host_data; // reserved pointer for the host 13 | 14 | // name and version are mandatory. 15 | const char *name; // eg: "Bitwig Studio" 16 | const char *vendor; // eg: "Bitwig GmbH" 17 | const char *url; // eg: "https://bitwig.com" 18 | const char *version; // eg: "4.3" 19 | 20 | // Query an extension. 21 | // [thread-safe] 22 | const void *(*get_extension)(const struct clap_host *host, const char *extension_id); 23 | 24 | // Request the host to deactivate and then reactivate the plugin. 25 | // The operation may be delayed by the host. 26 | // [thread-safe] 27 | void (*request_restart)(const struct clap_host *host); 28 | 29 | // Request the host to activate and start processing the plugin. 30 | // This is useful if you have external IO and need to wake up the plugin from "sleep". 31 | // [thread-safe] 32 | void (*request_process)(const struct clap_host *host); 33 | 34 | // Request the host to schedule a call to plugin->on_main_thread(plugin) on the main thread. 35 | // [thread-safe] 36 | void (*request_callback)(const struct clap_host *host); 37 | } clap_host_t; 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/draft/cv.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../plugin.h" 4 | 5 | // This extension can be used to specify the cv channel type used by the plugin. 6 | // Work in progress, suggestions are welcome 7 | 8 | static CLAP_CONSTEXPR const char CLAP_EXT_CV[] = "clap.cv.draft/0"; 9 | static CLAP_CONSTEXPR const char CLAP_PORT_CV[] = "cv"; 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | enum { 16 | // TODO: standardize values? 17 | CLAP_CV_VALUE = 0, 18 | CLAP_CV_GATE = 1, 19 | CLAP_CV_PITCH = 2, 20 | }; 21 | 22 | // TODO: maybe we want a channel_info instead, where we could have more details about the supported 23 | // ranges? 24 | 25 | typedef struct clap_plugin_cv { 26 | // Returns true on success. 27 | // [main-thread] 28 | bool (*get_channel_type)(const clap_plugin_t *plugin, 29 | bool is_input, 30 | uint32_t port_index, 31 | uint32_t channel_index, 32 | uint32_t *channel_type); 33 | } clap_plugin_cv_t; 34 | 35 | typedef struct clap_host_cv { 36 | // Informs the host that the channels type have changed. 37 | // The channels type can only change when the plugin is de-activated. 38 | // [main-thread,!active] 39 | void (*changed)(const clap_host_t *host); 40 | } clap_host_cv_t; 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_AcidPattern.cpp: -------------------------------------------------------------------------------- 1 | #include "rosic_AcidPattern.h" 2 | using namespace rosic; 3 | 4 | AcidPattern::AcidPattern() 5 | { 6 | numSteps = 16; 7 | stepLength = 0.5; 8 | } 9 | 10 | //------------------------------------------------------------------------------------------------- 11 | // setup: 12 | 13 | void AcidPattern::clear() 14 | { 15 | for(int i=0; idestroy(plugin); 29 | // The plugin is not allowed to use the host callbacks in the create method. 30 | // Returns null in case of error. 31 | // [thread-safe] 32 | const clap_plugin_t *(*create_plugin)(const struct clap_plugin_factory *factory, 33 | const clap_host_t *host, 34 | const char *plugin_id); 35 | } clap_plugin_factory_t; 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_MidiNoteEvent.cpp: -------------------------------------------------------------------------------- 1 | #include "rosic_MidiNoteEvent.h" 2 | using namespace rosic; 3 | 4 | //------------------------------------------------------------------------------------------------- 5 | // construction/destruction: 6 | 7 | MidiNoteEvent::MidiNoteEvent() 8 | { 9 | key = 64; 10 | vel = 64; 11 | detune = 0.0; 12 | priority = 0; 13 | } 14 | 15 | MidiNoteEvent::MidiNoteEvent(int initKey, int initVel, int initDetune, int initPriority) 16 | { 17 | if( initKey >=0 && initKey <= 127) 18 | key = initKey; 19 | else 20 | key = 64; 21 | 22 | if( initVel >=0 && initVel <= 127) 23 | vel = initVel; 24 | else 25 | vel = 64; 26 | 27 | if( initPriority >=0 ) 28 | priority = initPriority; 29 | else 30 | priority = 0; 31 | 32 | detune = initDetune; 33 | } 34 | 35 | MidiNoteEvent::~MidiNoteEvent() 36 | { 37 | 38 | } 39 | 40 | //------------------------------------------------------------------------------------------------- 41 | // parameter settings: 42 | 43 | void MidiNoteEvent::setKey(int newKey) 44 | { 45 | if( newKey >=0 && newKey <= 127) 46 | key = newKey; 47 | } 48 | 49 | void MidiNoteEvent::setVelocity(int newVelocity) 50 | { 51 | if( newVelocity >=0 && newVelocity <= 127) 52 | vel = newVelocity; 53 | } 54 | 55 | void MidiNoteEvent::setDetune(double newDetune) 56 | { 57 | detune = newDetune; 58 | } 59 | 60 | void MidiNoteEvent::setPriority(int newPriority) 61 | { 62 | if( newPriority >=0 ) 63 | priority = newPriority; 64 | } 65 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/draft/quick-controls.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../plugin.h" 4 | #include "../../string-sizes.h" 5 | 6 | // This extensions provides a set of pages, where each page contains up to 8 controls. 7 | // Those controls are param_id, and they are meant to be mapped onto a physical controller. 8 | // We chose 8 because this what most controllers offer, and it is more or less a standard. 9 | 10 | static CLAP_CONSTEXPR const char CLAP_EXT_QUICK_CONTROLS[] = "clap.quick-controls.draft/0"; 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | enum { CLAP_QUICK_CONTROLS_COUNT = 8 }; 17 | 18 | typedef struct clap_quick_controls_page { 19 | clap_id id; 20 | char name[CLAP_NAME_SIZE]; 21 | clap_id param_ids[CLAP_QUICK_CONTROLS_COUNT]; 22 | } clap_quick_controls_page_t; 23 | 24 | typedef struct clap_plugin_quick_controls { 25 | // [main-thread] 26 | uint32_t (*count)(const clap_plugin_t *plugin); 27 | 28 | // [main-thread] 29 | bool (*get)(const clap_plugin_t *plugin, uint32_t page_index, clap_quick_controls_page_t *page); 30 | } clap_plugin_quick_controls_t; 31 | 32 | typedef struct clap_host_quick_controls { 33 | // Informs the host that the quick controls have changed. 34 | // [main-thread] 35 | void (*changed)(const clap_host_t *host); 36 | 37 | // Suggest a page to the host because it correspond to what the user is currently editing in the 38 | // plugin's GUI. 39 | // [main-thread] 40 | void (*suggest_page)(const clap_host_t *host, clap_id page_id); 41 | } clap_host_quick_controls_t; 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/draft/ambisonic.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../plugin.h" 4 | 5 | // This extension can be used to specify the channel mapping used by the plugin. 6 | 7 | static CLAP_CONSTEXPR const char CLAP_EXT_AMBISONIC[] = "clap.ambisonic.draft/0"; 8 | 9 | static CLAP_CONSTEXPR const char CLAP_PORT_AMBISONIC[] = "ambisonic"; 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | enum { 16 | // FuMa channel ordering 17 | CLAP_AMBISONIC_FUMA = 0, 18 | 19 | // ACN channel ordering 20 | CLAP_AMBISONIC_ACN = 1, 21 | }; 22 | 23 | enum { 24 | CLAP_AMBISONIC_NORMALIZATION_MAXN = 0, 25 | CLAP_AMBISONIC_NORMALIZATION_SN3D = 1, 26 | CLAP_AMBISONIC_NORMALIZATION_N3D = 2, 27 | CLAP_AMBISONIC_NORMALIZATION_SN2D = 3, 28 | CLAP_AMBISONIC_NORMALIZATION_N2D = 4, 29 | }; 30 | 31 | typedef struct clap_ambisonic_info { 32 | uint32_t ordering; 33 | uint32_t normalization; 34 | } clap_ambisonic_info_t; 35 | 36 | typedef struct clap_plugin_ambisonic { 37 | // Returns true on success 38 | // [main-thread] 39 | bool (*get_info)(const clap_plugin_t *plugin, 40 | bool is_input, 41 | uint32_t port_index, 42 | clap_ambisonic_info_t *info); 43 | 44 | } clap_plugin_ambisonic_t; 45 | 46 | typedef struct clap_host_ambisonic { 47 | // Informs the host that the info has changed. 48 | // The info can only change when the plugin is de-activated. 49 | // [main-thread] 50 | void (*changed)(const clap_host_t *host); 51 | } clap_host_ambisonic_t; 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/posix-fd-support.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../plugin.h" 4 | 5 | // This extension let your plugin hook itself into the host select/poll/epoll/kqueue reactor. 6 | // This is useful to handle asynchronous I/O on the main thread. 7 | static CLAP_CONSTEXPR const char CLAP_EXT_POSIX_FD_SUPPORT[] = "clap.posix-fd-support"; 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | enum { 14 | // IO events flags, they can be used to form a mask which describes: 15 | // - which events you are interested in (register_fd/modify_fd) 16 | // - which events happened (on_fd) 17 | CLAP_POSIX_FD_READ = 1 << 0, 18 | CLAP_POSIX_FD_WRITE = 1 << 1, 19 | CLAP_POSIX_FD_ERROR = 1 << 2, 20 | }; 21 | typedef uint32_t clap_posix_fd_flags_t; 22 | 23 | typedef struct clap_plugin_posix_fd_support { 24 | // This callback is "level-triggered". 25 | // It means that a writable fd will continuously produce "on_fd()" events; 26 | // don't forget using modify_fd() to remove the write notification once you're 27 | // done writting. 28 | // 29 | // [main-thread] 30 | void (*on_fd)(const clap_plugin_t *plugin, int fd, clap_posix_fd_flags_t flags); 31 | } clap_plugin_posix_fd_support_t; 32 | 33 | typedef struct clap_host_posix_fd_support { 34 | // [main-thread] 35 | bool (*register_fd)(const clap_host_t *host, int fd, clap_posix_fd_flags_t flags); 36 | 37 | // [main-thread] 38 | bool (*modify_fd)(const clap_host_t *host, int fd, clap_posix_fd_flags_t flags); 39 | 40 | // [main-thread] 41 | bool (*unregister_fd)(const clap_host_t *host, int fd); 42 | } clap_host_posix_fd_support_t; 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | -------------------------------------------------------------------------------- /Build/VisualStudio2008/Open303.vcproj.XYZ-3B339B6A6CF.xyz.user: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | 35 | 36 | 39 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/plugin-invalidation.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "private/std.h" 4 | #include "private/macros.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef struct clap_plugin_invalidation_source { 11 | // Directory containing the file(s) to scan, must be absolute 12 | const char *directory; 13 | 14 | // globing pattern, in the form *.dll 15 | const char *filename_glob; 16 | 17 | // should the directory be scanned recursively? 18 | bool recursive_scan; 19 | } clap_plugin_invalidation_source_t; 20 | 21 | static const CLAP_CONSTEXPR char CLAP_PLUGIN_INVALIDATION_FACTORY_ID[] = 22 | "clap.plugin-invalidation-factory/draft0"; 23 | 24 | // Used to figure out when a plugin needs to be scanned again. 25 | // Imagine a situation with a single entry point: my-plugin.clap which then scans itself 26 | // a set of "sub-plugins". New plugin may be available even if my-plugin.clap file doesn't change. 27 | // This interfaces solves this issue and gives a way to the host to monitor additional files. 28 | typedef struct clap_plugin_invalidation_factory { 29 | // Get the number of invalidation source. 30 | uint32_t (*count)(const struct clap_plugin_invalidation_factory *factory); 31 | 32 | // Get the invalidation source by its index. 33 | // [thread-safe] 34 | const clap_plugin_invalidation_source_t *(*get)( 35 | const struct clap_plugin_invalidation_factory *factory, uint32_t index); 36 | 37 | // In case the host detected a invalidation event, it can call refresh() to let the 38 | // plugin_entry update the set of plugins available. 39 | // If the function returned false, then the plugin needs to be reloaded. 40 | bool (*refresh)(const struct clap_plugin_invalidation_factory *factory); 41 | } clap_plugin_invalidation_factory_t; 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_DecayEnvelope.cpp: -------------------------------------------------------------------------------- 1 | #include "rosic_DecayEnvelope.h" 2 | using namespace rosic; 3 | 4 | //------------------------------------------------------------------------------------------------- 5 | // construction/destruction: 6 | 7 | DecayEnvelope::DecayEnvelope() 8 | { 9 | c = 1.0; 10 | y = 1.0; 11 | yInit = 1.0; 12 | tau = 200.0; 13 | fs = 44100.0; 14 | normalizeSum = false; 15 | calculateCoefficient(); 16 | } 17 | 18 | DecayEnvelope::~DecayEnvelope() 19 | { 20 | 21 | } 22 | 23 | //------------------------------------------------------------------------------------------------- 24 | // parameter settings: 25 | 26 | void DecayEnvelope::setSampleRate(double newSampleRate) 27 | { 28 | if( newSampleRate > 0.0 ) 29 | { 30 | fs = newSampleRate; 31 | calculateCoefficient(); 32 | } 33 | } 34 | 35 | void DecayEnvelope::setDecayTimeConstant(double newTimeConstant) 36 | { 37 | if( newTimeConstant > 0.001 ) // at least 0.001 ms decay 38 | { 39 | tau = newTimeConstant; 40 | calculateCoefficient(); 41 | } 42 | } 43 | 44 | void DecayEnvelope::setNormalizeSum(bool shouldNormalizeSum) 45 | { 46 | normalizeSum = shouldNormalizeSum; 47 | calculateCoefficient(); 48 | } 49 | 50 | //------------------------------------------------------------------------------------------------- 51 | // others: 52 | 53 | void DecayEnvelope::trigger() 54 | { 55 | y = yInit; 56 | } 57 | 58 | bool DecayEnvelope::endIsReached(double threshold) 59 | { 60 | if( y < threshold ) 61 | return true; 62 | else 63 | return false; 64 | } 65 | 66 | //------------------------------------------------------------------------------------------------- 67 | // internal functions: 68 | 69 | void DecayEnvelope::calculateCoefficient() 70 | { 71 | c = exp( -1.0 / (0.001*tau*fs) ); 72 | if( normalizeSum == true ) 73 | yInit = (1.0-c)/c; 74 | else 75 | yInit = 1.0/c; 76 | } 77 | 78 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/draft/voice-info.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../plugin.h" 4 | 5 | // This extension indicates the number of voices the synthesizer has. 6 | // It is useful for the host when performing polyphonic modulations, 7 | // because the host needs its own voice management and should try to follow 8 | // what the plugin is doing: 9 | // - make the host's voice pool coherent with what the plugin has 10 | // - turn the host's voice management to mono when the plugin is mono 11 | 12 | static const char CLAP_EXT_VOICE_INFO[] = "clap.voice-info.draft/0"; 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | enum { 19 | // Allows the host to send overlapping NOTE_ON events. 20 | // The plugin will then rely upon the note_id to distinguish between them. 21 | CLAP_VOICE_INFO_SUPPORTS_OVERLAPPING_NOTES = 1 << 0, 22 | }; 23 | 24 | typedef struct clap_voice_info { 25 | // voice_count is the current number of voices that the patch can use 26 | // voice_capacity is the number of voices allocated voices 27 | // voice_count should not be confused with the number of active voices. 28 | // 29 | // 1 <= voice_count <= voice_capacity 30 | // 31 | // For example, a synth can have a capacity of 8 voices, but be configured 32 | // to only use 4 voices: {count: 4, capacity: 8}. 33 | // 34 | // If the voice_count is 1, then the synth is working in mono and the host 35 | // can decide to only use global modulation mapping. 36 | uint32_t voice_count; 37 | uint32_t voice_capacity; 38 | 39 | uint64_t flags; 40 | } clap_voice_info_t; 41 | 42 | typedef struct clap_plugin_voice_info { 43 | // gets the voice info, returns true on success 44 | // [main-thread && active] 45 | bool (*get)(const clap_plugin_t *plugin, clap_voice_info_t *info); 46 | } clap_plugin_voice_info_t; 47 | 48 | typedef struct clap_host_voice_info { 49 | // informs the host that the voice info has changed 50 | // [main-thread] 51 | void (*changed)(const clap_host_t *host); 52 | } clap_host_voice_info_t; 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/draft/transport-control.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../plugin.h" 4 | 5 | // This extension lets the plugin submit transport requests to the host. 6 | // The host has no obligation to execute these requests, so the interface may be 7 | // partially working. 8 | 9 | static CLAP_CONSTEXPR const char CLAP_EXT_TRANSPORT_CONTROL[] = "clap.transport-control.draft/0"; 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | typedef struct clap_host_transport_control { 16 | // Jumps back to the start point and starts the transport 17 | // [main-thread] 18 | void (*request_start)(const clap_host_t *host); 19 | 20 | // Stops the transport, and jumps to the start point 21 | // [main-thread] 22 | void (*request_stop)(const clap_host_t *host); 23 | 24 | // If not playing, starts the transport from its current position 25 | // [main-thread] 26 | void (*request_continue)(const clap_host_t *host); 27 | 28 | // If playing, stops the transport at the current position 29 | // [main-thread] 30 | void (*request_pause)(const clap_host_t *host); 31 | 32 | // Equivalent to what "space bar" does with most DAWs 33 | // [main-thread] 34 | void (*request_toggle_play)(const clap_host_t *host); 35 | 36 | // Jumps the transport to the given position. 37 | // Does not start the transport. 38 | // [main-thread] 39 | void (*request_jump)(const clap_host_t *host, clap_beattime position); 40 | 41 | // Sets the loop region 42 | // [main-thread] 43 | void (*request_loop_region)(const clap_host_t *host, clap_beattime start, clap_beattime duration); 44 | 45 | // Toggles looping 46 | // [main-thread] 47 | void (*request_toggle_loop)(const clap_host_t *host); 48 | 49 | // Enables/Disables looping 50 | // [main-thread] 51 | void (*request_enable_loop)(const clap_host_t *host, bool is_enabled); 52 | 53 | // Enables/Disables recording 54 | // [main-thread] 55 | void (*request_record)(const clap_host_t *host, bool is_recording); 56 | 57 | // Toggles recording 58 | // [main-thread] 59 | void (*request_toggle_record)(const clap_host_t *host); 60 | } clap_host_transport_control_t; 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_Complex.cpp: -------------------------------------------------------------------------------- 1 | #include "rosic_Complex.h" 2 | using namespace rosic; 3 | 4 | //------------------------------------------------------------------------------------------------- 5 | // construction/destruction: 6 | 7 | Complex::Complex() 8 | { 9 | re = im = 0.0; 10 | } 11 | 12 | Complex::Complex(double reInit) 13 | { 14 | re = reInit; 15 | im = 0.0; 16 | } 17 | 18 | Complex::Complex(double reInit, double imInit) 19 | { 20 | re = reInit; 21 | im = imInit; 22 | } 23 | 24 | Complex::~Complex() 25 | { 26 | 27 | } 28 | 29 | //------------------------------------------------------------------------------------------------- 30 | // magnitude, angle, etc. 31 | 32 | double Complex::getRadius() 33 | { 34 | return sqrt(re*re + im*im); 35 | } 36 | 37 | double Complex::getAngle() 38 | { 39 | if((re==0.0) && (im==0)) 40 | return 0.0; 41 | else 42 | return atan2(im, re); 43 | } 44 | 45 | void Complex::setRadius(double newRadius) 46 | { 47 | double phi = getAngle(); 48 | sinCos(phi, &im, &re); 49 | re *= newRadius; // re = newRadius * cos(phi); 50 | im *= newRadius; // im = newRadius * sin(phi); 51 | } 52 | 53 | void Complex::setAngle(double newAngle) 54 | { 55 | double r = getRadius(); 56 | sinCos(newAngle, &im, &re); 57 | re *= r; // re = r * cos(newAngle); 58 | im *= r; // im = r * sin(newAngle); 59 | } 60 | 61 | void Complex::setRadiusAndAngle(double newRadius, double newAngle) 62 | { 63 | sinCos(newAngle, &im, &re); 64 | re *= newRadius; // re = newRadius * cos(newAngle); 65 | im *= newRadius; // im = newRadius * sin(newAngle); 66 | } 67 | 68 | Complex Complex::getConjugate() 69 | { 70 | return Complex(re, -im); 71 | } 72 | 73 | Complex Complex::getReciprocal() 74 | { 75 | double scaler = 1.0 / (re*re + im*im); 76 | return Complex(scaler*re, -scaler*im); 77 | } 78 | 79 | bool Complex::isReal() 80 | { 81 | return (im == 0.0); 82 | } 83 | 84 | bool Complex::isImaginary() 85 | { 86 | return (re == 0.0); 87 | } 88 | 89 | bool Complex::isInfinite() 90 | { 91 | if( re == INF || re == NEG_INF || im == INF || im == NEG_INF ) 92 | return true; 93 | else 94 | return false; 95 | } 96 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/process.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "events.h" 4 | #include "audio-buffer.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | enum { 11 | // Processing failed. The output buffer must be discarded. 12 | CLAP_PROCESS_ERROR = 0, 13 | 14 | // Processing succeeded, keep processing. 15 | CLAP_PROCESS_CONTINUE = 1, 16 | 17 | // Processing succeeded, keep processing if the output is not quiet. 18 | CLAP_PROCESS_CONTINUE_IF_NOT_QUIET = 2, 19 | 20 | // Rely upon the plugin's tail to determine if the plugin should continue to process. 21 | // see clap_plugin_tail 22 | CLAP_PROCESS_TAIL = 3, 23 | 24 | // Processing succeeded, but no more processing is required, 25 | // until the next event or variation in audio input. 26 | CLAP_PROCESS_SLEEP = 4, 27 | }; 28 | typedef int32_t clap_process_status; 29 | 30 | typedef struct clap_process { 31 | // A steady sample time counter. 32 | // This field can be used to calculate the sleep duration between two process calls. 33 | // This value may be specific to this plugin instance and have no relation to what 34 | // other plugin instances may receive. 35 | // 36 | // Set to -1 if not available, otherwise the value must be greater or equal to 0, 37 | // and must be increased by at least `frames_count` for the next call to process. 38 | int64_t steady_time; 39 | 40 | // Number of frames to process 41 | uint32_t frames_count; 42 | 43 | // time info at sample 0 44 | // If null, then this is a free running host, no transport events will be provided 45 | const clap_event_transport_t *transport; 46 | 47 | // Audio buffers, they must have the same count as specified 48 | // by clap_plugin_audio_ports->get_count(). 49 | // The index maps to clap_plugin_audio_ports->get_info(). 50 | const clap_audio_buffer_t *audio_inputs; 51 | clap_audio_buffer_t *audio_outputs; 52 | uint32_t audio_inputs_count; 53 | uint32_t audio_outputs_count; 54 | 55 | // Input and output events. 56 | // 57 | // Events must be sorted by time. 58 | // The input event list can't be modified. 59 | const clap_input_events_t *in_events; 60 | const clap_output_events_t *out_events; 61 | } clap_process_t; 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/clap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CLAP - CLever Audio Plugin 3 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | * 5 | * Copyright (c) 2014...2022 Alexandre BIQUE 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | * THE SOFTWARE. 24 | */ 25 | 26 | #pragma once 27 | 28 | #include "entry.h" 29 | #include "plugin-factory.h" 30 | #include "plugin-invalidation.h" 31 | #include "plugin-features.h" 32 | 33 | #include "plugin.h" 34 | #include "host.h" 35 | 36 | #include "ext/audio-ports.h" 37 | #include "ext/audio-ports-config.h" 38 | #include "ext/gui.h" 39 | #include "ext/log.h" 40 | #include "ext/params.h" 41 | #include "ext/render.h" 42 | #include "ext/state.h" 43 | #include "ext/latency.h" 44 | #include "ext/thread-check.h" 45 | #include "ext/timer-support.h" 46 | #include "ext/posix-fd-support.h" 47 | #include "ext/note-name.h" 48 | #include "ext/note-ports.h" 49 | #include "ext/thread-pool.h" 50 | #include "ext/event-registry.h" 51 | #include "ext/tail.h" 52 | 53 | #include "ext/draft/preset-load.h" 54 | #include "ext/draft/quick-controls.h" 55 | #include "ext/draft/track-info.h" 56 | #include "ext/draft/tuning.h" 57 | #include "ext/draft/file-reference.h" 58 | #include "ext/draft/midi-mappings.h" 59 | #include "ext/draft/surround.h" 60 | #include "ext/draft/cv.h" 61 | #include "ext/draft/ambisonic.h" 62 | #include "ext/draft/voice-info.h" 63 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/entry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "version.h" 4 | #include "private/macros.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | // This interface is the entry point of the dynamic library. 11 | // 12 | // CLAP plugins standard search path: 13 | // 14 | // Linux 15 | // - ~/.clap 16 | // - /usr/lib/clap 17 | // 18 | // Windows 19 | // - %CommonFilesFolder%/CLAP/ 20 | // - %LOCALAPPDATA%/Programs/Common/CLAP/ 21 | // 22 | // MacOS 23 | // - /Library/Audio/Plug-Ins/CLAP 24 | // - ~/Library/Audio/Plug-Ins/CLAP 25 | // 26 | // In addition to the OS-specific default locations above, a CLAP host must query the environment 27 | // for a CLAP_PATH variable, which is a list of directories formatted in the same manner as the host 28 | // OS binary search path (PATH on Unix, separated by `:` and Path on Windows, separated by ';', as 29 | // of this writing). 30 | // 31 | // Each directory should be recursively searched for files and/or bundles as appropriate in your OS 32 | // ending with the extension `.clap`. 33 | // 34 | // Every method must be thread-safe. 35 | typedef struct clap_plugin_entry { 36 | clap_version_t clap_version; // initialized to CLAP_VERSION 37 | 38 | // This function must be called first, and can only be called once. 39 | // 40 | // It should be as fast as possible, in order to perform a very quick scan of the plugin 41 | // descriptors. 42 | // 43 | // It is forbidden to display graphical user interface in this call. 44 | // It is forbidden to perform user interaction in this call. 45 | // 46 | // If the initialization depends upon expensive computation, maybe try to do them ahead of time 47 | // and cache the result. 48 | // 49 | // If init() returns false, then the host must not call deinit() nor any other clap 50 | // related symbols from the DSO. 51 | bool (*init)(const char *plugin_path); 52 | 53 | // No more calls into the DSO must be made after calling deinit(). 54 | void (*deinit)(void); 55 | 56 | // Get the pointer to a factory. See plugin-factory.h for an example. 57 | // 58 | // Returns null if the factory is not provided. 59 | // The returned pointer must *not* be freed by the caller. 60 | const void *(*get_factory)(const char *factory_id); 61 | } clap_plugin_entry_t; 62 | 63 | /* Entry point */ 64 | CLAP_EXPORT extern const clap_plugin_entry_t clap_entry; 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/thread-pool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../plugin.h" 4 | 5 | /// @page 6 | /// 7 | /// This extension lets the plugin use the host's thread pool. 8 | /// 9 | /// The plugin must provide @ref clap_plugin_thread_pool, and the host may provide @ref 10 | /// clap_host_thread_pool. If it doesn't, the plugin should process its data by its own means. In the 11 | /// worst case, a single threaded for-loop. 12 | /// 13 | /// Simple example with N voices to process 14 | /// 15 | /// @code 16 | /// void myplug_thread_pool_exec(const clap_plugin *plugin, uint32_t voice_index) 17 | /// { 18 | /// compute_voice(plugin, voice_index); 19 | /// } 20 | /// 21 | /// void myplug_process(const clap_plugin *plugin, const clap_process *process) 22 | /// { 23 | /// ... 24 | /// bool didComputeVoices = false; 25 | /// if (host_thread_pool && host_thread_pool.exec) 26 | /// didComputeVoices = host_thread_pool.request_exec(host, plugin, N); 27 | /// 28 | /// if (!didComputeVoices) 29 | /// for (uint32_t i = 0; i < N; ++i) 30 | /// myplug_thread_pool_exec(plugin, i); 31 | /// ... 32 | /// } 33 | /// @endcode 34 | /// 35 | /// Be aware that using a thread pool may break hard real-time rules due to the thread 36 | /// synchronization involved. 37 | /// 38 | /// If the host knows that it is running under hard real-time pressure it may decide to not 39 | /// provide this interface. 40 | 41 | static CLAP_CONSTEXPR const char CLAP_EXT_THREAD_POOL[] = "clap.thread-pool"; 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | typedef struct clap_plugin_thread_pool { 48 | // Called by the thread pool 49 | void (*exec)(const clap_plugin_t *plugin, uint32_t task_index); 50 | } clap_plugin_thread_pool_t; 51 | 52 | typedef struct clap_host_thread_pool { 53 | // Schedule num_tasks jobs in the host thread pool. 54 | // It can't be called concurrently or from the thread pool. 55 | // Will block until all the tasks are processed. 56 | // This must be used exclusively for realtime processing within the process call. 57 | // Returns true if the host did execute all the tasks, false if it rejected the request. 58 | // The host should check that the plugin is within the process call, and if not, reject the exec 59 | // request. 60 | // [audio-thread] 61 | bool (*request_exec)(const clap_host_t *host, uint32_t num_tasks); 62 | } clap_host_thread_pool_t; 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/draft/tuning.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../plugin.h" 4 | #include "../../events.h" 5 | #include "../../string-sizes.h" 6 | 7 | static CLAP_CONSTEXPR const char CLAP_EXT_TUNING[] = "clap.tuning.draft/2"; 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | // Use clap_host_event_registry->query(host, CLAP_EXT_TUNING, &space_id) to know the event space. 14 | // 15 | // This event defines the tuning to be used on the given port/channel. 16 | typedef struct clap_event_tuning { 17 | clap_event_header_t header; 18 | 19 | int16_t port_index; // -1 global 20 | int16_t channel; // 0..15, -1 global 21 | clap_id tunning_id; 22 | } clap_event_tuning_t; 23 | 24 | typedef struct clap_tuning_info { 25 | clap_id tuning_id; 26 | char name[CLAP_NAME_SIZE]; 27 | bool is_dynamic; // true if the values may vary with time 28 | } clap_tuning_info_t; 29 | 30 | typedef struct clap_plugin_tuning { 31 | // Called when a tuning is added or removed from the pool. 32 | // [main-thread] 33 | void (*changed)(const clap_plugin_t *plugin); 34 | } clap_plugin_tuning_t; 35 | 36 | // This extension provides a dynamic tuning table to the plugin. 37 | typedef struct clap_host_tuning { 38 | // Gets the relative tuning in semitones against equal temperament with A4=440Hz. 39 | // The plugin may query the tuning at a rate that makes sense for *low* frequency modulations. 40 | // 41 | // If the tuning_id is not found or equals to CLAP_INVALID_ID, 42 | // then the function shall gracefuly return a sensible value. 43 | // 44 | // sample_offset is the sample offset from the begining of the current process block. 45 | // 46 | // should_play(...) should be checked before calling this function. 47 | // 48 | // [audio-thread & in-process] 49 | double (*get_relative)(const clap_host_t *host, 50 | clap_id tuning_id, 51 | int32_t channel, 52 | int32_t key, 53 | uint32_t sample_offset); 54 | 55 | // Returns true if the note should be played. 56 | // [audio-thread & in-process] 57 | bool (*should_play)(const clap_host_t *host, clap_id tuning_id, int32_t channel, int32_t key); 58 | 59 | // Returns the number of tunings in the pool. 60 | // [main-thread] 61 | uint32_t (*get_tuning_count)(const clap_host_t *host); 62 | 63 | // Gets info about a tuning 64 | // [main-thread] 65 | bool (*get_info)(const clap_host_t *host, uint32_t tuning_index, clap_tuning_info_t *info); 66 | } clap_host_tuning_t; 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_BlendOscillator.cpp: -------------------------------------------------------------------------------- 1 | #include "rosic_BlendOscillator.h" 2 | using namespace rosic; 3 | 4 | //------------------------------------------------------------------------------------------------- 5 | // construction/destruction: 6 | 7 | BlendOscillator::BlendOscillator() 8 | { 9 | // init member variables: 10 | tableLengthDbl = (double) MipMappedWaveTable::tableLength; // typecasted version 11 | sampleRate = 44100.0; 12 | freq = 440.0; 13 | increment = (tableLengthDbl*freq)/sampleRate; 14 | phaseIndex = 0.0; 15 | startIndex = 0.0; 16 | waveTable1 = NULL; 17 | waveTable2 = NULL; 18 | 19 | // somewhat redundant: 20 | setSampleRate(44100.0); // sampleRate = 44100 Hz by default 21 | setFrequency (440.0); // frequency = 440 Hz by default 22 | setStartPhase(0.0); // sartPhase = 0 by default 23 | 24 | setWaveForm1(MipMappedWaveTable::SAW); 25 | setWaveForm2(MipMappedWaveTable::SQUARE); 26 | 27 | resetPhase(); 28 | } 29 | 30 | BlendOscillator::~BlendOscillator() 31 | { 32 | 33 | } 34 | 35 | //------------------------------------------------------------------------------------------------- 36 | // parameter settings: 37 | 38 | void BlendOscillator::setSampleRate(double newSampleRate) 39 | { 40 | if( newSampleRate > 0.0 ) 41 | sampleRate = newSampleRate; 42 | sampleRateRec = 1.0 / sampleRate; 43 | increment = tableLengthDbl*freq*sampleRateRec; 44 | } 45 | 46 | void BlendOscillator::setWaveForm1(int newWaveForm1) 47 | { 48 | if( waveTable1 != NULL ) 49 | waveTable1->setWaveform(newWaveForm1); 50 | } 51 | 52 | void BlendOscillator::setWaveForm2(int newWaveForm2) 53 | { 54 | if( waveTable2 != NULL ) 55 | waveTable2->setWaveform(newWaveForm2); 56 | } 57 | 58 | void BlendOscillator::setWaveTable1(MipMappedWaveTable* newWaveTable1) 59 | { 60 | waveTable1 = newWaveTable1; 61 | } 62 | 63 | void BlendOscillator::setWaveTable2(MipMappedWaveTable* newWaveTable2) 64 | { 65 | waveTable2 = newWaveTable2; 66 | } 67 | 68 | void BlendOscillator::setStartPhase(double StartPhase) 69 | { 70 | if( (StartPhase>=0) && (StartPhase<=360) ) 71 | startIndex = (StartPhase/360.0)*tableLengthDbl; 72 | } 73 | 74 | //------------------------------------------------------------------------------------------------- 75 | // event processing: 76 | 77 | void BlendOscillator::resetPhase() 78 | { 79 | phaseIndex = startIndex; 80 | } 81 | 82 | void BlendOscillator::setPhase(double PhaseIndex) 83 | { 84 | phaseIndex = startIndex+PhaseIndex; 85 | } 86 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_MidiNoteEvent.h: -------------------------------------------------------------------------------- 1 | #ifndef rosic_MidiNoteEvent_h 2 | #define rosic_MidiNoteEvent_h 3 | 4 | namespace rosic 5 | { 6 | 7 | /** 8 | 9 | This is a class for representing MIDI note-events. 10 | 11 | */ 12 | 13 | class MidiNoteEvent 14 | { 15 | 16 | public: 17 | 18 | //--------------------------------------------------------------------------------------------- 19 | // construction/destruction: 20 | 21 | /** Default constructor. */ 22 | MidiNoteEvent(); 23 | 24 | /** Constructor with initializations. */ 25 | MidiNoteEvent(int initKey, int initVel, int initDetune = 0, int initPriority = 0 ); 26 | 27 | /** Destructor. */ 28 | ~MidiNoteEvent(); 29 | 30 | //--------------------------------------------------------------------------------------------- 31 | // parameter settings: 32 | 33 | /** Sets the key of the note (as MIDI note number between 0...127). */ 34 | void setKey(int newKey); 35 | 36 | /** Sets the velocity of the note (between 0...127). */ 37 | void setVelocity(int newVelocity); 38 | 39 | /** Sets the detuning of the note (in semitones). */ 40 | void setDetune(double newDetune); 41 | 42 | /** Sets the priority of the note. */ 43 | void setPriority(int newPriority); 44 | 45 | //--------------------------------------------------------------------------------------------- 46 | // inquiry: 47 | 48 | /** Returns the key of the note (as MIDI note number between 0...127). */ 49 | int getKey() const { return key; } 50 | 51 | /** Returns the velocity of the note (between 0...127). */ 52 | int getVelocity() const { return vel; } 53 | 54 | /** Returns the detuning of the note (in semitones). */ 55 | double getDetune() const { return detune; } 56 | 57 | /** Returns the priority of the note. */ 58 | int getPriority() const { return priority; } 59 | 60 | //--------------------------------------------------------------------------------------------- 61 | // overloaded operators: 62 | 63 | /** Note events are interpreted as equal if the have the same key. */ 64 | bool operator==(const MidiNoteEvent& note2) const 65 | { 66 | if( note2.key == key ) 67 | return true; 68 | else 69 | return false; 70 | } 71 | 72 | protected: 73 | 74 | int key; // key of the note in the range 0...127 75 | int vel; // velocity of the note in the range 0...127 76 | double detune; // detuning in cents (for microtuning) 77 | int priority; // a priority value 78 | 79 | }; 80 | 81 | } // end namespace rosic 82 | 83 | #endif // MidiNoteEvent_h 84 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/audio-ports-config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../string-sizes.h" 4 | #include "../plugin.h" 5 | 6 | /// @page Audio Ports Config 7 | /// 8 | /// This extension provides a way for the plugin to describe possible port configurations, for 9 | /// example mono, stereo, surround, ... and a way for the host to select a configuration. 10 | /// 11 | /// After the plugin initialization, the host may scan the list of configurations and eventually 12 | /// select one that fits the plugin context. The host can only select a configuration if the plugin 13 | /// is deactivated. 14 | /// 15 | /// A configuration is a very simple description of the audio ports: 16 | /// - it describes the main input and output ports 17 | /// - it has a name that can be displayed to the user 18 | /// 19 | /// The idea behind the configurations, is to let the user choose one via a menu. 20 | /// 21 | /// Plugins with very complex configuration possibilities should let the user configure the ports 22 | /// from the plugin GUI, and call @ref clap_host_audio_ports.rescan(CLAP_AUDIO_PORTS_RESCAN_ALL). 23 | 24 | static CLAP_CONSTEXPR const char CLAP_EXT_AUDIO_PORTS_CONFIG[] = "clap.audio-ports-config"; 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | // Minimalistic description of ports configuration 31 | typedef struct clap_audio_ports_config { 32 | clap_id id; 33 | char name[CLAP_NAME_SIZE]; 34 | 35 | uint32_t input_port_count; 36 | uint32_t output_port_count; 37 | 38 | // main input info 39 | bool has_main_input; 40 | uint32_t main_input_channel_count; 41 | const char *main_input_port_type; 42 | 43 | // main output info 44 | bool has_main_output; 45 | uint32_t main_output_channel_count; 46 | const char *main_output_port_type; 47 | } clap_audio_ports_config_t; 48 | 49 | // The audio ports config scan has to be done while the plugin is deactivated. 50 | typedef struct clap_plugin_audio_ports_config { 51 | // gets the number of available configurations 52 | // [main-thread] 53 | uint32_t (*count)(const clap_plugin_t *plugin); 54 | 55 | // gets information about a configuration 56 | // [main-thread] 57 | bool (*get)(const clap_plugin_t *plugin, uint32_t index, clap_audio_ports_config_t *config); 58 | 59 | // selects the configuration designated by id 60 | // returns true if the configuration could be applied 61 | // [main-thread,plugin-deactivated] 62 | bool (*select)(const clap_plugin_t *plugin, clap_id config_id); 63 | } clap_plugin_audio_ports_config_t; 64 | 65 | typedef struct clap_host_audio_ports_config { 66 | // Rescan the full list of configs. 67 | // [main-thread] 68 | void (*rescan)(const clap_host_t *host); 69 | } clap_host_audio_ports_config_t; 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/note-ports.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../plugin.h" 4 | #include "../string-sizes.h" 5 | 6 | /// @page Note Ports 7 | /// 8 | /// This extension provides a way for the plugin to describe its current note ports. 9 | /// If the plugin does not implement this extension, it won't have note input or output. 10 | /// The plugin is only allowed to change its note ports configuration while it is deactivated. 11 | 12 | static CLAP_CONSTEXPR const char CLAP_EXT_NOTE_PORTS[] = "clap.note-ports"; 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | enum clap_note_dialect { 19 | // Uses clap_event_note and clap_event_note_expression. 20 | CLAP_NOTE_DIALECT_CLAP = 1 << 0, 21 | 22 | // Uses clap_event_midi, no polyphonic expression 23 | CLAP_NOTE_DIALECT_MIDI = 1 << 1, 24 | 25 | // Uses clap_event_midi, with polyphonic expression (MPE) 26 | CLAP_NOTE_DIALECT_MIDI_MPE = 1 << 2, 27 | 28 | // Uses clap_event_midi2 29 | CLAP_NOTE_DIALECT_MIDI2 = 1 << 3, 30 | }; 31 | 32 | typedef struct clap_note_port_info { 33 | // id identifies a port and must be stable. 34 | // id may overlap between input and output ports. 35 | clap_id id; 36 | uint32_t supported_dialects; // bitfield, see clap_note_dialect 37 | uint32_t preferred_dialect; // one value of clap_note_dialect 38 | char name[CLAP_NAME_SIZE]; // displayable name, i18n? 39 | } clap_note_port_info_t; 40 | 41 | // The note ports scan has to be done while the plugin is deactivated. 42 | typedef struct clap_plugin_note_ports { 43 | // number of ports, for either input or output 44 | // [main-thread] 45 | uint32_t (*count)(const clap_plugin_t *plugin, bool is_input); 46 | 47 | // get info about about a note port. 48 | // [main-thread] 49 | bool (*get)(const clap_plugin_t *plugin, 50 | uint32_t index, 51 | bool is_input, 52 | clap_note_port_info_t *info); 53 | } clap_plugin_note_ports_t; 54 | 55 | enum { 56 | // The ports have changed, the host shall perform a full scan of the ports. 57 | // This flag can only be used if the plugin is not active. 58 | // If the plugin active, call host->request_restart() and then call rescan() 59 | // when the host calls deactivate() 60 | CLAP_NOTE_PORTS_RESCAN_ALL = 1 << 0, 61 | 62 | // The ports name did change, the host can scan them right away. 63 | CLAP_NOTE_PORTS_RESCAN_NAMES = 1 << 1, 64 | }; 65 | 66 | typedef struct clap_host_note_ports { 67 | // Query which dialects the host supports 68 | // [main-thread] 69 | uint32_t (*supported_dialects)(const clap_host_t *host); 70 | 71 | // Rescan the full list of note ports according to the flags. 72 | // [main-thread] 73 | void (*rescan)(const clap_host_t *host, uint32_t flags); 74 | } clap_host_note_ports_t; 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | -------------------------------------------------------------------------------- /Source/VSTPlugIn/StringConversions.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "string.h" 4 | 5 | 6 | 7 | 8 | 9 | //-------------------------------------------------------------------------------------------------- 10 | //functions for conversion from float-vst-parameter to string: 11 | /* 12 | void bpm2String(float value, char *string) 13 | { 14 | double mappedValue = value*200 + 50; //from 50 to 250 bpm 15 | if(value==0.0) 16 | sprintf(string, //pointer where the string is to be stored 17 | "%s", //format string, indicates that a string type parameter follows 18 | "sync"); //the parameter of type string 19 | else 20 | sprintf(string, //pointer where the string is to be stored 21 | "%.2f", //format string, indicates that a double/float type parameter 22 | //follows and should be orunded to 2 digits 23 | mappedValue); //the parameter of type double/float 24 | } 25 | 26 | void percent2String(float value, char* string) 27 | { 28 | double mappedValue = 100*value; 29 | sprintf(string, //pointer where the string is to be stored 30 | "%.1f %s", //format string, indicates that the first parameter (after the 31 | //format parameters) will be a double/float type parameter 32 | //and should be runded to 1 digit and the second one will be a 33 | //string type parameter 34 | mappedValue, //the parameter of type double/float 35 | "%"); //the parameter of type string (the "%" character in this case) 36 | } 37 | 38 | void scaler2String(float value, char* string) 39 | { 40 | double mappedValue = pow(4, (2*value - 1) ); //between 4^(-1) = 0.25 and 4^1 = 4 41 | sprintf(string, "%s %.2f", "*", mappedValue); 42 | } 43 | 44 | void numAndDen2String(float value, char* string) 45 | { 46 | long mappedValue = (long) floor(127*value+1); //from 1 to 128 47 | sprintf(string, "%i", mappedValue); 48 | } 49 | 50 | void Freq2String(float value, char* string) 51 | { 52 | double mappedValue = pow(1000,value)*20; //from 20 to 20000Hz 53 | sprintf(string, "%.0f", mappedValue); 54 | } 55 | 56 | void timeFactor2String(float value, char* string) 57 | { 58 | double mappedValue = pow(2, (2*value - 1) ); //between 2^(-1) = 0.5 and 2^1 = 2 59 | sprintf(string, "%.4f", mappedValue); 60 | } 61 | */ 62 | 63 | /* 64 | void phaseString2float(char *string, float& output) 65 | { 66 | output = 45.09; 67 | } 68 | */ 69 | 70 | 71 | void value2String(float value, char *string) 72 | { 73 | sprintf(string, "%.2f", value); 74 | } 75 | 76 | void phase2String(float value, char *string) 77 | { 78 | double mappedValue = 360.0*value; 79 | 80 | if( mappedValue <= 359.99 ) 81 | sprintf(string, "%.2f", mappedValue); 82 | else 83 | sprintf(string, "%s", "free"); 84 | } 85 | 86 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_AcidSequencer.cpp: -------------------------------------------------------------------------------- 1 | #include "rosic_AcidSequencer.h" 2 | using namespace rosic; 3 | 4 | //------------------------------------------------------------------------------------------------- 5 | // construction/destruction: 6 | 7 | AcidSequencer::AcidSequencer() 8 | { 9 | sampleRate = 44100.0; 10 | bpm = 140.0; 11 | activePattern = 0; 12 | running = false; 13 | countDown = 0; 14 | step = 0; 15 | sequencerMode = OFF; 16 | driftError = 0.0; 17 | modeChanged = false; 18 | 19 | for(int k=0; k<=12; k++) 20 | keyPermissible[k] = true; 21 | } 22 | 23 | //------------------------------------------------------------------------------------------------- 24 | // parameter settings: 25 | 26 | void AcidSequencer::setSampleRate(double newSampleRate) 27 | { 28 | if( newSampleRate > 0.0 ) 29 | sampleRate = newSampleRate; 30 | } 31 | 32 | void AcidSequencer::setMode(int newMode) 33 | { 34 | if( newMode >= 0 && newMode < NUM_SEQUENCER_MODES ) 35 | { 36 | sequencerMode = newMode; 37 | modeChanged = true; 38 | } 39 | } 40 | 41 | void AcidSequencer::setKeyPermissible(int key, bool shouldBePermissible) 42 | { 43 | if( key >= 0 && key <= 12 ) 44 | keyPermissible[key] = shouldBePermissible; 45 | } 46 | 47 | void AcidSequencer::toggleKeyPermissibility(int key) 48 | { 49 | if( key >= 0 && key <= 12 ) 50 | keyPermissible[key] = !keyPermissible[key]; 51 | } 52 | 53 | //------------------------------------------------------------------------------------------------- 54 | // inquiry: 55 | 56 | AcidPattern* AcidSequencer::getPattern(int index) 57 | { 58 | if( index < 0 || index >= numPatterns ) 59 | return NULL; 60 | else 61 | return &patterns[index]; 62 | } 63 | 64 | bool AcidSequencer::modeWasChanged() 65 | { 66 | bool result = modeChanged; 67 | modeChanged = false; 68 | return result; 69 | // mmm...wouldn't we need mutexes here? the mode changes from the GUI and modeWasChanged 70 | // is called from the audio-thread - otherwise note-hangs could happen? 71 | } 72 | 73 | bool AcidSequencer::isKeyPermissible(int key) 74 | { 75 | if( key >= 0 && key <= 12 ) 76 | return keyPermissible[key]; 77 | else 78 | return false; 79 | } 80 | 81 | //------------------------------------------------------------------------------------------------- 82 | // event handling: 83 | 84 | void AcidSequencer::start() 85 | { 86 | // set up members such that we will trap in the else-branch in the next call to getNote(): 87 | running = true; 88 | countDown = -1; 89 | step = 0; 90 | driftError = 0.0; 91 | } 92 | 93 | void AcidSequencer::stop() 94 | { 95 | running = false; 96 | } 97 | 98 | //------------------------------------------------------------------------------------------------- 99 | // others: 100 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/plugin-features.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "private/macros.h" 4 | 5 | // This file provides a set of standard plugin features meant to be used 6 | // within clap_plugin_descriptor.features. 7 | // 8 | // For practical reasons we'll avoid spaces and use `-` instead to facilitate 9 | // scripts that generate the feature array. 10 | // 11 | // Non-standard features should be formated as follow: "$namespace:$feature" 12 | 13 | ///////////////////// 14 | // Plugin category // 15 | ///////////////////// 16 | 17 | // Add this feature if your plugin can process note events and then produce audio 18 | #define CLAP_PLUGIN_FEATURE_INSTRUMENT "instrument" 19 | 20 | // Add this feature if your plugin is an audio effect 21 | #define CLAP_PLUGIN_FEATURE_AUDIO_EFFECT "audio-effect" 22 | 23 | // Add this feature if your plugin is a note effect or a note generator/sequencer 24 | #define CLAP_PLUGIN_FEATURE_NOTE_EFFECT "note-effect" 25 | 26 | // Add this feature if your plugin is an analyzer 27 | #define CLAP_PLUGIN_FEATURE_ANALYZER "analyzer" 28 | 29 | ///////////////////////// 30 | // Plugin sub-category // 31 | ///////////////////////// 32 | 33 | #define CLAP_PLUGIN_FEATURE_SYNTHESIZER "synthesizer" 34 | #define CLAP_PLUGIN_FEATURE_SAMPLER "sampler" 35 | #define CLAP_PLUGIN_FEATURE_DRUM "drum" // For single drum 36 | #define CLAP_PLUGIN_FEATURE_DRUM_MACHINE "drum-machine" 37 | 38 | #define CLAP_PLUGIN_FEATURE_FILTER "filter" 39 | #define CLAP_PLUGIN_FEATURE_PHASER "phaser" 40 | #define CLAP_PLUGIN_FEATURE_EQUALIZER "equalizer" 41 | #define CLAP_PLUGIN_FEATURE_DEESSER "de-esser" 42 | #define CLAP_PLUGIN_FEATURE_PHASE_VOCODER "phase-vocoder" 43 | #define CLAP_PLUGIN_FEATURE_GRANULAR "granular" 44 | #define CLAP_PLUGIN_FEATURE_FREQUENCY_SHIFTER "frequency-shifter" 45 | #define CLAP_PLUGIN_FEATURE_PITCH_SHIFTER "pitch-shifter" 46 | 47 | #define CLAP_PLUGIN_FEATURE_DISTORTION "distortion" 48 | #define CLAP_PLUGIN_FEATURE_TRANSIENT_SHAPER "transient-shaper" 49 | #define CLAP_PLUGIN_FEATURE_COMPRESSOR "compressor" 50 | #define CLAP_PLUGIN_FEATURE_LIMITER "limiter" 51 | 52 | #define CLAP_PLUGIN_FEATURE_FLANGER "flanger" 53 | #define CLAP_PLUGIN_FEATURE_CHORUS "chorus" 54 | #define CLAP_PLUGIN_FEATURE_DELAY "delay" 55 | #define CLAP_PLUGIN_FEATURE_REVERB "reverb" 56 | 57 | #define CLAP_PLUGIN_FEATURE_TREMOLO "tremolo" 58 | #define CLAP_PLUGIN_FEATURE_GLITCH "glitch" 59 | 60 | #define CLAP_PLUGIN_FEATURE_UTILITY "utility" 61 | #define CLAP_PLUGIN_FEATURE_PITCH_CORRECTION "pitch-correction" 62 | #define CLAP_PLUGIN_FEATURE_RESTORATION "restoration" // repair the sound 63 | 64 | #define CLAP_PLUGIN_FEATURE_MULTI_EFFECTS "multi-effects" 65 | 66 | #define CLAP_PLUGIN_FEATURE_MIXING "mixing" 67 | #define CLAP_PLUGIN_FEATURE_MASTERING "mastering" 68 | 69 | //////////////////////// 70 | // Audio Capabilities // 71 | //////////////////////// 72 | 73 | #define CLAP_PLUGIN_FEATURE_MONO "mono" 74 | #define CLAP_PLUGIN_FEATURE_STEREO "stereo" 75 | #define CLAP_PLUGIN_FEATURE_SURROUND "surround" 76 | #define CLAP_PLUGIN_FEATURE_AMBISONIC "ambisonic" 77 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_LeakyIntegrator.cpp: -------------------------------------------------------------------------------- 1 | #include "rosic_LeakyIntegrator.h" 2 | using namespace rosic; 3 | 4 | //------------------------------------------------------------------------------------------------- 5 | // construction/destruction: 6 | 7 | LeakyIntegrator::LeakyIntegrator() 8 | { 9 | sampleRate = 44100.0f; 10 | tau = 10.0f; 11 | y1 = 0.0; 12 | 13 | calculateCoefficient(); 14 | } 15 | 16 | LeakyIntegrator::~LeakyIntegrator() 17 | { 18 | 19 | } 20 | 21 | //------------------------------------------------------------------------------------------------- 22 | // parameter settings: 23 | 24 | void LeakyIntegrator::setSampleRate(double newSampleRate) 25 | { 26 | if( newSampleRate > 0.0 ) 27 | { 28 | sampleRate = newSampleRate; 29 | calculateCoefficient(); 30 | } 31 | } 32 | 33 | void LeakyIntegrator::setTimeConstant(double newTimeConstant) 34 | { 35 | if( newTimeConstant >= 0.0 && newTimeConstant != tau ) 36 | { 37 | tau = newTimeConstant; 38 | calculateCoefficient(); 39 | } 40 | } 41 | 42 | //------------------------------------------------------------------------------------------------- 43 | // inquiry: 44 | 45 | double LeakyIntegrator::getNormalizer(double tau1, double tau2, double fs) 46 | { 47 | double td = 0.001*tau1; 48 | double ta = 0.001*tau2; 49 | 50 | // catch some special cases: 51 | if( ta == 0.0 && td == 0.0 ) 52 | return 1.0; 53 | else if( ta == 0.0 ) 54 | { 55 | return 1.0 / (1.0-exp(-1.0/(fs*td))); 56 | } 57 | else if( td == 0.0 ) 58 | { 59 | return 1.0 / (1.0-exp(-1.0/(fs*ta))); 60 | } 61 | 62 | // compute the filter coefficients: 63 | double x = exp( -1.0 / (fs*td) ); 64 | double bd = 1-x; 65 | double ad = -x; 66 | x = exp( -1.0 / (fs*ta) ); 67 | double ba = 1-x; 68 | double aa = -x; 69 | 70 | // compute the location and height of the peak: 71 | double xp; 72 | if( ta == td ) 73 | { 74 | double tp = ta; 75 | double np = fs*tp; 76 | xp = (np+1.0)*ba*ba*pow(aa, np); 77 | } 78 | else 79 | { 80 | double tp = log(ta/td) / ( (1.0/td) - (1.0/ta) ); 81 | double np = fs*tp; 82 | double s = 1.0 / (aa-ad); 83 | double b01 = s * aa*ba*bd; 84 | double b02 = s * ad*ba*bd; 85 | double a01 = s * (ad-aa)*aa; 86 | double a02 = s * (ad-aa)*ad; 87 | xp = b01*pow(a01, np) - b02*pow(a02, np); 88 | } 89 | 90 | // return the normalizer as reciprocal of the peak height: 91 | return 1.0/xp; 92 | } 93 | 94 | //------------------------------------------------------------------------------------------------- 95 | // others: 96 | 97 | void LeakyIntegrator::reset() 98 | { 99 | y1 = 0; 100 | } 101 | 102 | void LeakyIntegrator::calculateCoefficient() 103 | { 104 | if( tau > 0.0 ) 105 | coeff = exp( -1.0 / (sampleRate*0.001*tau) ); 106 | else 107 | coeff = 0.0; 108 | } 109 | 110 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_LeakyIntegrator.h: -------------------------------------------------------------------------------- 1 | #ifndef rosic_LeakyIntegrator_h 2 | #define rosic_LeakyIntegrator_h 3 | 4 | // rosic-indcludes: 5 | #include "rosic_RealFunctions.h" 6 | 7 | namespace rosic 8 | { 9 | 10 | /** 11 | 12 | This is a leaky integrator type lowpass filter with user adjustable time constant which is set 13 | up in milliseconds. 14 | 15 | */ 16 | 17 | class LeakyIntegrator 18 | { 19 | 20 | public: 21 | 22 | //--------------------------------------------------------------------------------------------- 23 | // construction/destruction: 24 | 25 | /** Constructor. */ 26 | LeakyIntegrator(); 27 | 28 | /** Destructor. */ 29 | ~LeakyIntegrator(); 30 | 31 | //--------------------------------------------------------------------------------------------- 32 | // parameter settings: 33 | 34 | /** Sets the sample-rate. */ 35 | void setSampleRate(double newSampleRate); 36 | 37 | /** Sets the time constant (tau), value is expected in milliseconds. */ 38 | void setTimeConstant(double newTimeConstant); 39 | 40 | /** Sets the internal state of the filter to the passed value. */ 41 | void setState(double newState) { y1 = newState; } 42 | 43 | //--------------------------------------------------------------------------------------------- 44 | // inquiry: 45 | 46 | /** Returns the time constant (tau) in milliseconds. */ 47 | double getTimeConstant() const { return tau; } 48 | 49 | /** Returns the normalizer, required to normalize the impulse response of a series connection 50 | of two digital RC-type filters with time constants tau1 and tau2 (in milliseconds) to unity at 51 | the given samplerate. */ 52 | static double getNormalizer(double tau1, double tau2, double sampleRate); 53 | 54 | //--------------------------------------------------------------------------------------------- 55 | // audio processing: 56 | 57 | /** Calculates one sample at a time. */ 58 | INLINE double getSample(double in); 59 | 60 | //--------------------------------------------------------------------------------------------- 61 | // others: 62 | 63 | /** Resets the internal state of the filter. */ 64 | void reset(); 65 | 66 | //============================================================================================= 67 | 68 | protected: 69 | 70 | /** Calculates the filter coefficient. */ 71 | void calculateCoefficient(); 72 | 73 | double coeff; // filter coefficient 74 | double y1; // previous output sample 75 | double sampleRate; // the samplerate 76 | double tau; // time constant in milliseconds 77 | 78 | }; 79 | 80 | //----------------------------------------------------------------------------------------------- 81 | // inlined functions: 82 | 83 | INLINE double LeakyIntegrator::getSample(double in) 84 | { 85 | return y1 = in + coeff*(y1-in); 86 | } 87 | 88 | } // end namespace rosic 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /Source/DSPCode/GlobalDefinitions.h: -------------------------------------------------------------------------------- 1 | #ifndef GlobalDefinitions_h 2 | #define GlobalDefinitions_h 3 | 4 | #include 5 | 6 | /** This file contains a bunch of useful macros which are not wrapped into the 7 | rosic namespace to facilitate their global use. */ 8 | 9 | #ifdef _MSC_VER 10 | #define INLINE __forceinline 11 | #else 12 | #define INLINE inline // something better to do here ? 13 | #endif 14 | 15 | //_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON) 16 | 17 | //------------------------------------------------------------------------------------------------- 18 | // mathematical constants: 19 | 20 | #define PI 3.1415926535897932384626433832795 21 | #define EULER 2.7182818284590452353602874713527 22 | #define SQRT2 1.4142135623730950488016887242097 23 | #define ONE_OVER_SQRT2 0.70710678118654752440084436210485 24 | #define LN10 2.3025850929940456840179914546844 25 | #define ONE_OVER_LN10 0.43429448190325182765112891891661 26 | #define LN2 0.69314718055994530941723212145818 27 | #define ONE_OVER_LN2 1.4426950408889634073599246810019 28 | #define SEMITONE_FACTOR 1.0594630943592952645618252949463 29 | 30 | //------------------------------------------------------------------------------------------------- 31 | // type definitions: 32 | 33 | // unsigned 64 bit integers: 34 | #ifdef _MSC_VER 35 | typedef unsigned __int64 UINT64; 36 | #else 37 | typedef unsigned long long UINT64; 38 | #endif 39 | 40 | // signed 64 bit integers: 41 | #ifdef _MSC_VER 42 | typedef signed __int64 INT64; 43 | #else 44 | typedef signed long long INT64; 45 | #endif 46 | 47 | // unsigned 32 bit integers: 48 | #ifdef _MSC_VER 49 | typedef unsigned __int32 UINT32; 50 | #else 51 | typedef unsigned long UINT32; 52 | #endif 53 | 54 | // ...constants for numerical precision issues, denorm, etc.: 55 | #define TINY FLT_MIN 56 | #define EPS DBL_EPSILON 57 | 58 | // define infinity values: 59 | 60 | inline double dummyFunction(double x) { return x; } 61 | #define INF (1.0/dummyFunction(0.0)) 62 | #define NEG_INF (-1.0/dummyFunction(0.0)) 63 | 64 | //------------------------------------------------------------------------------------------------- 65 | // debug stuff: 66 | 67 | // this will try to break the debugger if one is currently hosting this app: 68 | #ifdef _DEBUG 69 | 70 | #ifdef _MSC_VER 71 | #pragma intrinsic (__debugbreak) 72 | #define DEBUG_BREAK __debugbreak(); 73 | #else 74 | #define DEBUG_BREAK {} 75 | #endif 76 | 77 | #else 78 | 79 | #define DEBUG_BREAK {} // evaluate to no op in release builds 80 | 81 | #endif 82 | 83 | // an replacement of the ASSERT macro 84 | #define rassert(expression) { if (! (expression)) DEBUG_BREAK } 85 | 86 | //------------------------------------------------------------------------------------------------- 87 | // bit twiddling: 88 | 89 | //extract the exponent from a IEEE 754 floating point number (single and double precision): 90 | #define EXPOFFLT(value) (((*((reinterpret_cast(&value)))&0x7FFFFFFF)>>23)-127) 91 | #define EXPOFDBL(value) (((*((reinterpret_cast(&value)))&0x7FFFFFFFFFFFFFFFULL)>>52)-1023) 92 | // ULL indicates an unsigned long long literal constant 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/draft/file-reference.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../plugin.h" 4 | #include "../../string-sizes.h" 5 | 6 | static CLAP_CONSTEXPR const char CLAP_EXT_FILE_REFERENCE[] = "clap.file-reference.draft/0"; 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | /// @page File Reference 13 | /// 14 | /// This extension provides a way for the host to know about files which are used 15 | /// by the plugin, like a wavetable, a sample, ... 16 | /// 17 | /// The host can then: 18 | /// - collect and save 19 | /// - search for missing files by using: 20 | /// - filename 21 | /// - hash 22 | /// - file size 23 | /// - be aware that some external file references are marked as dirty and need to be saved. 24 | /// 25 | /// Regarding the hashing algorithm, as of 2022 BLAKE3 seems to be the best choice in regards to 26 | /// performances and robustness while also providing a very small pure C library with permissive 27 | /// licensing. For more info see https://github.com/BLAKE3-team/BLAKE3 28 | /// 29 | /// This extension only exposes one hashing algorithm on purpose. 30 | 31 | // This describes a file currently used by the plugin 32 | typedef struct clap_file_reference { 33 | clap_id resource_id; 34 | bool belongs_to_plugin_collection; 35 | 36 | size_t path_capacity; // [in] the number of bytes reserved in path 37 | size_t path_size; // [out] the actual length of the path, can be bigger than path_capacity 38 | char *path; // [in,out] path to the file on the disk, must be null terminated, and may be 39 | // truncated if the capacity is less than the size 40 | } clap_file_reference_t; 41 | 42 | typedef struct clap_plugin_file_reference { 43 | // returns the number of file reference this plugin has 44 | // [main-thread] 45 | uint32_t (*count)(const clap_plugin_t *plugin); 46 | 47 | // gets the file reference at index 48 | // returns true on success 49 | // [main-thread] 50 | bool (*get)(const clap_plugin_t *plugin, uint32_t index, clap_file_reference_t *file_reference); 51 | 52 | // This method can be called even if the file is missing. 53 | // So the plugin is encouraged to store the digest in its state. 54 | // 55 | // digest is an array of 32 bytes. 56 | // 57 | // [main-thread] 58 | bool (*get_blake3_digest)(const clap_plugin_t *plugin, clap_id resource_id, uint8_t *digest); 59 | 60 | // This method can be called even if the file is missing. 61 | // So the plugin is encouraged to store the file's size in its state. 62 | // 63 | // [main-thread] 64 | bool (*get_file_size)(const clap_plugin_t *plugin, clap_id resource_id, uint64_t *size); 65 | 66 | // updates the path to a file reference 67 | // [main-thread] 68 | bool (*update_path)(const clap_plugin_t *plugin, clap_id resource_id, const char *path); 69 | 70 | // [main-thread] 71 | bool (*save_resources)(const clap_plugin_t *plugin); 72 | } clap_plugin_file_reference_t; 73 | 74 | typedef struct clap_host_file_reference { 75 | // informs the host that the file references have changed, the host should schedule a full rescan 76 | // [main-thread] 77 | void (*changed)(const clap_host_t *host); 78 | 79 | // [main-thread] 80 | void (*set_dirty)(const clap_host_t *host, clap_id resource_id); 81 | } clap_host_file_reference; 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_TeeBeeFilter.cpp: -------------------------------------------------------------------------------- 1 | #include "rosic_TeeBeeFilter.h" 2 | using namespace rosic; 3 | 4 | //------------------------------------------------------------------------------------------------- 5 | // construction/destruction: 6 | 7 | TeeBeeFilter::TeeBeeFilter() 8 | { 9 | cutoff = 1000.0; 10 | drive = 0.0; 11 | driveFactor = 1.0; 12 | resonanceRaw = 0.0; 13 | resonanceSkewed = 0.0; 14 | g = 1.0; 15 | sampleRate = 44100.0; 16 | twoPiOverSampleRate = 2.0*PI/sampleRate; 17 | 18 | feedbackHighpass.setMode(OnePoleFilter::HIGHPASS); 19 | feedbackHighpass.setCutoff(150.0); 20 | 21 | //setMode(LP_18); 22 | setMode(TB_303); 23 | calculateCoefficientsExact(); 24 | reset(); 25 | } 26 | 27 | TeeBeeFilter::~TeeBeeFilter() 28 | { 29 | 30 | } 31 | 32 | //------------------------------------------------------------------------------------------------- 33 | // parameter settings: 34 | 35 | void TeeBeeFilter::setSampleRate(double newSampleRate) 36 | { 37 | if( newSampleRate > 0.0 ) 38 | sampleRate = newSampleRate; 39 | twoPiOverSampleRate = 2.0*PI/sampleRate; 40 | feedbackHighpass.setSampleRate(newSampleRate); 41 | calculateCoefficientsExact(); 42 | } 43 | 44 | void TeeBeeFilter::setDrive(double newDrive) 45 | { 46 | drive = newDrive; 47 | driveFactor = dB2amp(drive); 48 | } 49 | 50 | void TeeBeeFilter::setMode(int newMode) 51 | { 52 | if( newMode >= 0 && newMode < NUM_MODES ) 53 | { 54 | mode = newMode; 55 | switch(mode) 56 | { 57 | case FLAT: c0 = 1.0; c1 = 0.0; c2 = 0.0; c3 = 0.0; c4 = 0.0; break; 58 | case LP_6: c0 = 0.0; c1 = 1.0; c2 = 0.0; c3 = 0.0; c4 = 0.0; break; 59 | case LP_12: c0 = 0.0; c1 = 0.0; c2 = 1.0; c3 = 0.0; c4 = 0.0; break; 60 | case LP_18: c0 = 0.0; c1 = 0.0; c2 = 0.0; c3 = 1.0; c4 = 0.0; break; 61 | case LP_24: c0 = 0.0; c1 = 0.0; c2 = 0.0; c3 = 0.0; c4 = 1.0; break; 62 | case HP_6: c0 = 1.0; c1 = -1.0; c2 = 0.0; c3 = 0.0; c4 = 0.0; break; 63 | case HP_12: c0 = 1.0; c1 = -2.0; c2 = 1.0; c3 = 0.0; c4 = 0.0; break; 64 | case HP_18: c0 = 1.0; c1 = -3.0; c2 = 3.0; c3 = -1.0; c4 = 0.0; break; 65 | case HP_24: c0 = 1.0; c1 = -4.0; c2 = 6.0; c3 = -4.0; c4 = 1.0; break; 66 | case BP_12_12: c0 = 0.0; c1 = 0.0; c2 = 1.0; c3 = -2.0; c4 = 1.0; break; 67 | case BP_6_18: c0 = 0.0; c1 = 0.0; c2 = 0.0; c3 = 1.0; c4 = -1.0; break; 68 | case BP_18_6: c0 = 0.0; c1 = 1.0; c2 = -3.0; c3 = 3.0; c4 = -1.0; break; 69 | case BP_6_12: c0 = 0.0; c1 = 0.0; c2 = 1.0; c3 = -1.0; c4 = 0.0; break; 70 | case BP_12_6: c0 = 0.0; c1 = 1.0; c2 = -2.0; c3 = 1.0; c4 = 0.0; break; 71 | case BP_6_6: c0 = 0.0; c1 = 1.0; c2 = -1.0; c3 = 0.0; c4 = 0.0; break; 72 | default: c0 = 1.0; c1 = 0.0; c2 = 0.0; c3 = 0.0; c4 = 0.0; // flat 73 | } 74 | } 75 | calculateCoefficientsApprox4(); 76 | } 77 | 78 | //------------------------------------------------------------------------------------------------- 79 | // others: 80 | 81 | void TeeBeeFilter::reset() 82 | { 83 | feedbackHighpass.reset(); 84 | y1 = 0.0; 85 | y2 = 0.0; 86 | y3 = 0.0; 87 | y4 = 0.0; 88 | } 89 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_DecayEnvelope.h: -------------------------------------------------------------------------------- 1 | #ifndef rosic_DecayEnvelope_h 2 | #define rosic_DecayEnvelope_h 3 | 4 | // rosic-indcludes: 5 | #include "rosic_RealFunctions.h" 6 | 7 | namespace rosic 8 | { 9 | 10 | /** 11 | 12 | This is a class implements an envelope generator that realizes a pure exponential decay. The 13 | output of the envelope is normalized to the range 0...1. 14 | 15 | */ 16 | 17 | class DecayEnvelope 18 | { 19 | 20 | public: 21 | 22 | //--------------------------------------------------------------------------------------------- 23 | // construction/destruction: 24 | 25 | /** Constructor. */ 26 | DecayEnvelope(); 27 | 28 | /** Destructor. */ 29 | ~DecayEnvelope(); 30 | 31 | //--------------------------------------------------------------------------------------------- 32 | // parameter settings: 33 | 34 | /** Sets the sample-rate. */ 35 | void setSampleRate(double newSampleRate); 36 | 37 | /** Sets the time constant for the multiplicative accumulator (which we consider as primarily 38 | responsible for the decaying part) in milliseconds. */ 39 | void setDecayTimeConstant(double newTimeConstant); 40 | 41 | /** Switches into a mode where the normalization is not made with respect to the peak amplitude 42 | but to the sum of the impulse response - if true, the output will be equivalent to a leaky 43 | integrator's impulse response. */ 44 | void setNormalizeSum(bool shouldNormalizeSum); 45 | 46 | //--------------------------------------------------------------------------------------------- 47 | // inquiry: 48 | 49 | /** Returns the length of the decay phase (in milliseconds). */ 50 | double getDecayTimeConstant() const { return tau; } 51 | 52 | /** True, if output is below some threshold. */ 53 | bool endIsReached(double threshold); 54 | 55 | //--------------------------------------------------------------------------------------------- 56 | // audio processing: 57 | 58 | /** Calculates one output sample at a time. */ 59 | INLINE double getSample(); 60 | 61 | //--------------------------------------------------------------------------------------------- 62 | // others: 63 | 64 | /** Triggers the envelope - the next sample retrieved via getSample() will be 1. */ 65 | void trigger(); 66 | 67 | protected: 68 | 69 | /** Calculates the coefficient for multiplicative accumulation. */ 70 | void calculateCoefficient(); 71 | 72 | double c; // coefficient for multiplicative accumulation 73 | double y; // previous output 74 | double yInit; // initial yalue for previous output (= y/c) 75 | double tau; // time-constant (in milliseconds) 76 | double fs; // sample-rate 77 | bool normalizeSum; // flag to indicate that the output should be normalized such that the 78 | // sum of the impulse response is unity (instead of the peak) - if true 79 | // the output will be equivalent to a leaky integrator's impulse 80 | // response 81 | 82 | }; 83 | 84 | //----------------------------------------------------------------------------------------------- 85 | // inlined functions: 86 | 87 | INLINE double DecayEnvelope::getSample() 88 | { 89 | y *= c; 90 | return y; 91 | } 92 | 93 | } // end namespace rosic 94 | 95 | #endif // rosic_DecayEnvelope_h 96 | -------------------------------------------------------------------------------- /Build/CodeBlocks/Open303.layout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/draft/surround.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../plugin.h" 4 | 5 | // This extension can be used to specify the channel mapping used by the plugin. 6 | // 7 | // To have consistent surround features across all the plugin instances, 8 | // here is the proposed workflow: 9 | // 1. the plugin queries the host preferred channel mapping and 10 | // adjusts its configuration to match it. 11 | // 2. the host checks how the plugin is effectively configured and honors it. 12 | // 13 | // If the host decides to change the project's surround setup: 14 | // 1. deactivate the plugin 15 | // 2. host calls clap_plugin_surround->changed() 16 | // 3. plugin calls clap_host_surround->get_preferred_channel_map() 17 | // 4. plugin eventually calls clap_host_surround->changed() 18 | // 5. host calls clap_plugin_surround->get_channel_map() if changed 19 | // 6. host activates the plugin and can start processing audio 20 | // 21 | // If the plugin wants to change its surround setup: 22 | // 1. call host->request_restart() if the plugin is active 23 | // 2. once deactivated plugin calls clap_host_surround->changed() 24 | // 3. host calls clap_plugin_surround->get_channel_map() 25 | // 4. host activates the plugin and can start processing audio 26 | 27 | static CLAP_CONSTEXPR const char CLAP_EXT_SURROUND[] = "clap.surround.draft/1"; 28 | 29 | static CLAP_CONSTEXPR const char CLAP_PORT_SURROUND[] = "surround"; 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | enum { 36 | CLAP_SURROUND_FL = 0, // Front Left 37 | CLAP_SURROUND_FR = 1, // Front Right 38 | CLAP_SURROUND_FC = 2, // Front Center 39 | CLAP_SURROUND_LFE = 3, // Low Frequency 40 | CLAP_SURROUND_BL = 4, // Back Left 41 | CLAP_SURROUND_BR = 5, // Back Right 42 | CLAP_SURROUND_FLC = 6, // Front Left of Center 43 | CLAP_SURROUND_FRC = 7, // Front Right of Center 44 | CLAP_SURROUND_BC = 8, // Back Center 45 | CLAP_SURROUND_SL = 9, // Side Left 46 | CLAP_SURROUND_SR = 10, // Side Right 47 | CLAP_SURROUND_TC = 11, // Top Center 48 | CLAP_SURROUND_TFL = 12, // Front Left Height 49 | CLAP_SURROUND_TFC = 13, // Front Center Height 50 | CLAP_SURROUND_TFR = 14, // Front Right Height 51 | CLAP_SURROUND_TBL = 15, // Rear Left Height 52 | CLAP_SURROUND_TBC = 16, // Rear Center Height 53 | CLAP_SURROUND_TBR = 17, // Rear Right Height 54 | }; 55 | 56 | typedef struct clap_plugin_surround { 57 | // Stores into the channel_map array, the surround identifer of each channels. 58 | // Returns the number of elements stored in channel_map 59 | // [main-thread] 60 | uint32_t (*get_channel_map)(const clap_plugin_t *plugin, 61 | bool is_input, 62 | uint32_t port_index, 63 | uint8_t *channel_map, 64 | uint32_t channel_map_capacity); 65 | 66 | // Informs the plugin that the host preferred channel map has changed. 67 | // [main-thread] 68 | void (*changed)(const clap_plugin_t *plugin); 69 | } clap_plugin_surround_t; 70 | 71 | typedef struct clap_host_surround { 72 | // Informs the host that the channel map has changed. 73 | // The channel map can only change when the plugin is de-activated. 74 | // [main-thread] 75 | void (*changed)(const clap_host_t *host); 76 | 77 | // Ask the host what is the prefered/project surround channel map. 78 | // [main-thread] 79 | void (*get_preferred_channel_map)(const clap_host_t *host, 80 | uint8_t *channel_map, 81 | uint32_t channel_map_capacity, 82 | uint32_t *channel_count); 83 | } clap_host_surround_t; 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_BiquadFilter.h: -------------------------------------------------------------------------------- 1 | #ifndef rosic_BiquadFilter_h 2 | #define rosic_BiquadFilter_h 3 | 4 | // rosic-indcludes: 5 | #include "rosic_RealFunctions.h" 6 | 7 | namespace rosic 8 | { 9 | 10 | /** 11 | 12 | This is an implementation of a simple one-pole filter unit. 13 | 14 | */ 15 | 16 | class BiquadFilter 17 | { 18 | 19 | public: 20 | 21 | /** Enumeration of the available filter modes. */ 22 | enum modes 23 | { 24 | BYPASS = 0, 25 | LOWPASS6, 26 | LOWPASS12, 27 | HIGHPASS6, 28 | HIGHPASS12, 29 | BANDPASS, 30 | BANDREJECT, 31 | PEAK, 32 | LOW_SHELF, 33 | //HIGH_SHELF, 34 | //ALLPASS, 35 | 36 | NUM_FILTER_MODES 37 | }; 38 | 39 | //--------------------------------------------------------------------------------------------- 40 | // construction/destruction: 41 | 42 | /** Constructor. */ 43 | BiquadFilter(); 44 | 45 | //--------------------------------------------------------------------------------------------- 46 | // parameter settings: 47 | 48 | /** Sets the sample-rate (in Hz) at which the filter runs. */ 49 | void setSampleRate(double newSampleRate); 50 | 51 | /** Sets the filter mode as one of the values in enum modes. */ 52 | void setMode(int newMode); 53 | 54 | /** Sets the center frequency in Hz. */ 55 | void setFrequency(double newFrequency); 56 | 57 | /** Sets the boost/cut gain in dB. */ 58 | void setGain(double newGain); 59 | 60 | /** Sets the bandwidth in octaves. */ 61 | void setBandwidth(double newBandwidth); 62 | 63 | //--------------------------------------------------------------------------------------------- 64 | // inquiry 65 | 66 | /** Sets the filter mode as one of the values in enum modes. */ 67 | int getMode() const { return mode; } 68 | 69 | /** Returns the center frequency in Hz. */ 70 | double getFrequency() const { return frequency; } 71 | 72 | /** Returns the boost/cut gain in dB. */ 73 | double getGain() const { return gain; } 74 | 75 | /** Returns the bandwidth in octaves. */ 76 | double getBandwidth() const { return bandwidth; } 77 | 78 | //--------------------------------------------------------------------------------------------- 79 | // audio processing: 80 | 81 | /** Calculates a single filtered output-sample. */ 82 | INLINE double getSample(double in); 83 | 84 | //--------------------------------------------------------------------------------------------- 85 | // others: 86 | 87 | /** Resets the internal buffers (for the \f$ x[n-1], y[n-1] \f$-samples) to zero. */ 88 | void reset(); 89 | 90 | //============================================================================================= 91 | 92 | protected: 93 | 94 | // internal functions: 95 | void calcCoeffs(); // calculates filter coefficients from filter parameters 96 | 97 | double b0, b1, b2, a1, a2; 98 | double x1, x2, y1, y2; 99 | 100 | double frequency, gain, bandwidth; 101 | double sampleRate; 102 | int mode; 103 | 104 | }; 105 | 106 | //----------------------------------------------------------------------------------------------- 107 | // inlined functions: 108 | 109 | INLINE double BiquadFilter::getSample(double in) 110 | { 111 | // calculate the output sample: 112 | double y = b0*in + b1*x1 + b2*x2 + a1*y1 + a2*y2 + TINY; 113 | 114 | // update the buffer variables: 115 | x2 = x1; 116 | x1 = in; 117 | y2 = y1; 118 | y1 = y; 119 | 120 | return y; 121 | } 122 | 123 | } // end namespace rosic 124 | 125 | #endif // rosic_BiquadFilter_h 126 | -------------------------------------------------------------------------------- /Source/VSTPlugIn/Open303VST.h: -------------------------------------------------------------------------------- 1 | #ifndef Open303VST_h 2 | #define Open303VST_h 3 | 4 | #include "public.sdk/source/vst2.x/audioeffectx.h" 5 | #include "../DSPCode/rosic_Open303.h" 6 | using namespace rosic; 7 | 8 | //#define SHOW_INTERNAL_PARAMETERS // comment this for builds that should only show 'user'-parameters 9 | 10 | enum Open303Parameters 11 | { 12 | WAVEFORM = 0, 13 | TUNING, 14 | CUTOFF, 15 | RESONANCE, 16 | ENVMOD, 17 | DECAY, 18 | ACCENT, 19 | VOLUME, 20 | 21 | FILTER_TYPE, 22 | 23 | #ifdef SHOW_INTERNAL_PARAMETERS 24 | AMP_SUSTAIN, 25 | TANH_SHAPER_DRIVE, 26 | TANH_SHAPER_OFFSET, 27 | PRE_FILTER_HPF, 28 | FEEDBACK_HPF, 29 | POST_FILTER_HPF, 30 | SQUARE_PHASE_SHIFT, 31 | #endif 32 | 33 | OPEN303_NUM_PARAMETERS 34 | }; 35 | 36 | //================================================================================================= 37 | // class Open303VSTProgram: 38 | 39 | class Open303VSTProgram 40 | { 41 | friend class Open303VST; 42 | public: 43 | Open303VSTProgram(); 44 | ~Open303VSTProgram() {} 45 | private: 46 | float parameters[OPEN303_NUM_PARAMETERS]; 47 | char name[kVstMaxProgNameLen+1]; 48 | }; 49 | 50 | //================================================================================================= 51 | // class Open303VST: 52 | 53 | class Open303VST : public AudioEffectX 54 | { 55 | public: 56 | 57 | // construction/destruction: 58 | Open303VST (audioMasterCallback audioMaster); 59 | ~Open303VST(); 60 | 61 | // audio- and event processing: 62 | virtual void processReplacing(float** inputs, float** outputs, VstInt32 sampleFrames); 63 | virtual VstInt32 processEvents (VstEvents* events); 64 | virtual void handleEvent (VstMidiEvent midiEvent); 65 | 66 | // program handling: 67 | virtual void setProgram (VstInt32 program); 68 | virtual void setProgramName (char* name); 69 | virtual void getProgramName (char* name); 70 | virtual bool getProgramNameIndexed(VstInt32 category, VstInt32 index, char* text); 71 | 72 | // parameter handling: 73 | virtual void setParameter (VstInt32 index, float value); 74 | virtual float getParameter (VstInt32 index); 75 | virtual void getParameterLabel (VstInt32 index, char* label); 76 | virtual void getParameterDisplay(VstInt32 index, char* text); 77 | virtual void getParameterName (VstInt32 index, char* text); 78 | 79 | // audio processing parameters: 80 | virtual void setSampleRate(float sampleRate); 81 | virtual void setBlockSize (VstInt32 blockSize); 82 | 83 | // callbacks to pass plugin info to the host: 84 | virtual bool getOutputProperties(VstInt32 index, VstPinProperties* properties); 85 | virtual bool getEffectName (char* name); 86 | virtual bool getVendorString (char* text); 87 | virtual bool getProductString(char* text); 88 | virtual VstInt32 getVendorVersion(); 89 | virtual VstInt32 canDo (char* text); 90 | virtual VstInt32 getNumMidiInputChannels () { return 1; } 91 | virtual VstInt32 getNumMidiOutputChannels() { return 0; } 92 | 93 | private: 94 | 95 | // internal functions: 96 | void noteOn(VstInt32 note, VstInt32 velocity, VstInt32 delta); 97 | 98 | /** Converts the data bytes of a MIDI pitchwheel message into a value in semitones. */ 99 | double convertToPitch(unsigned char highByte, unsigned char lowByte); 100 | 101 | static const int numOutputs = 2; 102 | static const int numPrograms = 128; 103 | 104 | // program handling: 105 | Open303VSTProgram* programs; 106 | VstInt32 channelPrograms[16]; 107 | 108 | // MIDI event handling: 109 | int eventBufferLength; 110 | VstEvent *eventBuffer; 111 | 112 | // the embedded core dsp object: 113 | Open303 open303Core; 114 | 115 | }; 116 | 117 | #endif 118 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_EllipticQuarterBandFilter.h: -------------------------------------------------------------------------------- 1 | #ifndef rosic_EllipticQuarterBandFilter_h 2 | #define rosic_EllipticQuarterBandFilter_h 3 | 4 | #include // for memmove 5 | 6 | // rosic-indcludes: 7 | #include "GlobalDefinitions.h" 8 | 9 | namespace rosic 10 | { 11 | 12 | /** 13 | 14 | This is an elliptic subband filter of 12th order using a Direct Form II implementation structure. 15 | 16 | */ 17 | 18 | class EllipticQuarterBandFilter 19 | { 20 | 21 | public: 22 | 23 | //--------------------------------------------------------------------------------------------- 24 | // construction/destruction: 25 | 26 | /** Constructor. */ 27 | EllipticQuarterBandFilter(); 28 | 29 | //--------------------------------------------------------------------------------------------- 30 | // parameter settings: 31 | 32 | /** Resets the filter state. */ 33 | void reset(); 34 | 35 | //--------------------------------------------------------------------------------------------- 36 | // audio processing: 37 | 38 | /** Calculates a single filtered output-sample. */ 39 | INLINE double getSample(double in); 40 | 41 | //============================================================================================= 42 | 43 | protected: 44 | 45 | // state buffer: 46 | double w[12]; 47 | 48 | }; 49 | 50 | //----------------------------------------------------------------------------------------------- 51 | // inlined functions: 52 | 53 | INLINE double EllipticQuarterBandFilter::getSample(double in) 54 | { 55 | const double a01 = -9.1891604652189471; 56 | const double a02 = 40.177553696870497; 57 | const double a03 = -110.11636661771178; 58 | const double a04 = 210.18506612078195; 59 | const double a05 = -293.84744771903240; 60 | const double a06 = 308.16345558359234; 61 | const double a07 = -244.06786780384243; 62 | const double a08 = 144.81877911392738; 63 | const double a09 = -62.770692151724198; 64 | const double a10 = 18.867762095902137; 65 | const double a11 = -3.5327094230551848; 66 | const double a12 = 0.31183189275203149; 67 | 68 | const double b00 = 0.00013671732099945628; 69 | const double b01 = -0.00055538501265606384; 70 | const double b02 = 0.0013681887636296387; 71 | const double b03 = -0.0022158566490711852; 72 | const double b04 = 0.0028320091007278322; 73 | const double b05 = -0.0029776933151090413; 74 | const double b06 = 0.0030283628243514991; 75 | const double b07 = -0.0029776933151090413; 76 | const double b08 = 0.0028320091007278331; 77 | const double b09 = -0.0022158566490711861; 78 | const double b10 = 0.0013681887636296393; 79 | const double b11 = -0.00055538501265606384; 80 | const double b12 = 0.00013671732099945636; 81 | 82 | // calculate intermediate and output sample via direct form II - the parentheses facilitate 83 | // out-of-order execution of the independent additions (for performance optimization): 84 | double tmp = (in + TINY) 85 | - ( (a01*w[0] + a02*w[1] ) + (a03*w[2] + a04*w[3] ) ) 86 | - ( (a05*w[4] + a06*w[5] ) + (a07*w[6] + a08*w[7] ) ) 87 | - ( (a09*w[8] + a10*w[9] ) + (a11*w[10] + a12*w[11] ) ); 88 | 89 | double y = b00*tmp 90 | + ( (b01*w[0] + b02*w[1]) + (b03*w[2] + b04*w[3] ) ) 91 | + ( (b05*w[4] + b06*w[5]) + (b07*w[6] + b08*w[7] ) ) 92 | + ( (b09*w[8] + b10*w[9]) + (b11*w[10] + b12*w[11] ) ); 93 | 94 | // update state variables: 95 | memmove(&w[1], &w[0], 11*sizeof(double)); 96 | w[0] = tmp; 97 | 98 | return y; 99 | } 100 | 101 | } // end namespace rosic 102 | 103 | #endif // rosic_EllipticQuarterBandFilter_h 104 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/plugin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "private/macros.h" 4 | #include "host.h" 5 | #include "process.h" 6 | #include "plugin-features.h" 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | typedef struct clap_plugin_descriptor { 13 | clap_version_t clap_version; // initialized to CLAP_VERSION 14 | 15 | // Mandatory fields must be set and must not be blank. 16 | // Otherwise the fields can be null or blank, though it is safer to make them blank. 17 | const char *id; // eg: "com.u-he.diva", mandatory 18 | const char *name; // eg: "Diva", mandatory 19 | const char *vendor; // eg: "u-he" 20 | const char *url; // eg: "https://u-he.com/products/diva/" 21 | const char *manual_url; // eg: "https://dl.u-he.com/manuals/plugins/diva/Diva-user-guide.pdf" 22 | const char *support_url; // eg: "https://u-he.com/support/" 23 | const char *version; // eg: "1.4.4" 24 | const char *description; // eg: "The spirit of analogue" 25 | 26 | // Arbitrary list of keywords. 27 | // They can be matched by the host indexer and used to classify the plugin. 28 | // The array of pointers must be null terminated. 29 | // For some standard features see plugin-features.h 30 | const char **features; 31 | } clap_plugin_descriptor_t; 32 | 33 | typedef struct clap_plugin { 34 | const clap_plugin_descriptor_t *desc; 35 | 36 | void *plugin_data; // reserved pointer for the plugin 37 | 38 | // Must be called after creating the plugin. 39 | // If init returns false, the host must destroy the plugin instance. 40 | // [main-thread] 41 | bool (*init)(const struct clap_plugin *plugin); 42 | 43 | // Free the plugin and its resources. 44 | // It is required to deactivate the plugin prior to this call. 45 | // [main-thread & !active] 46 | void (*destroy)(const struct clap_plugin *plugin); 47 | 48 | // Activate and deactivate the plugin. 49 | // In this call the plugin may allocate memory and prepare everything needed for the process 50 | // call. The process's sample rate will be constant and process's frame count will included in 51 | // the [min, max] range, which is bounded by [1, INT32_MAX]. 52 | // Once activated the latency and port configuration must remain constant, until deactivation. 53 | // 54 | // [main-thread & !active_state] 55 | bool (*activate)(const struct clap_plugin *plugin, 56 | double sample_rate, 57 | uint32_t min_frames_count, 58 | uint32_t max_frames_count); 59 | // [main-thread & active_state] 60 | void (*deactivate)(const struct clap_plugin *plugin); 61 | 62 | // Call start processing before processing. 63 | // [audio-thread & active_state & !processing_state] 64 | bool (*start_processing)(const struct clap_plugin *plugin); 65 | 66 | // Call stop processing before sending the plugin to sleep. 67 | // [audio-thread & active_state & processing_state] 68 | void (*stop_processing)(const struct clap_plugin *plugin); 69 | 70 | // - Clears all buffers, performs a full reset of the processing state (filters, oscillators, 71 | // enveloppes, lfo, ...) and kills all voices. 72 | // - The parameter's value remain unchanged. 73 | // - clap_process.steady_time may jump backward. 74 | // 75 | // [audio-thread & active_state] 76 | void (*reset)(const struct clap_plugin *plugin); 77 | 78 | // process audio, events, ... 79 | // [audio-thread & active_state & processing_state] 80 | clap_process_status (*process)(const struct clap_plugin *plugin, const clap_process_t *process); 81 | 82 | // Query an extension. 83 | // The returned pointer is owned by the plugin. 84 | // [thread-safe] 85 | const void *(*get_extension)(const struct clap_plugin *plugin, const char *id); 86 | 87 | // Called by the host on the main thread in response to a previous call to: 88 | // host->request_callback(host); 89 | // [main-thread] 90 | void (*on_main_thread)(const struct clap_plugin *plugin); 91 | } clap_plugin_t; 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_OnePoleFilter.cpp: -------------------------------------------------------------------------------- 1 | #include "rosic_OnePoleFilter.h" 2 | using namespace rosic; 3 | 4 | //------------------------------------------------------------------------------------------------- 5 | // construction/destruction: 6 | 7 | OnePoleFilter::OnePoleFilter() 8 | { 9 | shelvingGain = 1.0; 10 | setSampleRate(44100.0); // sampleRate = 44100 Hz by default 11 | setMode (0); // bypass by default 12 | setCutoff (20000.0); // cutoff = 20000 Hz by default 13 | reset(); // reset memorized samples to zero 14 | } 15 | 16 | //------------------------------------------------------------------------------------------------- 17 | // parameter settings: 18 | 19 | void OnePoleFilter::setSampleRate(double newSampleRate) 20 | { 21 | if( newSampleRate > 0.0 ) 22 | sampleRate = newSampleRate; 23 | sampleRateRec = 1.0 / sampleRate; 24 | 25 | calcCoeffs(); 26 | return; 27 | } 28 | 29 | void OnePoleFilter::setMode(int newMode) 30 | { 31 | mode = newMode; // 0:bypass, 1:Low Pass, 2:High Pass 32 | calcCoeffs(); 33 | } 34 | 35 | void OnePoleFilter::setCutoff(double newCutoff) 36 | { 37 | if( (newCutoff>0.0) && (newCutoff<=20000.0) ) 38 | cutoff = newCutoff; 39 | else 40 | cutoff = 20000.0; 41 | 42 | calcCoeffs(); 43 | return; 44 | } 45 | 46 | void OnePoleFilter::setShelvingGain(double newGain) 47 | { 48 | if( newGain > 0.0 ) 49 | { 50 | shelvingGain = newGain; 51 | calcCoeffs(); 52 | } 53 | else 54 | DEBUG_BREAK; // this is a linear gain factor and must be >= 0.0 55 | } 56 | 57 | void OnePoleFilter::setShelvingGainInDecibels(double newGain) 58 | { 59 | setShelvingGain(dB2amp(newGain)); 60 | } 61 | 62 | void OnePoleFilter::setCoefficients(double newB0, double newB1, double newA1) 63 | { 64 | b0 = newB0; 65 | b1 = newB1; 66 | a1 = newA1; 67 | } 68 | 69 | void OnePoleFilter::setInternalState(double newX1, double newY1) 70 | { 71 | x1 = newX1; 72 | y1 = newY1; 73 | } 74 | 75 | //------------------------------------------------------------------------------------------------- 76 | //others: 77 | 78 | void OnePoleFilter::calcCoeffs() 79 | { 80 | switch(mode) 81 | { 82 | case LOWPASS: 83 | { 84 | // formula from dspguide: 85 | double x = exp( -2.0 * PI * cutoff * sampleRateRec); 86 | b0 = 1-x; 87 | b1 = 0.0; 88 | a1 = x; 89 | } 90 | break; 91 | case HIGHPASS: 92 | { 93 | // formula from dspguide: 94 | double x = exp( -2.0 * PI * cutoff * sampleRateRec); 95 | b0 = 0.5*(1+x); 96 | b1 = -0.5*(1+x); 97 | a1 = x; 98 | } 99 | break; 100 | case LOWSHELV: 101 | { 102 | // formula from DAFX: 103 | double c = 0.5*(shelvingGain-1.0); 104 | double t = tan(PI*cutoff*sampleRateRec); 105 | double a; 106 | if( shelvingGain >= 1.0 ) 107 | a = (t-1.0)/(t+1.0); 108 | else 109 | a = (t-shelvingGain)/(t+shelvingGain); 110 | 111 | b0 = 1.0 + c + c*a; 112 | b1 = c + c*a + a; 113 | a1 = -a; 114 | } 115 | break; 116 | case HIGHSHELV: 117 | { 118 | // formula from DAFX: 119 | double c = 0.5*(shelvingGain-1.0); 120 | double t = tan(PI*cutoff*sampleRateRec); 121 | double a; 122 | if( shelvingGain >= 1.0 ) 123 | a = (t-1.0)/(t+1.0); 124 | else 125 | a = (shelvingGain*t-1.0)/(shelvingGain*t+1.0); 126 | 127 | b0 = 1.0 + c - c*a; 128 | b1 = a + c*a - c; 129 | a1 = -a; 130 | } 131 | break; 132 | 133 | case ALLPASS: 134 | { 135 | // formula from DAFX: 136 | double t = tan(PI*cutoff*sampleRateRec); 137 | double x = (t-1.0) / (t+1.0); 138 | 139 | b0 = x; 140 | b1 = 1.0; 141 | a1 = -x; 142 | } 143 | break; 144 | 145 | default: // bypass 146 | { 147 | b0 = 1.0; 148 | b1 = 0.0; 149 | a1 = 0.0; 150 | }break; 151 | } 152 | } 153 | 154 | void OnePoleFilter::reset() 155 | { 156 | x1 = 0.0; 157 | y1 = 0.0; 158 | } 159 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_OnePoleFilter.h: -------------------------------------------------------------------------------- 1 | #ifndef rosic_OnePoleFilter_h 2 | #define rosic_OnePoleFilter_h 3 | 4 | // rosic-indcludes: 5 | #include "rosic_RealFunctions.h" 6 | 7 | namespace rosic 8 | { 9 | 10 | /** 11 | 12 | This is an implementation of a simple one-pole filter unit. 13 | 14 | */ 15 | 16 | class OnePoleFilter 17 | { 18 | 19 | public: 20 | 21 | /** This is an enumeration of the available filter modes. */ 22 | enum modes 23 | { 24 | BYPASS = 0, 25 | LOWPASS, 26 | HIGHPASS, 27 | LOWSHELV, 28 | HIGHSHELV, 29 | ALLPASS 30 | }; 31 | // \todo (maybe): let the user choose between LP/HP versions obtained via bilinear trafo and 32 | // impulse invariant trafo 33 | 34 | //--------------------------------------------------------------------------------------------- 35 | // construction/destruction: 36 | 37 | /** Constructor. */ 38 | OnePoleFilter(); 39 | 40 | //--------------------------------------------------------------------------------------------- 41 | // parameter settings: 42 | 43 | /** Sets the sample-rate. */ 44 | void setSampleRate(double newSampleRate); 45 | 46 | /** Chooses the filter mode. See the enumeration for available modes. */ 47 | void setMode(int newMode); 48 | 49 | /** Sets the cutoff-frequency for this filter. */ 50 | void setCutoff(double newCutoff); 51 | 52 | /** This will set the time constant 'tau' for the case, when lowpass mode is chosen. This is 53 | the time, it takes for the impulse response to die away to 1/e = 0.368... or equivalently, the 54 | time it takes for the step response to raise to 1-1/e = 0.632... */ 55 | void setLowpassTimeConstant(double newTimeConstant) { setCutoff(1.0/(2*PI*newTimeConstant)); } 56 | 57 | /** Sets the gain factor for the shelving modes (this is not in decibels). */ 58 | void setShelvingGain(double newGain); 59 | 60 | /** Sets the gain for the shelving modes in decibels. */ 61 | void setShelvingGainInDecibels(double newGain); 62 | 63 | /** Sets the filter coefficients manually. */ 64 | void setCoefficients(double newB0, double newB1, double newA1); 65 | 66 | /** Sets up the internal state variables for both channels. */ 67 | void setInternalState(double newX1, double newY1); 68 | 69 | //--------------------------------------------------------------------------------------------- 70 | // inquiry 71 | 72 | /** Returns the cutoff-frequency. */ 73 | double getCutoff() const { return cutoff; } 74 | 75 | //--------------------------------------------------------------------------------------------- 76 | // audio processing: 77 | 78 | /** Calculates a single filtered output-sample. */ 79 | INLINE double getSample(double in); 80 | 81 | //--------------------------------------------------------------------------------------------- 82 | // others: 83 | 84 | /** Resets the internal buffers (for the \f$ x[n-1], y[n-1] \f$-samples) to zero. */ 85 | void reset(); 86 | 87 | //============================================================================================= 88 | 89 | protected: 90 | 91 | // buffering: 92 | double x1, y1; 93 | 94 | // filter coefficients: 95 | double b0; // feedforward coeffs 96 | double b1; 97 | double a1; // feedback coeff 98 | 99 | // filter parameters: 100 | double cutoff; 101 | double shelvingGain; 102 | int mode; 103 | 104 | double sampleRate; 105 | double sampleRateRec; // reciprocal of the sampleRate 106 | 107 | // internal functions: 108 | void calcCoeffs(); // calculates filter coefficients from filter parameters 109 | 110 | }; 111 | 112 | //----------------------------------------------------------------------------------------------- 113 | // inlined functions: 114 | 115 | INLINE double OnePoleFilter::getSample(double in) 116 | { 117 | // calculate the output sample: 118 | y1 = b0*in + b1*x1 + a1*y1 + TINY; 119 | 120 | // update the buffer variables: 121 | x1 = in; 122 | 123 | return y1; 124 | } 125 | 126 | } // end namespace rosic 127 | 128 | #endif // rosic_OnePoleFilter_h 129 | -------------------------------------------------------------------------------- /Libraries/clap/include/clap/ext/audio-ports.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../plugin.h" 4 | #include "../string-sizes.h" 5 | 6 | /// @page Audio Ports 7 | /// 8 | /// This extension provides a way for the plugin to describe its current audio ports. 9 | /// 10 | /// If the plugin does not implement this extension, it won't have audio ports. 11 | /// 12 | /// 32 bits support is required for both host and plugins. 64 bits audio is optional. 13 | /// 14 | /// The plugin is only allowed to change its ports configuration while it is deactivated. 15 | 16 | static CLAP_CONSTEXPR const char CLAP_EXT_AUDIO_PORTS[] = "clap.audio-ports"; 17 | static CLAP_CONSTEXPR const char CLAP_PORT_MONO[] = "mono"; 18 | static CLAP_CONSTEXPR const char CLAP_PORT_STEREO[] = "stereo"; 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | enum { 25 | // This port is the main audio input or output. 26 | // There can be only one main input and main output. 27 | // Main port must be at index 0. 28 | CLAP_AUDIO_PORT_IS_MAIN = 1 << 0, 29 | 30 | // This port can be used with 64 bits audio 31 | CLAP_AUDIO_PORT_SUPPORTS_64BITS = 1 << 1, 32 | 33 | // 64 bits audio is preferred with this port 34 | CLAP_AUDIO_PORT_PREFERS_64BITS = 1 << 2, 35 | 36 | // This port must be used with the same sample size as all the other ports which have this flag. 37 | // In other words if all ports have this flag then the plugin may either be used entirely with 38 | // 64 bits audio or 32 bits audio, but it can't be mixed. 39 | CLAP_AUDIO_PORT_REQUIRES_COMMON_SAMPLE_SIZE = 1 << 3, 40 | }; 41 | 42 | typedef struct clap_audio_port_info { 43 | // id identifies a port and must be stable. 44 | // id may overlap between input and output ports. 45 | clap_id id; 46 | char name[CLAP_NAME_SIZE]; // displayable name 47 | 48 | uint32_t flags; 49 | uint32_t channel_count; 50 | 51 | // If null or empty then it is unspecified (arbitrary audio). 52 | // This filed can be compared against: 53 | // - CLAP_PORT_MONO 54 | // - CLAP_PORT_STEREO 55 | // - CLAP_PORT_SURROUND (defined in the surround extension) 56 | // - CLAP_PORT_AMBISONIC (defined in the ambisonic extension) 57 | // - CLAP_PORT_CV (defined in the cv extension) 58 | // 59 | // An extension can provide its own port type and way to inspect the channels. 60 | const char *port_type; 61 | 62 | // in-place processing: allow the host to use the same buffer for input and output 63 | // if supported set the pair port id. 64 | // if not supported set to CLAP_INVALID_ID 65 | clap_id in_place_pair; 66 | } clap_audio_port_info_t; 67 | 68 | // The audio ports scan has to be done while the plugin is deactivated. 69 | typedef struct clap_plugin_audio_ports { 70 | // number of ports, for either input or output 71 | // [main-thread] 72 | uint32_t (*count)(const clap_plugin_t *plugin, bool is_input); 73 | 74 | // get info about about an audio port. 75 | // [main-thread] 76 | bool (*get)(const clap_plugin_t *plugin, 77 | uint32_t index, 78 | bool is_input, 79 | clap_audio_port_info_t *info); 80 | } clap_plugin_audio_ports_t; 81 | 82 | enum { 83 | // The ports name did change, the host can scan them right away. 84 | CLAP_AUDIO_PORTS_RESCAN_NAMES = 1 << 0, 85 | 86 | // [!active] The flags did change 87 | CLAP_AUDIO_PORTS_RESCAN_FLAGS = 1 << 1, 88 | 89 | // [!active] The channel_count did change 90 | CLAP_AUDIO_PORTS_RESCAN_CHANNEL_COUNT = 1 << 2, 91 | 92 | // [!active] The port type did change 93 | CLAP_AUDIO_PORTS_RESCAN_PORT_TYPE = 1 << 3, 94 | 95 | // [!active] The in-place pair did change, this requires. 96 | CLAP_AUDIO_PORTS_RESCAN_IN_PLACE_PAIR = 1 << 4, 97 | 98 | // [!active] The list of ports have changed: entries have been removed/added. 99 | CLAP_AUDIO_PORTS_RESCAN_LIST = 1 << 5, 100 | }; 101 | 102 | typedef struct clap_host_audio_ports { 103 | // Checks if the host allows a plugin to change a given aspect of the audio ports definition. 104 | // [main-thread] 105 | bool (*is_rescan_flag_supported)(const clap_host_t *host, uint32_t flag); 106 | 107 | // Rescan the full list of audio ports according to the flags. 108 | // It is illegal to ask the host to rescan with a flag that is not supported. 109 | // Certain flags require the plugin to be de-activated. 110 | // [main-thread] 111 | void (*rescan)(const clap_host_t *host, uint32_t flags); 112 | } clap_host_audio_ports_t; 113 | 114 | #ifdef __cplusplus 115 | } 116 | #endif 117 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_AcidPattern.h: -------------------------------------------------------------------------------- 1 | #ifndef rosic_AcidPattern_h 2 | #define rosic_AcidPattern_h 3 | 4 | // rosic-indcludes: 5 | #include "rosic_RealFunctions.h" 6 | #include "rosic_FunctionTemplates.h" 7 | 8 | namespace rosic 9 | { 10 | 11 | /** 12 | 13 | This is a class for representing note-events of acid-lines involving slides and accents. 14 | 15 | */ 16 | 17 | class AcidNote 18 | { 19 | public: 20 | 21 | int key; 22 | int octave; 23 | bool accent; 24 | bool slide; 25 | bool gate; 26 | 27 | AcidNote() 28 | { 29 | key = 0; 30 | octave = 0; 31 | accent = false; 32 | slide = false; 33 | gate = false; 34 | } 35 | 36 | bool isInDefaultState() 37 | { return key == 0 && octave == 0 && accent == false && slide == false && gate == false; } 38 | 39 | }; 40 | 41 | /** 42 | 43 | This is a class for representing typical acid-lines involving slides and accents. 44 | 45 | */ 46 | 47 | class AcidPattern 48 | { 49 | 50 | public: 51 | 52 | //--------------------------------------------------------------------------------------------- 53 | // construction/destruction: 54 | 55 | /** Constructor. */ 56 | AcidPattern(); 57 | 58 | //--------------------------------------------------------------------------------------------- 59 | // setup: 60 | 61 | /** Sets the length of one step (the time while gate is open) in units of one step (which 62 | is one 16th note). */ 63 | void setStepLength(double newStepLength) { stepLength = newStepLength; } 64 | 65 | /** Sets the key for one of the steps (between 0...12, where 0 and 12 is a C). */ 66 | void setKey(int step, int newKey) { notes[step].key = newKey; } 67 | 68 | /** Sets the octave for one of the steps (0 is the root octave between C2...B2). */ 69 | void setOctave(int step, int newOctave) { notes[step].octave = newOctave; } 70 | 71 | /** Sets the accent flag for one of the steps. */ 72 | void setAccent(int step, bool shouldBeAccented) { notes[step].accent = shouldBeAccented; } 73 | 74 | /** Sets the slide flag for one of the steps. */ 75 | void setSlide(int step, bool shouldHaveSlide) { notes[step].slide = shouldHaveSlide; } 76 | 77 | /** Sets the gate flag for one of the steps. */ 78 | void setGate(int step, bool shouldBeOpen) { notes[step].gate = shouldBeOpen; } 79 | 80 | /** Clears all notes in the pattern. */ 81 | void clear(); 82 | 83 | /** Randomizes all notes in the pattern. \todo: restrict possible note-values to some scales*/ 84 | void randomize(); 85 | 86 | /* 87 | void setRandomSeed(int newSeed); 88 | void resetRandomSeed(); 89 | void rendomizeGates(); 90 | void randomizeNotes(); 91 | void randomizeAccents(); 92 | void randomizeSlides(); 93 | void randomizeOctaves(int maxOctavesUp, int maxOctavesDown); 94 | */ 95 | 96 | /** Circularly shifts the whole pattern by the given number of steps. */ 97 | void circularShift(int numStepsToShift); 98 | 99 | //--------------------------------------------------------------------------------------------- 100 | // inquiry: 101 | 102 | /** Returns the length of one step (the time while gate is open) in units of one step (which 103 | is one 16th note). */ 104 | double getStepLength() const { return stepLength; } 105 | 106 | /** Returns the key for one of the steps (between 0...12, where 0 and 12 is a C). */ 107 | int getKey(int step) const { return notes[step].key; } 108 | 109 | /** Returns the octave for one of the steps (0 is the root octave between C2...B2). */ 110 | int getOctave(int step) const { return notes[step].octave; } 111 | 112 | /** Returns the accent flag for one of the steps. */ 113 | bool getAccent(int step) const { return notes[step].accent; } 114 | 115 | /** Returns the slide flag for one of the steps. */ 116 | bool getSlide(int step) const { return notes[step].slide; } 117 | 118 | /** Returns the gate flag for one of the steps. */ 119 | bool getGate(int step) const { return notes[step].gate; } 120 | 121 | /** Returns the maximum number of steps. */ 122 | static int getMaxNumSteps() { return maxNumSteps; } 123 | 124 | /** Returns the current number of steps. */ 125 | int getNumSteps() const { return numSteps; } 126 | 127 | /** Returns true if the pattern is empty, false otherwise. */ 128 | bool isEmpty() const; 129 | 130 | /** Returns a pointer to the note at the given step. */ 131 | AcidNote* getNote(int step) { return ¬es[step]; } 132 | 133 | //============================================================================================= 134 | 135 | protected: 136 | 137 | static const int maxNumSteps = 16; 138 | AcidNote notes[maxNumSteps]; 139 | 140 | int numSteps; // number of steps in the pattern 141 | double stepLength; // step length in step units (16th notes) 142 | 143 | }; 144 | 145 | } // end namespace rosic 146 | 147 | #endif // rosic_AcidPattern_h 148 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_AnalogEnvelope.cpp: -------------------------------------------------------------------------------- 1 | #include "rosic_AnalogEnvelope.h" 2 | using namespace rosic; 3 | 4 | //------------------------------------------------------------------------------------------------- 5 | // construction/destruction: 6 | 7 | AnalogEnvelope::AnalogEnvelope() 8 | { 9 | sampleRate = 44100.0; 10 | startLevel = 0.0; 11 | attackTime = 0.0; 12 | peakLevel = 1.0; 13 | holdTime = 0.0; 14 | decayTime = 0.1; 15 | sustainLevel = 0.5; 16 | releaseTime = 0.01; 17 | endLevel = 0.0; 18 | time = 0.0; 19 | timeScale = 1.0; 20 | peakByVel = 1.0; 21 | peakByKey = 1.0; 22 | timeScaleByVel = 1.0; 23 | timeScaleByKey = 1.0; 24 | increment = 1000.0*timeScale/sampleRate; 25 | tauScale = 1.0; 26 | peakScale = 1.0; 27 | noteIsOn = false; 28 | outputIsZero = true; 29 | 30 | previousOutput = 0.0; 31 | 32 | // call these functions to trigger the coefficient calculations: 33 | setAttack(attackTime); 34 | setDecay(decayTime); 35 | setRelease(releaseTime); 36 | } 37 | 38 | AnalogEnvelope::~AnalogEnvelope() 39 | { 40 | 41 | } 42 | 43 | //------------------------------------------------------------------------------------------------- 44 | // parameter settings: 45 | 46 | void AnalogEnvelope::setSampleRate(double newSampleRate) 47 | { 48 | if( newSampleRate > 0.0 ) 49 | sampleRate = newSampleRate; 50 | 51 | // adjust time increment: 52 | increment = 1000.0*timeScale/sampleRate; 53 | 54 | //re-calculate coefficients for the 3 filters: 55 | setAttack (attackTime); 56 | setDecay (decayTime); 57 | setRelease(releaseTime); 58 | } 59 | 60 | void AnalogEnvelope::setAttack(double newAttackTime) 61 | { 62 | if( newAttackTime > 0.0 ) 63 | { 64 | attackTime = newAttackTime; 65 | double tau = (sampleRate*0.001*attackTime) * tauScale/timeScale; 66 | attackCoeff = 1.0 - exp( -1.0 / tau ); 67 | } 68 | else // newAttackTime <= 0 69 | { 70 | attackTime = 0.0; 71 | attackCoeff = 1.0; 72 | } 73 | calculateAccumulatedTimes(); 74 | } 75 | 76 | void AnalogEnvelope::setHold(double newHoldTime) 77 | { 78 | if( newHoldTime >= 0 ) 79 | holdTime = newHoldTime; 80 | calculateAccumulatedTimes(); 81 | } 82 | 83 | void AnalogEnvelope::setDecay(double newDecayTime) 84 | { 85 | if( newDecayTime > 0.0 ) 86 | { 87 | decayTime = newDecayTime; 88 | double tau = (sampleRate*0.001*decayTime) * tauScale/timeScale; 89 | decayCoeff = 1.0 - exp( -1.0 / tau ); 90 | } 91 | else // newDecayTime <= 0 92 | { 93 | decayTime = 0.0; 94 | decayCoeff = 1.0; 95 | } 96 | calculateAccumulatedTimes(); 97 | } 98 | 99 | void AnalogEnvelope::setRelease(double newReleaseTime) 100 | { 101 | if( newReleaseTime > 0.0 ) 102 | { 103 | releaseTime = newReleaseTime; 104 | double tau = (sampleRate*0.001*releaseTime) * tauScale/timeScale; 105 | releaseCoeff = 1.0 - exp( -1.0 / tau ); 106 | } 107 | else // newReleaseTime <= 0 108 | { 109 | releaseTime = 0.0; 110 | releaseCoeff = 1.0; 111 | } 112 | calculateAccumulatedTimes(); 113 | } 114 | 115 | void AnalogEnvelope::setTimeScale(double newTimeScale) 116 | { 117 | if( newTimeScale > 0 ) 118 | timeScale = newTimeScale; 119 | 120 | increment = 1000.0*timeScale/sampleRate; 121 | 122 | //re-calculate coefficients for the 3 filters: 123 | setAttack (attackTime); 124 | setDecay (decayTime); 125 | setRelease(releaseTime); 126 | } 127 | 128 | void AnalogEnvelope::setTauScale(double newTauScale) 129 | { 130 | if( newTauScale > 0 ) 131 | tauScale = newTauScale; 132 | 133 | setAttack(attackTime); 134 | setDecay(decayTime); 135 | setRelease(releaseTime); 136 | } 137 | 138 | void AnalogEnvelope::setPeakScale(double newPeakScale) 139 | { 140 | if( newPeakScale > 0 ) 141 | peakScale = newPeakScale; 142 | } 143 | 144 | //------------------------------------------------------------------------------------------------- 145 | // others: 146 | 147 | void AnalogEnvelope::reset() 148 | { 149 | time = 0.0; 150 | } 151 | 152 | void AnalogEnvelope::noteOn(bool startFromCurrentLevel, int newKey, int newVel) 153 | { 154 | if( !startFromCurrentLevel ) 155 | previousOutput = startLevel; // may lead to clicks 156 | 157 | 158 | // \todo: calculate key and velocity scale factors for duration and peak-value... 159 | 160 | 161 | // reset time for the new note: 162 | time = 0.0; 163 | noteIsOn = true; 164 | outputIsZero = false; 165 | } 166 | 167 | void AnalogEnvelope::noteOff() 168 | { 169 | noteIsOn = false; 170 | 171 | // advance time to the beginnig of the release phase: 172 | time = (attackTime + holdTime + decayTime + increment); 173 | } 174 | 175 | bool AnalogEnvelope::endIsReached() 176 | { 177 | //return false; // test 178 | 179 | if( noteIsOn == false && previousOutput < 0.000001 ) 180 | return true; 181 | else 182 | return false; 183 | } 184 | 185 | //------------------------------------------------------------------------------------------------- 186 | // internal functions: 187 | 188 | void AnalogEnvelope::calculateAccumulatedTimes() 189 | { 190 | attPlusHld = attackTime + holdTime; 191 | attPlusHldPlusDec = attPlusHld + decayTime; 192 | attPlusHldPlusDecPlusRel = attPlusHldPlusDec + releaseTime; 193 | } 194 | -------------------------------------------------------------------------------- /Build/CodeBlocks/Open303.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 108 | 109 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_BiquadFilter.cpp: -------------------------------------------------------------------------------- 1 | #include "rosic_BiquadFilter.h" 2 | using namespace rosic; 3 | 4 | //------------------------------------------------------------------------------------------------- 5 | // construction/destruction: 6 | 7 | BiquadFilter::BiquadFilter() 8 | { 9 | frequency = 1000.0; 10 | gain = 0.0; 11 | bandwidth = 2.0*asinh(1.0/sqrt(2.0))/log(2.0); 12 | sampleRate = 44100.0; 13 | mode = BYPASS; 14 | calcCoeffs(); 15 | reset(); 16 | } 17 | 18 | //------------------------------------------------------------------------------------------------- 19 | // parameter settings: 20 | 21 | void BiquadFilter::setSampleRate(double newSampleRate) 22 | { 23 | if( newSampleRate > 0.0 ) 24 | sampleRate = newSampleRate; 25 | calcCoeffs(); 26 | } 27 | 28 | void BiquadFilter::setMode(int newMode) 29 | { 30 | mode = newMode; // 0:bypass, 1:Low Pass, 2:High Pass 31 | calcCoeffs(); 32 | } 33 | 34 | void BiquadFilter::setFrequency(double newFrequency) 35 | { 36 | frequency = newFrequency; 37 | calcCoeffs(); 38 | } 39 | 40 | void BiquadFilter::setGain(double newGain) 41 | { 42 | gain = newGain; 43 | calcCoeffs(); 44 | } 45 | 46 | void BiquadFilter::setBandwidth(double newBandwidth) 47 | { 48 | bandwidth = newBandwidth; 49 | calcCoeffs(); 50 | } 51 | 52 | //------------------------------------------------------------------------------------------------- 53 | //others: 54 | 55 | void BiquadFilter::calcCoeffs() 56 | { 57 | double w = 2*PI*frequency/sampleRate; 58 | double s, c; 59 | switch(mode) 60 | { 61 | case LOWPASS6: 62 | { 63 | // formula from dspguide: 64 | double x = exp(-w); 65 | a1 = x; 66 | a2 = 0.0; 67 | b0 = 1.0-x; 68 | b1 = 0.0; 69 | b2 = 0.0; 70 | } 71 | break; 72 | case LOWPASS12: 73 | { 74 | // formula from Robert Bristow Johnson's biquad cookbook: 75 | sinCos(w, &s, &c); 76 | double q = dB2amp(gain); 77 | double alpha = s/(2.0*q); 78 | double scale = 1.0/(1.0+alpha); 79 | a1 = 2.0*c * scale; 80 | a2 = (alpha-1.0) * scale; 81 | b1 = (1.0-c) * scale; 82 | b0 = 0.5*b1; 83 | b2 = b0; 84 | } 85 | break; 86 | case HIGHPASS6: 87 | { 88 | // formula from dspguide: 89 | double x = exp(-w); 90 | a1 = x; 91 | a2 = 0.0; 92 | b0 = 0.5*(1.0+x); 93 | b1 = -b0; 94 | b2 = 0.0; 95 | } 96 | break; 97 | case HIGHPASS12: 98 | { 99 | // formula from Robert Bristow Johnson's biquad cookbook: 100 | sinCos(w, &s, &c); 101 | double q = dB2amp(gain); 102 | double alpha = s/(2.0*q); 103 | double scale = 1.0/(1.0+alpha); 104 | a1 = 2.0*c * scale; 105 | a2 = (alpha-1.0) * scale; 106 | b1 = -(1.0+c) * scale; 107 | b0 = -0.5*b1; 108 | b2 = b0; 109 | } 110 | break; 111 | case BANDPASS: 112 | { 113 | // formula from Robert Bristow Johnson's biquad cookbook: 114 | sinCos(w, &s, &c); 115 | double alpha = s * sinh( 0.5*log(2.0) * bandwidth * w / s ); 116 | double scale = 1.0/(1.0+alpha); 117 | a1 = 2.0*c * scale; 118 | a2 = (alpha-1.0) * scale; 119 | b1 = 0.0; 120 | b0 = 0.5*s * scale; 121 | b2 = -b0; 122 | } 123 | break; 124 | case BANDREJECT: 125 | { 126 | // formula from Robert Bristow Johnson's biquad cookbook: 127 | sinCos(w, &s, &c); 128 | double alpha = s * sinh( 0.5*log(2.0) * bandwidth * w / s ); 129 | double scale = 1.0/(1.0+alpha); 130 | a1 = 2.0*c * scale; 131 | a2 = (alpha-1.0) * scale; 132 | b0 = 1.0 * scale; 133 | b1 = -2.0*c * scale; 134 | b2 = 1.0 * scale; 135 | } 136 | break; 137 | case PEAK: 138 | { 139 | // formula from Robert Bristow Johnson's biquad cookbook: 140 | sinCos(w, &s, &c); 141 | double alpha = s * sinh( 0.5*log(2.0) * bandwidth * w / s ); 142 | double A = dB2amp(gain); 143 | double scale = 1.0/(1.0+alpha/A); 144 | a1 = 2.0*c * scale; 145 | a2 = ((alpha/A) - 1.0) * scale; 146 | b0 = (1.0+alpha*A) * scale; 147 | b1 = -2.0*c * scale; 148 | b2 = (1.0-alpha*A) * scale; 149 | } 150 | break; 151 | case LOW_SHELF: 152 | { 153 | // formula from Robert Bristow Johnson's biquad cookbook: 154 | sinCos(w, &s, &c); 155 | double A = dB2amp(0.5*gain); 156 | double q = 1.0 / (2.0*sinh( 0.5*log(2.0) * bandwidth )); 157 | double beta = sqrt(A) / q; 158 | double scale = 1.0 / ( (A+1.0) + (A-1.0)*c + beta*s); 159 | a1 = 2.0 * ( (A-1.0) + (A+1.0)*c ) * scale; 160 | a2 = - ( (A+1.0) + (A-1.0)*c - beta*s ) * scale; 161 | b0 = A * ( (A+1.0) - (A-1.0)*c + beta*s ) * scale; 162 | b1 = 2.0 * A * ( (A-1.0) - (A+1.0)*c ) * scale; 163 | b2 = A * ( (A+1.0) - (A-1.0)*c - beta*s ) * scale; 164 | } 165 | break; 166 | 167 | 168 | 169 | 170 | // \todo: implement shelving and allpass modes 171 | 172 | default: // bypass 173 | { 174 | b0 = 1.0; 175 | b1 = 0.0; 176 | b2 = 0.0; 177 | a1 = 0.0; 178 | a2 = 0.0; 179 | }break; 180 | } 181 | } 182 | 183 | void BiquadFilter::reset() 184 | { 185 | x1 = 0.0; 186 | x2 = 0.0; 187 | y1 = 0.0; 188 | y2 = 0.0; 189 | } 190 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_RealFunctions.h: -------------------------------------------------------------------------------- 1 | #ifndef rosic_RealFunctions_h 2 | #define rosic_RealFunctions_h 3 | 4 | // standard library includes: 5 | #include 6 | #include 7 | 8 | // rosic includes: 9 | #include "GlobalFunctions.h" 10 | #include "rosic_NumberManipulations.h" 11 | 12 | namespace rosic 13 | { 14 | 15 | /** Inverse hyperbolic sine. */ 16 | INLINE double asinh(double x); 17 | 18 | /** Returns -1.0 if x is below low, 0.0 if x is between low and high and 1.0 if x is above high. */ 19 | INLINE double belowOrAbove(double x, double low, double high); 20 | 21 | /** Clips x into the range min...max. */ 22 | template 23 | INLINE T clip(T x, T min, T max); 24 | 25 | /** Evaluates the quartic polynomial y = a4*x^4 + a3*x^3 + a2*x^2 + a1*x + a0 at x. */ 26 | INLINE double evaluateQuartic(double x, double a0, double a1, double a2, double a3, double a4); 27 | 28 | /** foldover at the specified value */ 29 | INLINE double foldOver(double x, double min, double max); 30 | 31 | /** Computes an integer power of x by successively multiplying x with itself. */ 32 | INLINE double integerPower(double x, int exponent); 33 | 34 | /** Generates a pseudo-random number between min and max. */ 35 | INLINE double random(double min=0.0, double max=1.0); 36 | 37 | /** Generates a 2*pi periodic saw wave. */ 38 | INLINE double sawWave(double x); 39 | 40 | /** Calculates sine and cosine of x - this is more efficient than calling sin(x) and 41 | cos(x) seperately. */ 42 | INLINE void sinCos(double x, double* sinResult, double* cosResult); 43 | 44 | /** Calculates a parabolic approximation of the sine and cosine of x. */ 45 | INLINE void sinCosApprox(double x, double* sinResult, double* cosResult); 46 | 47 | /** Generates a 2*pi periodic square wave. */ 48 | INLINE double sqrWave(double x); 49 | 50 | /** Rational approximation of the hyperbolic tangent. */ 51 | INLINE double tanhApprox(double x); 52 | 53 | /** Generates a 2*pi periodic triangle wave. */ 54 | INLINE double triWave(double x); 55 | 56 | //=============================================================================================== 57 | // implementation: 58 | 59 | INLINE double asinh(double x) 60 | { 61 | return log(x + sqrt(x*x+1) ); 62 | } 63 | 64 | INLINE double belowOrAbove(double x, double low, double high) 65 | { 66 | if( x < low ) 67 | return -1.0; 68 | else if ( x > high ) 69 | return 1.0; 70 | else 71 | return 0.0; 72 | } 73 | 74 | template 75 | INLINE T clip(T x, T min, T max) 76 | { 77 | if( x > max ) 78 | return max; 79 | else if ( x < min ) 80 | return min; 81 | else return x; 82 | } 83 | 84 | INLINE double evaluateQuartic(double x, double a0, double a1, double a2, double a3, double a4) 85 | { 86 | double x2 = x*x; 87 | return x*(a3*x2+a1) + x2*(a4*x2+a2) + a0; 88 | } 89 | 90 | INLINE double foldOver(double x, double min, double max) 91 | { 92 | if( x > max ) 93 | return max - (x-max); 94 | else if( x < min ) 95 | return min - (x-min); 96 | else return x; 97 | } 98 | 99 | INLINE double integerPower(double x, int exponent) 100 | { 101 | double accu = 1.0; 102 | for(int i=0; i 2.0*PI ) 144 | x -= 2*PI; 145 | while( x < 0.0 ) 146 | x += 2*PI; 147 | 148 | if( x < PI/2 ) 149 | { 150 | double tmp1 = x; 151 | double tmp2 = (2/PI) * tmp1 - 0.5; 152 | double tmp3 = (2-4*c)*tmp2*tmp2 + c; 153 | *sinResult = tmp3 + tmp2; 154 | *cosResult = tmp3 - tmp2; 155 | } 156 | else if( x < PI ) 157 | { 158 | double tmp1 = (x-PI/2); 159 | double tmp2 = 0.5 - (2/PI) * tmp1; 160 | double tmp3 = (2-4*c)*tmp2*tmp2 + c; 161 | *sinResult = tmp2 + tmp3; 162 | *cosResult = tmp2 - tmp3; 163 | } 164 | else if( x < 1.5*PI ) 165 | { 166 | double tmp1 = (x-PI); 167 | double tmp2 = (2/PI) * tmp1 - 0.5; 168 | double tmp3 = (4*c-2)*tmp2*tmp2 - c; 169 | *sinResult = tmp3 - tmp2; 170 | *cosResult = tmp3 + tmp2; 171 | } 172 | else 173 | { 174 | double tmp1 = (x-1.5*PI); 175 | double tmp2 = (2/PI) * tmp1 - 0.5; 176 | double tmp3 = (2-4*c)*tmp2*tmp2 + c; 177 | *sinResult = tmp2 - tmp3; 178 | *cosResult = tmp2 + tmp3; 179 | } 180 | } 181 | 182 | INLINE double sqrWave(double x) 183 | { 184 | double tmp = fmod(x, 2*PI); 185 | if( tmp < PI ) 186 | return 1.0; 187 | else 188 | return -1.0; 189 | } 190 | 191 | INLINE double tanhApprox(double x) 192 | { 193 | double a = fabs(2*x); 194 | double b = 24+a*(12+a*(6+a)); 195 | return 2*(x*b)/(a*b+48); 196 | } 197 | 198 | INLINE double triWave(double x) 199 | { 200 | double tmp = fmod(x, 2*PI); 201 | if( tmp < 0.5*PI ) 202 | return tmp/(0.5*PI); 203 | else if( tmp < 1.5*PI ) 204 | return 1.0 - ((tmp-0.5*PI)/(0.5*PI)); 205 | else 206 | return -1.0 + ((tmp-1.5*PI)/(0.5*PI)); 207 | } 208 | 209 | } // end namespace rosic 210 | 211 | #endif // #ifndef rosic_RealFunctions_h 212 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_BlendOscillator.h: -------------------------------------------------------------------------------- 1 | #ifndef rosic_BlendOscillator_h 2 | #define rosic_BlendOscillator_h 3 | 4 | // rosic-indcludes: 5 | #include "rosic_MipMappedWaveTable.h" 6 | 7 | namespace rosic 8 | { 9 | 10 | /** 11 | 12 | This is an oscillator that can continuously blend between two waveforms - this is more efficient 13 | than using two separate oscillators because the phase-accumulator has to be calculated only once 14 | for both waveforms. 15 | 16 | */ 17 | 18 | class BlendOscillator 19 | { 20 | 21 | public: 22 | 23 | //--------------------------------------------------------------------------------------------- 24 | // construction/destruction: 25 | 26 | /** Constructor. */ 27 | BlendOscillator(); 28 | 29 | /** Destructor. */ 30 | ~BlendOscillator(); 31 | 32 | //--------------------------------------------------------------------------------------------- 33 | // parameter settings: 34 | 35 | /** Sets the sample-rateRate(). */ 36 | void setSampleRate(double newSampleRate); 37 | 38 | /** Sets the 1st waveform of the oscillator. */ 39 | void setWaveForm1(int newWaveForm1); 40 | 41 | /** Sets the 2nd waveform of the oscillator. */ 42 | void setWaveForm2(int newWaveForm2); 43 | 44 | /** Set start phase (range 0 - 360 degrees). */ 45 | void setStartPhase(double StartPhase); 46 | 47 | /** An object of class WaveTable should be passed with this function which will be used in the 48 | oscillator. Not to have "our own" WaveTable-object as member-variable avoids the need to have 49 | the same waveform for different synth-voices multiple times in the memory. This function sets 50 | the 1st wavetable. */ 51 | void setWaveTable1(MipMappedWaveTable* newWaveTable1); 52 | 53 | /** Sets the 2nd wavetable. @see setWaveTable1 */ 54 | void setWaveTable2(MipMappedWaveTable* newWaveTable2); 55 | 56 | /** Sets the blend/mix factor between the two waveforms. The value is expected between 0...1 57 | where 0 means waveform1 only, 1 means waveform2 only - in between there will be a linear blend 58 | between the two waveforms. */ 59 | void setBlendFactor(double newBlendFactor) { blend = newBlendFactor; } 60 | 61 | /** Sets the frequency of the oscillator. */ 62 | INLINE void setFrequency(double newFrequency); 63 | 64 | /** Sets the pulse width (or symmetry) of the oscillator. */ 65 | INLINE void setPulseWidth(double newPulseWidth); 66 | 67 | /** Sets the phase increment from outside. */ 68 | INLINE void setIncrement(double newIncrement) { increment = newIncrement; } 69 | 70 | //--------------------------------------------------------------------------------------------- 71 | // inquiry: 72 | 73 | /** Returns the blend/mix factor between the two waveforms as a value between 0...1 where 0 74 | means waveform1 only, 1 means waveform2 only - in between there will be a linear blend between 75 | the two waveforms. */ 76 | double getBlendFactor() const { return blend; } 77 | 78 | /** Returns the phase increment. */ 79 | INLINE double getIncrement() const { return increment; } 80 | 81 | //--------------------------------------------------------------------------------------------- 82 | // audio processing: 83 | 84 | /** Calculates one output sample at a time. */ 85 | INLINE double getSample(); 86 | 87 | //--------------------------------------------------------------------------------------------- 88 | // others: 89 | 90 | /** Calculates the phase-increments for first and second half-period according to freq and 91 | pulseWidth. */ 92 | INLINE void calculateIncrement(); 93 | 94 | /** Resets the phaseIndex to startIndex. */ 95 | void resetPhase(); 96 | 97 | /** Reset the phaseIndex to startIndex+PhaseIndex. */ 98 | void setPhase(double PhaseIndex); 99 | 100 | //============================================================================================= 101 | 102 | protected: 103 | 104 | double tableLengthDbl; // tableLength as double variable 105 | double phaseIndex; // current phase index 106 | double freq; // frequency of the oscillator 107 | double increment; // phase increment per sample 108 | double blend; // the blend factor between the two waveforms 109 | double startIndex; // start-phase-index of the osc (range: 0 - tableLength) 110 | double sampleRate; // the samplerate 111 | double sampleRateRec; // 1/sampleRate 112 | 113 | MipMappedWaveTable *waveTable1, *waveTable2; // the 2 wavetables between which we blend 114 | 115 | }; 116 | 117 | //----------------------------------------------------------------------------------------------- 118 | // inlined functions: 119 | 120 | INLINE void BlendOscillator::setFrequency(double newFrequency) 121 | { 122 | if( (newFrequency > 0.0) && (newFrequency < 20000.0) ) 123 | freq = newFrequency; 124 | } 125 | 126 | INLINE void BlendOscillator::setPulseWidth(double newPulseWidth) 127 | { 128 | waveTable1->setSymmetry(0.01*newPulseWidth); 129 | waveTable2->setSymmetry(0.01*newPulseWidth); 130 | } 131 | 132 | INLINE void BlendOscillator::calculateIncrement() 133 | { 134 | increment = tableLengthDbl*freq*sampleRateRec; 135 | } 136 | 137 | INLINE double BlendOscillator::getSample() 138 | { 139 | double out1, out2; 140 | int tableNumber; 141 | 142 | if( waveTable1 == NULL || waveTable2 == NULL ) 143 | return 0.0; 144 | 145 | // from this increment, decide which table is to be used: 146 | tableNumber = ((int)EXPOFDBL(increment)); 147 | //tableNumber += 1; // generate frequencies up to nyquist/2 on the highest note 148 | tableNumber += 2; // generate frequencies up to nyquist/4 on the highest note 149 | // \todo: make this number adjustable from outside 150 | 151 | // wraparound if necessary: 152 | while( phaseIndex>=tableLengthDbl ) 153 | phaseIndex -= tableLengthDbl; 154 | 155 | int intIndex = floorInt(phaseIndex); 156 | double frac = phaseIndex - (double) intIndex; 157 | out1 = (1.0-blend) * waveTable1->getValueLinear(intIndex, frac, tableNumber); 158 | out2 = blend * waveTable2->getValueLinear(intIndex, frac, tableNumber); 159 | 160 | out2 *= 0.5; // \todo: this is preliminary to scale the square in AciDevil we need to 161 | // implement something more general here (like a kind of crest-compensation in 162 | // the wavetable-class) 163 | 164 | phaseIndex += increment; 165 | return out1 + out2; 166 | } 167 | 168 | } // end namespace rosic 169 | 170 | #endif // rosic_BlendOscillator_h 171 | -------------------------------------------------------------------------------- /Build/VisualStudio2019/Open303.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {94076005-8c00-4632-bb1a-22d14a3731fd} 6 | 7 | 8 | {002baddd-f737-4e72-b858-1a612d0ded53} 9 | 10 | 11 | {7111e7ee-270f-4fda-8fb1-e275c637f3d1} 12 | 13 | 14 | 15 | 16 | VST PlugIn 17 | 18 | 19 | DSP Code 20 | 21 | 22 | DSP Code 23 | 24 | 25 | DSP Code 26 | 27 | 28 | DSP Code 29 | 30 | 31 | DSP Code 32 | 33 | 34 | DSP Code 35 | 36 | 37 | DSP Code 38 | 39 | 40 | DSP Code 41 | 42 | 43 | DSP Code 44 | 45 | 46 | DSP Code 47 | 48 | 49 | DSP Code 50 | 51 | 52 | DSP Code 53 | 54 | 55 | DSP Code 56 | 57 | 58 | DSP Code 59 | 60 | 61 | DSP Code 62 | 63 | 64 | DSP Code 65 | 66 | 67 | DSP Code 68 | 69 | 70 | DSP Code 71 | 72 | 73 | DSP Code 74 | 75 | 76 | VST-SDK 77 | 78 | 79 | VST-SDK 80 | 81 | 82 | VST-SDK 83 | 84 | 85 | 86 | 87 | VST PlugIn 88 | 89 | 90 | DSP Code 91 | 92 | 93 | DSP Code 94 | 95 | 96 | DSP Code 97 | 98 | 99 | DSP Code 100 | 101 | 102 | DSP Code 103 | 104 | 105 | DSP Code 106 | 107 | 108 | DSP Code 109 | 110 | 111 | DSP Code 112 | 113 | 114 | DSP Code 115 | 116 | 117 | DSP Code 118 | 119 | 120 | DSP Code 121 | 122 | 123 | DSP Code 124 | 125 | 126 | DSP Code 127 | 128 | 129 | DSP Code 130 | 131 | 132 | DSP Code 133 | 134 | 135 | DSP Code 136 | 137 | 138 | DSP Code 139 | 140 | 141 | DSP Code 142 | 143 | 144 | DSP Code 145 | 146 | 147 | DSP Code 148 | 149 | 150 | VST-SDK 151 | 152 | 153 | VST-SDK 154 | 155 | 156 | VST-SDK 157 | 158 | 159 | VST-SDK 160 | 161 | 162 | VST-SDK 163 | 164 | 165 | VST-SDK 166 | 167 | 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /Build/VisualStudio2008/Open303.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 160 | 161 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_FourierTransformerRadix2.h: -------------------------------------------------------------------------------- 1 | #ifndef rosic_FourierTransformerRadix2_h 2 | #define rosic_FourierTransformerRadix2_h 3 | 4 | // standard includes: 5 | #include 6 | 7 | // rosic-indcludes: 8 | #include "rosic_Complex.h" 9 | #include "rosic_RealFunctions.h" 10 | 11 | namespace rosic 12 | { 13 | 14 | /** 15 | 16 | This class performs a fast Fourier Transform on a block of complex numbers (which are of class 17 | "Complex"). The length of the block has to be a power of 2. It uses the FFT library by Takuya Ooura 18 | which seems to be rather efficient. It handles the conversion between doubles and Complex numbers 19 | by means of some hacky pointer trickery which relies on the fact that an object of class Complex 20 | can be interpreted as two doubles stored in subsequent memory locations. This is true for the 21 | compiler in MSVC 2005 but may or may not be true for other compilers. In case of problems, try the 22 | class FourierTransfromerRadix2Clean which goes without such nasty hacks but is vastly inferior 23 | efficiency-wise. 24 | 25 | */ 26 | 27 | class FourierTransformerRadix2 28 | { 29 | 30 | public: 31 | 32 | /** The direction of the transform. */ 33 | enum directions 34 | { 35 | FORWARD, 36 | INVERSE 37 | }; 38 | 39 | /** These are the possible normalization modes. */ 40 | enum normalizationModes 41 | { 42 | NORMALIZE_ON_FORWARD_TRAFO, // divide by blockSize on forward FFT 43 | NORMALIZE_ON_INVERSE_TRAFO, // divide by blockSize on inverse FFT (default) 44 | ORTHONORMAL_TRAFO // divide by sqrt(blockSize) on both transforms 45 | }; 46 | 47 | //--------------------------------------------------------------------------------------------- 48 | // construction/destruction: 49 | 50 | /** Constructor. */ 51 | FourierTransformerRadix2(); 52 | 53 | /** Destructor. */ 54 | ~FourierTransformerRadix2(); 55 | 56 | //--------------------------------------------------------------------------------------------- 57 | // parameter settings: 58 | 59 | /** FFT-size, has to be a power of 2 and >= 2. */ 60 | void setBlockSize(int newBlockSize); 61 | 62 | /** Sets the direction of the transform (@see: directions). This will affect the sign of the 63 | exponent (or equivalently: theimaginary part) in the twiddling factors and the normalization 64 | constant. */ 65 | void setDirection(int newDirection); 66 | 67 | /** When you switch bewteen usage of this object for real or complex signals, you will need to 68 | call this switch-function in between which just triggers a re-computation of the twiddle 69 | factors (which must be different for the two cases). */ 70 | void setRealSignalMode(bool willBeUsedForRealSignals); 71 | 72 | /** Sets the mode for normalization of the output (@see: normalizationModes). */ 73 | void setNormalizationMode(int newNormalizationMode); 74 | 75 | //--------------------------------------------------------------------------------------------- 76 | // complex Fourier transforms: 77 | 78 | /** Transforms a buffer of complex numbers into its (forward or inverse) fourier transform. 79 | The inBuffer will remain intact. Both, inBuffer and outBuffer must be of the size which was 80 | specified when setting up the blockSize with setBlockSize(). */ 81 | void transformComplexBuffer(Complex *inBuffer, Complex *outBuffer); 82 | 83 | /** Does the same thing as transformComplexBuffer but performes in-place calculation 84 | (overwrites the input buffer). */ 85 | void transformComplexBufferInPlace(Complex *buffer); 86 | 87 | //--------------------------------------------------------------------------------------------- 88 | // some convenience functions for dealing with real signals: 89 | 90 | /** Transforms a real signal into its corresponding (conjugate symmetric) complex spectrum 91 | using an algorithm which exploits the symmetries for more efficiency. When the input array is 92 | an array of doubles of length N, the output array will be an array of complex numbers (class 93 | Complex) of length N/2 with the (purely real) transform value of bin N/2 stored in the 94 | imaginary part of the first array entry (outSpectrum[0].im = real(N/2)). */ 95 | void transformRealSignal(double *inSignal, Complex *outSpectrum); 96 | 97 | /** Calculates real and imaginary part of the spectrum as interleaved double buffer: 98 | buf[2]=re[1], buf[3]=im[1], buf[4]=re[2], buf[5]=im[2],... in general: buf[2*k]=re[k], 99 | buf[2k+1]=im[k], k=1,..,(N/2)-1 where N is the FFT-size. The first two elements of the buffer 100 | have a special meaning: buf[0] is the (purely real) DC and buf[1] is the (purely real) 101 | coefficient for the Nyquist frequency. The other fields contain the real and imaginary parts of 102 | the positive frequencies only (interleaved) because the negative frequencies are redundant 103 | (they are conjugate symmetric). */ 104 | void transformRealSignal(double *signal, double *reAndIm); 105 | 106 | /** Calculates spectral magnitudes and phases from a signal, where *signal should be of 107 | length N, where N is the block-size as chosen with setBlockSize() *magnitudes and *phases 108 | should be of length N/2. */ 109 | void getRealSignalMagnitudesAndPhases(double *signal, double *magnitudes, double *phases); 110 | 111 | /** Calculates the magnitudes only from a signal (useful for analyzer-stuff). */ 112 | void getRealSignalMagnitudes(double *signal, double *magnitudes); 113 | 114 | /** Transforms a complex conjugate symmetric spectrum (i.e. a spectrum of a real signal) into 115 | the corresponding real signal. */ 116 | void transformSymmetricSpectrum(Complex *inSpectrum, double *outSignal); 117 | 118 | /** Calculates a time signal from and interleaved buffer containing the real and imaginary 119 | parts of the positive frequencies (the negative frequencies are assumed to be conjugate 120 | symmetric). */ 121 | void transformSymmetricSpectrum(double *reAndIm, double *signal); 122 | 123 | /** Calculates a real time signal from its magnitudes and phases, *magnitudes and *phases 124 | should be of length N/2, *signal is of length N where N is the block-size as chosen with 125 | setBlockSize(). */ 126 | void getRealSignalFromMagnitudesAndPhases(double *magnitudes, double *phases, double *signal); 127 | 128 | //--------------------------------------------------------------------------------------------- 129 | // static functions 130 | 131 | /** Returns the physical frequency in Hz that corresponds to the given 'binIndex' for a given 132 | 'fftSize' and 'sampleRate'. */ 133 | static double binIndexToFrequency(int binIndex, int fftSize, double sampleRate) 134 | { return binIndex*sampleRate/fftSize; } 135 | 136 | 137 | //============================================================================================= 138 | 139 | protected: 140 | 141 | /** Updates the normalizationFactor member variable acording to a new blockSize, direction or 142 | normalizationMode. */ 143 | void updateNormalizationFactor(); 144 | 145 | int N; /**< the blocksize of the FFT. */ 146 | int logN; /**< Base 2 logarithm of the blocksize. */ 147 | int direction; /**< The direction of the transform (@see: directions). */ 148 | int normalizationMode; /**< The normalization mode (@see: normalizationModes. */ 149 | double normalizationFactor; /**< The normalization factor (can be 1, 1/N or 1/sqrt(N)). */ 150 | 151 | // work-area stuff for Ooura's fft-routines: 152 | double *w; /**< Table of the twiddle-factors. */ 153 | int *ip; /**< Work area for bit-reversal (index pointer?). */ 154 | 155 | // our own temporary storage area: 156 | Complex* tmpBuffer; 157 | 158 | }; 159 | 160 | } // end namespace rosic 161 | 162 | #endif // rosic_FourierTransformerRadix2_h 163 | -------------------------------------------------------------------------------- /Build/CodeBlocks/Open303.depend: -------------------------------------------------------------------------------- 1 | # depslib dependency file v1.0 2 | 1256315264 source:d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_realfunctions.cpp 3 | "rosic_RealFunctions.h" 4 | 5 | 1271960317 d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_realfunctions.h 6 | 7 | 8 | "GlobalFunctions.h" 9 | "rosic_NumberManipulations.h" 10 | 11 | 1256315264 d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\globalfunctions.h 12 | 13 | 14 | "GlobalDefinitions.h" 15 | 16 | 1271960851 d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\globaldefinitions.h 17 | 18 | 19 | 1271960486 d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_numbermanipulations.h 20 | "GlobalDefinitions.h" 21 | 22 | 23 | 1256315264 source:d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_numbermanipulations.cpp 24 | "rosic_NumberManipulations.h" 25 | 26 | 1256315264 source:d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_functiontemplates.cpp 27 | "rosic_FunctionTemplates.h" 28 | 29 | 1271960405 d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_functiontemplates.h 30 | "rosic_RealFunctions.h" 31 | 32 | 33 | 1271960984 source:d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_open303.cpp 34 | "rosic_Open303.h" 35 | 36 | 1258100254 d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_open303.h 37 | "rosic_MidiNoteEvent.h" 38 | "rosic_BlendOscillator.h" 39 | "rosic_BiquadFilter.h" 40 | "rosic_TeeBeeFilter.h" 41 | "rosic_AnalogEnvelope.h" 42 | "rosic_DecayEnvelope.h" 43 | "rosic_LeakyIntegrator.h" 44 | "rosic_EllipticQuarterBandFilter.h" 45 | "rosic_AcidSequencer.h" 46 | 47 | 48 | 1271961063 d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_midinoteevent.h 49 | 50 | 1258100208 d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_blendoscillator.h 51 | "rosic_MipMappedWaveTable.h" 52 | 53 | 1258100135 d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_mipmappedwavetable.h 54 | "rosic_FunctionTemplates.h" 55 | "rosic_FourierTransformerRadix2.h" 56 | 57 | 1256315264 d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_fouriertransformerradix2.h 58 | 59 | "rosic_Complex.h" 60 | "rosic_RealFunctions.h" 61 | 62 | 1260805766 d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_complex.h 63 | "rosic_RealFunctions.h" 64 | 65 | 1256376058 d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_biquadfilter.h 66 | "rosic_RealFunctions.h" 67 | 68 | 1256324674 d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_teebeefilter.h 69 | 70 | "rosic_OnePoleFilter.h" 71 | 72 | 1256315265 d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_onepolefilter.h 73 | "rosic_RealFunctions.h" 74 | 75 | 1256315265 d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_analogenvelope.h 76 | "rosic_RealFunctions.h" 77 | 78 | 1256315265 d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_decayenvelope.h 79 | "rosic_RealFunctions.h" 80 | 81 | 1256315264 d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_leakyintegrator.h 82 | "rosic_RealFunctions.h" 83 | 84 | 1256315264 d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_ellipticquarterbandfilter.h 85 | 86 | "GlobalDefinitions.h" 87 | 88 | 1256315264 d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_acidsequencer.h 89 | "rosic_AcidPattern.h" 90 | 91 | 1266352322 d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_acidpattern.h 92 | "rosic_RealFunctions.h" 93 | "rosic_FunctionTemplates.h" 94 | 95 | 1256315264 source:d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\globalfunctions.cpp 96 | "GlobalFunctions.h" 97 | 98 | 1256315265 source:d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\fft4g.c 99 | 100 | 101 | 1271960509 source:d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_acidpattern.cpp 102 | "rosic_AcidPattern.h" 103 | 104 | 1271960529 source:d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_acidsequencer.cpp 105 | "rosic_AcidSequencer.h" 106 | 107 | 1271960540 source:d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_analogenvelope.cpp 108 | "rosic_AnalogEnvelope.h" 109 | 110 | 1256376048 source:d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_biquadfilter.cpp 111 | "rosic_BiquadFilter.h" 112 | 113 | 1271960562 source:d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_blendoscillator.cpp 114 | "rosic_BlendOscillator.h" 115 | 116 | 1271960606 source:d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_complex.cpp 117 | "rosic_Complex.h" 118 | 119 | 1256315264 source:d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_decayenvelope.cpp 120 | "rosic_DecayEnvelope.h" 121 | 122 | 1256315265 source:d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_ellipticquarterbandfilter.cpp 123 | "rosic_EllipticQuarterBandFilter.h" 124 | 125 | 1256315265 source:d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_fouriertransformerradix2.cpp 126 | "rosic_FourierTransformerRadix2.h" 127 | "fft4g.c" 128 | 129 | 1256315265 d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\fft4g.c 130 | 131 | 132 | 1256315265 source:d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_leakyintegrator.cpp 133 | "rosic_LeakyIntegrator.h" 134 | 135 | 1271960900 source:d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_midinoteevent.cpp 136 | "rosic_MidiNoteEvent.h" 137 | 138 | 1271960940 source:d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_mipmappedwavetable.cpp 139 | "rosic_MipMappedWaveTable.h" 140 | 141 | 1256315264 source:d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_onepolefilter.cpp 142 | "rosic_OnePoleFilter.h" 143 | 144 | 1271961125 source:d:\programming\collaborationprojects\open303\open303_r5\source\dspcode\rosic_teebeefilter.cpp 145 | "rosic_TeeBeeFilter.h" 146 | 147 | 1256315265 source:d:\programming\collaborationprojects\open303\open303_r5\source\vstplugin\stringconversions.c 148 | 149 | 150 | "string.h" 151 | 152 | 1271962061 source:d:\programming\collaborationprojects\open303\open303_r5\source\vstplugin\open303vst.cpp 153 | "Open303VST.h" 154 | 155 | 1271961796 d:\programming\collaborationprojects\open303\open303_r5\source\vstplugin\open303vst.h 156 | "public.sdk/source/vst2.x/audioeffectx.h" 157 | "../DSPCode/rosic_Open303.h" 158 | 159 | 1137047732 d:\programming\collaborationprojects\open303\open303_r5\libraries\vstsdk2.4\public.sdk\source\vst2.x\audioeffectx.h 160 | "audioeffect.h" 161 | "pluginterfaces/vst2.x/aeffectx.h" 162 | 163 | 1137047732 d:\programming\collaborationprojects\open303\open303_r5\libraries\vstsdk2.4\public.sdk\source\vst2.x\audioeffect.h 164 | "pluginterfaces/vst2.x/aeffect.h" 165 | 166 | 1137047696 d:\programming\collaborationprojects\open303\open303_r5\libraries\vstsdk2.4\pluginterfaces\vst2.x\aeffect.h 167 | 168 | 169 | 1137047696 d:\programming\collaborationprojects\open303\open303_r5\libraries\vstsdk2.4\pluginterfaces\vst2.x\aeffectx.h 170 | "aeffect.h" 171 | 172 | 1133154206 source:d:\programming\collaborationprojects\open303\open303_r5\libraries\vstsdk2.4\public.sdk\source\vst2.x\audioeffect.cpp 173 | "audioeffect.h" 174 | "aeffeditor.h" 175 | 176 | 177 | 178 | 179 | 1137047732 d:\programming\collaborationprojects\open303\open303_r5\libraries\vstsdk2.4\public.sdk\source\vst2.x\aeffeditor.h 180 | "audioeffectx.h" 181 | 182 | 1137047732 source:d:\programming\collaborationprojects\open303\open303_r5\libraries\vstsdk2.4\public.sdk\source\vst2.x\audioeffectx.cpp 183 | "audioeffectx.h" 184 | "aeffeditor.h" 185 | 186 | 1137047732 source:d:\programming\collaborationprojects\open303\open303_r5\libraries\vstsdk2.4\public.sdk\source\vst2.x\vstplugmain.cpp 187 | "audioeffect.h" 188 | 189 | 190 | -------------------------------------------------------------------------------- /Source/DSPCode/rosic_Complex.h: -------------------------------------------------------------------------------- 1 | #ifndef rosic_Complex_h 2 | #define rosic_Complex_h 3 | 4 | // rosic-indcludes: 5 | #include "rosic_RealFunctions.h" 6 | 7 | namespace rosic 8 | { 9 | 10 | /** 11 | 12 | This is a class for complex numbers. It defines the basic arithmetic operations between complex 13 | numbers as well as the special cases when one of the operands is real (double). 14 | 15 | ATTENTION: do not define any further member variables, nor switch the ordering of re and im 16 | because the FourierTransformer classes rely on the fact that a complex number consists of two 17 | doubles re, im and nothing else (the algorithms actually run on buffers of doubles). 18 | 19 | */ 20 | 21 | class Complex 22 | { 23 | 24 | public: 25 | 26 | //--------------------------------------------------------------------------------------------- 27 | // public member variables: 28 | 29 | /** Real part */ 30 | double re; 31 | 32 | /** Imaginary part */ 33 | double im; 34 | 35 | //--------------------------------------------------------------------------------------------- 36 | // construction/destruction: 37 | 38 | /** Constructor. Initializes real and imaginary part to zero. */ 39 | Complex(); 40 | 41 | /** Constructor. Initializes real part to the argument "reInit" and imaginary part to zero. */ 42 | Complex(double reInit); 43 | 44 | /** Constructor. Initializes real and imaginary parts with the parameters. */ 45 | Complex(double reInit, double imInit); 46 | 47 | /** Destructor. */ 48 | ~Complex(); 49 | 50 | //--------------------------------------------------------------------------------------------- 51 | // overloaded operators: 52 | 53 | /** Compares two complex numbers of equality. */ 54 | bool operator==(const Complex& z) const 55 | { 56 | if( re == z.re && im == z.im ) 57 | return true; 58 | else 59 | return false; 60 | } 61 | 62 | /** Compares two complex numbers of inequality. */ 63 | bool operator!=(const Complex& z) const 64 | { 65 | if( re != z.re || im != z.im ) 66 | return true; 67 | else 68 | return false; 69 | } 70 | 71 | /** Defines the negative of a complex number. */ 72 | Complex operator-() 73 | { return Complex(-re, -im); } 74 | 75 | /** Adds another complex number to this complex and returns the result. */ 76 | Complex& operator+=(const Complex &z) 77 | { 78 | this->re += z.re; 79 | this->im += z.im; 80 | return *this; 81 | } 82 | 83 | /** Adds a real number to this complex and returns the result. */ 84 | Complex& operator+=(const double &r) 85 | { 86 | this->re += r; 87 | return *this; 88 | } 89 | 90 | /** Subtracts another complex number from this complex and returns the result. */ 91 | Complex& operator-=(const Complex &z) 92 | { 93 | this->re -= z.re; 94 | this->im -= z.im; 95 | return *this; 96 | } 97 | 98 | /** Subtracts a real number from this complex and returns the result. */ 99 | Complex& operator-=(const double &r) 100 | { 101 | this->re -= r; 102 | return *this; 103 | } 104 | 105 | /** Multiplies this complex number by another complex number and returns the result. */ 106 | Complex& operator*=(const Complex &z) 107 | { 108 | double reNew = re*z.re - im*z.im; 109 | double imNew = re*z.im + im*z.re; 110 | this->re = reNew; 111 | this->im = imNew; 112 | return *this; 113 | } 114 | 115 | /** Multiplies this complex number by a real number and returns the result. */ 116 | Complex& operator*=(const double &r) 117 | { 118 | this->re *= r; 119 | this->im *= r; 120 | return *this; 121 | } 122 | 123 | /** Divides this complex number by another complex number and returns the result. */ 124 | Complex& operator/=(const Complex &z) 125 | { 126 | double scale = 1.0 / (z.re*z.re + z.im*z.im); 127 | double reNew = scale*( re*z.re + im*z.im ); 128 | double imNew = scale*( im*z.re - re*z.im ); 129 | this->re = reNew; 130 | this->im = imNew; 131 | return *this; 132 | } 133 | 134 | /** Divides this complex number by a real number and returns the result. */ 135 | Complex& operator/=(const double &r) 136 | { 137 | double scale = 1.0 / r; 138 | this->re *= scale; 139 | this->im *= scale; 140 | return *this; 141 | } 142 | 143 | //--------------------------------------------------------------------------------------------- 144 | // set-functions: 145 | 146 | /** Adjusts the radius of this complex number leaving the angle unchanged. */ 147 | void setRadius(double newRadius); 148 | 149 | /** Adjusts the angle of this complex number leaving the magnitude unchanged. */ 150 | void setAngle(double newAngle); 151 | 152 | /** Sets the radius and angle of this complex number. */ 153 | void setRadiusAndAngle(double newRadius, double newAngle); 154 | 155 | //--------------------------------------------------------------------------------------------- 156 | // get-functions: 157 | 158 | /** Returns the radius of this complex number. */ 159 | double getRadius(); 160 | 161 | /** Returns the angle of this complex number. */ 162 | double getAngle(); 163 | 164 | /** Returns the complex conjugate of this complex number. */ 165 | Complex getConjugate(); 166 | 167 | /** Returns the reciprocal of this complex number. */ 168 | Complex getReciprocal(); 169 | 170 | /** Returns true, if this complex number is purely real. */ 171 | bool isReal(); 172 | 173 | /** Returns true, if this complex number is purely imaginary. */ 174 | bool isImaginary(); 175 | 176 | /** Returns true if real or imaginary part (or both) are plus or minus infinity, false 177 | otherwise. */ 178 | bool isInfinite(); 179 | 180 | }; // end of class Complex 181 | 182 | // some binary operators are defined outside the class such that the left hand operand does 183 | // not necesarrily need to be of class Complex 184 | 185 | /** Adds two complex numbers. */ 186 | INLINE Complex operator+(const Complex &z, const Complex &w) 187 | { return Complex(z.re+w.re, z.im+w.im); } 188 | 189 | /** Adds a complex and a real number. */ 190 | INLINE Complex operator+(const Complex &z, const double &r) 191 | { return Complex(z.re+r, z.im); } 192 | 193 | /** Adds a real and a complex number. */ 194 | INLINE Complex operator+(const double &r, const Complex &z) 195 | { return Complex(z.re+r, z.im); } 196 | 197 | /** Subtracts two complex numbers. */ 198 | INLINE Complex operator-(const Complex &z, const Complex &w) 199 | { return Complex(z.re-w.re, z.im-w.im); } 200 | 201 | /** Subtracts a real number from a complex number. */ 202 | INLINE Complex operator-(const Complex &z, const double &r) 203 | { return Complex(z.re-r, z.im); } 204 | 205 | /** Subtracts a complex number from a real number. */ 206 | INLINE Complex operator-(const double &r, const Complex &z) 207 | { return Complex(r-z.re, -z.im); } 208 | 209 | /** Multiplies two complex numbers. */ 210 | INLINE Complex operator*(const Complex &z, const Complex &w) 211 | { return Complex(z.re*w.re-z.im*w.im, z.re*w.im+z.im*w.re); } 212 | 213 | /** Multiplies a complex number and a real number. */ 214 | INLINE Complex operator*(const Complex &z, const double &r) 215 | { return Complex(z.re*r, z.im*r); } 216 | 217 | /** Multiplies a real number and a complex number. */ 218 | INLINE Complex operator*(const double &r, const Complex &z) 219 | { return Complex(z.re*r, z.im*r); } 220 | 221 | /** Divides two complex numbers. */ 222 | INLINE Complex operator/(const Complex &z, const Complex &w) 223 | { 224 | double scale = 1.0 / (w.re*w.re + w.im*w.im); 225 | return Complex( scale*( z.re*w.re + z.im*w.im), // real part 226 | scale*( z.im*w.re - z.re*w.im) ); // imaginary part 227 | } 228 | 229 | /** Divides a complex number by a real number. */ 230 | INLINE Complex operator/(const Complex &z, const double &r) 231 | { 232 | double scale = 1.0 / r; 233 | return Complex(scale*z.re, scale*z.im); 234 | } 235 | 236 | /** Divides a real number by a complex number. */ 237 | INLINE Complex operator/(const double &r, const Complex &z) 238 | { 239 | double scale = r / (z.re*z.re + z.im*z.im); 240 | return Complex(scale*z.re, -scale*z.im); 241 | } 242 | 243 | } // end namespace rosic 244 | 245 | #endif // rosic_Complex_h 246 | --------------------------------------------------------------------------------