API / platform/audio
platform/audio
오디오 백엔드.
- AudioManager, AudioPlayer, AudioAsset, BeepPlayer 가 소리를 낼 때 부르는 아래층이다. 공통 코드는 core, resource, misc 에 있다.
- 백엔드마다 아래 이름을 같은 꼴로 낸다. AudioContext(공유 컨텍스트), AudioBuffer(디코딩한 소리), AudioPlatformState(매니저가 드는 백엔드 상태), AudioPlayerBackend(플레이어 하나의 소리 내는 부분), AudioBusBackend(버스 하나의 소리 모으는 부분, create_player_backend 로 그 버스로 트는 플레이어), HAS_USER_GESTURE_AT_START, create_audio_platform_state, create_audio_context, resume_audio_context, is_audio_context_running, load_audio_file, load_audio_bytes(읽기 방식 AudioLoadType 을 받는다), get_audio_buffer_duration, play_beep_tone, AudioStream(스트리밍으로 읽은 소리, get_duration, get_stream_url), AudioPlayerBackend::start_stream_playback, get_stream_time suspend_audio_context(컨텍스트 멈춤), get_audio_context_time(컨텍스트 시계), AudioPlayerBackend::set_pan(좌우)
- 데스크탑: cpal 출력 위의 엔진 믹서. (desktop.rs, mixer.rs. 노드 그래프와 셈이 크롬 WebAudio 와 같다) 소리 파일 해석은 크롬 decodeAudioData 와 같게 decode/ 가 한다. (symphonia 0.6, Opus 는 opus-pure) PannerNode(초안, panner.rs)의 HRTF 는 크롬의 HRTFPanner 와 IRCAM 자료(Composite.flac)를 옮긴 hrtf/ 가 셈한다. (FFT 는 크롬과 같은 rustfft)
- 웹: 원본과 같은 WebAudio 를 web-sys 로 직접 부른다. (web.rs)
- 게임 코드가 이름을 부를 수 있게 AudioContext, AudioBuffer 두 타입만 밖으로 낸다. 나머지는 엔진 안에서만 쓴다.
Audio backend.
- The lower layer AudioManager, AudioPlayer, AudioAsset and BeepPlayer call to make sound. The common code is in core, resource and misc.
- Each backend exposes the following names in the same form. AudioContext (the shared context), AudioBuffer (decoded sound), AudioPlatformState (the backend state the manager holds), AudioPlayerBackend (the sound-making part of one player), AudioBusBackend (the sound-gathering part of one bus, create_player_backend makes a player that plays into that bus), HAS_USER_GESTURE_AT_START, create_audio_platform_state, create_audio_context, resume_audio_context, is_audio_context_running, load_audio_file, load_audio_bytes (take the load type AudioLoadType), get_audio_buffer_duration, play_beep_tone, AudioStream (a sound loaded for streaming, get_duration, get_stream_url), AudioPlayerBackend::start_stream_playback, get_stream_time suspend_audio_context (suspending the context), get_audio_context_time (the context clock), AudioPlayerBackend::set_pan (left and right)
- Desktop: the engine mixer on top of cpal output. (desktop.rs, mixer.rs. The node graph and math are the same as Chrome WebAudio) Sound files are decoded by decode/ the same way as Chrome decodeAudioData. (symphonia 0.6, opus-pure for Opus) The HRTF of PannerNode (draft, panner.rs) is computed by hrtf/, a port of Chrome's HRTFPanner and the IRCAM data (Composite.flac). (the FFT is the same rustfft as Chrome)
- Web: calls the same WebAudio as the original directly through web-sys. (web.rs)
- Only the two types AudioContext and AudioBuffer are exposed so game code can name them. The rest are used only inside the engine.