<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://onlinesequencer.net/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Liam</id>
	<title>Online Sequencer Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://onlinesequencer.net/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Liam"/>
	<link rel="alternate" type="text/html" href="https://onlinesequencer.net/wiki/Special:Contributions/Liam"/>
	<updated>2026-06-08T07:19:15Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=Synthesizer&amp;diff=1134</id>
		<title>Synthesizer</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=Synthesizer&amp;diff=1134"/>
		<updated>2023-11-16T20:29:03Z</updated>

		<summary type="html">&lt;p&gt;Liam: LMAO. The synth isn&amp;#039;t discontinued.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The &#039;&#039;&#039;synthesizer&#039;&#039;&#039; is an upcoming instrument that will allow users to create their own custom sounds. It is currently being tested as an adjustable synthesizer instrument (ID 55). Similar to the 8-bit instruments, it makes use of the Web Audio API instead of samples. When selecting the instrument, the synthesizer tab is shown, with the following options:[[File:Synthesizertab marked.png|thumb|The synthesizer tab]]&lt;br /&gt;
#&#039;&#039;&#039;Waveform&#039;&#039;&#039;: the base waveform and sound to use for the instrument. Can be sine, square, sawtooth, or triangle.&lt;br /&gt;
#&#039;&#039;&#039;Filter&#039;&#039;&#039;: The type of filter pass and frequency to use can be selected with the dropdown menu and slider. A low pass, high pass, and band pass are available.&lt;br /&gt;
#*Currently, it seems like the high pass and band pass are mislabeled as each other.&lt;br /&gt;
#&#039;&#039;&#039;Resonance&#039;&#039;&#039;: A slider controlling the resonance of the filter.&lt;br /&gt;
#&#039;&#039;&#039;Oscillator waveform&#039;&#039;&#039;: The waveform to use for the oscillator.&lt;br /&gt;
#&#039;&#039;&#039;Oscillator frequency/toggle&#039;&#039;&#039;: Allows you to turn the oscillator on or off, along with its period relative to a measure or by frequency.&lt;br /&gt;
#&#039;&#039;&#039;Oscillator type and amplitude&#039;&#039;&#039;: The dropdown menu allows you to select what the oscillators affects; volume, pitch, and the filter intensity can be adjusted. The slider controls the effect of the oscillation.&lt;br /&gt;
#&#039;&#039;&#039;ADSR (Attack, Decay, Sustain, and Release)&#039;&#039;&#039;: ADSR can be toggled on the left side of the tab. When enabled, the ADSR sliders will control the attack, delay, sustain, and release of the synthesizer.&lt;br /&gt;
&lt;br /&gt;
=== Current Status ===&lt;br /&gt;
The project is still in development, but is no longer available on the [[test site]].&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=Brad&amp;diff=911</id>
		<title>Brad</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=Brad&amp;diff=911"/>
		<updated>2023-09-22T22:56:19Z</updated>

		<summary type="html">&lt;p&gt;Liam: Redirected page to Brad Day&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Brad_Day]]&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=!wiki&amp;diff=866</id>
		<title>!wiki</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=!wiki&amp;diff=866"/>
		<updated>2023-08-31T01:48:30Z</updated>

		<summary type="html">&lt;p&gt;Liam: Redirected page to Main Page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Main_Page]]&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=FFT&amp;diff=791</id>
		<title>FFT</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=FFT&amp;diff=791"/>
		<updated>2023-07-13T00:56:15Z</updated>

		<summary type="html">&lt;p&gt;Liam: Redirected page to Vocal synthesis using sine&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Vocal_synthesis_using_sine]]&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=Console_Commands&amp;diff=667</id>
		<title>Console Commands</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=Console_Commands&amp;diff=667"/>
		<updated>2023-05-05T20:48:16Z</updated>

		<summary type="html">&lt;p&gt;Liam: Add a tweakNotes example showing how to quantize notes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Chrome console.png|alt=The Chrome developer console|thumb|The Chrome developer console]]&lt;br /&gt;
&#039;&#039;&#039;Console Commands&#039;&#039;&#039; 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. &lt;br /&gt;
&lt;br /&gt;
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].&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to keep a few things in mind when using the console:&lt;br /&gt;
&lt;br /&gt;
* Not all of the commands below have undo/redo support. So if you make a change it might not be possible to undo it.&lt;br /&gt;
* It&#039;s possible to corrupt your sequence using the console. So if you&#039;re new to this it&#039;s highly recommended that you save your sequence before messing with the console.&lt;br /&gt;
&lt;br /&gt;
* 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.&lt;br /&gt;
* Instruments are identified using a number, also known as the ID. The current instrument is stored in the global variable &amp;quot;instrument&amp;quot;. So to figure out the number for an instrument, just choose that instrument in the UI, type &amp;quot;instrument&amp;quot;, and press enter. You can also just pass &amp;quot;instrument&amp;quot; directly to use the current instrument, eg &amp;quot;setDetune(instrument, 1200)&amp;quot;.&lt;br /&gt;
* 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 &amp;quot;Selected context only&amp;quot; in the console settings (see image). This works in Chrome, but there will be similar filters in any browser.&lt;br /&gt;
[[File:Silencing log spam.png|alt=Silencing log spam|thumb|241x241px|To silence log spam, click the console settings button, then enable &amp;quot;Selected context only&amp;quot;.]]&lt;br /&gt;
&lt;br /&gt;
== Basic techniques ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Grid ===&lt;br /&gt;
 setGrid(value)&lt;br /&gt;
Changes the size of the grid. The way the value works is a bit confusing: it&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== Time signature ===&lt;br /&gt;
 setTimeSig(timeSig)&lt;br /&gt;
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 &amp;quot;setTimeSig(7)&amp;quot;. If you want something more exotic, you&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== Detune ===&lt;br /&gt;
 setDetune(instrument, detune)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; Firefox does not support detunes outside -1200 to 1200, so using extreme values will mean your sequence will only play correctly on Chromium browsers.&lt;br /&gt;
&lt;br /&gt;
=== Reverb and distortion ===&lt;br /&gt;
 setReverbVolume(instrument, volume)&lt;br /&gt;
 setDistortVolume(instrument, volume)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Equalizer ===&lt;br /&gt;
 setEqHigh(instrument, value)&lt;br /&gt;
 setEqMid(instrument, value)&lt;br /&gt;
 setEqLow(instrument, value)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Panning ===&lt;br /&gt;
 setPan(instrument, value)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Intermediate techniques ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
In JS, function parameters can have [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters default values]. This means if you don&#039;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&#039;re written in the documentation like this: &amp;quot;fadeNotes(fadeIn = false)&amp;quot;. This means the &amp;quot;fadeIn&amp;quot; parameter defaults to false, so instead of writing &amp;quot;fadeNotes(false)&amp;quot; you can just write &amp;quot;fadeNotes()&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The functions in this section are defined [https://onlinesequencer.net/app/consoleCommands.js here]. If you know some JS, you can read this file to learn how they work and create your own.&lt;br /&gt;
&lt;br /&gt;
=== Fade notes ===&lt;br /&gt;
 fadeNotesIn()&lt;br /&gt;
 fadeNotesOut()&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Stretch notes ===&lt;br /&gt;
 stretchNotes(factor)&lt;br /&gt;
