From 7ea9edc568dc805b2b7f404e5be2c542562c3e2a Mon Sep 17 00:00:00 2001 From: Anindya Date: Tue, 14 Jul 2020 15:45:41 +0530 Subject: [PATCH] Clean up --- js/blocks/DrumBlocks.js | 2 +- js/blocks/RhythmBlockPaletteBlocks.js | 16 ++-- js/logo.js | 103 +++----------------------- js/turtle-singer.js | 4 +- 4 files changed, 20 insertions(+), 105 deletions(-) diff --git a/js/blocks/DrumBlocks.js b/js/blocks/DrumBlocks.js index 9c9b7509e4..b62ca12cb3 100644 --- a/js/blocks/DrumBlocks.js +++ b/js/blocks/DrumBlocks.js @@ -399,7 +399,7 @@ function setupDrumBlocks() { last(logo.blocks.blockList[blk].connections) == null ) { // Play a stand-alone drum block as a quarter note. - logo.clearNoteParams(turtle, blk, []); + logo.clearNoteParams(tur, blk, []); logo.inNoteBlock[turtle].push(blk); tur.singer.noteDrums[last(logo.inNoteBlock[turtle])].push(drumname); diff --git a/js/blocks/RhythmBlockPaletteBlocks.js b/js/blocks/RhythmBlockPaletteBlocks.js index 72e68a6c0f..d9ef9a507b 100644 --- a/js/blocks/RhythmBlockPaletteBlocks.js +++ b/js/blocks/RhythmBlockPaletteBlocks.js @@ -96,11 +96,11 @@ function setupRhythmBlockPaletteBlocks() { if (logo.drumStyle[turtle].length > 0) { // Play rhythm block as if it were a drum. - logo.clearNoteParams(turtle, blk, logo.drumStyle[turtle]); + logo.clearNoteParams(tur, blk, logo.drumStyle[turtle]); logo.inNoteBlock[turtle].push(blk); } else { // Or use the current synth. - logo.clearNoteParams(turtle, blk, []); + logo.clearNoteParams(tur, blk, []); logo.inNoteBlock[turtle].push(blk); tur.singer.notePitches[last(logo.inNoteBlock[turtle])] = ["G"]; tur.singer.noteOctaves[last(logo.inNoteBlock[turtle])] = [4]; @@ -480,13 +480,9 @@ function setupRhythmBlockPaletteBlocks() { // Play rhythm block as if it were a drum. if (logo.drumStyle[turtle].length > 0) { - logo.clearNoteParams( - turtle, - blk, - logo.drumStyle[turtle] - ); + logo.clearNoteParams(tur, blk, logo.drumStyle[turtle]); } else { - logo.clearNoteParams(turtle, blk, [DEFAULTDRUM]); + logo.clearNoteParams(tur, blk, [DEFAULTDRUM]); } logo.inNoteBlock[turtle].push(blk); @@ -681,9 +677,9 @@ function setupRhythmBlockPaletteBlocks() { // Play rhythm block as if it were a drum. if (logo.drumStyle[turtle].length > 0) { - logo.clearNoteParams(turtle, blk, logo.drumStyle[turtle]); + logo.clearNoteParams(tur, blk, logo.drumStyle[turtle]); } else { - logo.clearNoteParams(turtle, blk, [DEFAULTDRUM]); + logo.clearNoteParams(tur, blk, [DEFAULTDRUM]); } logo.inNoteBlock[turtle].push(blk); diff --git a/js/logo.js b/js/logo.js index 29faa37842..1c39df7469 100644 --- a/js/logo.js +++ b/js/logo.js @@ -179,45 +179,6 @@ class Logo { this.inNoteBlock = []; this.multipleVoices = []; - // Parameters used by pitch - /** @deprecated */ // this.scalarTransposition = {}; - /** @deprecated */ // this.scalarTranspositionValues = {}; - /** @deprecated */ // this.transposition = {}; - /** @deprecated */ // this.transpositionValues = {}; - - // Parameters used by notes - /** @deprecated */ // this._masterBPM = TARGETBPM; - /** @deprecated */ // this.defaultBPMFactor = TONEBPM / TARGETBPM; - - /** @deprecated */ // this.register = {}; - /** @deprecated */ // this.beatFactor = {}; - /** @deprecated */ // this.dotCount = {}; - /** @deprecated */ // this.noteBeat = {}; - /** @deprecated */ // this.noteValue = {}; - /** @deprecated */ // this.oscList = {}; - /** @deprecated */ // this.noteDrums = {}; - /** @deprecated */ // this.notePitches = {}; - /** @deprecated */ // this.noteOctaves = {}; - /** @deprecated */ // this.noteCents = {}; - /** @deprecated */ // this.noteHertz = {}; - /** @deprecated */ // this.noteBeatValues = {}; - /** @deprecated */ // this.embeddedGraphics = {}; - /** @deprecated */ // this.lastNotePlayed = {}; - /** @deprecated */ // this.lastPitchPlayed = {}; // for a stand-alone pitch block - /** @deprecated */ // this.previousNotePlayed = {}; - /** @deprecated */ // this.noteStatus = {}; - /** @deprecated */ // this.noteDirection = {}; - /** @deprecated */ // this.pitchNumberOffset = []; // 39, C4 - /** @deprecated */ // this.currentOctave = {}; - /** @deprecated */ // this.currentCalculatedOctave = {}; // for a stand-alone pitch block - /** @deprecated */ // this.inHarmonic = {}; - /** @deprecated */ // this.partials = {}; - /** @deprecated */ // this.inNeighbor = []; - /** @deprecated */ // this.neighborStepPitch = {}; - /** @deprecated */ // this.neighborNoteValue = {}; - /** @deprecated */ // this.inDefineMode = {}; - /** @deprecated */ // this.defineMode = {}; - // Parameters used in time signature this.pickup = {}; this.beatsPerMeasure = {}; @@ -789,34 +750,22 @@ class Logo { /** * Clears note params. * - * @param turtle + * @param {Object} turtle - Turtle object * @param blk * @param drums * @returns {void} */ clearNoteParams(turtle, blk, drums) { - let tur = this.turtles.ithTurtle(turtle); - - /** @deprecated */ // this.oscList[turtle][blk] = []; - tur.singer.oscList[blk] = []; - /** @deprecated */ // this.noteBeat[turtle][blk] = []; - tur.singer.noteBeat[blk] = []; - /** @deprecated */ // this.noteBeatValues[turtle][blk] = []; - tur.singer.noteBeatValues[blk] = []; - /** @deprecated */ // this.noteValue[turtle][blk] = null; - tur.singer.noteValue[blk] = null; - /** @deprecated */ // this.notePitches[turtle][blk] = []; - tur.singer.notePitches[blk] = []; - /** @deprecated */ // this.noteOctaves[turtle][blk] = []; - tur.singer.noteOctaves[blk] = []; - /** @deprecated */ // this.noteCents[turtle][blk] = []; - tur.singer.noteCents[blk] = []; - /** @deprecated */ // this.noteHertz[turtle][blk] = []; - tur.singer.noteHertz[blk] = []; - /** @deprecated */ // this.embeddedGraphics[turtle][blk] = []; - tur.singer.embeddedGraphics[blk] = []; - /** @deprecated */ // this.noteDrums[turtle][blk] = drums !== null ? drums : []; - tur.singer.noteDrums[blk] = drums !== null ? drums : []; + turtle.singer.oscList[blk] = []; + turtle.singer.noteBeat[blk] = []; + turtle.singer.noteBeatValues[blk] = []; + turtle.singer.noteValue[blk] = null; + turtle.singer.notePitches[blk] = []; + turtle.singer.noteOctaves[blk] = []; + turtle.singer.noteCents[blk] = []; + turtle.singer.noteHertz[blk] = []; + turtle.singer.embeddedGraphics[blk] = []; + turtle.singer.noteDrums[blk] = drums !== null ? drums : []; } /** @@ -1335,28 +1284,7 @@ class Logo { this.cp2y[turtle] = 100; this.inNoteBlock[turtle] = []; this.multipleVoices[turtle] = false; - /** @deprecated */ // this.scalarTransposition[turtle] = 0; - /** @deprecated */ // this.scalarTranspositionValues[turtle] = []; - /** @deprecated */ // this.transposition[turtle] = 0; - /** @deprecated */ // this.transpositionValues[turtle] = []; - /** @deprecated */ // this.noteBeat[turtle] = {}; - /** @deprecated */ // this.noteValue[turtle] = {}; - /** @deprecated */ // this.noteCents[turtle] = {}; - /** @deprecated */ // this.noteHertz[turtle] = {}; - /** @deprecated */ // this.lastNotePlayed[turtle] = null; - /** @deprecated */ // this.previousNotePlayed[turtle] = null; - /** @deprecated */ // this.noteStatus[turtle] = null; - /** @deprecated */ // this.noteDirection[turtle] = 0; - /** @deprecated */ // this.noteDrums[turtle] = {}; - /** @deprecated */ // this.notePitches[turtle] = {}; - /** @deprecated */ // this.noteOctaves[turtle] = {}; - /** @deprecated */ // this.currentOctave[turtle] = 4; - /** @deprecated */ // this.register[turtle] = 0; - /** @deprecated */ // this.noteBeatValues[turtle] = {}; - /** @deprecated */ // this.embeddedGraphics[turtle] = {}; this.embeddedGraphicsFinished[turtle] = true; - /** @deprecated */ // this.beatFactor[turtle] = 1; - /** @deprecated */ // this.dotCount[turtle] = 0; this.invertList[turtle] = []; this.beatList[turtle] = []; this.factorList[turtle] = []; @@ -1372,7 +1300,6 @@ class Logo { this.whichNoteToCount[turtle] = 1; this.keySignature[turtle] = "C " + "major"; this.pushedNote[turtle] = false; - /** @deprecated */ // this.oscList[turtle] = {}; this.bpm[turtle] = []; this.inSetTimbre[turtle] = false; this.instrumentNames[turtle] = ["electronic synth"]; @@ -1416,8 +1343,6 @@ class Logo { this.neighborArgNote2[turtle] = []; this.neighborArgBeat[turtle] = []; this.neighborArgCurrentBeat[turtle] = []; - /** @deprecated */ // this.inDefineMode[turtle] = false; - /** @deprecated */ // this.defineMode[turtle] = []; this.dispatchFactor[turtle] = 1; this.pickup[turtle] = 0; this.beatsPerMeasure[turtle] = 4; // default is 4/4 time @@ -1432,15 +1357,9 @@ class Logo { this.notation.pickupPOW2[turtle] = false; this.firstPitch[turtle] = []; this.lastPitch[turtle] = []; - /** @deprecated */ // this.pitchNumberOffset[turtle] = 39; // C4 this.suppressOutput[turtle] = this.runningLilypond || this.runningAbc || this.runningMxml || this.compiling; this.moveable[turtle] = false; - /** @deprecated */ // this.inNeighbor[turtle] = []; - /** @deprecated */ // this.neighborStepPitch[turtle] = []; - /** @deprecated */ // this.neighborNoteValue[turtle] = []; - /** @deprecated */ // this.inHarmonic[turtle] = []; - /** @deprecated */ // this.partials[turtle] = []; this.returns[turtle] = []; this.defaultStrongBeats[turtle] = false; diff --git a/js/turtle-singer.js b/js/turtle-singer.js index 81dc1710f1..44128067c7 100644 --- a/js/turtle-singer.js +++ b/js/turtle-singer.js @@ -766,7 +766,7 @@ class Singer { } } else { // Play a stand-alone pitch block as a quarter note. - logo.clearNoteParams(turtle, blk, []); + logo.clearNoteParams(tur, blk, []); if (tur.singer.currentCalculatedOctave === undefined) { tur.singer.currentCalculatedOctave = 4; } @@ -868,7 +868,7 @@ class Singer { // A note can contain multiple pitch blocks to create a chord. The chord is accumuated in // arrays, which are used when we play the note - logo.clearNoteParams(turtle, blk, []); + logo.clearNoteParams(tur, blk, []); let noteBeatValue = logo.blocks.blockList[blk].name === "newnote" ? 1 / value : value;