diff --git a/packages/alphatab/src/generated/model/RenderStylesheetSerializer.ts b/packages/alphatab/src/generated/model/RenderStylesheetSerializer.ts index c111ed9ef..4ac08c97c 100644 --- a/packages/alphatab/src/generated/model/RenderStylesheetSerializer.ts +++ b/packages/alphatab/src/generated/model/RenderStylesheetSerializer.ts @@ -43,6 +43,7 @@ export class RenderStylesheetSerializer { m.set(k.toString(), v); } } + o.set("globaldisplaychorddiagramsinscore", obj.globalDisplayChordDiagramsInScore); o.set("singletracktracknamepolicy", obj.singleTrackTrackNamePolicy as number); o.set("multitracktracknamepolicy", obj.multiTrackTrackNamePolicy as number); o.set("firstsystemtracknamemode", obj.firstSystemTrackNameMode as number); @@ -89,6 +90,9 @@ export class RenderStylesheetSerializer { obj.perTrackChordDiagramsOnTop!.set(Number.parseInt(k), v as boolean); }); return true; + case "globaldisplaychorddiagramsinscore": + obj.globalDisplayChordDiagramsInScore = v! as boolean; + return true; case "singletracktracknamepolicy": obj.singleTrackTrackNamePolicy = JsonHelper.parseEnum(v, TrackNamePolicy)!; return true; diff --git a/packages/alphatab/src/importer/BinaryStylesheet.ts b/packages/alphatab/src/importer/BinaryStylesheet.ts index 8fe7370c0..ace358467 100644 --- a/packages/alphatab/src/importer/BinaryStylesheet.ts +++ b/packages/alphatab/src/importer/BinaryStylesheet.ts @@ -150,6 +150,9 @@ export class BinaryStylesheet { case 'Global/DrawChords': score.stylesheet.globalDisplayChordDiagramsOnTop = value as boolean; break; + case 'System/drawChordInScore': + score.stylesheet.globalDisplayChordDiagramsInScore = value as boolean; + break; case 'System/showTrackNameSingle': if (!(value as boolean)) { score.stylesheet.singleTrackTrackNamePolicy = TrackNamePolicy.Hidden; @@ -460,6 +463,11 @@ export class BinaryStylesheet { score.stylesheet.globalDisplayChordDiagramsOnTop, DataType.Boolean ); + binaryStylesheet.addValue( + 'System/drawChordInScore', + score.stylesheet.globalDisplayChordDiagramsInScore, + DataType.Boolean + ); switch (score.stylesheet.singleTrackTrackNamePolicy) { case TrackNamePolicy.Hidden: diff --git a/packages/alphatab/src/importer/MusicXmlImporter.ts b/packages/alphatab/src/importer/MusicXmlImporter.ts index 83add730d..51c1ef281 100644 --- a/packages/alphatab/src/importer/MusicXmlImporter.ts +++ b/packages/alphatab/src/importer/MusicXmlImporter.ts @@ -1362,6 +1362,15 @@ export class MusicXmlImporter extends ScoreImporter { chord.name += degreeParenthesis ? `(${degree})` : degree; } + if (element.getAttribute('print-frame', 'no') === 'yes') { + chord.showDiagram = true; + this._score.stylesheet.globalDisplayChordDiagramsInScore = true; + } + + if (element.getAttribute('print-object', 'yes') === 'yes') { + chord.showDiagram = true; + } + if (this._nextBeatChord === null) { this._nextBeatChord = chord; } @@ -2703,8 +2712,10 @@ export class MusicXmlImporter extends ScoreImporter { } private static readonly _b4Value = 71; - private _estimateBeamDirection(note: Note): BeamDirection { - return note.calculateRealValue(false, false) < MusicXmlImporter._b4Value ? BeamDirection.Down : BeamDirection.Up; + private _estimateBeamDirection(note: Note): BeamDirection { + return note.calculateRealValue(false, false) < MusicXmlImporter._b4Value + ? BeamDirection.Down + : BeamDirection.Up; } private _parseNoteHead(element: XmlNode, note: Note, beatDuration: Duration, beamDirection: BeamDirection) { @@ -3297,7 +3308,7 @@ export class MusicXmlImporter extends ScoreImporter { } } - private _parseArpeggiate(element: XmlNode, beat: Beat) { + private _parseArpeggiate(element: XmlNode, beat: Beat) { const direction = element.getAttribute('direction', 'down'); switch (direction) { case 'down': @@ -3607,7 +3618,7 @@ export class MusicXmlImporter extends ScoreImporter { } } - private _parseTied(element: XmlNode, note: Note, staff: Staff): void { + private _parseTied(element: XmlNode, note: Note, staff: Staff): void { const type = element.getAttribute('type'); const number = element.getAttribute('number', ''); diff --git a/packages/alphatab/src/importer/alphaTex/AlphaTex1LanguageDefinitions.ts b/packages/alphatab/src/importer/alphaTex/AlphaTex1LanguageDefinitions.ts index 273e26bed..1461dd28e 100644 --- a/packages/alphatab/src/importer/alphaTex/AlphaTex1LanguageDefinitions.ts +++ b/packages/alphatab/src/importer/alphaTex/AlphaTex1LanguageDefinitions.ts @@ -3,19 +3,11 @@ import type { ArgumentListParseTypesMode } from '@coderline/alphatab/importer/al /** * @target web */ -type SimpleAlphaTexParameterDefinition = [ - AlphaTexNodeType[], - ArgumentListParseTypesMode -] | [ - AlphaTexNodeType[], - ArgumentListParseTypesMode, - string[] -] | [ - AlphaTexNodeType[], - ArgumentListParseTypesMode, - string[] | null, - string[] -] | null; +type SimpleAlphaTexParameterDefinition = + | [AlphaTexNodeType[], ArgumentListParseTypesMode] + | [AlphaTexNodeType[], ArgumentListParseTypesMode, string[]] + | [AlphaTexNodeType[], ArgumentListParseTypesMode, string[] | null, string[]] + | null; /** * @record * @internal @@ -45,41 +37,38 @@ export class AlphaTex1LanguageDefinitions { return { expectedTypes: new Set(simple[0]), parseMode: simple[1], - allowedValues: simple.length > 2 && simple[2] && simple[2]!.length > 0 ? new Set(simple[2]!) : undefined, - reservedIdentifiers: simple.length > 3 && simple[3] && simple[3]!.length > 0 ? new Set(simple[3]!) : undefined + allowedValues: + simple.length > 2 && simple[2] && simple[2]!.length > 0 ? new Set(simple[2]!) : undefined, + reservedIdentifiers: + simple.length > 3 && simple[3] && simple[3]!.length > 0 ? new Set(simple[3]!) : undefined }; } - private static _simple(signature: (SimpleAlphaTexParameterDefinition | null)[][] | null): AlphaTexSignatureDefinition[] | null { + private static _simple( + signature: (SimpleAlphaTexParameterDefinition | null)[][] | null + ): AlphaTexSignatureDefinition[] | null { if (signature == null) { return null; } - return signature.map(s => ({ - isStrict: s.length > 0 && s[0] === null, - parameters: s.map(AlphaTex1LanguageDefinitions._param).filter(p => p !== null) - }) as AlphaTexSignatureDefinition); + return signature.map( + s => + ({ + isStrict: s.length > 0 && s[0] === null, + parameters: s.map(AlphaTex1LanguageDefinitions._param).filter(p => p !== null) + }) as AlphaTexSignatureDefinition + ); } - private static _metaProps(props: [ - string, - [ - string, - SimpleAlphaTexParameterDefinition[][] | null - ][] | null - ][]) { - return new Map(props.map(p => [ - p[0], - p[1] === null ? null : new Map(p[1]!.map(p => [p[0], AlphaTex1LanguageDefinitions._simple(p[1])])) - ])); + private static _metaProps(props: [string, [string, SimpleAlphaTexParameterDefinition[][] | null][] | null][]) { + return new Map( + props.map(p => [ + p[0], + p[1] === null ? null : new Map(p[1]!.map(p => [p[0], AlphaTex1LanguageDefinitions._simple(p[1])])) + ]) + ); } - private static _props(props: [ - string, - SimpleAlphaTexParameterDefinition[][] | null - ][]) { + private static _props(props: [string, SimpleAlphaTexParameterDefinition[][] | null][]) { return new Map(props.map(p => [p[0], AlphaTex1LanguageDefinitions._simple(p[1])])); } - private static _signatures(signatures: [ - string, - SimpleAlphaTexParameterDefinition[][] | null - ][]) { + private static _signatures(signatures: [string, SimpleAlphaTexParameterDefinition[][] | null][]) { return new Map(signatures.map(s => [s[0], AlphaTex1LanguageDefinitions._simple(s[1])])); } // The following definitions age auto-generated from the central definitions in @@ -87,138 +76,517 @@ export class AlphaTex1LanguageDefinitions { // to reduce code size, the parameter types are specified as number values and then // translated inside AlphaTex1LanguageDefinitions._signatures during runtime public static readonly scoreMetaDataSignatures = AlphaTex1LanguageDefinitions._signatures([ - ["title", [[[[17, 10], 0], [[17], 1], [[10, 17], 1, ["left", "center", "right"]]]]], - ["subtitle", [[[[17, 10], 0], [[17], 1], [[10, 17], 1, ["left", "center", "right"]]]]], - ["artist", [[[[17, 10], 0], [[17], 1], [[10, 17], 1, ["left", "center", "right"]]]]], - ["album", [[[[17, 10], 0], [[17], 1], [[10, 17], 1, ["left", "center", "right"]]]]], - ["words", [[[[17, 10], 0], [[17], 1], [[10, 17], 1, ["left", "center", "right"]]]]], - ["music", [[[[17, 10], 0], [[17], 1], [[10, 17], 1, ["left", "center", "right"]]]]], - ["wordsandmusic", [[[[17], 0], [[10, 17], 1, ["left", "center", "right"]]]]], - ["copyright", [[[[17, 10], 0], [[17], 1], [[10, 17], 1, ["left", "center", "right"]]]]], - ["copyright2", [[[[17], 0], [[10, 17], 1, ["left", "center", "right"]]]]], - ["instructions", [[[[17, 10], 0]]]], - ["notices", [[[[17, 10], 0]]]], - ["tab", [[[[17, 10], 0], [[17], 1], [[10, 17], 1, ["left", "center", "right"]]]]], - ["systemslayout", [[[[16], 5]]]], - ["defaultsystemslayout", [[[[16], 0]]]], - ["showdynamics", null], - ["hidedynamics", null], - ["usesystemsignseparator", null], - ["multibarrest", null], - ["bracketextendmode", [[[[10, 17], 0, ["nobrackets", "groupstaves", "groupsimilarinstruments"]]]]], - ["singletracktracknamepolicy", [[[[10, 17], 0, ["hidden", "firstsystem", "allsystems"]]]]], - ["multitracktracknamepolicy", [[[[10, 17], 0, ["hidden", "firstsystem", "allsystems"]]]]], - ["firstsystemtracknamemode", [[[[10, 17], 0, ["fullname", "shortname"]]]]], - ["othersystemstracknamemode", [[[[10, 17], 0, ["fullname", "shortname"]]]]], - ["firstsystemtracknameorientation", [[[[10, 17], 0, ["horizontal", "vertical"]]]]], - ["othersystemstracknameorientation", [[[[10, 17], 0, ["horizontal", "vertical"]]]]], - ["extendbarlines", null] + [ + 'title', + [ + [ + [[17, 10], 0], + [[17], 1], + [[10, 17], 1, ['left', 'center', 'right']] + ] + ] + ], + [ + 'subtitle', + [ + [ + [[17, 10], 0], + [[17], 1], + [[10, 17], 1, ['left', 'center', 'right']] + ] + ] + ], + [ + 'artist', + [ + [ + [[17, 10], 0], + [[17], 1], + [[10, 17], 1, ['left', 'center', 'right']] + ] + ] + ], + [ + 'album', + [ + [ + [[17, 10], 0], + [[17], 1], + [[10, 17], 1, ['left', 'center', 'right']] + ] + ] + ], + [ + 'words', + [ + [ + [[17, 10], 0], + [[17], 1], + [[10, 17], 1, ['left', 'center', 'right']] + ] + ] + ], + [ + 'music', + [ + [ + [[17, 10], 0], + [[17], 1], + [[10, 17], 1, ['left', 'center', 'right']] + ] + ] + ], + [ + 'wordsandmusic', + [ + [ + [[17], 0], + [[10, 17], 1, ['left', 'center', 'right']] + ] + ] + ], + [ + 'copyright', + [ + [ + [[17, 10], 0], + [[17], 1], + [[10, 17], 1, ['left', 'center', 'right']] + ] + ] + ], + [ + 'copyright2', + [ + [ + [[17], 0], + [[10, 17], 1, ['left', 'center', 'right']] + ] + ] + ], + ['instructions', [[[[17, 10], 0]]]], + ['notices', [[[[17, 10], 0]]]], + [ + 'tab', + [ + [ + [[17, 10], 0], + [[17], 1], + [[10, 17], 1, ['left', 'center', 'right']] + ] + ] + ], + ['systemslayout', [[[[16], 5]]]], + ['defaultsystemslayout', [[[[16], 0]]]], + ['showdynamics', null], + ['hidedynamics', null], + ['usesystemsignseparator', null], + ['multibarrest', null], + ['bracketextendmode', [[[[10, 17], 0, ['nobrackets', 'groupstaves', 'groupsimilarinstruments']]]]], + ['singletracktracknamepolicy', [[[[10, 17], 0, ['hidden', 'firstsystem', 'allsystems']]]]], + ['multitracktracknamepolicy', [[[[10, 17], 0, ['hidden', 'firstsystem', 'allsystems']]]]], + ['firstsystemtracknamemode', [[[[10, 17], 0, ['fullname', 'shortname']]]]], + ['othersystemstracknamemode', [[[[10, 17], 0, ['fullname', 'shortname']]]]], + ['firstsystemtracknameorientation', [[[[10, 17], 0, ['horizontal', 'vertical']]]]], + ['othersystemstracknameorientation', [[[[10, 17], 0, ['horizontal', 'vertical']]]]], + ['extendbarlines', null], + ['chorddiagramsinscore', [[[[10], 1, ['true', 'false']]]]] ]); public static readonly staffMetaDataSignatures = AlphaTex1LanguageDefinitions._signatures([ - ["tuning", [[[[10, 17], 0, ["piano", "none", "voice"]]], [[[10, 17], 5]]]], - ["chord", [[[[17, 10], 0], [[10, 17, 16], 5]]]], - ["capo", [[[[16], 0]]]], - ["lyrics", [[[[17], 0]], [[[16], 0], [[17], 0]]]], - ["articulation", [[[[10], 0, ["defaults"]]], [[[17, 10], 0], [[16], 0]]]], - ["displaytranspose", [[[[16], 0]]]], - ["transpose", [[[[16], 0]]]], - ["instrument", [[[[16], 0]], [[[17, 10], 0]], [[[10], 0, ["percussion"]]]]] + ['tuning', [[[[10, 17], 0, ['piano', 'none', 'voice']]], [[[10, 17], 5]]]], + [ + 'chord', + [ + [ + [[17, 10], 0], + [[10, 17, 16], 5] + ] + ] + ], + ['capo', [[[[16], 0]]]], + [ + 'lyrics', + [ + [[[17], 0]], + [ + [[16], 0], + [[17], 0] + ] + ] + ], + [ + 'articulation', + [ + [[[10], 0, ['defaults']]], + [ + [[17, 10], 0], + [[16], 0] + ] + ] + ], + ['displaytranspose', [[[[16], 0]]]], + ['transpose', [[[[16], 0]]]], + ['instrument', [[[[16], 0]], [[[17, 10], 0]], [[[10], 0, ['percussion']]]]] ]); public static readonly structuralMetaDataSignatures = AlphaTex1LanguageDefinitions._signatures([ - ["track", [[[[17], 1], [[17], 1]]]], - ["staff", null], - ["voice", null] + [ + 'track', + [ + [ + [[17], 1], + [[17], 1] + ] + ] + ], + ['staff', null], + ['voice', null] ]); public static readonly barMetaDataSignatures = AlphaTex1LanguageDefinitions._signatures([ - ["ts", [[[[10, 17], 0, ["common"]]], [[[16], 0], [[16], 0]]]], - ["ro", null], - ["rc", [[[[16], 0]]]], - ["ae", [[[[16, 13], 4]]]], - ["ks", [[[[10, 17], 0, ["cb", "gb", "db", "ab", "eb", "bb", "f", "c", "g", "d", "a", "e", "b", "f#", "c#", "cbmajor", "abminor", "gbmajor", "ebminor", "dbmajor", "bbminor", "abmajor", "fminor", "ebmajor", "cminor", "bbmajor", "gminor", "fmajor", "dminor", "cmajor", "aminor", "gmajor", "eminor", "dmajor", "bminor", "amajor", "f#minor", "emajor", "c#minor", "bmajor", "g#minor", "f#major", "d#minor", "f#", "c#major", "a#minor", "c#"]]]]], - ["clef", [[[[10, 16, 17], 0, ["neutral", "c3", "c4", "f4", "g2", "n", "alto", "tenor", "bass", "treble"]]]]], - ["ottava", [[[[10, 17], 0, ["15ma", "8va", "regular", "8vb", "15mb", "15ma", "8va", "8vb", "15mb"]]]]], - ["tempo", [[[[16], 2], [[17], 1]], [null, [[16], 2], [[17], 0], [[16], 1], [[10], 1, ["hide"]]]]], - ["tf", [[[[10, 16, 17], 0, ["none", "triplet16th", "triplet8th", "dotted16th", "dotted8th", "scottish16th", "scottish8th", "none", "no", "notripletfeel", "t16", "triplet-16th", "t8", "triplet-8th", "d16", "dotted-16th", "d8", "dotted-8th", "s16", "scottish-16th", "s8", "scottish-8th"]]]]], - ["ac", null], - ["section", [[[[17, 10], 0]], [[[17, 10], 0], [[17, 10], 0, null, ["x", "-", "r"]]]]], - ["jump", [[[[10, 17], 0, ["fine", "segno", "segnosegno", "coda", "doublecoda", "dacapo", "dacapoalcoda", "dacapoaldoublecoda", "dacapoalfine", "dalsegno", "dalsegnoalcoda", "dalsegnoaldoublecoda", "dalsegnoalfine", "dalsegnosegno", "dalsegnosegnoalcoda", "dalsegnosegnoaldoublecoda", "dalsegnosegnoalfine", "dacoda", "dadoublecoda"]]]]], - ["ft", null], - ["simile", [[[[10, 17], 0, ["none", "simple", "firstofdouble", "secondofdouble"]]]]], - ["barlineleft", [[[[10, 17], 0, ["automatic", "dashed", "dotted", "heavy", "heavyheavy", "heavylight", "lightheavy", "lightlight", "none", "regular", "short", "tick"]]]]], - ["barlineright", [[[[10, 17], 0, ["automatic", "dashed", "dotted", "heavy", "heavyheavy", "heavylight", "lightheavy", "lightlight", "none", "regular", "short", "tick"]]]]], - ["scale", [[[[16], 2]]]], - ["width", [[[[16], 2]]]], - ["sync", [[[[16], 0], [[16], 0], [[16], 0], [[16], 3]]]], - ["accidentals", [[[[10, 17], 0, ["auto", "explicit"]]]]], - ["spd", [[[[16], 2]]]], - ["sph", [[[[16], 2]]]], - ["spu", [[[[16], 2]]]], - ["db", null], - ["voicemode", [[[[10, 17], 0, ["staffwise", "barwise"]]]]] + [ + 'ts', + [ + [[[10, 17], 0, ['common']]], + [ + [[16], 0], + [[16], 0] + ] + ] + ], + ['ro', null], + ['rc', [[[[16], 0]]]], + ['ae', [[[[16, 13], 4]]]], + [ + 'ks', + [ + [ + [ + [10, 17], + 0, + [ + 'cb', + 'gb', + 'db', + 'ab', + 'eb', + 'bb', + 'f', + 'c', + 'g', + 'd', + 'a', + 'e', + 'b', + 'f#', + 'c#', + 'cbmajor', + 'abminor', + 'gbmajor', + 'ebminor', + 'dbmajor', + 'bbminor', + 'abmajor', + 'fminor', + 'ebmajor', + 'cminor', + 'bbmajor', + 'gminor', + 'fmajor', + 'dminor', + 'cmajor', + 'aminor', + 'gmajor', + 'eminor', + 'dmajor', + 'bminor', + 'amajor', + 'f#minor', + 'emajor', + 'c#minor', + 'bmajor', + 'g#minor', + 'f#major', + 'd#minor', + 'f#', + 'c#major', + 'a#minor', + 'c#' + ] + ] + ] + ] + ], + ['clef', [[[[10, 16, 17], 0, ['neutral', 'c3', 'c4', 'f4', 'g2', 'n', 'alto', 'tenor', 'bass', 'treble']]]]], + ['ottava', [[[[10, 17], 0, ['15ma', '8va', 'regular', '8vb', '15mb', '15ma', '8va', '8vb', '15mb']]]]], + [ + 'tempo', + [ + [ + [[16], 2], + [[17], 1] + ], + [null, [[16], 2], [[17], 0], [[16], 1], [[10], 1, ['hide']]] + ] + ], + [ + 'tf', + [ + [ + [ + [10, 16, 17], + 0, + [ + 'none', + 'triplet16th', + 'triplet8th', + 'dotted16th', + 'dotted8th', + 'scottish16th', + 'scottish8th', + 'none', + 'no', + 'notripletfeel', + 't16', + 'triplet-16th', + 't8', + 'triplet-8th', + 'd16', + 'dotted-16th', + 'd8', + 'dotted-8th', + 's16', + 'scottish-16th', + 's8', + 'scottish-8th' + ] + ] + ] + ] + ], + ['ac', null], + [ + 'section', + [ + [[[17, 10], 0]], + [ + [[17, 10], 0], + [[17, 10], 0, null, ['x', '-', 'r']] + ] + ] + ], + [ + 'jump', + [ + [ + [ + [10, 17], + 0, + [ + 'fine', + 'segno', + 'segnosegno', + 'coda', + 'doublecoda', + 'dacapo', + 'dacapoalcoda', + 'dacapoaldoublecoda', + 'dacapoalfine', + 'dalsegno', + 'dalsegnoalcoda', + 'dalsegnoaldoublecoda', + 'dalsegnoalfine', + 'dalsegnosegno', + 'dalsegnosegnoalcoda', + 'dalsegnosegnoaldoublecoda', + 'dalsegnosegnoalfine', + 'dacoda', + 'dadoublecoda' + ] + ] + ] + ] + ], + ['ft', null], + ['simile', [[[[10, 17], 0, ['none', 'simple', 'firstofdouble', 'secondofdouble']]]]], + [ + 'barlineleft', + [ + [ + [ + [10, 17], + 0, + [ + 'automatic', + 'dashed', + 'dotted', + 'heavy', + 'heavyheavy', + 'heavylight', + 'lightheavy', + 'lightlight', + 'none', + 'regular', + 'short', + 'tick' + ] + ] + ] + ] + ], + [ + 'barlineright', + [ + [ + [ + [10, 17], + 0, + [ + 'automatic', + 'dashed', + 'dotted', + 'heavy', + 'heavyheavy', + 'heavylight', + 'lightheavy', + 'lightlight', + 'none', + 'regular', + 'short', + 'tick' + ] + ] + ] + ] + ], + ['scale', [[[[16], 2]]]], + ['width', [[[[16], 2]]]], + [ + 'sync', + [ + [ + [[16], 0], + [[16], 0], + [[16], 0], + [[16], 3] + ] + ] + ], + ['accidentals', [[[[10, 17], 0, ['auto', 'explicit']]]]], + ['spd', [[[[16], 2]]]], + ['sph', [[[[16], 2]]]], + ['spu', [[[[16], 2]]]], + ['db', null], + ['voicemode', [[[[10, 17], 0, ['staffwise', 'barwise']]]]] ]); public static readonly metaDataProperties = AlphaTex1LanguageDefinitions._metaProps([ - ["track", [["color", [[[[17], 0]]]], ["systemslayout", [[[[16], 5]]]], ["defaultsystemslayout", [[[[16], 0]]]], ["solo", null], ["mute", null], ["volume", [[[[16], 0]]]], ["balance", [[[[16], 0]]]], ["instrument", [[[[16], 0]], [[[17, 10], 0]], [[[10], 0, ["percussion"]]]]], ["bank", [[[[16], 0]]]], ["multibarrest", null]]], - ["staff", [["score", [[[[16], 1]]]], ["tabs", null], ["slash", null], ["numbered", null]]], - ["voice", null], - ["title", null], - ["subtitle", null], - ["artist", null], - ["album", null], - ["words", null], - ["music", null], - ["wordsandmusic", null], - ["copyright", null], - ["copyright2", null], - ["instructions", null], - ["notices", null], - ["tab", null], - ["systemslayout", null], - ["defaultsystemslayout", null], - ["showdynamics", null], - ["hidedynamics", null], - ["usesystemsignseparator", null], - ["multibarrest", null], - ["bracketextendmode", null], - ["singletracktracknamepolicy", null], - ["multitracktracknamepolicy", null], - ["firstsystemtracknamemode", null], - ["othersystemstracknamemode", null], - ["firstsystemtracknameorientation", null], - ["othersystemstracknameorientation", null], - ["extendbarlines", null], - ["tuning", [["hide", null], ["label", [[[[17], 0]]]]]], - ["chord", [["firstfret", [[[[16], 0]]]], ["barre", [[[[16], 5]]]], ["showdiagram", [[], [[[17], 0, ["true", "false"]]], [[[10], 0, ["true", "false"]]], [[[16], 0, ["1", "0"]]]]], ["showfingering", [[], [[[17], 0, ["true", "false"]]], [[[10], 0, ["true", "false"]]], [[[16], 0, ["1", "0"]]]]], ["showname", [[], [[[17], 0, ["true", "false"]]], [[[10], 0, ["true", "false"]]], [[[16], 0, ["1", "0"]]]]]]], - ["capo", null], - ["lyrics", null], - ["articulation", null], - ["displaytranspose", null], - ["transpose", null], - ["instrument", null], - ["ts", null], - ["ro", null], - ["rc", null], - ["ae", null], - ["ks", null], - ["clef", null], - ["ottava", null], - ["tempo", null], - ["tf", null], - ["ac", null], - ["section", null], - ["jump", null], - ["ft", null], - ["simile", null], - ["barlineleft", null], - ["barlineright", null], - ["scale", null], - ["width", null], - ["sync", null], - ["accidentals", null], - ["spd", null], - ["sph", null], - ["spu", null], - ["db", null], - ["voicemode", null] + [ + 'track', + [ + ['color', [[[[17], 0]]]], + ['systemslayout', [[[[16], 5]]]], + ['defaultsystemslayout', [[[[16], 0]]]], + ['solo', null], + ['mute', null], + ['volume', [[[[16], 0]]]], + ['balance', [[[[16], 0]]]], + ['instrument', [[[[16], 0]], [[[17, 10], 0]], [[[10], 0, ['percussion']]]]], + ['bank', [[[[16], 0]]]], + ['multibarrest', null] + ] + ], + [ + 'staff', + [ + ['score', [[[[16], 1]]]], + ['tabs', null], + ['slash', null], + ['numbered', null] + ] + ], + ['voice', null], + ['title', null], + ['subtitle', null], + ['artist', null], + ['album', null], + ['words', null], + ['music', null], + ['wordsandmusic', null], + ['copyright', null], + ['copyright2', null], + ['instructions', null], + ['notices', null], + ['tab', null], + ['systemslayout', null], + ['defaultsystemslayout', null], + ['showdynamics', null], + ['hidedynamics', null], + ['usesystemsignseparator', null], + ['multibarrest', null], + ['bracketextendmode', null], + ['singletracktracknamepolicy', null], + ['multitracktracknamepolicy', null], + ['firstsystemtracknamemode', null], + ['othersystemstracknamemode', null], + ['firstsystemtracknameorientation', null], + ['othersystemstracknameorientation', null], + ['extendbarlines', null], + ['chorddiagramsinscore', null], + [ + 'tuning', + [ + ['hide', null], + ['label', [[[[17], 0]]]] + ] + ], + [ + 'chord', + [ + ['firstfret', [[[[16], 0]]]], + ['barre', [[[[16], 5]]]], + [ + 'showdiagram', + [[], [[[17], 0, ['true', 'false']]], [[[10], 0, ['true', 'false']]], [[[16], 0, ['1', '0']]]] + ], + [ + 'showfingering', + [[], [[[17], 0, ['true', 'false']]], [[[10], 0, ['true', 'false']]], [[[16], 0, ['1', '0']]]] + ], + [ + 'showname', + [[], [[[17], 0, ['true', 'false']]], [[[10], 0, ['true', 'false']]], [[[16], 0, ['1', '0']]]] + ] + ] + ], + ['capo', null], + ['lyrics', null], + ['articulation', null], + ['displaytranspose', null], + ['transpose', null], + ['instrument', null], + ['ts', null], + ['ro', null], + ['rc', null], + ['ae', null], + ['ks', null], + ['clef', null], + ['ottava', null], + ['tempo', null], + ['tf', null], + ['ac', null], + ['section', null], + ['jump', null], + ['ft', null], + ['simile', null], + ['barlineleft', null], + ['barlineright', null], + ['scale', null], + ['width', null], + ['sync', null], + ['accidentals', null], + ['spd', null], + ['sph', null], + ['spu', null], + ['db', null], + ['voicemode', null] ]); public static readonly metaDataSignatures = [ AlphaTex1LanguageDefinitions.scoreMetaDataSignatures, @@ -227,100 +595,347 @@ export class AlphaTex1LanguageDefinitions { AlphaTex1LanguageDefinitions.barMetaDataSignatures ]; public static readonly durationChangeProperties = AlphaTex1LanguageDefinitions._props([ - ["tu", [[[[16], 0, ["3", "5", "6", "7", "9", "10", "12"]]], [[[16], 0], [[16], 0]]]] + [ + 'tu', + [ + [[[16], 0, ['3', '5', '6', '7', '9', '10', '12']]], + [ + [[16], 0], + [[16], 0] + ] + ] + ] ]); public static readonly beatProperties = AlphaTex1LanguageDefinitions._props([ - ["f", null], - ["fo", null], - ["vs", null], - ["v", null], - ["vw", null], - ["s", null], - ["p", null], - ["tt", null], - ["d", null], - ["dd", null], - ["su", null], - ["sd", null], - ["cre", null], - ["dec", null], - ["spd", null], - ["sph", null], - ["spu", null], - ["spe", null], - ["slashed", null], - ["ds", null], - ["glpf", null], - ["glpt", null], - ["waho", null], - ["wahc", null], - ["legatoorigin", null], - ["timer", null], - ["tu", [[[[16], 0, ["3", "5", "6", "7", "9", "10", "12"]]], [[[16], 0], [[16], 0]]]], - ["txt", [[[[17, 10], 0]]]], - ["lyrics", [[[[17], 0]], [[[16], 0], [[17], 0]]]], - ["tb", [[[[16], 5]], [[[10, 17], 0, ["custom", "dive", "dip", "hold", "predive", "predivedive"]], [[16], 5]], [[[10, 17], 0, ["default", "gradual", "fast"]], [[16], 5]], [[[10, 17], 0, ["custom", "dive", "dip", "hold", "predive", "predivedive"]], [[10, 17], 0, ["default", "gradual", "fast"]], [[16], 5]]]], - ["tbe", [[[[16], 5]], [[[10, 17], 0, ["custom", "dive", "dip", "hold", "predive", "predivedive"]], [[16], 5]], [[[10, 17], 0, ["default", "gradual", "fast"]], [[16], 5]], [[[10, 17], 0, ["custom", "dive", "dip", "hold", "predive", "predivedive"]], [[10, 17], 0, ["default", "gradual", "fast"]], [[16], 5]]]], - ["bu", [[[[16], 1]]]], - ["bd", [[[[16], 1]]]], - ["au", [[[[16], 1]]]], - ["ad", [[[[16], 1]]]], - ["ch", [[[[17, 10], 0]]]], - ["gr", [[[[10, 17], 1, ["onbeat", "beforebeat", "bendgrace", "ob", "bb", "b"]]]]], - ["dy", [[[[10, 17], 0, ["ppp", "pp", "p", "mp", "mf", "f", "ff", "fff", "pppp", "ppppp", "pppppp", "ffff", "fffff", "ffffff", "sf", "sfp", "sfpp", "fp", "rf", "rfz", "sfz", "sffz", "fz", "n", "pf", "sfzp"]]]]], - ["tempo", [[[[16], 0], [[10], 1, ["hide"]]], [[[16], 0], [[17], 0], [[10], 1, ["hide"]]]]], - ["volume", [[[[16], 0]]]], - ["balance", [[[[16], 0]]]], - ["tp", [[[[16], 0, ["8", "16", "32"]]]]], - ["barre", [[[[16], 0], [[10, 17], 1, ["full", "half"]]]]], - ["rasg", [[[[10, 17], 0, ["ii", "mi", "miitriplet", "miianapaest", "pmptriplet", "pmpanapaest", "peitriplet", "peianapaest", "paitriplet", "paianapaest", "amitriplet", "amianapaest", "ppp", "amii", "amip", "eami", "eamii", "peami"]]]]], - ["ot", [[[[10, 17], 0, ["15ma", "8va", "regular", "8vb", "15mb", "15ma", "8va", "8vb", "15mb"]]]]], - ["instrument", [[[[16], 0]], [[[17, 10], 0]], [[[10], 0, ["percussion"]]]]], - ["bank", [[[[16], 0]]]], - ["fermata", [[[[10, 17], 0, ["short", "medium", "long"]], [[16], 3]]]], - ["beam", [[[[10, 17], 0, ["invert", "up", "down", "auto", "split", "merge", "splitsecondary"]]]]] + ['f', null], + ['fo', null], + ['vs', null], + ['v', null], + ['vw', null], + ['s', null], + ['p', null], + ['tt', null], + ['d', null], + ['dd', null], + ['su', null], + ['sd', null], + ['cre', null], + ['dec', null], + ['spd', null], + ['sph', null], + ['spu', null], + ['spe', null], + ['slashed', null], + ['ds', null], + ['glpf', null], + ['glpt', null], + ['waho', null], + ['wahc', null], + ['legatoorigin', null], + ['timer', null], + [ + 'tu', + [ + [[[16], 0, ['3', '5', '6', '7', '9', '10', '12']]], + [ + [[16], 0], + [[16], 0] + ] + ] + ], + ['txt', [[[[17, 10], 0]]]], + [ + 'lyrics', + [ + [[[17], 0]], + [ + [[16], 0], + [[17], 0] + ] + ] + ], + [ + 'tb', + [ + [[[16], 5]], + [ + [[10, 17], 0, ['custom', 'dive', 'dip', 'hold', 'predive', 'predivedive']], + [[16], 5] + ], + [ + [[10, 17], 0, ['default', 'gradual', 'fast']], + [[16], 5] + ], + [ + [[10, 17], 0, ['custom', 'dive', 'dip', 'hold', 'predive', 'predivedive']], + [[10, 17], 0, ['default', 'gradual', 'fast']], + [[16], 5] + ] + ] + ], + [ + 'tbe', + [ + [[[16], 5]], + [ + [[10, 17], 0, ['custom', 'dive', 'dip', 'hold', 'predive', 'predivedive']], + [[16], 5] + ], + [ + [[10, 17], 0, ['default', 'gradual', 'fast']], + [[16], 5] + ], + [ + [[10, 17], 0, ['custom', 'dive', 'dip', 'hold', 'predive', 'predivedive']], + [[10, 17], 0, ['default', 'gradual', 'fast']], + [[16], 5] + ] + ] + ], + ['bu', [[[[16], 1]]]], + ['bd', [[[[16], 1]]]], + ['au', [[[[16], 1]]]], + ['ad', [[[[16], 1]]]], + ['ch', [[[[17, 10], 0]]]], + ['gr', [[[[10, 17], 1, ['onbeat', 'beforebeat', 'bendgrace', 'ob', 'bb', 'b']]]]], + [ + 'dy', + [ + [ + [ + [10, 17], + 0, + [ + 'ppp', + 'pp', + 'p', + 'mp', + 'mf', + 'f', + 'ff', + 'fff', + 'pppp', + 'ppppp', + 'pppppp', + 'ffff', + 'fffff', + 'ffffff', + 'sf', + 'sfp', + 'sfpp', + 'fp', + 'rf', + 'rfz', + 'sfz', + 'sffz', + 'fz', + 'n', + 'pf', + 'sfzp' + ] + ] + ] + ] + ], + [ + 'tempo', + [ + [ + [[16], 0], + [[10], 1, ['hide']] + ], + [ + [[16], 0], + [[17], 0], + [[10], 1, ['hide']] + ] + ] + ], + ['volume', [[[[16], 0]]]], + ['balance', [[[[16], 0]]]], + ['tp', [[[[16], 0, ['8', '16', '32']]]]], + [ + 'barre', + [ + [ + [[16], 0], + [[10, 17], 1, ['full', 'half']] + ] + ] + ], + [ + 'rasg', + [ + [ + [ + [10, 17], + 0, + [ + 'ii', + 'mi', + 'miitriplet', + 'miianapaest', + 'pmptriplet', + 'pmpanapaest', + 'peitriplet', + 'peianapaest', + 'paitriplet', + 'paianapaest', + 'amitriplet', + 'amianapaest', + 'ppp', + 'amii', + 'amip', + 'eami', + 'eamii', + 'peami' + ] + ] + ] + ] + ], + ['ot', [[[[10, 17], 0, ['15ma', '8va', 'regular', '8vb', '15mb', '15ma', '8va', '8vb', '15mb']]]]], + ['instrument', [[[[16], 0]], [[[17, 10], 0]], [[[10], 0, ['percussion']]]]], + ['bank', [[[[16], 0]]]], + [ + 'fermata', + [ + [ + [[10, 17], 0, ['short', 'medium', 'long']], + [[16], 3] + ] + ] + ], + ['beam', [[[[10, 17], 0, ['invert', 'up', 'down', 'auto', 'split', 'merge', 'splitsecondary']]]]] ]); public static readonly noteProperties = AlphaTex1LanguageDefinitions._props([ - ["nh", null], - ["ah", [[[[16], 1]]]], - ["th", [[[[16], 1]]]], - ["ph", [[[[16], 1]]]], - ["sh", [[[[16], 1]]]], - ["fh", [[[[16], 1]]]], - ["v", null], - ["vw", null], - ["sl", null], - ["ss", null], - ["sib", null], - ["sia", null], - ["sou", null], - ["sod", null], - ["psu", null], - ["psd", null], - ["h", null], - ["lht", null], - ["g", null], - ["ac", null], - ["hac", null], - ["ten", null], - ["tr", [[[[16], 0], [[16], 1, ["16", "32", "64"]]]]], - ["pm", null], - ["st", null], - ["lr", null], - ["x", null], - ["t", null], - ["turn", null], - ["iturn", null], - ["umordent", null], - ["lmordent", null], - ["string", null], - ["hide", null], - ["b", [[[[16], 5]], [[[10, 17], 0, ["custom", "bend", "release", "bendrelease", "hold", "prebend", "prebendbend", "prebendrelease"]], [[16], 5]], [[[10, 17], 0, ["default", "gradual", "fast"]], [[16], 5]], [[[10, 17], 0, ["custom", "bend", "release", "bendrelease", "hold", "prebend", "prebendbend", "prebendrelease"]], [[10, 17], 0, ["default", "gradual", "fast"]], [[16], 5]]]], - ["be", [[[[16], 5]], [[[10, 17], 0, ["custom", "bend", "release", "bendrelease", "hold", "prebend", "prebendbend", "prebendrelease"]], [[16], 5]], [[[10, 17], 0, ["default", "gradual", "fast"]], [[16], 5]], [[[10, 17], 0, ["custom", "bend", "release", "bendrelease", "hold", "prebend", "prebendbend", "prebendrelease"]], [[10, 17], 0, ["default", "gradual", "fast"]], [[16], 5]]]], - ["lf", [[[[16], 0, ["1", "2", "3", "4", "5"]]]]], - ["rf", [[[[16], 0, ["1", "2", "3", "4", "5"]]]]], - ["acc", [[[[10, 17], 0, ["default", "forcenone", "forcenatural", "forcesharp", "forcedoublesharp", "forceflat", "forcedoubleflat", "d", "-", "n", "#", "##", "x", "b", "bb"]]]]], - ["slur", [[[[17], 0]], [[[10], 0]]]], - ["-", null] + ['nh', null], + ['ah', [[[[16], 1]]]], + ['th', [[[[16], 1]]]], + ['ph', [[[[16], 1]]]], + ['sh', [[[[16], 1]]]], + ['fh', [[[[16], 1]]]], + ['v', null], + ['vw', null], + ['sl', null], + ['ss', null], + ['sib', null], + ['sia', null], + ['sou', null], + ['sod', null], + ['psu', null], + ['psd', null], + ['h', null], + ['lht', null], + ['g', null], + ['ac', null], + ['hac', null], + ['ten', null], + [ + 'tr', + [ + [ + [[16], 0], + [[16], 1, ['16', '32', '64']] + ] + ] + ], + ['pm', null], + ['st', null], + ['lr', null], + ['x', null], + ['t', null], + ['turn', null], + ['iturn', null], + ['umordent', null], + ['lmordent', null], + ['string', null], + ['hide', null], + [ + 'b', + [ + [[[16], 5]], + [ + [ + [10, 17], + 0, + ['custom', 'bend', 'release', 'bendrelease', 'hold', 'prebend', 'prebendbend', 'prebendrelease'] + ], + [[16], 5] + ], + [ + [[10, 17], 0, ['default', 'gradual', 'fast']], + [[16], 5] + ], + [ + [ + [10, 17], + 0, + ['custom', 'bend', 'release', 'bendrelease', 'hold', 'prebend', 'prebendbend', 'prebendrelease'] + ], + [[10, 17], 0, ['default', 'gradual', 'fast']], + [[16], 5] + ] + ] + ], + [ + 'be', + [ + [[[16], 5]], + [ + [ + [10, 17], + 0, + ['custom', 'bend', 'release', 'bendrelease', 'hold', 'prebend', 'prebendbend', 'prebendrelease'] + ], + [[16], 5] + ], + [ + [[10, 17], 0, ['default', 'gradual', 'fast']], + [[16], 5] + ], + [ + [ + [10, 17], + 0, + ['custom', 'bend', 'release', 'bendrelease', 'hold', 'prebend', 'prebendbend', 'prebendrelease'] + ], + [[10, 17], 0, ['default', 'gradual', 'fast']], + [[16], 5] + ] + ] + ], + ['lf', [[[[16], 0, ['1', '2', '3', '4', '5']]]]], + ['rf', [[[[16], 0, ['1', '2', '3', '4', '5']]]]], + [ + 'acc', + [ + [ + [ + [10, 17], + 0, + [ + 'default', + 'forcenone', + 'forcenatural', + 'forcesharp', + 'forcedoublesharp', + 'forceflat', + 'forcedoubleflat', + 'd', + '-', + 'n', + '#', + '##', + 'x', + 'b', + 'bb' + ] + ] + ] + ] + ], + ['slur', [[[[17], 0]], [[[10], 0]]]], + ['-', null] ]); } diff --git a/packages/alphatab/src/importer/alphaTex/AlphaTex1LanguageHandler.ts b/packages/alphatab/src/importer/alphaTex/AlphaTex1LanguageHandler.ts index 13ebb462b..fab749e45 100644 --- a/packages/alphatab/src/importer/alphaTex/AlphaTex1LanguageHandler.ts +++ b/packages/alphatab/src/importer/alphaTex/AlphaTex1LanguageHandler.ts @@ -259,6 +259,12 @@ export class AlphaTex1LanguageHandler implements IAlphaTexLanguageImportHandler } score.stylesheet.otherSystemsTrackNameOrientation = otherSystemsTrackNameOrientation!; return ApplyNodeResult.Applied; + case 'chorddiagramsinscore': + score.stylesheet.globalDisplayChordDiagramsInScore = metaData.arguments + ? AlphaTex1LanguageHandler._booleanLikeValue(metaData.arguments!.arguments, 0) + : true; + return ApplyNodeResult.Applied; + default: return ApplyNodeResult.NotAppliedUnrecognizedMarker; } @@ -2488,6 +2494,10 @@ export class AlphaTex1LanguageHandler implements IAlphaTexLanguageImportHandler nodes.push(Atnf.meta('extendBarLines')); } + if (stylesheet.globalDisplayChordDiagramsInScore) { + nodes.push(Atnf.meta('chordDiagramsInScore')); + } + // Unsupported: // 'globaldisplaychorddiagramsontop', // 'pertrackchorddiagramsontop', diff --git a/packages/alphatab/src/model/RenderStylesheet.ts b/packages/alphatab/src/model/RenderStylesheet.ts index 70a8c31e5..83825cbe2 100644 --- a/packages/alphatab/src/model/RenderStylesheet.ts +++ b/packages/alphatab/src/model/RenderStylesheet.ts @@ -115,6 +115,11 @@ export class RenderStylesheet { */ public perTrackChordDiagramsOnTop: Map | null = null; + /** + * Whether to show the chord diagrams in score. + */ + public globalDisplayChordDiagramsInScore: boolean = false; + /** * The policy where to show track names when a single track is rendered. */ diff --git a/packages/alphatab/src/rendering/effects/ChordsEffectInfo.ts b/packages/alphatab/src/rendering/effects/ChordsEffectInfo.ts index 7e5475212..cad5e1d6f 100644 --- a/packages/alphatab/src/rendering/effects/ChordsEffectInfo.ts +++ b/packages/alphatab/src/rendering/effects/ChordsEffectInfo.ts @@ -7,6 +7,7 @@ import { TextGlyph } from '@coderline/alphatab/rendering/glyphs/TextGlyph'; import { EffectInfo } from '@coderline/alphatab/rendering/EffectInfo'; import type { Settings } from '@coderline/alphatab/Settings'; import { NotationElement } from '@coderline/alphatab/NotationSettings'; +import { ChordDiagramGlyph } from '@coderline/alphatab/rendering/glyphs/ChordDiagramGlyph'; /** * @internal @@ -33,7 +34,10 @@ export class ChordsEffectInfo extends EffectInfo { } public createNewGlyph(renderer: BarRendererBase, beat: Beat): EffectGlyph { - return new TextGlyph(0, 0, beat.chord!.name, renderer.resources.effectFont, TextAlign.Center); + const showDiagram = beat.voice.bar.staff.track.score.stylesheet.globalDisplayChordDiagramsInScore; + return showDiagram + ? new ChordDiagramGlyph(0, 0, beat.chord!, true) + : new TextGlyph(0, 0, beat.chord!.name, renderer.resources.effectFont, TextAlign.Center); } public canExpand(_from: Beat, _to: Beat): boolean { diff --git a/packages/alphatab/src/rendering/glyphs/ChordDiagramGlyph.ts b/packages/alphatab/src/rendering/glyphs/ChordDiagramGlyph.ts index 271499580..136deae87 100644 --- a/packages/alphatab/src/rendering/glyphs/ChordDiagramGlyph.ts +++ b/packages/alphatab/src/rendering/glyphs/ChordDiagramGlyph.ts @@ -14,10 +14,12 @@ export class ChordDiagramGlyph extends EffectGlyph { private _textRow: number = 0; private _fretRow: number = 0; private _firstFretSpacing: number = 0; + private _center: boolean; - public constructor(x: number, y: number, chord: Chord) { + public constructor(x: number, y: number, chord: Chord, center: boolean = false) { super(x, y); this._chord = chord; + this._center = center; } public override doLayout(): void { @@ -44,6 +46,10 @@ export class ChordDiagramGlyph extends EffectGlyph { public override paint(cx: number, cy: number, canvas: ICanvas): void { cx += this.x + this.renderer.smuflMetrics.chordDiagramPaddingX + this._firstFretSpacing; cy += this.y; + if (this._center) { + cx -= this.width / 2; + } + const stringSpacing: number = this.renderer.smuflMetrics.chordDiagramStringSpacing; const fretSpacing: number = this.renderer.smuflMetrics.chordDiagramFretSpacing; const res: RenderingResources = this.renderer.resources; @@ -72,9 +78,9 @@ export class ChordDiagramGlyph extends EffectGlyph { const y: number = cy + this._fretRow / 2; let fret: number = this._chord.strings[this._chord.strings.length - i - 1]; if (fret < 0) { - CanvasHelper.fillMusicFontSymbolSafe(canvas,x, y + xTopOffset, 1, MusicFontSymbol.FretboardX, true); + CanvasHelper.fillMusicFontSymbolSafe(canvas, x, y + xTopOffset, 1, MusicFontSymbol.FretboardX, true); } else if (fret === 0) { - CanvasHelper.fillMusicFontSymbolSafe(canvas,x, y + oTopOffset, 1, MusicFontSymbol.FretboardO, true); + CanvasHelper.fillMusicFontSymbolSafe(canvas, x, y + oTopOffset, 1, MusicFontSymbol.FretboardO, true); } else { fret -= this._chord.firstFret - 1; canvas.fillText(fret.toString(), x, y); @@ -126,7 +132,8 @@ export class ChordDiagramGlyph extends EffectGlyph { } const y: number = cy + fret * fretSpacing + fretSpacing / 2 + 0.5; const x: number = cx + (this._chord.strings.length - guitarString - 1) * stringSpacing + lineWidth / 2; - CanvasHelper.fillMusicFontSymbolSafe(canvas, + CanvasHelper.fillMusicFontSymbolSafe( + canvas, x, y + circleTopOffset - circleHeight / 2, 1, diff --git a/packages/alphatab/test-data/guitarpro8/show-diagrams-in-score.gp b/packages/alphatab/test-data/guitarpro8/show-diagrams-in-score.gp new file mode 100644 index 000000000..ed2e0c232 Binary files /dev/null and b/packages/alphatab/test-data/guitarpro8/show-diagrams-in-score.gp differ diff --git a/packages/alphatab/test-data/visual-tests/effects-and-annotations/inscore-chord-diagrams.png b/packages/alphatab/test-data/visual-tests/effects-and-annotations/inscore-chord-diagrams.png new file mode 100644 index 000000000..c07a31dca Binary files /dev/null and b/packages/alphatab/test-data/visual-tests/effects-and-annotations/inscore-chord-diagrams.png differ diff --git a/packages/alphatab/test/importer/AlphaTexImporter.test.ts b/packages/alphatab/test/importer/AlphaTexImporter.test.ts index 695e1429f..90586ed74 100644 --- a/packages/alphatab/test/importer/AlphaTexImporter.test.ts +++ b/packages/alphatab/test/importer/AlphaTexImporter.test.ts @@ -2529,4 +2529,27 @@ describe('AlphaTexImporterTest', () => { ).toMatchSnapshot(); }); }); + + it('inline-chord-diagrams', () =>{ + let score = parseTex(` + \\chordDiagramsInScore + \\chord ("E" 0 0 1 2 2 0) + (0.1 0.2 1.3 2.4 2.5 0.6){ch "E"} + `); + expect(score.stylesheet.globalDisplayChordDiagramsInScore).to.be.true; + + score = parseTex(` + \\chordDiagramsInScore true + \\chord ("E" 0 0 1 2 2 0) + (0.1 0.2 1.3 2.4 2.5 0.6){ch "E"} + `); + expect(score.stylesheet.globalDisplayChordDiagramsInScore).to.be.true; + + score = parseTex(` + \\chordDiagramsInScore false + \\chord ("E" 0 0 1 2 2 0) + (0.1 0.2 1.3 2.4 2.5 0.6){ch "E"} + `); + expect(score.stylesheet.globalDisplayChordDiagramsInScore).to.be.false; + }) }); diff --git a/packages/alphatab/test/importer/Gp8Importer.test.ts b/packages/alphatab/test/importer/Gp8Importer.test.ts index 1e12472f9..24ca35899 100644 --- a/packages/alphatab/test/importer/Gp8Importer.test.ts +++ b/packages/alphatab/test/importer/Gp8Importer.test.ts @@ -132,6 +132,14 @@ describe('Gp8ImporterTest', () => { expect(show.stylesheet.globalDisplayChordDiagramsOnTop).to.be.true; }); + it('show-chord-diagrams-in-score', async () => { + const hide = (await prepareImporterWithFile('guitarpro8/show-diagrams-in-score.gp')).readScore(); + expect(hide.stylesheet.globalDisplayChordDiagramsInScore).to.be.true; + + const show = (await prepareImporterWithFile('guitarpro8/directions.gp')).readScore(); + expect(show.stylesheet.globalDisplayChordDiagramsInScore).to.be.false; + }); + it('beaming-mode', async () => { const score = (await prepareImporterWithFile('guitarpro8/beaming-mode.gp')).readScore(); diff --git a/packages/alphatab/test/visualTests/features/EffectsAndAnnotations.test.ts b/packages/alphatab/test/visualTests/features/EffectsAndAnnotations.test.ts index 1fd58f3b7..46183dadd 100644 --- a/packages/alphatab/test/visualTests/features/EffectsAndAnnotations.test.ts +++ b/packages/alphatab/test/visualTests/features/EffectsAndAnnotations.test.ts @@ -305,4 +305,18 @@ describe('EffectsAndAnnotationsTests', () => { 'test-data/visual-tests/effects-and-annotations/legato.png' ); }); + + it('inscore-chord-diagrams', async () => { + await VisualTestHelper.runVisualTestTex( + ` + \\chordDiagramsInScore true + \\chord ("E" 0 0 1 2 2 0) + \\chord ("C" 0 1 0 2 3 x) + + (0.1 0.2 1.3 2.4 2.5 0.6){ch "E"} r r r | + (0.1 1.2 0.3 2.4 3.5){ch "C"} r r r | + `, + 'test-data/visual-tests/effects-and-annotations/inscore-chord-diagrams.png' + ); + }); }); diff --git a/packages/alphatex/src/definitions.ts b/packages/alphatex/src/definitions.ts index b1056b6ba..0ffb4163d 100644 --- a/packages/alphatex/src/definitions.ts +++ b/packages/alphatex/src/definitions.ts @@ -148,6 +148,7 @@ import { x } from '@coderline/alphatab-alphatex//properties/note/x'; import { metadata, properties } from '@coderline/alphatab-alphatex/common'; import { db } from '@coderline/alphatab-alphatex/metadata/bar/db'; import { voiceMode } from '@coderline/alphatab-alphatex/metadata/bar/voiceMode'; +import { chordDiagramsInScore } from '@coderline/alphatab-alphatex/metadata/score/chordDiagramsInScore'; import { extendBarLines } from '@coderline/alphatab-alphatex/metadata/score/extendbarlines'; import { instrumentMeta } from '@coderline/alphatab-alphatex/metadata/staff/instrument'; import type { AlphaTexExample, WithDescription, WithSignatures } from '@coderline/alphatab-alphatex/types'; @@ -179,7 +180,8 @@ export const scoreMetaData = metadata( otherSystemsTrackNameMode, firstSystemTrackNameOrientation, otherSystemsTrackNameOrientation, - extendBarLines + extendBarLines, + chordDiagramsInScore ); export const staffMetaData = metadata( diff --git a/packages/alphatex/src/metadata/score/chordDiagramsInScore.ts b/packages/alphatex/src/metadata/score/chordDiagramsInScore.ts new file mode 100644 index 000000000..71039463f --- /dev/null +++ b/packages/alphatex/src/metadata/score/chordDiagramsInScore.ts @@ -0,0 +1,33 @@ +import * as alphaTab from '@coderline/alphatab'; +import type { MetadataTagDefinition } from '@coderline/alphatab-alphatex/types'; + +export const chordDiagramsInScore: MetadataTagDefinition = { + tag: '\\chordDiagramsInScore', + snippet: '\\chordDiagramsInScore', + shortDescription: 'Show inline chord diagrams in score.', + longDescription: `Configures whether chord diagrams are shown inline in the score..`, + signatures: [ + { + parameters: [ + { + name: 'visibility', + shortDescription: 'The visibility of the diagrams', + parseMode: alphaTab.importer.alphaTex.ArgumentListParseTypesMode.Optional, + defaultValue: 'true', + type: alphaTab.importer.alphaTex.AlphaTexNodeType.Ident, + values: [ + { name: 'true', snippet: 'true', shortDescription: 'Show the diagrams' }, + { name: 'false', snippet: 'false', shortDescription: 'Hide the diagrams' } + ] + } + ] + } + ], + examples: [ + ` + \\chordDiagramsInScore + \\chord ("E" 0 0 1 2 2 0) + (0.1 0.2 1.3 2.4 2.5 0.6){ch "E"} + ` + ] +};