Stretches or squishes the selected segment by the given factor. A factor of 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.&lt;br /&gt;
&lt;br /&gt;
It also works on selected markers, but since marker times are quantized to whole number time steps, 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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Truncate notes ===&lt;br /&gt;
 truncateNotesAt(time)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Convert to detune markers ===&lt;br /&gt;
 convertToDetuneMarkers(startNote = &#039;C5&#039;)&lt;br /&gt;
Moves all the selected notes to the &amp;quot;startNote&amp;quot;, then creates detune markers to detune each note back to its original pitch. For example, if you select a &amp;quot;D5&amp;quot; and then run this with the default startNote, it will move the note to &amp;quot;C5&amp;quot; and create a detune marker to detune it up 200 cents back to &amp;quot;D5&amp;quot;. This is useful for making clear melodies on instruments that get muddy when there are a lot of notes.&lt;br /&gt;
&lt;br /&gt;
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&#039;s only ever one note at a particular time. This function ignores drum kit instruments.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Humanize ===&lt;br /&gt;
 humanize(volumeVariation = 0.2, timeVariation = 0.1)&lt;br /&gt;
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 &amp;quot;humanize()&amp;quot; to use the defaults.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
Note that if you use this function on a note that touches the end of of the last measure of your sequence, there&#039;s a 50/50 chance it will be moved to the right (past the end of the sequence) causing your sequence to loop one measure late. You can fix this by manually changing the length of the note to snap it back to the end of that final measure.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Remix notes ===&lt;br /&gt;
 remixNotes(chunkSize = 4, avgChunksPerUnmixedSection = 2, avgChunksPerMixedSection = 2, avgMixedSectionsPerUnmixedSection = 1)&lt;br /&gt;
Divides the selected segment into chunks and mix 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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Reset all instrument settings ===&lt;br /&gt;
 resetAllInstrumentSettings()&lt;br /&gt;
Resets the settings of all the instruments in the sequence.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; No undo/redo support.&lt;br /&gt;
 removeAllMarkers()&lt;br /&gt;
Deletes all the markers in the sequence.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; No undo/redo support.&lt;br /&gt;
&lt;br /&gt;
== Advanced techniques ==&lt;br /&gt;
You will need to know some JS to use these functions. In particular, we&#039;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].&lt;br /&gt;
&lt;br /&gt;
=== Working with the selection ===&lt;br /&gt;
Most of the functions in the previous section work on the selected notes and markers. The notes and markers selected in the UI are stored in the &amp;quot;selection&amp;quot; object.&lt;br /&gt;
 console.log(selection.notes)&lt;br /&gt;
 console.log(selection.markers)&lt;br /&gt;
 console.log(selection.getTimeSpan())&lt;br /&gt;
You can find all the methods on the selection object [https://onlinesequencer.net/app/selection.js here]. It&#039;s sometimes useful to be able to loop over all the notes or markers in the selection, but if you want to modify the notes in the selection, use tweakNotes below.&lt;br /&gt;
 for (const note of selection.notes) {&lt;br /&gt;
   console.log(note);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 for (const marker of selection.marker) {&lt;br /&gt;
   console.log(marker);&lt;br /&gt;
 }&lt;br /&gt;
You can also add or remove markers and notes from the selection using the selectNote, selectMarker, deselectNote, and deselectMarker methods. However, it&#039;s usually easier to use these functions:&lt;br /&gt;
 selectNotesIf(predicate, addToSelection = false)&lt;br /&gt;
 selectMarkersIf(predicate, addToSelection = false)&lt;br /&gt;
These functions take a predicate (a function that returns true or false) and select all the notes or markers for which the predicate returns true. If addToSelection is true, these notes or markers are added to the existing selection, otherwise, they replace the current selection. Both these functions include undo/redo support.&lt;br /&gt;
&lt;br /&gt;
For example, say you wanted to delete the [https://tiusic.com/thumb.html thumbnail] notes from a sequence, so you can change the thumbnail. Thumbnail notes all have 0 volume, so you can just select all the notes with 0 volume:&lt;br /&gt;
 selectNotesIf(n =&amp;gt; n.volume == 0)&lt;br /&gt;
This selects all the thumbnail notes, so now you can delete them as normal (though the UI focus will still be on the console, so you&#039;ll have to click on the sequencer before you press delete).&lt;br /&gt;
&lt;br /&gt;
=== Tweaking notes ===&lt;br /&gt;
 tweakNotes(tweakFunction)&lt;br /&gt;
This is probably the single most useful console function. It basically runs tweakFunction on every selected note and has undo/redo support for any changes that tweakFunction makes to the note. It&#039;s roughly equivalent to:&lt;br /&gt;
 for (const note of selection.notes) {&lt;br /&gt;
   tweakFunction(note);&lt;br /&gt;
 }&lt;br /&gt;
There are a few problems with doing a for loop like this and manually tweaking the notes. For starters, you won&#039;t get undo/redo support, but the bigger problem is that there are a few optimizations that OS does based on the note time, instrument, length, or pitch that require extra work if you modify those parameters (namely &amp;quot;song.moveNote()&amp;quot; and &amp;quot;song.updateLoopTime()&amp;quot;). Failure to do so could corrupt your sequence. tweakNotes takes care of this work for you so you don&#039;t have to worry about it.&lt;br /&gt;
&lt;br /&gt;
The fields of the note object that you can modify are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+The fields of the Note object&lt;br /&gt;
!Name&lt;br /&gt;
!Type&lt;br /&gt;
!Description&lt;br /&gt;
!Can modify?&lt;br /&gt;
|-&lt;br /&gt;
|instrument&lt;br /&gt;
|Integer&lt;br /&gt;
|The instrument id, eg 22 for sitar&lt;br /&gt;
|Only with tweakNotes&lt;br /&gt;
|-&lt;br /&gt;
|type&lt;br /&gt;
|String&lt;br /&gt;
|The pitch or keyboard note, eg &#039;C5&#039; or &#039;F#7&#039;&lt;br /&gt;
|Only with tweakNotes&lt;br /&gt;
|-&lt;br /&gt;
|time&lt;br /&gt;
|Number&lt;br /&gt;
|The time when the note starts in standard time units (quarter notes)&lt;br /&gt;
|Only with tweakNotes&lt;br /&gt;
|-&lt;br /&gt;
|length&lt;br /&gt;
|Number&lt;br /&gt;
|The length of the note in standard time units&lt;br /&gt;
|Only with tweakNotes&lt;br /&gt;
|-&lt;br /&gt;
|volume&lt;br /&gt;
|Number&lt;br /&gt;
|The volume of the note, usually from 0 to 1.&lt;br /&gt;
|Always&lt;br /&gt;
|}&lt;br /&gt;
If you console.log the note you&#039;ll see other internal fields, but &#039;&#039;&#039;DO NOT MODIFY THESE&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
For example, you can halve the volume like this (eg for a custom delay effect, copy, shift, then tweak the volume):&lt;br /&gt;
 tweakNotes(n =&amp;gt; n.volume *= 0.5)&lt;br /&gt;
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):&lt;br /&gt;
 tweakNotes(n=&amp;gt;n.time = Math.round(n.time * grid) / grid)&lt;br /&gt;
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):&lt;br /&gt;
 function humanize(volumeVariation = 0.2, timeVariation = 0.1) {&lt;br /&gt;
   tweakNotes(n =&amp;gt; {&lt;br /&gt;
     n.volume *= 1 + volumeVariation * (2 * Math.random() - 1);&lt;br /&gt;
     n.time += timeVariation * (2 * Math.random() - 1);&lt;br /&gt;
     if (n.time &amp;lt; 0) n.time = 0;&lt;br /&gt;
   });&lt;br /&gt;
 }&lt;br /&gt;
Tweak notes can also be used to generate the lengthening sawtooth effect from [https://onlinesequencer.net/1905746 Ganymede]:&lt;br /&gt;
 const span = selection.getTimeSpan();&lt;br /&gt;
 tweakNotes(n =&amp;gt; {&lt;br /&gt;
   n.length *= 0.5 + (n.time - span.min) / (span.max - span.min);&lt;br /&gt;
 });&lt;br /&gt;
A more complicated example is adding swing to your selected notes:&lt;br /&gt;
 tweakNotes(n =&amp;gt; {&lt;br /&gt;
   const t = n.time / 4;&lt;br /&gt;
   const intTime = Math.floor(t);&lt;br /&gt;
   const fracTime = t - intTime;&lt;br /&gt;
   const newFracTime = fracTime &amp;lt;= 0.5 ? fracTime * 4 / 3 : (fracTime - 0.5) * 3 / 4 + 2 / 3;&lt;br /&gt;
   n.time = (intTime + newFracTime) * 4;&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Tweaking markers ===&lt;br /&gt;
There is currently no marker equivalent of tweakNotes. Markers also have optimizations that mean you can&#039;t modify the time, instrument, or setting, without doing extra work. The only things you can safely modify are the value and the blend. If you need to modify the other parameters, you&#039;re better off asking the devs to add a tweakMarkers function, rather than trying to modify them and corrupting your sequence.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+The fields of the Marker object&lt;br /&gt;
!Name&lt;br /&gt;
!Type&lt;br /&gt;
!Description&lt;br /&gt;
!Can modify?&lt;br /&gt;
|-&lt;br /&gt;
|instrument&lt;br /&gt;
|Integer&lt;br /&gt;
|The instrument id, eg 19 for xylophone&lt;br /&gt;
|Never&lt;br /&gt;
|-&lt;br /&gt;
|time&lt;br /&gt;
|Integer&lt;br /&gt;
|The marker&#039;s time (quarter notes, must be a whole number)&lt;br /&gt;
|Never&lt;br /&gt;
|-&lt;br /&gt;
|setting&lt;br /&gt;
|Integer&lt;br /&gt;
|The setting (one of the kMarkerSetting... constants, eg kMarkerSettingBpm)&lt;br /&gt;
|Never&lt;br /&gt;
|-&lt;br /&gt;
|value&lt;br /&gt;
|Dynamic&lt;br /&gt;
|The marker value. Its type depends on the marker setting.&lt;br /&gt;
|Always&lt;br /&gt;
|-&lt;br /&gt;
|blend&lt;br /&gt;
|Boolean&lt;br /&gt;
|Whether or not the marker is blended.&lt;br /&gt;
|Always&lt;br /&gt;
|}&lt;br /&gt;
With these limitations, the most useful thing you can do is set the marker value to a value outside the normal range (like we did for the instrument settings above). This snippet sets all the selected detune markers to detune up by 2 octaves:&lt;br /&gt;
 for (const marker of selection.markers) {&lt;br /&gt;
   if (marker.setting == kMarkerSettingInstrumentDetune) {&lt;br /&gt;
     marker.value = 2400;&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
If you really need to change the instrument, time, or setting, delete the marker and create a new one (see below for details).&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;quot;song.getAllMarkersAtTime(t)&amp;quot; to get a list of all the markers at a specific time, but selecting them in the UI and then iterating over &amp;quot;selection.markers&amp;quot; is easier.&lt;br /&gt;
&lt;br /&gt;
=== Creating notes ===&lt;br /&gt;
You can create Note objects using &amp;quot;new Note&amp;quot;, but you also have to manually add them to the song, like so:&lt;br /&gt;
 song.addNote(new Note(song, type, time, length, instrument, volume))&lt;br /&gt;
For example, let&#039;s generate a random melody:&lt;br /&gt;
 for (let i = 0; i &amp;lt; 16; ++i) {&lt;br /&gt;
   song.addNote(new Note(song, &#039;CDEFGAB&#039;[Math.floor(Math.random() * 7)] + &#039;4&#039;, i, 1, instrument, 1));&lt;br /&gt;
 }&lt;br /&gt;
Whenever you make changes to the notes of a sequence (adding, removing, moving, etc), the changes won&#039;t be visible until the sequencer view is updated. You can either run &amp;quot;SequencerView.repaint()&amp;quot;, or just move the view a bit (eg scroll). tweakNotes handles this for you, but in this example, you need to do it manually.&lt;br /&gt;
&lt;br /&gt;
Adding notes like this doesn&#039;t have undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Deleting notes ===&lt;br /&gt;
If you have a Note object, you can remove it from the sequence like this:&lt;br /&gt;
 song.removeNote(note)&lt;br /&gt;
This doesn&#039;t actually delete the Note object, just removes it from the sequence. In fact you can add it again if you want, using &amp;quot;song.addNote(note)&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s take another look at our earlier example, where we wanted to delete the thumbnail notes. Instead of using selectNotesIf and then manually deleting them, we could automatically delete them.&lt;br /&gt;
 for (const note of song.notes) {&lt;br /&gt;
   if (note.volume == 0) {&lt;br /&gt;
     song.removeNote(note);&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
Removing notes like this doesn&#039;t have undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Creating markers ===&lt;br /&gt;
 addMarker(time, setting, instrument, value, blend)&lt;br /&gt;
This function adds a marker to the song. The parameters are the same as in the marker field table above. Returns the newly created Marker object. Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Deleting markers ===&lt;br /&gt;
 removeMarker(marker)&lt;br /&gt;
Removes the marker from the sequence. Includes undo/redo support.&lt;br /&gt;
[[category:Online Sequencer UI]]&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=Console_Commands&amp;diff=666</id>
		<title>Console Commands</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=Console_Commands&amp;diff=666"/>
		<updated>2023-05-05T20:43:17Z</updated>

		<summary type="html">&lt;p&gt;Liam: Update fade notes section to mention fadeNotesIn and fadeNotesOut&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Chrome console.png|alt=The Chrome developer console|thumb|The Chrome developer console]]&lt;br /&gt;
&#039;&#039;&#039;Console Commands&#039;&#039;&#039; 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. &lt;br /&gt;
&lt;br /&gt;
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].&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to keep a few things in mind when using the console:&lt;br /&gt;
&lt;br /&gt;
* Not all of the commands below have undo/redo support. So if you make a change it might not be possible to undo it.&lt;br /&gt;
* It&#039;s possible to corrupt your sequence using the console. So if you&#039;re new to this it&#039;s highly recommended that you save your sequence before messing with the console.&lt;br /&gt;
&lt;br /&gt;
* 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.&lt;br /&gt;
* Instruments are identified using a number, also known as the ID. The current instrument is stored in the global variable &amp;quot;instrument&amp;quot;. So to figure out the number for an instrument, just choose that instrument in the UI, type &amp;quot;instrument&amp;quot;, and press enter. You can also just pass &amp;quot;instrument&amp;quot; directly to use the current instrument, eg &amp;quot;setDetune(instrument, 1200)&amp;quot;.&lt;br /&gt;
* 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 &amp;quot;Selected context only&amp;quot; in the console settings (see image). This works in Chrome, but there will be similar filters in any browser.&lt;br /&gt;
[[File:Silencing log spam.png|alt=Silencing log spam|thumb|241x241px|To silence log spam, click the console settings button, then enable &amp;quot;Selected context only&amp;quot;.]]&lt;br /&gt;
&lt;br /&gt;
== Basic techniques ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Grid ===&lt;br /&gt;
 setGrid(value)&lt;br /&gt;
Changes the size of the grid. The way the value works is a bit confusing: it&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== Time signature ===&lt;br /&gt;
 setTimeSig(timeSig)&lt;br /&gt;
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 &amp;quot;setTimeSig(7)&amp;quot;. If you want something more exotic, you&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== Detune ===&lt;br /&gt;
 setDetune(instrument, detune)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; Firefox does not support detunes outside -1200 to 1200, so using extreme values will mean your sequence will only play correctly on Chromium browsers.&lt;br /&gt;
&lt;br /&gt;
=== Reverb and distortion ===&lt;br /&gt;
 setReverbVolume(instrument, volume)&lt;br /&gt;
 setDistortVolume(instrument, volume)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Equalizer ===&lt;br /&gt;
 setEqHigh(instrument, value)&lt;br /&gt;
 setEqMid(instrument, value)&lt;br /&gt;
 setEqLow(instrument, value)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Panning ===&lt;br /&gt;
 setPan(instrument, value)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Intermediate techniques ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
In JS, function parameters can have [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters default values]. This means if you don&#039;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&#039;re written in the documentation like this: &amp;quot;fadeNotes(fadeIn = false)&amp;quot;. This means the &amp;quot;fadeIn&amp;quot; parameter defaults to false, so instead of writing &amp;quot;fadeNotes(false)&amp;quot; you can just write &amp;quot;fadeNotes()&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The functions in this section are defined [https://onlinesequencer.net/app/consoleCommands.js here]. If you know some JS, you can read this file to learn how they work and create your own.&lt;br /&gt;
&lt;br /&gt;
=== Fade notes ===&lt;br /&gt;
 fadeNotesIn()&lt;br /&gt;
 fadeNotesOut()&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Stretch notes ===&lt;br /&gt;
 stretchNotes(factor)&lt;br /&gt;
Stretches or squishes the selected segment by the given factor. A factor of 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.&lt;br /&gt;
&lt;br /&gt;
It also works on selected markers, but since marker times are quantized to whole number time steps, 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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Truncate notes ===&lt;br /&gt;
 truncateNotesAt(time)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Convert to detune markers ===&lt;br /&gt;
 convertToDetuneMarkers(startNote = &#039;C5&#039;)&lt;br /&gt;
Moves all the selected notes to the &amp;quot;startNote&amp;quot;, then creates detune markers to detune each note back to its original pitch. For example, if you select a &amp;quot;D5&amp;quot; and then run this with the default startNote, it will move the note to &amp;quot;C5&amp;quot; and create a detune marker to detune it up 200 cents back to &amp;quot;D5&amp;quot;. This is useful for making clear melodies on instruments that get muddy when there are a lot of notes.&lt;br /&gt;
&lt;br /&gt;
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&#039;s only ever one note at a particular time. This function ignores drum kit instruments.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Humanize ===&lt;br /&gt;
 humanize(volumeVariation = 0.2, timeVariation = 0.1)&lt;br /&gt;
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 &amp;quot;humanize()&amp;quot; to use the defaults.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
Note that if you use this function on a note that touches the end of of the last measure of your sequence, there&#039;s a 50/50 chance it will be moved to the right (past the end of the sequence) causing your sequence to loop one measure late. You can fix this by manually changing the length of the note to snap it back to the end of that final measure.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Remix notes ===&lt;br /&gt;
 remixNotes(chunkSize = 4, avgChunksPerUnmixedSection = 2, avgChunksPerMixedSection = 2, avgMixedSectionsPerUnmixedSection = 1)&lt;br /&gt;
Divides the selected segment into chunks and mix 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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Reset all instrument settings ===&lt;br /&gt;
 resetAllInstrumentSettings()&lt;br /&gt;
Resets the settings of all the instruments in the sequence.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; No undo/redo support.&lt;br /&gt;
 removeAllMarkers()&lt;br /&gt;
Deletes all the markers in the sequence.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; No undo/redo support.&lt;br /&gt;
&lt;br /&gt;
== Advanced techniques ==&lt;br /&gt;
You will need to know some JS to use these functions. In particular, we&#039;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].&lt;br /&gt;
&lt;br /&gt;
=== Working with the selection ===&lt;br /&gt;
Most of the functions in the previous section work on the selected notes and markers. The notes and markers selected in the UI are stored in the &amp;quot;selection&amp;quot; object.&lt;br /&gt;
 console.log(selection.notes)&lt;br /&gt;
 console.log(selection.markers)&lt;br /&gt;
 console.log(selection.getTimeSpan())&lt;br /&gt;
You can find all the methods on the selection object [https://onlinesequencer.net/app/selection.js here]. It&#039;s sometimes useful to be able to loop over all the notes or markers in the selection, but if you want to modify the notes in the selection, use tweakNotes below.&lt;br /&gt;
 for (const note of selection.notes) {&lt;br /&gt;
   console.log(note);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 for (const marker of selection.marker) {&lt;br /&gt;
   console.log(marker);&lt;br /&gt;
 }&lt;br /&gt;
You can also add or remove markers and notes from the selection using the selectNote, selectMarker, deselectNote, and deselectMarker methods. However, it&#039;s usually easier to use these functions:&lt;br /&gt;
 selectNotesIf(predicate, addToSelection = false)&lt;br /&gt;
 selectMarkersIf(predicate, addToSelection = false)&lt;br /&gt;
These functions take a predicate (a function that returns true or false) and select all the notes or markers for which the predicate returns true. If addToSelection is true, these notes or markers are added to the existing selection, otherwise, they replace the current selection. Both these functions include undo/redo support.&lt;br /&gt;
&lt;br /&gt;
For example, say you wanted to delete the [https://tiusic.com/thumb.html thumbnail] notes from a sequence, so you can change the thumbnail. Thumbnail notes all have 0 volume, so you can just select all the notes with 0 volume:&lt;br /&gt;
 selectNotesIf(n =&amp;gt; n.volume == 0)&lt;br /&gt;
This selects all the thumbnail notes, so now you can delete them as normal (though the UI focus will still be on the console, so you&#039;ll have to click on the sequencer before you press delete).&lt;br /&gt;
&lt;br /&gt;
=== Tweaking notes ===&lt;br /&gt;
 tweakNotes(tweakFunction)&lt;br /&gt;
This is probably the single most useful console function. It basically runs tweakFunction on every selected note and has undo/redo support for any changes that tweakFunction makes to the note. It&#039;s roughly equivalent to:&lt;br /&gt;
 for (const note of selection.notes) {&lt;br /&gt;
   tweakFunction(note);&lt;br /&gt;
 }&lt;br /&gt;
There are a few problems with doing a for loop like this and manually tweaking the notes. For starters, you won&#039;t get undo/redo support, but the bigger problem is that there are a few optimizations that OS does based on the note time, instrument, length, or pitch that require extra work if you modify those parameters (namely &amp;quot;song.moveNote()&amp;quot; and &amp;quot;song.updateLoopTime()&amp;quot;). Failure to do so could corrupt your sequence. tweakNotes takes care of this work for you so you don&#039;t have to worry about it.&lt;br /&gt;
&lt;br /&gt;
The fields of the note object that you can modify are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+The fields of the Note object&lt;br /&gt;
!Name&lt;br /&gt;
!Type&lt;br /&gt;
!Description&lt;br /&gt;
!Can modify?&lt;br /&gt;
|-&lt;br /&gt;
|instrument&lt;br /&gt;
|Integer&lt;br /&gt;
|The instrument id, eg 22 for sitar&lt;br /&gt;
|Only with tweakNotes&lt;br /&gt;
|-&lt;br /&gt;
|type&lt;br /&gt;
|String&lt;br /&gt;
|The pitch or keyboard note, eg &#039;C5&#039; or &#039;F#7&#039;&lt;br /&gt;
|Only with tweakNotes&lt;br /&gt;
|-&lt;br /&gt;
|time&lt;br /&gt;
|Number&lt;br /&gt;
|The time when the note starts in standard time units (quarter notes)&lt;br /&gt;
|Only with tweakNotes&lt;br /&gt;
|-&lt;br /&gt;
|length&lt;br /&gt;
|Number&lt;br /&gt;
|The length of the note in standard time units&lt;br /&gt;
|Only with tweakNotes&lt;br /&gt;
|-&lt;br /&gt;
|volume&lt;br /&gt;
|Number&lt;br /&gt;
|The volume of the note, usually from 0 to 1.&lt;br /&gt;
|Always&lt;br /&gt;
|}&lt;br /&gt;
If you console.log the note you&#039;ll see other internal fields, but &#039;&#039;&#039;DO NOT MODIFY THESE&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
For example, you can halve the volume like this (eg for a custom delay effect, copy, shift, then tweak the volume):&lt;br /&gt;
 tweakNotes(n =&amp;gt; n.volume *= 0.5)&lt;br /&gt;
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):&lt;br /&gt;
 function humanize(volumeVariation = 0.2, timeVariation = 0.1) {&lt;br /&gt;
   tweakNotes(n =&amp;gt; {&lt;br /&gt;
     n.volume *= 1 + volumeVariation * (2 * Math.random() - 1);&lt;br /&gt;
     n.time += timeVariation * (2 * Math.random() - 1);&lt;br /&gt;
     if (n.time &amp;lt; 0) n.time = 0;&lt;br /&gt;
   });&lt;br /&gt;
 }&lt;br /&gt;
Tweak notes can also be used to generate the lengthening sawtooth effect from [https://onlinesequencer.net/1905746 Ganymede]:&lt;br /&gt;
 const span = selection.getTimeSpan();&lt;br /&gt;
 tweakNotes(n =&amp;gt; {&lt;br /&gt;
   n.length *= 0.5 + (n.time - span.min) / (span.max - span.min);&lt;br /&gt;
 });&lt;br /&gt;
A more complicated example is adding swing to your selected notes:&lt;br /&gt;
 tweakNotes(n =&amp;gt; {&lt;br /&gt;
   const t = n.time / 4;&lt;br /&gt;
   const intTime = Math.floor(t);&lt;br /&gt;
   const fracTime = t - intTime;&lt;br /&gt;
   const newFracTime = fracTime &amp;lt;= 0.5 ? fracTime * 4 / 3 : (fracTime - 0.5) * 3 / 4 + 2 / 3;&lt;br /&gt;
   n.time = (intTime + newFracTime) * 4;&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Tweaking markers ===&lt;br /&gt;
There is currently no marker equivalent of tweakNotes. Markers also have optimizations that mean you can&#039;t modify the time, instrument, or setting, without doing extra work. The only things you can safely modify are the value and the blend. If you need to modify the other parameters, you&#039;re better off asking the devs to add a tweakMarkers function, rather than trying to modify them and corrupting your sequence.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+The fields of the Marker object&lt;br /&gt;
!Name&lt;br /&gt;
!Type&lt;br /&gt;
!Description&lt;br /&gt;
!Can modify?&lt;br /&gt;
|-&lt;br /&gt;
|instrument&lt;br /&gt;
|Integer&lt;br /&gt;
|The instrument id, eg 19 for xylophone&lt;br /&gt;
|Never&lt;br /&gt;
|-&lt;br /&gt;
|time&lt;br /&gt;
|Integer&lt;br /&gt;
|The marker&#039;s time (quarter notes, must be a whole number)&lt;br /&gt;
|Never&lt;br /&gt;
|-&lt;br /&gt;
|setting&lt;br /&gt;
|Integer&lt;br /&gt;
|The setting (one of the kMarkerSetting... constants, eg kMarkerSettingBpm)&lt;br /&gt;
|Never&lt;br /&gt;
|-&lt;br /&gt;
|value&lt;br /&gt;
|Dynamic&lt;br /&gt;
|The marker value. Its type depends on the marker setting.&lt;br /&gt;
|Always&lt;br /&gt;
|-&lt;br /&gt;
|blend&lt;br /&gt;
|Boolean&lt;br /&gt;
|Whether or not the marker is blended.&lt;br /&gt;
|Always&lt;br /&gt;
|}&lt;br /&gt;
With these limitations, the most useful thing you can do is set the marker value to a value outside the normal range (like we did for the instrument settings above). This snippet sets all the selected detune markers to detune up by 2 octaves:&lt;br /&gt;
 for (const marker of selection.markers) {&lt;br /&gt;
   if (marker.setting == kMarkerSettingInstrumentDetune) {&lt;br /&gt;
     marker.value = 2400;&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
If you really need to change the instrument, time, or setting, delete the marker and create a new one (see below for details).&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;quot;song.getAllMarkersAtTime(t)&amp;quot; to get a list of all the markers at a specific time, but selecting them in the UI and then iterating over &amp;quot;selection.markers&amp;quot; is easier.&lt;br /&gt;
&lt;br /&gt;
=== Creating notes ===&lt;br /&gt;
You can create Note objects using &amp;quot;new Note&amp;quot;, but you also have to manually add them to the song, like so:&lt;br /&gt;
 song.addNote(new Note(song, type, time, length, instrument, volume))&lt;br /&gt;
For example, let&#039;s generate a random melody:&lt;br /&gt;
 for (let i = 0; i &amp;lt; 16; ++i) {&lt;br /&gt;
   song.addNote(new Note(song, &#039;CDEFGAB&#039;[Math.floor(Math.random() * 7)] + &#039;4&#039;, i, 1, instrument, 1));&lt;br /&gt;
 }&lt;br /&gt;
Whenever you make changes to the notes of a sequence (adding, removing, moving, etc), the changes won&#039;t be visible until the sequencer view is updated. You can either run &amp;quot;SequencerView.repaint()&amp;quot;, or just move the view a bit (eg scroll). tweakNotes handles this for you, but in this example, you need to do it manually.&lt;br /&gt;
&lt;br /&gt;
Adding notes like this doesn&#039;t have undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Deleting notes ===&lt;br /&gt;
If you have a Note object, you can remove it from the sequence like this:&lt;br /&gt;
 song.removeNote(note)&lt;br /&gt;
This doesn&#039;t actually delete the Note object, just removes it from the sequence. In fact you can add it again if you want, using &amp;quot;song.addNote(note)&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s take another look at our earlier example, where we wanted to delete the thumbnail notes. Instead of using selectNotesIf and then manually deleting them, we could automatically delete them.&lt;br /&gt;
 for (const note of song.notes) {&lt;br /&gt;
   if (note.volume == 0) {&lt;br /&gt;
     song.removeNote(note);&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
Removing notes like this doesn&#039;t have undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Creating markers ===&lt;br /&gt;
 addMarker(time, setting, instrument, value, blend)&lt;br /&gt;
This function adds a marker to the song. The parameters are the same as in the marker field table above. Returns the newly created Marker object. Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Deleting markers ===&lt;br /&gt;
 removeMarker(marker)&lt;br /&gt;
Removes the marker from the sequence. Includes undo/redo support.&lt;br /&gt;
[[category:Online Sequencer UI]]&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=Equalizer&amp;diff=661</id>
		<title>Equalizer</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=Equalizer&amp;diff=661"/>
		<updated>2023-04-29T08:43:05Z</updated>

		<summary type="html">&lt;p&gt;Liam: Expanded the EQ page a bit&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[file:Equalizer_OS.png|300px|right|thumb|The high, mid, and low equalizers seen on OS]] An &#039;&#039;&#039;equalizer&#039;&#039;&#039; (commonly and simply known as &#039;&#039;&#039;EQ&#039;&#039;&#039;) is a device that allows the user to adjust the level of specific frequency ranges within an audio signal. It typically consists of frequency bands, with controls that allow the user to boost or cut the level of each band. On OS, the EQ that&#039;s used is known as a graphic EQ. This EQ has 3 bands. The low-frequency band is responsible for adjusting the bass frequencies, the mid-frequency band adjusts the midrange, and the high-frequency band adjusts the treble. Using an EQ, it is possible to shape the tonal characteristics of an audio signal by boosting or cutting specific frequency ranges. This can be useful for a variety of purposes, including making sure each instrument can be heard clearly, correcting for imbalances in the frequency response of a system, or sculpting the tone of an instrument or vocal to produce interesting effects.&lt;br /&gt;
[[File:Eq enabled.png|thumb|The EQ has been enabled, and the bass has been boosted.]] &lt;br /&gt;
&lt;br /&gt;
On OS, the EQ can be found in the advanced instrument settings. To change the EQ, first click the &amp;quot;Equalizer&amp;quot; button on the left, to enable EQ for this instrument. Then drag your chosen frequency band slider to the right to boost it, or to the left to suppress it. The EQ sliders are measured in decibels, which means that increasing the slider by a certain amount &#039;&#039;multiplies&#039;&#039; the loudness of that frequency band. In other words, the response of these sliders is &#039;&#039;exponential&#039;&#039;, not linear. So use caution when increasing the sliders, and try to stay out of the red zones, to avoid hurting your ears.&lt;br /&gt;
[[category:Online Sequencer UI]]&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=File:Eq_enabled.png&amp;diff=660</id>
		<title>File:Eq enabled.png</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=File:Eq_enabled.png&amp;diff=660"/>
		<updated>2023-04-29T08:36:33Z</updated>

		<summary type="html">&lt;p&gt;Liam: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The EQ has been enabled, and the bass has been boosted.&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=Detune&amp;diff=659</id>
		<title>Detune</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=Detune&amp;diff=659"/>
		<updated>2023-04-29T08:27:04Z</updated>

		<summary type="html">&lt;p&gt;Liam: Expanded the detune page a bit&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Detune slider.png|thumb|The detune slider in advanced instrument settings.]]&lt;br /&gt;
&#039;&#039;&#039;Detune&#039;&#039;&#039; is one of the instrument options in Online Sequencer, which can change the speed at which a sound is played, changing the pitch. It functions exactly like speeding up and slowing down a record or tape, in which the speed can not be altered without also altering the pitch. Detune is usually used to extend the range of an instrument, change its timbre, shorten or lengthen the sustain time, or used it in combination with [[markers]] to create vibratos or slides.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Detune is measured in &amp;quot;cents&amp;quot;. One semitone is 100 cents, one octave is 1200 cents. By default, the detune slider goes up or down by 100 cents at a time. To detune more precisely (microtones) hold Shift while clicking on the slider (you have to release your mouse click before you release shift). The detune slider goes from -1200 to 1200 cents. For more extreme (or preceise) detunes, you can use [[Console Commands#Detune|console commands]].&lt;br /&gt;
[[category:Online Sequencer UI]]&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=File:Detune_slider.png&amp;diff=658</id>
		<title>File:Detune slider.png</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=File:Detune_slider.png&amp;diff=658"/>
		<updated>2023-04-29T08:10:26Z</updated>

		<summary type="html">&lt;p&gt;Liam: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The detune slider in advanced instrument settings.&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=Cloning&amp;diff=657</id>
		<title>Cloning</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=Cloning&amp;diff=657"/>
		<updated>2023-04-28T22:30:21Z</updated>

		<summary type="html">&lt;p&gt;Liam: Expanded the cloning page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Cloning&#039;&#039;&#039; is a feature on OS that lets users create copies of existing instruments. The clones use the same instrument samples as the base instrument, but changing the settings of the clone doesn&#039;t affect the base instrument. There&#039;s no limit to the number of clones that can be created, however for certain instruments (particularly 8-bit sine, square, triangle, and saw) too many clones can be expensive and make the sequence lag. This feature became first available on the test website on April 23, 2023, and was pushed to the main site on April 28, after many requests since the early 2020s.&lt;br /&gt;
&lt;br /&gt;
[[File:Cloning buttons.png|thumb|The clone and delete buttons in advanced instrument settings.]]&lt;br /&gt;
To clone an instrument, click the Clone button in advanced instrument settings. To delete a clone, click the Delete button.&lt;br /&gt;
&lt;br /&gt;
=== Uses ===&lt;br /&gt;
Cloning is one of the most versatile and powerful features on OS, though it doesn&#039;t seem that way at first. Here are a few things they can be used for:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Chorus effects:&#039;&#039;&#039; By playing the same melody on 2 copies of the instrument, but detuning one of them by 5-10 cents.&lt;br /&gt;
* &#039;&#039;&#039;Stereo effects:&#039;&#039;&#039; By cloning an instrument and panning it differently you can make the stereo sound wider, especially if you delay the clone&#039;s notes slightly.&lt;br /&gt;
* &#039;&#039;&#039;Note panning:&#039;&#039;&#039; You can pan individual notes more precisely than is possible with markers.&lt;br /&gt;
* &#039;&#039;&#039;Note detune:&#039;&#039;&#039; By moving some notes to a different clone, and detuning that clone with markers, you can pitch bend specific notes without affecting the rest of the instrument.&lt;br /&gt;
* &#039;&#039;&#039;Better delay:&#039;&#039;&#039; If you want a custom delay effect, you have to copy the entire instrument&#039;s notes and paste them with an offset. Without clones this makes a mess. With clones you can keep them organised. Additionally, you can give the clones different settings, such as making the delayed notes muffled with EQ.&lt;br /&gt;
* &#039;&#039;&#039;Precise drum mixing:&#039;&#039;&#039; For best drum mastering results, it&#039;s sometimes necessary to EQ some of the drum stems differently. For example, bass boosting the kick drum, while also treble boosting the hihat. By moving some stems to a clone, the clones can be EQ&#039;d separately.&lt;br /&gt;
* &#039;&#039;&#039;Extending instrument ranges:&#039;&#039;&#039; Without cloning you can detune an instrument up or down an octave to change the range of notes you have access too. With cloning you can also detune a clone down by an octave to access lower notes too.&lt;br /&gt;
* &#039;&#039;&#039;Reducing marker usage:&#039;&#039;&#039; Often markers are used to change instrument settings between sections. This could be done using clones instead, which reduces the number of markers, and is much easier to do. Markers only really need to be used for smooth (blended) settings changes.&lt;br /&gt;
* &#039;&#039;&#039;Organisation:&#039;&#039;&#039; Clones can be useful just to organize your sequence. For example, you can lock specific sections by moving sections to clones.&lt;br /&gt;
* &#039;&#039;&#039;Microtonal FFT:&#039;&#039;&#039; https://onlinesequencer.net/3365882&lt;br /&gt;
&lt;br /&gt;
[[category:Online Sequencer UI]]&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=File:Cloning_buttons.png&amp;diff=656</id>
		<title>File:Cloning buttons.png</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=File:Cloning_buttons.png&amp;diff=656"/>
		<updated>2023-04-28T22:05:44Z</updated>

		<summary type="html">&lt;p&gt;Liam: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The clone and delete buttons in advanced instrument settings&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=Vocal_synthesis_using_sine&amp;diff=626</id>
		<title>Vocal synthesis using sine</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=Vocal_synthesis_using_sine&amp;diff=626"/>
		<updated>2023-04-14T02:51:34Z</updated>

		<summary type="html">&lt;p&gt;Liam: Add a section about my new FFT tool&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;One of the key limitations of Online Sequencer is the inability to include audio from any outside source.  One way to get around this is by using a script which reconstructs any sound using 8 Bit Sine.  The results often have enough fidelity to discern lyrics, or the timbre of an instrument, depending on which FFT algorithm is used.  This method creates lots of notes, and requires a fast computer to both create and play back these sequences. Simpler sounds work best, like someone talking, or a clear sound effect.  More complex and busy sounds like a whole song, with many parts and layers, usually don&#039;t work as well, but can still produce usable results.&lt;br /&gt;
&lt;br /&gt;
== Liam&#039;s FFT ==&lt;br /&gt;
The easiest way to do FFT is using [https://tiusic.com/os_fft/deploy/index.html Liam&#039;s FFT tool]. Just upload a WAV file, choose a preset mode, and click GO. Then you can either copy the notes and paste them into a sequence, or download the sequence file and drag/drop it into OS. There are lots of advanced options to play with to optimize the output. This tool is based on the older fft.py script, which is now deprecated.&lt;br /&gt;
&lt;br /&gt;
== Jacob&#039;s FFT ==&lt;br /&gt;
Below is a script that can be used by copying and pasting it into the console on the sequencer.  Press F12 to access the console, then click in the box.  Once you see a blinking cursor, paste the script in.  It will ask you to upload an audio file.  MP3, WAV, and OGG are accepted.  This script should function the same regardless of the level of the signal in your file, and with mono and stereo files (final output will be mono).  It will generate 8 Bit Sine notes corresponding to the frequencies present in your file, with time resolution being equal to 1/16 grid at whatever tempo you have set.  Less notes will be placed if a slower tempo is used, but time resolution will suffer.  For most purposes, 110 BPM is fine, but it can be helpful to match the sequences BPM with that of the file you intend to upload (only if you are uploading a song) or to not change the BPM at all if you are incorporating this into an existing sequence.&lt;br /&gt;
&lt;br /&gt;
[https://docs.google.com/document/d/1zGu4K8rJ6Uo0TCnnGYUzbV96ogTLS3pwL1sZhYT3jKc/edit?usp=sharing &amp;lt;u&amp;gt;&amp;lt;nowiki&amp;gt;[Jacob&#039;s FFT Converter]&amp;lt;/nowiki&amp;gt;&amp;lt;/u&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
=== Restoring High Frequency Sounds ===&lt;br /&gt;
Using this algorithm bounds you to the frequencies accessible by the 8 bit sine, which will often result in high frequencies getting cut off, making things sound muffled and certain syllables will be difficult to hear.  It is possible to get around this limitation and more accurately reproduce high frequency sounds in the sequencer.  In order to do this, you must first follow the instructions in the paragraph above as normal, except you should use a BPM that is a multiple of 4.  After that, select all of the notes and change them to 8 Bit Triangle.  Open the console and run this command: setDetune(13,2400) .  This makes all 8 Bit Sine notes sound 2 octaves higher than they are.  Next, open your sound file in an audio editor such as audacity.  Slow down the sound to 25% of its original speed, and make sure you do not have any setting enabled which preserves the pitch of the sound.  In audacity, this can be done by clicking the drop down menu next to the audio track, and changing the &amp;quot;rate&amp;quot; to a quarter of itself.  The purpose of this is to bring high frequency data down into the range which can be detected by the FFT Converter.  Return to the sequencer and set the sequence&#039;s tempo to a quarter of itself.  Run Jacob&#039;s FFT Converter in the console as before, this time importing the slowed down version of the audio.  Once it is finished, change the tempo back to normal.  You should have the original conversion in 8 Bit Triangle, and a different with more high frequencies in 8 bit sine.  They should completely overlap and sync up, creating a clearer sound.  Volume and EQ of the Sine and Triangle should be adjusted to your taste.&lt;br /&gt;
[[Category:User experience]]&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=Console_Commands&amp;diff=601</id>
		<title>Console Commands</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=Console_Commands&amp;diff=601"/>
		<updated>2023-03-05T20:13:57Z</updated>

		<summary type="html">&lt;p&gt;Liam: Added a couple of images, and a tip about silence log spam&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Chrome console.png|alt=The Chrome developer console|thumb|The Chrome developer console]]&lt;br /&gt;
&#039;&#039;&#039;Console Commands&#039;&#039;&#039; 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. &lt;br /&gt;
&lt;br /&gt;
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].&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to keep a few things in mind when using the console:&lt;br /&gt;
&lt;br /&gt;
* Not all of the commands below have undo/redo support. So if you make a change it might not be possible to undo it.&lt;br /&gt;
* It&#039;s possible to corrupt your sequence using the console. So if you&#039;re new to this it&#039;s highly recommended that you save your sequence before messing with the console.&lt;br /&gt;
&lt;br /&gt;
* 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.&lt;br /&gt;
* Instruments are identified using a number, also known as the ID. The current instrument is stored in the global variable &amp;quot;instrument&amp;quot;. So to figure out the number for an instrument, just choose that instrument in the UI, type &amp;quot;instrument&amp;quot;, and press enter. You can also just pass &amp;quot;instrument&amp;quot; directly to use the current instrument, eg &amp;quot;setDetune(instrument, 1200)&amp;quot;.&lt;br /&gt;
* 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 &amp;quot;Selected context only&amp;quot; in the console settings (see image). This works in Chrome, but there will be similar filters in any browser.&lt;br /&gt;
[[File:Silencing log spam.png|alt=Silencing log spam|thumb|241x241px|To silence log spam, click the console settings button, then enable &amp;quot;Selected context only&amp;quot;.]]&lt;br /&gt;
&lt;br /&gt;
== Basic techniques ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Grid ===&lt;br /&gt;
 setGrid(value)&lt;br /&gt;
Changes the size of the grid. The way the value works is a bit confusing: it&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== Time signature ===&lt;br /&gt;
 setTimeSig(timeSig)&lt;br /&gt;
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 &amp;quot;setTimeSig(7)&amp;quot;. If you want something more exotic, you&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== Detune ===&lt;br /&gt;
 setDetune(instrument, detune)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; Firefox does not support detunes outside -1200 to 1200, so using extreme values will mean your sequence will only play correctly on Chromium browsers.&lt;br /&gt;
&lt;br /&gt;
=== Reverb and distortion ===&lt;br /&gt;
 setReverbVolume(instrument, volume)&lt;br /&gt;
 setDistortVolume(instrument, volume)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Equalizer ===&lt;br /&gt;
 setEqHigh(instrument, value)&lt;br /&gt;
 setEqMid(instrument, value)&lt;br /&gt;
 setEqLow(instrument, value)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Panning ===&lt;br /&gt;
 setPan(instrument, value)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Intermediate techniques ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
In JS, function parameters can have [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters default values]. This means if you don&#039;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&#039;re written in the documentation like this: &amp;quot;fadeNotes(fadeIn = false)&amp;quot;. This means the &amp;quot;fadeIn&amp;quot; parameter defaults to false, so instead of writing &amp;quot;fadeNotes(false)&amp;quot; you can just write &amp;quot;fadeNotes()&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The functions in this section are defined [https://onlinesequencer.net/app/consoleCommands.js here]. If you know some JS, you can read this file to learn how they work and create your own.&lt;br /&gt;
&lt;br /&gt;
=== Fade notes ===&lt;br /&gt;
 fadeNotes(fadeIn = false)&lt;br /&gt;
 fadeNotes()      // Fade out&lt;br /&gt;
 fadeNotes(true)  // Fade in&lt;br /&gt;
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, &amp;quot;fadeIn&amp;quot; which defaults to false. In other words, it fades the notes from their original volume to 0 by default, or if you pass &amp;quot;true&amp;quot; it fades in the segment from 0 volume to the original volume.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Stretch notes ===&lt;br /&gt;
 stretchNotes(factor)&lt;br /&gt;
Stretches or squishes the selected segment by the given factor. A factor of 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.&lt;br /&gt;
&lt;br /&gt;
It also works on selected markers, but since marker times are quantized to whole number time steps, 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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Truncate notes ===&lt;br /&gt;
 truncateNotesAt(time)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Convert to detune markers ===&lt;br /&gt;
 convertToDetuneMarkers(startNote = &#039;C5&#039;)&lt;br /&gt;
Moves all the selected notes to the &amp;quot;startNote&amp;quot;, then creates detune markers to detune each note back to its original pitch. For example, if you select a &amp;quot;D5&amp;quot; and then run this with the default startNote, it will move the note to &amp;quot;C5&amp;quot; and create a detune marker to detune it up 200 cents back to &amp;quot;D5&amp;quot;. This is useful for making clear melodies on instruments that get muddy when there are a lot of notes.&lt;br /&gt;
&lt;br /&gt;
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&#039;s only ever one note at a particular time. This function ignores drum kit instruments.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Humanize ===&lt;br /&gt;
 humanize(volumeVariation = 0.2, timeVariation = 0.1)&lt;br /&gt;
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 &amp;quot;humanize()&amp;quot; to use the defaults.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
Note that if you use this function on a note that touches the end of of the last measure of your sequence, there&#039;s a 50/50 chance it will be moved to the right (past the end of the sequence) causing your sequence to loop one measure late. You can fix this by manually changing the length of the note to snap it back to the end of that final measure.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Remix notes ===&lt;br /&gt;
 remixNotes(chunkSize = 4, avgChunksPerUnmixedSection = 2, avgChunksPerMixedSection = 2, avgMixedSectionsPerUnmixedSection = 1)&lt;br /&gt;
Divides the selected segment into chunks and mix 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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Reset all instrument settings ===&lt;br /&gt;
 resetAllInstrumentSettings()&lt;br /&gt;
Resets the settings of all the instruments in the sequence.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; No undo/redo support.&lt;br /&gt;
 removeAllMarkers()&lt;br /&gt;
Deletes all the markers in the sequence.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; No undo/redo support.&lt;br /&gt;
&lt;br /&gt;
== Advanced techniques ==&lt;br /&gt;
You will need to know some JS to use these functions. In particular, we&#039;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].&lt;br /&gt;
&lt;br /&gt;
=== Working with the selection ===&lt;br /&gt;
Most of the functions in the previous section work on the selected notes and markers. The notes and markers selected in the UI are stored in the &amp;quot;selection&amp;quot; object.&lt;br /&gt;
 console.log(selection.notes)&lt;br /&gt;
 console.log(selection.markers)&lt;br /&gt;
 console.log(selection.getTimeSpan())&lt;br /&gt;
You can find all the methods on the selection object [https://onlinesequencer.net/app/selection.js here]. It&#039;s sometimes useful to be able to loop over all the notes or markers in the selection, but if you want to modify the notes in the selection, use tweakNotes below.&lt;br /&gt;
 for (const note of selection.notes) {&lt;br /&gt;
   console.log(note);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 for (const marker of selection.marker) {&lt;br /&gt;
   console.log(marker);&lt;br /&gt;
 }&lt;br /&gt;
You can also add or remove markers and notes from the selection using the selectNote, selectMarker, deselectNote, and deselectMarker methods. However, it&#039;s usually easier to use these functions:&lt;br /&gt;
 selectNotesIf(predicate, addToSelection = false)&lt;br /&gt;
 selectMarkersIf(predicate, addToSelection = false)&lt;br /&gt;
These functions take a predicate (a function that returns true or false) and select all the notes or markers for which the predicate returns true. If addToSelection is true, these notes or markers are added to the existing selection, otherwise, they replace the current selection. Both these functions include undo/redo support.&lt;br /&gt;
&lt;br /&gt;
For example, say you wanted to delete the [https://tiusic.com/thumb.html thumbnail] notes from a sequence, so you can change the thumbnail. Thumbnail notes all have 0 volume, so you can just select all the notes with 0 volume:&lt;br /&gt;
 selectNotesIf(n =&amp;gt; n.volume == 0)&lt;br /&gt;
This selects all the thumbnail notes, so now you can delete them as normal (though the UI focus will still be on the console, so you&#039;ll have to click on the sequencer before you press delete).&lt;br /&gt;
&lt;br /&gt;
=== Tweaking notes ===&lt;br /&gt;
 tweakNotes(tweakFunction)&lt;br /&gt;
This is probably the single most useful console function. It basically runs tweakFunction on every selected note and has undo/redo support for any changes that tweakFunction makes to the note. It&#039;s roughly equivalent to:&lt;br /&gt;
 for (const note of selection.notes) {&lt;br /&gt;
   tweakFunction(note);&lt;br /&gt;
 }&lt;br /&gt;
There are a few problems with doing a for loop like this and manually tweaking the notes. For starters, you won&#039;t get undo/redo support, but the bigger problem is that there are a few optimizations that OS does based on the note time, instrument, length, or pitch that require extra work if you modify those parameters (namely &amp;quot;song.moveNote()&amp;quot; and &amp;quot;song.updateLoopTime()&amp;quot;). Failure to do so could corrupt your sequence. tweakNotes takes care of this work for you so you don&#039;t have to worry about it.&lt;br /&gt;
&lt;br /&gt;
The fields of the note object that you can modify are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+The fields of the Note object&lt;br /&gt;
!Name&lt;br /&gt;
!Type&lt;br /&gt;
!Description&lt;br /&gt;
!Can modify?&lt;br /&gt;
|-&lt;br /&gt;
|instrument&lt;br /&gt;
|Integer&lt;br /&gt;
|The instrument id, eg 22 for sitar&lt;br /&gt;
|Only with tweakNotes&lt;br /&gt;
|-&lt;br /&gt;
|type&lt;br /&gt;
|String&lt;br /&gt;
|The pitch or keyboard note, eg &#039;C5&#039; or &#039;F#7&#039;&lt;br /&gt;
|Only with tweakNotes&lt;br /&gt;
|-&lt;br /&gt;
|time&lt;br /&gt;
|Number&lt;br /&gt;
|The time when the note starts in standard time units (quarter notes)&lt;br /&gt;
|Only with tweakNotes&lt;br /&gt;
|-&lt;br /&gt;
|length&lt;br /&gt;
|Number&lt;br /&gt;
|The length of the note in standard time units&lt;br /&gt;
|Only with tweakNotes&lt;br /&gt;
|-&lt;br /&gt;
|volume&lt;br /&gt;
|Number&lt;br /&gt;
|The volume of the note, usually from 0 to 1.&lt;br /&gt;
|Always&lt;br /&gt;
|}&lt;br /&gt;
If you console.log the note you&#039;ll see other internal fields, but &#039;&#039;&#039;DO NOT MODIFY THESE&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
For example, you can halve the volume like this (eg for a custom delay effect, copy, shift, then tweak the volume):&lt;br /&gt;
 tweakNotes(n =&amp;gt; n.volume *= 0.5)&lt;br /&gt;
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):&lt;br /&gt;
 function humanize(volumeVariation = 0.2, timeVariation = 0.1) {&lt;br /&gt;
   tweakNotes(n =&amp;gt; {&lt;br /&gt;
     n.volume *= 1 + volumeVariation * (2 * Math.random() - 1);&lt;br /&gt;
     n.time += timeVariation * (2 * Math.random() - 1);&lt;br /&gt;
     if (n.time &amp;lt; 0) n.time = 0;&lt;br /&gt;
   });&lt;br /&gt;
 }&lt;br /&gt;
Tweak notes can also be used to generate the lengthening sawtooth effect from [https://onlinesequencer.net/1905746 Ganymede]:&lt;br /&gt;
 const span = selection.getTimeSpan();&lt;br /&gt;
 tweakNotes(n =&amp;gt; {&lt;br /&gt;
   n.length *= 0.5 + (n.time - span.min) / (span.max - span.min);&lt;br /&gt;
 });&lt;br /&gt;
A more complicated example is adding swing to your selected notes:&lt;br /&gt;
 tweakNotes(n =&amp;gt; {&lt;br /&gt;
   const t = n.time / 4;&lt;br /&gt;
   const intTime = Math.floor(t);&lt;br /&gt;
   const fracTime = t - intTime;&lt;br /&gt;
   const newFracTime = fracTime &amp;lt;= 0.5 ? fracTime * 4 / 3 : (fracTime - 0.5) * 3 / 4 + 2 / 3;&lt;br /&gt;
   n.time = (intTime + newFracTime) * 4;&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Tweaking markers ===&lt;br /&gt;
There is currently no marker equivalent of tweakNotes. Markers also have optimizations that mean you can&#039;t modify the time, instrument, or setting, without doing extra work. The only things you can safely modify are the value and the blend. If you need to modify the other parameters, you&#039;re better off asking the devs to add a tweakMarkers function, rather than trying to modify them and corrupting your sequence.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+The fields of the Marker object&lt;br /&gt;
!Name&lt;br /&gt;
!Type&lt;br /&gt;
!Description&lt;br /&gt;
!Can modify?&lt;br /&gt;
|-&lt;br /&gt;
|instrument&lt;br /&gt;
|Integer&lt;br /&gt;
|The instrument id, eg 19 for xylophone&lt;br /&gt;
|Never&lt;br /&gt;
|-&lt;br /&gt;
|time&lt;br /&gt;
|Integer&lt;br /&gt;
|The marker&#039;s time (quarter notes, must be a whole number)&lt;br /&gt;
|Never&lt;br /&gt;
|-&lt;br /&gt;
|setting&lt;br /&gt;
|Integer&lt;br /&gt;
|The setting (one of the kMarkerSetting... constants, eg kMarkerSettingBpm)&lt;br /&gt;
|Never&lt;br /&gt;
|-&lt;br /&gt;
|value&lt;br /&gt;
|Dynamic&lt;br /&gt;
|The marker value. Its type depends on the marker setting.&lt;br /&gt;
|Always&lt;br /&gt;
|-&lt;br /&gt;
|blend&lt;br /&gt;
|Boolean&lt;br /&gt;
|Whether or not the marker is blended.&lt;br /&gt;
|Always&lt;br /&gt;
|}&lt;br /&gt;
With these limitations, the most useful thing you can do is set the marker value to a value outside the normal range (like we did for the instrument settings above). This snippet sets all the selected detune markers to detune up by 2 octaves:&lt;br /&gt;
 for (const marker of selection.markers) {&lt;br /&gt;
   if (marker.setting == kMarkerSettingInstrumentDetune) {&lt;br /&gt;
     marker.value = 2400;&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
If you really need to change the instrument, time, or setting, delete the marker and create a new one (see below for details).&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;quot;song.getAllMarkersAtTime(t)&amp;quot; to get a list of all the markers at a specific time, but selecting them in the UI and then iterating over &amp;quot;selection.markers&amp;quot; is easier.&lt;br /&gt;
&lt;br /&gt;
=== Creating notes ===&lt;br /&gt;
You can create Note objects using &amp;quot;new Note&amp;quot;, but you also have to manually add them to the song, like so:&lt;br /&gt;
 song.addNote(new Note(song, type, time, length, instrument, volume))&lt;br /&gt;
For example, let&#039;s generate a random melody:&lt;br /&gt;
 for (let i = 0; i &amp;lt; 16; ++i) {&lt;br /&gt;
   song.addNote(new Note(song, &#039;CDEFGAB&#039;[Math.floor(Math.random() * 7)] + &#039;4&#039;, i, 1, instrument, 1));&lt;br /&gt;
 }&lt;br /&gt;
Whenever you make changes to the notes of a sequence (adding, removing, moving, etc), the changes won&#039;t be visible until the sequencer view is updated. You can either run &amp;quot;SequencerView.repaint()&amp;quot;, or just move the view a bit (eg scroll). tweakNotes handles this for you, but in this example, you need to do it manually.&lt;br /&gt;
&lt;br /&gt;
Adding notes like this doesn&#039;t have undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Deleting notes ===&lt;br /&gt;
If you have a Note object, you can remove it from the sequence like this:&lt;br /&gt;
 song.removeNote(note)&lt;br /&gt;
This doesn&#039;t actually delete the Note object, just removes it from the sequence. In fact you can add it again if you want, using &amp;quot;song.addNote(note)&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s take another look at our earlier example, where we wanted to delete the thumbnail notes. Instead of using selectNotesIf and then manually deleting them, we could automatically delete them.&lt;br /&gt;
 for (const note of song.notes) {&lt;br /&gt;
   if (note.volume == 0) {&lt;br /&gt;
     song.removeNote(note);&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
Removing notes like this doesn&#039;t have undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Creating markers ===&lt;br /&gt;
 addMarker(time, setting, instrument, value, blend)&lt;br /&gt;
This function adds a marker to the song. The parameters are the same as in the marker field table above. Returns the newly created Marker object. Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Deleting markers ===&lt;br /&gt;
 removeMarker(marker)&lt;br /&gt;
Removes the marker from the sequence. Includes undo/redo support.&lt;br /&gt;
[[category:Online Sequencer UI]]&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=File:Chrome_console.png&amp;diff=600</id>
		<title>File:Chrome console.png</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=File:Chrome_console.png&amp;diff=600"/>
		<updated>2023-03-05T20:09:33Z</updated>

		<summary type="html">&lt;p&gt;Liam: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Chrome developer console&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=File:Silencing_log_spam.png&amp;diff=598</id>
		<title>File:Silencing log spam.png</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=File:Silencing_log_spam.png&amp;diff=598"/>
		<updated>2023-03-05T19:58:01Z</updated>

		<summary type="html">&lt;p&gt;Liam: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To silence log spam, click the console settings button, then enable &amp;quot;Selected context only&amp;quot;.&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=Console_Commands&amp;diff=583</id>
		<title>Console Commands</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=Console_Commands&amp;diff=583"/>
		<updated>2023-01-31T04:07:46Z</updated>

		<summary type="html">&lt;p&gt;Liam: Added a small note to humanize, and reverted a few grammar changes (all the other grammar changes were good, thanks Crum).&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Console Commands&#039;&#039;&#039; 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.&lt;br /&gt;
&lt;br /&gt;
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].&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to keep a few things in mind when using the console:&lt;br /&gt;
&lt;br /&gt;
* Not all of the commands below have undo/redo support. So if you make a change it might not be possible to undo it.&lt;br /&gt;
* It&#039;s possible to corrupt your sequence using the console. So if you&#039;re new to this it&#039;s highly recommended that you save your sequence before messing with the console.&lt;br /&gt;
&lt;br /&gt;
* 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.&lt;br /&gt;
* Instruments are identified using a number, also known as the ID. The current instrument is stored in the global variable &amp;quot;instrument&amp;quot;. So to figure out the number for an instrument, just choose that instrument in the UI, type &amp;quot;instrument&amp;quot;, and press enter. You can also just pass &amp;quot;instrument&amp;quot; directly to use the current instrument, eg &amp;quot;setDetune(instrument, 1200)&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Basic techniques ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Grid ===&lt;br /&gt;
 setGrid(value)&lt;br /&gt;
Changes the size of the grid. The way the value works is a bit confusing: it&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== Time signature ===&lt;br /&gt;
 setTimeSig(timeSig)&lt;br /&gt;
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 &amp;quot;setTimeSig(7)&amp;quot;. If you want something more exotic, you&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== Detune ===&lt;br /&gt;
 setDetune(instrument, detune)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; Firefox does not support detunes outside -1200 to 1200, so using extreme values will mean your sequence will only play correctly on Chromium browsers.&lt;br /&gt;
&lt;br /&gt;
=== Reverb and distortion ===&lt;br /&gt;
 setReverbVolume(instrument, volume)&lt;br /&gt;
 setDistortVolume(instrument, volume)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Equalizer ===&lt;br /&gt;
 setEqHigh(instrument, value)&lt;br /&gt;
 setEqMid(instrument, value)&lt;br /&gt;
 setEqLow(instrument, value)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Panning ===&lt;br /&gt;
 setPan(instrument, value)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Intermediate techniques ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
In JS, function parameters can have [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters default values]. This means if you don&#039;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&#039;re written in the documentation like this: &amp;quot;fadeNotes(fadeIn = false)&amp;quot;. This means the &amp;quot;fadeIn&amp;quot; parameter defaults to false, so instead of writing &amp;quot;fadeNotes(false)&amp;quot; you can just write &amp;quot;fadeNotes()&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The functions in this section are defined [https://onlinesequencer.net/app/consoleCommands.js here]. If you know some JS, you can read this file to learn how they work and create your own.&lt;br /&gt;
&lt;br /&gt;
=== Fade notes ===&lt;br /&gt;
 fadeNotes(fadeIn = false)&lt;br /&gt;
 fadeNotes()      // Fade out&lt;br /&gt;
 fadeNotes(true)  // Fade in&lt;br /&gt;
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, &amp;quot;fadeIn&amp;quot; which defaults to false. In other words, it fades the notes from their original volume to 0 by default, or if you pass &amp;quot;true&amp;quot; it fades in the segment from 0 volume to the original volume.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Stretch notes ===&lt;br /&gt;
 stretchNotes(factor)&lt;br /&gt;
Stretches or squishes the selected segment by the given factor. A factor of 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.&lt;br /&gt;
&lt;br /&gt;
It also works on selected markers, but since marker times are quantized to whole number time steps, 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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Truncate notes ===&lt;br /&gt;
 truncateNotesAt(time)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Convert to detune markers ===&lt;br /&gt;
 convertToDetuneMarkers(startNote = &#039;C5&#039;)&lt;br /&gt;
Moves all the selected notes to the &amp;quot;startNote&amp;quot;, then creates detune markers to detune each note back to its original pitch. For example, if you select a &amp;quot;D5&amp;quot; and then run this with the default startNote, it will move the note to &amp;quot;C5&amp;quot; and create a detune marker to detune it up 200 cents back to &amp;quot;D5&amp;quot;. This is useful for making clear melodies on instruments that get muddy when there are a lot of notes.&lt;br /&gt;
&lt;br /&gt;
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&#039;s only ever one note at a particular time. This function ignores drum kit instruments.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Humanize ===&lt;br /&gt;
 humanize(volumeVariation = 0.2, timeVariation = 0.1)&lt;br /&gt;
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 &amp;quot;humanize()&amp;quot; to use the defaults.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
Note that if you use this function on a note that touches the end of of the last measure of your sequence, there&#039;s a 50/50 chance it will be moved to the right (past the end of the sequence) causing your sequence to loop one measure late. You can fix this by manually changing the length of the note to snap it back to the end of that final measure.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Remix notes ===&lt;br /&gt;
 remixNotes(chunkSize = 4, avgChunksPerUnmixedSection = 2, avgChunksPerMixedSection = 2, avgMixedSectionsPerUnmixedSection = 1)&lt;br /&gt;
Divides the selected segment into chunks and mix 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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Reset all instrument settings ===&lt;br /&gt;
 resetAllInstrumentSettings()&lt;br /&gt;
Resets the settings of all the instruments in the sequence.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; No undo/redo support.&lt;br /&gt;
 removeAllMarkers()&lt;br /&gt;
Deletes all the markers in the sequence.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; No undo/redo support.&lt;br /&gt;
&lt;br /&gt;
== Advanced techniques ==&lt;br /&gt;
You will need to know some JS to use these functions. In particular, we&#039;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].&lt;br /&gt;
&lt;br /&gt;
=== Working with the selection ===&lt;br /&gt;
Most of the functions in the previous section work on the selected notes and markers. The notes and markers selected in the UI are stored in the &amp;quot;selection&amp;quot; object.&lt;br /&gt;
 console.log(selection.notes)&lt;br /&gt;
 console.log(selection.markers)&lt;br /&gt;
 console.log(selection.getTimeSpan())&lt;br /&gt;
You can find all the methods on the selection object [https://onlinesequencer.net/app/selection.js here]. It&#039;s sometimes useful to be able to loop over all the notes or markers in the selection, but if you want to modify the notes in the selection, use tweakNotes below.&lt;br /&gt;
 for (const note of selection.notes) {&lt;br /&gt;
   console.log(note);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 for (const marker of selection.marker) {&lt;br /&gt;
   console.log(marker);&lt;br /&gt;
 }&lt;br /&gt;
You can also add or remove markers and notes from the selection using the selectNote, selectMarker, deselectNote, and deselectMarker methods. However, it&#039;s usually easier to use these functions:&lt;br /&gt;
 selectNotesIf(predicate, addToSelection = false)&lt;br /&gt;
 selectMarkersIf(predicate, addToSelection = false)&lt;br /&gt;
These functions take a predicate (a function that returns true or false) and select all the notes or markers for which the predicate returns true. If addToSelection is true, these notes or markers are added to the existing selection, otherwise, they replace the current selection. Both these functions include undo/redo support.&lt;br /&gt;
&lt;br /&gt;
For example, say you wanted to delete the [https://tiusic.com/thumb.html thumbnail] notes from a sequence, so you can change the thumbnail. Thumbnail notes all have 0 volume, so you can just select all the notes with 0 volume:&lt;br /&gt;
 selectNotesIf(n =&amp;gt; n.volume == 0)&lt;br /&gt;
This selects all the thumbnail notes, so now you can delete them as normal (though the UI focus will still be on the console, so you&#039;ll have to click on the sequencer before you press delete).&lt;br /&gt;
&lt;br /&gt;
=== Tweaking notes ===&lt;br /&gt;
 tweakNotes(tweakFunction)&lt;br /&gt;
This is probably the single most useful console function. It basically runs tweakFunction on every selected note and has undo/redo support for any changes that tweakFunction makes to the note. It&#039;s roughly equivalent to:&lt;br /&gt;
 for (const note of selection.notes) {&lt;br /&gt;
   tweakFunction(note);&lt;br /&gt;
 }&lt;br /&gt;
There are a few problems with doing a for loop like this and manually tweaking the notes. For starters, you won&#039;t get undo/redo support, but the bigger problem is that there are a few optimizations that OS does based on the note time, instrument, length, or pitch that require extra work if you modify those parameters (namely &amp;quot;song.moveNote()&amp;quot; and &amp;quot;song.updateLoopTime()&amp;quot;). Failure to do so could corrupt your sequence. tweakNotes takes care of this work for you so you don&#039;t have to worry about it.&lt;br /&gt;
&lt;br /&gt;
The fields of the note object that you can modify are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+The fields of the Note object&lt;br /&gt;
!Name&lt;br /&gt;
!Type&lt;br /&gt;
!Description&lt;br /&gt;
!Can modify?&lt;br /&gt;
|-&lt;br /&gt;
|instrument&lt;br /&gt;
|Integer&lt;br /&gt;
|The instrument id, eg 22 for sitar&lt;br /&gt;
|Only with tweakNotes&lt;br /&gt;
|-&lt;br /&gt;
|type&lt;br /&gt;
|String&lt;br /&gt;
|The pitch or keyboard note, eg &#039;C5&#039; or &#039;F#7&#039;&lt;br /&gt;
|Only with tweakNotes&lt;br /&gt;
|-&lt;br /&gt;
|time&lt;br /&gt;
|Number&lt;br /&gt;
|The time when the note starts in standard time units (quarter notes)&lt;br /&gt;
|Only with tweakNotes&lt;br /&gt;
|-&lt;br /&gt;
|length&lt;br /&gt;
|Number&lt;br /&gt;
|The length of the note in standard time units&lt;br /&gt;
|Only with tweakNotes&lt;br /&gt;
|-&lt;br /&gt;
|volume&lt;br /&gt;
|Number&lt;br /&gt;
|The volume of the note, usually from 0 to 1.&lt;br /&gt;
|Always&lt;br /&gt;
|}&lt;br /&gt;
If you console.log the note you&#039;ll see other internal fields, but &#039;&#039;&#039;DO NOT MODIFY THESE&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
For example, you can halve the volume like this (eg for a custom delay effect, copy, shift, then tweak the volume):&lt;br /&gt;
 tweakNotes(n =&amp;gt; n.volume *= 0.5)&lt;br /&gt;
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):&lt;br /&gt;
 function humanize(volumeVariation = 0.2, timeVariation = 0.1) {&lt;br /&gt;
   tweakNotes(n =&amp;gt; {&lt;br /&gt;
     n.volume *= 1 + volumeVariation * (2 * Math.random() - 1);&lt;br /&gt;
     n.time += timeVariation * (2 * Math.random() - 1);&lt;br /&gt;
     if (n.time &amp;lt; 0) n.time = 0;&lt;br /&gt;
   });&lt;br /&gt;
 }&lt;br /&gt;
Tweak notes can also be used to generate the lengthening sawtooth effect from [https://onlinesequencer.net/1905746 Ganymede]:&lt;br /&gt;
 const span = selection.getTimeSpan();&lt;br /&gt;
 tweakNotes(n =&amp;gt; {&lt;br /&gt;
   n.length *= 0.5 + (n.time - span.min) / (span.max - span.min);&lt;br /&gt;
 });&lt;br /&gt;
A more complicated example is adding swing to your selected notes:&lt;br /&gt;
 tweakNotes(n =&amp;gt; {&lt;br /&gt;
   const t = n.time / 4;&lt;br /&gt;
   const intTime = Math.floor(t);&lt;br /&gt;
   const fracTime = t - intTime;&lt;br /&gt;
   const newFracTime = fracTime &amp;lt;= 0.5 ? fracTime * 4 / 3 : (fracTime - 0.5) * 3 / 4 + 2 / 3;&lt;br /&gt;
   n.time = (intTime + newFracTime) * 4;&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Tweaking markers ===&lt;br /&gt;
There is currently no marker equivalent of tweakNotes. Markers also have optimizations that mean you can&#039;t modify the time, instrument, or setting, without doing extra work. The only things you can safely modify are the value and the blend. If you need to modify the other parameters, you&#039;re better off asking the devs to add a tweakMarkers function, rather than trying to modify them and corrupting your sequence.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+The fields of the Marker object&lt;br /&gt;
!Name&lt;br /&gt;
!Type&lt;br /&gt;
!Description&lt;br /&gt;
!Can modify?&lt;br /&gt;
|-&lt;br /&gt;
|instrument&lt;br /&gt;
|Integer&lt;br /&gt;
|The instrument id, eg 19 for xylophone&lt;br /&gt;
|Never&lt;br /&gt;
|-&lt;br /&gt;
|time&lt;br /&gt;
|Integer&lt;br /&gt;
|The marker&#039;s time (quarter notes, must be a whole number)&lt;br /&gt;
|Never&lt;br /&gt;
|-&lt;br /&gt;
|setting&lt;br /&gt;
|Integer&lt;br /&gt;
|The setting (one of the kMarkerSetting... constants, eg kMarkerSettingBpm)&lt;br /&gt;
|Never&lt;br /&gt;
|-&lt;br /&gt;
|value&lt;br /&gt;
|Dynamic&lt;br /&gt;
|The marker value. Its type depends on the marker setting.&lt;br /&gt;
|Always&lt;br /&gt;
|-&lt;br /&gt;
|blend&lt;br /&gt;
|Boolean&lt;br /&gt;
|Whether or not the marker is blended.&lt;br /&gt;
|Always&lt;br /&gt;
|}&lt;br /&gt;
With these limitations, the most useful thing you can do is set the marker value to a value outside the normal range (like we did for the instrument settings above). This snippet sets all the selected detune markers to detune up by 2 octaves:&lt;br /&gt;
 for (const marker of selection.markers) {&lt;br /&gt;
   if (marker.setting == kMarkerSettingInstrumentDetune) {&lt;br /&gt;
     marker.value = 2400;&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
If you really need to change the instrument, time, or setting, delete the marker and create a new one (see below for details).&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;quot;song.getAllMarkersAtTime(t)&amp;quot; to get a list of all the markers at a specific time, but selecting them in the UI and then iterating over &amp;quot;selection.markers&amp;quot; is easier.&lt;br /&gt;
&lt;br /&gt;
=== Creating notes ===&lt;br /&gt;
You can create Note objects using &amp;quot;new Note&amp;quot;, but you also have to manually add them to the song, like so:&lt;br /&gt;
 song.addNote(new Note(song, type, time, length, instrument, volume))&lt;br /&gt;
For example, let&#039;s generate a random melody:&lt;br /&gt;
 for (let i = 0; i &amp;lt; 16; ++i) {&lt;br /&gt;
   song.addNote(new Note(song, &#039;CDEFGAB&#039;[Math.floor(Math.random() * 7)] + &#039;4&#039;, i, 1, instrument, 1));&lt;br /&gt;
 }&lt;br /&gt;
Whenever you make changes to the notes of a sequence (adding, removing, moving, etc), the changes won&#039;t be visible until the sequencer view is updated. You can either run &amp;quot;SequencerView.repaint()&amp;quot;, or just move the view a bit (eg scroll). tweakNotes handles this for you, but in this example, you need to do it manually.&lt;br /&gt;
&lt;br /&gt;
Adding notes like this doesn&#039;t have undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Deleting notes ===&lt;br /&gt;
If you have a Note object, you can remove it from the sequence like this:&lt;br /&gt;
 song.removeNote(note)&lt;br /&gt;
This doesn&#039;t actually delete the Note object, just removes it from the sequence. In fact you can add it again if you want, using &amp;quot;song.addNote(note)&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s take another look at our earlier example, where we wanted to delete the thumbnail notes. Instead of using selectNotesIf and then manually deleting them, we could automatically delete them.&lt;br /&gt;
 for (const note of song.notes) {&lt;br /&gt;
   if (note.volume == 0) {&lt;br /&gt;
     song.removeNote(note);&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
Removing notes like this doesn&#039;t have undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Creating markers ===&lt;br /&gt;
 addMarker(time, setting, instrument, value, blend)&lt;br /&gt;
This function adds a marker to the song. The parameters are the same as in the marker field table above. Returns the newly created Marker object. Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Deleting markers ===&lt;br /&gt;
 removeMarker(marker)&lt;br /&gt;
Removes the marker from the sequence. Includes undo/redo support.&lt;br /&gt;
[[category:Online Sequencer UI]]&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=Mixing_and_Mastering&amp;diff=373</id>
		<title>Mixing and Mastering</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=Mixing_and_Mastering&amp;diff=373"/>
		<updated>2023-01-06T23:17:09Z</updated>

		<summary type="html">&lt;p&gt;Liam: /* Headphones OS Creators Actually Use */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Mixing and Mastering&#039;&#039;&#039; is the process of tweaking attributes of sounds within music to make it sound clear and organized.  This skill is essential to make music regardless of which medium is used to create it.  In Online Sequencer, limited tools are available for mixing, but good results are still possible, even with complex and layered songs. Here, most mixing is accomplished through the instrument settings, using volume, panning, equalizer, and reverb. Others like detuning and distortion are useful too but are not always necessary.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
To mix correctly, speakers or &#039;&#039;&#039;headphones&#039;&#039;&#039; that provide an even listening experience are required.  Many will sound wildly different from one another, but professional and critical listening models will be calibrated properly.  In order for a sound device to be appropriate for mixing, it must have a flat frequency response.  This means that the device will produce an equally loud sound regardless of how high are low pitched the signal it receives is.  Listening to music with speakers that provide extra bass sacrifices clarity elsewhere, and gives you an experience that is skewed toward those frequencies.  It is long debated whether headphones or speakers are better for mixing; that will not be addressed here.&lt;br /&gt;
&lt;br /&gt;
=== Headphones OS Creators Actually Use ===&lt;br /&gt;
* Ashduino101: Audio Technica ATH-M40x&lt;br /&gt;
* Alex!: Audio Technica ATH-M50x&lt;br /&gt;
* Calico: Audio Technica ATH-M40x&lt;br /&gt;
* Cool172: Beyerdynamic DT-770 Pro 80ohm&lt;br /&gt;
* Syntax: Beyerdynamic DT-770 Pro&lt;br /&gt;
* Lopyt: Kali LP-6&lt;br /&gt;
* Liam: AKG K712 Pro&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another important thing that is useful in music production is the &#039;&#039;&#039;Audio Interface&#039;&#039;&#039; which acts as an external sound card and as a device you can plug in instruments with. Generally speaking they are a bit more expensive but the sound quality will sound a lot better than plugging directly into the PC&#039;s sound port because the audio interface will directly interface with the computer using USB B or lightning cable. &lt;br /&gt;
&lt;br /&gt;
== Creating Clarity in Music ==&lt;br /&gt;
A well-mixed song allows the listener to easily hear the parts that different instruments are playing, without blasting the volume or causing discomfort.&lt;br /&gt;
&lt;br /&gt;
Ideally its good to find the right balance between no reverb vs full reverb. Often times its not about knowing values but using your ears to determine whether or not the mix of the reverb is well used or not. &lt;br /&gt;
&lt;br /&gt;
Panning can be used to separate elements to make the mix a higher quality due to separation of certain elements like the kick and bass which often share frequencies especially low to low mid range. This could cause an effect called masking which should be avoided. This can happen when an instrument like a bass is louder than other instruments around its frequency spectrum and causing the kick to be muddled especially when the volume is louder on the bass. &lt;br /&gt;
&lt;br /&gt;
Ideally keeping instruments below a level where clipping or digital distortion prevents digital distortions that you would not necessarily want in a mix or recording. Use your ears to tell whether or not the instruments are clipping or not. &lt;br /&gt;
&lt;br /&gt;
=== Volume ===&lt;br /&gt;
Volume is how loud the viewers are listening to the sequence.&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=Console_Commands&amp;diff=260</id>
		<title>Console Commands</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=Console_Commands&amp;diff=260"/>
		<updated>2023-01-03T10:12:26Z</updated>

		<summary type="html">&lt;p&gt;Liam: Finish off advanced techniques.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Console Commands&#039;&#039;&#039; 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.&lt;br /&gt;
&lt;br /&gt;
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].&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to keep a few things in mind when using the console:&lt;br /&gt;
&lt;br /&gt;
* Not all of the commands below have undo/redo support. So if you make a change it might not be possible to undo it.&lt;br /&gt;
* It&#039;s possible to corrupt your sequence using the console. So if you&#039;re new to this it&#039;s highly recommended that you save your sequence before messing with the console.&lt;br /&gt;
&lt;br /&gt;
* 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.&lt;br /&gt;
* Instruments are identified using a number, also know as the id. The current instrument is stored in the global variable &amp;quot;instrument&amp;quot;. So to figure out the number for an instrument, just choose that instrument in the UI, type &amp;quot;instrument&amp;quot;, and press enter. You can also just pass &amp;quot;instrument&amp;quot; directly to use the current instrument, eg &amp;quot;setDetune(instrument, 1200)&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Basic techniques ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Grid ===&lt;br /&gt;
 setGrid(value)&lt;br /&gt;
Changes the size of the grid. The way the value works is a bit confusing: it&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== Time signature ===&lt;br /&gt;
 setTimeSig(timeSig)&lt;br /&gt;
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 &amp;quot;setTimeSig(7)&amp;quot;. If you want something more exotic, you&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== Detune ===&lt;br /&gt;
 setDetune(instrument, detune)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; Firefox does not support detunes outside -1200 to 1200, so using extreme values will mean your sequence will only play correctly on Chromium browsers.&lt;br /&gt;
&lt;br /&gt;
=== Reverb and distortion ===&lt;br /&gt;
 setReverbVolume(instrument, volume)&lt;br /&gt;
 setDistortVolume(instrument, volume)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Equalizer ===&lt;br /&gt;
 setEqHigh(instrument, value)&lt;br /&gt;
 setEqMid(instrument, value)&lt;br /&gt;
 setEqLow(instrument, value)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Panning ===&lt;br /&gt;
 setPan(instrument, value)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Intermediate techniques ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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&#039;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&#039;re written in the documentation like this: &amp;quot;fadeNotes(fadeIn = false)&amp;quot;. This means the &amp;quot;fadeIn&amp;quot; parameter defaults to false, so instead of writing &amp;quot;fadeNotes(false)&amp;quot; you can just write &amp;quot;fadeNotes()&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The functions in this section are defined [https://onlinesequencer.net/app/consoleCommands.js here]. If you know some JS, you can read this file to learn how they work and create your own.&lt;br /&gt;
&lt;br /&gt;
=== Fade notes ===&lt;br /&gt;
 fadeNotes(fadeIn = false)&lt;br /&gt;
 fadeNotes()      // Fade out&lt;br /&gt;
 fadeNotes(true)  // Fade in&lt;br /&gt;
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, &amp;quot;fadeIn&amp;quot; which defaults to false. In other words it fades the notes from their original volume to 0 by default, or if you pass &amp;quot;true&amp;quot; it fades in the segment from 0 volume to original volume.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Stretch notes ===&lt;br /&gt;
 stretchNotes(factor)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Truncate notes ===&lt;br /&gt;
 truncateNotesAt(time)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Convert to detune markers ===&lt;br /&gt;
 convertToDetuneMarkers(startNote = &#039;C5&#039;)&lt;br /&gt;
Moves all the selected notes to the &amp;quot;startNote&amp;quot;, then creates detune markers to detune each note back to its original pitch. For example, if you select a &amp;quot;D5&amp;quot; and then run this with the default startNote, it will move the note to &amp;quot;C5&amp;quot; and create a detune marker to detune it up 200 cents back to &amp;quot;D5&amp;quot;. This is useful for making clear melodies on instruments that get muddy when there&#039;s a lot of notes.&lt;br /&gt;
&lt;br /&gt;
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&#039;s only ever one note at a particular time. This function ignores drum kit instruments.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Humanize ===&lt;br /&gt;
 humanize(volumeVariation = 0.2, timeVariation = 0.1)&lt;br /&gt;
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 &amp;quot;humanize()&amp;quot; to use the defaults.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Remix notes ===&lt;br /&gt;
 remixNotes(chunkSize = 4, avgChunksPerUnmixedSection = 2, avgChunksPerMixedSection = 2, avgMixedSectionsPerUnmixedSection = 1)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Reset all instrument settings ===&lt;br /&gt;
 resetAllInstrumentSettings()&lt;br /&gt;
Resets the settings of all the instruments in the sequence.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; No undo/redo support.&lt;br /&gt;
 removeAllMarkers()&lt;br /&gt;
Deletes all the markers in the sequence.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; No undo/redo support.&lt;br /&gt;
&lt;br /&gt;
== Advanced techniques ==&lt;br /&gt;
You will need to know some JS to use these functions. In particular, we&#039;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].&lt;br /&gt;
&lt;br /&gt;
=== Working with the selection ===&lt;br /&gt;
Most of the functions in the previous section work on the selected notes and markers. The notes and markers selected in the UI are stored in the &amp;quot;selection&amp;quot; object.&lt;br /&gt;
 console.log(selection.notes)&lt;br /&gt;
 console.log(selection.markers)&lt;br /&gt;
 console.log(selection.getTimeSpan())&lt;br /&gt;
You can find all the methods on the selection object [https://onlinesequencer.net/app/selection.js here]. It&#039;s sometimes useful to be able to loop over all the notes or markers in the selection, but if you want to modify the notes in the selection, use tweakNotes below.&lt;br /&gt;
 for (const note of selection.notes) {&lt;br /&gt;
   console.log(note);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 for (const marker of selection.marker) {&lt;br /&gt;
   console.log(marker);&lt;br /&gt;
 }&lt;br /&gt;
You can also add or remove markers and notes from the selection using the selectNote, selectMarker, deselectNote, and deselectMarker methods. However, it&#039;s usually easier to use these functions:&lt;br /&gt;
 selectNotesIf(predicate, addToSelection = false)&lt;br /&gt;
 selectMarkersIf(predicate, addToSelection = false)&lt;br /&gt;
These functions take a predicate (a function that returns true or false) and select all the notes or markers for which the predicate returns true. If addToSelection is true, these notes or markers are added to the existing selection, otherwise they replace the current selection. Both these functions include undo/redo support.&lt;br /&gt;
&lt;br /&gt;
For example, say you wanted to delete the [https://tiusic.com/thumb.html thumbnail] notes from a sequence, so you can change the thumbnail. Thumbnail notes all have 0 volume, so you can just select all the notes with 0 volume:&lt;br /&gt;
 selectNotesIf(n =&amp;gt; n.volume == 0)&lt;br /&gt;
This selects all the thumbnail notes, so now you can delete them as normal (though the UI focus will still be on the console, so you&#039;ll have to click on the sequencer before you press delete).&lt;br /&gt;
&lt;br /&gt;
=== Tweaking notes ===&lt;br /&gt;
 tweakNotes(tweakFunction)&lt;br /&gt;
This is probably the single most useful console function. It basically runs tweakFunction on every selected note, and has undo/redo support for any changes that tweakFunction makes to the note. It&#039;s roughly equivalent to:&lt;br /&gt;
 for (const note of selection.notes) {&lt;br /&gt;
   tweakFunction(note);&lt;br /&gt;
 }&lt;br /&gt;
There are a few problems with doing a for loop like this and manually tweaking the notes. For starters you won&#039;t get undo/redo support, but the bigger problem is that there are a few optimizations that OS does based on the note time, instrument, length, or pitch that require extra work if you modify those parameters (namely &amp;quot;song.moveNote()&amp;quot; and &amp;quot;song.updateLoopTime()&amp;quot;). Failure to do so could corrupt your sequence. tweakNotes takes care of this work for you so you don&#039;t have to worry about it.&lt;br /&gt;
&lt;br /&gt;
The fields of the note object that you can modify are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+The fields of the Note object&lt;br /&gt;
!Name&lt;br /&gt;
!Type&lt;br /&gt;
!Description&lt;br /&gt;
!Can modify?&lt;br /&gt;
|-&lt;br /&gt;
|instrument&lt;br /&gt;
|Integer&lt;br /&gt;
|The instrument id, eg 22 for sitar&lt;br /&gt;
|Only with tweakNotes&lt;br /&gt;
|-&lt;br /&gt;
|type&lt;br /&gt;
|String&lt;br /&gt;
|The pitch or keyboard note, eg &#039;C5&#039; or &#039;F#7&#039;&lt;br /&gt;
|Only with tweakNotes&lt;br /&gt;
|-&lt;br /&gt;
|time&lt;br /&gt;
|Number&lt;br /&gt;
|The time when the note starts in standard time units (quarter notes)&lt;br /&gt;
|Only with tweakNotes&lt;br /&gt;
|-&lt;br /&gt;
|length&lt;br /&gt;
|Number&lt;br /&gt;
|The length of the note in standard time units&lt;br /&gt;
|Only with tweakNotes&lt;br /&gt;
|-&lt;br /&gt;
|volume&lt;br /&gt;
|Number&lt;br /&gt;
|The volume of the note, usually from 0 to 1.&lt;br /&gt;
|Always&lt;br /&gt;
|}&lt;br /&gt;
If you console.log the note you&#039;ll see other internal fields, but &#039;&#039;&#039;DO NOT MODIFY THESE&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
For example, you can halve the volume like this (eg for a custom delay effect, copy, shift, then tweak the volume):&lt;br /&gt;
 tweakNotes(n =&amp;gt; n.volume *= 0.5)&lt;br /&gt;
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):&lt;br /&gt;
 function humanize(volumeVariation = 0.2, timeVariation = 0.1) {&lt;br /&gt;
   tweakNotes(n =&amp;gt; {&lt;br /&gt;
     n.volume *= 1 + volumeVariation * (2 * Math.random() - 1);&lt;br /&gt;
     n.time += timeVariation * (2 * Math.random() - 1);&lt;br /&gt;
     if (n.time &amp;lt; 0) n.time = 0;&lt;br /&gt;
   });&lt;br /&gt;
 }&lt;br /&gt;
Tweak notes can also be used to generate the lengthening sawtooth effect from [https://onlinesequencer.net/1905746 Ganymede]:&lt;br /&gt;
 const span = selection.getTimeSpan();&lt;br /&gt;
 tweakNotes(n =&amp;gt; {&lt;br /&gt;
   n.length *= 0.5 + (n.time - span.min) / (span.max - span.min);&lt;br /&gt;
 });&lt;br /&gt;
A more complicated example is adding swing to your selected notes:&lt;br /&gt;
 tweakNotes(n =&amp;gt; {&lt;br /&gt;
   const t = n.time / 4;&lt;br /&gt;
   const intTime = Math.floor(t);&lt;br /&gt;
   const fracTime = t - intTime;&lt;br /&gt;
   const newFracTime = fracTime &amp;lt;= 0.5 ? fracTime * 4 / 3 : (fracTime - 0.5) * 3 / 4 + 2 / 3;&lt;br /&gt;
   n.time = (intTime + newFracTime) * 4;&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Tweaking markers ===&lt;br /&gt;
There is currently no marker equivalent of tweakNotes. Markers also have optimizations that mean you can&#039;t modify the time, instrument, or setting, without doing extra work. The only things you can safely modify are the value and the blend. If you need to modify the other parameters, you&#039;re better off asking the devs to add a tweakMarkers function, rather than trying to modify them and corrupting your sequence.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+The fields of the Marker object&lt;br /&gt;
!Name&lt;br /&gt;
!Type&lt;br /&gt;
!Description&lt;br /&gt;
!Can modify?&lt;br /&gt;
|-&lt;br /&gt;
|instrument&lt;br /&gt;
|Integer&lt;br /&gt;
|The instrument id, eg 19 for xylophone&lt;br /&gt;
|Never&lt;br /&gt;
|-&lt;br /&gt;
|time&lt;br /&gt;
|Integer&lt;br /&gt;
|The marker&#039;s time (quarter notes, must be a whole number)&lt;br /&gt;
|Never&lt;br /&gt;
|-&lt;br /&gt;
|setting&lt;br /&gt;
|Integer&lt;br /&gt;
|The setting (one of the kMarkerSetting... constants, eg kMarkerSettingBpm)&lt;br /&gt;
|Never&lt;br /&gt;
|-&lt;br /&gt;
|value&lt;br /&gt;
|Dynamic&lt;br /&gt;
|The marker value. Its type depends on the marker setting.&lt;br /&gt;
|Always&lt;br /&gt;
|-&lt;br /&gt;
|blend&lt;br /&gt;
|Boolean&lt;br /&gt;
|Whether or not the marker is blended.&lt;br /&gt;
|Always&lt;br /&gt;
|}&lt;br /&gt;
With these limitations, the most useful thing you can do is set the marker value to a value outside the normal range (like we did for the instrument settings above). This snippet sets all the selected detune markers to detune up by 2 octaves:&lt;br /&gt;
 for (const marker of selection.markers) {&lt;br /&gt;
   if (marker.setting == kMarkerSettingInstrumentDetune) {&lt;br /&gt;
     marker.value = 2400;&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
If you really need to change the instrument, time, or setting, delete the marker and create a new one (see below for details).&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;quot;song.getAllMarkersAtTime(t)&amp;quot; to get a list of all the markers at a specific time, but selecting them in the UI and then iterating over &amp;quot;selection.markers&amp;quot; is easier.&lt;br /&gt;
&lt;br /&gt;
=== Creating notes ===&lt;br /&gt;
You can create Note objects using &amp;quot;new Note&amp;quot;, but you also have to manually add them to the song, like so:&lt;br /&gt;
 song.addNote(new Note(song, type, time, length, instrument, volume))&lt;br /&gt;
For example, let&#039;s generate a random melody:&lt;br /&gt;
 for (let i = 0; i &amp;lt; 16; ++i) {&lt;br /&gt;
   song.addNote(new Note(song, &#039;CDEFGAB&#039;[Math.floor(Math.random() * 7)] + &#039;4&#039;, i, 1, instrument, 1));&lt;br /&gt;
 }&lt;br /&gt;
Whenever you make changes to the notes of a sequence (adding, removing, moving, etc), the changes won&#039;t be visible until the sequencer view is updated. You can either run &amp;quot;SequencerView.repaint()&amp;quot;, or just move the view a bit (eg scroll). tweakNotes handles this for you, but in this example you need to do it manually.&lt;br /&gt;
&lt;br /&gt;
Adding notes like this doesn&#039;t have undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Deleting notes ===&lt;br /&gt;
If you have a Note object, you can remove it from the sequence like this:&lt;br /&gt;
 song.removeNote(note)&lt;br /&gt;
This doesn&#039;t actually delete the Note object, just removes it from the sequence. In fact you can add it again if you want, using &amp;quot;song.addNote(note)&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s take another look at our earlier example, where we wanted to delete the thumbnail notes. Instead of using selectNotesIf and then manually deleting them, we could automatically delete them.&lt;br /&gt;
 for (const note of song.notes) {&lt;br /&gt;
   if (note.volume == 0) {&lt;br /&gt;
     song.removeNote(note);&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
Removing notes like this doesn&#039;t have undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Creating markers ===&lt;br /&gt;
 addMarker(time, setting, instrument, value, blend)&lt;br /&gt;
This function adds a marker to the song. The parameters are the same as in the marker field table above. Returns the newly created Marker object. Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Deleting markers ===&lt;br /&gt;
 removeMarker(marker)&lt;br /&gt;
Removes the marker from the sequence. Includes undo/redo support.&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=Console_Commands&amp;diff=259</id>
		<title>Console Commands</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=Console_Commands&amp;diff=259"/>
		<updated>2023-01-03T08:23:11Z</updated>

		<summary type="html">&lt;p&gt;Liam: Missed a line of code&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Console Commands&#039;&#039;&#039; 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.&lt;br /&gt;
&lt;br /&gt;
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].&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to keep a few things in mind when using the console:&lt;br /&gt;
&lt;br /&gt;
* Not all of the commands below have undo/redo support. So if you make a change it might not be possible to undo it.&lt;br /&gt;
* It&#039;s possible to corrupt your sequence using the console. So if you&#039;re new to this it&#039;s highly recommended that you save your sequence before messing with the console.&lt;br /&gt;
&lt;br /&gt;
* 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.&lt;br /&gt;
* Instruments are identified using a number, also know as the id. The current instrument is stored in the global variable &amp;quot;instrument&amp;quot;. So to figure out the number for an instrument, just choose that instrument in the UI, type &amp;quot;instrument&amp;quot;, and press enter. You can also just pass &amp;quot;instrument&amp;quot; directly to use the current instrument, eg &amp;quot;setDetune(instrument, 1200)&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Basic techniques ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Grid ===&lt;br /&gt;
 setGrid(value)&lt;br /&gt;
Changes the size of the grid. The way the value works is a bit confusing: it&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== Time signature ===&lt;br /&gt;
 setTimeSig(timeSig)&lt;br /&gt;
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 &amp;quot;setTimeSig(7)&amp;quot;. If you want something more exotic, you&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== Detune ===&lt;br /&gt;
 setDetune(instrument, detune)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; Firefox does not support detunes outside -1200 to 1200, so using extreme values will mean your sequence will only play correctly on Chromium browsers.&lt;br /&gt;
&lt;br /&gt;
=== Reverb and distortion ===&lt;br /&gt;
 setReverbVolume(instrument, volume)&lt;br /&gt;
 setDistortVolume(instrument, volume)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Equalizer ===&lt;br /&gt;
 setEqHigh(instrument, value)&lt;br /&gt;
 setEqMid(instrument, value)&lt;br /&gt;
 setEqLow(instrument, value)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Panning ===&lt;br /&gt;
 setPan(instrument, value)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Intermediate techniques ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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&#039;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&#039;re written in the documentation like this: &amp;quot;fadeNotes(fadeIn = false)&amp;quot;. This means the &amp;quot;fadeIn&amp;quot; parameter defaults to false, so instead of writing &amp;quot;fadeNotes(false)&amp;quot; you can just write &amp;quot;fadeNotes()&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The functions in this section are defined [https://onlinesequencer.net/app/consoleCommands.js here]. If you know some JS, you can read this file to learn how they work and create your own.&lt;br /&gt;
&lt;br /&gt;
=== Fade notes ===&lt;br /&gt;
 fadeNotes(fadeIn = false)&lt;br /&gt;
 fadeNotes()      // Fade out&lt;br /&gt;
 fadeNotes(true)  // Fade in&lt;br /&gt;
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, &amp;quot;fadeIn&amp;quot; which defaults to false. In other words it fades the notes from their original volume to 0 by default, or if you pass &amp;quot;true&amp;quot; it fades in the segment from 0 volume to original volume.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Stretch notes ===&lt;br /&gt;
 stretchNotes(factor)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Truncate notes ===&lt;br /&gt;
 truncateNotesAt(time)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Convert to detune markers ===&lt;br /&gt;
 convertToDetuneMarkers(startNote = &#039;C5&#039;)&lt;br /&gt;
Moves all the selected notes to the &amp;quot;startNote&amp;quot;, then creates detune markers to detune each note back to its original pitch. For example, if you select a &amp;quot;D5&amp;quot; and then run this with the default startNote, it will move the note to &amp;quot;C5&amp;quot; and create a detune marker to detune it up 200 cents back to &amp;quot;D5&amp;quot;. This is useful for making clear melodies on instruments that get muddy when there&#039;s a lot of notes.&lt;br /&gt;
&lt;br /&gt;
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&#039;s only ever one note at a particular time. This function ignores drum kit instruments.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Humanize ===&lt;br /&gt;
 humanize(volumeVariation = 0.2, timeVariation = 0.1)&lt;br /&gt;
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 &amp;quot;humanize()&amp;quot; to use the defaults.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Remix notes ===&lt;br /&gt;
 remixNotes(chunkSize = 4, avgChunksPerUnmixedSection = 2, avgChunksPerMixedSection = 2, avgMixedSectionsPerUnmixedSection = 1)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Reset all instrument settings ===&lt;br /&gt;
 resetAllInstrumentSettings()&lt;br /&gt;
Resets the settings of all the instruments in the sequence.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; No undo/redo support.&lt;br /&gt;
 removeAllMarkers()&lt;br /&gt;
Deletes all the markers in the sequence.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; No undo/redo support.&lt;br /&gt;
&lt;br /&gt;
== Advanced techniques ==&lt;br /&gt;
You will need to know some JS to use these functions. In particular, we&#039;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].&lt;br /&gt;
&lt;br /&gt;
=== Working with the selection ===&lt;br /&gt;
Most of the functions in the previous section work on the selected notes and markers. The notes and markers selected in the UI are stored in the &amp;quot;selection&amp;quot; object.&lt;br /&gt;
 console.log(selection.notes)&lt;br /&gt;
 console.log(selection.markers)&lt;br /&gt;
 console.log(selection.getTimeSpan())&lt;br /&gt;
You can find all the methods on the selection object [https://onlinesequencer.net/app/selection.js here]. It&#039;s sometimes useful to be able to loop over all the notes or markers in the selection, but if you want to modify the notes in the selection, use tweakNotes below.&lt;br /&gt;
 for (const note of selection.notes) {&lt;br /&gt;
   console.log(note);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 for (const marker of selection.marker) {&lt;br /&gt;
   console.log(marker);&lt;br /&gt;
 }&lt;br /&gt;
You can also add or remove markers and notes from the selection using the selectNote, selectMarker, deselectNote, and deselectMarker methods. However, it&#039;s usually easier to use these functions:&lt;br /&gt;
 selectNotesIf(predicate, addToSelection = false)&lt;br /&gt;
 selectMarkersIf(predicate, addToSelection = false)&lt;br /&gt;
These functions take a predicate (a function that returns true or false) and select all the notes or markers for which the predicate returns true. If addToSelection is true, these notes or markers are added to the existing selection, otherwise they replace the current selection. Both these functions include undo/redo support.&lt;br /&gt;
&lt;br /&gt;
For example, say you wanted to delete the [https://tiusic.com/thumb.html thumbnail] notes from a sequence, so you can change the thumbnail. Thumbnail notes all have 0 volume, so you can just select all the notes with 0 volume:&lt;br /&gt;
 selectNotesIf(n =&amp;gt; n.volume == 0)&lt;br /&gt;
This selects all the thumbnail notes, so now you can delete them as normal (though the UI focus will still be on the console, so you&#039;ll have to click on the sequencer before you press delete).&lt;br /&gt;
&lt;br /&gt;
=== Tweaking notes ===&lt;br /&gt;
 tweakNotes(tweakFunction)&lt;br /&gt;
This is probably the single most useful console function. It basically runs tweakFunction on every selected note, and has undo/redo support for any changes that tweakFunction makes to the note. It&#039;s roughly equivalent to:&lt;br /&gt;
 for (const note of selection.notes) {&lt;br /&gt;
   tweakFunction(note);&lt;br /&gt;
 }&lt;br /&gt;
There are a few problems with doing a for loop like this and manually tweaking the notes. For starters you won&#039;t get undo/redo support, but the bigger problem is that there are a few optimizations that OS does based on the note time, instrument, length, or pitch that require extra work if you modify those parameters (namely &amp;quot;song.moveNote()&amp;quot; and &amp;quot;song.updateLoopTime()&amp;quot;). Failure to do so could corrupt your sequence. tweakNotes takes care of this work for you so you don&#039;t have to worry about it.&lt;br /&gt;
&lt;br /&gt;
The fields of the note object that you can modify are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+The fields of the Note object&lt;br /&gt;
!Name&lt;br /&gt;
!Type&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|instrument&lt;br /&gt;
|Integer&lt;br /&gt;
|The instrument id, eg 22 for sitar&lt;br /&gt;
|-&lt;br /&gt;
|type&lt;br /&gt;
|String&lt;br /&gt;
|The pitch or keyboard note, eg &#039;C5&#039; or &#039;F#7&#039;&lt;br /&gt;
|-&lt;br /&gt;
|time&lt;br /&gt;
|Number&lt;br /&gt;
|The time when the note starts in standard time units (quarter notes)&lt;br /&gt;
|-&lt;br /&gt;
|length&lt;br /&gt;
|Number&lt;br /&gt;
|The length of the note in standard time units&lt;br /&gt;
|-&lt;br /&gt;
|volume&lt;br /&gt;
|Number&lt;br /&gt;
|The volume of the note, usually from 0 to 1.&lt;br /&gt;
|}&lt;br /&gt;
If you console.log the note you&#039;ll see other internal fields, but &#039;&#039;&#039;DO NOT MODIFY THESE&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
For example, you can halve the volume like this (eg for a custom delay effect, copy, shift, then tweak the volume):&lt;br /&gt;
 tweakNotes(n =&amp;gt; n.volume *= 0.5)&lt;br /&gt;
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):&lt;br /&gt;
 function humanize(volumeVariation = 0.2, timeVariation = 0.1) {&lt;br /&gt;
   tweakNotes(n =&amp;gt; {&lt;br /&gt;
     n.volume *= 1 + volumeVariation * (2 * Math.random() - 1);&lt;br /&gt;
     n.time += timeVariation * (2 * Math.random() - 1);&lt;br /&gt;
     if (n.time &amp;lt; 0) n.time = 0;&lt;br /&gt;
   });&lt;br /&gt;
 }&lt;br /&gt;
Tweak notes can also be used to generate the lengthening sawtooth effect from [https://onlinesequencer.net/1905746 Ganymede]:&lt;br /&gt;
 const span = selection.getTimeSpan();&lt;br /&gt;
 tweakNotes(n =&amp;gt; {&lt;br /&gt;
   n.length *= 0.5 + (n.time - span.min) / (span.max - span.min);&lt;br /&gt;
 });&lt;br /&gt;
A more complicated example is adding swing to your selected notes:&lt;br /&gt;
 tweakNotes(n =&amp;gt; {&lt;br /&gt;
   const t = n.time / 4;&lt;br /&gt;
   const intTime = Math.floor(t);&lt;br /&gt;
   const fracTime = t - intTime;&lt;br /&gt;
   const newFracTime = fracTime &amp;lt;= 0.5 ? fracTime * 4 / 3 : (fracTime - 0.5) * 3 / 4 + 2 / 3;&lt;br /&gt;
   n.time = (intTime + newFracTime) * 4;&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Tweaking markers ===&lt;br /&gt;
There is currently no marker equivalent of tweakNotes. Markers also have optimizations that mean you can&#039;t modify the time, instrument, or setting, without doing extra work. The only things you can safely modify are the value and the blend. If you need to modify the other parameters, you&#039;re better off asking the devs to add a tweakMarkers function, rather than trying to modify them and corrupting your sequence.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+The fields of the Marker object&lt;br /&gt;
!Name&lt;br /&gt;
!Type&lt;br /&gt;
!Description&lt;br /&gt;
!Can modify?&lt;br /&gt;
|-&lt;br /&gt;
|instrument&lt;br /&gt;
|Integer&lt;br /&gt;
|The instrument id, eg 19 for xylophone&lt;br /&gt;
|NO!&lt;br /&gt;
|-&lt;br /&gt;
|time&lt;br /&gt;
|Integer&lt;br /&gt;
|The marker&#039;s time (quarter notes, must be a whole number)&lt;br /&gt;
|NO!&lt;br /&gt;
|-&lt;br /&gt;
|setting&lt;br /&gt;
|Integer&lt;br /&gt;
|The setting (one of the kMarkerSetting... constants, eg kMarkerSettingBpm)&lt;br /&gt;
|NO!&lt;br /&gt;
|-&lt;br /&gt;
|value&lt;br /&gt;
|Dynamic&lt;br /&gt;
|The marker value. Its type depends on the marker setting.&lt;br /&gt;
|yes&lt;br /&gt;
|-&lt;br /&gt;
|blend&lt;br /&gt;
|Boolean&lt;br /&gt;
|Whether or not the marker is blended.&lt;br /&gt;
|yes&lt;br /&gt;
|}&lt;br /&gt;
With these limitations, the most useful thing you can do is set the marker value to a value outside the normal range (like we did for the instrument settings above). This snippet sets all the selected detune markers to detune up by 2 octaves:&lt;br /&gt;
 for (const marker of selection.markers) {&lt;br /&gt;
   if (marker.setting == kMarkerSettingInstrumentDetune) {&lt;br /&gt;
     marker.value = 2400;&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
You can also use &amp;quot;song.getAllMarkersAtTime(t)&amp;quot; to get a list of all the markers at a specific time, but selecting them in the UI and then iterating over &amp;quot;selection.markers&amp;quot; is easier.&lt;br /&gt;
&lt;br /&gt;
=== Creating and deleting notes ===&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Creating and deleting markers ===&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Other handy tools ===&lt;br /&gt;
TODO&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=Console_Commands&amp;diff=258</id>
		<title>Console Commands</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=Console_Commands&amp;diff=258"/>
		<updated>2023-01-03T08:21:45Z</updated>

		<summary type="html">&lt;p&gt;Liam: Add examples in advanced techniques&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Console Commands&#039;&#039;&#039; 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.&lt;br /&gt;
&lt;br /&gt;
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].&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to keep a few things in mind when using the console:&lt;br /&gt;
&lt;br /&gt;
* Not all of the commands below have undo/redo support. So if you make a change it might not be possible to undo it.&lt;br /&gt;
* It&#039;s possible to corrupt your sequence using the console. So if you&#039;re new to this it&#039;s highly recommended that you save your sequence before messing with the console.&lt;br /&gt;
&lt;br /&gt;
* 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.&lt;br /&gt;
* Instruments are identified using a number, also know as the id. The current instrument is stored in the global variable &amp;quot;instrument&amp;quot;. So to figure out the number for an instrument, just choose that instrument in the UI, type &amp;quot;instrument&amp;quot;, and press enter. You can also just pass &amp;quot;instrument&amp;quot; directly to use the current instrument, eg &amp;quot;setDetune(instrument, 1200)&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Basic techniques ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Grid ===&lt;br /&gt;
 setGrid(value)&lt;br /&gt;
Changes the size of the grid. The way the value works is a bit confusing: it&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== Time signature ===&lt;br /&gt;
 setTimeSig(timeSig)&lt;br /&gt;
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 &amp;quot;setTimeSig(7)&amp;quot;. If you want something more exotic, you&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== Detune ===&lt;br /&gt;
 setDetune(instrument, detune)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; Firefox does not support detunes outside -1200 to 1200, so using extreme values will mean your sequence will only play correctly on Chromium browsers.&lt;br /&gt;
&lt;br /&gt;
=== Reverb and distortion ===&lt;br /&gt;
 setReverbVolume(instrument, volume)&lt;br /&gt;
 setDistortVolume(instrument, volume)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Equalizer ===&lt;br /&gt;
 setEqHigh(instrument, value)&lt;br /&gt;
 setEqMid(instrument, value)&lt;br /&gt;
 setEqLow(instrument, value)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Panning ===&lt;br /&gt;
 setPan(instrument, value)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Intermediate techniques ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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&#039;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&#039;re written in the documentation like this: &amp;quot;fadeNotes(fadeIn = false)&amp;quot;. This means the &amp;quot;fadeIn&amp;quot; parameter defaults to false, so instead of writing &amp;quot;fadeNotes(false)&amp;quot; you can just write &amp;quot;fadeNotes()&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The functions in this section are defined [https://onlinesequencer.net/app/consoleCommands.js here]. If you know some JS, you can read this file to learn how they work and create your own.&lt;br /&gt;
&lt;br /&gt;
=== Fade notes ===&lt;br /&gt;
 fadeNotes(fadeIn = false)&lt;br /&gt;
 fadeNotes()      // Fade out&lt;br /&gt;
 fadeNotes(true)  // Fade in&lt;br /&gt;
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, &amp;quot;fadeIn&amp;quot; which defaults to false. In other words it fades the notes from their original volume to 0 by default, or if you pass &amp;quot;true&amp;quot; it fades in the segment from 0 volume to original volume.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Stretch notes ===&lt;br /&gt;
 stretchNotes(factor)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Truncate notes ===&lt;br /&gt;
 truncateNotesAt(time)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Convert to detune markers ===&lt;br /&gt;
 convertToDetuneMarkers(startNote = &#039;C5&#039;)&lt;br /&gt;
Moves all the selected notes to the &amp;quot;startNote&amp;quot;, then creates detune markers to detune each note back to its original pitch. For example, if you select a &amp;quot;D5&amp;quot; and then run this with the default startNote, it will move the note to &amp;quot;C5&amp;quot; and create a detune marker to detune it up 200 cents back to &amp;quot;D5&amp;quot;. This is useful for making clear melodies on instruments that get muddy when there&#039;s a lot of notes.&lt;br /&gt;
&lt;br /&gt;
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&#039;s only ever one note at a particular time. This function ignores drum kit instruments.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Humanize ===&lt;br /&gt;
 humanize(volumeVariation = 0.2, timeVariation = 0.1)&lt;br /&gt;
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 &amp;quot;humanize()&amp;quot; to use the defaults.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Remix notes ===&lt;br /&gt;
 remixNotes(chunkSize = 4, avgChunksPerUnmixedSection = 2, avgChunksPerMixedSection = 2, avgMixedSectionsPerUnmixedSection = 1)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Reset all instrument settings ===&lt;br /&gt;
 resetAllInstrumentSettings()&lt;br /&gt;
Resets the settings of all the instruments in the sequence.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; No undo/redo support.&lt;br /&gt;
 removeAllMarkers()&lt;br /&gt;
Deletes all the markers in the sequence.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; No undo/redo support.&lt;br /&gt;
&lt;br /&gt;
== Advanced techniques ==&lt;br /&gt;
You will need to know some JS to use these functions. In particular, we&#039;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].&lt;br /&gt;
&lt;br /&gt;
=== Working with the selection ===&lt;br /&gt;
Most of the functions in the previous section work on the selected notes and markers. The notes and markers selected in the UI are stored in the &amp;quot;selection&amp;quot; object.&lt;br /&gt;
 console.log(selection.notes)&lt;br /&gt;
 console.log(selection.markers)&lt;br /&gt;
 console.log(selection.getTimeSpan())&lt;br /&gt;
You can find all the methods on the selection object [https://onlinesequencer.net/app/selection.js here]. It&#039;s sometimes useful to be able to loop over all the notes or markers in the selection, but if you want to modify the notes in the selection, use tweakNotes below.&lt;br /&gt;
 for (const note of selection.notes) {&lt;br /&gt;
   console.log(note);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 for (const marker of selection.marker) {&lt;br /&gt;
   console.log(marker);&lt;br /&gt;
 }&lt;br /&gt;
You can also add or remove markers and notes from the selection using the selectNote, selectMarker, deselectNote, and deselectMarker methods. However, it&#039;s usually easier to use these functions:&lt;br /&gt;
 selectNotesIf(predicate, addToSelection = false)&lt;br /&gt;
 selectMarkersIf(predicate, addToSelection = false)&lt;br /&gt;
These functions take a predicate (a function that returns true or false) and select all the notes or markers for which the predicate returns true. If addToSelection is true, these notes or markers are added to the existing selection, otherwise they replace the current selection. Both these functions include undo/redo support.&lt;br /&gt;
&lt;br /&gt;
For example, say you wanted to delete the [https://tiusic.com/thumb.html thumbnail] notes from a sequence, so you can change the thumbnail. Thumbnail notes all have 0 volume, so you can just select all the notes with 0 volume:&lt;br /&gt;
 selectNotesIf(n =&amp;gt; n.volume == 0)&lt;br /&gt;
This selects all the thumbnail notes, so now you can delete them as normal (though the UI focus will still be on the console, so you&#039;ll have to click on the sequencer before you press delete).&lt;br /&gt;
&lt;br /&gt;
=== Tweaking notes ===&lt;br /&gt;
 tweakNotes(tweakFunction)&lt;br /&gt;
This is probably the single most useful console function. It basically runs tweakFunction on every selected note, and has undo/redo support for any changes that tweakFunction makes to the note. It&#039;s roughly equivalent to:&lt;br /&gt;
 for (const note of selection.notes) {&lt;br /&gt;
   tweakFunction(note);&lt;br /&gt;
 }&lt;br /&gt;
There are a few problems with doing a for loop like this and manually tweaking the notes. For starters you won&#039;t get undo/redo support, but the bigger problem is that there are a few optimizations that OS does based on the note time, instrument, length, or pitch that require extra work if you modify those parameters (namely &amp;quot;song.moveNote()&amp;quot; and &amp;quot;song.updateLoopTime()&amp;quot;). Failure to do so could corrupt your sequence. tweakNotes takes care of this work for you so you don&#039;t have to worry about it.&lt;br /&gt;
&lt;br /&gt;
The fields of the note object that you can modify are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+The fields of the Note object&lt;br /&gt;
!Name&lt;br /&gt;
!Type&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|instrument&lt;br /&gt;
|Integer&lt;br /&gt;
|The instrument id, eg 22 for sitar&lt;br /&gt;
|-&lt;br /&gt;
|type&lt;br /&gt;
|String&lt;br /&gt;
|The pitch or keyboard note, eg &#039;C5&#039; or &#039;F#7&#039;&lt;br /&gt;
|-&lt;br /&gt;
|time&lt;br /&gt;
|Number&lt;br /&gt;
|The time when the note starts in standard time units (quarter notes)&lt;br /&gt;
|-&lt;br /&gt;
|length&lt;br /&gt;
|Number&lt;br /&gt;
|The length of the note in standard time units&lt;br /&gt;
|-&lt;br /&gt;
|volume&lt;br /&gt;
|Number&lt;br /&gt;
|The volume of the note, usually from 0 to 1.&lt;br /&gt;
|}&lt;br /&gt;
If you console.log the note you&#039;ll see other internal fields, but &#039;&#039;&#039;DO NOT MODIFY THESE&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
For example, you can halve the volume like this (eg for a custom delay effect, copy, shift, then tweak the volume):&lt;br /&gt;
 tweakNotes(n =&amp;gt; n.volume *= 0.5)&lt;br /&gt;
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):&lt;br /&gt;
 function humanize(volumeVariation = 0.2, timeVariation = 0.1) {&lt;br /&gt;
   tweakNotes(n =&amp;gt; {&lt;br /&gt;
     n.volume *= 1 + volumeVariation * (2 * Math.random() - 1);&lt;br /&gt;
     n.time += timeVariation * (2 * Math.random() - 1);&lt;br /&gt;
     if (n.time &amp;lt; 0) n.time = 0;&lt;br /&gt;
   });&lt;br /&gt;
 }&lt;br /&gt;
Tweak notes can also be used to generate the lengthening sawtooth effect from [https://onlinesequencer.net/1905746 Ganymede]:&lt;br /&gt;
 tweakNotes(n =&amp;gt; {&lt;br /&gt;
   n.length *= 0.5 + (n.time - span.min) / (span.max - span.min);&lt;br /&gt;
 });&lt;br /&gt;
A more complicated example is adding swing to your selected notes:&lt;br /&gt;
 tweakNotes(n =&amp;gt; {&lt;br /&gt;
   const t = n.time / 4;&lt;br /&gt;
   const intTime = Math.floor(t);&lt;br /&gt;
   const fracTime = t - intTime;&lt;br /&gt;
   const newFracTime = fracTime &amp;lt;= 0.5 ? fracTime * 4 / 3 : (fracTime - 0.5) * 3 / 4 + 2 / 3;&lt;br /&gt;
   n.time = (intTime + newFracTime) * 4;&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Tweaking markers ===&lt;br /&gt;
There is currently no marker equivalent of tweakNotes. Markers also have optimizations that mean you can&#039;t modify the time, instrument, or setting, without doing extra work. The only things you can safely modify are the value and the blend. If you need to modify the other parameters, you&#039;re better off asking the devs to add a tweakMarkers function, rather than trying to modify them and corrupting your sequence.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+The fields of the Marker object&lt;br /&gt;
!Name&lt;br /&gt;
!Type&lt;br /&gt;
!Description&lt;br /&gt;
!Can modify?&lt;br /&gt;
|-&lt;br /&gt;
|instrument&lt;br /&gt;
|Integer&lt;br /&gt;
|The instrument id, eg 19 for xylophone&lt;br /&gt;
|NO!&lt;br /&gt;
|-&lt;br /&gt;
|time&lt;br /&gt;
|Integer&lt;br /&gt;
|The marker&#039;s time (quarter notes, must be a whole number)&lt;br /&gt;
|NO!&lt;br /&gt;
|-&lt;br /&gt;
|setting&lt;br /&gt;
|Integer&lt;br /&gt;
|The setting (one of the kMarkerSetting... constants, eg kMarkerSettingBpm)&lt;br /&gt;
|NO!&lt;br /&gt;
|-&lt;br /&gt;
|value&lt;br /&gt;
|Dynamic&lt;br /&gt;
|The marker value. Its type depends on the marker setting.&lt;br /&gt;
|yes&lt;br /&gt;
|-&lt;br /&gt;
|blend&lt;br /&gt;
|Boolean&lt;br /&gt;
|Whether or not the marker is blended.&lt;br /&gt;
|yes&lt;br /&gt;
|}&lt;br /&gt;
With these limitations, the most useful thing you can do is set the marker value to a value outside the normal range (like we did for the instrument settings above). This snippet sets all the selected detune markers to detune up by 2 octaves:&lt;br /&gt;
 for (const marker of selection.markers) {&lt;br /&gt;
   if (marker.setting == kMarkerSettingInstrumentDetune) {&lt;br /&gt;
     marker.value = 2400;&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
You can also use &amp;quot;song.getAllMarkersAtTime(t)&amp;quot; to get a list of all the markers at a specific time, but selecting them in the UI and then iterating over &amp;quot;selection.markers&amp;quot; is easier.&lt;br /&gt;
&lt;br /&gt;
=== Creating and deleting notes ===&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Creating and deleting markers ===&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Other handy tools ===&lt;br /&gt;
TODO&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=Console_Commands&amp;diff=257</id>
		<title>Console Commands</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=Console_Commands&amp;diff=257"/>
		<updated>2023-01-03T06:27:56Z</updated>

		<summary type="html">&lt;p&gt;Liam: Working on the advanced techniques section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Console Commands&#039;&#039;&#039; 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.&lt;br /&gt;
&lt;br /&gt;
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].&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to keep a few things in mind when using the console:&lt;br /&gt;
&lt;br /&gt;
* Not all of the commands below have undo/redo support. So if you make a change it might not be possible to undo it.&lt;br /&gt;
* It&#039;s possible to corrupt your sequence using the console. So if you&#039;re new to this it&#039;s highly recommended that you save your sequence before messing with the console.&lt;br /&gt;
&lt;br /&gt;
* 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.&lt;br /&gt;
* Instruments are identified using a number, also know as the id. The current instrument is stored in the global variable &amp;quot;instrument&amp;quot;. So to figure out the number for an instrument, just choose that instrument in the UI, type &amp;quot;instrument&amp;quot;, and press enter. You can also just pass &amp;quot;instrument&amp;quot; directly to use the current instrument, eg &amp;quot;setDetune(instrument, 1200)&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Basic techniques ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Grid ===&lt;br /&gt;
 setGrid(value)&lt;br /&gt;
Changes the size of the grid. The way the value works is a bit confusing: it&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== Time signature ===&lt;br /&gt;
 setTimeSig(timeSig)&lt;br /&gt;
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 &amp;quot;setTimeSig(7)&amp;quot;. If you want something more exotic, you&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== Detune ===&lt;br /&gt;
 setDetune(instrument, detune)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; Firefox does not support detunes outside -1200 to 1200, so using extreme values will mean your sequence will only play correctly on Chromium browsers.&lt;br /&gt;
&lt;br /&gt;
=== Reverb and distortion ===&lt;br /&gt;
 setReverbVolume(instrument, volume)&lt;br /&gt;
 setDistortVolume(instrument, volume)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Equalizer ===&lt;br /&gt;
 setEqHigh(instrument, value)&lt;br /&gt;
 setEqMid(instrument, value)&lt;br /&gt;
 setEqLow(instrument, value)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Panning ===&lt;br /&gt;
 setPan(instrument, value)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Intermediate techniques ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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&#039;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&#039;re written in the documentation like this: &amp;quot;fadeNotes(fadeIn = false)&amp;quot;. This means the &amp;quot;fadeIn&amp;quot; parameter defaults to false, so instead of writing &amp;quot;fadeNotes(false)&amp;quot; you can just write &amp;quot;fadeNotes()&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The functions in this section are defined [https://onlinesequencer.net/app/consoleCommands.js here]. If you know some JS, you can read this file to learn how they work and create your own.&lt;br /&gt;
&lt;br /&gt;
=== Fade notes ===&lt;br /&gt;
 fadeNotes(fadeIn = false)&lt;br /&gt;
 fadeNotes()      // Fade out&lt;br /&gt;
 fadeNotes(true)  // Fade in&lt;br /&gt;
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, &amp;quot;fadeIn&amp;quot; which defaults to false. In other words it fades the notes from their original volume to 0 by default, or if you pass &amp;quot;true&amp;quot; it fades in the segment from 0 volume to original volume.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Stretch notes ===&lt;br /&gt;
 stretchNotes(factor)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Truncate notes ===&lt;br /&gt;
 truncateNotesAt(time)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Convert to detune markers ===&lt;br /&gt;
 convertToDetuneMarkers(startNote = &#039;C5&#039;)&lt;br /&gt;
Moves all the selected notes to the &amp;quot;startNote&amp;quot;, then creates detune markers to detune each note back to its original pitch. For example, if you select a &amp;quot;D5&amp;quot; and then run this with the default startNote, it will move the note to &amp;quot;C5&amp;quot; and create a detune marker to detune it up 200 cents back to &amp;quot;D5&amp;quot;. This is useful for making clear melodies on instruments that get muddy when there&#039;s a lot of notes.&lt;br /&gt;
&lt;br /&gt;
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&#039;s only ever one note at a particular time. This function ignores drum kit instruments.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Humanize ===&lt;br /&gt;
 humanize(volumeVariation = 0.2, timeVariation = 0.1)&lt;br /&gt;
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 &amp;quot;humanize()&amp;quot; to use the defaults.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Remix notes ===&lt;br /&gt;
 remixNotes(chunkSize = 4, avgChunksPerUnmixedSection = 2, avgChunksPerMixedSection = 2, avgMixedSectionsPerUnmixedSection = 1)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Reset all instrument settings ===&lt;br /&gt;
 resetAllInstrumentSettings()&lt;br /&gt;
Resets the settings of all the instruments in the sequence.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; No undo/redo support.&lt;br /&gt;
 removeAllMarkers()&lt;br /&gt;
Deletes all the markers in the sequence.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; No undo/redo support.&lt;br /&gt;
&lt;br /&gt;
== Advanced techniques ==&lt;br /&gt;
You will need to know some JS to use these functions. In particular, we&#039;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].&lt;br /&gt;
&lt;br /&gt;
=== Working with the selection ===&lt;br /&gt;
Most of the functions in the previous section work on the selected notes and markers. The notes and markers selected in the UI are stored in the &amp;quot;selection&amp;quot; object.&lt;br /&gt;
 console.log(selection.notes)&lt;br /&gt;
 console.log(selection.markers)&lt;br /&gt;
 console.log(selection.getTimeSpan())&lt;br /&gt;
You can find all the methods on the selection object [https://onlinesequencer.net/app/selection.js here]. It&#039;s sometimes useful to be able to loop over all the notes or markers in the selection, but if you want to modify the notes in the selection, use tweakNotes below.&lt;br /&gt;
 for (const note of selection.notes) {&lt;br /&gt;
   console.log(note);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 for (const marker of selection.marker) {&lt;br /&gt;
   console.log(marker);&lt;br /&gt;
 }&lt;br /&gt;
You can also add or remove markers and notes from the selection using the selectNote, selectMarker, deselectNote, and deselectMarker methods. However, it&#039;s usually easier to use these functions:&lt;br /&gt;
 selectNotesIf(predicate, addToSelection = false)&lt;br /&gt;
 selectMarkersIf(predicate, addToSelection = false)&lt;br /&gt;
These functions take a predicate (a function that returns true or false) and select all the notes or markers for which the predicate returns true. If addToSelection is true, these notes or markers are added to the existing selection, otherwise they replace the current selection. Both these functions include undo/redo support.&lt;br /&gt;
&lt;br /&gt;
For example, say you wanted to delete the [https://tiusic.com/thumb.html thumbnail] notes from a sequence, so you can change the thumbnail. Thumbnail notes all have 0 volume, so you can just select all the notes with 0 volume:&lt;br /&gt;
 selectNotesIf(n =&amp;gt; n.volume == 0)&lt;br /&gt;
This selects all the thumbnail notes, so now you can delete them as normal (though the UI focus will still be on the console, so you&#039;ll have to click on the sequencer before you press delete).&lt;br /&gt;
&lt;br /&gt;
=== Tweaking notes ===&lt;br /&gt;
 tweakNotes(tweakFunction)&lt;br /&gt;
This is probably the single most useful console function. It basically runs tweakFunction on every selected note, and has undo/redo support for any changes that tweakFunction makes to the note. It&#039;s roughly equivalent to:&lt;br /&gt;
 for (const note of selection.notes) {&lt;br /&gt;
   tweakFunction(note);&lt;br /&gt;
 }&lt;br /&gt;
There are a few problems with doing a for loop like this and manually tweaking the notes. For starters you won&#039;t get undo/redo support, but the bigger problem is that there are a few optimizations that OS does based on the note time, instrument, length, or pitch that require extra work if you modify those parameters (namely &amp;quot;song.moveNote()&amp;quot; and &amp;quot;song.updateLoopTime()&amp;quot;). Failure to do so could corrupt your sequence. tweakNotes takes care of this work for you so you don&#039;t have to worry about it.&lt;br /&gt;
&lt;br /&gt;
The fields of the note object that you can modify are:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+The fields of the Note object&lt;br /&gt;
!Name&lt;br /&gt;
!Type&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|instrument&lt;br /&gt;
|Integer&lt;br /&gt;
|The instrument id, eg 22 for sitar&lt;br /&gt;
|-&lt;br /&gt;
|type&lt;br /&gt;
|String&lt;br /&gt;
|The pitch or keyboard note, eg &#039;C5&#039; or &#039;F#7&#039;&lt;br /&gt;
|-&lt;br /&gt;
|time&lt;br /&gt;
|Number&lt;br /&gt;
|The time when the note starts in standard time units (quarter notes)&lt;br /&gt;
|-&lt;br /&gt;
|length&lt;br /&gt;
|Number&lt;br /&gt;
|The length of the note in standard time units&lt;br /&gt;
|-&lt;br /&gt;
|volume&lt;br /&gt;
|Number&lt;br /&gt;
|The volume of the note, usually from 0 to 1.&lt;br /&gt;
|}&lt;br /&gt;
If you console.log the note you&#039;ll see other internal fields, but &#039;&#039;&#039;DO NOT MODIFY THESE&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
TODO: example&lt;br /&gt;
&lt;br /&gt;
=== Tweaking markers ===&lt;br /&gt;
There is currently no marker equivalent of tweakNotes. Markers also have optimizations that mean you can&#039;t modify the time, instrument, or setting, without doing extra work. The only things you can safely modify are the value and the blend. If you need to modify the other parameters, you&#039;re better off asking the devs to add a tweakMarkers function, rather than trying to modify them and corrupting your sequence.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+The fields of the Marker object&lt;br /&gt;
!Name&lt;br /&gt;
!Type&lt;br /&gt;
!Description&lt;br /&gt;
!Can modify?&lt;br /&gt;
|-&lt;br /&gt;
|instrument&lt;br /&gt;
|Integer&lt;br /&gt;
|The instrument id, eg 19 for xylophone&lt;br /&gt;
|NO!&lt;br /&gt;
|-&lt;br /&gt;
|time&lt;br /&gt;
|Integer&lt;br /&gt;
|The marker&#039;s time (quarter notes, must be a whole number)&lt;br /&gt;
|NO!&lt;br /&gt;
|-&lt;br /&gt;
|setting&lt;br /&gt;
|Integer&lt;br /&gt;
|The setting (one of the kMarkerSetting... constants, eg kMarkerSettingBpm)&lt;br /&gt;
|NO!&lt;br /&gt;
|-&lt;br /&gt;
|value&lt;br /&gt;
|Dynamic&lt;br /&gt;
|The marker value. Its type depends on the marker setting.&lt;br /&gt;
|yes&lt;br /&gt;
|-&lt;br /&gt;
|blend&lt;br /&gt;
|Boolean&lt;br /&gt;
|Whether or not the marker is blended.&lt;br /&gt;
|yes&lt;br /&gt;
|}&lt;br /&gt;
TODO: example&lt;br /&gt;
&lt;br /&gt;
=== Creating and deleting notes ===&lt;br /&gt;
&lt;br /&gt;
=== Creating and deleting markers ===&lt;br /&gt;
&lt;br /&gt;
=== Other handy tools ===&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=Console_Commands&amp;diff=249</id>
		<title>Console Commands</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=Console_Commands&amp;diff=249"/>
		<updated>2023-01-03T04:06:14Z</updated>

		<summary type="html">&lt;p&gt;Liam: Fill in intermediate techniques.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Console Commands&#039;&#039;&#039; 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.&lt;br /&gt;
&lt;br /&gt;
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].&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to keep a few things in mind when using the console:&lt;br /&gt;
&lt;br /&gt;
* Not all of the commands below have undo/redo support. So if you make a change it might not be possible to undo it.&lt;br /&gt;
* It&#039;s possible to corrupt your sequence using the console. So if you&#039;re new to this it&#039;s highly recommended that you save your sequence before messing with the console.&lt;br /&gt;
&lt;br /&gt;
* 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.&lt;br /&gt;
* Instruments are identified using a number, also know as the id. The current instrument is stored in the global variable &amp;quot;instrument&amp;quot;. So to figure out the number for an instrument, just choose that instrument in the UI, type &amp;quot;instrument&amp;quot;, and press enter. You can also just pass &amp;quot;instrument&amp;quot; directly to use the current instrument, eg &amp;quot;setDetune(instrument, 1200)&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Basic techniques ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Grid ===&lt;br /&gt;
 setGrid(value)&lt;br /&gt;
Changes the size of the grid. The way the value works is a bit confusing: it&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== Time signature ===&lt;br /&gt;
 setTimeSig(timeSig)&lt;br /&gt;
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 &amp;quot;setTimeSig(7)&amp;quot;. If you want something more exotic, you&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== Detune ===&lt;br /&gt;
 setDetune(instrument, detune)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; Firefox does not support detunes outside -1200 to 1200, so using extreme values will mean your sequence will only play correctly on Chromium browsers.&lt;br /&gt;
&lt;br /&gt;
=== Reverb and distortion ===&lt;br /&gt;
 setReverbVolume(instrument, volume)&lt;br /&gt;
 setDistortVolume(instrument, volume)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Equalizer ===&lt;br /&gt;
 setEqHigh(instrument, value)&lt;br /&gt;
 setEqMid(instrument, value)&lt;br /&gt;
 setEqLow(instrument, value)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Panning ===&lt;br /&gt;
 setPan(instrument, value)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Intermediate techniques ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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&#039;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&#039;re written in the documentation like this: &amp;quot;fadeNotes(fadeIn = false)&amp;quot;. This means the &amp;quot;fadeIn&amp;quot; parameter defaults to false, so instead of writing &amp;quot;fadeNotes(false)&amp;quot; you can just write &amp;quot;fadeNotes()&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Fade notes ===&lt;br /&gt;
 fadeNotes(fadeIn = false)&lt;br /&gt;
 fadeNotes()      // Fade out&lt;br /&gt;
 fadeNotes(true)  // Fade in&lt;br /&gt;
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, &amp;quot;fadeIn&amp;quot; which defaults to false. In other words it fades the notes from their original volume to 0 by default, or if you pass &amp;quot;true&amp;quot; it fades in the segment from 0 volume to original volume.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Stretch notes ===&lt;br /&gt;
 stretchNotes(factor)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Truncate notes ===&lt;br /&gt;
 truncateNotesAt(time)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Convert to detune markers ===&lt;br /&gt;
 convertToDetuneMarkers(startNote = &#039;C5&#039;)&lt;br /&gt;
Moves all the selected notes to the &amp;quot;startNote&amp;quot;, then creates detune markers to detune each note back to its original pitch. For example, if you select a &amp;quot;D5&amp;quot; and then run this with the default startNote, it will move the note to &amp;quot;C5&amp;quot; and create a detune marker to detune it up 200 cents back to &amp;quot;D5&amp;quot;. This is useful for making clear melodies on instruments that get muddy when there&#039;s a lot of notes.&lt;br /&gt;
&lt;br /&gt;
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&#039;s only ever one note at a particular time. This function ignores drum kit instruments.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Humanize ===&lt;br /&gt;
 humanize(volumeVariation = 0.2, timeVariation = 0.1)&lt;br /&gt;
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 &amp;quot;humanize()&amp;quot; to use the defaults.&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Remix notes ===&lt;br /&gt;
 remixNotes(chunkSize = 4, avgChunksPerUnmixedSection = 2, avgChunksPerMixedSection = 2, avgMixedSectionsPerUnmixedSection = 1)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Includes undo/redo support.&lt;br /&gt;
&lt;br /&gt;
=== Reset all instrument settings ===&lt;br /&gt;
 resetAllInstrumentSettings()&lt;br /&gt;
Resets the settings of all the instruments in the sequence.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; No undo/redo support.&lt;br /&gt;
 removeAllMarkers()&lt;br /&gt;
Deletes all the markers in the sequence.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; No undo/redo support.&lt;br /&gt;
&lt;br /&gt;
== Advanced techniques ==&lt;br /&gt;
You will need to know a little JS to use these functions. In particular, we&#039;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].&lt;br /&gt;
&lt;br /&gt;
=== Selecting notes and markers ===&lt;br /&gt;
 selectNotesIf(predicate, addToSelection = false)&lt;br /&gt;
 selectMarkersIf(predicate, addToSelection = false)&lt;br /&gt;
&lt;br /&gt;
=== Tweaking notes ===&lt;br /&gt;
 tweakNotes(tweakFunction)&lt;br /&gt;
&lt;br /&gt;
=== Tweaking markers ===&lt;br /&gt;
&lt;br /&gt;
=== Creating and deleting notes ===&lt;br /&gt;
&lt;br /&gt;
=== Creating and deleting markers ===&lt;br /&gt;
&lt;br /&gt;
=== Other handy tools ===&lt;br /&gt;
 selection&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
	<entry>
		<id>https://onlinesequencer.net/w/index.php?title=Console_Commands&amp;diff=206</id>
		<title>Console Commands</title>
		<link rel="alternate" type="text/html" href="https://onlinesequencer.net/w/index.php?title=Console_Commands&amp;diff=206"/>
		<updated>2023-01-02T23:27:49Z</updated>

		<summary type="html">&lt;p&gt;Liam: Rewrote and expanded the console commands page, but I&amp;#039;m only about half done ;)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Console Commands&#039;&#039;&#039; 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to keep a few things in mind when using the console:&lt;br /&gt;
&lt;br /&gt;
* Not all of the commands below have undo/redo support. So if you make a change it might not be possible to undo it.&lt;br /&gt;
* It&#039;s possible to corrupt your sequence using the console. So if you&#039;re new to this it&#039;s highly recommended that you save your sequence before messing with the console.&lt;br /&gt;
&lt;br /&gt;
* 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.&lt;br /&gt;
* Instruments are identified using a number, also know as the id. The current instrument is stored in the global variable &amp;quot;instrument&amp;quot;. So to figure out the number for an instrument, just choose that instrument in the UI, type &amp;quot;instrument&amp;quot;, and press enter. You can also just pass &amp;quot;instrument&amp;quot; directly to use the current instrument, eg &amp;quot;setDetune(instrument, 1200)&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Basic techniques ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Grid ===&lt;br /&gt;
 setGrid(value)&lt;br /&gt;
Changes the size of the grid. The way the value works is a bit confusing: it&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== Time signature ===&lt;br /&gt;
 setTimeSig(timeSig)&lt;br /&gt;
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 &amp;quot;setTimeSig(7)&amp;quot;. If you want something more exotic, you&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== Detune ===&lt;br /&gt;
 setDetune(instrument, detune)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; Firefox does not support detunes outside -1200 to 1200, so using extreme values will mean your sequence will only play correctly on Chromium browsers.&lt;br /&gt;
&lt;br /&gt;
=== Reverb and distortion ===&lt;br /&gt;
 setReverbVolume(instrument, volume)&lt;br /&gt;
 setDistortVolume(instrument, volume)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Equalizer ===&lt;br /&gt;
 setEqHigh(instrument, value)&lt;br /&gt;
 setEqMid(instrument, value)&lt;br /&gt;
 setEqLow(instrument, value)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Panning ===&lt;br /&gt;
 setPan(instrument, value)&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Intermediate techniques ==&lt;br /&gt;
 function stretchNotes(factor)&lt;br /&gt;
 function fadeNotes(fadeIn = false)&lt;br /&gt;
 function resetAllInstrumentSettings()&lt;br /&gt;
 function truncateNotesAt(time)&lt;br /&gt;
 function removeAllMarkers()&lt;br /&gt;
 function convertToDetuneMarkers(startNote = &#039;C5&#039;)&lt;br /&gt;
 function humanize(volumeVariation = 0.2, timeVariation = 0.1)&lt;br /&gt;
 function remixNotes(chunkSize = 4, avgChunksPerUnmixedSection = 2, avgChunksPerMixedSextion = 2, avgMixedSectionsPerUnmixedSection = 1)&lt;br /&gt;
TODO: Documentation&lt;br /&gt;
&lt;br /&gt;
== Advanced techniques ==&lt;br /&gt;
You will need to know a little JS to use these functions. In particular, we&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== Selecting notes and markers ===&lt;br /&gt;
 function selectNotesIf(predicate, addToSelection = false)&lt;br /&gt;
 function selectMarkersIf(predicate, addToSelection = false)&lt;br /&gt;
&lt;br /&gt;
=== Tweaking notes ===&lt;br /&gt;
 function tweakNotes(tweakFunction)&lt;br /&gt;
&lt;br /&gt;
=== Tweaking markers ===&lt;br /&gt;
&lt;br /&gt;
=== Creating and deleting notes ===&lt;br /&gt;
&lt;br /&gt;
=== Creating and deleting markers ===&lt;/div&gt;</summary>
		<author><name>Liam</name></author>
	</entry>
</feed>