core/soundeffectpool
효과음 풀.
- 원본 core/soundeffectpool.js. 같은 효과음이 연달아 겹쳐 나도 끊기지 않도록 여러 AudioPlayer 를 돌려 가며(라운드로빈) 재생한다.
- 백엔드를 직접 부르지 않는다. AudioPlayer 위에서 차례와 음량만 센다.
- 사용:
let mut sound_effect_pool = SoundEffectPool::new(&engine.get_audio_manager(), 6);
sound_effect_pool.play(&hitAudioAsset, 1.0);
sound_effect_pool.play(&hitAudioAsset, 0.5); // 이 재생만 절반 음량.
sound_effect_pool.set_volume(0.8); // 풀 전체의 음량. (재생 중인 것에도 곱해진다)- 보이스 수가 0 이면 play 는 원본처럼 아무것도 하지 않는다.
- 원본과 다른 점:
play 의 음량은 기본값이 없어 늘 넘긴다. (원본 기본 1)Sound effect pool.
- The original core/soundeffectpool.js. So the same sound effect is not cut off when it overlaps in quick succession, it plays by rotating through several AudioPlayers (round robin).
- Does not call the backend directly. On top of AudioPlayer it only tracks the turn and volume.
- Usage:
let mut sound_effect_pool = SoundEffectPool::new(&engine.get_audio_manager(), 6);
sound_effect_pool.play(&hitAudioAsset, 1.0);
sound_effect_pool.play(&hitAudioAsset, 0.5); // Half volume for this playback only.
sound_effect_pool.set_volume(0.8); // Volume of the whole pool. (also multiplied into ones already playing)- If the voice count is 0, play does nothing, as in the original.
- Differences from the original:
play's volume has no default, so it is always passed. (the original defaults to 1)SoundEffectPoolstruct
효과음 풀.
- 플레이어 여럿을 차례로 돌려 같은 효과음이 겹쳐도 앞 소리를 끊지 않는다. (보이스 수보다 많이 겹치면 가장 오래된 것을 끊는다)
Sound effect pool.
- Rotates through several players in turn so overlapping copies of the same sound effect do not cut off the earlier sound. (if more overlap than the voice count, the oldest is cut)
use vanilla::{Engine, EngineConfiguration, SoundEffectPool};
let engine = Engine::new(EngineConfiguration::new());
let hit_audio_asset = engine.load_audio_asset("tests/assets/audio/wav_s16_stereo.wav").unwrap();
let mut sound_effect_pool = SoundEffectPool::new(&engine.get_audio_manager(), 6);
sound_effect_pool.play(&hit_audio_asset, 1.0);
sound_effect_pool.play(&hit_audio_asset, 0.5);
sound_effect_pool.set_volume(0.8);
assert_eq!(sound_effect_pool.get_voice_count(), 6);use vanilla::{AudioManager, SoundEffectPool};
let audio_manager = AudioManager::new();
let mut sound_effect_pool = SoundEffectPool::new(&audio_manager, 0);
assert_eq!(sound_effect_pool.get_voice_count(), 0);
sound_effect_pool.set_volume(1.5);
assert_eq!(sound_effect_pool.get_volume(), 1.0);
sound_effect_pool.set_muted(true);
assert!(sound_effect_pool.is_muted());생성. (voice_count: 동시에 겹칠 수 있는 최대 재생 수)
Creates. (voice_count: maximum number of playbacks that can overlap at once)
- audio_manager&AudioManager
- 플레이어를 만들 매니저. (보통 engine.get_audio_manager())Manager to create the players with. (usually engine.get_audio_manager())
- voice_countusize
- 동시에 겹칠 수 있는 최대 재생 수. (원본 기본 6, DEFAULT_VOICE_COUNT) 0 이면 play 가 아무것도 하지 않는다.Maximum number of playbacks that can overlap at once. (the original default 6, DEFAULT_VOICE_COUNT) If 0, play does nothing.
반환ReturnsSoundEffectPool 플레이어 voice_count 개를 든 새 풀. (음량 1, 음소거 아님)A new pool holding voice_count players. (volume 1, not muted)
짝Counterpart: vanilla.js SoundEffectPool.constructor
효과음 재생.
- 다음 차례의 플레이어에 애셋을 실어 재생한다. 그 플레이어가 재생 중이었다면 끊고 새로 튼다.
- 음량은 이 재생의 음량(0 ~ 1)에 풀의 음량을 곱한 것이다.
- 음소거 중이거나 보이스가 없으면 아무것도 하지 않고 차례도 넘기지 않는다.
Plays a sound effect.
- Loads the asset into the next player in turn and plays it. If that player was playing, cuts it and plays anew.
- The volume is this playback's volume (0 ~ 1) multiplied by the pool's volume.
- While muted or without voices, does nothing and does not advance the turn.
- audio_asset&Rc<AudioAsset>
- 틀 효과음 애셋.Sound effect asset to play.
- volumef64
- 이 재생의 음량. (0 ~ 1, 풀의 음량을 곱한 뒤 0 ~ 1 로 자른다)Volume of this playback. (0 ~ 1, multiplied by the pool's volume then clamped to 0 ~ 1)
짝Counterpart: vanilla.js SoundEffectPool.play
모두 정지.
Stops all.
짝Counterpart: vanilla.js SoundEffectPool.stopAll
음소거 설정.
- 모든 플레이어를 음소거하거나 풀고, 음소거 중에는 play 를 건너뛴다.
Sets mute.
- Mutes or unmutes all players, and skips play while muted.
- is_mutedbool
- true 면 음소거, false 면 풀기.True to mute, false to unmute.
짝Counterpart: vanilla.js SoundEffectPool.setMuted
풀 전체의 음량 설정. (0 ~ 1, 재생 중인 것에도 바로 곱해진다)
Sets the volume of the whole pool. (0 ~ 1, applied immediately to those playing too)
- volumef64
- 풀 전체의 음량. (0 ~ 1 로 자른다, 유한하지 않으면 1)Volume of the whole pool. (clamped to 0 ~ 1, 1 if not finite)
짝Counterpart: vanilla.js SoundEffectPool.setVolume
풀 전체의 음량.
Volume of the whole pool.
반환Returnsf64 풀 전체의 음량. (0 ~ 1, 기본 1)Volume of the whole pool. (0 ~ 1, default 1)
짝Counterpart: vanilla.js SoundEffectPool.getVolume
음소거 여부.
Whether muted.
반환Returnsbool set_muted(true) 뒤면 true.True after set_muted(true).
짝Counterpart: vanilla.js SoundEffectPool.isMuted
보이스 수 반환.
Returns the number of voices.
반환Returnsusize 풀이 든 플레이어 수. (만들 때의 voice_count)Number of players the pool holds. (voice_count at creation)
짝Counterpart: vanilla.js SoundEffectPool.getVoiceCount
상수Constants
원본 생성자의 기본 보이스 수.
Default voice count of the original constructor.
반환Returnsusize