Module Duplex.Applications.GridPie

Grid Pie lets you combine different parts of song, non-linearly, in real time.

View the README.md (github)

Functions

__init (VarArg) Constructor method
_add_pending_update (src_patt_idx, pos) Method for adding pending updates, called whenever a pattern which is being monitored has changed and a track requires a copy-expansion.
_apply_pending_updates () Copy/expand tracks once the scheduled updates have timed out
adapt_gridpie_pattern () Prepare a newly cloned Grid Pie pattern before playback reaches it
is_session_recording () Helper method to determine if we are currently recording a session
clear_lines (track_idx, patt_idx, start_line, end_line) Clear lines using iterator
alias_slot (track_idx, alias_p_idx) Set one of the recombination pattern-tracks as aliased
set_pattern_cache (patt_idx, track_idx, num_lines) update the internal pattern cache, called immediately after copy-expand
get_pattern_cache (patt_idx, track_idx) retrieve value from internal pattern cache
_set_page_sizes () apply the current settings to pagesizev and pagesizeh variables
_get_v_limit () figure out the upper boundary
_get_h_limit () Figure out the lower boundary
set_vertical_pos (idx) set the vertical position of the grid
set_horizontal_pos (idx) set the horizontal position of the grid
set_vertical_pos_page (seq_idx) set a pattern sequence index, quantized to page size
update_h_buttons () update buttons for horizontal navigation
update_v_buttons () update buttons for vertical navigation
update_v_slider () update slider for vertical navigation
update_h_slider () update slider for horizontal navigation
goto_prev_track_page () go to previous track-page
goto_next_track_page () go to next track-page
goto_first_track_page () go to first track-page
goto_last_track_page () go to last track-page
goto_next_seq_page () go to next sequence-page
goto_prev_seq_page () go to previous sequence-page
goto_first_seq_page () go to first sequence-page
goto_last_seq_page () go to last sequence-page
can_mute_pattern (seq_idx) check if a hold event should perform a "pattern toggle" this is only possible when every track is active & aligned
_slots_are_aligned (seq_idx) function to check if all slots are aligned to the same sequence index
is_garbage_pos (track_idx, seq_idx) is garbage PM position?
matrix_cell (x, y) access a cell in the Grid Pie
init_pm_slots_to (val) toggle all slot mutes in Pattern Matrix (called when starting and stopping the application)
init_gp_pattern () initialize Grid Pie Pattern (called when starting the application)
check_recording_status () realtime recording, check if conditions have changed and call either start/stop_recording (will also update the pattern-sequence loop) this method is called by various notifiers
build_cache () build the initial pattern cache - called on application startup.
make_slot_unique (ptrack, track_idx) makes the target slot unique, update gridpie (first button that has been pressed is the target)
get_idx_from_coords (x, y) translate X/Y into track/sequence position
get_ptrack_from_coords (x, y, skip_garbage) get a pattern-track (slot) from provided coordinates
get_ptrack (seq_idx, track_idx) safely obtain a pattern-track by it's sequence/track index
adjust_grid () update the grid display (used sparingly, as this will paint each and every slot in the grid)
paint_cell (cell, x, y) standalone method for painting individual cells in the grid used by adjustgrid and updatehomeless_tracks
clear_track (track_idx) clear a given track, and briefly mute it
brief_track_mute (track_idx) this is a hackaround, fix when API is updated See: http://www.renoise.com/board/index.php?showtopic=31927
copy_and_expand (patt_idx, dest_patt_idx, track_idx, num_lines, offset, lines_total, start_line, end_line) copy and expand a track
goto_slot (track_idx) show the first/master occurrence of the indicated GP slot, update display (nothing will happen if the slot isn't aliased)
clone_pattern () Call this method to clone the GP pattern, insert at the end patternsequenceobservable will take care of the rest...
toggler (x, y, pattern) toggle position in grid
_toggle_slot (seq_idx, track_idx) toggle a particular slot, auto-detect if we should toggle on or off also, update the pattern-matrix mute state...
_toggle_pattern (seq_idx, track_idx) Toggle a particular pattern
has_aliased_master (ptrk, track_idx) determine if a (gridpie) slot has an aliased master
toggle_slot_record (gridpie_patt, track_idx, mute, master_p_idx) method for toggling slots while realtime recording
set_record_patt_length (gridpie_patt, num_lines, old_num_lines) when recording, we need to pay special attention to the pattern length
remove_buffer_pattern () remove buffer, turn back into gridpie pattern
_update_pm_mutes (seq_idx, track_idx, muted) update PM mute state, called after toggling slot/pattern
_build_app () inherited from Application
assign_to_slot (bt, force) unified method for multi-touch assign/unassign of slot aliases (is using the src_button variable to determine combinations)
start_app (start_running) inherited from Application
stop_app () inherited from Application
abort () song has somehow become invalid - shut down active application
_attach_line_notifiers () attach line notifier to selected pattern, including any aliased patterns
_remove_line_notifiers () remove current set of line notifiers
_restrict_to_pattern_length (num_lines, patt) safe way to set pattern length
_track_changes (pos) Decide if we need to update the recombination/source pattern 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
resolve_patt_idx (patt_idx, track_idx) resolve aliasing of a given pattern-track
on_new_document () inherited from Application
update_homeless_tracks () update display of homeless tracks
on_idle () inherited from Application
incremental_update (track_idx) Call this to produce output for one of the realtime tracks
get_gridpie_seq_pos () quick'n'dirty method for obtaining the gridpie sequence index (it will not check if the pattern is actually the right one)
edit_pos_in_gridpie () determine if edit-position is inside the GRID PIE pattern
mute_selected_track_slot (track_idx) mute existing selected slot (if any) in the pattern matrix
get_grid_x_pos (track_idx) determine the x-position of a track within the grid
get_grid_y_pos (patt_idx) determine the y-position of a pattern within the grid
playback_pos_to_gridpie (restart) move playback position to the GRID PIE pattern
reset_tables () prepare a bunch of values/tables
_attach_to_song (new_song) attach notifiers to the song
_attach_to_pattern (new_song) attach notifiers to the pattern
set_writeahead () To produce continous output to a pattern, we need to have an idea about how much the song-position is advancing within a period of time (the method is called when BPM/LPB is changed)
_keep_the_beat (old_lines, old_pos) Keep the beat: perform a number of tricks in order to keep the playback inside the GRID PIE pattern steady, even as it's size is being changed note: to avoid glitches, call this method before doing anything heavy
_remove_notifiers (new_song, observables) detach all attached notifiers in list, but don't even try to detach when a new song arrived - old observables will no longer be alive then...

Fields

self.matrix_height width/height of the "grid" control-map group
self.matrix_cells references to the grid's buttons
self.gridpie_patt_idx pattern index of gridpie pattern
self.gp_buffer_seq_pos sequence-pos/pattern-index of former gridpie pattern (assigned when session recording)
self.skip_gp_notifier true when we shouldn't listen for changes to the gridpie pattern (when copying pattern data)
self.last_playback_line remember playback-pos line on each idle (for detecting when we arrive at the beginning of a pattern)
self.realtime_record when we record changes in realtime (no aliasing)
self.realtime_tracks list of tracks that should be output as incremental updates (during idle loop) trackidx (int) srcpattidx (int) lastoutput_pos (int or nil)
self.writeahead_length (int) number of lines to output, each time an incremental update is written to the pattern
self.writeahead_interval (int) number of lines between incremental updates
self.skip_line_updates table of lines that should be skipped (for when we have written a note-off)
self.poly_counter list of lengths (pattern-lines) for each track the value is nil when the track isn't active
self.revert_pm_slot memorized state of the matrix
self.homeless_tracks indexed list of homeless tracks
self._blink the state of our slow blink rate (alternates between true and false)
self.x_pos these indicate the upper-left corner of the area currently displayed on the controller
self.active_slots remember the slot sequence indices, set by toggler() (this is set, no matter if the track is active or not, check the poly_counter to see if the track is active)
self._track_count (int) remember the number of sequencer tracks, so we can tell when tracks have been removed or inserted before the tracks_observable is invoked
self.patt_cache

the pattern cache: a table with this structure

[patt_idx] = {
  [track_idx] = {
    cached_length (int)
  }
}
self.pending_updates

when we have edited content that needs copy-expansion:

[track_index] = {
  src_patt_idx (int)
  pos (line notifier table)
}
self._update_task (Scheduler) delayed updates for copy-expanding
self.held_buttons

keep track of held buttons in the matrix

[x][y] = {
  obj (UIButton)
  ptrack (PatternTrack)
  track_idx (int)
  seq_idx (int)
  void (bool)
}
self.src_button the button which was first pressed
self._is_monochrome set once application has been initialized (if true then use alternative draw method)
self.page_size_v page size (horizontal/vertical)
self._current_seq_index remember the current pattern
self._aligned_playpos pattern seq.
self._playing_seq_idx internal value for keeping track of playback progress through the pattern sequence...
self._has_been_started (bool) true once application has been initialized
self.play_requested various flags used by idle loop
self._pattern_observables song observables
self._line_notifiers pattern observables
self._bt_prev_seq UIComponent references


Functions

__init (VarArg)
Constructor method

Parameters:

  • VarArg )

See also:

_add_pending_update (src_patt_idx, pos)
Method for adding pending updates, called whenever a pattern which is being monitored has changed and a track requires a copy-expansion.

Parameters:

  • src_patt_idx (int) "unresolved" source pattern index
  • pos (Table) pos.pattern, pos.track, pos.line
_apply_pending_updates ()
Copy/expand tracks once the scheduled updates have timed out
adapt_gridpie_pattern ()
Prepare a newly cloned Grid Pie pattern before playback reaches it
is_session_recording ()
Helper method to determine if we are currently recording a session
clear_lines (track_idx, patt_idx, start_line, end_line)
Clear lines using iterator

Parameters:

  • track_idx (int)
  • patt_idx (int)
  • start_line (int)
  • end_line (int)
alias_slot (track_idx, alias_p_idx)
Set one of the recombination pattern-tracks as aliased

Parameters:

  • track_idx (int)
  • alias_p_idx (int)
set_pattern_cache (patt_idx, track_idx, num_lines)
update the internal pattern cache, called immediately after copy-expand

Parameters:

  • patt_idx (int), the pattern index
  • track_idx (int), the track index (0 to copy all tracks in pattern)
  • num_lines (int), amount of lines or nil to clear
get_pattern_cache (patt_idx, track_idx)
retrieve value from internal pattern cache

