15 changed files with 26 additions and 195 deletions
@ -0,0 +1,6 @@ |
|||||
|
#ifndef HECK_OSP_TYPES_HH |
||||
|
#define HECK_OSP_TYPES_HH |
||||
|
|
||||
|
#include "types.hh" |
||||
|
|
||||
|
#endif |
@ -0,0 +1,2 @@ |
|||||
|
#include "osp_utils.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 |
|
@ -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…
Reference in new issue