Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // this plugin subdivides all notes into 256ths
- function init() {
- };
- var duration = 240;
- function run() {
- if (typeof curScore === 'undefined')
- return;
- var cursor = new Cursor(curScore);
- var c2 = new Cursor(curScore);
- cursor.goToSelectionStart();
- c2.goToSelectionStart();
- var startStaff = cursor.staff;
- cursor.goToSelectionEnd();
- c2.goToSelectionEnd();
- var endStaff = cursor.staff;
- var endTick = cursor.tick() // if no selection, end of score
- if (cursor.eos()) { // no selection
- startStaff = 0; // start with 1st staff
- endStaff = curScore.staves; // and end with last
- }
- for (var staff = startStaff; staff < endStaff; ++staff) {
- for (var voice = 0; voice < 4; voice++) {
- cursor.goToSelectionStart(); // sets voice to 0
- c2.goToSelectionStart();
- cursor.voice = voice; //voice has to be set after goTo
- c2.voice = voice;
- cursor.staff = staff;
- c2.staff = staff;
- if (cursor.eos()) {
- cursor.rewind() // if no selection, beginning of score
- c2.rewind();
- }
- while (cursor.tick() < endTick) {
- if (cursor.isChord()) {
- var chord = cursor.chord();
- var rest = new Rest(curScore);
- rest.tickLen = chord.tickLen;
- var it = chord.tickLen / duration;
- chord.tickLen = duration;
- c2.add(rest);
- for (var i = 0; i < it; i++) {
- cursor.add(chord);
- //cursor.next();
- }
- } else {
- c2.next();
- cursor.next();
- }
- }
- }
- }
- };
- var mscorePlugin = {
- menu: 'Plugins.Subdivide.8ths',
- init: init,
- run: run
- };
- mscorePlugin;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement