Skip to content

Commit

Permalink
Feature: Expanded LFO II (Reset, Delayed, Display)
Browse files Browse the repository at this point in the history
Added 2 new properties:
-- rstcount (for increment spirals)
-- delayed (extra pre-time)
- Display Header adapted
- Display Delay and FadeOut
  • Loading branch information
rio-rattenrudel committed Nov 14, 2019
1 parent 36a6266 commit a3b7baf
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 5 deletions.
55 changes: 52 additions & 3 deletions apps/sequencers/midibox_seq_v4/core/seq_lfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand All @@ -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
Expand Down
52 changes: 50 additions & 2 deletions apps/sequencers/midibox_seq_v4/core/seq_ui_fx_lfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a3b7baf

Please sign in to comment.