Skip to content

Commit

Permalink
Add 'chords'/mono mode to Edges MIDI implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
brianleu committed Oct 19, 2018
1 parent 98fa698 commit b7f740f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions edges/midi_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ class MidiHandler : public midi::MidiDevice {
pitch_[channel] = stack_[channel].most_recent_note().note << 7;
}
break;

case MIDI_MODE_CHORDS:
stack_[0].NoteOn(note, velocity);
for (uint8_t i = 0; i < kNumChannels; ++i) {
pitch_[i] = stack_[0].most_recent_note().note << 7;
}
gate_ = 0xf;
break;
}
gate_ |= (1 << channel);
}
Expand Down Expand Up @@ -122,6 +130,16 @@ class MidiHandler : public midi::MidiDevice {
(stack_[channel].size() != 0) ? gate_ |= (1 << channel) : gate_ &= ~(1 << channel);
}
break;

case MIDI_MODE_CHORDS:
stack_[0].NoteOff(note);
for (uint8_t i = 0; i < kNumChannels; ++i) {
if (stack_[0].size()) {
pitch_[channel] = stack_[0].most_recent_note().note << 7;
}
}
(stack_[0].size() != 0) ? gate_ = 0xf : gate_ = 0;
break;
}
}

Expand All @@ -136,6 +154,7 @@ class MidiHandler : public midi::MidiDevice {
break;

case MIDI_MODE_POLYPHONIC:
case MIDI_MODE_CHORDS:
for (uint8_t i = 0; i < kNumChannels; ++i) {
pitch_bend_[i] = v;
}
Expand Down Expand Up @@ -170,6 +189,7 @@ class MidiHandler : public midi::MidiDevice {
return ((channel - base_channel()) & 0xf) < kNumChannels;

case MIDI_MODE_POLYPHONIC:
case MIDI_MODE_CHORDS:
return channel == base_channel();

case MIDI_MODE_3_1:
Expand Down
1 change: 1 addition & 0 deletions edges/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum MidiMode {
MIDI_MODE_MULTITIMBRAL,
MIDI_MODE_POLYPHONIC,
MIDI_MODE_3_1,
MIDI_MODE_CHORDS,
NUM_MIDI_MODES
};

Expand Down

0 comments on commit b7f740f

Please sign in to comment.