@@ -11,26 +11,26 @@ var WebAudioSoundManager = new Class({
1111 * @property {AudioContext } context
1212 */
1313 this . context = this . createAudioContext ( game ) ;
14+ /**
15+ * [description]
16+ *
17+ * @property {GainNode } masterMuteNode
18+ */
19+ this . masterMuteNode = this . context . createGain ( ) ;
1420 /**
1521 * [description]
1622 *
1723 * @property {GainNode } masterVolumeNode
1824 */
1925 this . masterVolumeNode = this . context . createGain ( ) ;
26+ this . masterMuteNode . connect ( this . masterVolumeNode ) ;
27+ this . masterVolumeNode . connect ( this . context . destination ) ;
2028 /**
2129 * Destination node for connecting individual sounds to.
2230 *
2331 * @property {AudioNode } destination
2432 */
25- this . destination = this . masterVolumeNode ;
26- /**
27- * [description]
28- *
29- * @property {GainNode } masterMuteNode
30- */
31- this . masterMuteNode = this . context . createGain ( ) ;
32- this . masterVolumeNode . connect ( this . masterMuteNode ) ;
33- this . masterMuteNode . connect ( this . context . destination ) ;
33+ this . destination = this . masterMuteNode ;
3434 BaseSoundManager . call ( this , game ) ;
3535 } ,
3636 createAudioContext : function ( game ) {
@@ -47,27 +47,27 @@ var WebAudioSoundManager = new Class({
4747 }
4848} ) ;
4949/**
50- * Global volume setting.
51- * @property {number } volume
50+ * Global mute setting.
51+ * @property {boolean } mute
5252 */
53- Object . defineProperty ( WebAudioSoundManager . prototype , 'volume ' , {
53+ Object . defineProperty ( WebAudioSoundManager . prototype , 'mute ' , {
5454 get : function ( ) {
55- return this . masterVolumeNode . gain . value ;
55+ return this . masterMuteNode . gain . value === 0 ;
5656 } ,
5757 set : function ( value ) {
58- this . masterVolumeNode . gain . value = value ;
58+ this . masterMuteNode . gain . value = value ? 0 : 1 ;
5959 }
6060} ) ;
6161/**
62- * Global mute setting.
63- * @property {boolean } mute
62+ * Global volume setting.
63+ * @property {number } volume
6464 */
65- Object . defineProperty ( WebAudioSoundManager . prototype , 'mute ' , {
65+ Object . defineProperty ( WebAudioSoundManager . prototype , 'volume ' , {
6666 get : function ( ) {
67- return this . masterMuteNode . gain . value === 0 ;
67+ return this . masterVolumeNode . gain . value ;
6868 } ,
6969 set : function ( value ) {
70- this . masterMuteNode . gain . value = value ? 0 : 1 ;
70+ this . masterVolumeNode . gain . value = value ;
7171 }
7272} ) ;
7373module . exports = WebAudioSoundManager ;
0 commit comments