Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
meganindya committed Jul 14, 2020
1 parent cd10b9c commit 7ea9edc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 105 deletions.
2 changes: 1 addition & 1 deletion js/blocks/DrumBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
16 changes: 6 additions & 10 deletions js/blocks/RhythmBlockPaletteBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
103 changes: 11 additions & 92 deletions js/logo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down Expand Up @@ -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 : [];
}

/**
Expand Down Expand Up @@ -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] = [];
Expand All @@ -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"];
Expand Down Expand Up @@ -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
Expand All @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions js/turtle-singer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 7ea9edc

Please sign in to comment.