Skip to content

Commit fadf986

Browse files
committed
refactor to less convoluted logic for step pitch
1 parent 37135b7 commit fadf986

File tree

2 files changed

+32
-41
lines changed

2 files changed

+32
-41
lines changed

js/logo.js

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2460,7 +2460,7 @@ function Logo () {
24602460
if (that.pitchBlocks.indexOf(blk) === -1) {
24612461
that.pitchBlocks.push(blk);
24622462
}
2463-
that.pitchTimeMatrix.rowLabelsPush(that.blocks.blockList[blk].name, false);
2463+
that.pitchTimeMatrix.rowLabels.push(that.blocks.blockList[blk].name);
24642464
that.pitchTimeMatrix.rowArgs.push([args[0], args[1]]);
24652465
} else if (that.inNoteBlock[turtle].length > 0) {
24662466
that.embeddedGraphics[turtle][last(that.inNoteBlock[turtle])].push(blk);
@@ -2489,7 +2489,7 @@ function Logo () {
24892489
if (that.pitchBlocks.indexOf(blk) === -1) {
24902490
that.pitchBlocks.push(blk);
24912491
}
2492-
that.pitchTimeMatrix.rowLabelsPush(that.blocks.blockList[blk].name, false);
2492+
that.pitchTimeMatrix.rowLabels.push(that.blocks.blockList[blk].name);
24932493
that.pitchTimeMatrix.rowArgs.push([args[0], args[1]]);
24942494
} else if (that.inNoteBlock[turtle].length > 0) {
24952495
that.embeddedGraphics[turtle][last(that.inNoteBlock[turtle])].push(blk);
@@ -2518,7 +2518,7 @@ function Logo () {
25182518
if (that.pitchBlocks.indexOf(blk) === -1) {
25192519
that.pitchBlocks.push(blk);
25202520
}
2521-
that.pitchTimeMatrix.rowLabelsPush(that.blocks.blockList[blk].name, false);
2521+
that.pitchTimeMatrix.rowLabels.push(that.blocks.blockList[blk].name);
25222522
that.pitchTimeMatrix.rowArgs.push([args[0], args[1]]);
25232523
} else if (that.inNoteBlock[turtle].length > 0) {
25242524
that.embeddedGraphics[turtle][last(that.inNoteBlock[turtle])].push(blk);
@@ -2640,7 +2640,7 @@ function Logo () {
26402640
if (that.pitchBlocks.indexOf(blk) === -1) {
26412641
that.pitchBlocks.push(blk);
26422642
}
2643-
that.pitchTimeMatrix.rowLabelsPush(that.blocks.blockList[blk].name, false);
2643+
that.pitchTimeMatrix.rowLabels.push(that.blocks.blockList[blk].name);
26442644
that.pitchTimeMatrix.rowArgs.push(args[0]);
26452645
} else if (that.inNoteBlock[turtle].length > 0) {
26462646
that.embeddedGraphics[turtle][last(that.inNoteBlock[turtle])].push(blk);
@@ -2669,7 +2669,7 @@ function Logo () {
26692669
if (that.pitchBlocks.indexOf(blk) === -1) {
26702670
that.pitchBlocks.push(blk);
26712671
}
2672-
that.pitchTimeMatrix.rowLabelsPush(that.blocks.blockList[blk].name, false);
2672+
that.pitchTimeMatrix.rowLabels.push(that.blocks.blockList[blk].name);
26732673
that.pitchTimeMatrix.rowArgs.push(args[0]);
26742674
} else if (that.inNoteBlock[turtle].length > 0) {
26752675
that.embeddedGraphics[turtle][last(that.inNoteBlock[turtle])].push(blk);
@@ -2698,7 +2698,7 @@ function Logo () {
26982698
if (that.pitchBlocks.indexOf(blk) === -1) {
26992699
that.pitchBlocks.push(blk);
27002700
}
2701-
that.pitchTimeMatrix.rowLabelsPush(that.blocks.blockList[blk].name, false);
2701+
that.pitchTimeMatrix.rowLabels.push(that.blocks.blockList[blk].name);
27022702
that.pitchTimeMatrix.rowArgs.push(args[0]);
27032703
} else if (that.inNoteBlock[turtle].length > 0) {
27042704
that.embeddedGraphics[turtle][last(that.inNoteBlock[turtle])].push(blk);
@@ -2727,7 +2727,7 @@ function Logo () {
27272727
if (that.pitchBlocks.indexOf(blk) === -1) {
27282728
that.pitchBlocks.push(blk);
27292729
}
2730-
that.pitchTimeMatrix.rowLabelsPush(that.blocks.blockList[blk].name, false);
2730+
that.pitchTimeMatrix.rowLabels.push(that.blocks.blockList[blk].name);
27312731
that.pitchTimeMatrix.rowArgs.push(args[0]);
27322732
} else if (that.inNoteBlock[turtle].length > 0) {
27332733
that.embeddedGraphics[turtle][last(that.inNoteBlock[turtle])].push(blk);
@@ -2756,7 +2756,7 @@ function Logo () {
27562756
if (that.pitchBlocks.indexOf(blk) === -1) {
27572757
that.pitchBlocks.push(blk);
27582758
}
2759-
that.pitchTimeMatrix.rowLabelsPush(that.blocks.blockList[blk].name, false);
2759+
that.pitchTimeMatrix.rowLabels.push(that.blocks.blockList[blk].name);
27602760
that.pitchTimeMatrix.rowArgs.push(args[0]);
27612761
} else if (that.inNoteBlock[turtle].length > 0) {
27622762
that.embeddedGraphics[turtle][last(that.inNoteBlock[turtle])].push(blk);
@@ -2929,7 +2929,7 @@ function Logo () {
29292929
that.pitchBlocks.push(blk);
29302930
}
29312931

2932-
that.pitchTimeMatrix.rowLabelsPush(that.blocks.blockList[blk].name, false);
2932+
that.pitchTimeMatrix.rowLabels.push(that.blocks.blockList[blk].name);
29332933
that.pitchTimeMatrix.rowArgs.push(args[0]);
29342934
} else if (that.inNoteBlock[turtle].length > 0) {
29352935
that.embeddedGraphics[turtle][last(that.inNoteBlock[turtle])].push(blk);
@@ -2964,7 +2964,7 @@ function Logo () {
29642964
that.pitchBlocks.push(blk);
29652965
}
29662966

2967-
that.pitchTimeMatrix.rowLabelsPush(that.blocks.blockList[blk].name, false);
2967+
that.pitchTimeMatrix.rowLabels.push(that.blocks.blockList[blk].name);
29682968
that.pitchTimeMatrix.rowArgs.push(args[0]);
29692969
} else if (that.inNoteBlock[turtle].length > 0) {
29702970
that.embeddedGraphics[turtle][last(that.inNoteBlock[turtle])].push(blk);
@@ -2989,7 +2989,7 @@ function Logo () {
29892989
that.pitchBlocks.push(blk);
29902990
}
29912991

2992-
that.pitchTimeMatrix.rowLabelsPush(that.blocks.blockList[blk].name, false);
2992+
that.pitchTimeMatrix.rowLabels.push(that.blocks.blockList[blk].name);
29932993
that.pitchTimeMatrix.rowArgs.push(args[0]);
29942994
} else if (that.inNoteBlock[turtle].length > 0) {
29952995
that.embeddedGraphics[turtle][last(that.inNoteBlock[turtle])].push(blk);
@@ -3014,7 +3014,7 @@ function Logo () {
30143014
that.pitchBlocks.push(blk);
30153015
}
30163016

3017-
that.pitchTimeMatrix.rowLabelsPush(that.blocks.blockList[blk].name, false);
3017+
that.pitchTimeMatrix.rowLabels.push(that.blocks.blockList[blk].name);
30183018
that.pitchTimeMatrix.rowArgs.push(args[0]);
30193019
} else if (that.inNoteBlock[turtle].length > 0) {
30203020
that.embeddedGraphics[turtle][last(that.inNoteBlock[turtle])].push(blk);
@@ -3041,7 +3041,7 @@ function Logo () {
30413041
that.pitchBlocks.push(blk);
30423042
}
30433043

3044-
that.pitchTimeMatrix.rowLabelsPush(that.blocks.blockList[blk].name, false);
3044+
that.pitchTimeMatrix.rowLabels.push(that.blocks.blockList[blk].name);
30453045
that.pitchTimeMatrix.rowArgs.push(args[0]);
30463046
} else if (that.inNoteBlock[turtle].length > 0) {
30473047
that.embeddedGraphics[turtle][last(that.inNoteBlock[turtle])].push(blk);
@@ -3066,7 +3066,7 @@ function Logo () {
30663066
that.pitchBlocks.push(blk);
30673067
}
30683068

3069-
that.pitchTimeMatrix.rowLabelsPush(that.blocks.blockList[blk].name, false);
3069+
that.pitchTimeMatrix.rowLabels.push(that.blocks.blockList[blk].name);
30703070
that.pitchTimeMatrix.rowArgs.push(args[0]);
30713071
} else if (that.inNoteBlock[turtle].length > 0) {
30723072
that.embeddedGraphics[turtle][last(that.inNoteBlock[turtle])].push(blk);
@@ -4516,10 +4516,19 @@ function Logo () {
45164516
if (that.pitchTimeMatrix.rowLabels.length > 0) {
45174517
if (last(that.pitchTimeMatrix.rowLabels) === 'hertz') {
45184518
var freq = pitchToFrequency(noteObj[0], noteObj[1], 0, that.keySignature[turtle]);
4519-
that.pitchTimeMatrix.rowLabelsPush('hertz', false);
4519+
that.pitchTimeMatrix.rowLabels.push('hertz');
45204520
that.pitchTimeMatrix.rowArgs.push(parseInt(freq));
45214521
} else {
4522-
that.pitchTimeMatrix.rowLabelsPush(noteObj1[0], true);
4522+
if (that.pitchTimeMatrix.rowLabels.length > 0) {
4523+
if (SOLFEGENAMES1.indexOf(last(that.pitchTimeMatrix.rowLabels)) !== -1) {
4524+
that.pitchTimeMatrix.rowLabels.push(SOLFEGECONVERSIONTABLE[noteObj1[0]]);
4525+
} else {
4526+
that.pitchTimeMatrix.rowLabels.push(noteObj1[0]);
4527+
}
4528+
} else {
4529+
that.pitchTimeMatrix.rowLabels.push(noteObj1[0]);
4530+
}
4531+
45234532
that.pitchTimeMatrix.rowArgs.push(noteObj1[1]);
45244533
}
45254534
}
@@ -4629,7 +4638,7 @@ function Logo () {
46294638
that.drumBlocks.push(blk);
46304639
}
46314640
} else if (that.inMatrix) {
4632-
that.pitchTimeMatrix.rowLabelsPush(drumname, false);
4641+
that.pitchTimeMatrix.rowLabels.push(drumname);
46334642
that.pitchTimeMatrix.rowArgs.push(-1);
46344643

46354644
that.pitchTimeMatrix.addRowBlock(blk);
@@ -4969,14 +4978,14 @@ function Logo () {
49694978

49704979
// If we are in a setdrum clamp, override the pitch.
49714980
if (that.drumStyle[turtle].length > 0) {
4972-
that.pitchTimeMatrix.rowLabelsPush(last(that.drumStyle[turtle]), false);
4981+
that.pitchTimeMatrix.rowLabels.push(last(that.drumStyle[turtle]));
49734982
that.pitchTimeMatrix.rowArgs.push(-1);
49744983
} else {
49754984
// Was the pitch arg a note name or solfege name?
49764985
if (useSolfegeName && noteObj[0] in SOLFEGECONVERSIONTABLE) {
4977-
that.pitchTimeMatrix.rowLabelsPush(SOLFEGECONVERSIONTABLE[noteObj[0]], false);
4986+
that.pitchTimeMatrix.rowLabels.push(SOLFEGECONVERSIONTABLE[noteObj[0]]);
49784987
} else {
4979-
that.pitchTimeMatrix.rowLabelsPush(noteObj[0], false);
4988+
that.pitchTimeMatrix.rowLabels.push(noteObj[0]);
49804989
}
49814990

49824991
that.pitchTimeMatrix.rowArgs.push(noteObj[1]);
@@ -7254,7 +7263,7 @@ function Logo () {
72547263
that.pitchBlocks.push(blk);
72557264
}
72567265

7257-
that.pitchTimeMatrix.rowLabelsPush(that.blocks.blockList[blk].name, false);
7266+
that.pitchTimeMatrix.rowLabels.push(that.blocks.blockList[blk].name);
72587267
that.pitchTimeMatrix.rowArgs.push(arg);
72597268
// convert hertz to note/octave
72607269
var note = frequencyToPitch(arg);
@@ -7347,7 +7356,7 @@ function Logo () {
73477356
that.pitchBlocks.push(blk);
73487357
}
73497358

7350-
that.pitchTimeMatrix.rowLabelsPush(that.blocks.blockList[blk].name, false);
7359+
that.pitchTimeMatrix.rowLabels.push(that.blocks.blockList[blk].name);
73517360
that.pitchTimeMatrix.rowArgs.push(args[0]);
73527361
} else if (that.inPitchSlider) {
73537362
that.pitchSlider.Sliders.push([args[0], 0, 0]);

js/widgets/pitchtimematrix.js

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -153,24 +153,6 @@ function PitchTimeMatrix () {
153153
}
154154
};
155155

156-
this.rowLabelsPush = function(label, convert) {
157-
// When convert is true, we are using step pitch, so preserve
158-
// the form of the previous note.
159-
if (convert && this.rowLabels.length > 0) {
160-
if (SOLFEGENAMES1.indexOf(last(this.rowLabels)) !== -1) {
161-
if (label in SOLFEGECONVERSIONTABLE) {
162-
this.rowLabels.push(SOLFEGECONVERSIONTABLE[label]);
163-
} else {
164-
this.rowLabels.push(label);
165-
}
166-
} else {
167-
this.rowLabels.push(label);
168-
}
169-
} else {
170-
this.rowLabels.push(label);
171-
}
172-
};
173-
174156
this._get_save_lock = function () {
175157
// Debounce the save button.
176158
return this._save_lock;
@@ -464,7 +446,7 @@ function PitchTimeMatrix () {
464446
var noteName = this.rowLabels[i];
465447
if (noteName in BELLSETIDX && this.rowArgs[i] === 4) {
466448
cell.innerHTML = '<img src="' + 'images/8_bellset_key_' + BELLSETIDX[noteName] + '.svg' + '" width="' + cell.style.width + '" vertical-align="middle">';
467-
} else if (['C', 'do'].indexOf(noteName) !== 0 && this.rowArgs[i] === 5) {
449+
} else if (['C', 'do'].indexOf(noteName) !== -1 && this.rowArgs[i] === 5) {
468450
cell.innerHTML = '<img src="' + 'images/8_bellset_key_8.svg' + '" width="' + cell.style.width + '" vertical-align="middle">';
469451
}
470452
}

0 commit comments

Comments
 (0)