vanilladocs
vanillapunch.com
API / core/soundeffectpool

core/soundeffectpool

효과음 풀.

Sound effect pool.

SoundEffectPoolextends Object

짝Counterpart: vanilla-engine SoundEffectPool

효과음 풀.

  • 같은 효과음이 연달아 겹쳐 나도 끊기지 않도록, 여러 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)
예제Example같은 효과음을 겹쳐 내기Play the same sound effect overlapping
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();
생성자constructorconstructor(audioManager, voiceCount = 6)#0.3.0 부터since 0.3.0소스source

생성.

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

메서드methodplay(audioAsset, volume = 1)#0.3.0 부터since 0.3.0소스source

효과음 재생.

  • 다음 차례의 플레이어에 애셋을 실어 재생한다. 그 플레이어가 재생 중이었다면 끊고 새로 튼다.
  • 음량은 이 재생의 음량(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

메서드methodstopAll()#0.3.0 부터since 0.3.0소스source

모두 정지.

Stops all.

짝Counterpart: vanilla-engine SoundEffectPool.stop_all

메서드methodsetMuted(isMuted)#0.3.0 부터since 0.3.0소스source

음소거 설정.

Sets mute.

isMutedboolean
참이면 모든 플레이어를 음소거하고 새 재생도 하지 않는다.If true, mutes all players and does not start new playback.

짝Counterpart: vanilla-engine SoundEffectPool.set_muted

메서드methodsetVolume(volume)#0.3.2 부터since 0.3.2소스source

풀 전체의 음량 설정. (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

메서드methodgetVolume()#0.3.2 부터since 0.3.2소스source

풀 전체의 음량.

Volume of the whole pool.

반환Returnsnumber 풀 전체의 음량. (0 ~ 1, 기본 1)Volume of the whole pool. (0 ~ 1, default 1)

짝Counterpart: vanilla-engine SoundEffectPool.get_volume

메서드methodisMuted()#0.3.0 부터since 0.3.0소스source

음소거 여부.

Whether muted.

반환Returnsboolean 음소거 중이면 참.True if muted.

짝Counterpart: vanilla-engine SoundEffectPool.is_muted

메서드methodgetVoiceCount()#0.3.0 부터since 0.3.0소스source

보이스 수 반환.

Returns the number of voices.

반환Returnsnumber 플레이어 수. (동시에 겹칠 수 있는 최대 재생 수)Player count. (the maximum number of overlapping playbacks)

짝Counterpart: vanilla-engine SoundEffectPool.get_voice_count