MP3 (.mp3)

  • Import and Export support the MP3 specification.
  • BackgroundBackground

      MIME types: audio/mpeg, audio/mpeg3, audio/x-mpeg-3MP3 digital audio format, known as MPEG Audio Layer 3.
      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.
      Follows the ISO/IEC 11172-3 and ISO/IEC 13818-3 standard.
      Supports a few sampling frequencies from 8kHz to 48kHz.
      Supports up to two audio channels.

    Import and ExportImport and Export

    • Import["file.mp3"] imports an MP3 file, returning a sound object.
    • Import["file.mp3"] converts the compressed data to pulse-code modulation (PCM) and gives an expression of the form Sound[SampledSoundList[data,r]].
    • Export["file.mp3",expr] creates an MP3 file from the sound object expr.
    • Import["file.mp3",elem] imports the specified element from an MP3 file.
    • Import["file.mp3",{{elem1,elem2,}}] imports multiple elements.
    • The import format can be specified with Import["file","MP3"] or Import["file",{"MP3",elem,}].
    • Export["file.mp3",expr,elem] creates an MP3 file by treating expr as specifying element elem.
    • Export["file.mp3",{expr1,expr2,},{{elem1,elem2,}}] treats each as specifying the corresponding .
    • Export["file.mp3",expr,opt1->val1,] exports expr with the specified option elements taken to have the specified values.
    • Export["file.mp3",{elem1->expr1,elem2->expr2,},"Rules"] uses rules to specify the elements to be exported.
    • See the reference pages for full general information on Import and Export.
    • ImportString and ExportString support the MP3 format.

    ElementsElements

    • 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:
    • "Data"raw audio samples, given as a list of real numbers, each sublist representing an individual audio channel
      "SampledSoundList"sound data given as a SampledSoundList object
      "Sound"sound data given as a Sound object
    • The element corresponds to the first argument of SampledSoundList.
    • Multiple channels are represented as an array of audio samples.
    • Import and Export use the element by default for MP3 files.
    • Advanced Import element:
    • "AudioChannels"the number of audio channels in the file
      "SampleRate"number of amplitude samples per second and channel

    OptionsOptions

    • General option:
    • SampleRateAutomaticnumber of amplitude samples per second for each channel
    • Export options:
    • "AudioChannels"Automaticnumber of audio channels
      "CompressionLevel"0.5compression level, given as a number between 0 and 1
    • Supported Export sample rates in Hz are 8000, 11025, 16000, 22050, 24000, 32000, 44100, and 48000.

    ExamplesExamplesopen allclose all

    Basic Examples  (2)Basic Examples  (2)

    Import an MP3 file:

    In[1]:=
    Click for copyable input
    Out[1]=

    Generate a sound and export to MP3:

    In[1]:=
    Click for copyable input
    Out[1]=
    In[2]:=
    Click for copyable input
    Out[2]=
    Introduced in 2014
    (10.0)
    Translate this page: