Skip to content

Commit

Permalink
additions to v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dunland committed Dec 4, 2020
1 parent 0ff2ceb commit 64bd2d5
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 106 deletions.
1 change: 1 addition & 0 deletions Code/teensy/include/Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ enum CC_Type // channels on mKORG:
Patch_1_Depth = 28,
Patch_3_Depth = 30,
Cutoff = 44,
LFO_Rate = 46,
Resonance = 71,
Amplevel = 50,
Attack = 23,
Expand Down
3 changes: 2 additions & 1 deletion Code/teensy/include/Instruments.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ class Instrument

////////////////////// SETUP FUNCTIONS ////////////////////////////

void setup_notes(std::vector<int> list);
// set MIDI notes according to a vector list:
void set_notes(std::vector<int> list);

void setup_midi(CC_Type cc_type, Synthesizer *synth, int cc_max, int cc_min, float cc_increase_factor, float cc_tidyUp_factor);

Expand Down
3 changes: 3 additions & 0 deletions Code/teensy/include/Score.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ class Score
static TOPOGRAPHY topo_midi_effect; // for TopographyMidiEffect

// SETUP etc:
static void set_notes(std::vector<int> list);

static void add_bassNote(int note); // adds a NOTE to notes[]


// MODES:
static void playRhythmicNotes(Synthesizer *synth, midi::MidiInterface<HardwareSerial> MIDI, int note_change_pos_ = 0); // initiates a continuous bass note from score

Expand Down
2 changes: 2 additions & 0 deletions Code/teensy/src/Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,8 @@ CC_Type Globals::int_to_cc_type(int integer)
return Patch_3_Depth;
case 44:
return Cutoff;
case 46:
return LFO_Rate;
case 71:
return Resonance;
case 50:
Expand Down
4 changes: 2 additions & 2 deletions Code/teensy/src/Hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ void Hardware::checkFootSwitch(std::vector<Instrument *> instruments)
if (switch_state == LOW)
{
footswitch_pressed(instruments);
Serial.println("Footswitch pressed.");
Globals::println_to_console("Footswitch pressed.");
}
else
{
footswitch_released(instruments);
Serial.println("Footswitch released.");
Globals::println_to_console("Footswitch released.");
}
last_switch_state = switch_state;
last_switch_toggle = millis();
Expand Down
2 changes: 1 addition & 1 deletion Code/teensy/src/Instruments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <Score.h>
#include <Hardware.h>

