Commit graph

328 commits

Author SHA1 Message Date
Pavle Goloskokovic
67477708b2 Ditching loopSource approach as logic would be too complicated when taking playback rate into account 2017-12-12 20:11:46 +01:00
Pavle Goloskokovic
47522af035 Reordering setting loop value in applyConfig before rate and detune to enable rate and detune to update loop source as well 2017-12-12 20:02:17 +01:00
Pavle Goloskokovic
c06a2bc78c Setting loop source rate in setRate method if looping is enables 2017-12-12 20:00:49 +01:00
Pavle Goloskokovic
dbc4b8b6f2 Renamed createLoopBufferSource to createAndStartLoopBufferSource and added some logic for starting loop source 2017-12-12 20:00:04 +01:00
Pavle Goloskokovic
d13bdfde62 Added createBufferSource to reuse buffer source creation logic 2017-12-12 19:58:44 +01:00
Pavle Goloskokovic
648187295e Added method for creating loop buffer source 2017-12-12 19:56:18 +01:00
Pavle Goloskokovic
d788ed3a44 Stop and remove loopSource in stopAndRemoveBufferSource 2017-12-12 19:52:24 +01:00
Pavle Goloskokovic
bca40391fe If value set to loop property is the same as config value skip any further commands 2017-12-12 19:47:57 +01:00
Pavle Goloskokovic
c8f43e7a5a Added a bit of logic and couple of TODOs to handle loop source when setting loop property value 2017-12-12 19:46:08 +01:00
Pavle Goloskokovic
bcda86c566 Setting config value when setting loop property 2017-12-12 19:44:41 +01:00
Pavle Goloskokovic
48f86abb65 Returning config value when getting loop property 2017-12-12 19:43:21 +01:00
Pavle Goloskokovic
02962f316e Defined loop property for WebAudioSound class 2017-12-12 19:42:21 +01:00
Pavle Goloskokovic
121672d442 Added loopSource field for timed loop sound source 2017-12-12 19:40:36 +01:00
Pavle Goloskokovic
429d86ba31 Added TODO for handling removed or destroyed sounds 2017-12-10 13:18:03 +01:00
Pavle Goloskokovic
c9868d5408 Implemented destroy method for WebAudioSound class 2017-12-10 13:17:39 +01:00
Pavle Goloskokovic
594d1512aa Implemented destroy method for BaseSound class 2017-12-10 13:17:17 +01:00
Pavle Goloskokovic
b5e8a60530 Saving seek value only when sound is playing or paused, for consistency 2017-12-07 20:58:54 +01:00
Pavle Goloskokovic
8d161ac06d Returning config value when paused and 0 when stopped when getting seek value 2017-12-07 20:58:07 +01:00
Pavle Goloskokovic
e4ca4d4b75 Updated description for mute property 2017-12-07 20:57:05 +01:00
Pavle Goloskokovic
361ff7ff94 Updated description for volume property 2017-12-07 20:56:51 +01:00
Pavle Goloskokovic
42003ca74c Updated description for seek property 2017-12-07 20:56:34 +01:00
Pavle Goloskokovic
d856a97e98 Reverting to resetting config on every play method call 2017-12-07 20:55:47 +01:00
Pavle Goloskokovic
11d9d5455d Resetting config on stop call 2017-12-07 20:17:38 +01:00
Pavle Goloskokovic
1973781052 Resetting config when calling play method only if current call plays different marker than previous (to enable setting seek before replaying same sound) 2017-12-07 20:17:00 +01:00
Pavle Goloskokovic
75d480ffba Added protected access modifier to overridden applyConfig method 2017-12-07 20:14:58 +01:00
Pavle Goloskokovic
c3107ca629 Setting paused time (seek) before calling stopAndRemoveBufferSource since getCurrentTime depends on startTime value and it gets reset in stopAndRemoveBufferSource method 2017-12-07 20:13:52 +01:00
Pavle Goloskokovic
039ed52cf2 Resetting startTime value inside of stopAndRemoveBufferSource method to have more consistent sound state 2017-12-07 20:11:09 +01:00
Pavle Goloskokovic
0a5e8de376 Using subclass values for duration properties if available 2017-12-06 18:07:43 +01:00
Pavle Goloskokovic
58d0be5279 Setting duration properties before calling super method 2017-12-06 18:06:39 +01:00
Pavle Goloskokovic
0338d6f7c0 Initializing duration properties before config because some config options' setters use those values (seek) 2017-12-06 18:06:05 +01:00
Pavle Goloskokovic
b01859eb06 Moved config initialization right before config options initializations 2017-12-06 18:04:18 +01:00
Pavle Goloskokovic
260d519a7e Resetting config before merging it with config provided to play method 2017-12-05 20:25:31 +01:00
Pavle Goloskokovic
99aa2b22c4 Resetting sound playback at seek time if sound is playing 2017-12-05 20:22:49 +01:00
Pavle Goloskokovic
06b7ad91fd Updated a TODO to add delay config setting 2017-12-05 20:21:14 +01:00
Pavle Goloskokovic
b3f5b03e6f Calling getCurrentTime directly when setting seek as paused time since we don't want to self-assign it 2017-12-05 20:20:33 +01:00
Pavle Goloskokovic
4e0c274ca4 No need to reset config seek value since it is reset in resetConfig method 2017-12-05 20:19:02 +01:00
Pavle Goloskokovic
44ce0edd82 Moved the same logic for calculating offset duration and startTime into createAndStartBufferSource method 2017-12-05 20:17:14 +01:00
Pavle Goloskokovic
25a11687c2 Replaced pausedTime field with config seek value 2017-12-05 20:01:06 +01:00
Pavle Goloskokovic
f347bcc45a Limiting seek value to be between 0 and current duration in seek property setter 2017-12-05 19:57:07 +01:00
Pavle Goloskokovic
7920ad3b6d Setting config seek value to value provided to seek property setter 2017-12-05 19:55:48 +01:00
Pavle Goloskokovic
d7f65cc003 Added comments to make it easier to figure out isPaused and isPlaying current values at any time 2017-12-05 19:51:15 +01:00
Pavle Goloskokovic
1590ab2dda Returning config seek value in seek property getter if is not playing 2017-12-05 19:48:52 +01:00
Pavle Goloskokovic
5a5444e936 Returning value from getCurrentTime in seek property getter only if sound is currently playing 2017-12-05 19:47:41 +01:00
Pavle Goloskokovic
6c7f7ae732 Setting pausedTime to current seek value 2017-12-05 19:45:33 +01:00
Pavle Goloskokovic
aa503131a4 Returning value from getCurrentTime in seek property getter 2017-12-05 19:44:37 +01:00
Pavle Goloskokovic
a27f32b3a3 Added getCurrentTime method to WebAudioSound class to precisely calculate current sound time 2017-12-05 19:43:08 +01:00
Pavle Goloskokovic
0543b8d5ef Calling resetConfig after starting buffer sound 2017-12-05 19:41:07 +01:00
Pavle Goloskokovic
344aec2b86 Added resetConfig method where seek config, and later delay config, are reset 2017-12-05 19:40:25 +01:00
Pavle Goloskokovic
b2950775a1 Applying config right before calling start on buffer source 2017-12-05 19:36:59 +01:00
Pavle Goloskokovic
7bde818fa5 Override applyConfig method and moved rateUpdates resetting logic there 2017-12-05 19:35:26 +01:00
Pavle Goloskokovic
dc4bb51b93 Updated few members access modifiers from private to protected 2017-12-05 19:31:58 +01:00
Pavle Goloskokovic
00c2fd3189 Moved totalRate initialisation above setting config options since it is used in some of the config options' setters (detune, rate) 2017-12-05 19:28:08 +01:00
Pavle Goloskokovic
fd96a329de Moved isPlaying and isPaused flags initialisation above setting config options since they are used in some of the config options' setters (detune, rate) 2017-12-05 19:24:17 +01:00
Pavle Goloskokovic
97441f3bc8 Adding initial rate update to help calculate seek 2017-12-05 19:21:23 +01:00
Pavle Goloskokovic
ad687016ad Included config seek into calculation when playing sound 2017-12-05 19:19:19 +01:00
Pavle Goloskokovic
3176293f53 Resetting rateUpdates before playing sound source 2017-12-05 19:14:53 +01:00
Pavle Goloskokovic
fb9bc44685 Save rate updates only when sound is playing 2017-12-05 19:13:09 +01:00
Pavle Goloskokovic
7dd0a877ec Save sound current time instead of context current time 2017-12-05 19:12:18 +01:00
Pavle Goloskokovic
54f5e6141d Adding an item to rateUpdates every time setRate method is called 2017-12-05 19:11:30 +01:00
Pavle Goloskokovic
bc486daaa3 Adding rateUpdates field to WebAudioSound class to keep track of all rate changes 2017-12-05 19:09:34 +01:00
Pavle Goloskokovic
6e85e6a419 Adding seek property to WebAudioSound class 2017-12-05 19:07:40 +01:00
Pavle Goloskokovic
de1657de01 Updated comments with private and readonly descriptors 2017-12-04 22:09:41 +01:00
Pavle Goloskokovic
fe36e80f24 Removing detune range limitation 2017-12-04 22:05:29 +01:00
Pavle Goloskokovic
66d216af19 Reading total rate value directly from totalRate property in setRate 2017-12-01 15:41:24 +01:00
Pavle Goloskokovic
a3dbb51d3e Removed return value for setRate method as it is not needed because that value is now stored in totalRate property 2017-12-01 15:40:35 +01:00
Pavle Goloskokovic
411fdd48b2 Setting totalRate value in setRate method 2017-12-01 15:33:02 +01:00
Pavle Goloskokovic
fe9c9c0819 Added totalRate property to BaseSound class 2017-12-01 15:32:03 +01:00
Pavle Goloskokovic
42b47d2674 Fixed few references 2017-11-30 22:56:54 +01:00
Pavle Goloskokovic
786c6913ac Removing WebAudioSpriteSound class, audio sprite creation logic is generic and can be used in base sound manager class, no need for adding more classes and making class hierarchy more complex 2017-11-30 22:15:47 +01:00
Pavle Goloskokovic
9e90b9eec2 Moved logic for audio sprite creation to BaseSoundManager addAudioSprite method 2017-11-30 22:14:20 +01:00
Pavle Goloskokovic
9a3d0a4140 Added hasOwnProperty check for traversing spritemap object 2017-11-30 18:56:38 +01:00
Pavle Goloskokovic
5c3a3ebef2 Improve readability with local variable 2017-11-30 18:56:12 +01:00
Pavle Goloskokovic
9a156ec898 Adding marker for each key in spritemap object 2017-11-30 18:55:21 +01:00
Pavle Goloskokovic
d65cf17a4d Added spritemap property to WebAudioSpriteSound that holds reference to 'spritemap' object form json file generated by audiosprite tool. 2017-11-30 18:54:27 +01:00
Pavle Goloskokovic
39edc8a9ac Defaulting config to empty object and calling super method in WebAudioSpriteSound constructor 2017-11-30 18:53:12 +01:00
Pavle Goloskokovic
6412a3c3c2 Added WebAudioSpriteSound class - a Web Audio implementation of audio sprite sound 2017-11-30 18:50:54 +01:00
Pavle Goloskokovic
9ec1fb4cd1 Removing touche events when unlocking only after promise returned from resume method gets resolved 2017-11-30 14:41:46 +01:00
Pavle Goloskokovic
1b94d7eac3 Trying to unlock Web Audio on both touchstart and touchend events 2017-11-30 14:39:24 +01:00
Pavle Goloskokovic
f692aad1b1 Replaced touchstart with touchend event when unlocking Web Audio 2017-11-30 13:37:31 +01:00
Pavle Goloskokovic
65c30b9f7a Removed detune property as it is now defined in BaseSoundManager class 2017-11-27 17:38:43 +01:00
Pavle Goloskokovic
e4cebbf29c Removed rate property as it is now defined in BaseSoundManager class 2017-11-27 17:38:28 +01:00
Pavle Goloskokovic
3c2670a2f9 Removed _detune field as it is now set in BaseSoundManager class 2017-11-27 17:37:41 +01:00
Pavle Goloskokovic
c84a00e248 Removed _rate field as it is now set in BaseSoundManager class 2017-11-27 17:37:11 +01:00
Pavle Goloskokovic
28ae0811e6 Defining detune property in BaseSound class so it can be used in both Web Audio and HTML5 Audio implementations 2017-11-27 17:35:35 +01:00
Pavle Goloskokovic
1c1e75ac85 Defining rate property in BaseSound class so it can be used in both Web Audio and HTML5 Audio implementations 2017-11-27 17:35:09 +01:00
Pavle Goloskokovic
27ad50d276 Setting _detune field in BaseSound class so it can be used in both Web Audio and HTML5 Audio implementations 2017-11-27 17:34:27 +01:00
Pavle Goloskokovic
92ac9d41c5 Setting _rate field in BaseSound class so it can be used in both Web Audio and HTML5 Audio implementations 2017-11-27 17:33:37 +01:00
Pavle Goloskokovic
cf46145d7c Calling super method in setRate method of WebAudioSound class, setting returned value to source playback rate audio param and returning the same value to match method signature 2017-11-27 17:32:16 +01:00
Pavle Goloskokovic
f389176362 Added setRate method to BaseSound class that contains logic for applying rate and detune settings to sound so it can be reused in both Web Audio and HTML5 Audio implementations 2017-11-27 17:30:55 +01:00
Pavle Goloskokovic
881474b7cd Added a TODO to take into account playback rate when pausing and resuming sound 2017-11-27 16:50:45 +01:00
Pavle Goloskokovic
ffc205b400 Calling setRate method on all sound objects when updating global detune value 2017-11-27 16:50:05 +01:00
Pavle Goloskokovic
c57f692c85 Calling setRate method on all sound objects when updating global rate value 2017-11-27 16:49:28 +01:00
Pavle Goloskokovic
9fffd57ad3 Moved sound source not null check from properties' setter methods to setRate method 2017-11-27 16:48:20 +01:00
Pavle Goloskokovic
db06b3d742 Calling setRate in WebAudioSound detune property's setter method 2017-11-27 16:46:42 +01:00
Pavle Goloskokovic
074c60c270 Calling setRate in WebAudioSound rate property's setter method 2017-11-27 16:45:58 +01:00
Pavle Goloskokovic
1fddd3de2a Added setRate method to WebAudioSound class that calculates and sets playback rate based on sound's and manager's detune and rate values 2017-11-27 16:44:23 +01:00
Pavle Goloskokovic
d13fae2260 Preventing negative values for source start call 2017-11-26 18:12:55 +01:00
Pavle Goloskokovic
93ac04329b Updated WebAudioSound update method docs and signature 2017-11-26 17:25:01 +01:00
Pavle Goloskokovic
66dcd9f02f Resetting hasEnded in update method 2017-11-26 17:07:56 +01:00
Pavle Goloskokovic
0a078d26f6 Setting hasEnded when sound ends 2017-11-26 17:07:05 +01:00
Pavle Goloskokovic
f0bc96e68f Checking hasEnded on update in order to call stop method 2017-11-26 17:05:24 +01:00
Pavle Goloskokovic
84e6459b59 Added hasEnded property to WebAudioSound class 2017-11-26 17:03:36 +01:00
Pavle Goloskokovic
94e834fa96 Updating all sounds on sound manager update 2017-11-26 16:59:12 +01:00
Pavle Goloskokovic
ceeef0368c Added a todo to fix race condition 2017-11-26 16:41:46 +01:00
Pavle Goloskokovic
2995b7eaf6 Added short logic explanation for onended event handler 2017-11-26 16:37:03 +01:00
Pavle Goloskokovic
e13b829ab1 Removed redundant check in onended handler and reverted setting source to null before calling stop() on it since it does not invoke onended event handler immediately 2017-11-26 16:35:13 +01:00
Pavle Goloskokovic
007a565700 Just checking for null sound reference isn't enough since because calling play() on already playing sound is not covered by that condition 2017-11-26 16:31:06 +01:00
Pavle Goloskokovic
aab5150016 Setting source to null before calling stop on it to determine if onended event was fired when sound ended or when it was stopped by user 2017-11-26 16:28:54 +01:00
Pavle Goloskokovic
04eb680d52 Checking if source is null before stopping sound on ended handler because it is called also when stop() method is called on it 2017-11-26 16:27:39 +01:00
Pavle Goloskokovic
1808fab27e Calling stop method when sound ends 2017-11-26 16:24:49 +01:00
Pavle Goloskokovic
53dbf050d4 Marked a few methods as private 2017-11-26 16:19:56 +01:00
Pavle Goloskokovic
762c6cb147 Updated a TODO 2017-11-23 13:55:27 +01:00
Pavle Goloskokovic
266ebc4925 Taking into account marker start time on resuming sound 2017-11-23 13:55:08 +01:00
Pavle Goloskokovic
d369d46e35 Taking into account marker start time if marker is currently played 2017-11-23 13:53:57 +01:00
Pavle Goloskokovic
0ded9af3a9 Resetting current marker if no marker name is provided to play method 2017-11-23 13:52:03 +01:00
Pavle Goloskokovic
5f55931d22 Completed a TODO by setting BaseSound update method to NOOP 2017-11-23 13:19:22 +01:00
Pavle Goloskokovic
a2ceff63f1 Returning marker/null instead of boolean in removeMarker 2017-11-23 13:14:41 +01:00
Pavle Goloskokovic
b3337b6c51 Added validation for non existing marker in removeMarker method 2017-11-23 13:13:25 +01:00
Pavle Goloskokovic
c48f51de35 Setting marker to null on removeMarker call 2017-11-23 13:12:21 +01:00
Pavle Goloskokovic
9d8afee78f Added validation for non existing marker to updateMarker method 2017-11-23 12:56:32 +01:00
Pavle Goloskokovic
0e97a18553 Added validation for invalid marker name to updateMarker method 2017-11-23 12:56:06 +01:00
Pavle Goloskokovic
42735ee09f Added validation for when no marker is provided to updateMarker method 2017-11-23 12:55:22 +01:00
Pavle Goloskokovic
17d39f7bab Merging provided marker with existing marker in updateMarker method 2017-11-23 12:54:47 +01:00
Pavle Goloskokovic
8a4e439b55 Updated logging for addMarker method of BaseSound class 2017-11-23 12:52:19 +01:00
Pavle Goloskokovic
6c38853a6f Added update marker method to BaseSound class 2017-11-23 12:41:41 +01:00
Pavle Goloskokovic
76a32e20c6 Fixed return values for addMarker method 2017-11-23 12:37:10 +01:00
Pavle Goloskokovic
1e213e6d86 Added validation for existing marker 2017-11-23 12:35:55 +01:00
Pavle Goloskokovic
de5689b129 Added validation for marker name 2017-11-23 12:34:43 +01:00
Pavle Goloskokovic
2bcffe6f2f Merging provided marker with object with default values 2017-11-23 12:33:56 +01:00
Pavle Goloskokovic
40b4dc2e6e Adding validation and error handling if no marker is passed 2017-11-23 12:31:34 +01:00
Pavle Goloskokovic
084d309efb Adding market to markers array in addMarker method 2017-11-23 12:30:24 +01:00
Pavle Goloskokovic
c1b0bc4ee7 Added a TODO for scheduled playback 2017-11-22 18:07:08 +01:00
Pavle Goloskokovic
068fc6d1c9 Renamed 'marker' param of play method to 'markerName' to avoid any confusion for WebAudioSound 2017-11-22 18:06:21 +01:00
Pavle Goloskokovic
d367dc1a85 Renamed 'marker' param of play method to 'markerName' to avoid any confusion for BaseSound 2017-11-22 18:05:18 +01:00
Pavle Goloskokovic
8e912ab877 Updated currentMarker property to hold reference to marker object instead it's name 2017-11-22 18:03:44 +01:00
Pavle Goloskokovic
55e5041ef8 Setting correct duration value when calling play on BaseSound class 2017-11-22 18:00:53 +01:00
Pavle Goloskokovic
de0aefba7e Added default value for config in WebAudioSound constructor 2017-11-22 17:58:05 +01:00
Pavle Goloskokovic
9a143694d1 Using duration property instead of config duration setting in WebAudioSound 2017-11-22 17:56:55 +01:00
Pavle Goloskokovic
92abe3f678 Remove completed TODO 2017-11-22 17:54:38 +01:00
Pavle Goloskokovic
ffe4e49512 Setting duration and totalDuration properties in WebAudioSound constructor 2017-11-22 17:54:00 +01:00
Pavle Goloskokovic
90d2e8cf03 Removed setting duration setting in config for WebAudioSound 2017-11-22 17:51:10 +01:00
Pavle Goloskokovic
1296dd737d Added totalDuration property to BaseSound class 2017-11-22 17:48:10 +01:00
Pavle Goloskokovic
f932e315d6 Added duration property to BaseSound class 2017-11-22 17:47:18 +01:00
Pavle Goloskokovic
7442ab5bc8 Removed duration setting from sound config 2017-11-22 17:45:57 +01:00
Pavle Goloskokovic
cd43f0095c fixed deprecation issues with AudioParam for WebAudioSoundManager 2017-11-21 19:47:43 +01:00
Pavle Goloskokovic
1f32f04036 fixed deprecation issues with AudioParam for WebAudioSound 2017-11-21 19:47:27 +01:00
Pavle Goloskokovic
658e8c0ee6 implemented onBlur and onFocus methods for WebAudioSoundManager 2017-11-21 18:09:30 +01:00
Pavle Goloskokovic
ab9a9c951f bound onBlur and onFocus methods to corresponding game events 2017-11-21 18:06:18 +01:00
Pavle Goloskokovic
dd824c4a79 added onBlur and onFocus methods to BaseSoundManager 2017-11-21 18:04:54 +01:00
Pavle Goloskokovic
f00421f112 changed muteOnPause flag to be pauseOnBlur for BaseSoundManager 2017-11-21 18:02:24 +01:00