Skip to content

Commit 905bc21

Browse files
committed
handle step pitch in music keyboard
1 parent fadf986 commit 905bc21

File tree

1 file changed

+34
-13
lines changed

1 file changed

+34
-13
lines changed

js/logo.js

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4514,32 +4514,50 @@ function Logo () {
45144514
}
45154515

45164516
if (that.pitchTimeMatrix.rowLabels.length > 0) {
4517-
if (last(that.pitchTimeMatrix.rowLabels) === 'hertz') {
4518-
var freq = pitchToFrequency(noteObj[0], noteObj[1], 0, that.keySignature[turtle]);
4519-
that.pitchTimeMatrix.rowLabels.push('hertz');
4520-
that.pitchTimeMatrix.rowArgs.push(parseInt(freq));
4521-
} else {
4522-
if (that.pitchTimeMatrix.rowLabels.length > 0) {
4517+
if (that.pitchTimeMatrix.rowLabels.length > 0) {
4518+
if (last(that.pitchTimeMatrix.rowLabels) === 'hertz') {
4519+
var freq = pitchToFrequency(noteObj[0], noteObj[1], 0, that.keySignature[turtle]);
4520+
that.pitchTimeMatrix.rowLabels.push('hertz');
4521+
that.pitchTimeMatrix.rowArgs.push(parseInt(freq));
4522+
} else {
45234523
if (SOLFEGENAMES1.indexOf(last(that.pitchTimeMatrix.rowLabels)) !== -1) {
45244524
that.pitchTimeMatrix.rowLabels.push(SOLFEGECONVERSIONTABLE[noteObj1[0]]);
45254525
} else {
45264526
that.pitchTimeMatrix.rowLabels.push(noteObj1[0]);
45274527
}
4528-
} else {
4529-
that.pitchTimeMatrix.rowLabels.push(noteObj1[0]);
4530-
}
45314528

4532-
that.pitchTimeMatrix.rowArgs.push(noteObj1[1]);
4533-
}
4529+
that.pitchTimeMatrix.rowArgs.push(noteObj1[1]);
4530+
}
4531+
} else {
4532+
that.pitchTimeMatrix.rowLabels.push(noteObj1[0]);
4533+
that.pitchTimeMatrix.rowArgs.push(noteObj1[1]);
4534+
}
45344535
}
45354536

45364537
that.previousNotePlayed[turtle] = that.lastNotePlayed[turtle];
45374538
that.lastNotePlayed[turtle] = [noteObj1[0] + noteObj1[1], 4];
45384539
} else if (that.inMusicKeyboard) {
45394540
if (that.drumStyle[turtle].length === 0) {
45404541
that.musicKeyboard.instruments.push(last(that.instrumentNames[turtle]));
4541-
that.musicKeyboard.noteNames.push(noteObj1[0]);
4542-
that.musicKeyboard.octaves.push(noteObj1[1]);
4542+
if (that.musicKeyboard.noteNames.length > 0) {
4543+
if (last(that.musicKeyboard.noteNames) === 'hertz') {
4544+
var freq = pitchToFrequency(noteObj[0], noteObj[1], 0, that.keySignature[turtle]);
4545+
that.musicKeyboard.noteNames.push('hertz');
4546+
that.musicKeyboard.octaves.push(parseInt(freq));
4547+
} else {
4548+
if (SOLFEGENAMES1.indexOf(last(that.musicKeyboard.noteNames)) !== -1) {
4549+
that.musicKeyboard.noteNames.push(SOLFEGECONVERSIONTABLE[noteObj1[0]]);
4550+
} else {
4551+
that.musicKeyboard.noteNames.push(noteObj1[0]);
4552+
}
4553+
4554+
that.musicKeyboard.octaves.push(noteObj1[1]);
4555+
}
4556+
} else {
4557+
that.musicKeyboard.noteNames.push(noteObj1[0]);
4558+
that.musicKeyboard.octaves.push(noteObj1[1]);
4559+
}
4560+
45434561
that.musicKeyboard.addRowBlock(blk);
45444562
that.lastNotePlayed[turtle] = [noteObj1[0] + noteObj1[1], 4];
45454563
}
@@ -7273,6 +7291,9 @@ function Logo () {
72737291
that.musicKeyboard.noteNames.push('hertz');
72747292
that.musicKeyboard.octaves.push(arg);
72757293
that.musicKeyboard.addRowBlock(blk);
7294+
// convert hertz to note/octave
7295+
var note = frequencyToPitch(arg);
7296+
that.lastNotePlayed[turtle] = [note[0] + note[1], 4];
72767297
} else if (that.inNoteBlock[turtle].length > 0) {
72777298

72787299
function addPitch(note, octave, cents, frequency, direction) {

0 commit comments

Comments
 (0)