void Instrument::setup_notes(std::vector<int> list)
void Instrument::set_notes(std::vector<int> list)
{
for (uint8_t i = 0; i < list.size(); i++)
{
Expand Down
16 changes: 16 additions & 0 deletions Code/teensy/src/Score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ void Score::add_bassNote(int note)
Globals::println_to_console("]");
}

void Score::set_notes(std::vector<int> list)
{
for (uint8_t i = 0; i < list.size(); i++)
{
notes.push_back(list[i]);
}

Globals::print_to_console("Score::notes:");
for (uint8_t i = 0; i < notes.size(); i++)
{
Globals::print_to_console(" ");
Globals::print_to_console(notes[i]);
}
Globals::println_to_console("");
}

///////////////////////////////////////////////////////////////////////
////////////////////////////// MODES //////////////////////////////////
///////////////////////////////////////////////////////////////////////
Expand Down
94 changes: 47 additions & 47 deletions Code/teensy/src/Serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,61 +11,61 @@

void JSON::compose_and_send_json(std::vector<Instrument *> instruments)
{
// size_t capacity = JSON_ARRAY_SIZE(Score::notes.size()) + 9 * JSON_ARRAY_SIZE(16) + 9 * JSON_OBJECT_SIZE(8) + 2 * JSON_OBJECT_SIZE(9);
// DynamicJsonDocument doc(capacity);
size_t capacity = JSON_ARRAY_SIZE(Score::notes.size()) + 9 * JSON_ARRAY_SIZE(16) + 9 * JSON_OBJECT_SIZE(8) + 2 * JSON_OBJECT_SIZE(9);
DynamicJsonDocument doc(capacity);

// // ---------------------- Global values ---------------------------
// JsonObject score = doc.createNestedObject("score");
// score["millis"] = millis();
// score["current_beat_pos"] = Globals::current_beat_pos;
// score["score_step"] = Score::step;
// ---------------------- Global values ---------------------------
JsonObject score = doc.createNestedObject("score");
score["millis"] = millis();
score["current_beat_pos"] = Globals::current_beat_pos;
score["score_step"] = Score::step;

// // -------------------------- Score -------------------------------
// JsonArray score_notes = score.createNestedArray("notes");
// for (uint8_t i = 0; i < Score::notes.size(); i++)
// {
// score_notes.add(Score::notes[i]);
// }
// score["note"] = Score::notes[Score::note_idx];
// -------------------------- Score -------------------------------
JsonArray score_notes = score.createNestedArray("notes");
for (uint8_t i = 0; i < Score::notes.size(); i++)
{
score_notes.add(Score::notes[i]);
}
score["note"] = Score::notes[Score::note_idx];

// // Score topographies:
// JsonArray score_topo = score.createNestedArray("topo");
// for (uint8_t i = 0; i < Score::beat_sum.a_16.size(); i++)
// {
// score_topo.add(Score::beat_sum.a_16[i]);
// }
// Score topographies:
JsonArray score_topo = score.createNestedArray("topo");
for (uint8_t i = 0; i < Score::beat_sum.a_16.size(); i++)
{
score_topo.add(Score::beat_sum.a_16[i]);
}

// // Score topography values:
// score["topo_ready"] = Score::beat_sum.ready(); // TODO: replace with beat_regularity at some point
// score["average_smooth"] = Score::beat_sum.average_smooth; // TODO: replace with beat_regularity at some point
// score["activation_thresh"] = Score::beat_sum.activation_thresh; // TODO: replace with beat_regularity at some point
// Score topography values:
score["topo_ready"] = Score::beat_sum.ready(); // TODO: replace with beat_regularity at some point
score["average_smooth"] = Score::beat_sum.average_smooth; // TODO: replace with beat_regularity at some point
score["activation_thresh"] = Score::beat_sum.activation_thresh; // TODO: replace with beat_regularity at some point

// // --------------------------- Instruments ------------------------
// for (auto &instrument : instruments)
// {
// JsonObject instr = doc.createNestedObject(Globals::DrumtypeToHumanreadable(instrument->drumtype));
// --------------------------- Instruments ------------------------
for (auto &instrument : instruments)
{
JsonObject instr = doc.createNestedObject(Globals::DrumtypeToHumanreadable(instrument->drumtype));

// JsonArray topo = instr.createNestedArray("topo");
JsonArray topo = instr.createNestedArray("topo");

// // instrument topography:
// for (uint8_t i = 0; i < instrument->topography.a_16.size(); i++)
// {
// topo.add(instrument->topography.a_16[i]);
// }
// instrument topography:
for (uint8_t i = 0; i < instrument->topography.a_16.size(); i++)
{
topo.add(instrument->topography.a_16[i]);
}

// // topo information:
// instr["average_smooth"] = instrument->topography.average_smooth;
// instr["activation_thresh"] = instrument->topography.activation_thresh;
// topo information:
instr["average_smooth"] = instrument->topography.average_smooth;
instr["activation_thresh"] = instrument->topography.activation_thresh;

// // instrument values:
// instr["wasHit"] = instrument->wasHit;
// instr["cc_val"] = instrument->midi_settings.cc_val;
// instr["cc_increase"] = instrument->midi_settings.cc_increase_factor;
// instr["cc_decay"] = instrument->midi_settings.cc_tidyUp_factor;
// instr["effect"] = Globals::EffectstypeToHumanReadable(instrument->effect);
// }
// instrument values:
instr["wasHit"] = instrument->timing.wasHit;
instr["cc_val"] = instrument->midi_settings.cc_val;
instr["cc_increase"] = instrument->midi_settings.cc_increase_factor;
instr["cc_decay"] = instrument->midi_settings.cc_tidyUp_factor;
instr["effect"] = Globals::EffectstypeToHumanReadable(instrument->effect);
}

// // transmit information:
// serializeJson(doc, Serial);
// Serial.println("");
// transmit information:
serializeJson(doc, Serial);
Serial.println("");
}
Loading

0 comments on commit 64bd2d5

Please sign in to comment.