Console Commands: Difference between revisions

Rewrote and expanded the console commands page, but I'm only about half done ;)
(typos)
(Rewrote and expanded the console commands page, but I'm only about half done ;))
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.
==Grid==
 
Using the formula "grid=g" can make even larger or smaller grids. Due to this, some users had the chance (as early as 2020) to use unusual grids.
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.
===Shortcut===
 
Using ctrl-alt-c can automatically split into multiple smaller grid-sized pieces.
It's important to keep a few things in mind when using the console:
==Detune==
 
Using "setDetune(instrument, n)" (replace n with a number) can make detune go beyond 1200 or -1200.
* Not all of the commands below have undo/redo support. So if you make a change it might not be possible to undo it.
==Reverb and distortion==
* It's possible to corrupt your sequence using the console. So if you're new to this it's highly recommended that you save your sequence before messing with the console.
In reverb and distortion, using "setReverbVolume (r)" and "setDistortVolume (d)" (replace either variable with a number) can both go beyond 1.
 
==Equalizer==
* 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 be placed at t=0, 1, 2, etc.
The equalizer is separated into three parts, high, mid, and low. Using either "setEqHigh" "setEqMid" or "setEqLow" can be set beyond 48 and -48.
* Instruments are identified using a number, also know 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)".
==Panning==
 
Using "setPan" can make panning go beyond 1 or -1.
== Basic techniques ==
==Markers==
You can change a lot of the sequencer options in the console. This can be useful to go beyond the values usually allowed in the UI.
*''See also: [[Markers#Using the console to format markers]]''
 
Using the formula song.getAllMarkersAtTime(t) (replacing the "t" with another number, using the grid to make a number exact) will bypass the restrictions of any effects of what the marker has.
=== Grid ===
setGrid(value)
Changes the size of the grid. The way the value works is a bit confusing: it's the number of grid lines per time unit (per quarter note). So a 1/4 grid has a value of 1, and a 1/8 grid has a value of 2. You can use this formula to work out the value: value = 0.25 / grid. No undo/redo support.
 
=== Time signature ===
setTimeSig(timeSig)
Sets the time signature of the sequence. Time signatures on OS are always N/4 (so 3/4, 4/4, 5/4 etc), and the timeSig parameter is just the N. So to set the time signature to 7/4, use "setTimeSig(7)". If you want something more exotic, you'll need to find the closest equivalent in N/4. So 6/8 could be represented as 3/4, and 7/16 could be represented as 7/4 with a faster tempo. No undo/redo support.
 
=== Detune ===
setDetune(instrument, detune)
Sets the detune of an instrument. Detune values are measured in cents, where each semi-tone is 100 cents. So to detune a full octave up, set the detune to 1200. The usual limit in the UI is -1200 to 1200, but you can use this function to set it to more extreme values. No undo/redo support.
 
'''WARNING:''' Firefox does not support detunes outside -1200 to 1200, so using extreme values will mean your sequence will only play correctly on Chromium browsers.
 
=== Reverb and distortion ===
setReverbVolume(instrument, volume)
setDistortVolume(instrument, volume)
Sets the reverb volume and distort volume of an instrument. The volume goes from 0 to 1 in the UI, but you can set it to whatever you like using these functions. No undo/redo support.
 
=== Equalizer ===
setEqHigh(instrument, value)
setEqMid(instrument, value)
setEqLow(instrument, value)
Sets the EQ of an instrument. The values only go from -48 to 48 in the UI, but you can set them to any value using these functions. No undo/redo support.
 
=== Panning ===
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.
 
== Intermediate techniques ==
function stretchNotes(factor)
function fadeNotes(fadeIn = false)
function resetAllInstrumentSettings()
function truncateNotesAt(time)
function removeAllMarkers()
function convertToDetuneMarkers(startNote = 'C5')
function humanize(volumeVariation = 0.2, timeVariation = 0.1)
function remixNotes(chunkSize = 4, avgChunksPerUnmixedSection = 2, avgChunksPerMixedSextion = 2, avgMixedSectionsPerUnmixedSection = 1)
TODO: Documentation
 
== 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.
 
=== Selecting notes and markers ===
function selectNotesIf(predicate, addToSelection = false)
function selectMarkersIf(predicate, addToSelection = false)
 
=== Tweaking notes ===
function tweakNotes(tweakFunction)
 
=== Tweaking markers ===
 
=== Creating and deleting notes ===
 
=== Creating and deleting markers ===