Browse Source

Merge branch 'dev_cleartrackcc'

main
heck 7 months ago
parent
commit
38b7afa75a
  1. 18
      src/instr_zosc.cc
  2. 114
      src/main_perkons.cc
  3. 15
      src/track.hh

18
src/instr_zosc.cc

@ -13,14 +13,12 @@ namespace Heck {
void ZOsc::init()
{
zosc.Init(samplerate);
zosc.SetFreq(80.f);
zosc.SetShape(1.f);
zosc.SetFreq(40.f);
zosc.SetShape(1.);
zosc.SetFormantFreq(200);
}
void ZOsc::trigger()
{
}
void ZOsc::trigger() {}
void ZOsc::ctl(unsigned int ctl_nr, float val)
{
@ -29,13 +27,13 @@ namespace Heck {
zosc.SetFreq(scalen_min_max(val, 40, 180));
} break;
case 1: {
// zosc.SetDecay(scalen_min_max(val,0,1));
// zosc.SetDecay(scalen_min_max(val,0,1));
} break;
case 2: {
zosc.SetFormantFreq(scalen_min_max(val,200,800));
zosc.SetFormantFreq(scalen_min_max(val, 200, 800));
} break;
case 3: {
zosc.SetShape(scalen_min_max(val,0,1));
zosc.SetShape(1. - scalen_min_max(val, 0, 1));
} break;
}
}
@ -43,7 +41,7 @@ namespace Heck {
void ZOsc::switch_mode1(unsigned int pos)
{
mode1 = pos;
zosc.SetMode(((float)pos)/3.);
zosc.SetMode(((float)pos) / 3.);
hw.PrintLine("");
}

114
src/main_perkons.cc

@ -19,6 +19,11 @@ namespace ld = daisy;
namespace dsp = daisysp;
namespace Heck {
namespace State {
bool record_mode{ false };
bool clear_mode{ false };
} // namespace State
// =============================================================================================
// INIT
// =============================================================================================
@ -150,7 +155,7 @@ namespace Heck {
}
}
void tracks_midi_in(ld::MidiEvent msg)
void midi_in_from_uart_polling(ld::MidiEvent msg)
{
switch (msg.type) {
case ld::MidiMessageType::NoteOn: {
@ -159,44 +164,50 @@ namespace Heck {
}
} break;
case ld::MidiMessageType::ControlChange: {
sequencer.midi_in(msg);
ld::ControlChangeEvent cc = msg.AsControlChange();
float val_normalized = cc.value / 127.;
switch (cc.control_number) {
// Pots
case Constants::MIDI_Mapping::TRACK_PITCH:
tracks[cc.channel].instrument->ctl(0, val_normalized);
break;
case Constants::MIDI_Mapping::TRACK_DECAY:
tracks[cc.channel].decay(val_normalized);
break;
case Constants::MIDI_Mapping::TRACK_PARAM1:
tracks[cc.channel].instrument->ctl(2, val_normalized);
break;
case Constants::MIDI_Mapping::TRACK_PARAM2:
tracks[cc.channel].instrument->ctl(3, val_normalized);
break;
case Constants::MIDI_Mapping::TRACK_FILTER:
tracks[cc.channel].filter(val_normalized);
break;
case Constants::MIDI_Mapping::TRACK_DRIVE:
tracks[cc.channel].drive(val_normalized);
break;
case Constants::MIDI_Mapping::TRACK_VOLUME:
tracks[cc.channel].volume(val_normalized);
break;
// Switches
case Constants::MIDI_Mapping::TRACK_MODE1:
tracks[cc.channel].instrument->switch_mode1(int(val_normalized * 2.));
break;
case Constants::MIDI_Mapping::TRACK_MODE2:
tracks[cc.channel].instrument->switch_mode2(int(val_normalized * 2.));
break;
case Constants::MIDI_Mapping::TRACK_FILTERMODE:
tracks[cc.channel].filtermode(val_normalized);
break;
default:
break;
if (State::clear_mode) {
ld::ControlChangeEvent cc = msg.AsControlChange();
hw.PrintLine("Clear: ch: %i, cc: %i",cc.channel,cc.control_number);
sequencer.clear_track_cc(cc.channel, cc.control_number);
} else {
sequencer.midi_in(msg);
float val_normalized = cc.value / 127.;
switch (cc.control_number) {
// Pots
case Constants::MIDI_Mapping::TRACK_PITCH:
tracks[cc.channel].instrument->ctl(0, val_normalized);
break;
case Constants::MIDI_Mapping::TRACK_DECAY:
tracks[cc.channel].decay(val_normalized);
break;
case Constants::MIDI_Mapping::TRACK_PARAM1:
tracks[cc.channel].instrument->ctl(2, val_normalized);
break;
case Constants::MIDI_Mapping::TRACK_PARAM2:
tracks[cc.channel].instrument->ctl(3, val_normalized);
break;
case Constants::MIDI_Mapping::TRACK_FILTER:
tracks[cc.channel].filter(val_normalized);
break;
case Constants::MIDI_Mapping::TRACK_DRIVE:
tracks[cc.channel].drive(val_normalized);
break;
case Constants::MIDI_Mapping::TRACK_VOLUME:
tracks[cc.channel].volume(val_normalized);
break;
// Switches
case Constants::MIDI_Mapping::TRACK_MODE1:
tracks[cc.channel].instrument->switch_mode1(int(val_normalized * 2.));
break;
case Constants::MIDI_Mapping::TRACK_MODE2:
tracks[cc.channel].instrument->switch_mode2(int(val_normalized * 2.));
break;
case Constants::MIDI_Mapping::TRACK_FILTERMODE:
tracks[cc.channel].filtermode(val_normalized);
break;
default:
break;
}
}
} break;
default: {
@ -205,20 +216,20 @@ namespace Heck {
}
}
void midi_async_handler()
void midi_in_from_uart_interrupt()
{
while (midi.HasEvents()) {
ld::MidiEvent msg = midi.PopEvent();
event_log.PushBack(msg);
tracks_midi_in(msg);
midi_in_from_uart_polling(msg);
}
}
void sequencer_midi_handler()
void midi_in_from_sequencer()
{
std::vector<ld::MidiEvent> queue = sequencer.midi_out();
for (ld::MidiEvent msg : queue) {
tracks_midi_in(msg);
midi_in_from_uart_polling(msg);
}
}
@ -276,18 +287,26 @@ namespace Heck {
sequencer.next_step();
}
sequencer_midi_handler();
midi_async_handler();
midi_in_from_sequencer();
midi_in_from_uart_interrupt();
// REC
but_rec.Debounce();
but_record_new = but_rec.Pressed();
if (but_record_current != but_record_new) {
// State changed
but_record_current = but_record_new;
if (but_record_current) {
hw.PrintLine("BUTTON RECORD ON");
if (State::clear_mode) {
hw.PrintLine("CLEAR SEQUENCE");
sequencer.clear_sequence();
} else {
hw.PrintLine("BUTTON RECORD ON");
State::record_mode = true;
}
} else {
hw.PrintLine("BUTTON RECORD OFF");
State::record_mode = false;
}
sequencer.recording = but_record_current;
}
@ -296,15 +315,18 @@ namespace Heck {
but_clear.Debounce();
but_clear_new = but_clear.Pressed();
if (but_clear_current != but_clear_new) {
// State changed
but_clear_current = but_clear_new;
if (but_clear_current) {
hw.PrintLine("BUTTON CLEAR ON");
State::clear_mode = true;
} else {
hw.PrintLine("BUTTON CLEAR OFF");
sequencer.clear_sequence();
State::clear_mode = false;
}
}
if (systick_now - midi_log_systick_last > 5) {
midi_log_systick_last = systick_now;
if (!event_log.IsEmpty()) {

15
src/track.hh

@ -3,7 +3,8 @@
#include "daisysp.h"
#include "instr_abstract.hh"
#include "utils.hh"
#include "globals.hh"
namespace dsp = daisysp;
namespace Heck {
@ -20,7 +21,7 @@ namespace Heck {
decay_.SetTime(dsp::ADENV_SEG_DECAY, 0.1);
decay_.SetMax(1);
decay_.SetMin(0);
decay_.SetCurve(-18);
decay_.SetCurve(-50);
// Vol
ctl_volume_ = 0.;
@ -28,11 +29,12 @@ namespace Heck {
// Filter
ladder_.Init(Constants::SAMPLERATE);
ladder_.SetFilterMode(daisysp::LadderFilter::FilterMode::LP24);
ladder_.SetRes(0.7);
ladder_.SetRes(0.4);
ladder_.SetInputDrive(1.3);
// Drive
od_.Init();
od_.SetDrive(0.425);
}
float nextsample()
@ -54,7 +56,7 @@ namespace Heck {
void decay(float val)
{
decay_.SetTime(dsp::ADENV_SEG_DECAY, 0.01 + val * 8.);
decay_.SetTime(dsp::ADENV_SEG_DECAY, 0.01 + val * 12.);
}
void volume(float vol)
@ -70,7 +72,7 @@ namespace Heck {
void drive(float amt)
{
od_.SetDrive(0.35 + amt * 0.15);
od_.SetDrive(scalen_min_max(amt, 0.35, 0.5));
}
// range: 0-1
@ -80,14 +82,17 @@ namespace Heck {
// MID
if (ctl_filtermode_ < 0.33) {
hw.PrintLine("Track: Filter BP");
ladder_.SetFilterMode(daisysp::LadderFilter::FilterMode::BP24);
}
// HIGH
if (ctl_filtermode_ >= 0.33 && ctl_filtermode_ < 0.66) {
hw.PrintLine("Track: Filter HP");
ladder_.SetFilterMode(daisysp::LadderFilter::FilterMode::HP24);
}
// LOW
if (ctl_filtermode_ >= 0.66) {
hw.PrintLine("Track: Filter LP");
ladder_.SetFilterMode(daisysp::LadderFilter::FilterMode::LP24);
}
}

Loading…
Cancel
Save