Skip to content

Commit 7da5242

Browse files
authored
Release 1.1 (#444)
1 parent f391fc6 commit 7da5242

File tree

415 files changed

+5669
-2232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

415 files changed

+5669
-2232
lines changed

package-lock.json

Lines changed: 307 additions & 309 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coderline/alphatab",
3-
"version": "1.0.1",
3+
"version": "1.1.0",
44
"description": "alphaTab is a music notation and guitar tablature rendering library",
55
"keywords": [
66
"guitar",
@@ -30,7 +30,7 @@
3030
"lint": "tslint --project tsconfig.build.json -t codeFrame 'src/**/*.ts' 'test/**/*.ts'",
3131
"build": "ttsc --project tsconfig.build.json && rollup -c rollup.config.js",
3232
"build-ci": "npm run clean && npm run build && npm pack",
33-
"start": "node scripts/setup-playground.js && npm run build && concurrently --kill-others \"ttsc --project tsconfig.build.json --watch\" \"rollup -c rollup.config.js -w\" \"http-server -o playground/control.html \"",
33+
"start": "node scripts/setup-playground.js && npm run build && concurrently --kill-others \"ttsc --project tsconfig.build.json --watch\" \"rollup -c rollup.config.js -w\"",
3434
"test": "ttsc --project tsconfig.json && concurrently --kill-others \"ttsc --project tsconfig.json -w\" \"karma start karma.conf.js --browsers Chrome --no-single-run --reporters spec,kjhtml\"",
3535
"test-ci": "ttsc --project tsconfig.json && karma start karma.conf.js --browsers ChromeHeadless --single-run --reporters spec",
3636
"generate-csharp": "ts-node --project tsconfig.build-csharp.json src.compiler/csharp/CSharpTranspiler.ts --project tsconfig.build-csharp.json",
@@ -40,35 +40,35 @@
4040
"test-csharp-ci": "cd src.csharp && dotnet test"
4141
},
4242
"devDependencies": {
43-
"@rollup/plugin-commonjs": "^14.0.0",
44-
"@types/jasmine": "^3.5.11",
45-
"concurrently": "^5.2.0",
43+
"@rollup/plugin-commonjs": "^16.0.0",
44+
"@types/jasmine": "^3.6.1",
45+
"concurrently": "^5.3.0",
4646
"cors": "^2.8.5",
4747
"fs-extra": "^9.0.1",
4848
"git-branch": "^2.0.1",
49-
"http-server": "^0.12.3",
50-
"karma": "^5.1.0",
49+
"karma": "^5.2.3",
5150
"karma-chrome-launcher": "^3.1.0",
5251
"karma-express-http-server": "0.0.1",
53-
"karma-jasmine": "^3.3.1",
52+
"karma-jasmine": "^4.0.1",
5453
"karma-jasmine-html-reporter": "^1.5.4",
5554
"karma-rollup-preprocessor": "^7.0.5",
5655
"karma-spec-reporter": "0.0.32",
57-
"lodash": "^4.17.19",
56+
"lodash": "^4.17.20",
5857
"multer": "^1.4.2",
5958
"rimraf": "^3.0.2",
60-
"rollup": "^2.21.0",
59+
"rollup": "^2.33.1",
6160
"rollup-plugin-copy": "^3.3.0",
62-
"rollup-plugin-dts": "^1.4.8",
63-
"rollup-plugin-license": "^2.1.0",
64-
"rollup-plugin-terser": "^6.1.0",
65-
"terser": "^4.8.0",
66-
"ts-node": "^8.10.2",
67-
"tslint": "^6.1.2",
61+
"rollup-plugin-dts": "^1.4.13",
62+
"rollup-plugin-license": "^2.2.0",
63+
"rollup-plugin-serve": "^1.1.0",
64+
"rollup-plugin-terser": "^7.0.2",
65+
"terser": "^5.3.8",
66+
"ts-node": "^9.0.0",
67+
"tslint": "^6.1.3",
6868
"tslint-config-prettier": "^1.15.0",
6969
"tslint-config-standard": "^9.0.0",
70-
"ttypescript": "^1.5.10",
71-
"typescript": "^3.9.6"
70+
"ttypescript": "^1.5.12",
71+
"typescript": "^4.0.5"
7272
},
7373
"files": [
7474
"/dist/alphaTab.js",

playground-template/control-template.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@
8888
</div>
8989

9090
<div class="at-player-right">
91+
<a href="#" class="at-count-in disabled" data-toggle="tooltip" data-placement="top" title="Count-In">
92+
<i class="fas fa-hourglass-half"></i>
93+
</a>
9194
<a href="#" class="at-metronome disabled" data-toggle="tooltip" data-placement="top" title="Metronome">
9295
<i class="fas fa-edit"></i>
9396
</a>

playground-template/control.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,17 @@ function setupControl(selector) {
201201
}
202202
};
203203

204+
control.querySelector('.at-count-in').onclick = function (e) {
205+
e.stopPropagation();
206+
const link = e.target.closest('a');
207+
link.classList.toggle('active');
208+
if (link.classList.contains('active')) {
209+
at.countInVolume = 1;
210+
} else {
211+
at.countInVolume = 0;
212+
}
213+
};
214+
204215
control.querySelectorAll('.at-speed-options a').forEach(function (a) {
205216
a.onclick = function (e) {
206217
e.preventDefault();

rollup.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const dts = require('rollup-plugin-dts').default;
44
const copy = require('rollup-plugin-copy');
55
const branch = require('git-branch');
66
const license = require('rollup-plugin-license');
7+
const serve = require('rollup-plugin-serve');
78

89
const commonOutput = {
910
name: 'alphaTab',
@@ -13,6 +14,8 @@ const commonOutput = {
1314
}
1415
};
1516

17+
const isWatch = process.env.ROLLUP_WATCH;
18+
1619
module.exports = [
1720
{
1821
input: `dist/lib/alphatab.js`,
@@ -59,6 +62,13 @@ module.exports = [
5962
mappings: {
6063
'@src': 'dist/lib'
6164
}
65+
}),
66+
67+
isWatch && serve({
68+
open: true,
69+
openPage: '/playground/control.html',
70+
contentBase: '',
71+
port: 8080
6272
})
6373
]
6474
},

scripts/setup-playground.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ const fs = require('fs-extra');
22

33
const src = `${__dirname}/../playground-template`
44
const dest = `${__dirname}/../playground`
5-
fs.copySync(src, dest);
5+
fs.copySync(src, dest, { overwrite: false });

src.compiler/JsonSerializationBuilder.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ function getTypeWithNullableInfo(checker: ts.TypeChecker, node: ts.TypeNode) {
1515
for (const t of node.types) {
1616
if (t.kind === ts.SyntaxKind.NullKeyword) {
1717
isNullable = true;
18+
} else if (ts.isLiteralTypeNode(t) && t.literal.kind === ts.SyntaxKind.NullKeyword) {
19+
isNullable = true;
1820
} else if (type !== null) {
19-
throw new Error('Multi union types on JSON settings not supported!');
21+
throw new Error('Multi union types on JSON settings not supported: ' + node.getSourceFile().fileName + ':' + node.getText());
2022
} else {
2123
type = checker.getTypeAtLocation(t);
2224
}

src.compiler/csharp/CSharpAstTransformer.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,8 @@ export default class CSharpAstTransformer {
495495
}
496496
} else if (ts.isVariableStatement(s)) {
497497
this.visitTestClassProperty(csClass, s);
498+
} else if (ts.isFunctionDeclaration(s)) {
499+
this.visitTestClassMethod(csClass, s);
498500
} else {
499501
this._context.addTsNodeDiagnostics(
500502
s,
@@ -507,6 +509,40 @@ export default class CSharpAstTransformer {
507509
this._csharpFile.namespace.declarations.push(csClass);
508510
}
509511

512+
private visitTestClassMethod(parent: cs.ClassDeclaration, d: ts.FunctionDeclaration) {
513+
const signature = this._context.typeChecker.getSignatureFromDeclaration(d);
514+
const returnType = this._context.typeChecker.getReturnTypeOfSignature(signature!);
515+
516+
const csMethod: cs.MethodDeclaration = {
517+
parent: parent,
518+
nodeType: cs.SyntaxKind.MethodDeclaration,
519+
isAbstract: false,
520+
isOverride: false,
521+
isStatic: false,
522+
isVirtual: false,
523+
name: this._context.toPascalCase((d.name as ts.Identifier).text),
524+
parameters: [],
525+
returnType: this.createUnresolvedTypeNode(null, d.type ?? d, returnType),
526+
visibility: this.mapVisibility(d.modifiers),
527+
tsNode: d,
528+
skipEmit: this.shouldSkip(d)
529+
};
530+
csMethod.isAsync =
531+
!!d.modifiers &&
532+
!!d.modifiers.find(m => m.kind === ts.SyntaxKind.AsyncKeyword);
533+
534+
const type = this._context.typeChecker.getTypeAtLocation(d.name!);
535+
csMethod.returnType.parent = csMethod;
536+
537+
d.parameters.forEach(p => csMethod.parameters.push(this.makeParameter(csMethod, p)));
538+
this._declarationOrAssignmentTypeStack.push(type);
539+
csMethod.body = this.visitBlock(csMethod, d.body as ts.Block);
540+
this._declarationOrAssignmentTypeStack.pop();
541+
542+
parent.members.push(csMethod);
543+
this._context.registerSymbol(csMethod);
544+
}
545+
510546
private visitTestMethod(parent: cs.ClassDeclaration, d: ts.CallExpression) {
511547
const csMethod: cs.MethodDeclaration = {
512548
parent: parent,

src.csharp/AlphaTab.Windows/NAudioSynthOutput.cs

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ public class NAudioSynthOutput : WaveProvider32, ISynthOutput, IDisposable
1818

1919
private DirectSoundOut _context;
2020
private CircularSampleBuffer _circularBuffer;
21-
private bool _finished;
2221

2322
/// <inheritdoc />
2423
public double SampleRate => PreferredSampleRate;
@@ -42,7 +41,6 @@ public void Activate()
4241
/// <inheritdoc />
4342
public void Open()
4443
{
45-
_finished = false;
4644
_circularBuffer = new CircularSampleBuffer(BufferSize * BufferCount);
4745

4846
_context = new DirectSoundOut(100);
@@ -62,7 +60,6 @@ public void Dispose()
6260
/// </summary>
6361
public void Close()
6462
{
65-
_finished = true;
6663
_context.Stop();
6764
_circularBuffer.Clear();
6865
_context.Dispose();
@@ -72,7 +69,6 @@ public void Close()
7269
public void Play()
7370
{
7471
RequestBuffers();
75-
_finished = false;
7672
_context.Play();
7773
}
7874

@@ -82,12 +78,6 @@ public void Pause()
8278
_context.Pause();
8379
}
8480

85-
/// <inheritdoc />
86-
public void SequencerFinished()
87-
{
88-
_finished = true;
89-
}
90-
9181
/// <inheritdoc />
9282
public void AddSamples(Float32Array f)
9383
{
@@ -117,29 +107,16 @@ private void RequestBuffers()
117107
/// <inheritdoc />
118108
public override int Read(float[] buffer, int offset, int count)
119109
{
120-
if (_circularBuffer.Count < count)
121-
{
122-
if (_finished)
123-
{
124-
((EventEmitter) Finished).Trigger();
125-
}
126-
}
127-
else
128-
{
129-
var read = new Float32Array(count);
130-
_circularBuffer.Read(read, 0, read.Length);
110+
var read = new Float32Array(count);
111+
_circularBuffer.Read(read, 0, System.Math.Min(read.Length, _circularBuffer.Count));
131112

132-
Buffer.BlockCopy(read.Data, 0, buffer, offset * sizeof(float),
133-
count * sizeof(float));
113+
Buffer.BlockCopy(read.Data, 0, buffer, offset * sizeof(float),
114+
count * sizeof(float));
134115

135-
var samples = count / 2;
136-
((EventEmitterOfT<double>) SamplesPlayed).Trigger(samples);
137-
}
116+
var samples = count / 2;
117+
((EventEmitterOfT<double>) SamplesPlayed).Trigger(samples);
138118

139-
if (!_finished)
140-
{
141-
RequestBuffers();
142-
}
119+
RequestBuffers();
143120

144121
return count;
145122
}
@@ -152,8 +129,5 @@ public override int Read(float[] buffer, int offset, int count)
152129

153130
/// <inheritdoc />
154131
public IEventEmitter SampleRequest { get; } = new EventEmitter();
155-
156-
/// <inheritdoc />
157-
public IEventEmitter Finished { get; } = new EventEmitter();
158132
}
159133
}

src.csharp/AlphaTab/Core/Globals.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ namespace AlphaTab.Core
44
{
55
public static class Globals
66
{
7+
public const double NaN = double.NaN;
78
public static Console Console { get; } = new Console();
89

910
public static double ParseInt(string s)

0 commit comments

Comments
 (0)