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
6 changes: 6 additions & 0 deletions src.csharp/AlphaTab/Core/TypeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ public static int CharCodeAt(this string s, double index)
{
return s[(int) index];
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string CharAt(this string s, double index)
{
return s.Substring((int) index, 1);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string ToLowerCase(this string s)
Expand Down
2 changes: 1 addition & 1 deletion src/DisplaySettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class DisplaySettings {
/**
* Gets or sets the resources used during rendering. This defines all fonts and colors used.
*/
public readonly resources: RenderingResources = new RenderingResources();
public resources: RenderingResources = new RenderingResources();

/**
* Gets or sets the padding between the music notation and the border.
Expand Down
6 changes: 4 additions & 2 deletions src/Environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import { Settings } from '@src/Settings';
import { FontLoadingChecker } from '@src/util/FontLoadingChecker';
import { Logger } from '@src/Logger';
import { LeftHandTapEffectInfo } from './rendering/effects/LeftHandTapEffectInfo';
import { CapellaImporter } from './importer/CapellaImporter';

export class LayoutEngineFactory {
public readonly vertical: boolean;
Expand Down Expand Up @@ -339,8 +340,9 @@ export class Environment {
new Gp3To5Importer(),
new GpxImporter(),
new Gp7Importer(),
new AlphaTexImporter(),
new MusicXmlImporter()
new MusicXmlImporter(),
new CapellaImporter(),
new AlphaTexImporter()
];
}

Expand Down
60 changes: 60 additions & 0 deletions src/importer/CapellaImporter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { ScoreImporter } from '@src/importer/ScoreImporter';
import { UnsupportedFormatError } from '@src/importer/UnsupportedFormatError';

import { Score } from '@src/model/Score';

import { Logger } from '@src/Logger';

import { ZipEntry, ZipReader } from '@src/zip/ZipReader';
import { IOHelper } from '@src/io/IOHelper';
import { CapellaParser } from './CapellaParser';

/**
* This ScoreImporter can read Capella (cap/capx) files.
*/
export class CapellaImporter extends ScoreImporter {
public get name(): string {
return 'Capella';
}

public constructor() {
super();
}

public readScore(): Score {
Logger.debug(this.name, 'Loading ZIP entries');
let fileSystem: ZipReader = new ZipReader(this.data);
let entries: ZipEntry[];
let xml: string | null = null;
entries = fileSystem.read();

Logger.debug(this.name, 'Zip entries loaded');
if (entries.length > 0) {
for (let entry of entries) {
switch (entry.fileName) {
case 'score.xml':
xml = IOHelper.toString(entry.data, this.settings.importer.encoding);
break;
}
}
} else {
this.data.reset();
xml = IOHelper.toString(this.data.readAll(), this.settings.importer.encoding);
}

if (!xml) {
throw new UnsupportedFormatError('No valid capella file');
}

Logger.debug(this.name, 'Start Parsing score.xml');
try {
let capellaParser: CapellaParser = new CapellaParser();
capellaParser.parseXml(xml, this.settings);
Logger.debug(this.name, 'score.xml parsed');
let score: Score = capellaParser.score;
return score;
} catch (e) {
throw new UnsupportedFormatError('Failed to parse CapXML', e);
}
}
}
Loading