OpenShot Audio Library | OpenShotAudio 0.3.2
|
#include <juce_AudioFormatWriter.h>
Inherited by juce::AiffAudioFormatWriter, and juce::WavAudioFormatWriter.
Classes | |
class | ThreadedWriter |
struct | WriteHelper |
Public Member Functions | |
virtual | ~AudioFormatWriter () |
const String & | getFormatName () const noexcept |
virtual bool | write (const int **samplesToWrite, int numSamples)=0 |
virtual bool | flush () |
bool | writeFromAudioReader (AudioFormatReader &reader, int64 startSample, int64 numSamplesToRead) |
bool | writeFromAudioSource (AudioSource &source, int numSamplesToRead, int samplesPerBlock=2048) |
bool | writeFromAudioSampleBuffer (const AudioBuffer< float > &source, int startSample, int numSamples) |
bool | writeFromFloatArrays (const float *const *channels, int numChannels, int numSamples) |
double | getSampleRate () const noexcept |
int | getNumChannels () const noexcept |
int | getBitsPerSample () const noexcept |
bool | isFloatingPoint () const noexcept |
Protected Member Functions | |
AudioFormatWriter (OutputStream *destStream, const String &formatName, double sampleRate, unsigned int numberOfChannels, unsigned int bitsPerSample) | |
AudioFormatWriter (OutputStream *destStream, const String &formatName, double sampleRate, const AudioChannelSet &audioChannelLayout, unsigned int bitsPerSample) | |
Protected Attributes | |
double | sampleRate |
unsigned int | numChannels |
unsigned int | bitsPerSample |
bool | usesFloatingPointData |
AudioChannelSet | channelLayout |
OutputStream * | output |
Writes samples to an audio file stream.
A subclass that writes a specific type of audio format will be created by an AudioFormat object.
After creating one of these with the AudioFormat::createWriterFor() method you can call its write() method to store the samples, and then delete it.
Definition at line 44 of file juce_AudioFormatWriter.h.
|
protected |
Creates an AudioFormatWriter object.
destStream | the stream to write to - this will be deleted by this object when it is no longer needed |
formatName | the description that will be returned by the getFormatName() method |
sampleRate | the sample rate to use - the base class just stores this value, it doesn't do anything with it |
numberOfChannels | the number of channels to write - the base class just stores this value, it doesn't do anything with it |
bitsPerSample | the bit depth of the stream - the base class just stores this value, it doesn't do anything with it |
Definition at line 30 of file juce_AudioFormatWriter.cpp.
|
protected |
Creates an AudioFormatWriter object.
destStream | the stream to write to - this will be deleted by this object when it is no longer needed |
formatName | the description that will be returned by the getFormatName() method |
sampleRate | the sample rate to use - the base class just stores this value, it doesn't do anything with it |
audioChannelLayout | the channel layout to use for the writer - the base class just stores this value, it doesn't do anything with it |
bitsPerSample | the bit depth of the stream - the base class just stores this value, it doesn't do anything with it |
Definition at line 45 of file juce_AudioFormatWriter.cpp.
|
virtual |
Destructor.
Definition at line 60 of file juce_AudioFormatWriter.cpp.
|
virtual |
Some formats may support a flush operation that makes sure the file is in a valid state before carrying on. If supported, this means that by calling flush periodically when writing data to a large file, then it should still be left in a readable state if your program crashes. It goes without saying that this method must be called from the same thread that's calling write()! If the format supports flushing and the operation succeeds, this returns true.
Definition at line 207 of file juce_AudioFormatWriter.cpp.
|
inlinenoexcept |
Returns the bit-depth of the data being written.
Definition at line 174 of file juce_AudioFormatWriter.h.
Returns a description of what type of format this is.
E.g. "AIFF file"
Definition at line 96 of file juce_AudioFormatWriter.h.
|
inlinenoexcept |
Returns the number of channels being written.
Definition at line 171 of file juce_AudioFormatWriter.h.
Referenced by writeFromAudioSource().
|
inlinenoexcept |
Returns the sample rate being used.
Definition at line 168 of file juce_AudioFormatWriter.h.
|
inlinenoexcept |
Returns true if it's a floating-point format, false if it's fixed-point.
Definition at line 177 of file juce_AudioFormatWriter.h.
Referenced by writeFromAudioReader(), and writeFromFloatArrays().
|
pure virtual |
Writes a set of samples to the audio stream.
Note that if you're trying to write the contents of an AudioBuffer, you can use writeFromAudioSampleBuffer().
samplesToWrite | an array of arrays containing the sample data for each channel to write. This is a zero-terminated array of arrays, and can contain a different number of channels than the actual stream uses, and the writer should do its best to cope with this. If the format is fixed-point, each channel will be formatted as an array of signed integers using the full 32-bit range -0x80000000 to 0x7fffffff, regardless of the source's bit-depth. If it is a floating-point format, you should treat the arrays as arrays of floats, and just cast it to an (int**) to pass it into the method. |
numSamples | the number of samples to write |
Referenced by writeFromAudioReader(), and writeFromFloatArrays().
bool juce::AudioFormatWriter::writeFromAudioReader | ( | AudioFormatReader & | reader, |
int64 | startSample, | ||
int64 | numSamplesToRead | ||
) |
Reads a section of samples from an AudioFormatReader, and writes these to the output.
This will take care of any floating-point conversion that's required to convert between the two formats. It won't deal with sample-rate conversion, though.
If numSamplesToRead < 0, it will write the entire length of the reader.
Definition at line 82 of file juce_AudioFormatWriter.cpp.
bool juce::AudioFormatWriter::writeFromAudioSampleBuffer | ( | const AudioBuffer< float > & | source, |
int | startSample, | ||
int | numSamples | ||
) |
Writes some samples from an AudioBuffer.
Definition at line 188 of file juce_AudioFormatWriter.cpp.
Referenced by writeFromAudioSource().
bool juce::AudioFormatWriter::writeFromAudioSource | ( | AudioSource & | source, |
int | numSamplesToRead, | ||
int | samplesPerBlock = 2048 |
||
) |
Reads some samples from an AudioSource, and writes these to the output.
The source must already have been initialised with the AudioSource::prepareToPlay() method
source | the source to read from |
numSamplesToRead | total number of samples to read and write |
samplesPerBlock | the maximum number of samples to fetch from the source |
Definition at line 129 of file juce_AudioFormatWriter.cpp.
bool juce::AudioFormatWriter::writeFromFloatArrays | ( | const float *const * | channels, |
int | numChannels, | ||
int | numSamples | ||
) |
Writes some samples from a set of float data channels.
Definition at line 151 of file juce_AudioFormatWriter.cpp.
Referenced by writeFromAudioSampleBuffer().
The bit depth of the file.
Definition at line 255 of file juce_AudioFormatWriter.h.
|
protected |
The audio channel layout that the writer should use
Definition at line 261 of file juce_AudioFormatWriter.h.
The number of channels being written to the stream.
Definition at line 252 of file juce_AudioFormatWriter.h.
Referenced by writeFromAudioReader(), and writeFromAudioSampleBuffer().
|
protected |
The output stream for use by subclasses.
Definition at line 264 of file juce_AudioFormatWriter.h.
Referenced by ~AudioFormatWriter().
|
protected |
The sample rate of the stream.
Definition at line 249 of file juce_AudioFormatWriter.h.
|
protected |
True if it's a floating-point format, false if it's fixed-point.
Definition at line 258 of file juce_AudioFormatWriter.h.