Skip to content

Commit

Permalink
Activity refactor (#2943)
Browse files Browse the repository at this point in the history
* clean up many un/misdeclared variables

* use getter/setter for octaveRatio

* use functions to access TEMPERAMENT

* eslint

* refactor to eliminate most globals and all eslint errors

* no longer supported

* refactor in response to activity.js refactoring

* refactor in response to activity.js refactoring

* refactor in response to activity.js refactoring

* refactor in response to activity.js refactoring

* refactor in response to activity.js refactoring

* refactor in response to activity.js refactoring

* refactoring due to changes to activity.js

* wrong case on exported

* inadvertently removed

* temporarily disable plugins and myblocks

* fix inconsistency with cameraID

* fix regression with custom pitch block

* handle neg. cents

* fix regression in stage

* fix regression with grid

* fix my blocks code

* fix regression in collapse graphics

* update maths plugin to reflect new format

* add support for flow plugins

* add external support for hideArrows

* linting

* mark as deprecated

* refactor to new format

* refactor plugin global storage

* updates for new refactor

* more changes to fix long-standing regressions with plugins

* more plugin updates

* updated to new format

* wrapping up plugin changes

* fix lint warnings

* don't use global lint disable

* missed one

* Fixes Mouse Name Block Connection issues #2942

* Fix: Print simultaneous with the note #2938

* Fixed : NaN appearing in Stats #2937

* Collapsible define temperament and define mode blocks #2934

* [email protected]

* fixes #2907: When new project button is pressed, the original project is first saved #2923

* missed some tweaks due to refactoring

* don't crash when macros as malformed

* lint

Co-authored-by: Kumar Saurabh Raj <[email protected]>
Co-authored-by: Daksh Shah <[email protected]>
Co-authored-by: Joykirat Singh <[email protected]>
Co-authored-by: Daksh Doshi <[email protected]>
Co-authored-by: tborich <[email protected]>
  • Loading branch information
6 people authored May 13, 2021
1 parent 34dcfbc commit ae7ce91
Show file tree
Hide file tree
Showing 115 changed files with 12,329 additions and 12,354 deletions.
268 changes: 130 additions & 138 deletions js/SaveInterface.js

Large diffs are not rendered by default.

70 changes: 40 additions & 30 deletions js/abc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2017-20 Walter Bender
// Copyright (c) 2017-21 Walter Bender
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the The GNU Affero General Public
Expand All @@ -9,19 +9,30 @@
// License along with this library; if not, write to the Free Software
// Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA

/*
global
frequencyToPitch, NOTATIONNOTE, NOTATIONTUPLETVALUE, NOTATIONDURATION,
NOTATIONROUNDDOWN, NOTATIONINSIDECHORD, NOTATIONDOTCOUNT,
NOTATIONSTACCATO, toFraction
*/

/* exported saveAbcOutput */

// This header is prepended to the Abc output.
const ABCHEADER = "X:1\nT:Music Blocks composition\nC:Mr. Mouse\nL:1/16\nM:C\n";
getABCHeader = function() {

const getABCHeader = function() {
return ABCHEADER;
};

processABCNotes = function(logo, turtle) {
const processABCNotes = function(logo, turtle) {
// obj = [instructions] or
// obj = [[notes], duration, dotCount, tupletValue, roundDown,
// insideChord, staccato]
logo.notationNotes[turtle] = "";

function __convertDuration(duration) {
const __convertDuration = function(duration) {
let returnString = "";
switch (duration) {
case 64:
Expand Down Expand Up @@ -51,9 +62,9 @@ processABCNotes = function(logo, turtle) {
}

return returnString;
}
};

function __toABCnote(note) {
const __toABCnote = function (note) {
// beams -- no space between notes
// ties use ()
// % comment
Expand Down Expand Up @@ -126,14 +137,14 @@ processABCNotes = function(logo, turtle) {
}

return note.toUpperCase();
}
};

let counter = 0;
let queueSlur = false;
let articulation = false;
let targetDuration = 0;
let tupletDuration = 0;
let notes, note;
let notes, note;

for (let i = 0; i < logo.notation.notationStaging[turtle].length; i++) {
const obj = logo.notation.notationStaging[turtle][i];
Expand Down Expand Up @@ -252,14 +263,14 @@ processABCNotes = function(logo, turtle) {
}
}

function __processTuplet(logo, turtle, i, count) {
const __processTuplet = function (logo, turtle, i, count) {
let j = 0;
let k = 0;

while (k < count) {
const tupletDuration = 2 *
logo.notation.notationStaging[turtle][i + j][
NOTATIONDURATION];
// const tupletDuration = 2 *
// logo.notation.notationStaging[turtle][i + j][
// NOTATIONDURATION];

if (typeof notes === "object") {
if (notes.length > 1) {
Expand All @@ -286,6 +297,7 @@ processABCNotes = function(logo, turtle) {
j++; // Jump to next note.
k++; // Increment notes in tuplet.
} else {
// eslint-disable-next-line no-console
console.debug("ignoring " + notes);
j++; // Jump to next note.
k++; // Increment notes in tuplet.
Expand All @@ -306,7 +318,7 @@ processABCNotes = function(logo, turtle) {
}

return j;
}
};

if (obj[NOTATIONTUPLETVALUE] > 0) {
if (incompleteTuplet === 0) {
Expand Down Expand Up @@ -414,30 +426,28 @@ processABCNotes = function(logo, turtle) {
}
};

saveAbcOutput = function(logo) {
let turtleCount = 0;
const clef = [];
const saveAbcOutput = function(activity) {
// let turtleCount = 0;

logo.notationOutput = getABCHeader();
activity.logo.notationOutput = getABCHeader();

for (const t in logo.notation.notationStaging) {
turtleCount += 1;
}
console.debug("saving as abc: " + turtleCount);
// for (const t in activity.logo.notation.notationStaging) {
// turtleCount += 1;
// }
// eslint-disable-next-line no-console
// console.debug("saving as abc: " + turtleCount);

let c = 0;
for (const t in logo.notation.notationStaging) {
logo.notationOutput +=
"K:" + logo.turtles.ithTurtle(t).singer.keySignature
for (const t in activity.logo.notation.notationStaging) {
activity.logo.notationOutput +=
"K:" + activity.turtles.ithTurtle(t).singer.keySignature
.toUpperCase()
.replace(" ", "")
.replace("♭", "b")
.replace("♯", "#") + "\n";
processABCNotes(logo, t);
logo.notationOutput += logo.notationNotes[t];
c += 1;
processABCNotes(activity.logo, t);
activity.logo.notationOutput += activity.logo.notationNotes[t];
}

logo.notationOutput += "\n";
return logo.notationOutput;
activity.logo.notationOutput += "\n";
return activity.logo.notationOutput;
};
Loading

0 comments on commit ae7ce91

Please sign in to comment.