Unity Vorbis plugin is a powerful tool for the Unity game engine that allows you to work with OGG Vorbis audio files. OGG Vorbis is a free, open-source audio coding format that is well-suited for streaming and manipulation in games.
The plugin provides you with the following functionalities:
- Load Vorbis OGG from file at runtime: Allows you to load OGG files from specified file paths.
- Save Vorbis OGG to file at runtime: Allows you to save AudioClip objects as OGG files at specified paths.
- Get Vorbis OGG from bytes array at runtime: Allows you to convert byte arrays to AudioClip objects.
- Serialize Vorbis OGG to bytes array at runtime: Allows you to convert AudioClip objects to byte arrays.
- C# API to read from file as from stream: This is an experimental feature and is not fully tested.
For detailed information about these features, visit the API Reference page on our wiki.
- Android
- iOS
- Windows
- OSX
To install the plugin, follow these steps:
- Download the latest release from the releases page.
- In Unity, go to Assets -> Import Package -> Custom Package and import the downloaded file.
- If you're using assembly definition files, add "VorbisPluginImpl" as a reference in your project.
For more detailed instructions, please visit the Installation Guide on the wiki.
Here's a quick rundown on how to use some of the most essential functions provided by this plugin:
// Loading Vorbis OGG from file at runtime:
string pathToFile = ...; // path to your file
UnityEngine.AudioClip audioClip = OggVorbis.VorbisPlugin.Load(pathToFile);
// Saving Vorbis OGG to file at runtime:
string pathToFile = ...; // path where you want to save the file
UnityEngine.AudioClip audioClip = ...; // audio clip you want to save
float quality = 0.4f; // optional parameter, values from 0 to 1
OggVorbis.VorbisPlugin.Save(pathToFile, audioClip, quality);
// Getting Vorbis OGG from bytes array at runtime:
byte[] sourceAudioBytes = ...; // byte array of your audio
UnityEngine.AudioClip sourceAudioClip = OggVorbis.VorbisPlugin.ToAudioClip(sourceAudioBytes, "NameOfAudioClip");
// Serializing Vorbis OGG to bytes array at runtime:
UnityEngine.AudioClip sourceAudioClip = ...; // audio clip you want to serialize
float quality = 0.4f; // optional parameter, values from 0 to 1
byte[] bytes = OggVorbis.VorbisPlugin.GetOggVorbis(sourceAudioClip, quality);
Visit the Usage Guide on the wiki for step-by-step instructions on how to use the plugin in your Unity project.
If you want to build the plugin from source, we've provided detailed instructions for each supported platform in our Building from Source page on the wiki.
We welcome contributions from the community. To contribute, please read the Contribution Guidelines on the wiki.
This project is licensed under the MIT License. See the LICENSE file for details.