Skip to content
Porrith Suong edited this page May 26, 2022 · 4 revisions

Welcome to the MiniAudio.Unity wiki!

Using MiniAudio with DOTS

Authoring

Attach the AudioAuthoring component to a GameObject that will be converted to an Audio Entity.

You can set the following settings:

  • IsPathStreamingAssets
    • Is the path located in the streaming assets folder? If so, the path must be relative to Unity's StreamingAssets' folder.
  • Path
    • The path to the audio file. If you use a streaming asset path, you need to use a relative path to the StreamingAssets' folder. If using the StreamingAssets folder, then the AudioSystem will concatenate the relative path with the StreamingAssets path on runtime.
  • SoundLoadParameters
    • IsLooping
      • Does the audio file seek to the beginning of the file after finishing?
    • Volume
      • How loud is the sound being played?
    • StartTime
      • Do we need a custom start time because there's a delay before the first sound is played?
    • EndTime
      • Do we need a custom end time because there's a delay before the last sound is played?

Components

The following components will be attached to the Entity:

  • LoadPath : DynamicBuffer
    • Local or absolute path to the file. Unicode 16 is supported.
  • AudioClip : IComponentData
    • Handle: stores in native memory that represents the sounds playing.
    • AudioState: The current state of the sound (Stopped, Played, Paused)
    • Parameters: The SoundLoadParameter which defines the volume, start, end, and whether the audio file loops.
  • AudioMetadata
    • IsLoaded: Is the sound loaded?
    • IsStreamingAssets: Is the audio file relative at the StreamingAssets path?
  • AudioStateHistory

Systems

  • AudioSystem
    1. Loads an audio file. If the audio file exists, then a valid uint handle will be set to the AudioClip component. An invalid handle is equivalent to uint.MaxValue.
    2. If the AudioClip's current state changes, then the ManageAudioJob will execute the appropriate function calls to to Stop, Play, or Pause the audio.

Unloading

  • You must call MiniAudioHandler.UnloadSound(uint handle) with the correct audio handle. This will properly free native memory and push the handle to a free list for reuse.
  • To unload a sound, you must delete the entity with the components mentioned above.
    • All sounds are unloaded upon quitting.

Limitations

  • Burst Compiler support is only allowed in builds. All editor functionality must be non burstable.
    • You must wrap all [BurstCompile] jobs #if !UNITY_EDITOR defines.
Clone this wiki locally