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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 1 addition & 61 deletions src/importer/AlphaTexImporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export class AlphaTexImporter extends ScoreImporter {
}
}

this.consolidate();
ModelUtils.consolidate(this._score);
this._score.finish(this.settings);
this._score.rebuildRepeatGroups();
for (const [track, lyrics] of this._lyrics) {
Expand All @@ -256,66 +256,6 @@ export class AlphaTexImporter extends ScoreImporter {
}
}

/**
* Ensures all staffs of all tracks have the correct number of bars
* (the number of bars per staff and track could be inconsistent)
*/
private consolidate(): void {
// empty score?
if (this._score.masterBars.length === 0) {
const master: MasterBar = new MasterBar();
this._score.addMasterBar(master);

const tempoAutomation: Automation = new Automation();
tempoAutomation.isLinear = false;
tempoAutomation.type = AutomationType.Tempo;
tempoAutomation.value = this._score.tempo;
master.tempoAutomations.push(tempoAutomation);

const bar: Bar = new Bar();
this._score.tracks[0].staves[0].addBar(bar);

const v = new Voice();
bar.addVoice(v);

const emptyBeat: Beat = new Beat();
emptyBeat.isEmpty = true;
v.addBeat(emptyBeat);
return;
}

for (const track of this._score.tracks) {
for (const staff of track.staves) {
// fill empty beats
for (const b of staff.bars) {
for (const v of b.voices) {
if (v.isEmpty && v.beats.length === 0) {
const emptyBeat: Beat = new Beat();
emptyBeat.isEmpty = true;
v.addBeat(emptyBeat);
}
}
}

// fill missing bars
const voiceCount = staff.bars.length === 0 ? 1 : staff.bars[0].voices.length;
while (staff.bars.length < this._score.masterBars.length) {
const bar: Bar = new Bar();
staff.addBar(bar);

for (let i = 0; i < voiceCount; i++) {
const v = new Voice();
bar.addVoice(v);

const emptyBeat: Beat = new Beat();
emptyBeat.isEmpty = true;
v.addBeat(emptyBeat);
}
}
}
}
}

private error(nonterm: string, expected: AlphaTexSymbols, wrongSymbol: boolean = true): void {
let receivedSymbol: AlphaTexSymbols;
let showSyData = false;
Expand Down
26 changes: 1 addition & 25 deletions src/importer/CapellaParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,31 +137,7 @@ export class CapellaParser {
}

private consolidate() {
// voice counts and contents might be inconsistent
// we need to ensure we have an equal amount of voices across all bars
// and voices must contain an empty beat at minimum
for (const track of this.score.tracks) {
const trackVoiceCount = this._voiceCounts.get(track.index)!;
for (const staff of track.staves) {
while (staff.bars.length < this.score.masterBars.length) {
this.addNewBar(staff);
}

for (const bar of staff.bars) {
while (bar.voices.length < trackVoiceCount) {
bar.addVoice(new Voice());
}

for (const voice of bar.voices) {
if (voice.beats.length === 0) {
const emptyBeat = new Beat();
emptyBeat.isEmpty = true;
voice.addBeat(emptyBeat);
}
}
}
}
}
ModelUtils.consolidate(this.score);

CapellaParser.applyEffectRange(this._slurs, (_, beat) => {
beat.isLegatoOrigin = true;
Expand Down
6 changes: 4 additions & 2 deletions src/importer/Gp3To5Importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export class Gp3To5Importer extends ScoreImporter {
this._score.masterBars[0].tempoAutomations.push(automation);
}

ModelUtils.consolidate(this._score);
this._score.finish(this.settings);
if (this._lyrics && this._lyricsTrack >= 0) {
this._score.tracks[this._lyricsTrack].applyLyrics(this._lyrics);
Expand Down Expand Up @@ -290,10 +291,11 @@ export class Gp3To5Importer extends ScoreImporter {

public readPlaybackInfos(): void {
this._playbackInfos = [];
let channel = 0;
for (let i: number = 0; i < 64; i++) {
const info: PlaybackInformation = new PlaybackInformation();
info.primaryChannel = i;
info.secondaryChannel = i;
info.primaryChannel = channel++;
info.secondaryChannel = channel++;
info.program = IOHelper.readInt32LE(this.data);
info.volume = this.data.readByte();
info.balance = this.data.readByte();
Expand Down
Loading