-
Notifications
You must be signed in to change notification settings - Fork 4
Usage Guide
Gindemit Konstantin edited this page May 12, 2023
·
2 revisions
Once you've installed the Unity Vorbis Plugin, you can start utilizing its functionality in your Unity project. This guide will walk you through the basic usage of the plugin.
The Unity Vorbis Plugin provides a variety of functions for loading, saving, and manipulating OGG Vorbis audio files.
- 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);
- Reading from file as from stream (C# API, not fully tested): This function is currently not well tested. If you're interested in using this feature, please refer to the API Reference for more details.
Please note that when specifying the quality parameter while saving or serializing, a value of 0 corresponds to the lowest quality and a value of 1 corresponds to the highest quality. For more details on the quality parameter, refer to the official Vorbis documentation.
For a more comprehensive understanding of each function and its parameters, please visit the API Reference.