mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
AudioRecordingDemo: Use the new AudioFormat::createWriterFor overload
This commit is contained in:
parent
9feee44070
commit
eb7de7f15b
1 changed files with 9 additions and 5 deletions
|
|
@ -83,21 +83,25 @@ public:
|
|||
// Create an OutputStream to write to our destination file...
|
||||
file.deleteFile();
|
||||
|
||||
if (auto fileStream = std::unique_ptr<FileOutputStream> (file.createOutputStream()))
|
||||
if (std::unique_ptr<OutputStream> fileStream { file.createOutputStream() })
|
||||
{
|
||||
// Now create a WAV writer object that writes to our output stream...
|
||||
WavAudioFormat wavFormat;
|
||||
|
||||
if (auto writer = wavFormat.createWriterFor (fileStream.get(), sampleRate, 1, 16, {}, 0))
|
||||
using Opts = AudioFormatWriterOptions;
|
||||
|
||||
if (auto writer = wavFormat.createWriterFor (fileStream, Opts{}.withSampleRate (sampleRate)
|
||||
.withNumChannels (1)
|
||||
.withBitsPerSample (16)))
|
||||
{
|
||||
fileStream.release(); // (passes responsibility for deleting the stream to the writer object that is now using it)
|
||||
auto* writerPtr = writer.get();
|
||||
|
||||
// Now we'll create one of these helper objects which will act as a FIFO buffer, and will
|
||||
// write the data to disk on our background thread.
|
||||
threadedWriter.reset (new AudioFormatWriter::ThreadedWriter (writer, backgroundThread, 32768));
|
||||
threadedWriter.reset (new AudioFormatWriter::ThreadedWriter (writer.release(), backgroundThread, 32768));
|
||||
|
||||
// Reset our recording thumbnail
|
||||
thumbnail.reset (writer->getNumChannels(), writer->getSampleRate());
|
||||
thumbnail.reset (writerPtr->getNumChannels(), writerPtr->getSampleRate());
|
||||
nextSampleNum = 0;
|
||||
|
||||
// And now, swap over our active writer pointer so that the audio callback will start using it..
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue