Skip to content

Commit

Permalink
audio-source: Change maxVolume to volume
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyhale committed Feb 26, 2024
1 parent e2571da commit 6892bc9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions example/js/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ export class ButtonComponent extends Component {
this.click = this.object.addComponent(AudioSource, {
src: 'sfx/click.wav',
isStationary: true,
maxVolume: 0.5,
volume: 0.2,
spatial: true,
});
this.unclick = this.object.addComponent(AudioSource, {
src: 'sfx/unclick.wav',
isStationary: true,
maxVolume: 0.5,
volume: 0.5,
});
this.welcome = WL.scene.addObject(this.object);
this.welcome.addComponent(AudioSource, {
Expand Down
4 changes: 2 additions & 2 deletions src/audio-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class AudioSource extends Component {
* Maximum volume a source can have. From 0 to 1 (0% to 100%).
*/
@property.float(1.0)
maxVolume!: number;
volume!: number;

/** Path to the audio file that should be played. */
@property.string()
Expand Down Expand Up @@ -106,7 +106,7 @@ export class AudioSource extends Component {
return;
}
this.gainNode = new GainNode(_audioContext, {
gain: this.maxVolume,
gain: this.volume,
});
this.gainNode.connect(_audioContext.destination);
this.isLoaded = getAudioData(this.src);
Expand Down

0 comments on commit 6892bc9

Please sign in to comment.