Console Commands: Difference between revisions

Fill in intermediate techniques.
(Rewrote and expanded the console commands page, but I'm only about half done ;))
(Fill in intermediate techniques.)
Line 1: Line 1:
'''Console Commands''' extend the functionality of the sequencer beyond what is possible with the UI. To access the console, press Ctrl + Shift + J for Chromium browsers, or Ctrl + Shift + K for Firefox.
'''Console Commands''' extend the functionality of the sequencer beyond what is possible with the UI. To access the console, press Ctrl + Shift + J for Chromium browsers, or Ctrl + Shift + K for Firefox.


To run a command using the console, just type it in and press enter. The console executes JS code, so if you want to go beyond copy/pasting the commands on this page, try learning some JS.
To run a command using the console, just type it in and press enter. The console executes JS code, so if you want to go beyond copy/pasting the commands on this page, try [https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps learning some JS].


It's important to keep a few things in mind when using the console:
It's important to keep a few things in mind when using the console:
Line 44: Line 44:


== Intermediate techniques ==
== Intermediate techniques ==
function stretchNotes(factor)
Most of these functions act on the currently selected notes. Select the notes you want to edit, then run the function in the console. I refer to the sequence of selected notes as the selected segment.
  function fadeNotes(fadeIn = false)
 
  function resetAllInstrumentSettings()
In JS, functions parameters can have [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters default values]. This means if you don't pass a value to that parameter, it will default to some value. A lot of the functions in this section have default parameters. They're written in the documentation like this: "fadeNotes(fadeIn = false)". This means the "fadeIn" parameter defaults to false, so instead of writing "fadeNotes(false)" you can just write "fadeNotes()".
  function truncateNotesAt(time)
 
  function removeAllMarkers()
=== Fade notes ===
  function convertToDetuneMarkers(startNote = 'C5')
  fadeNotes(fadeIn = false)
  function humanize(volumeVariation = 0.2, timeVariation = 0.1)
  fadeNotes()     // Fade out
  function remixNotes(chunkSize = 4, avgChunksPerUnmixedSection = 2, avgChunksPerMixedSextion = 2, avgMixedSectionsPerUnmixedSection = 1)
  fadeNotes(true)  // Fade in
TODO: Documentation
Fades the selected notes in or out (that is, it sets the volumes of the notes based on their position in the segment). The function takes a single parameter, "fadeIn" which defaults to false. In other words it fades the notes from their original volume to 0 by default, or if you pass "true" it fades in the segment from 0 volume to original volume.
 
Includes undo/redo support.
 
=== Stretch notes ===
stretchNotes(factor)
Stretches or squishes the selected segment by the given factor. A factor more than 1 will make the selected segment longer, and less than 1 will make it shorter. A factor less than 0 will reverse the segment.
 
It also works on selected markers, but since marker times are quantized to whole number times, they might not be moved to exactly the right spot. Also, reversing markers is complicated, and not all marker sequences are reversible, so negative factors are not supported if you have markers selected.
 
Includes undo/redo support.
 
=== Truncate notes ===
  truncateNotesAt(time)
Cuts off all the selected notes at the specified time. If a note extends past this time, its length will be truncated. If a note begins after this time it will be deleted.
 
Includes undo/redo support.
 
=== Convert to detune markers ===
  convertToDetuneMarkers(startNote = 'C5')
Moves all the selected notes to the "startNote", then creates detune markers to detune each note back to its original pitch. For example, if you select a "D5" and then run this with the default startNote, it will move the note to "C5" and create a detune marker to detune it up 200 cents back to "D5". This is useful for making clear melodies on instruments that get muddy when there's a lot of notes.
 
Due to the limitations of detune markers, this will only work if the melody sticks to whole number time steps (ie lines up with the quarter note grid), and there's only ever one note at a particular time. This function ignores drum kit instruments.
 
Includes undo/redo support.
 
=== Humanize ===
  humanize(volumeVariation = 0.2, timeVariation = 0.1)
Randomly alters the volume and start time of all the selected notes by a small amount. This is designed to simulate a human playing the sequence. You can choose your own variation amounts, or just run "humanize()" to use the defaults.
 
Each note volume is multiplied by a random value between 1 - volumeVariation and 1 + volumeVariation (so 0.8 to 1.2 by default). Each note start time is shifted by a random value between -timeVariation and timeVariation (ie timeVariation is measured in quarter notes).
 
Includes undo/redo support.
 
=== Remix notes ===
  remixNotes(chunkSize = 4, avgChunksPerUnmixedSection = 2, avgChunksPerMixedSection = 2, avgMixedSectionsPerUnmixedSection = 1)
Divides the selected segment into chunks and mixes them around. This is mainly just for fun, but can be handy to generate a breakdown by remixing a drum loop, or to reshuffle a melody if you need a bit of inspiration. The chunkSize parameter controls how large the chunks are (in quarter notes), and the other parameters control how the chunks are mixed up.
 
Includes undo/redo support.
 
=== Reset all instrument settings ===
resetAllInstrumentSettings()
Resets the settings of all the instruments in the sequence.
 
'''WARNING:''' No undo/redo support.
removeAllMarkers()
Deletes all the markers in the sequence.
 
'''WARNING:''' No undo/redo support.


== Advanced techniques ==
== Advanced techniques ==
You will need to know a little JS to use these functions. In particular, we're going to be using a lot of [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#syntax lambda functions], so familiarize yourself with these first. This section also assumes you know basic programming concepts like variables, objects, for loops, and if statements.
You will need to know a little JS to use these functions. In particular, we're going to be using a lot of [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#syntax lambda functions], so familiarize yourself with these first. This section also assumes you know basic programming concepts like [https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/Variables variables], [https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Basics objects], [https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Looping_code loops], and [https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/conditionals if statements].


=== Selecting notes and markers ===
=== Selecting notes and markers ===
  function selectNotesIf(predicate, addToSelection = false)
  selectNotesIf(predicate, addToSelection = false)
  function selectMarkersIf(predicate, addToSelection = false)
  selectMarkersIf(predicate, addToSelection = false)


=== Tweaking notes ===
=== Tweaking notes ===
  function tweakNotes(tweakFunction)
  tweakNotes(tweakFunction)


=== Tweaking markers ===
=== Tweaking markers ===
Line 69: Line 117:


=== Creating and deleting markers ===
=== Creating and deleting markers ===
=== Other handy tools ===
selection