From c3c6f619c3f5527f6dcb43c39c2773b5b9006530 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 29 Dec 2014 13:58:15 +0100 Subject: make it easier to add new midi sequences --- libs/backends/dummy/dummy_audiobackend.cc | 15 +-------------- libs/backends/dummy/dummy_midi_seq.h | 16 ++++++++++------ 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/libs/backends/dummy/dummy_audiobackend.cc b/libs/backends/dummy/dummy_audiobackend.cc index 91d27fb8cd..a96db7a37c 100644 --- a/libs/backends/dummy/dummy_audiobackend.cc +++ b/libs/backends/dummy/dummy_audiobackend.cc @@ -1754,20 +1754,7 @@ struct MidiEventSorter { void DummyMidiPort::setup_generator (int seq_id, const float sr) { DummyPort::setup_random_number_generator(); - switch (seq_id) { - case 1: - _midi_seq_dat = DummyMidiData::s1; - break; - case 2: - _midi_seq_dat = DummyMidiData::s2; - break; - case 3: - _midi_seq_dat = DummyMidiData::s3; - break; - default: - _midi_seq_dat = DummyMidiData::s0; - break; - } + _midi_seq_dat = DummyMidiData::sequences[seq_id % NUM_MIDI_EVENT_GENERATORS]; _midi_seq_spb = sr * .5f; // 120 BPM, beat_time 1.0 per beat. _midi_seq_pos = 0; _midi_seq_time = 0; diff --git a/libs/backends/dummy/dummy_midi_seq.h b/libs/backends/dummy/dummy_midi_seq.h index 1ca27b87fa..e086a5aed6 100644 --- a/libs/backends/dummy/dummy_midi_seq.h +++ b/libs/backends/dummy/dummy_midi_seq.h @@ -23,9 +23,7 @@ namespace ARDOUR { namespace DummyMidiData { -#define NUM_MIDI_EVENT_GENERATORS 4 - -const MIDISequence s0[] = { // some arbitrary short sequence +static const MIDISequence s0[] = { // some arbitrary short sequence { 0.00, {0x90, 64, 0x7f} }, { 0.50, {0x80, 64, 0x00} }, { 1.00, {0x90, 66, 0x7f} }, @@ -37,7 +35,7 @@ const MIDISequence s0[] = { // some arbitrary short sequence { 4.00, {0xff, 255, 0xff} }, // sentinel }; -const MIDISequence s1[] = { // Cmaj7 - iterate all channels +static const MIDISequence s1[] = { // Cmaj7 - iterate all channels { 0.00, {0x90, 60, 0x7f} }, { 0.25, {0x90, 64, 0x7f} }, { 0.50, {0x90, 67, 0x7f} }, @@ -201,7 +199,7 @@ const MIDISequence s1[] = { // Cmaj7 - iterate all channels {32.00, {0xff, 255, 0xff} }, // sentinel }; -const MIDISequence s2[] = { // channel 1, sweep all notes +static const MIDISequence s2[] = { // channel 1, sweep all notes { 0.00, {0x90, 0, 0x7f} }, { 0.25, {0x80, 0, 0x00} }, { 0.25, {0x90, 1, 0x7f} }, @@ -461,7 +459,7 @@ const MIDISequence s2[] = { // channel 1, sweep all notes {32.00, {0xff, 255, 0xff} }, // sentinel }; -const MIDISequence s3[] = { // velocity sweep +static const MIDISequence s3[] = { // velocity sweep { 0.000, {0x90, 60, 0x00} }, { 0.125, {0x80, 60, 0x00} }, { 0.125, {0x90, 61, 0x01} }, @@ -721,6 +719,12 @@ const MIDISequence s3[] = { // velocity sweep {16.000, {0xff, 255, 0xff} }, // sentinel }; +static const MIDISequence *sequences[] = { + s0, s1, s2, s3 +}; + }} // namespace +#define NUM_MIDI_EVENT_GENERATORS (sizeof (ARDOUR::DummyMidiData::sequences) / sizeof(ARDOUR::DummyMidiData::MIDISequence*)) + #endif -- cgit v1.2.3