Commit faac823
authored
refactor(core): overhaul audio engine and device architecture (#72)
This commit introduces a major architectural refactoring to move away from a singleton-based (`AudioEngine.Instance`) model to a device-centric, instance-based architecture. This fundamental change enables true multi-device input and output, allowing applications to manage and switch between multiple playback and capture devices simultaneously and independently.
This refactor also includes several new features, performance improvements, and critical bug fixes that are built upon the new architecture.
### Key Changes & Features
- **Multi-Device Architecture**: The global `AudioEngine.Instance` and `Mixer.Master` have been removed. The new design introduces `AudioPlaybackDevice`, `AudioCaptureDevice`, and `FullDuplexDevice` abstractions, each managing its own audio graph and `MasterMixer`.
- **Explicit Context**: Core components now receive `AudioEngine` and `AudioFormat` context via their constructors, removing implicit dependencies on global state.
- **Device Switching API**: A new, robust `Engine.SwitchDevice()` API allows for seamless hot-swapping of active audio devices while preserving their state (e.g., attached components or event subscribers).
- **New `VoiceIsolationEffect`**: Adds an experimental modifier that acts as a band-pass filter to help isolate human speech frequencies.
- **New `MultiEngines` Sample**: A new sample project is included to demonstrate and test the new multi-device capabilities.
### Fixes & Performance Improvements
- **fix(network)**: Refactored `NetworkDataProvider` to use a chunked streaming and decoding model, resolving excessive memory usage. Memory consumption for a 15-minute audio file is reduced from ~1GB to ~20MB.
- **fix(recording)**: Corrects a critical audio format conversion bug that produced garbled audio when recording to formats other than F32.
- **refactor(native)**: Unified the FFT implementations in `MathHelper` for Scalar, SSE, and AVX paths to ensure consistent behavior. The SIMD paths are now toggleable via static properties for easier debugging.
- **refactor(interop)**: The native device configuration layer now uses a comprehensive DTO, allowing for more granular control over backend-specific settings (WASAPI, ALSA, etc.).
BREAKING CHANGE: This is a fundamental architectural change that affects the entire public API.
- `AudioEngine.Instance` is removed. An `AudioEngine` must now be instantiated (e.g., `new MiniAudioEngine()`).
- Audio is no longer played by adding components to `Mixer.Master`. Users must first initialize a device (e.g., `engine.InitializePlaybackDevice(...)`) and then add components to the device's `MasterMixer`.
- Constructors for nearly all `SoundComponent`, `ISoundDataProvider`, `SoundModifier`, and `AudioAnalyzer` derivatives have changed. They now require an `AudioEngine` and/or `AudioFormat` instance to be passed in.
- The global `AudioEngine.OnAudioProcessed` event is removed. Events for processed audio are now available on a per-device basis (e.g., `AudioCaptureDevice.OnAudioProcessed`).
- The previous `SwitchDevice` API is replaced with new, more explicit methods on the `AudioEngine` instance that return a new device object.1 parent 8393338 commit faac823
File tree
144 files changed
+5713
-3685
lines changed- .github/workflows
- Extensions/SoundFlow.Extensions.WebRtc.Apm
- Components
- Modifiers
- Native
- Samples
- SoundFlow.Samples.EditingMixer
- SoundFlow.Samples.MultiEngines
- SoundFlow.Samples.NoiseSuppression
- SoundFlow.Samples.SimplePlayer
- SoundFlow.Samples.SwitchDevices
- Src
- Abstracts
- Devices
- Backends/MiniAudio
- Devices
- Enums
- Structs
- runtimes
- android-arm64/native
- android-arm/native
- android-x64/native
- freebsd-arm64/native
- freebsd-x64/native
- iOS-arm64/native/miniaudio.framework
- linux-arm64/native
- linux-arm/native
- linux-x64/native
- osx-arm64/native
- osx-x64/native
- win-arm64/native
- win-x64/native
- win-x86/native
- Components
- Editing
- Persistence
- Enums
- Exceptions
- Experimental
- Interfaces
- Modifiers
- Providers
- Structs
- Utils
- Visualization
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
144 files changed
+5713
-3685
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
288 | | - | |
| 288 | + | |
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
293 | | - | |
| 293 | + | |
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
300 | | - | |
| 300 | + | |
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| |||
389 | 389 | | |
390 | 390 | | |
391 | 391 | | |
392 | | - | |
| 392 | + | |
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
396 | | - | |
397 | | - | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
398 | 401 | | |
399 | | - | |
| 402 | + | |
400 | 403 | | |
401 | 404 | | |
402 | 405 | | |
403 | | - | |
404 | | - | |
405 | | - | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
406 | 411 | | |
407 | | - | |
| 412 | + | |
408 | 413 | | |
409 | 414 | | |
410 | 415 | | |
411 | 416 | | |
412 | | - | |
| 417 | + | |
413 | 418 | | |
| 419 | + | |
| 420 | + | |
414 | 421 | | |
415 | | - | |
| 422 | + | |
416 | 423 | | |
417 | 424 | | |
418 | 425 | | |
419 | 426 | | |
420 | | - | |
421 | | - | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
422 | 446 | | |
423 | | - | |
| 447 | + | |
424 | 448 | | |
425 | 449 | | |
426 | 450 | | |
427 | 451 | | |
428 | | - | |
| 452 | + | |
429 | 453 | | |
| 454 | + | |
| 455 | + | |
430 | 456 | | |
431 | 457 | | |
432 | 458 | | |
| |||
0 commit comments