Online Sequencer Forums
Time Tool - Printable Version

+- Online Sequencer Forums (https://onlinesequencer.net/forum)
+-- Forum: Online Sequencer (https://onlinesequencer.net/forum/forum-3.html)
+--- Forum: Suggestions (https://onlinesequencer.net/forum/forum-6.html)
+--- Thread: Time Tool (/thread-2181.html)



Time Tool - Frank - 03-18-2018

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.


RE: Time Tool - Tests - 03-18-2018

Nice!


RE: Time Tool - korwynkim - 03-18-2018

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)
}



RE: Time Tool - Frank - 03-18-2018

(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


RE: Time Tool - environmentalSlimePreference - 06-16-2021

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)
}


RE: Time Tool - Liam - 06-17-2021

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)