tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_AudioFileWriter.h
Go to the documentation of this file.
1 /*
2 ,--. ,--. ,--. ,--.
3 ,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2024
4 '-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
5 | | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
6 `---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
7
8 Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
9*/
10
11namespace tracktion { inline namespace engine
12{
13
14//==============================================================================
22{
23public:
24 AudioFileWriter (const AudioFile& file,
25 juce::AudioFormat* formatToUse,
26 int numChannels,
27 double sampleRate,
28 int bitsPerSample,
29 const juce::StringPairArray& metadata,
30 int quality);
31
34
35 //==============================================================================
37 bool isOpen() const noexcept;
38
40 double getSampleRate() const noexcept;
41
43 int getNumChannels() const noexcept;
44
45 //==============================================================================
47 bool appendBuffer (juce::AudioBuffer<float>& buffer, int numSamples);
48
50 bool appendBuffer (const int** buffer, int numSamples);
51
53 bool writeFromAudioReader (juce::AudioFormatReader&, SampleCount startSample, SampleCount numSamples);
54
56 void closeForWriting();
57
58 AudioFile file;
59
60private:
61 int samplesUntilFlush;
63 juce::CriticalSection writerLock;
64};
65
66}} // namespace tracktion { inline namespace engine
Smart wrapper for writing to an audio file.
double getSampleRate() const noexcept
Returns the sample rate of the writer, should only be called on an open writer.
~AudioFileWriter()
Destructor, calls closeForWriting.
bool appendBuffer(juce::AudioBuffer< float > &buffer, int numSamples)
Appends an AudioBuffer to the file.
int getNumChannels() const noexcept
Returns the num channels of the writer, should only be called on an open writer.
bool writeFromAudioReader(juce::AudioFormatReader &, SampleCount startSample, SampleCount numSamples)
Appends a block of samples to the file from an audio format reader.
bool isOpen() const noexcept
Returns true if the file is open and ready to write to.
void closeForWriting()
Deletes the writer and releases the file handle.