core/soundeffectpool
효과음 풀.
Sound effect pool.
SoundEffectPoolextends Object
효과음 풀.
- 같은 효과음이 연달아 겹쳐 나도 끊기지 않도록, 여러 AudioPlayer 를 돌려 가며(라운드로빈) 재생한다. (여러 게임이 6채널 풀을 제각각 구현하던 것)
- 사용:
const pool = new SoundEffectPool(engine.getAudioManager(), 6);
pool.play(hitAudioAsset);
pool.play(hitAudioAsset, 0.5); // 이 재생만 절반 음량.
pool.setVolume(0.8); // 풀 전체의 음량. (재생 중인 것에도 곱해진다)Sound effect pool.
- Plays by rotating (round robin) through several AudioPlayers so the same sound effect is not cut off when it overlaps in quick succession. (what several games each implemented as a 6-channel pool)
- Usage:
const pool = new SoundEffectPool(engine.getAudioManager(), 6);
pool.play(hitAudioAsset);
pool.play(hitAudioAsset, 0.5); // half volume for this playback only.
pool.setVolume(0.8); // volume of the whole pool. (also multiplied into those playing)import { Engine, EngineConfiguration, AudioAsset, SoundEffectPool } from "./build/vanilla.js";
const engineConfiguration = new EngineConfiguration();
const engine = new Engine(engineConfiguration);
const audioManager = engine.getAudioManager();
const audioAsset = new AudioAsset();
await audioAsset.load("examples/assets/beep.wav");
const soundEffectPool = new SoundEffectPool(audioManager, 4);
soundEffectPool.setVolume(0.8);
soundEffectPool.play(audioAsset);
soundEffectPool.play(audioAsset, 0.5);
console.log(soundEffectPool.getVoiceCount(), soundEffectPool.getVolume());
soundEffectPool.stopAll();생성.
Constructor.
- audioManagerAudioManager
- 엔진의 AudioManager. (engine.getAudioManager(), 플레이어를 만든다)The engine's AudioManager. (engine.getAudioManager(), makes the players)
- voiceCountnumber
- 동시에 겹칠 수 있는 최대 재생 수.Maximum number of playbacks that can overlap at once.
짝Counterpart: vanilla-engine SoundEffectPool.new
효과음 재생.
- 다음 차례의 플레이어에 애셋을 실어 재생한다. 그 플레이어가 재생 중이었다면 끊고 새로 튼다.
- 음량은 이 재생의 음량(0 ~ 1)에 풀의 음량을 곱한 것이다.
Plays a sound effect.
- Loads the asset into the next player in turn and plays it. If that player was playing, stops it and plays the new one.
- The volume is this playback's volume (0 ~ 1) multiplied by the pool volume.
- audioAssetAudioAsset
- 재생할 오디오 애셋. (없거나 음소거 중이면 내지 않는다)Audio asset to play. (not played if missing or muted)
- volumenumber
- 이 재생의 음량. (0 ~ 1, 기본 1)Volume of this playback. (0 ~ 1, default 1)
짝Counterpart: vanilla-engine SoundEffectPool.play
음소거 설정.
Sets mute.
- isMutedboolean
- 참이면 모든 플레이어를 음소거하고 새 재생도 하지 않는다.If true, mutes all players and does not start new playback.
짝Counterpart: vanilla-engine SoundEffectPool.set_muted
풀 전체의 음량 설정. (0 ~ 1, 재생 중인 것에도 바로 곱해진다)
Sets the volume of the whole pool. (0 ~ 1, applied immediately to those playing too)
- volumenumber
- 풀 전체의 음량. (0 ~ 1 로 자르고, 유한한 숫자가 아니면 1)Volume of the whole pool. (clamped to 0 ~ 1, 1 if not a finite number)
짝Counterpart: vanilla-engine SoundEffectPool.set_volume
풀 전체의 음량.
Volume of the whole pool.
반환Returnsnumber 풀 전체의 음량. (0 ~ 1, 기본 1)Volume of the whole pool. (0 ~ 1, default 1)
짝Counterpart: vanilla-engine SoundEffectPool.get_volume
음소거 여부.
Whether muted.
반환Returnsboolean 음소거 중이면 참.True if muted.
짝Counterpart: vanilla-engine SoundEffectPool.is_muted
보이스 수 반환.
Returns the number of voices.
반환Returnsnumber 플레이어 수. (동시에 겹칠 수 있는 최대 재생 수)Player count. (the maximum number of overlapping playbacks)
짝Counterpart: vanilla-engine SoundEffectPool.get_voice_count