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

[Closes #515] Refactor sound resources to address inconsistent behaviors #644

Merged
merged 23 commits into from
Sep 3, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
46133f7
Add proper simultaneous sound handling to AudioTag and WebAudio provi…
kamranayub Sep 1, 2016
e8e130c
Refactor sounds to be simpler
kamranayub Sep 1, 2016
d2b0b9c
Fix other audio test to not do simultaneous plays
kamranayub Sep 1, 2016
8a676f8
Compile dists and address TSLint
kamranayub Sep 1, 2016
20d21e6
Merge latest PRs and recompile dists
kamranayub Sep 1, 2016
364e30c
Simplify and consolidate Sound resource and sound implementations
kamranayub Sep 2, 2016
ffa05d1
Fix web audio offset calculation to be in seconds
kamranayub Sep 2, 2016
9bab3e5
Fix sandbox
kamranayub Sep 2, 2016
b78a3f5
Compile dists
kamranayub Sep 2, 2016
55efb9c
Fix some potential issues
kamranayub Sep 2, 2016
43ef13d
Add initial sound tests
kamranayub Sep 2, 2016
d4dca5e
Add sound unit test coverage
kamranayub Sep 2, 2016
1f31c28
Add callback tests
kamranayub Sep 2, 2016
c7df9a8
Add callback test with data preloaded
kamranayub Sep 2, 2016
c447e7f
Fix TSlint and add `instanceCount()` method to get number of currentl…
kamranayub Sep 2, 2016
0f11c8d
Compile dists
kamranayub Sep 2, 2016
b48d89f
Ignore audio implementations for coverage
kamranayub Sep 2, 2016
216c4c1
Compile dists
kamranayub Sep 2, 2016
b2c74a1
Merge in master changes and recompile dists
kamranayub Sep 2, 2016
6bc6e2f
Add more debug messages for debugging
kamranayub Sep 2, 2016
10a8a7e
Fix tslint task to include all engine files
kamranayub Sep 2, 2016
4827768
Fix tslint errors
kamranayub Sep 2, 2016
88d509a
Recompile dists
kamranayub Sep 2, 2016
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
1 change: 0 additions & 1 deletion src/engine/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
/// <reference path="Particles.ts" />
/// <reference path="Drawing/Animation.ts" />
/// <reference path="Camera.ts" />
/// <reference path="Sound.ts" />
/// <reference path="Loader.ts" />
/// <reference path="Promises.ts" />
/// <reference path="Util/Util.ts" />
Expand Down
12 changes: 12 additions & 0 deletions src/engine/Interfaces/IAudio.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference path="../Promises.ts" />

module ex {
export interface IAudio {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add docs

setVolume(volume: number);
setLoop(loop: boolean);
isPlaying(): boolean;
play(): ex.Promise<any>;
pause();
stop();
}
}
23 changes: 23 additions & 0 deletions src/engine/Interfaces/IAudioImplementation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module ex {

/**
* Represents an audio implementation like [[AudioTag]] or [[WebAudio]]
*/
export interface IAudioImplementation {

/**
* XHR response type
*/
responseType: string;

/**
* Processes raw data and transforms into sound data
*/
processData(data: Blob|ArrayBuffer): ex.Promise<string|AudioBuffer>;

/**
* Factory method that returns an instance of a played audio track
*/
createInstance(data: string|AudioBuffer): IAudio;
}
}
8 changes: 7 additions & 1 deletion src/engine/Interfaces/ILoadable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ module ex {
*/
load(): Promise<any>;

/**
* Gets the data that was loaded
*/
getData(): any;

/**
* Sets the data (can be populated from remote request or in-memory data)
*/
setData(data: any): void;

/**
Expand All @@ -34,7 +41,6 @@ module ex {
*/
wireEngine(engine: Engine): void;


/**
* onprogress handler
*/
Expand Down
3 changes: 2 additions & 1 deletion src/engine/Loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/// <reference path="Util/DrawUtil.ts" />
/// <reference path="Promises.ts" />
/// <reference path="Resources/Resource.ts" />
/// <reference path="Resources/Sound.ts" />
/// <reference path="Interfaces/ILoadable.ts" />
/// <reference path="Interfaces/ILoader.ts" />

Expand Down Expand Up @@ -339,7 +340,7 @@ module ex {
}

// unlock Safari WebAudio context
Internal.WebAudio.unlock();
WebAudio.unlock();

// continue to play game
this._waitPromise.resolve(this._loadedValue);
Expand Down
Loading