Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src.csharp/AlphaTab/Core/TypeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,12 @@ public static string SubstringIndex(this string s, double startIndex, double end
return s.Substring((int) startIndex, (int) (endIndex - startIndex));
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string Join(this IList<string> s, string separator)
{
return string.Join(separator, s);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string ReplaceAll(this string s, string before, string after)
{
Expand Down
19 changes: 17 additions & 2 deletions src/model/Chord.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Staff } from '@src/model/Staff';

// TODO: rework model to specify for each finger
// on which frets they are placed.
// TODO: rework model to specify for each finger
// on which frets they are placed.

/**
* A chord definition.
Expand Down Expand Up @@ -51,4 +51,19 @@ export class Chord {
* Gets or sets whether the fingering is shown below the chord diagram.
*/
public showFingering: boolean = true;
/**
* Gets a unique id for this chord based on its properties.
*/
public get uniqueId(): string {
const properties = [
this.name,
this.firstFret.toString(),
this.strings.join(','),
this.barreFrets.join(','),
this.showDiagram.toString(),
this.showFingering.toString(),
this.showName.toString()
];
return properties.join('|');
}
}
10 changes: 5 additions & 5 deletions src/rendering/layout/ScoreLayout.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { StaveProfile } from '@src/StaveProfile';
import { Environment } from '@src/Environment';
import { Bar } from '@src/model/Bar';
import { Chord } from '@src/model/Chord';
import { Font, FontStyle, FontWeight } from '@src/model/Font';
import { Score } from '@src/model/Score';
import { Staff } from '@src/model/Staff';
Expand Down Expand Up @@ -209,15 +208,16 @@ export abstract class ScoreLayout {
if (notation.isNotationElementVisible(NotationElement.ChordDiagrams)) {
this.chordDiagrams = new ChordDiagramContainerGlyph(0, 0);
this.chordDiagrams.renderer = fakeBarRenderer;
let chords: Map<string, Chord> = new Map<string, Chord>();
let chordIds: Set<string> = new Set<string>();

for (let track of this.renderer.tracks!) {
for (let staff of track.staves) {
const sc = staff.chords;
if (sc) {
for (const [chordId, chord] of sc) {
if (!chords.has(chordId)) {
for (const [, chord] of sc) {
if (!chordIds.has(chord.uniqueId)) {
if (chord.showDiagram) {
chords.set(chordId, chord);
chordIds.add(chord.uniqueId);
this.chordDiagrams!.addChord(chord);
}
}
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions test/visualTests/features/EffectsAndAnnotations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ describe('EffectsAndAnnotationsTests', () => {
await VisualTestHelper.runVisualTest('effects-and-annotations/chords.gp');
});

it('chords-duplicates', async () => {
// This file was manually modified to contain 2 separate chords with the same details.
await VisualTestHelper.runVisualTest('effects-and-annotations/chords-duplicates.gp');
});

it('vibrato', async () => {
await VisualTestHelper.runVisualTest('effects-and-annotations/vibrato.gp');
});
Expand Down