Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Wah Pedal #1745

Merged
merged 1 commit into from
Nov 10, 2024
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: 5 additions & 1 deletion src/Environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import { TabBarRenderer } from './rendering/TabBarRenderer';
import { SustainPedalEffectInfo } from './rendering/effects/SustainPedalEffectInfo';
import { GolpeEffectInfo } from './rendering/effects/GolpeEffectInfo';
import { GolpeType } from './model/GolpeType';
import { WahPedalEffectInfo } from './rendering/effects/WahPedalEffectInfo';

export class LayoutEngineFactory {
public readonly vertical: boolean;
Expand Down Expand Up @@ -506,7 +507,10 @@ export class Environment {

//
// Score (standard notation)
new EffectBarRendererFactory(Environment.StaffIdBeforeScoreAlways, [new FermataEffectInfo()]),
new EffectBarRendererFactory(Environment.StaffIdBeforeScoreAlways, [
new FermataEffectInfo(),
new WahPedalEffectInfo()
]),
new EffectBarRendererFactory(
Environment.StaffIdBeforeScoreHideable,
[
Expand Down
9 changes: 7 additions & 2 deletions src/NotationSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,14 @@ export enum NotationElement {
EffectSustainPedal,

/**
* The Golpe effect signs above and below the saff.
* The Golpe effect signs above and below the staff.
*/
EffectGolpe
EffectGolpe,

/**
* The Wah effect signs above and below the staff.
*/
EffectWahPedal
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/exporter/GpifWriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { TripletFeel } from '@src/model/TripletFeel';
import { Tuning } from '@src/model/Tuning';
import { VibratoType } from '@src/model/VibratoType';
import { Voice } from '@src/model/Voice';
import { WahPedal } from '@src/model/WahPedal';
import { TextBaseline } from '@src/platform/ICanvas';
import { BeamDirection } from '@src/rendering/utils/BeamDirection';
import { XmlDocument } from '@src/xml/XmlDocument';
Expand Down Expand Up @@ -753,6 +754,10 @@ export class GpifWriter {
beatNode.addElement('Golpe').innerText = GolpeType[beat.golpe];
}

if (beat.wahPedal !== WahPedal.None) {
beatNode.addElement('Wah').innerText = WahPedal[beat.wahPedal];
}

this.writeBeatProperties(beatNode, beat);
this.writeBeatXProperties(beatNode, beat);

Expand Down
1 change: 1 addition & 0 deletions src/generated/model/BeatCloner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class BeatCloner {
clone.preferredBeamDirection = original.preferredBeamDirection;
clone.isEffectSlurOrigin = original.isEffectSlurOrigin;
clone.beamingMode = original.beamingMode;
clone.wahPedal = original.wahPedal;
return clone;
}
}
5 changes: 5 additions & 0 deletions src/generated/model/BeatSerializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { GolpeType } from "@src/model/GolpeType";
import { DynamicValue } from "@src/model/DynamicValue";
import { BeamDirection } from "@src/rendering/utils/BeamDirection";
import { BeatBeamingMode } from "@src/model/Beat";
import { WahPedal } from "@src/model/WahPedal";
export class BeatSerializer {
public static fromJson(obj: Beat, m: unknown): void {
if (!m) {
Expand Down Expand Up @@ -79,6 +80,7 @@ export class BeatSerializer {
o.set("invertbeamdirection", obj.invertBeamDirection);
o.set("preferredbeamdirection", obj.preferredBeamDirection as number | null);
o.set("beamingmode", obj.beamingMode as number);
o.set("wahpedal", obj.wahPedal as number);
return o;
}
public static setProperty(obj: Beat, property: string, v: unknown): boolean {
Expand Down Expand Up @@ -220,6 +222,9 @@ export class BeatSerializer {
case "beamingmode":
obj.beamingMode = JsonHelper.parseEnum<BeatBeamingMode>(v, BeatBeamingMode)!;
return true;
case "wahpedal":
obj.wahPedal = JsonHelper.parseEnum<WahPedal>(v, WahPedal)!;
return true;
}
return false;
}
Expand Down
9 changes: 9 additions & 0 deletions src/importer/AlphaTexImporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { PercussionMapper } from '@src/model/PercussionMapper';
import { NoteAccidentalMode } from '@src/model';
import { GolpeType } from '@src/model/GolpeType';
import { FadeType } from '@src/model/FadeType';
import { WahPedal } from '@src/model/WahPedal';

/**
* A list of terminals recognized by the alphaTex-parser
Expand Down Expand Up @@ -1631,6 +1632,14 @@ export class AlphaTexImporter extends ScoreImporter {
this._sy = this.newSy();
beat.golpe = GolpeType.Thumb;
return true;
} else if (syData === 'waho') {
this._sy = this.newSy();
beat.wahPedal = WahPedal.Open;
return true;
} else if (syData === 'wahc') {
this._sy = this.newSy();
beat.wahPedal = WahPedal.Closed;
return true;
} else {
// string didn't match any beat effect syntax
return false;
Expand Down
11 changes: 11 additions & 0 deletions src/importer/GpifParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { NoteCloner } from '@src/generated/model/NoteCloner';
import { Logger } from '@src/Logger';
import { GolpeType } from '@src/model/GolpeType';
import { FadeType } from '@src/model/FadeType';
import { WahPedal } from '@src/model/WahPedal';

/**
* This structure represents a duration within a gpif
Expand Down Expand Up @@ -1635,6 +1636,16 @@ export class GpifParser {
break;
}
break;
case 'Wah':
switch (c.innerText) {
case 'Open':
beat.wahPedal = WahPedal.Open;
break;
case 'Closed':
beat.wahPedal = WahPedal.Closed;
break;
}
break;
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/model/Beat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { BeatCloner } from '@src/generated/model/BeatCloner';
import { GraceGroup } from '@src/model/GraceGroup';
import { GolpeType } from './GolpeType';
import { FadeType } from './FadeType';
import { WahPedal } from './WahPedal';

/**
* Lists the different modes on how beaming for a beat should be done.
Expand Down Expand Up @@ -472,6 +473,11 @@ export class Beat {
*/
public beamingMode: BeatBeamingMode = BeatBeamingMode.Auto;

/**
* Whether the wah pedal should be used when playing the beat.
*/
public wahPedal:WahPedal = WahPedal.None;

public addWhammyBarPoint(point: BendPoint): void {
let points = this.whammyBarPoints;
if (points === null) {
Expand Down
3 changes: 3 additions & 0 deletions src/model/MusicFontSymbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ export enum MusicFontSymbol {
GuitarString8 = 0xe83b,
GuitarString9 = 0xe83c,

GuitarOpenPedal = 0xe83d,
GuitarClosePedal = 0xe83f,

GuitarGolpe = 0xe842,
GuitarFadeIn = 0xe843,
GuitarFadeOut = 0xe844,
Expand Down
8 changes: 8 additions & 0 deletions src/model/WahPedal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Lists all wah pedal modes.
*/
export enum WahPedal {
None,
Open,
Closed
}
39 changes: 39 additions & 0 deletions src/rendering/effects/WahPedalEffectInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Beat } from '@src/model';
import { NotationElement } from '@src/NotationSettings';
import { BarRendererBase } from '../BarRendererBase';
import { EffectBarGlyphSizing } from '../EffectBarGlyphSizing';
import { EffectBarRendererInfo } from '../EffectBarRendererInfo';
import { EffectGlyph } from '../glyphs/EffectGlyph';
import { WahPedal } from '@src/model/WahPedal';
import { Settings } from '@src/Settings';
import { WahPedalGlyph } from '../glyphs/WahPedalGlyph';

export class WahPedalEffectInfo extends EffectBarRendererInfo {
public get notationElement(): NotationElement {
return NotationElement.EffectWahPedal;
}

public get hideOnMultiTrack(): boolean {
return false;
}

public get canShareBand(): boolean {
return true;
}

public get sizingMode(): EffectBarGlyphSizing {
return EffectBarGlyphSizing.SingleOnBeat;
}

public shouldCreateGlyph(settings: Settings, beat: Beat): boolean {
return beat.wahPedal !== WahPedal.None;
}

public createNewGlyph(renderer: BarRendererBase, beat: Beat): EffectGlyph {
return new WahPedalGlyph(beat.wahPedal);
}

public canExpand(from: Beat, to: Beat): boolean {
return false;
}
}
29 changes: 29 additions & 0 deletions src/rendering/glyphs/WahPedalGlyph.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { MusicFontSymbol } from '@src/model/MusicFontSymbol';
import { WahPedal } from '@src/model/WahPedal';
import { MusicFontGlyph } from './MusicFontGlyph';
import { ICanvas } from '@src/platform';

export class WahPedalGlyph extends MusicFontGlyph {
public constructor(wahPedal: WahPedal) {
super(0, 0, 1, WahPedalGlyph.getSymbol(wahPedal));
this.center = true;
}
private static getSymbol(wahPedal: WahPedal): MusicFontSymbol {
switch (wahPedal) {
case WahPedal.Open:
return MusicFontSymbol.GuitarOpenPedal;
case WahPedal.Closed:
return MusicFontSymbol.GuitarClosePedal;
}
return MusicFontSymbol.None;
}

public override doLayout(): void {
this.width = 11 * this.scale;
this.height = 11 * this.scale;
}

public override paint(cx: number, cy: number, canvas: ICanvas): void {
super.paint(cx, cy + this.height, canvas);
}
}
Binary file modified test-data/visual-tests/notation-legend/full-default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test-data/visual-tests/notation-legend/full-songbook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test-data/visual-tests/notation-legend/resize-sequence-1300.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test-data/visual-tests/notation-legend/resize-sequence-1500.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test-data/visual-tests/notation-legend/resize-sequence-500.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test-data/visual-tests/notation-legend/resize-sequence-800.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test-data/visual-tests/notation-legend/wah-default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test-data/visual-tests/notation-legend/wah-songbook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading