core/audiobus
오디오 버스.
Audio bus.
AudioBus
오디오 버스. 여러 플레이어의 소리를 한 길로 모아 크기와 음소거를 한꺼번에 건다. (SoundSystem 의 배경음악 버스와 효과음 버스) 출력(audioContext.destination)에 이은 GainNode 하나이고, 그 버스로 트는 플레이어(createAudioPlayer)는 GainNode 를 출력 대신 여기에 잇는다. 만드는 곳은 AudioManager.createAudioBus() 다. AudioContext 가 없을 때 만든 버스는 소리가 없고, 그 버스로 만든 플레이어도 소리를 내지 않는다. 크기와 음소거는 AudioPlayer 와 같은 규칙이다. (0 ~ 1 로 자르고, 음소거를 풀면 설정한 크기로 돌아간다) 러스트 판(vanilla-engine)의 AudioBus 와 같은 꼴이다. (데스크탑은 kira 하위 트랙, 웹은 이 GainNode)
Audio bus. Gathers the sound of several players into one path and applies volume and mute to them at once. (SoundSystem's background music bus and sound effect bus) A single GainNode connected to the output (audioContext.destination), and players playing through the bus (createAudioPlayer) connect their GainNode here instead of to the output. Created by AudioManager.createAudioBus(). A bus created without an AudioContext is silent, and players made from it play no sound either. Volume and mute follow the same rules as AudioPlayer. (clamped to 0 ~ 1, unmuting returns to the set volume) Same shape as AudioBus in the Rust version (vanilla-engine). (a kira sub-track on desktop, this GainNode on the web)
import { Engine, EngineConfiguration, AudioAsset } from "./build/vanilla.js";
const engineConfiguration = new EngineConfiguration();
const engine = new Engine(engineConfiguration);
const audioManager = engine.getAudioManager();
const audioBus = audioManager.createAudioBus();
audioBus.setVolume(0.5);
const audioAsset = new AudioAsset();
await audioAsset.load("examples/assets/beep.wav");
const audioPlayer = audioBus.createAudioPlayer();
audioPlayer.setAudioAsset(audioAsset);
audioPlayer.play();
console.log(audioBus.isAvailable(), audioBus.getVolume());
audioBus.mute();
console.log(audioBus.isMuted());생성.
Constructor.
- audioContextAudioContext | null
- 버스를 만들 오디오 컨텍스트. (null 이면 소리 없는 버스)Audio context to make the bus with. (if null, a silent bus)
짝Counterpart: vanilla-engine AudioBus.new
이 버스로 트는 오디오 플레이어 생성. (버스가 소리 없으면 소리 없는 플레이어)
Creates an audio player that plays through this bus. (a silent player if the bus is silent)
반환ReturnsAudioPlayer 이 버스로 소리를 내는 플레이어.A player that sounds through this bus.
짝Counterpart: vanilla-engine AudioBus.create_audio_player
음소거. (소리 없는 버스면 아무것도 하지 않는다)
Mute. (does nothing on a silent bus)
짝Counterpart: vanilla-engine AudioBus.mute
음소거 해제. (설정한 크기로 돌아간다)
Unmute. (returns to the set volume)
짝Counterpart: vanilla-engine AudioBus.unmute
크기 설정. (0 ~ 1, 음소거 중이면 음소거를 풀 때 적용된다)
Sets the volume. (0 ~ 1, if muted it applies when unmuted)
- volumenumber
- 크기. (0 ~ 1 로 자르고, 유한한 숫자가 아니면 1)Volume. (clamped to 0 ~ 1, 1 if not a finite number)
짝Counterpart: vanilla-engine AudioBus.set_volume
크기 반환.
Returns the volume.
반환Returnsnumber 크기. (0 ~ 1, 기본 1)Volume. (0 ~ 1, default 1)
짝Counterpart: vanilla-engine AudioBus.get_volume
음소거 여부 반환.
Returns whether muted.
반환Returnsboolean 음소거 중이면 참.True if muted.
짝Counterpart: vanilla-engine AudioBus.is_muted
소리를 모을 수 있는지. (AudioContext 가 있을 때 만든 버스)
Whether it can gather sound. (a bus created while an AudioContext exists)
반환Returnsboolean 소리를 모을 수 있으면 참.True if it can collect sound.
짝Counterpart: vanilla-engine AudioBus.is_available
버스의 GainNode. (다른 WebAudio 노드를 이 버스에 이을 때, SoundSystem 이 설정 크기를 걸 때, 없으면 null)
- 이 노드에 직접 건 크기는 크기 칸(getVolume)과 음소거 칸을 바꾸지 않는다. setVolume, mute 로 건 값은 그때까지만 간다.
The bus's GainNode. (for connecting other WebAudio nodes to this bus, for SoundSystem to apply the volume setting, null if none)
- Volume set directly on this node does not change the volume field (getVolume) or the mute field. Values set with setVolume and mute last only until then.
반환ReturnsGainNode | null 버스의 GainNode. (없으면 null)The bus GainNode. (null if none)
짝Counterpart: vanilla-engine AudioBus.get_gain_node