UNPKG

alphatab-pd

Version:

alphaTab is a music notation and guitar tablature rendering library

1,379 lines (1,346 loc) 1.94 MB
/** * alphaTab v1.0.21 (develop, build 0) * * Copyright © 2024, Daniel Kuschny and Contributors, All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * SoundFont loading and Audio Synthesis based on TinySoundFont (licensed under MIT) * Copyright (C) 2017, 2018 Bernhard Schelling (https://github.com/schellingb/TinySoundFont) * * TinySoundFont is based on SFZero (licensed under MIT) * Copyright (C) 2012 Steve Folta (https://github.com/stevefolta/SFZero) */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.alphaTab = {})); })(this, (function (exports) { 'use strict'; /** * Lists all layout modes that are supported. */ exports.LayoutMode = void 0; (function (LayoutMode) { /** * Bars are aligned in rows using a fixed width. */ LayoutMode[LayoutMode["Page"] = 0] = "Page"; /** * Bars are aligned horizontally in one row */ LayoutMode[LayoutMode["Horizontal"] = 1] = "Horizontal"; })(exports.LayoutMode || (exports.LayoutMode = {})); /** * Lists all stave profiles controlling which staves are shown. */ exports.StaveProfile = void 0; (function (StaveProfile) { /** * The profile is auto detected by the track configurations. */ StaveProfile[StaveProfile["Default"] = 0] = "Default"; /** * Standard music notation and guitar tablature are rendered. */ StaveProfile[StaveProfile["ScoreTab"] = 1] = "ScoreTab"; /** * Only standard music notation is rendered. */ StaveProfile[StaveProfile["Score"] = 2] = "Score"; /** * Only guitar tablature is rendered. */ StaveProfile[StaveProfile["Tab"] = 3] = "Tab"; /** * Only guitar tablature is rendered, but also rests and time signatures are not shown. * This profile is typically used in multi-track scenarios. */ StaveProfile[StaveProfile["TabMixed"] = 4] = "TabMixed"; })(exports.StaveProfile || (exports.StaveProfile = {})); /** * This public class provides names for all general midi instruments. */ class GeneralMidi { static getValue(name) { if (!GeneralMidi._values) { GeneralMidi._values = new Map(); } name = name.toLowerCase().replaceAll(' ', ''); return GeneralMidi._values.has(name) ? GeneralMidi._values.get(name) : 0; } static isPiano(program) { return program <= 7 || program >= 16 && program <= 23; } static isGuitar(program) { return program >= 24 && program <= 39 || program === 105 || program === 43; } } GeneralMidi._values = new Map([ ['acousticgrandpiano', 0], ['brightacousticpiano', 1], ['electricgrandpiano', 2], ['honkytonkpiano', 3], ['electricpiano1', 4], ['electricpiano2', 5], ['harpsichord', 6], ['clavinet', 7], ['celesta', 8], ['glockenspiel', 9], ['musicbox', 10], ['vibraphone', 11], ['marimba', 12], ['xylophone', 13], ['tubularbells', 14], ['dulcimer', 15], ['drawbarorgan', 16], ['percussiveorgan', 17], ['rockorgan', 18], ['churchorgan', 19], ['reedorgan', 20], ['accordion', 21], ['harmonica', 22], ['tangoaccordion', 23], ['acousticguitarnylon', 24], ['acousticguitarsteel', 25], ['electricguitarjazz', 26], ['electricguitarclean', 27], ['electricguitarmuted', 28], ['overdrivenguitar', 29], ['distortionguitar', 30], ['guitarharmonics', 31], ['acousticbass', 32], ['electricbassfinger', 33], ['electricbasspick', 34], ['fretlessbass', 35], ['slapbass1', 36], ['slapbass2', 37], ['synthbass1', 38], ['synthbass2', 39], ['violin', 40], ['viola', 41], ['cello', 42], ['contrabass', 43], ['tremolostrings', 44], ['pizzicatostrings', 45], ['orchestralharp', 46], ['timpani', 47], ['stringensemble1', 48], ['stringensemble2', 49], ['synthstrings1', 50], ['synthstrings2', 51], ['choiraahs', 52], ['voiceoohs', 53], ['synthvoice', 54], ['orchestrahit', 55], ['trumpet', 56], ['trombone', 57], ['tuba', 58], ['mutedtrumpet', 59], ['frenchhorn', 60], ['brasssection', 61], ['synthbrass1', 62], ['synthbrass2', 63], ['sopranosax', 64], ['altosax', 65], ['tenorsax', 66], ['baritonesax', 67], ['oboe', 68], ['englishhorn', 69], ['bassoon', 70], ['clarinet', 71], ['piccolo', 72], ['flute', 73], ['recorder', 74], ['panflute', 75], ['blownbottle', 76], ['shakuhachi', 77], ['whistle', 78], ['ocarina', 79], ['lead1square', 80], ['lead2sawtooth', 81], ['lead3calliope', 82], ['lead4chiff', 83], ['lead5charang', 84], ['lead6voice', 85], ['lead7fifths', 86], ['lead8bassandlead', 87], ['pad1newage', 88], ['pad2warm', 89], ['pad3polysynth', 90], ['pad4choir', 91], ['pad5bowed', 92], ['pad6metallic', 93], ['pad7halo', 94], ['pad8sweep', 95], ['fx1rain', 96], ['fx2soundtrack', 97], ['fx3crystal', 98], ['fx4atmosphere', 99], ['fx5brightness', 100], ['fx6goblins', 101], ['fx7echoes', 102], ['fx8scifi', 103], ['sitar', 104], ['banjo', 105], ['shamisen', 106], ['koto', 107], ['kalimba', 108], ['bagpipe', 109], ['fiddle', 110], ['shanai', 111], ['tinklebell', 112], ['agogo', 113], ['steeldrums', 114], ['woodblock', 115], ['taikodrum', 116], ['melodictom', 117], ['synthdrum', 118], ['reversecymbal', 119], ['guitarfretnoise', 120], ['breathnoise', 121], ['seashore', 122], ['birdtweet', 123], ['telephonering', 124], ['helicopter', 125], ['applause', 126], ['gunshot', 127] ]); /** * This is the base public class for creating new song importers which * enable reading scores from any binary datasource */ class ScoreImporter { /** * Initializes the importer with the given data and settings. */ init(data, settings) { this.data = data; this.settings = settings; } } exports.AlphaTabErrorType = void 0; (function (AlphaTabErrorType) { AlphaTabErrorType[AlphaTabErrorType["General"] = 0] = "General"; AlphaTabErrorType[AlphaTabErrorType["Format"] = 1] = "Format"; AlphaTabErrorType[AlphaTabErrorType["AlphaTex"] = 2] = "AlphaTex"; })(exports.AlphaTabErrorType || (exports.AlphaTabErrorType = {})); class AlphaTabError extends Error { constructor(type, message = "", inner) { super(message !== null && message !== void 0 ? message : ""); this.type = type; this.inner = inner !== null && inner !== void 0 ? inner : null; Object.setPrototypeOf(this, AlphaTabError.prototype); } } /** * The exception thrown by a {@link ScoreImporter} in case the * binary data does not contain a reader compatible structure. */ class UnsupportedFormatError extends AlphaTabError { constructor(message = null, inner = null) { super(exports.AlphaTabErrorType.Format, message !== null && message !== void 0 ? message : 'Unsupported format'); this.inner = inner; Object.setPrototypeOf(this, UnsupportedFormatError.prototype); } } /** * Lists all types of note acceuntations */ var AccentuationType; (function (AccentuationType) { /** * No accentuation */ AccentuationType[AccentuationType["None"] = 0] = "None"; /** * Normal accentuation */ AccentuationType[AccentuationType["Normal"] = 1] = "Normal"; /** * Heavy accentuation */ AccentuationType[AccentuationType["Heavy"] = 2] = "Heavy"; })(AccentuationType || (AccentuationType = {})); /** * This public enumeration lists all types of automations. */ var AutomationType; (function (AutomationType) { /** * Tempo change. */ AutomationType[AutomationType["Tempo"] = 0] = "Tempo"; /** * Colume change. */ AutomationType[AutomationType["Volume"] = 1] = "Volume"; /** * Instrument change. */ AutomationType[AutomationType["Instrument"] = 2] = "Instrument"; /** * Balance change. */ AutomationType[AutomationType["Balance"] = 3] = "Balance"; })(AutomationType || (AutomationType = {})); /** * Automations are used to change the behaviour of a song. * @cloneable * @json * @json_strict */ class Automation { constructor() { /** * Gets or sets whether the automation is applied linear. */ this.isLinear = false; /** * Gets or sets the type of the automation. */ this.type = AutomationType.Tempo; /** * Gets or sets the target value of the automation. */ this.value = 0; /** * Gets or sets the relative position of of the automation. */ this.ratioPosition = 0; /** * Gets or sets the additional text of the automation. */ this.text = ''; } static buildTempoAutomation(isLinear, ratioPosition, value, reference) { if (reference < 1 || reference > 5) { reference = 2; } let references = new Float32Array([1, 0.5, 1.0, 1.5, 2.0, 3.0]); let automation = new Automation(); automation.type = AutomationType.Tempo; automation.isLinear = isLinear; automation.ratioPosition = ratioPosition; automation.value = value * references[reference]; return automation; } static buildInstrumentAutomation(isLinear, ratioPosition, value) { let automation = new Automation(); automation.type = AutomationType.Instrument; automation.isLinear = isLinear; automation.ratioPosition = ratioPosition; automation.value = value; return automation; } } /** * This public enumeration lists all supported Clefs. */ var Clef; (function (Clef) { /** * Neutral clef. */ Clef[Clef["Neutral"] = 0] = "Neutral"; /** * C3 clef */ Clef[Clef["C3"] = 1] = "C3"; /** * C4 clef */ Clef[Clef["C4"] = 2] = "C4"; /** * F4 clef */ Clef[Clef["F4"] = 3] = "F4"; /** * G2 clef */ Clef[Clef["G2"] = 4] = "G2"; })(Clef || (Clef = {})); /** * Lists all ottavia. */ var Ottavia; (function (Ottavia) { /** * 2 octaves higher */ Ottavia[Ottavia["_15ma"] = 0] = "_15ma"; /** * 1 octave higher */ Ottavia[Ottavia["_8va"] = 1] = "_8va"; /** * Normal */ Ottavia[Ottavia["Regular"] = 2] = "Regular"; /** * 1 octave lower */ Ottavia[Ottavia["_8vb"] = 3] = "_8vb"; /** * 2 octaves lower. */ Ottavia[Ottavia["_15mb"] = 4] = "_15mb"; })(Ottavia || (Ottavia = {})); /** * Lists all simile mark types as they are assigned to bars. */ var SimileMark; (function (SimileMark) { /** * No simile mark is applied */ SimileMark[SimileMark["None"] = 0] = "None"; /** * A simple simile mark. The previous bar is repeated. */ SimileMark[SimileMark["Simple"] = 1] = "Simple"; /** * A double simile mark. This value is assigned to the first * bar of the 2 repeat bars. */ SimileMark[SimileMark["FirstOfDouble"] = 2] = "FirstOfDouble"; /** * A double simile mark. This value is assigned to the second * bar of the 2 repeat bars. */ SimileMark[SimileMark["SecondOfDouble"] = 3] = "SecondOfDouble"; })(SimileMark || (SimileMark = {})); /** * A bar is a single block within a track, also known as Measure. * @json * @json_strict */ class Bar { constructor() { /** * Gets or sets the unique id of this bar. */ this.id = Bar._globalBarId++; /** * Gets or sets the zero-based index of this bar within the staff. * @json_ignore */ this.index = 0; /** * Gets or sets the next bar that comes after this bar. * @json_ignore */ this.nextBar = null; /** * Gets or sets the previous bar that comes before this bar. * @json_ignore */ this.previousBar = null; /** * Gets or sets the clef on this bar. */ this.clef = Clef.G2; /** * Gets or sets the ottava applied to the clef. */ this.clefOttava = Ottavia.Regular; /** * Gets or sets the list of voices contained in this bar. * @json_add addVoice */ this.voices = []; /** * Gets or sets the simile mark on this bar. */ this.simileMark = SimileMark.None; /** * Gets a value indicating whether this bar contains multiple voices with notes. * @json_ignore */ this.isMultiVoice = false; /** * A relative scale for the size of the bar when displayed. The scale is relative * within a single line (system/stave group). The sum of all scales in one line make the total width, * and then this individual scale gives the relative size. */ this.displayScale = 1; /** * An absolute width of the bar to use when displaying in single track display scenarios. */ this.displayWidth = -1; } get masterBar() { return this.staff.track.score.masterBars[this.index]; } get isEmpty() { for (let i = 0, j = this.voices.length; i < j; i++) { if (!this.voices[i].isEmpty) { return false; } } return true; } addVoice(voice) { voice.bar = this; voice.index = this.voices.length; this.voices.push(voice); } finish(settings, sharedDataBag = null) { this.isMultiVoice = false; for (let i = 0, j = this.voices.length; i < j; i++) { let voice = this.voices[i]; voice.finish(settings, sharedDataBag); if (i > 0 && !voice.isEmpty) { this.isMultiVoice = true; } } } calculateDuration() { let duration = 0; for (let voice of this.voices) { let voiceDuration = voice.calculateDuration(); if (voiceDuration > duration) { duration = voiceDuration; } } return duration; } } Bar._globalBarId = 0; class MidiUtils { /** * Converts the given midi tick duration into milliseconds. * @param ticks The duration in midi ticks * @param tempo The current tempo in BPM. * @returns The converted duration in milliseconds. */ static ticksToMillis(ticks, tempo) { return (ticks * (60000.0 / (tempo * MidiUtils.QuarterTime))) | 0; } /** * Converts the given midi tick duration into milliseconds. * @param millis The duration in milliseconds * @param tempo The current tempo in BPM. * @returns The converted duration in midi ticks. */ static millisToTicks(millis, tempo) { return (millis / (60000.0 / (tempo * MidiUtils.QuarterTime))) | 0; } /** * Converts a duration value to its ticks equivalent. */ static toTicks(duration) { return MidiUtils.valueToTicks(duration); } /** * Converts a numerical value to its ticks equivalent. * @param duration the numerical proportion to convert. (i.E. timesignature denominator, note duration,...) */ static valueToTicks(duration) { let denomninator = duration; if (denomninator < 0) { denomninator = 1 / -denomninator; } return (MidiUtils.QuarterTime * (4.0 / denomninator)) | 0; } static applyDot(ticks, doubleDotted) { if (doubleDotted) { return ticks + ((ticks / 4) | 0) * 3; } return ticks + ((ticks / 2) | 0); } static applyTuplet(ticks, numerator, denominator) { return ((ticks * denominator) / numerator) | 0; } static removeTuplet(ticks, numerator, denominator) { return ((ticks * numerator) / denominator) | 0; } static dynamicToVelocity(dynamicsSteps) { return MidiUtils.MinVelocity + dynamicsSteps * MidiUtils.VelocityIncrement; } } MidiUtils.QuarterTime = 960; MidiUtils.MinVelocity = 15; MidiUtils.VelocityIncrement = 16; /** * A single point of a bending graph. Used to * describe WhammyBar and String Bending effects. * @cloneable * @json * @json_strict */ class BendPoint { /** * Initializes a new instance of the {@link BendPoint} class. * @param offset The offset. * @param value The value. */ constructor(offset = 0, value = 0) { this.offset = offset; this.value = value; } } BendPoint.MaxPosition = 60; BendPoint.MaxValue = 12; /** * Lists the different bend styles */ var BendStyle; (function (BendStyle) { /** * The bends are as described by the bend points */ BendStyle[BendStyle["Default"] = 0] = "Default"; /** * The bends are gradual over the beat duration. */ BendStyle[BendStyle["Gradual"] = 1] = "Gradual"; /** * The bends are done fast before the next note. */ BendStyle[BendStyle["Fast"] = 2] = "Fast"; })(BendStyle || (BendStyle = {})); /** * Lists all types of bends */ var BendType; (function (BendType) { /** * No bend at all */ BendType[BendType["None"] = 0] = "None"; /** * Individual points define the bends in a flexible manner. * This system was mainly used in Guitar Pro 3-5 */ BendType[BendType["Custom"] = 1] = "Custom"; /** * Simple Bend from an unbended string to a higher note. */ BendType[BendType["Bend"] = 2] = "Bend"; /** * Release of a bend that was started on an earlier note. */ BendType[BendType["Release"] = 3] = "Release"; /** * A bend that starts from an unbended string, * and also releases the bend after some time. */ BendType[BendType["BendRelease"] = 4] = "BendRelease"; /** * Holds a bend that was started on an earlier note */ BendType[BendType["Hold"] = 5] = "Hold"; /** * A bend that is already started before the note is played then it is held until the end. */ BendType[BendType["Prebend"] = 6] = "Prebend"; /** * A bend that is already started before the note is played and * bends even further, then it is held until the end. */ BendType[BendType["PrebendBend"] = 7] = "PrebendBend"; /** * A bend that is already started before the note is played and * then releases the bend to a lower note where it is held until the end. */ BendType[BendType["PrebendRelease"] = 8] = "PrebendRelease"; })(BendType || (BendType = {})); /** * Lists all types of how to brush multiple notes on a beat. */ var BrushType; (function (BrushType) { /** * No brush. */ BrushType[BrushType["None"] = 0] = "None"; /** * Normal brush up. */ BrushType[BrushType["BrushUp"] = 1] = "BrushUp"; /** * Normal brush down. */ BrushType[BrushType["BrushDown"] = 2] = "BrushDown"; /** * Arpeggio up. */ BrushType[BrushType["ArpeggioUp"] = 3] = "ArpeggioUp"; /** * Arpeggio down. */ BrushType[BrushType["ArpeggioDown"] = 4] = "ArpeggioDown"; })(BrushType || (BrushType = {})); /** * Lists all Crescendo and Decrescendo types. */ var CrescendoType; (function (CrescendoType) { /** * No crescendo applied. */ CrescendoType[CrescendoType["None"] = 0] = "None"; /** * Normal crescendo applied. */ CrescendoType[CrescendoType["Crescendo"] = 1] = "Crescendo"; /** * Normal decrescendo applied. */ CrescendoType[CrescendoType["Decrescendo"] = 2] = "Decrescendo"; })(CrescendoType || (CrescendoType = {})); /** * Lists all durations of a beat. */ var Duration; (function (Duration) { /** * A quadruple whole note duration */ Duration[Duration["QuadrupleWhole"] = -4] = "QuadrupleWhole"; /** * A double whole note duration */ Duration[Duration["DoubleWhole"] = -2] = "DoubleWhole"; /** * A whole note duration */ Duration[Duration["Whole"] = 1] = "Whole"; /** * A 1/2 note duration */ Duration[Duration["Half"] = 2] = "Half"; /** * A 1/4 note duration */ Duration[Duration["Quarter"] = 4] = "Quarter"; /** * A 1/8 note duration */ Duration[Duration["Eighth"] = 8] = "Eighth"; /** * A 1/16 note duration */ Duration[Duration["Sixteenth"] = 16] = "Sixteenth"; /** * A 1/32 note duration */ Duration[Duration["ThirtySecond"] = 32] = "ThirtySecond"; /** * A 1/64 note duration */ Duration[Duration["SixtyFourth"] = 64] = "SixtyFourth"; /** * A 1/128 note duration */ Duration[Duration["OneHundredTwentyEighth"] = 128] = "OneHundredTwentyEighth"; /** * A 1/256 note duration */ Duration[Duration["TwoHundredFiftySixth"] = 256] = "TwoHundredFiftySixth"; })(Duration || (Duration = {})); /** * Lists all dynamics. */ var DynamicValue; (function (DynamicValue) { /** * pianississimo (very very soft) */ DynamicValue[DynamicValue["PPP"] = 0] = "PPP"; /** * pianissimo (very soft) */ DynamicValue[DynamicValue["PP"] = 1] = "PP"; /** * piano (soft) */ DynamicValue[DynamicValue["P"] = 2] = "P"; /** * mezzo-piano (half soft) */ DynamicValue[DynamicValue["MP"] = 3] = "MP"; /** * mezzo-forte (half loud) */ DynamicValue[DynamicValue["MF"] = 4] = "MF"; /** * forte (loud) */ DynamicValue[DynamicValue["F"] = 5] = "F"; /** * fortissimo (very loud) */ DynamicValue[DynamicValue["FF"] = 6] = "FF"; /** * fortississimo (very very loud) */ DynamicValue[DynamicValue["FFF"] = 7] = "FFF"; })(DynamicValue || (DynamicValue = {})); /** * Lists all types of grace notes */ var GraceType; (function (GraceType) { /** * No grace, normal beat. */ GraceType[GraceType["None"] = 0] = "None"; /** * The beat contains on-beat grace notes. */ GraceType[GraceType["OnBeat"] = 1] = "OnBeat"; /** * The beat contains before-beat grace notes. */ GraceType[GraceType["BeforeBeat"] = 2] = "BeforeBeat"; /** * The beat contains very special bend-grace notes used in SongBook style displays. */ GraceType[GraceType["BendGrace"] = 3] = "BendGrace"; })(GraceType || (GraceType = {})); /** * Lists all fingers. */ var Fingers; (function (Fingers) { /** * Unknown type (not documented) */ Fingers[Fingers["Unknown"] = -2] = "Unknown"; /** * No finger, dead note */ Fingers[Fingers["NoOrDead"] = -1] = "NoOrDead"; /** * The thumb */ Fingers[Fingers["Thumb"] = 0] = "Thumb"; /** * The index finger */ Fingers[Fingers["IndexFinger"] = 1] = "IndexFinger"; /** * The middle finger */ Fingers[Fingers["MiddleFinger"] = 2] = "MiddleFinger"; /** * The annular finger */ Fingers[Fingers["AnnularFinger"] = 3] = "AnnularFinger"; /** * The little finger */ Fingers[Fingers["LittleFinger"] = 4] = "LittleFinger"; })(Fingers || (Fingers = {})); /** * Lists all harmonic types. */ var HarmonicType; (function (HarmonicType) { /** * No harmonics. */ HarmonicType[HarmonicType["None"] = 0] = "None"; /** * Natural harmonic */ HarmonicType[HarmonicType["Natural"] = 1] = "Natural"; /** * Artificial harmonic */ HarmonicType[HarmonicType["Artificial"] = 2] = "Artificial"; /** * Pinch harmonics */ HarmonicType[HarmonicType["Pinch"] = 3] = "Pinch"; /** * Tap harmonics */ HarmonicType[HarmonicType["Tap"] = 4] = "Tap"; /** * Semi harmonics */ HarmonicType[HarmonicType["Semi"] = 5] = "Semi"; /** * Feedback harmonics */ HarmonicType[HarmonicType["Feedback"] = 6] = "Feedback"; })(HarmonicType || (HarmonicType = {})); /** * Lists the modes how accidentals are handled for notes */ var NoteAccidentalMode; (function (NoteAccidentalMode) { /** * Accidentals are calculated automatically. */ NoteAccidentalMode[NoteAccidentalMode["Default"] = 0] = "Default"; /** * This will try to ensure that no accidental is shown. */ NoteAccidentalMode[NoteAccidentalMode["ForceNone"] = 1] = "ForceNone"; /** * This will move the note one line down and applies a Naturalize. */ NoteAccidentalMode[NoteAccidentalMode["ForceNatural"] = 2] = "ForceNatural"; /** * This will move the note one line down and applies a Sharp. */ NoteAccidentalMode[NoteAccidentalMode["ForceSharp"] = 3] = "ForceSharp"; /** * This will move the note to be shown 2 half-notes deeper with a double sharp symbol */ NoteAccidentalMode[NoteAccidentalMode["ForceDoubleSharp"] = 4] = "ForceDoubleSharp"; /** * This will move the note one line up and applies a Flat. */ NoteAccidentalMode[NoteAccidentalMode["ForceFlat"] = 5] = "ForceFlat"; /** * This will move the note two half notes up with a double flag symbol. */ NoteAccidentalMode[NoteAccidentalMode["ForceDoubleFlat"] = 6] = "ForceDoubleFlat"; })(NoteAccidentalMode || (NoteAccidentalMode = {})); /** * This public enum lists all different types of finger slide-ins on a string. */ var SlideInType; (function (SlideInType) { /** * No slide. */ SlideInType[SlideInType["None"] = 0] = "None"; /** * Slide into the note from below on the same string. */ SlideInType[SlideInType["IntoFromBelow"] = 1] = "IntoFromBelow"; /** * Slide into the note from above on the same string. */ SlideInType[SlideInType["IntoFromAbove"] = 2] = "IntoFromAbove"; })(SlideInType || (SlideInType = {})); /** * This public enum lists all different types of finger slide-outs on a string. */ var SlideOutType; (function (SlideOutType) { /** * No slide. */ SlideOutType[SlideOutType["None"] = 0] = "None"; /** * Shift slide to next note on same string */ SlideOutType[SlideOutType["Shift"] = 1] = "Shift"; /** * Legato slide to next note on same string. */ SlideOutType[SlideOutType["Legato"] = 2] = "Legato"; /** * Slide out from the note from upwards on the same string. */ SlideOutType[SlideOutType["OutUp"] = 3] = "OutUp"; /** * Slide out from the note from downwards on the same string. */ SlideOutType[SlideOutType["OutDown"] = 4] = "OutDown"; /** * Pickslide down on this note */ SlideOutType[SlideOutType["PickSlideDown"] = 5] = "PickSlideDown"; /** * Pickslide up on this note */ SlideOutType[SlideOutType["PickSlideUp"] = 6] = "PickSlideUp"; })(SlideOutType || (SlideOutType = {})); /** * This public enum lists all vibrato types that can be performed. */ var VibratoType; (function (VibratoType) { /** * No vibrato. */ VibratoType[VibratoType["None"] = 0] = "None"; /** * A slight vibrato. */ VibratoType[VibratoType["Slight"] = 1] = "Slight"; /** * A wide vibrato. */ VibratoType[VibratoType["Wide"] = 2] = "Wide"; })(VibratoType || (VibratoType = {})); /** * Lists the different modes on how rhythm notation is shown on the tab staff. */ exports.TabRhythmMode = void 0; (function (TabRhythmMode) { /** * Rhythm notation is hidden. */ TabRhythmMode[TabRhythmMode["Hidden"] = 0] = "Hidden"; /** * Rhythm notation is shown with individual beams per beat. */ TabRhythmMode[TabRhythmMode["ShowWithBeams"] = 1] = "ShowWithBeams"; /** * Rhythm notation is shown and behaves like normal score notation with connected bars. */ TabRhythmMode[TabRhythmMode["ShowWithBars"] = 2] = "ShowWithBars"; })(exports.TabRhythmMode || (exports.TabRhythmMode = {})); /** * Lists all modes on how fingerings should be displayed. */ exports.FingeringMode = void 0; (function (FingeringMode) { /** * Fingerings will be shown in the standard notation staff. */ FingeringMode[FingeringMode["ScoreDefault"] = 0] = "ScoreDefault"; /** * Fingerings will be shown in the standard notation staff. Piano finger style is enforced, where * fingers are rendered as 1-5 instead of p,i,m,a,c and T,1,2,3,4. */ FingeringMode[FingeringMode["ScoreForcePiano"] = 1] = "ScoreForcePiano"; /** * Fingerings will be shown in a effect band above the tabs in case * they have only a single note on the beat. */ FingeringMode[FingeringMode["SingleNoteEffectBand"] = 2] = "SingleNoteEffectBand"; /** * Fingerings will be shown in a effect band above the tabs in case * they have only a single note on the beat. Piano finger style is enforced, where * fingers are rendered as 1-5 instead of p,i,m,a,c and T,1,2,3,4. */ FingeringMode[FingeringMode["SingleNoteEffectBandForcePiano"] = 3] = "SingleNoteEffectBandForcePiano"; })(exports.FingeringMode || (exports.FingeringMode = {})); /** * Lists all modes on how alphaTab can handle the display and playback of music notation. */ exports.NotationMode = void 0; (function (NotationMode) { /** * Music elements will be displayed and played as in Guitar Pro. */ NotationMode[NotationMode["GuitarPro"] = 0] = "GuitarPro"; /** * Music elements will be displayed and played as in traditional songbooks. * Changes: * 1. Bends * For bends additional grace beats are introduced. * Bends are categorized into gradual and fast bends. * - Gradual bends are indicated by beat text "grad" or "grad.". Bend will sound along the beat duration. * - Fast bends are done right before the next note. If the next note is tied even on-beat of the next note. * 2. Whammy Bars * Dips are shown as simple annotation over the beats * Whammy Bars are categorized into gradual and fast. * - Gradual whammys are indicated by beat text "grad" or "grad.". Whammys will sound along the beat duration. * - Fast whammys are done right the beat. * 3. Let Ring * Tied notes with let ring are not shown in standard notation * Let ring does not cause a longer playback, duration is defined via tied notes. */ NotationMode[NotationMode["SongBook"] = 1] = "SongBook"; })(exports.NotationMode || (exports.NotationMode = {})); /** * Lists all major music notation elements that are part * of the music sheet and can be dynamically controlled to be shown * or hidden. */ var NotationElement; (function (NotationElement) { /** * The score title shown at the start of the music sheet. */ NotationElement[NotationElement["ScoreTitle"] = 0] = "ScoreTitle"; /** * The score subtitle shown at the start of the music sheet. */ NotationElement[NotationElement["ScoreSubTitle"] = 1] = "ScoreSubTitle"; /** * The score artist shown at the start of the music sheet. */ NotationElement[NotationElement["ScoreArtist"] = 2] = "ScoreArtist"; /** * The score album shown at the start of the music sheet. */ NotationElement[NotationElement["ScoreAlbum"] = 3] = "ScoreAlbum"; /** * The score words author shown at the start of the music sheet. */ NotationElement[NotationElement["ScoreWords"] = 4] = "ScoreWords"; /** * The score music author shown at the start of the music sheet. */ NotationElement[NotationElement["ScoreMusic"] = 5] = "ScoreMusic"; /** * The score words&music author shown at the start of the music sheet. */ NotationElement[NotationElement["ScoreWordsAndMusic"] = 6] = "ScoreWordsAndMusic"; /** * The score copyright owner shown at the start of the music sheet. */ NotationElement[NotationElement["ScoreCopyright"] = 7] = "ScoreCopyright"; /** * The tuning information of the guitar shown * above the staves. */ NotationElement[NotationElement["GuitarTuning"] = 8] = "GuitarTuning"; /** * The track names which are shown in the accolade. */ NotationElement[NotationElement["TrackNames"] = 9] = "TrackNames"; /** * The chord diagrams for guitars. Usually shown * below the score info. */ NotationElement[NotationElement["ChordDiagrams"] = 10] = "ChordDiagrams"; /** * Parenthesis that are shown for tied bends * if they are preceeded by bends. */ NotationElement[NotationElement["ParenthesisOnTiedBends"] = 11] = "ParenthesisOnTiedBends"; /** * The tab number for tied notes if the * bend of a note is increased at that point. */ NotationElement[NotationElement["TabNotesOnTiedBends"] = 12] = "TabNotesOnTiedBends"; /** * Zero tab numbers on "dive whammys". */ NotationElement[NotationElement["ZerosOnDiveWhammys"] = 13] = "ZerosOnDiveWhammys"; /** * The alternate endings information on repeats shown above the staff. */ NotationElement[NotationElement["EffectAlternateEndings"] = 14] = "EffectAlternateEndings"; /** * The information about the fret on which the capo is placed shown above the staff. */ NotationElement[NotationElement["EffectCapo"] = 15] = "EffectCapo"; /** * The chord names shown above beats shown above the staff. */ NotationElement[NotationElement["EffectChordNames"] = 16] = "EffectChordNames"; /** * The crescendo/decrescendo angle shown above the staff. */ NotationElement[NotationElement["EffectCrescendo"] = 17] = "EffectCrescendo"; /** * The beat dynamics shown above the staff. */ NotationElement[NotationElement["EffectDynamics"] = 18] = "EffectDynamics"; /** * The curved angle for fade in/out effects shown above the staff. */ NotationElement[NotationElement["EffectFadeIn"] = 19] = "EffectFadeIn"; /** * The fermata symbol shown above the staff. */ NotationElement[NotationElement["EffectFermata"] = 20] = "EffectFermata"; /** * The fingering information. */ NotationElement[NotationElement["EffectFingering"] = 21] = "EffectFingering"; /** * The harmonics names shown above the staff. * (does not represent the harmonic note heads) */ NotationElement[NotationElement["EffectHarmonics"] = 22] = "EffectHarmonics"; /** * The let ring name and line above the staff. */ NotationElement[NotationElement["EffectLetRing"] = 23] = "EffectLetRing"; /** * The lyrics of the track shown above the staff. */ NotationElement[NotationElement["EffectLyrics"] = 24] = "EffectLyrics"; /** * The section markers shown above the staff. */ NotationElement[NotationElement["EffectMarker"] = 25] = "EffectMarker"; /** * The ottava symbol and lines shown above the staff. */ NotationElement[NotationElement["EffectOttavia"] = 26] = "EffectOttavia"; /** * The palm mute name and line shown above the staff. */ NotationElement[NotationElement["EffectPalmMute"] = 27] = "EffectPalmMute"; /** * The pick slide information shown above the staff. * (does not control the pick slide lines) */ NotationElement[NotationElement["EffectPickSlide"] = 28] = "EffectPickSlide"; /** * The pick stroke symbols shown above the staff. */ NotationElement[NotationElement["EffectPickStroke"] = 29] = "EffectPickStroke"; /** * The slight beat vibrato waves shown above the staff. */ NotationElement[NotationElement["EffectSlightBeatVibrato"] = 30] = "EffectSlightBeatVibrato"; /** * The slight note vibrato waves shown above the staff. */ NotationElement[NotationElement["EffectSlightNoteVibrato"] = 31] = "EffectSlightNoteVibrato"; /** * The tap/slap/pop effect names shown above the staff. */ NotationElement[NotationElement["EffectTap"] = 32] = "EffectTap"; /** * The tempo information shown above the staff. */ NotationElement[NotationElement["EffectTempo"] = 33] = "EffectTempo"; /** * The additional beat text shown above the staff. */ NotationElement[NotationElement["EffectText"] = 34] = "EffectText"; /** * The trill name and waves shown above the staff. */ NotationElement[NotationElement["EffectTrill"] = 35] = "EffectTrill"; /** * The triplet feel symbol shown above the staff. */ NotationElement[NotationElement["EffectTripletFeel"] = 36] = "EffectTripletFeel"; /** * The whammy bar information shown above the staff. * (does not control the whammy lines shown within the staff) */ NotationElement[NotationElement["EffectWhammyBar"] = 37] = "EffectWhammyBar"; /** * The wide beat vibrato waves shown above the staff. */ NotationElement[NotationElement["EffectWideBeatVibrato"] = 38] = "EffectWideBeatVibrato"; /** * The wide note vibrato waves shown above the staff. */ NotationElement[NotationElement["EffectWideNoteVibrato"] = 39] = "EffectWideNoteVibrato"; /** * The left hand tap symbol shown above the staff. */ NotationElement[NotationElement["EffectLeftHandTap"] = 40] = "EffectLeftHandTap"; })(NotationElement || (NotationElement = {})); /** * The notation settings control how various music notation elements are shown and behaving * @json */ class NotationSettings { constructor() { /** * Gets or sets the mode to use for display and play music notation elements. */ this.notationMode = exports.NotationMode.GuitarPro; /** * Gets or sets the fingering mode to use. */ this.fingeringMode = exports.FingeringMode.ScoreDefault; /** * Gets or sets the configuration on whether music notation elements are visible or not. * If notation elements are not specified, the default configuration will be applied. */ this.elements = new Map(); /** * Whether to show rhythm notation in the guitar tablature. */ this.rhythmMode = exports.TabRhythmMode.Hidden; /** * The height of the rythm bars. */ this.rhythmHeight = 15; /** * The transposition pitch offsets for the individual tracks. * They apply to rendering and playback. */ this.transpositionPitches = []; /** * The transposition pitch offsets for the individual tracks. * They apply to rendering only. */ this.displayTranspositionPitches = []; /** * If set to true the guitar tabs on grace beats are rendered smaller. */ this.smallGraceTabNotes = true; /** * If set to true bend arrows expand to the end of the last tied note * of the string. Otherwise they end on the next beat. */ this.extendBendArrowsOnTiedNotes = true; /** * If set to true, line effects (like w/bar, let-ring etc) * are drawn until the end of the beat instead of the start. */ this.extendLineEffectsToBeatEnd = false; /** * Gets or sets the height for slurs. The factor is multiplied with the a logarithmic distance * between slur start and end. */ this.slurHeight = 5.0; } /** * Gets whether the given music notation element should be shown * @param element the element to check * @returns true if the element should be shown, otherwise false. */ isNotationElementVisible(element) { if (this.elements.has(element)) { return this.elements.get(element); } if (NotationSettings.defaultElements.has(element)) { return NotationSettings.defaultElements.get(element); } return true; } } /** * Gets the default configuration of the {@see notationElements} setting. Do not modify * this map as it might not result in the expected side effects. * If items are not listed explicitly in this list, they are considered visible. */ NotationSettings.defaultElements = new Map([ [NotationElement.ZerosOnDiveWhammys, false] ]); /** * @target web */ class Lazy { constructor(factory) { this._value = undefined; this._factory = factory; } get value() { if (this._value === undefined) { this._value = this._factory(); } return this._value; } } /** * Defines all loglevels. * @json */ exports.LogLevel = void 0; (function (LogLevel) { /** * No logging */ LogLevel[LogLevel["None"] = 0] = "None"; /** * Debug level (internal details are displayed). */ LogLevel[LogLevel["Debug"] = 1] = "Debug"; /** * Info level (only important details are shown) */ LogLevel[LogLevel["Info"] = 2] = "Info"; /** * Warning level */ LogLevel[LogLevel["Warning"] = 3] = "Warning"; /** * Error level. */ LogLevel[LogLevel["Error"] = 4] = "Error"; })(exports.LogLevel || (exports.LogLevel = {})); class ConsoleLogger { static format(category, msg) { return `[AlphaTab][${category}] ${msg}`; } debug(category, msg, ...details) { console.debug(ConsoleLogger.format(category, msg), ...details); } warning(category, msg, ...details) { console.warn(ConsoleLogger.format(category, msg), ...details); } info(category, msg, ...details) { console.info(ConsoleLogger.format(category, msg), ...details); } error(category, msg, ...details) { console.error(ConsoleLogger.format(category, msg), ...details); } } ConsoleLogger.logLevel = exports.LogLevel.Info; class Logger { static shouldLog(level) { return Logger.logLevel !== exports.LogLevel.None && level >= Logger.logLevel; } static debug(category, msg, ...details) { if (Logger.shouldLog(exports.LogLevel.Debug)) { Logger.log.debug(category, msg, ...details); } } static warning(category, msg, ...details) { if (Logger.shouldLog(exports.LogLevel.Warning)) { Logger.log.warning(category, msg, ...details); } } static info(category, msg, ...details) { if (Logger.shouldLog(exports.LogLevel.Info)) { Logger.log.info(category, msg, ...details); } } static error(category, msg, ...details) { if (Logger.shouldLog(exports.LogLevel.Error)) { Logger.log.error(category, msg, ...details); } } } Logger.logLevel = exports.LogLevel.Info; Logger.log = new ConsoleLogger(); class TuningParseResult { constructor() { this.note = null; this.noteValue = 0; this.octave = 0; } get realValue() { return this.octave * 12 + this.noteValue; } } /** * This public class contains some utilities for working with model public classes */ class ModelUtils { static getIndex(duration) { let index = 0; let value = duration; if (value < 0) { return index; } return Math.log2(duration) | 0; } static keySignatureIsFlat(ks) { return ks < 0; } static keySignatureIsNatural(ks) { return ks === 0; } static keySignatureIsSharp(ks) { return ks > 0; } static applyPitchOffsets(settings, score) { for (let i = 0; i < score.tracks.length; i++) { if (i < settings.notation.displayTranspositionPitches.length) { for (let staff of score.tracks[i].staves) { staff.displayTranspositionPitch = -settings.notation.displayTranspositionPitches[i]; } } if (i < settings.notation.transpositionPitches.length) { for (let staff of score.tracks[i].staves) { staff.transpositionPitch = -settings.notation.transpositionPitches[i]; } } } } static fingerToString(settings, beat, finger, leftHand) { if (settings.notation.fingeringMode === exports.FingeringMode.ScoreForcePiano || settings.notation.fingeringMode === exports.FingeringMode.SingleNoteEffectBandForcePiano || GeneralMidi.isPiano(beat.voice.bar.staff.