Browse Source

Start using 'libDizzy' as a new dependency

master
heck 8 months ago
parent
commit
51bb0adae1
  1. 8
      Makefile.conf
  2. 2
      src/instr_bd2.cc
  3. 2
      src/instr_fm.cc
  4. 2
      src/instr_grainlet.cc
  5. 2
      src/instr_hihat.cc
  6. 2
      src/instr_kick.cc
  7. 2
      src/instr_zosc.cc
  8. 8
      src/main_osp.cc
  9. 2
      src/main_osp.hh
  10. 6
      src/osp_types.hh
  11. 2
      src/osp_utils.cc
  12. 28
      src/osp_utils.hh
  13. 2
      src/track.hh
  14. 34
      src/types.hh
  15. 119
      src/utils.cc

8
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

2
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 {

2
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 {

2
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 {

2
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 {

2
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 {

2
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 {

8
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();
}

2
src/main_osp.hh

@ -4,7 +4,7 @@
#include <cstdint>
#include "daisy_seed.h"
#include "daisysp.h"
#include "types.hh"
#include "osp_types.hh"
namespace Heck::OSP {
namespace Constants {

6
src/osp_types.hh

@ -0,0 +1,6 @@
#ifndef HECK_OSP_TYPES_HH
#define HECK_OSP_TYPES_HH
#include "types.hh"
#endif

2
src/osp_utils.cc

@ -0,0 +1,2 @@
#include "osp_utils.hh"

28
src/utils.hh → 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(u32 time)>;
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<typename T> class Observer {

2
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 {

34
src/types.hh

@ -1,34 +0,0 @@
#ifndef HECK_OSP_TYPES_HH
#define HECK_OSP_TYPES_HH
#include <cstdint>
#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

119
src/utils.cc

@ -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
Loading…
Cancel
Save