Browse Source

utils - add nomalized scaling functions / move into namespace Heck

main
heck 7 months ago
parent
commit
8c37b46d82
  1. 18
      src/utils.cc
  2. 4
      src/utils.hh

18
src/utils.cc

@ -2,6 +2,8 @@
using namespace daisy;
namespace Heck {
void GetMidiTypeAsString(MidiEvent& msg, char* str)
{
switch (msg.type) {
@ -76,3 +78,19 @@ void GetMidiRTTypeAsString(MidiEvent& msg, char* str)
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

4
src/utils.hh

@ -4,8 +4,12 @@
#include "daisy_seed.h"
#include "globals.hh"
namespace Heck {
void GetMidiTypeAsString(daisy::MidiEvent& msg, char* str);
void GetMidiRTTypeAsString(daisy::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
#endif // HECK_DAISY_UTILS_HH
Loading…
Cancel
Save