Parameters:

  • patt_idx (int), the pattern index
  • track_idx (int), the track index

Returns:

    (int or nil), amount of lines with valid data
_set_page_sizes ()
apply the current settings to pagesizev and pagesizeh variables
_get_v_limit ()
figure out the upper boundary

Returns:

    int
_get_h_limit ()
Figure out the lower boundary

Returns:

    int
set_vertical_pos (idx)
set the vertical position of the grid

Parameters:

  • idx (int)
set_horizontal_pos (idx)
set the horizontal position of the grid

Parameters:

  • idx (int)
set_vertical_pos_page (seq_idx)
set a pattern sequence index, quantized to page size

Parameters:

  • seq_idx (int)

Returns:

    (int)
update_h_buttons ()
update buttons for horizontal navigation
update_v_buttons ()
update buttons for vertical navigation
update_v_slider ()
update slider for vertical navigation
update_h_slider ()
update slider for horizontal navigation
goto_prev_track_page ()
go to previous track-page
goto_next_track_page ()
go to next track-page
goto_first_track_page ()
go to first track-page
goto_last_track_page ()
go to last track-page
goto_next_seq_page ()
go to next sequence-page
goto_prev_seq_page ()
go to previous sequence-page
goto_first_seq_page ()
go to first sequence-page
goto_last_seq_page ()
go to last sequence-page
can_mute_pattern (seq_idx)
check if a hold event should perform a "pattern toggle" this is only possible when every track is active & aligned

