From 51bb0adae1621fb22136863cbcaac59d542b43f7 Mon Sep 17 00:00:00 2001 From: heck Date: Tue, 5 Nov 2024 17:53:03 +0100 Subject: [PATCH] Start using 'libDizzy' as a new dependency --- Makefile.conf | 8 +-- src/instr_bd2.cc | 2 +- src/instr_fm.cc | 2 +- src/instr_grainlet.cc | 2 +- src/instr_hihat.cc | 2 +- src/instr_kick.cc | 2 +- src/instr_zosc.cc | 2 +- src/main_osp.cc | 8 +-- src/main_osp.hh | 2 +- src/osp_types.hh | 6 ++ src/osp_utils.cc | 2 + src/{utils.hh => osp_utils.hh} | 28 +------- src/track.hh | 2 +- src/types.hh | 34 ---------- src/utils.cc | 119 --------------------------------- 15 files changed, 26 insertions(+), 195 deletions(-) create mode 100644 src/osp_types.hh create mode 100644 src/osp_utils.cc rename src/{utils.hh => osp_utils.hh} (78%) delete mode 100644 src/types.hh delete mode 100644 src/utils.cc diff --git a/Makefile.conf b/Makefile.conf index 5439a0b..8375a12 100644 --- a/Makefile.conf +++ b/Makefile.conf @@ -6,10 +6,10 @@ DEBUG ?= 0 LIBDAISY_DIR ?= ../../heck_libDaisy DAISYSP_DIR ?= ../../heck_DaisySP -#LIBDIZZY_DIR ?= ../src/ -#CXXFLAGS += -I$(LIBDIZZY_DIR) -#LDFLAGS += -L$(LIBDIZZY_DIR) -#LDFLAGS += -ldizzy +LIBDIZZY_DIR ?= ../../heck_libdizzy/src/ +CXXFLAGS += -I$(LIBDIZZY_DIR) +LDFLAGS += -L$(LIBDIZZY_DIR) +LDFLAGS += -ldizzy CXX_STANDARD ?= -std=c++17 CXXFLAGS += -Wall -Wno-unused -Wno-reorder-ctor -Wno-switch diff --git a/src/instr_bd2.cc b/src/instr_bd2.cc index b91bf63..256a502 100644 --- a/src/instr_bd2.cc +++ b/src/instr_bd2.cc @@ -1,6 +1,6 @@ #include "instr_bd2.hh" #include "daisysp.h" -#include "utils.hh" +#include "osp_utils.hh" namespace Heck::OSP { namespace Instrument { diff --git a/src/instr_fm.cc b/src/instr_fm.cc index 45f1618..03144c7 100644 --- a/src/instr_fm.cc +++ b/src/instr_fm.cc @@ -1,6 +1,6 @@ #include "instr_fm.hh" #include "daisysp.h" -#include "utils.hh" +#include "osp_utils.hh" namespace Heck::OSP { namespace Instrument { diff --git a/src/instr_grainlet.cc b/src/instr_grainlet.cc index 1389af6..1d5451b 100644 --- a/src/instr_grainlet.cc +++ b/src/instr_grainlet.cc @@ -1,6 +1,6 @@ #include "instr_Grainlet.hh" #include "daisysp.h" -#include "utils.hh" +#include "osp_utils.hh" namespace Heck::OSP { namespace Instrument { diff --git a/src/instr_hihat.cc b/src/instr_hihat.cc index c26a8e3..274a8fe 100644 --- a/src/instr_hihat.cc +++ b/src/instr_hihat.cc @@ -1,6 +1,6 @@ #include "instr_hihat.hh" #include "daisysp.h" -#include "utils.hh" +#include "osp_utils.hh" namespace Heck::OSP { namespace Instrument { diff --git a/src/instr_kick.cc b/src/instr_kick.cc index a914098..4ad9b09 100644 --- a/src/instr_kick.cc +++ b/src/instr_kick.cc @@ -1,6 +1,6 @@ #include "instr_kick.hh" #include "daisysp.h" -#include "utils.hh" +#include "osp_utils.hh" namespace Heck::OSP { namespace Instrument { diff --git a/src/instr_zosc.cc b/src/instr_zosc.cc index 5e222ec..4466237 100644 --- a/src/instr_zosc.cc +++ b/src/instr_zosc.cc @@ -1,6 +1,6 @@ #include "instr_zosc.hh" #include "daisysp.h" -#include "utils.hh" +#include "osp_utils.hh" namespace Heck::OSP { namespace Instrument { diff --git a/src/main_osp.cc b/src/main_osp.cc index 3b8a947..c821d23 100644 --- a/src/main_osp.cc +++ b/src/main_osp.cc @@ -3,7 +3,7 @@ #include "main_osp.hh" #include "track.hh" -#include "utils.hh" +#include "osp_utils.hh" #include "midiclock.hh" #include "sequencer.hh" #include "instr_interface.hh" @@ -375,11 +375,11 @@ namespace Heck { heartbeat.is_it_already_time_again(time_boot_ms); } } -} // namespace Heck +} // namespace Heck::OSP int main() { - Heck::init(); - Heck::mainloop(); + Heck::OSP::init(); + Heck::OSP::mainloop(); } \ No newline at end of file diff --git a/src/main_osp.hh b/src/main_osp.hh index 3213b60..d59a179 100644 --- a/src/main_osp.hh +++ b/src/main_osp.hh @@ -4,7 +4,7 @@ #include #include "daisy_seed.h" #include "daisysp.h" -#include "types.hh" +#include "osp_types.hh" namespace Heck::OSP { namespace Constants { diff --git a/src/osp_types.hh b/src/osp_types.hh new file mode 100644 index 0000000..fda0c4c --- /dev/null +++ b/src/osp_types.hh @@ -0,0 +1,6 @@ +#ifndef HECK_OSP_TYPES_HH +#define HECK_OSP_TYPES_HH + +#include "types.hh" + +#endif \ No newline at end of file diff --git a/src/osp_utils.cc b/src/osp_utils.cc new file mode 100644 index 0000000..33471eb --- /dev/null +++ b/src/osp_utils.cc @@ -0,0 +1,2 @@ +#include "osp_utils.hh" + diff --git a/src/utils.hh b/src/osp_utils.hh similarity index 78% rename from src/utils.hh rename to src/osp_utils.hh index d48fee2..fe8469d 100644 --- a/src/utils.hh +++ b/src/osp_utils.hh @@ -2,32 +2,8 @@ #define HECK_OSP_UTILS_HH #include "daisy_seed.h" -#include "types.hh" - -namespace Heck::OSP { - void GetMidiTypeAsString(const ld::MidiEvent& msg, char* str); - void GetMidiRTTypeAsString(const ld::MidiEvent& msg, char* str); - - float scalen_min_max(float val, float min, float max); - float scalen_center_range(float val, float center, float range); -} // namespace Heck::OSP - - -namespace Heck::OSP { - class SWTimer { - public: - using Callback = std::function; - - void set_period(u32 time_units); - void set_callback(const Callback& cb); - bool is_it_already_time_again(u32 time_now); - - private: - Callback callback_{}; - u32 time_last_exec_{}; - u32 time_period_{}; - }; -} // namespace Heck::OSP +#include "osp_types.hh" +#include "utils.hh" namespace Heck::OSP { template class Observer { diff --git a/src/track.hh b/src/track.hh index b644c00..319fabe 100644 --- a/src/track.hh +++ b/src/track.hh @@ -3,7 +3,7 @@ #include "daisysp.h" #include "instr_interface.hh" -#include "utils.hh" +#include "osp_utils.hh" #include "main_osp.hh" namespace Heck::OSP { diff --git a/src/types.hh b/src/types.hh deleted file mode 100644 index 44eb2f4..0000000 --- a/src/types.hh +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef HECK_OSP_TYPES_HH -#define HECK_OSP_TYPES_HH - -#include -#include "daisy_seed.h" -#include "daisysp.h" - -namespace Heck::OSP { - - // fundamental types - using u8 = uint8_t; - using u16 = uint16_t; - using u32 = uint32_t; - using u64 = uint64_t; - - using i8 = int8_t; - using i16 = int16_t; - using i32 = int32_t; - using i64 = int64_t; - - using f32 = float; - using f64 = double; - - // namespace aliases - namespace ld = daisy; - namespace dsp = daisysp; - - // type aliases from libs - using Samplerate = ld::SaiHandle::Config::SampleRate; - -} // namespace Heck - - -#endif \ No newline at end of file diff --git a/src/utils.cc b/src/utils.cc deleted file mode 100644 index 20be2e7..0000000 --- a/src/utils.cc +++ /dev/null @@ -1,119 +0,0 @@ -#include "utils.hh" - -namespace Heck::OSP { - - void GetMidiTypeAsString(const ld::MidiEvent& msg, char* str) - { - switch (msg.type) { - case ld::NoteOff: - strcpy(str, "NoteOff"); - break; - case ld::NoteOn: - strcpy(str, "NoteOn"); - break; - case ld::PolyphonicKeyPressure: - strcpy(str, "PolyKeyPres."); - break; - case ld::ControlChange: - strcpy(str, "CC"); - break; - case ld::ProgramChange: - strcpy(str, "Prog. Change"); - break; - case ld::ChannelPressure: - strcpy(str, "Chn. Pressure"); - break; - case ld::PitchBend: - strcpy(str, "PitchBend"); - break; - case ld::SystemCommon: - strcpy(str, "Sys. Common"); - break; - case ld::SystemRealTime: - strcpy(str, "Sys. Realtime"); - break; - case ld::ChannelMode: - strcpy(str, "Chn. Mode"); - break; - default: - strcpy(str, "Unknown"); - break; - } - } - - void GetMidiRTTypeAsString(const ld::MidiEvent& msg, char* str) - { - switch (msg.srt_type) { - case ld::TimingClock: - strcpy(str, "TimingClock"); - break; - case ld::SRTUndefined0: - strcpy(str, "SRTUndefined0"); - break; - case ld::Start: - strcpy(str, "Start"); - break; - case ld::Continue: - strcpy(str, "Continue"); - break; - case ld::Stop: - strcpy(str, "Stop"); - break; - case ld::SRTUndefined1: - strcpy(str, "SRTUndefined1"); - break; - case ld::ActiveSensing: - strcpy(str, "ActiveSensing"); - break; - case ld::Reset: - strcpy(str, "Reset"); - break; - case ld::SystemRealTimeLast: - strcpy(str, "SystemRealTimeLast"); - break; - default: - strcpy(str, "Unknown"); - break; - } - } - - - float scalen_min_max(float val, float min, float max) - { - float range = max - min; - float ret = min + (val * range); - return ret; - } - - float scalen_center_range(float val, float center, float range) - { - float min = center - (range / 2); - float ret = min + (val * range); - return ret; - } -} // namespace Heck - -namespace Heck::OSP { - void SWTimer::set_period(u32 time_units) - { - time_period_ = time_units; - } - - void SWTimer::set_callback(const Callback& cb) - { - callback_ = cb; - } - - bool SWTimer::is_it_already_time_again(u32 time_now) - { - if (time_now - time_last_exec_ >= time_period_) { - time_last_exec_ = time_now; - if (callback_) { - //todo: constexpr if metrics - callback_(time_now); - } - return true; - } - return false; - } -} // namespace Heck