Console Commands: Difference between revisions

m
(Added a small note to humanize, and reverted a few grammar changes (all the other grammar changes were good, thanks Crum).)
 
(5 intermediate revisions by 3 users not shown)
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.
[[File:Chrome console.png|alt=The Chrome developer console|thumb|The Chrome developer console]]
'''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 copying/pasting the commands on this page, try [https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps 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 copying/pasting the commands on this page, try [https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps learning some JS].
Line 10: Line 11:
* The fundamental time units used by the sequencer are quarter notes, starting at 0. So t=10 would mean the half-beat after the second beat. If you set the grid to 1/4 (the default) the grid lines match this time unit. Markers can only be placed at whole number time steps: t=0, 1, 2, etc.
* The fundamental time units used by the sequencer are quarter notes, starting at 0. So t=10 would mean the half-beat after the second beat. If you set the grid to 1/4 (the default) the grid lines match this time unit. Markers can only be placed at whole number time steps: t=0, 1, 2, etc.
* Instruments are identified using a number, also known as the ID. The current instrument is stored in the global variable "instrument". So to figure out the number for an instrument, just choose that instrument in the UI, type "instrument", and press enter. You can also just pass "instrument" directly to use the current instrument, eg "setDetune(instrument, 1200)".
* Instruments are identified using a number, also known as the ID. The current instrument is stored in the global variable "instrument". So to figure out the number for an instrument, just choose that instrument in the UI, type "instrument", and press enter. You can also just pass "instrument" directly to use the current instrument, eg "setDetune(instrument, 1200)".
* The console can be very noisy, but all the log spam comes from the ads. You can restrict the console to only show logs from the sequencer itself by enabling "Selected context only" in the console settings (see image). This works in Chrome, but there will be similar filters in any browser.
[[File:Silencing log spam.png|alt=Silencing log spam|thumb|241x241px|To silence log spam, click the console settings button, then enable "Selected context only".]]


== Basic techniques ==
== Basic techniques ==
Line 42: Line 45:
  setPan(instrument, value)
  setPan(instrument, value)
Sets the panning of an instrument. The value can go from -1 to 1 in the UI, but this function can set it to anything. No undo/redo support.
Sets the panning of an instrument. The value can go from -1 to 1 in the UI, but this function can set it to anything. No undo/redo support.
=== Volume ===
Instrument Volume:
setInitialInstrumentVolume(instrument, value)
Sets the volume of an instrument. The value can go from -1 to 1 in the UI, but this function can set it to anything. No undo/redo support. Does not update the UI automatically, either update the UI manually or use fillAdvancedInstrumentSettings() and fillSimpleInstrumentSettings()
Sequence Volume:
setInitialSongVolume(value)
Sets the volume of the sequence. The value can go from -1 to 1 in the UI, but this function can set it to anything. No undo/redo support. Does not update the UI.


== Intermediate techniques ==
== Intermediate techniques ==
Line 51: Line 63:


=== Fade notes ===
=== Fade notes ===
  fadeNotes(fadeIn = false)
  fadeNotesIn()
  fadeNotes()     // Fade out
  fadeNotesOut()
fadeNotes(true)  // Fade in
Fades the selected notes in or out. FadeNotesIn fades in the segment from 0 volume to the original volume, and fadeNotesOut fades the notes from their original volume to 0.
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 the original volume.


Includes undo/redo support.
Includes undo/redo support.
Line 77: Line 88:


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.
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.
=== Convert to Marimba ===
convertToMarimba()
Clones and detunes the "2023 Drum Kit" for each note in the selection, then moves each note to the closest octave of the three "Marimba" notes in the kit. This is useful for using the marimba as its own instrument, and works with multiple notes at a time. This function ignores drum kit instruments.


Includes undo/redo support.
Includes undo/redo support.
Line 176: Line 193:
For example, you can halve the volume like this (eg for a custom delay effect, copy, shift, then tweak the volume):
For example, you can halve the volume like this (eg for a custom delay effect, copy, shift, then tweak the volume):
  tweakNotes(n => n.volume *= 0.5)
  tweakNotes(n => n.volume *= 0.5)
We can also use tweakNotes to quantize the note times. This code snaps the notes to the nearest grid line (grid is a global variable that contains the grid value, see setGrid above):
tweakNotes(n=>n.time = Math.round(n.time * grid) / grid)
Another example is the humanize function, which is built on tweakNotes (in fact, several of the other functions could be rewritten in terms of tweakNotes):
Another example is the humanize function, which is built on tweakNotes (in fact, several of the other functions could be rewritten in terms of tweakNotes):
  function humanize(volumeVariation = 0.2, timeVariation = 0.1) {
  function humanize(volumeVariation = 0.2, timeVariation = 0.1) {
11

edits