Online Sequencer Forums

Full Version: Time Tool
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Have you ever wanted to speed up or slow down a section you composed relative to other sections, but can't because tempo is the only way to control speed? Well, fear not, I have written a console script that does that!
Code:
n=parseFloat(prompt());
for(i=0;i<selectedNotes.length;i++){
j=selectedNotes[i];
song.moveNote(j,j.instrument,j.instrument,j.time,j.time*n,j.type,j.type)}
x=selectedNotes;deleteSelection();undoChange();selectedNotes=x;
Just paste this into the console after selecting the notes you want to change, and then just enter the tempo multiplier! Just remember that numbers greater than 1 REDUCE the tempo, and vice-versa. Note that parseFloat() returns NaN when you give it invalid stuff, so if you give it something like "Frank Sucks", then it will ruin all the notes by changing their time to NaN. Also, it changes tempo relative to the start of the song, but it is easy to move the notes back to their proper place.

NaN Note Documentation:
Never makes sound, can be moved around but to no avail.
Nice!
You really should write cleaner code and use more descriptive variable names Tounge

Here it is cleaned up

Code:
multiplier  =  parseFloat(prompt("How much do you want to scale the note lengths?"))

for(i  =  0;  i  <  selectedNotes.length;  i++){
       note  =  selectedNotes[i]
       song.moveNote(note,  note.instrument,  note.instrument,  note.time,  note.time*multiplier,  note.type,  note.type)
       song.update(note)
}
(03-18-2018, 05:58 PM)korwynkim Wrote: [ -> ]You really should write cleaner code and use more descriptive variable names Tounge

Here it is cleaned up

Code:
multiplier  =  parseFloat(prompt("How much do you want to scale the note lengths?"))

for(i  =  0;  i  <  selectedNotes.length;  i++){
       note  =  selectedNotes[i]
       song.moveNote(note,  note.instrument,  note.instrument,  note.time,  note.time*multiplier,  note.type,  note.type)
       song.update(note)
}

What? No! Now it isn't as short as possible! /s
updated selectedNotes to selection.notes and removed song.update apparently



multiplier = parseFloat(prompt("How much do you want to scale?"))

for(i = 0; i < selection.notes.length; i++){
note = selection.notes[i]
song.moveNote(note, note.instrument, note.instrument, note.time, note.time*multiplier, note.type, note.type)
}
This thread is super out of date. There's now an official console command for this:
stretchNotes(scaleFactor)

It can also handle markers, and negative stretching (tho markers can't be negatively stretched)