Skip to content

Commit

Permalink
feat: Add Ragueado (#1748)
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielku15 authored Nov 10, 2024
1 parent a6d5246 commit 485f1c5
Show file tree
Hide file tree
Showing 15 changed files with 297 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/Environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import { GolpeType } from './model/GolpeType';
import { WahPedalEffectInfo } from './rendering/effects/WahPedalEffectInfo';
import { BeatBarreEffectInfo } from './rendering/effects/BeatBarreEffectInfo';
import { NoteOrnamentEffectInfo } from './rendering/effects/NoteOrnamentEffectInfo';
import { RasgueadoEffectInfo } from './rendering/effects/RasgueadoEffectInfo';

export class LayoutEngineFactory {
public readonly vertical: boolean;
Expand Down Expand Up @@ -513,6 +514,7 @@ export class Environment {
new FermataEffectInfo(),
new BeatBarreEffectInfo(),
new NoteOrnamentEffectInfo(),
new RasgueadoEffectInfo(),
new WahPedalEffectInfo(),
]),
new EffectBarRendererFactory(
Expand Down
5 changes: 5 additions & 0 deletions src/NotationSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ export enum NotationElement {
* The note ornaments like turns and mordents.
*/
EffectNoteOrnament,

/**
* The Rasgueado indicator above the staff Rasg. ----|"
*/
EffectRasgueado,
}

/**
Expand Down
65 changes: 64 additions & 1 deletion src/exporter/GpifWriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { Ottavia } from '@src/model/Ottavia';
import { PercussionMapper } from '@src/model/PercussionMapper';
import { PickStroke } from '@src/model/PickStroke';
import { PlaybackInformation } from '@src/model/PlaybackInformation';
import { Rasgueado } from '@src/model/Rasgueado';
import { Score } from '@src/model/Score';
import { SimileMark } from '@src/model/SimileMark';
import { SlideInType } from '@src/model/SlideInType';
Expand Down Expand Up @@ -384,7 +385,7 @@ export class GpifWriter {
noteNode.addElement('InstrumentArticulation').innerText = '0';
}

if(note.ornament !== NoteOrnament.None){
if (note.ornament !== NoteOrnament.None) {
noteNode.addElement('Ornament').innerText = NoteOrnament[note.ornament];
}
}
Expand Down Expand Up @@ -837,6 +838,68 @@ export class GpifWriter {
break;
}
}

if (beat.rasgueado != Rasgueado.None) {
let rasgueado = '';
switch (beat.rasgueado) {
case Rasgueado.Ii:
rasgueado = 'ii_1';
break;
case Rasgueado.Mi:
rasgueado = 'mi_1';
break;
case Rasgueado.MiiTriplet:
rasgueado = 'mii_1';
break;
case Rasgueado.MiiAnapaest:
rasgueado = 'mii_2';
break;
case Rasgueado.PmpTriplet:
rasgueado = 'pmp_1';
break;
case Rasgueado.PmpAnapaest:
rasgueado = 'pmp_2';
break;
case Rasgueado.PeiTriplet:
rasgueado = 'pei_1';
break;
case Rasgueado.PeiAnapaest:
rasgueado = 'pei_2';
break;
case Rasgueado.PaiTriplet:
rasgueado = 'pai_1';
break;
case Rasgueado.PaiAnapaest:
rasgueado = 'pai_2';
break;
case Rasgueado.AmiTriplet:
rasgueado = 'ami_1';
break;
case Rasgueado.AmiAnapaest:
rasgueado = 'ami_2';
break;
case Rasgueado.Ppp:
rasgueado = 'ppp_1';
break;
case Rasgueado.Amii:
rasgueado = 'amii_1';
break;
case Rasgueado.Amip:
rasgueado = 'amip_1';
break;
case Rasgueado.Eami:
rasgueado = 'eami_1';
break;
case Rasgueado.Eamii:
rasgueado = 'eamii_1';
break;
case Rasgueado.Peami:
rasgueado = 'peami_1';
break;
}

this.writeSimplePropertyNode(beatProperties, 'Rasgueado', 'Rasgueado', rasgueado);
}
}

private writeRhythm(parent: XmlNode, beat: Beat, rhythms: XmlNode) {
Expand Down
2 changes: 1 addition & 1 deletion src/generated/model/BeatCloner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export class BeatCloner {
clone.dots = original.dots;
clone.fade = original.fade;
clone.lyrics = original.lyrics ? original.lyrics.slice() : null;
clone.hasRasgueado = original.hasRasgueado;
clone.pop = original.pop;
clone.slap = original.slap;
clone.tap = original.tap;
Expand Down Expand Up @@ -67,6 +66,7 @@ export class BeatCloner {
clone.wahPedal = original.wahPedal;
clone.barreFret = original.barreFret;
clone.barreShape = original.barreShape;
clone.rasgueado = original.rasgueado;
return clone;
}
}
9 changes: 5 additions & 4 deletions src/generated/model/BeatSerializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { BeamDirection } from "@src/rendering/utils/BeamDirection";
import { BeatBeamingMode } from "@src/model/Beat";
import { WahPedal } from "@src/model/WahPedal";
import { BarreShape } from "@src/model/BarreShape";
import { Rasgueado } from "@src/model/Rasgueado";
export class BeatSerializer {
public static fromJson(obj: Beat, m: unknown): void {
if (!m) {
Expand All @@ -50,7 +51,6 @@ export class BeatSerializer {
o.set("dots", obj.dots);
o.set("fade", obj.fade as number);
o.set("lyrics", obj.lyrics);
o.set("hasrasgueado", obj.hasRasgueado);
o.set("pop", obj.pop);
o.set("slap", obj.slap);
o.set("tap", obj.tap);
Expand Down Expand Up @@ -84,6 +84,7 @@ export class BeatSerializer {
o.set("wahpedal", obj.wahPedal as number);
o.set("barrefret", obj.barreFret);
o.set("barreshape", obj.barreShape as number);
o.set("rasgueado", obj.rasgueado as number);
return o;
}
public static setProperty(obj: Beat, property: string, v: unknown): boolean {
Expand Down Expand Up @@ -131,9 +132,6 @@ export class BeatSerializer {
case "lyrics":
obj.lyrics = v as string[] | null;
return true;
case "hasrasgueado":
obj.hasRasgueado = v! as boolean;
return true;
case "pop":
obj.pop = v! as boolean;
return true;
Expand Down Expand Up @@ -234,6 +232,9 @@ export class BeatSerializer {
case "barreshape":
obj.barreShape = JsonHelper.parseEnum<BarreShape>(v, BarreShape)!;
return true;
case "rasgueado":
obj.rasgueado = JsonHelper.parseEnum<Rasgueado>(v, Rasgueado)!;
return true;
}
return false;
}
Expand Down
67 changes: 67 additions & 0 deletions src/importer/AlphaTexImporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { FadeType } from '@src/model/FadeType';
import { WahPedal } from '@src/model/WahPedal';
import { BarreShape } from '@src/model/BarreShape';
import { NoteOrnament } from '@src/model/NoteOrnament';
import { Rasgueado } from '@src/model/Rasgueado';

/**
* A list of terminals recognized by the alphaTex-parser
Expand Down Expand Up @@ -1665,6 +1666,72 @@ export class AlphaTexImporter extends ScoreImporter {
}
}

return true;
} else if (syData === 'rasg') {
this._sy = this.newSy();

if (this._sy !== AlphaTexSymbols.String) {
this.error('rasgueado', AlphaTexSymbols.String, true);
}

switch ((this._syData as string).toLowerCase()) {
case 'ii':
beat.rasgueado = Rasgueado.Ii;
break;
case 'mi':
beat.rasgueado = Rasgueado.Mi;
break;
case 'miitriplet':
beat.rasgueado = Rasgueado.MiiTriplet;
break;
case 'miianapaest':
beat.rasgueado = Rasgueado.MiiAnapaest;
break;
case 'pmptriplet':
beat.rasgueado = Rasgueado.PmpTriplet;
break;
case 'pmpanapaest':
beat.rasgueado = Rasgueado.PmpAnapaest;
break;
case 'peitriplet':
beat.rasgueado = Rasgueado.PeiTriplet;
break;
case 'peianapaest':
beat.rasgueado = Rasgueado.PeiAnapaest;
break;
case 'paitriplet':
beat.rasgueado = Rasgueado.PaiTriplet;
break;
case 'paianapaest':
beat.rasgueado = Rasgueado.PaiAnapaest;
break;
case 'amitriplet':
beat.rasgueado = Rasgueado.AmiTriplet;
break;
case 'amianapaest':
beat.rasgueado = Rasgueado.AmiAnapaest;
break;
case 'ppp':
beat.rasgueado = Rasgueado.Ppp;
break;
case 'amii':
beat.rasgueado = Rasgueado.Amii;
break;
case 'amip':
beat.rasgueado = Rasgueado.Amip;
break;
case 'eami':
beat.rasgueado = Rasgueado.Eami;
break;
case 'eamii':
beat.rasgueado = Rasgueado.Eamii;
break;
case 'peami':
beat.rasgueado = Rasgueado.Peami;
break;
}
this._sy = this.newSy();

return true;
} else {
// string didn't match any beat effect syntax
Expand Down
5 changes: 4 additions & 1 deletion src/importer/Gp3To5Importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { ModelUtils } from '@src/model/ModelUtils';
import { IWriteable } from '@src/io/IWriteable';
import { Tuning } from '@src/model/Tuning';
import { FadeType } from '@src/model/FadeType';
import { Rasgueado } from '@src/model/Rasgueado';

export class Gp3To5Importer extends ScoreImporter {
private static readonly VersionString: string = 'FICHIER GUITAR PRO ';
Expand Down Expand Up @@ -690,7 +691,9 @@ export class Gp3To5Importer extends ScoreImporter {
if ((this._versionNumber < 400 && (flags & 0x01) !== 0) || (flags & 0x02) !== 0) {
beat.vibrato = VibratoType.Slight;
}
beat.hasRasgueado = (flags2 & 0x01) !== 0;
if( (flags2 & 0x01) !== 0) {
beat.rasgueado = Rasgueado.Ii;
}
if ((flags & 0x20) !== 0 && this._versionNumber >= 400) {
let slapPop: number = IOHelper.readSInt8(this.data);
switch (slapPop) {
Expand Down
59 changes: 59 additions & 0 deletions src/importer/GpifParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { FadeType } from '@src/model/FadeType';
import { WahPedal } from '@src/model/WahPedal';
import { BarreShape } from '@src/model/BarreShape';
import { NoteOrnament } from '@src/model/NoteOrnament';
import { Rasgueado } from '@src/model/Rasgueado';

/**
* This structure represents a duration within a gpif
Expand Down Expand Up @@ -1841,6 +1842,64 @@ export class GpifParser {
break;
}
break;
case 'Rasgueado':
switch (c.findChildElement('Rasgueado')!.innerText) {
case 'ii_1':
beat.rasgueado = Rasgueado.Ii;
break;
case 'mi_1':
beat.rasgueado = Rasgueado.Mi;
break;
case 'mii_1':
beat.rasgueado = Rasgueado.MiiTriplet;
break;
case 'mii_2':
beat.rasgueado = Rasgueado.MiiAnapaest;
break;
case 'pmp_1':
beat.rasgueado = Rasgueado.PmpTriplet;
break;
case 'pmp_2':
beat.rasgueado = Rasgueado.PmpAnapaest;
break;
case 'pei_1':
beat.rasgueado = Rasgueado.PeiTriplet;
break;
case 'pei_2':
beat.rasgueado = Rasgueado.PeiAnapaest;
break;
case 'pai_1':
beat.rasgueado = Rasgueado.PaiTriplet;
break;
case 'pai_2':
beat.rasgueado = Rasgueado.PaiAnapaest;
break;
case 'ami_1':
beat.rasgueado = Rasgueado.AmiTriplet;
break;
case 'ami_2':
beat.rasgueado = Rasgueado.AmiAnapaest;
break;
case 'ppp_1':
beat.rasgueado = Rasgueado.Ppp;
break;
case 'amii_1':
beat.rasgueado = Rasgueado.Amii;
break;
case 'amip_1':
beat.rasgueado = Rasgueado.Amip;
break;
case 'eami_1':
beat.rasgueado = Rasgueado.Eami;
break;
case 'eamii_1':
beat.rasgueado = Rasgueado.Eamii;
break;
case 'peami_1':
beat.rasgueado = Rasgueado.Peami;
break;
}
break;
}
break;
}
Expand Down
10 changes: 9 additions & 1 deletion src/model/Beat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { GolpeType } from './GolpeType';
import { FadeType } from './FadeType';
import { WahPedal } from './WahPedal';
import { BarreShape } from './BarreShape';
import { Rasgueado } from './Rasgueado';

/**
* Lists the different modes on how beaming for a beat should be done.
Expand Down Expand Up @@ -239,7 +240,9 @@ export class Beat {
/**
* Gets or sets a value indicating whether the beat is played in rasgueado style.
*/
public hasRasgueado: boolean = false;
public get hasRasgueado(): boolean {
return this.rasgueado !== Rasgueado.None;
}

/**
* Gets or sets a value indicating whether the notes on this beat are played with a pop-style (bass).
Expand Down Expand Up @@ -496,6 +499,11 @@ export class Beat {
return this.barreShape !== BarreShape.None && this.barreFret >= 0;
}

/**
* The Rasgueado pattern to play with this beat.
*/
public rasgueado: Rasgueado = Rasgueado.None;

public addWhammyBarPoint(point: BendPoint): void {
let points = this.whammyBarPoints;
if (points === null) {
Expand Down
Loading

0 comments on commit 485f1c5

Please sign in to comment.