Online Sequencer Forums

Full Version: Continuous Notes Tool
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
For those with beefy computers, inspired by https://onlinesequencer.net/forum/showth...p?tid=2904, written in TamperMonkey,
CONTINUOUS NOTES! (Sort of)
Code:
// ==UserScript==
// @name         Continuous sound!
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  CONTINUOUS
// @author       Frank
// @match        https://onlinesequencer.net
// @grant        none
// @run-at       context-menu
// ==/UserScript==

(function() {
   'use strict';
   var notes = selectedNotes.length ? selectedNotes : song.notes;
   var length = parseFloat(prompt("Length of subdivisions? (Inclusive, 16 = 1 Measure.)"));
   notes = notes.filter(x => x.length >= length && !instrumentLock[x.instrument]);
   for(var i = 0; i < notes.length; i++){
       var note = notes[i];
       var timeStart = note.time;
       var timeEnd = timeStart + note.length;
       var j;
       for(j = timeStart; j < timeEnd - length; j += length){
           song.addNote(new Note(song, note.type, j, length, note.instrument));
       }
       song.addNote(new Note(song, note.type, j, timeEnd - j, note.instrument));
       song.removeNote(note);
   }
   SequencerView.repaint()
})();
This replaces all unlocked notes selected (all unlocked notes if no notes are selected) with a bunch of smaller notes with a length you specify.
Run it by using the context menu after downloading TamperMonkey (from https://tampermonkey.net/, stable).
Guide image: [Image: ZDQrzpY]
This isn't doing anything for me
It works on the console, but not Tampermonkey
(09-08-2018, 05:52 PM)Guest Wrote: [ -> ]It works on the console, but not Tampermonkey

Describe your problem. Be specific.
When I load the new script, it doesn't do anything
(09-08-2018, 07:22 PM)Guest Wrote: [ -> ]When I load the new script, it doesn't do anything

Did you right click to pull up the context menu? What do you mean by "load"?
this is great! Do you think it would be possible to make a "Cancer Piano" option with this? It is basically the same pseudo -sustain, but some notes are randomly left out

examples

this amazing one by Flonk (in which the notes no longer show up because in his, the notes are on a tiny grid)


this ok on by me (I used the 1/16 grid and did it all by hand)

it would be cool to be able to automatically make this effect
(09-09-2018, 09:59 AM)Benjobanjo7 Wrote: [ -> ]this is great!  Do you think it would be possible to make a "Cancer Piano" option with this?  It is basically the same pseudo -sustain, but some notes are randomly left out

examples

this amazing one by Flonk (in which the notes no longer show up  because in his, the notes are on a tiny  grid)

# #541748
this ok on by me (I used the 1/16 grid and did it all by hand)

it would be cool to be able to automatically make this effect

Version 1.1 now has cancer!
Code:
// ==UserScript==
// @name         Continuous sound!
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  CONTINUOUS
// @author       Frank
// @match        https://onlinesequencer.net
// @grant        none
// @run-at       context-menu
// ==/UserScript==

(function() {
    'use strict';
    var notes = selectedNotes.length ? selectedNotes : song.notes;
    var length = parseFloat(prompt("Length of subdivisions? (Inclusive, 16 = 1 Measure.)"));
    var cancer = parseFloat(prompt("Cancer resistance? (1 = no effect, .5 = half destroyed)"))
    switch (true){
        case isNaN(cancer):
            cancer = -1;
            break;
        case cancer > 1:
            cancer = 1;
            break;
        case cancer < 0:
            cancer = 0;
    }
    notes = notes.filter(x => x.length >= length && !instrumentLock[x.instrument]);
    for (var i = 0; i < notes.length; i++){
        var note = notes[i];
        var timeStart = note.time;
        var timeEnd = timeStart + note.length;
        var j;
        if (cancer == 1 || cancer == -1){
            for (j = timeStart; j < timeEnd - length; j += length){
                song.addNote(new Note(song, note.type, j, length, note.instrument));
            }
        }
        else {
            for (j = timeStart; j < timeEnd - length; j += length){
                Math.random() < cancer ? song.addNote(new Note(song, note.type, j, length, note.instrument)) : null;
            }
        }
        Math.random() < cancer ? song.addNote(new Note(song, note.type, j, timeEnd - j, note.instrument)) : null;
        song.removeNote(note);
    }
    SequencerView.repaint()
})();

Example:
Hey Frank, thanks so much, this is really cool, I hope people will use this in creative ways in the future.