OggVorbis (.oga, .ogg)

Background & Context

    • MIME types: audio/ogg, audio/vorbis, audio/x-ogg
    • OggVorbis digital audio format.
    • A lossy compression scheme commonly used for consumer audio streaming, storage, transfer and playback, which can also be used on the web.
    • Binary file format.
    • Stores up to 255 channels of compressed audio data.
    • OggVorbis uses variable bit rate (VBR) per sample.
    • Supports arbitrary sampling frequencies from 8 kHz to 192 kHz.

Import & Export

  • Import["file.ogg"] imports an OggVorbis file, returning an audio object.
  • Import["file.ogg",elem] imports the specified element from an OggVorbis file.
  • The import format can be specified with Import["file","OggVorbis"] or Import["file",{"OggVorbis",elem,}].
  • Export["file.oga",expr] exports an audio or sound object to an OggVorbis file.
  • Export["file.oga",expr,"OggVorbis"] can also be used to export to an OggVorbis file.
  • Sound objects including notes are rasterized to sampled audio.
  • See the reference pages for full general information on Import and Export.
  • ImportString and ExportString support the OggVorbis audio format.

Import Elements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties and settings
  • Data representation elements:
  • "Audio"audio signal given as an Audio object
    "AudioFile"audio signal given as an out-of-core Audio object
    "Data"raw audio samples, given as a list of real numbers, each sublist representing an individual audio channel
    "SampledSoundList"audio signal given as a SampledSoundList object
    "Sound"audio signal given as a Sound object
  • Import by default uses the "Audio" element for short OggVorbis files and the "AudioFile" element otherwise.
  • Multiple channels are represented as an array of audio samples.
  • Advanced Import element:
  • "AudioChannels"number of audio channels
    "AudioEncoding"audio encoding
    "Duration"duration of the audio given in seconds
    "Length"number of samples
    "SampleDepth"number of bits used to store every sample
    "SampleRate"number of amplitude samples per second and channel
  • Metadata elements:
  • "MetaInformation"interpreted as quantities, locations, dates, numbers, etc.
    "RawMetaInformation"uninterpreted as strings and numbers
  • Available metadata tags include "Xiph".

Options

  • Import and Export option:
  • "AudioChannels"Automaticnumber of audio channels
    IncludeMetaInformationAllmetadata types to import and export
    SampleRateAutomaticsamples per second for each channel
  • Export option:
  • CompressionLevel0.5compression level, given as a number between 0 and 1
  • If the number of channels is unspecified, the highest number of simultaneous channels is taken, and silence is inserted if necessary.
  • If "AudioChannels" is set to a value n that is less than the number of channels to be exported, only the first n channels are exported.
  • CompressionLevel can be set to values in the range from 0 to 1, with larger values resulting in smaller file sizes.
  • Supported IncludeMetaInformation settings are: "Xiph", "RawXiph", All and None.

Examples

open allclose all

Basic Examples  (2)

Import an OggVorbis file:

Export to an OggVorbis file:

Decrease compression level:

Scope  (5)

Show all import elements available in this file:

Import audio properties:

Use ExportString and ImportString with OggVorbis:

Use Play to generate sampled sound and export it to OggVorbis:

Export it to OggVorbis:

Sound notes are automatically sampled and exported to OggVorbis:

Import Elements  (16)

Available Elements  (3)

List of available elements:

Get audio-related information as a list of rules:

Import some image options:

The "Options" element does not return all options that are present in the imported image:

Data Representation  (5)

"Audio"  (1)

Get an audio signal given as an Audio object:

"AudioFile"  (1)

Get an audio signal given as an out-of-core Audio object:

"Data"  (1)

Get a raw audio sample, given as a list of real numbers, each sublist representing an audio channel:

Create audio from imported data:

"SampledSoundList"  (1)

Get an audio signal given as a SampledSoundList object:

"Sound"  (1)

Get an audio signal given as a Sound object:

Metadata  (8)

"AudioChannels"  (1)

Number of audio channels:

"AudioEncoding"  (1)

Audio encoding:

"Duration"  (1)

Duration of the audio given in seconds:

"Length"  (1)

Number of samples:

"MetaInformation"  (1)

Get the audio metadata:

"RawMetaInformation"  (1)

Get the audio metadata in a raw form:

"SampleDepth"  (1)

Get the number of bits used to store every sample:

"SampleRate"  (1)

Get the number of amplitude samples per second and channel:

Import Options  (5)

"AudioChannels"  (1)

By default, the number of audio channels is set to be Automatic:

Specify all the audio channels to be imported:

Import second channel only:

IncludeMetaInformation  (3)

By default, all available metadata is imported:

Import the sound with no metadata:

Import the audio with only specified classes of metadata:

SampleRate  (1)

By default, the sample rate is extracted from the file:

Specify the sample rate of the imported sound:

Export Options  (4)

"AudioChannels" (2)

By default, the audio is exported using the default number of channels:

Specify the number of channels of exported audio:

By default, the audio is exported using the 0.5 compression level:

Specify the encoding of exported audio:

IncludeMetaInformation  (1)

By default, the audio is exported using the metadata:

Specify the metadata of exported audio:

SampleRate  (1)

By default, the audio is exported using the default sample rate:

Specify the sample rate of exported audio:

Introduced in 2014
 (10.0)
 |
Updated in 2018
 (11.3)
2020
 (12.1)