From a3b7baff0a7a6a9e20dac2870e94182e08a8f5c2 Mon Sep 17 00:00:00 2001 From: Rio Date: Mon, 7 Oct 2019 23:54:46 +0200 Subject: [PATCH] Feature: Expanded LFO II (Reset, Delayed, Display) Added 2 new properties: -- rstcount (for increment spirals) -- delayed (extra pre-time) - Display Header adapted - Display Delay and FadeOut --- apps/sequencers/midibox_seq_v4/core/seq_lfo.c | 55 ++++++++++++++++++- .../midibox_seq_v4/core/seq_ui_fx_lfo.c | 52 +++++++++++++++++- 2 files changed, 102 insertions(+), 5 deletions(-) diff --git a/apps/sequencers/midibox_seq_v4/core/seq_lfo.c b/apps/sequencers/midibox_seq_v4/core/seq_lfo.c index da54f8d7d..912d3c1e4 100644 --- a/apps/sequencers/midibox_seq_v4/core/seq_lfo.c +++ b/apps/sequencers/midibox_seq_v4/core/seq_lfo.c @@ -26,11 +26,20 @@ // Local types ///////////////////////////////////////////////////////////////////////////// +//########################################################################### +//# RIO: Added Spezial Behaviour LFO (rstcount for increment spirals, delay) +//########################################################################### + typedef struct { u16 step_ctr; u16 pos; + u16 rstcount; // RIO: added rstcount + u8 delayed; // RIO: added delayflag } seq_lfo_t; +//########################################################################### +//# RIO: END MODIFICATION +//########################################################################### ///////////////////////////////////////////////////////////////////////////// // Local variables @@ -58,6 +67,9 @@ s32 SEQ_LFO_Init(u32 mode) return 0; // no error } +//########################################################################### +//# RIO: Added Spezial Behaviour LFO (rstcount for increment spirals, delay) +//########################################################################### ///////////////////////////////////////////////////////////////////////////// // Initializes the LFO of a given track @@ -68,6 +80,11 @@ s32 SEQ_LFO_ResetTrk(u8 track) lfo->step_ctr = 0; lfo->pos = 0; + lfo->rstcount = 0; // RIO: added rstcount + + seq_cc_trk_t *tcc = &seq_cc_trk[track]; + if (tcc->lfo_phase > 100 && tcc->lfo_phase <= 200) lfo->delayed = 1; // RIO: added delayed + else lfo->delayed = 0; return 0; // no error } @@ -88,28 +105,60 @@ s32 SEQ_LFO_HandleTrk(u8 track, u32 bpm_tick) if( (bpm_tick % 96) == 0 && lfo->step_ctr != 65535) // @384 ppqn (reference bpm_tick resolution) ++lfo->step_ctr; + // RIO: delay + u8 delvalue = 0; + if (tcc->lfo_phase > 100 && tcc->lfo_phase <= 200) { + delvalue = tcc->lfo_phase-100; + if (lfo->delayed) { + if( lfo->step_ctr >= delvalue ) { + lfo->delayed = 0; + lfo->step_ctr = 0; + } + } + } // increment waveform position - if( lfo->step_ctr > tcc->lfo_steps_rst ) { + if( lfo->step_ctr > tcc->lfo_steps_rst - delvalue) { // RIO: added delvalue to reset if( tcc->lfo_enable_flags.ONE_SHOT ) { // oneshot mode: halt LFO counter lfo->step_ctr = 65535; - lfo->pos = 65535; + + //lfo->pos = 65535; // ORIGINAL + if (tcc->lfo_phase <= 100) lfo->pos = tcc->lfo_phase * 655; // RIO: setup phase in oneshot + else lfo->pos = 65535; + } else { + // reset step counter and LFO position lfo->step_ctr = 0; - lfo->pos = tcc->lfo_phase * 655; // possible phase offset: 0%..99% + + lfo->rstcount++; // RIO: increment rstcount + //lfo->pos = tcc->lfo_phase * 655; // possible phase offset: 0%..99% // ORIGINAL + if (tcc->lfo_phase <= 100) lfo->pos = tcc->lfo_phase * 655 * lfo->rstcount; // RIO: added rstcount + else lfo->pos = 0; + } + if (tcc->lfo_phase > 100 && tcc->lfo_phase <= 200) lfo->delayed = 1; // RIO: set again delay + } else { + + if (lfo->delayed) return 0; // RIO: no LFO increment + // increment waveform pointer u32 lfo_ticks = (u32)(tcc->lfo_steps+1) * 96; // @384 ppqn (reference bpm_tick resolution) u32 inc = 65536 / lfo_ticks; lfo->pos += inc; + } return 0; // no error } +//########################################################################### +//# RIO: END MODIFICATION +//########################################################################### + + ///////////////////////////////////////////////////////////////////////////// // modifies a MIDI event depending on LFO settings diff --git a/apps/sequencers/midibox_seq_v4/core/seq_ui_fx_lfo.c b/apps/sequencers/midibox_seq_v4/core/seq_ui_fx_lfo.c index 1277146fa..3226c9abc 100644 --- a/apps/sequencers/midibox_seq_v4/core/seq_ui_fx_lfo.c +++ b/apps/sequencers/midibox_seq_v4/core/seq_ui_fx_lfo.c @@ -383,7 +383,40 @@ static s32 LCD_Handler(u8 high_prio) /////////////////////////////////////////////////////////////////////////// SEQ_LCD_CursorSet(0, 0); - SEQ_LCD_PrintString("Trk. Wave Amp. Phs. Steps Rst OneShot Note Vel. Len. CC ExtraCC# Offs. PPQN"); + + //############################## + //# RIO: Display Header adapted + //############################## + + // Original: + //SEQ_LCD_PrintString("Trk. Wave Amp. Phs. Steps Rst OneShot Note Vel. Len. CC ExtraCC# Offs. PPQN"); + + char buffer1[5]; + char buffer2[5]; + char ch = ' '; + + u8 value = SEQ_CC_Get(visible_track, SEQ_CC_LFO_WAVEFORM); + if ( value >= SEQ_LFO_WAVEFORM___V2 && value <=SEQ_LFO_WAVEFORM_A4A4) sprintf(buffer1, "R+Q+"); + else sprintf(buffer1, "Wave"); + + if (SEQ_CC_Get(visible_track, SEQ_CC_LFO_PHASE) > 200) { + if (SEQ_CC_Get(visible_track, SEQ_CC_LFO_ENABLE_FLAGS) & (1 << 7)) { + if (SEQ_CC_Get(visible_track, SEQ_CC_LFO_ENABLE_FLAGS) & (1 << 6)) sprintf(buffer2, "FupA"); + else sprintf(buffer2, "FdnA"); + } else { + if (SEQ_CC_Get(visible_track, SEQ_CC_LFO_ENABLE_FLAGS) & (1 << 6)) sprintf(buffer2, "FupR"); + else sprintf(buffer2, "FdnR"); + } + } + else if (SEQ_CC_Get(visible_track, SEQ_CC_LFO_PHASE) > 100) sprintf(buffer2, "Dly."); + else sprintf(buffer2, "Phs."); + + SEQ_LCD_PrintFormattedString("Trk. %s%cAmp. %s Steps Rst OneShot Note Vel. Len. CC ExtraCC# Offs. PPQN",buffer1,ch,buffer2); + + //############################## + //# RIO: END MODIFICATION + //############################## + /////////////////////////////////////////////////////////////////////////// SEQ_LCD_CursorSet(0, 1); @@ -534,13 +567,28 @@ static s32 LCD_Handler(u8 high_prio) SEQ_LCD_PrintFormattedString("%4d ", value); } + + //########################### + //# RIO: Delay and FadeOut + //########################### + /////////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_PHASE && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(6); } else { - SEQ_LCD_PrintFormattedString("%3d%% ", SEQ_CC_Get(visible_track, SEQ_CC_LFO_PHASE)); + // Original: + // SEQ_LCD_PrintFormattedString("%3d%% ", SEQ_CC_Get(visible_track, SEQ_CC_LFO_PHASE)); + + u8 tmp = SEQ_CC_Get(visible_track, SEQ_CC_LFO_PHASE); // RIO: added Delay and FadeOut + if (tmp > 200) SEQ_LCD_PrintFormattedString("%3d ", tmp-200); + else if (tmp > 100) SEQ_LCD_PrintFormattedString("%3d ", tmp-100); + else SEQ_LCD_PrintFormattedString("%3d%% ", tmp); } + //########################### + //# RIO: END MODIFICATION + //########################### + /////////////////////////////////////////////////////////////////////////// if( ui_selected_item == ITEM_STEPS && ui_cursor_flash ) { SEQ_LCD_PrintSpaces(5);