Parameters:

  • seq_idx (int)

Returns:

    bool
_slots_are_aligned (seq_idx)
function to check if all slots are aligned to the same sequence index

Parameters:

  • seq_idx (int)

Returns:

    bool
is_garbage_pos (track_idx, seq_idx)
is garbage PM position?

Parameters:

  • track_idx (int)
  • seq_idx (int)

Returns:

    bool
matrix_cell (x, y)
access a cell in the Grid Pie

Parameters:

  • x (int)
  • y (int)

Returns:

    Duplex.UIButton
init_pm_slots_to (val)
toggle all slot mutes in Pattern Matrix (called when starting and stopping the application)

Parameters:

  • val (bool) true when starting, false when stopping (restore)
init_gp_pattern ()
initialize Grid Pie Pattern (called when starting the application)
check_recording_status ()
realtime recording, check if conditions have changed and call either start/stop_recording (will also update the pattern-sequence loop) this method is called by various notifiers
build_cache ()
build the initial pattern cache - called on application startup.
make_slot_unique (ptrack, track_idx)
makes the target slot unique, update gridpie (first button that has been pressed is the target)

Parameters:

  • ptrack (PatternTrack) the target slot (destination)
  • track_idx (int)

Returns:

    bool, true when slot was made unique
get_idx_from_coords (x, y)
translate X/Y into track/sequence position

Parameters:

  • x (int)
  • y (int)

Returns:

    int,int
get_ptrack_from_coords (x, y, skip_garbage)
get a pattern-track (slot) from provided coordinates

Parameters:

  • x (int) grid x coordinate
  • y (int) grid y coordinate
  • skip_garbage (bool) skip garbage pos, including gridpie

Returns:

    renoise.PatternTrack or nil, int, int
get_ptrack (seq_idx, track_idx)
safely obtain a pattern-track by it's sequence/track index

Parameters:

  • seq_idx (int)
  • track_idx (int)

Returns:

    renoise.PatternTrack or nil
adjust_grid ()
update the grid display (used sparingly, as this will paint each and every slot in the grid)
paint_cell (cell, x, y)
standalone method for painting individual cells in the grid used by adjustgrid and updatehomeless_tracks

Parameters:

clear_track (track_idx)
clear a given track, and briefly mute it

Parameters:

  • track_idx (int)
brief_track_mute (track_idx)
this is a hackaround, fix when API is updated See: http://www.renoise.com/board/index.php?showtopic=31927

Parameters:

  • track_idx (int)
copy_and_expand (patt_idx, dest_patt_idx, track_idx, num_lines, offset, lines_total, start_line, end_line)
copy and expand a track

Parameters:

  • patt_idx (Pattern) source pattern index
  • dest_patt_idx (int) optional, destination pattern index - defined when realtime recording, will use the source pattern index if not defined
  • track_idx (int) the track index
  • num_lines (int) optional, lines to copy before repeating - use source pattern length if not defined
  • offset (int) optional, the source line offset - 0 is the default
  • lines_total (int) optional, use destination pattern length if not defined
  • start_line (int) optional, start output from this line
  • end_line (int) optional, stop output at this line
