Module Duplex.Applications.StepSequencer

Use your grid controller as a basic step sequencer.

Inheritance: Duplex.Application > Duplex.Application.StepSequencer

Each button in the grid corresponds to a line in a track. The grid is scrollable too - use the line/track mappings to access any part of the pattern you're editing.

Originally written by daxton.fleming@gmail.com

How to use:

  • Press an empty button to put a note down, using the currently selected instrument, base-note and volume
  • Press a lit button to remove the note
  • Press and hold a lit button to copy the note. Toggle a note on/off somewhere else to paste the copied note to this location
  • Transpose note up/down by pressing and holding any number of notes, and then pressing the transpose buttons. Changes will be applied to all held notes
  • Adjust note volume by pressing and holding any number of notes, and then pressing a level button. Changes will be applied to all held notes
  • Press level/transpose buttons when no notes are held, to adjust the base-note and default volume

Changes

0.98.21

- Support line_notifier when slots are aliased (also when created and/or removed)
- Workflow: when navigating from a long pattern into a shorter one, start from
  the top (IOW, always restrict to the actual pattern length)
- Fixed: update the volume-level display when base volume is changed
- Fixed: selecting a group track could cause an error

0.98.20

- Fixed: focus bug when holding button

0.98.18

- Mappings track, level, line, transpose are now optional. This should fix an
  issue with the nano2K config that didn’t specify ‘track’
- Fixed: under certain conditions, could throw error on startup

0.98

- Palette now uses the standard format (easier to customize)
- Sequencer tracks can be linked with instruments, simply by assigning
  the same name to both.
  UISpinner (deprecated) control replaced with UISlider+UIButton(s)

0.96

- Option: "follow_track", set to align to selected track in Renoise
- Option: "track_increment", specify custom step size for track-switching

0.95

- The sequencer is now fully synchronized with the currently selected
  pattern in  Renoise. You can copy, delete or move notes around,
  and the StepSequencer will update it's display accordingly
- Enabling Renoise's follow mode will cause instant catch-up
- Display volume/base-note changes in the status bar
- Orientation: use as sideways 16-step sequencer on monome128 etc.
- Option: "increment by this amount" value for navigating lines
- Improved performance

0.93

- Support other devices than the Launchpad (such as the monome)
- Display playposition and volume simultaneously

0.92

- Original version

Functions

__init (VarArg) constructor method
start_app () inherited from Application
stop_app () inherited from Application
_build_app () inherited from Application
_build_line () line (up/down scrolling)
_build_track () track (sideways scrolling)
_build_grid () construct user interface
_build_level () construct user interface
_build_transpose () construct user interface
on_idle () inherited from Application
_update_track_count () update track navigator, on new song, and when tracks have been changed
_update_position () if the playback position is inside visible range of the sequencer, update the position indicator else, if follow mode is active, display the current page (called on_idle when playing)
_update_page () check if we should switch the active page/range inside the pattern
get_pos () get the current position (edit-pos when stopped, playpos when playing)
set_page (idx) set the current edit page
jump_to_top () jump to topmost page
jump_to_bottom () jump to bottommost page
jump_to_prev_lines () jump to previous page
jump_to_next_lines () jump to next page
post_jump_update () update display after a jump
_draw_position (idx) called on_idle
_update_line_count () update the range of the line navigator
_update_line_buttons () update the display (line buttons)
_update_grid () update the display (main grid)
_track_changes (pos) decide if we need to update the display when the pattern editor has changed note: this method might be called hundreds of times when doing edits like cutting all notes from a pattern, so we need it to be really simple
_line_is_visible (line_pos) check if a given line is within the visible range
_track_is_visible (track_idx) check if a given track is within the visible range
_follow_track () when following the active track in Renoise, we call this method (track following is limited to sequencer tracks)
_get_track_page (track_idx) figure out the active "track page" based on the supplied track index
_get_page_width () get the currently set page width
_get_orientation () get the orientation of the main grid
_attach_to_song () add notifiers to relevant parts of the song
_attach_to_pattern (new_song, patt_idx) add notifiers to the pattern
_attach_alias_notifiers (new_song, patt_idx) monitor the current pattern for changes to it's aliases
_attach_line_notifiers (new_song, patt_idx) attach line notifiers to pattern check for existing notifiers first, and remove those then add pattern notifiers to pattern (including aliased slots)
remove_line_notifiers (new_song) remove currently attached line notifiers
on_new_document () inherited from Application
_process_grid_event (x, y, state, btn) handle when button in main grid is pressed
_obtain_instrument_by_name (name) obtain instrument by name (track<>instrument synchronization)
_copy_grid_button (lx, ly, btn) invoked when starting a note-copy gesture (first held button)
_draw_volume_slider (volume) update display of volume slider
_set_note (note_obj, note, instrument, volume) write properties into provided note column
_clear_note (note_obj) clear properties for note column
_draw_grid_button (button, note, current_track) assign color to button, based on note properties
_volume_palette (vol, max) figure out the color for a given volume level
_set_basenote (note_value) set basenote for new notes
_transpose_basenote (steps) transpose existing basenote by given amount
_remove_notifiers (new_song, observables) detach all previously attached notifiers first but don't even try to detach when a new song arrived.
_walk_held_keys (callback, toggle_exempt) apply a function to all held grid buttons, optionally adding them all to toggle_exempt table.

Tables

self._keys_down track held grid keys
self._toggle_exempt don't toggle off if pressing multiple on / transposing / etc

Fields

