diff --git a/src/synth/chord-track.js b/src/synth/chord-track.js index 6e5a55d05..7cc76c1a3 100644 --- a/src/synth/chord-track.js +++ b/src/synth/chord-track.js @@ -284,8 +284,11 @@ ChordTrack.prototype.resolveChords = function (startTime, endTime) { firstBoom = true var type = thisPattern[p] var isBoom = type.indexOf('boom') >= 0 - // If we changed chords at a time when we're not expecting a bass note, then add an extra bass note in. - var newBass = !isBoom && p !== 0 && (!currentChordsExpanded[p-1] || currentChordsExpanded[p-1].boom !== currentChordsExpanded[p].boom) + // If we changed chords at a time when we're not expecting a bass note, then add an extra bass note in if the first thing in the pattern is a bass note. + var newBass = !isBoom && + p !== 0 && + thisPattern[0].indexOf('boom') >= 0 && + (!currentChordsExpanded[p-1] || currentChordsExpanded[p-1].boom !== currentChordsExpanded[p].boom) var pitches = resolvePitch(currentChordsExpanded[p], type, firstBoom, newBass) if (isBoom) firstBoom = false diff --git a/tests/synth/flattener.test.js b/tests/synth/flattener.test.js index 2b13dc639..0e678627b 100644 --- a/tests/synth/flattener.test.js +++ b/tests/synth/flattener.test.js @@ -2727,7 +2727,9 @@ describe("Audio flattener", function() { '%%MIDI chordprog 72\n' + '%%MIDI chordvol 23\n' + 'K:C\n' + - '"C"z4|"G7"z4|\n' + '"C"z4|"G7"z2z"C"z|\n' + + '%%MIDI gchord GHIHghih\n' + + '"C"z4|"G7"z2z"C"z|\n' var expectedChordArpeggio = { @@ -2875,7 +2877,16 @@ describe("Audio flattener", function() { }, { "cmd": "note", - "pitch": 74, + "pitch": 36, + "volume": 125, + "start": 1.75, + "duration": 0.125, + "gap": 0, + "instrument": 10 + }, + { + "cmd": "note", + "pitch": 67, "volume": 23, "start": 1.75, "duration": 0.125, @@ -2884,18 +2895,161 @@ describe("Audio flattener", function() { }, { "cmd": "note", - "pitch": 71, + "pitch": 64, "volume": 23, "start": 1.875, "duration": 0.125, "gap": 0, "instrument": 72 + }, + { + "cmd": "note", + "pitch": 48, + "volume": 23, + "start": 2, + "duration": 0.125, + "gap": 0, + "instrument": 72 + }, + { + "cmd": "note", + "pitch": 52, + "volume": 23, + "start": 2.125, + "duration": 0.125, + "gap": 0, + "instrument": 72 + }, + { + "cmd": "note", + "pitch": 55, + "volume": 23, + "start": 2.25, + "duration": 0.125, + "gap": 0, + "instrument": 72 + }, + { + "cmd": "note", + "pitch": 52, + "volume": 23, + "start": 2.375, + "duration": 0.125, + "gap": 0, + "instrument": 72 + }, + { + "cmd": "note", + "pitch": 60, + "volume": 23, + "start": 2.5, + "duration": 0.125, + "gap": 0, + "instrument": 72 + }, + { + "cmd": "note", + "pitch": 64, + "volume": 23, + "start": 2.625, + "duration": 0.125, + "gap": 0, + "instrument": 72 + }, + { + "cmd": "note", + "pitch": 67, + "volume": 23, + "start": 2.75, + "duration": 0.125, + "gap": 0, + "instrument": 72 + }, + { + "cmd": "note", + "pitch": 64, + "volume": 23, + "start": 2.875, + "duration": 0.125, + "gap": 0, + "instrument": 72 + }, + { + "cmd": "note", + "pitch": 55, + "volume": 23, + "start": 3, + "duration": 0.125, + "gap": 0, + "instrument": 72 + }, + { + "cmd": "note", + "pitch": 59, + "volume": 23, + "start": 3.125, + "duration": 0.125, + "gap": 0, + "instrument": 72 + }, + { + "cmd": "note", + "pitch": 62, + "volume": 23, + "start": 3.25, + "duration": 0.125, + "gap": 0, + "instrument": 72 + }, + { + "cmd": "note", + "pitch": 59, + "volume": 23, + "start": 3.375, + "duration": 0.125, + "gap": 0, + "instrument": 72 + }, + { + "cmd": "note", + "pitch": 67, + "volume": 23, + "start": 3.5, + "duration": 0.125, + "gap": 0, + "instrument": 72 + }, + { + "cmd": "note", + "pitch": 71, + "volume": 23, + "start": 3.625, + "duration": 0.125, + "gap": 0, + "instrument": 72 + }, + { + "cmd": "note", + "pitch": 67, + "volume": 23, + "start": 3.75, + "duration": 0.125, + "gap": 0, + "instrument": 72 + }, + { + "cmd": "note", + "pitch": 64, + "volume": 23, + "start": 3.875, + "duration": 0.125, + "gap": 0, + "instrument": 72 } ] ], - "totalDuration": 2 + "totalDuration": 4 } - ////////////////////////////////////////////////////////// var abcChordSwing = 'X: 1\n' +