goto_slot (track_idx)
show the first/master occurrence of the indicated GP slot, update display (nothing will happen if the slot isn't aliased)

Parameters:

  • track_idx (int)
clone_pattern ()
Call this method to clone the GP pattern, insert at the end patternsequenceobservable will take care of the rest...
toggler (x, y, pattern)
toggle position in grid

Parameters:

  • x (int)
  • y (int)
  • pattern (bool), whether to copy entire pattern
_toggle_slot (seq_idx, track_idx)
toggle a particular slot, auto-detect if we should toggle on or off also, update the pattern-matrix mute state...

Parameters:

  • seq_idx (int), the pattern-sequence index
  • track_idx (int), the track index
_toggle_pattern (seq_idx, track_idx)
Toggle a particular pattern

Parameters:

  • seq_idx (int)
  • track_idx (int)
has_aliased_master (ptrk, track_idx)
determine if a (gridpie) slot has an aliased master

Parameters:

  • ptrk (renoise.PatternTrack)
  • track_idx (int)

Returns:

    (bool[,int]) - isalias & aliaspattern_index (optional)
toggle_slot_record (gridpie_patt, track_idx, mute, master_p_idx)
method for toggling slots while realtime recording

Parameters:

  • gridpie_patt (renoise.Pattern) reference to gridpie pattern
  • track_idx (int) the track index
  • mute (bool) true when track should be muted
  • master_p_idx (int) index of the originating/master pattern
set_record_patt_length (gridpie_patt, num_lines, old_num_lines)
when recording, we need to pay special attention to the pattern length

Parameters:

  • gridpie_patt (renoise.Pattern) reference to gridpie pattern
  • num_lines (int)
  • old_num_lines (int)
remove_buffer_pattern ()
remove buffer, turn back into gridpie pattern
_update_pm_mutes (seq_idx, track_idx, muted)
update PM mute state, called after toggling slot/pattern

Parameters:

  • seq_idx (int)
  • track_idx (int or nil), leave out to target the whole pattern
  • muted (bool) true when we should mute the slot(s)
_build_app ()
inherited from Application

Returns:

    bool

See also:

assign_to_slot (bt, force)
unified method for multi-touch assign/unassign of slot aliases (is using the src_button variable to determine combinations)

Parameters:

  • bt (table) see GridPie.held_buttons
  • force (bool) force-assign (otherwise, unique slots are left alone)

Returns:

    bool, true when assigned, false when we need to force-assign
start_app (start_running)
inherited from Application

Parameters:

  • start_running

Returns:

    bool or nil

See also:

stop_app ()
inherited from Application

See also:

abort ()
song has somehow become invalid - shut down active application
_attach_line_notifiers ()
attach line notifier to selected pattern, including any aliased patterns
_remove_line_notifiers ()
remove current set of line notifiers
_restrict_to_pattern_length (num_lines, patt)
safe way to set pattern length

Parameters:

  • num_lines (int)
  • patt (renoise.Pattern)
_track_changes (pos)
Decide if we need to update the recombination/source pattern 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 (table with fields "pattern", "track" and "line")
resolve_patt_idx (patt_idx, track_idx)
resolve aliasing of a given pattern-track

Parameters:

  • patt_idx TRACE("GridPie
  • track_idx resolvepattidx()",pattidx,trackidx)

Returns:

    int, the resolived pattern index
on_new_document ()
inherited from Application

See also:

update_homeless_tracks ()
update display of homeless tracks
on_idle ()
inherited from Application

See also:

incremental_update (track_idx)
Call this to produce output for one of the realtime tracks

Parameters:

  • track_idx (int)
get_gridpie_seq_pos ()
quick'n'dirty method for obtaining the gridpie sequence index (it will not check if the pattern is actually the right one)
edit_pos_in_gridpie ()
determine if edit-position is inside the GRID PIE pattern

Returns:

    bool
mute_selected_track_slot (track_idx)
mute existing selected slot (if any) in the pattern matrix

Parameters:

  • track_idx (int)
get_grid_x_pos (track_idx)
determine the x-position of a track within the grid

Parameters:

  • track_idx (int)
get_grid_y_pos (patt_idx)
determine the y-position of a pattern within the grid

Parameters:

  • patt_idx (int)
playback_pos_to_gridpie (restart)
move playback position to the GRID PIE pattern

Parameters:

  • restart (bool) force pattern to play from the beginning
reset_tables ()
prepare a bunch of values/tables
_attach_to_song (new_song)
attach notifiers to the song

Parameters:

  • new_song (bool) when false, we attempt to remove existing notifiers
_attach_to_pattern (new_song)
attach notifiers to the pattern

Parameters:

  • new_song (bool) when false, we attempt to remove existing notifiers
set_writeahead ()
To produce continous output to a pattern, we need to have an idea about how much the song-position is advancing within a period of time (the method is called when BPM/LPB is changed)
_keep_the_beat (old_lines, old_pos)
Keep the beat: perform a number of tricks in order to keep the playback inside the GRID PIE pattern steady, even as it's size is being changed note: to avoid glitches, call this method before doing anything heavy

Parameters:

  • old_lines (int) the previous number of lines
  • old_pos (renoise.SongPos) the songposition to translate
_remove_notifiers (new_song, observables)
detach all attached notifiers in list, 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 (table)

Fields

self.matrix_height
width/height of the "grid" control-map group
self.matrix_cells
references to the grid's buttons
self.gridpie_patt_idx
pattern index of gridpie pattern
self.gp_buffer_seq_pos
sequence-pos/pattern-index of former gridpie pattern (assigned when session recording)
self.skip_gp_notifier
true when we shouldn't listen for changes to the gridpie pattern (when copying pattern data)
self.last_playback_line
remember playback-pos line on each idle (for detecting when we arrive at the beginning of a pattern)
self.realtime_record
when we record changes in realtime (no aliasing)
self.realtime_tracks
list of tracks that should be output as incremental updates (during idle loop) trackidx (int) srcpattidx (int) lastoutput_pos (int or nil)
self.writeahead_length
(int) number of lines to output, each time an incremental update is written to the pattern
self.writeahead_interval
(int) number of lines between incremental updates
self.skip_line_updates
table of lines that should be skipped (for when we have written a note-off)
self.poly_counter
list of lengths (pattern-lines) for each track the value is nil when the track isn't active
self.revert_pm_slot
memorized state of the matrix
self.homeless_tracks
indexed list of homeless tracks
self._blink
the state of our slow blink rate (alternates between true and false)
self.x_pos
these indicate the upper-left corner of the area currently displayed on the controller
self.active_slots
remember the slot sequence indices, set by toggler() (this is set, no matter if the track is active or not, check the poly_counter to see if the track is active)
self._track_count
(int) remember the number of sequencer tracks, so we can tell when tracks have been removed or inserted before the tracks_observable is invoked
self.patt_cache

the pattern cache: a table with this structure

[patt_idx] = {
  [track_idx] = {
    cached_length (int)
  }
}
self.pending_updates

when we have edited content that needs copy-expansion:

[track_index] = {
  src_patt_idx (int)
  pos (line notifier table)
}
self._update_task
(Scheduler) delayed updates for copy-expanding
self.held_buttons

keep track of held buttons in the matrix

[x][y] = {
  obj (UIButton)
  ptrack (PatternTrack)
  track_idx (int)
  seq_idx (int)
  void (bool)
}
self.src_button
the button which was first pressed
self._is_monochrome
set once application has been initialized (if true then use alternative draw method)
self.page_size_v
page size (horizontal/vertical)
self._current_seq_index
remember the current pattern
self._aligned_playpos
pattern seq. index from when we started, and the "aligned" song position (nil when all active tracks aren't aligned to the same sequence pos)
self._playing_seq_idx
internal value for keeping track of playback progress through the pattern sequence...
self._has_been_started
(bool) true once application has been initialized
self.play_requested
various flags used by idle loop
self._pattern_observables
song observables
self._line_notifiers
pattern observables
self._bt_prev_seq
UIComponent references
generated by LDoc 1.4.2