self._base_note default note/volume
self._track_count default note-grid size
self._edit_page the currently editing "page"
self._track_offset the track offset (0-#tracks)
self._follow_player true when song follow is enabled, set to false when using the line navigator
self._start_tracking a "fire once" flag, which is set when switching from "not follow" to "follow"
self._current_pattern remember the current pattern index here
self._current_line_index remember the current line index
self._line_notifiers collect patterns indices with line_notifiers
self._alias_notifiers collect references to pattern-alias notifier methods


Functions

__init (VarArg)
constructor method

Parameters:

  • VarArg )

See also:

start_app ()
inherited from Application

Returns:

    bool or nil

See also:

stop_app ()
inherited from Application

See also:

_build_app ()
inherited from Application

Returns:

    bool

See also:

_build_line ()
line (up/down scrolling)
_build_track ()
track (sideways scrolling)
_build_grid ()
construct user interface
_build_level ()
construct user interface
_build_transpose ()
construct user interface
on_idle ()
inherited from Application

See also:

_update_track_count ()
update track navigator, on new song, and when tracks have been changed
_update_position ()
if the playback position is inside visible range of the sequencer, update the position indicator else, if follow mode is active, display the current page (called on_idle when playing)
_update_page ()
check if we should switch the active page/range inside the pattern
get_pos ()
get the current position (edit-pos when stopped, playpos when playing)

Returns:

    SongPos
set_page (idx)
set the current edit page

Parameters:

  • idx (int)
jump_to_top ()
jump to topmost page
jump_to_bottom ()
jump to bottommost page
jump_to_prev_lines ()
jump to previous page
jump_to_next_lines ()
jump to next page
post_jump_update ()
update display after a jump
_draw_position (idx)
called on_idle

Parameters:

  • idx TRACE("StepSequencer drawposition(idx)",idx)
_update_line_count ()
update the range of the line navigator
_update_line_buttons ()
update the display (line buttons)
_update_grid ()
update the display (main grid)
_track_changes (pos)
decide if we need to update the display when the pattern editor has changed note: this method might be called hundreds of times when doing edits like cutting all notes from a pattern, so we need it to be really simple

Parameters:

  • pos
_line_is_visible (line_pos)
check if a given line is within the visible range

Parameters:

  • line_pos (int)
_track_is_visible (track_idx)
check if a given track is within the visible range

Parameters:

  • track_idx (int)
_follow_track ()
when following the active track in Renoise, we call this method (track following is limited to sequencer tracks)
_get_track_page (track_idx)
figure out the active "track page" based on the supplied track index

Parameters:

  • track_idx , renoise track number return integer (0-number of pages)
_get_page_width ()
get the currently set page width

Returns:

    int
_get_orientation ()
get the orientation of the main grid
_attach_to_song ()
add notifiers to relevant parts of the song
_attach_to_pattern (new_song, patt_idx)
add notifiers to the pattern

Parameters:

  • new_song
  • patt_idx
_attach_alias_notifiers (new_song, patt_idx)
monitor the current pattern for changes to it's aliases

Parameters:

  • new_song
  • patt_idx
_attach_line_notifiers (new_song, patt_idx)
attach line notifiers to pattern check for existing notifiers first, and remove those then add pattern notifiers to pattern (including aliased slots)

Parameters:

  • new_song
  • patt_idx
remove_line_notifiers (new_song)
remove currently attached line notifiers

Parameters:

  • new_song
on_new_document ()
inherited from Application

See also:

_process_grid_event (x, y, state, btn)
handle when button in main grid is pressed

Parameters:

  • x
  • y
  • state
  • btn
_obtain_instrument_by_name (name)
obtain instrument by name (track<>instrument synchronization)

Parameters:

  • name

Returns:

    (int) instrument index
_copy_grid_button (lx, ly, btn)
invoked when starting a note-copy gesture (first held button)

Parameters:

_draw_volume_slider (volume)
update display of volume slider

Parameters:

  • volume (int), between 0-127
_set_note (note_obj, note, instrument, volume)
write properties into provided note column

Parameters:

  • note_obj (NoteColumn)
  • note (int) note pitch
  • instrument (int) instrument number
  • volume (int) note velocity
_clear_note (note_obj)
clear properties for note column

Parameters:

  • note_obj (NoteColumn)
_draw_grid_button (button, note, current_track)
assign color to button, based on note properties

Parameters:

  • button
  • note
  • current_track
_volume_palette (vol, max)
figure out the color for a given volume level

Parameters:

  • vol (int), between 0-127
  • max (int), 127
_set_basenote (note_value)
set basenote for new notes

Parameters:

  • note_value (int) note pitch
_transpose_basenote (steps)
transpose existing basenote by given amount

Parameters:

  • steps (int) relative amount to add
_remove_notifiers (new_song, observables)
detach all previously attached notifiers first but don't even try to detach when a new song arrived. old observables will no longer be alive then...

Parameters:

  • new_song (bool), true to leave existing notifiers alone
  • observables
    • list of observables
_walk_held_keys (callback, toggle_exempt)
apply a function to all held grid buttons, optionally adding them all to toggle_exempt table. return the number of held keys

Parameters:

  • callback (function), the callback function
  • toggle_exempt (bool), do not toggle off

Tables

self._keys_down
track held grid keys
self._toggle_exempt
don't toggle off if pressing multiple on / transposing / etc

Fields

self._base_note
default note/volume
self._track_count
default note-grid size
self._edit_page
the currently editing "page"
self._track_offset
the track offset (0-#tracks)
self._follow_player
true when song follow is enabled, set to false when using the line navigator
self._start_tracking
a "fire once" flag, which is set when switching from "not follow" to "follow"
self._current_pattern
remember the current pattern index here
self._current_line_index
remember the current line index
self._line_notifiers
collect patterns indices with line_notifiers
self._alias_notifiers
collect references to pattern-alias notifier methods
generated by LDoc 1.4.2