@@ -1592,19 +1592,25 @@ class Singer {
15921592 ) {
15931593 match = false ;
15941594 } else {
1595- /**
1596- * @todo FIXME: This check assumes that the order of the pitch blocks in a chord are the same
1597- */
1598- for ( let i = 0 ; i < tur . singer . tieNotePitches . length ; i ++ ) {
1599- if (
1600- tur . singer . tieNotePitches [ i ] [ 0 ] !=
1601- tur . singer . notePitches [ last ( tur . singer . inNoteBlock ) ] [ i ] ||
1602- tur . singer . tieNotePitches [ i ] [ 1 ] !=
1603- tur . singer . noteOctaves [ last ( tur . singer . inNoteBlock ) ] [ i ]
1604- ) {
1605- match = false ;
1606- break ;
1607- }
1595+ // Compare tied chords in an order-independent way (pitch, octave, cents)
1596+ const normalizeChord = chord =>
1597+ chord . map ( p => `${ p [ 0 ] } :${ p [ 1 ] } :${ p [ 2 ] } ` ) . sort ( ) ;
1598+
1599+ const tiedChord = normalizeChord ( tur . singer . tieNotePitches ) ;
1600+
1601+ const currentChord = normalizeChord (
1602+ tur . singer . notePitches [ last ( tur . singer . inNoteBlock ) ] . map ( ( p , i ) => [
1603+ p ,
1604+ tur . singer . noteOctaves [ last ( tur . singer . inNoteBlock ) ] [ i ] ,
1605+ tur . singer . noteCents [ last ( tur . singer . inNoteBlock ) ] [ i ]
1606+ ] )
1607+ ) ;
1608+
1609+ if (
1610+ tiedChord . length !== currentChord . length ||
1611+ ! tiedChord . every ( ( v , i ) => v === currentChord [ i ] )
1612+ ) {
1613+ match = false ;
16081614 }
16091615 }
16101616
@@ -2054,8 +2060,9 @@ class Singer {
20542060 0 ,
20552061 null
20562062 ) ;
2057- const pitchNumber = getTemperament ( activity . logo . synth . inTemperament )
2058- . pitchNumber ;
2063+ const pitchNumber = getTemperament (
2064+ activity . logo . synth . inTemperament
2065+ ) . pitchNumber ;
20592066 const ratio = [ ] ;
20602067 const number = [ ] ;
20612068 const numerator = [ ] ;
0 commit comments