The OSP is a hackable, open source drum machine that accidentally got very, very close to the erica perkons hd-01, which is real beauty of instrument design that i truly love, except for its unhackable closed source nature. So, we new need gnu one.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

119 lines
3.2 KiB

#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