Class juce.AudioFormatReader

Class to read audio files.

Example usage: soundfile-test.lua.

Reads the formats that JUCE supports, namely: WAV, AIFF, Flac, Ogg-Vorbis, Windows Media codecs, CoreAudio codecs, MP3.

Is a pointer to a JUCE AudioFormatReader, and wraps some AudioFormatManager functionality.

Constructors

juce.AudioFormatReader (filename) Load a sound file as an AudioFormatReader.

Methods

juce.AudioFormatReader:read
(destSamples, numDestChannels, startSampleInSource, numSamplesToRead[, fillLeftoverChannelsWithCopies=true])
Read samples.
juce.AudioFormatReader:readToFloat
([nChannels=2[, resample=true]])
Read entire wave to float array.
juce.AudioFormatReader:readToDouble
([nChannels=2[, resample=true]])
Read entire wave to double array.

Fields

juce.AudioFormatReader.sampleRate Sample rate
juce.AudioFormatReader.bitsPerSample Bits per sample
juce.AudioFormatReader.lengthInSamples Length in samples
juce.AudioFormatReader.numChannels Number of channels
juce.AudioFormatReader.usesFloatingPointData Uses floating point data (boolean)


Constructors

juce.AudioFormatReader (filename)
Load a sound file as an AudioFormatReader. The path can be absolute or relative to the protoplug directory. Returns nil if unsuccessful. The file will remain open until the AudioFormatReader is unset or otherwise garbage-collected.

Parameters:

  • filename

Methods

juce.AudioFormatReader:read
(destSamples, numDestChannels, startSampleInSource, numSamplesToRead[, fillLeftoverChannelsWithCopies=true])
Read samples.
Copies a number of samples from the file into the provided array.

Parameters:

  • destSamples a cdata array of pointers to buffers for each channel (int * const *)
  • numDestChannels the number of elements in destSamples
  • startSampleInSource
  • numSamplesToRead
  • fillLeftoverChannelsWithCopies boolean used if destSamples has more channels than the source. (default true)

Returns:

    boolean success
juce.AudioFormatReader:readToFloat
([nChannels=2[, resample=true]])
Read entire wave to float array.
A simplified wrapper function for read

Parameters:

  • nChannels number of channels to be returned (default 2)
  • resample whether to perform samplerate conversion to match the host's sample rate. If true, the length of the returned array may not be the wave's original lengthInSamples . It will be given by the second returned value. (default true)

Returns:

  1. a two-dimensional cdata array of channels containing samples (float [nChannels][nSamples])
  2. the number of samples in each channel of the returned array
juce.AudioFormatReader:readToDouble
([nChannels=2[, resample=true]])
Read entire wave to double array.
This wraps readToFloat and returns an array containing double-precision numbers. This takes twice as much space, but it may be faster to use, as this is the native Lua type.

Parameters:

  • nChannels number of channels to be returned (default 2)
  • resample whether to perform samplerate conversion to match the host's sample rate. If true, the length of the returned array may not be the wave's original lengthInSamples . It will be given by the second returned value. (default true)

Returns:

  1. a two-dimensional cdata array of channels containing samples (double [nChannels][nSamples])
  2. the number of samples in each channel of the returned array

Fields

juce.AudioFormatReader.sampleRate
Sample rate
juce.AudioFormatReader.bitsPerSample
Bits per sample
juce.AudioFormatReader.lengthInSamples
Length in samples
juce.AudioFormatReader.numChannels
Number of channels
juce.AudioFormatReader.usesFloatingPointData
Uses floating point data (boolean)
generated by LDoc 1.4.2