Skip to content

API Reference

Gindemit Konstantin edited this page May 12, 2023 · 1 revision

API Reference

Class: VorbisPlugin

Namespace: OggVorbis

The VorbisPlugin class is the main interface for interacting with the OggVorbis audio format.

Method: Save

public static void Save(
    string filePath,
    UnityEngine.AudioClip audioClip,
    float quality = 0.4f,
    int samplesToRead = 1024)

Parameters:

  • filePath: The file path where the audio clip will be saved.
  • audioClip: The Unity audio clip to be saved.
  • quality: The quality of the output audio file, default is 0.4f.
  • samplesToRead: The number of samples to read from the audio clip, default is 1024.

This method saves a Unity audio clip to a specified file path with the given quality and number of samples to read.

Method: GetOggVorbis

public static byte[] GetOggVorbis(
    UnityEngine.AudioClip audioClip,
    float quality = 0.4f,
    int samplesToRead = 1024)

Parameters:

  • audioClip: The Unity audio clip to be converted.
  • quality: The quality of the output audio data, default is 0.4f.
  • samplesToRead: The number of samples to read from the audio clip, default is 1024.

This method returns a byte array representing the audio clip in the OggVorbis format.

Method: Load

public static UnityEngine.AudioClip Load(
    string filePath, 
    int maxSamplesToRead = 1024)

Parameters:

  • filePath: The file path of the audio file to be loaded.
  • maxSamplesToRead: The maximum number of samples to read from the audio file, default is 1024.

This method loads an audio clip from a specified file path and returns it as a Unity AudioClip.

Method: ToAudioClip

public static UnityEngine.AudioClip ToAudioClip(
    byte[] bytes, 
    string audioClipName, 
    int maxSamplesToRead = 1024)

Parameters:

  • bytes: The byte array representing the audio data.
  • audioClipName: The name of the new Unity audio clip.
  • maxSamplesToRead: The maximum number of samples to read from the audio data, default is 1024.

This method converts a byte array representing audio data into a Unity AudioClip.