diff --git a/sequencer.cpp b/sequencer.cpp index c6eaeac..e5ffada 100644 --- a/sequencer.cpp +++ b/sequencer.cpp @@ -39,81 +39,85 @@ void sequencer_part1(void) for (uint8_t d = 0; d < NUM_SEQ_TRACKS; d++) { - if ( seq_track_type[d] == 0) { // drum track (drum samples and pitched one-shot samples) - if (seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] > 0 ) - { - if (seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step] > 209) // it is a pitched sample + if (seq_patternchain[seq_chain_active_step][d] != 99 ) // sequence not empty + { + if ( seq_track_type[d] == 0) + { // drum track (drum samples and pitched one-shot samples) + if (seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] > 0 ) { - // Drum[slot]->setPlaybackRate( pow (2, (inNote - 72) / 12.00) * drum_config[sample].pitch ); get_sample_vol_max(sample) - set_sample_pitch(seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step] - 210 , (float)pow (2, (seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] - 72) / 12.00) * get_sample_p_offset( seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step] - 210 ) ); - handleNoteOn(drum_midi_channel, seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step] , 90 ); + if (seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step] > 209) // it is a pitched sample + { + // Drum[slot]->setPlaybackRate( pow (2, (inNote - 72) / 12.00) * drum_config[sample].pitch ); get_sample_vol_max(sample) + set_sample_pitch(seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step] - 210 , (float)pow (2, (seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] - 72) / 12.00) * get_sample_p_offset( seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step] - 210 ) ); + handleNoteOn(drum_midi_channel, seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step] , 90 ); + } + else // else play normal drum sample + handleNoteOn(drum_midi_channel, seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] , seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step]); } - else // else play normal drum sample - handleNoteOn(drum_midi_channel, seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] , seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step]); } - } - else { - if (seq_data[seq_patternchain[seq_chain_active_step][d]][seq_step] > 0 ) // instrument track - { - if (seq_track_type[d] == 1 || (seq_track_type[d] == 3 && arp_play_basenote) ) + else { + if (seq_data[seq_patternchain[seq_chain_active_step][d]][seq_step] > 0 ) // instrument track { - if (seq_data[seq_patternchain[seq_chain_active_step][d]][seq_step] != 130 ) + if (seq_track_type[d] == 1 || (seq_track_type[d] == 3 && arp_play_basenote) ) { - handleNoteOn(configuration.dexed[seq_inst_dexed[d]].midi_channel, seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step], seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step]); - seq_prev_note[d] = seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step]; - seq_prev_vel[d] = seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step]; + if (seq_data[seq_patternchain[seq_chain_active_step][d]][seq_step] != 130 ) + { + handleNoteOn(configuration.dexed[seq_inst_dexed[d]].midi_channel, seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step], seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step]); + seq_prev_note[d] = seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step]; + seq_prev_vel[d] = seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step]; + } } - } - else if (seq_track_type[d] == 2 ) //Chords - { - if (seq_vel[ seq_patternchain[seq_chain_active_step][d]][seq_step] > 199) + else if (seq_track_type[d] == 2 ) //Chords { + if (seq_vel[ seq_patternchain[seq_chain_active_step][d]][seq_step] > 199) + { - //handleNoteOn(configuration.dexed[seq_inst_dexed[d]].midi_channel, seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step], seq_chord_velocity); // basenote + //handleNoteOn(configuration.dexed[seq_inst_dexed[d]].midi_channel, seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step], seq_chord_velocity); // basenote - for (uint8_t x = seq_element_shift; x < seq_element_shift + seq_chord_key_ammount; x++) //play chord notes - { - handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] + (seq_oct_shift * 12) + seq_arps[seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step] - 200][x], seq_chord_velocity); + for (uint8_t x = seq_element_shift; x < seq_element_shift + seq_chord_key_ammount; x++) //play chord notes + { + handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] + (seq_oct_shift * 12) + seq_arps[seq_vel[ seq_patternchain[seq_chain_active_step][d] ][seq_step] - 200][x], seq_chord_velocity); + } + seq_prev_note[d] = seq_data[seq_patternchain[seq_chain_active_step][d]][seq_step] + (seq_oct_shift * 12); + seq_prev_vel[d] = seq_vel[seq_patternchain[seq_chain_active_step][d]][seq_step]; } - seq_prev_note[d] = seq_data[seq_patternchain[seq_chain_active_step][d]][seq_step] + (seq_oct_shift * 12); - seq_prev_vel[d] = seq_vel[seq_patternchain[seq_chain_active_step][d]][seq_step]; + } + if (seq_track_type[d] == 3) { //Arp + arp_step = 0; + arp_counter = 0; + arp_note = seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] + (seq_oct_shift * 12); + arp_chord = seq_vel[seq_patternchain[seq_chain_active_step][d] ][seq_step] - 200; } } - if (seq_track_type[d] == 3) { //Arp - arp_step = 0; - arp_counter = 0; - arp_note = seq_data[ seq_patternchain[seq_chain_active_step][d] ][seq_step] + (seq_oct_shift * 12); - arp_chord = seq_vel[seq_patternchain[seq_chain_active_step][d] ][seq_step] - 200; - } - } - // after here not triggered by a key input - arp only - if (seq_track_type[d] == 3) - { //Arp - if (arp_speed == 0 || (arp_speed == 1 && arp_counter == 0) ) { + // after here not triggered by a key input - arp only + if (seq_track_type[d] == 3) + { //Arp + if (arp_speed == 0 || (arp_speed == 1 && arp_counter == 0) ) { - { if (arp_style == 0) { //arp up - handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][arp_step + seq_element_shift], seq_chord_velocity); - arp_note_prev = arp_note + seq_arps[arp_chord][arp_step + seq_element_shift] ; - } - else if (arp_style == 1) { //arp down - handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][arp_lenght - arp_step + seq_element_shift], seq_chord_velocity); - arp_note_prev = arp_note + seq_arps[arp_chord][arp_lenght - arp_step + seq_element_shift] ; - } - else if (arp_style == 2) { //arp up & down - if (arp_step <= arp_lenght) { - handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][arp_step ], seq_chord_velocity); - arp_note_prev = arp_note + seq_arps[arp_chord][arp_step ] ; + { if (arp_style == 0) { //arp up + handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][arp_step + seq_element_shift], seq_chord_velocity); + arp_note_prev = arp_note + seq_arps[arp_chord][arp_step + seq_element_shift] ; } - else { - handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][arp_lenght * 2 - arp_step ], seq_chord_velocity); - arp_note_prev = arp_note + seq_arps[arp_chord][arp_lenght * 2 - arp_step ] ; + else if (arp_style == 1) { //arp down + handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][arp_lenght - arp_step + seq_element_shift], seq_chord_velocity); + arp_note_prev = arp_note + seq_arps[arp_chord][arp_lenght - arp_step + seq_element_shift] ; + } + else if (arp_style == 2) { //arp up & down + if (arp_step <= arp_lenght) { + handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][arp_step ], seq_chord_velocity); + arp_note_prev = arp_note + seq_arps[arp_chord][arp_step ] ; + } + else { + handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][arp_lenght * 2 - arp_step ], seq_chord_velocity); + arp_note_prev = arp_note + seq_arps[arp_chord][arp_lenght * 2 - arp_step ] ; + } + } + else if (arp_style == 3) { //arp random + uint8_t rnd1 = random(arp_lenght); + handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][rnd1 + seq_element_shift] + (seq_oct_shift * 12), seq_chord_velocity); + arp_note_prev = arp_note + seq_arps[arp_chord][rnd1 + seq_element_shift] + (seq_oct_shift * 12); } - } - else if (arp_style == 3) { //arp random - uint8_t rnd1 = random(arp_lenght); - handleNoteOn(configuration.dexed[seq_chord_dexed_inst].midi_channel, arp_note + seq_arps[arp_chord][rnd1 + seq_element_shift] + (seq_oct_shift * 12), seq_chord_velocity); - arp_note_prev = arp_note + seq_arps[arp_chord][rnd1 + seq_element_shift] + (seq_oct_shift * 12); } } }