Console Commands: Difference between revisions

Jump to navigation Jump to search
Add examples in advanced techniques
(Working on the advanced techniques section)
(Add examples in advanced techniques)
Line 166: Line 166:
If you console.log the note you'll see other internal fields, but '''DO NOT MODIFY THESE'''.
If you console.log the note you'll see other internal fields, but '''DO NOT MODIFY THESE'''.


TODO: example
For example, you can halve the volume like this (eg for a custom delay effect, copy, shift, then tweak the volume):
tweakNotes(n => n.volume *= 0.5)
Another example is the humanize function, which is built on tweakNotes (in fact, several of the other functions could be rewritten in terms of tweakNotes):
function humanize(volumeVariation = 0.2, timeVariation = 0.1) {
  tweakNotes(n => {
    n.volume *= 1 + volumeVariation * (2 * Math.random() - 1);
    n.time += timeVariation * (2 * Math.random() - 1);
    if (n.time < 0) n.time = 0;
  });
}
Tweak notes can also be used to generate the lengthening sawtooth effect from [https://onlinesequencer.net/1905746 Ganymede]:
tweakNotes(n => {
  n.length *= 0.5 + (n.time - span.min) / (span.max - span.min);
});
A more complicated example is adding swing to your selected notes:
tweakNotes(n => {
  const t = n.time / 4;
  const intTime = Math.floor(t);
  const fracTime = t - intTime;
  const newFracTime = fracTime <= 0.5 ? fracTime * 4 / 3 : (fracTime - 0.5) * 3 / 4 + 2 / 3;
  n.time = (intTime + newFracTime) * 4;
});


=== Tweaking markers ===
=== Tweaking markers ===
Line 202: Line 223:
|yes
|yes
|}
|}
TODO: example
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:
for (const marker of selection.markers) {
  if (marker.setting == kMarkerSettingInstrumentDetune) {
    marker.value = 2400;
  }
}
You can also use "song.getAllMarkersAtTime(t)" to get a list of all the markers at a specific time, but selecting them in the UI and then iterating over "selection.markers" is easier.


=== Creating and deleting notes ===
=== Creating and deleting notes ===
TODO


=== Creating and deleting markers ===
=== Creating and deleting markers ===
TODO


=== Other handy tools ===
=== Other handy tools ===
TODO

Navigation menu