浏览代码

Merge pull request #93754 from adamscott/fix-audio-server-bus-volumedb

Fix assignations to non-existing keys and clean-up Web audio library
Rémi Verschelde 1 年之前
父节点
当前提交
6a12548e34
共有 1 个文件被更改,包括 4 次插入6 次删除
  1. 4 6
      platform/web/js/libs/library_godot_audio.js

+ 4 - 6
platform/web/js/libs/library_godot_audio.js

@@ -142,7 +142,7 @@ class Sample {
 	 * @returns {void}
 	 * @returns {void}
 	 */
 	 */
 	clear() {
 	clear() {
-		this.audioBuffer = null;
+		this.setAudioBuffer(null);
 		GodotAudio.Sample.delete(this.id);
 		GodotAudio.Sample.delete(this.id);
 	}
 	}
 
 
@@ -432,7 +432,7 @@ class SampleNode {
 		/** @type {number} */
 		/** @type {number} */
 		this._playbackRate = 44100;
 		this._playbackRate = 44100;
 		/** @type {LoopMode} */
 		/** @type {LoopMode} */
-		this.loopMode = 'disabled';
+		this.loopMode = options.loopMode ?? this.getSample().loopMode ?? 'disabled';
 		/** @type {number} */
 		/** @type {number} */
 		this._pitchScale = 1;
 		this._pitchScale = 1;
 		/** @type {number} */
 		/** @type {number} */
@@ -445,7 +445,6 @@ class SampleNode {
 		this._onended = null;
 		this._onended = null;
 
 
 		this.setPlaybackRate(options.playbackRate ?? 44100);
 		this.setPlaybackRate(options.playbackRate ?? 44100);
-		this.loopMode = options.loopMode ?? this.getSample().loopMode ?? 'disabled';
 		this._source.buffer = this.getSample().getAudioBuffer();
 		this._source.buffer = this.getSample().getAudioBuffer();
 
 
 		this._addEndedListener();
 		this._addEndedListener();
@@ -777,8 +776,7 @@ class Bus {
 	 */
 	 */
 	static move(fromIndex, toIndex) {
 	static move(fromIndex, toIndex) {
 		const movedBus = GodotAudio.Bus.getBus(fromIndex);
 		const movedBus = GodotAudio.Bus.getBus(fromIndex);
-		let buses = GodotAudio.buses;
-		buses = buses.filter((_, i) => i !== fromIndex);
+		const buses = GodotAudio.buses.filter((_, i) => i !== fromIndex);
 		// Inserts at index.
 		// Inserts at index.
 		buses.splice(toIndex - 1, 0, movedBus);
 		buses.splice(toIndex - 1, 0, movedBus);
 		GodotAudio.buses = buses;
 		GodotAudio.buses = buses;
@@ -1369,7 +1367,7 @@ const _GodotAudio = {
 		 */
 		 */
 		set_sample_bus_volume_db: function (busIndex, volumeDb) {
 		set_sample_bus_volume_db: function (busIndex, volumeDb) {
 			const bus = GodotAudio.Bus.getBus(busIndex);
 			const bus = GodotAudio.Bus.getBus(busIndex);
-			bus.volumeDb = volumeDb;
+			bus.setVolumeDb(volumeDb);
 		},
 		},
 
 
 		/**
 		/**