Created
March 22, 2023 14:41
-
-
Save Xenakios/e8cdba51430a14b0c1e3565f8726ecfc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int bufsize = m_aman.getCurrentAudioDevice()->getCurrentBufferSizeSamples(); | |
// need to stop the realtime playback so we don't get conflicts while offline rendering | |
m_aman.removeAudioCallback(&m_aeng); | |
m_aeng.seekToSeconds(0.0); | |
juce::WavAudioFormat wavformat; | |
juce::File f = juce::File::getSpecialLocation(juce::File::userDocumentsDirectory); | |
auto outfile = f.getNonexistentChildFile("upic_renders/upic_out",".wav"); | |
auto ostream = outfile.createOutputStream(); | |
auto writer = wavformat.createWriterFor(ostream.release(),m_aeng.m_sr,2,32,{},0); | |
bool was_playing = m_aeng.getPlayState(); | |
if (writer) | |
{ | |
if (m_aeng.getPlayState()==false) | |
m_aeng.setPlayState(true); | |
juce::AudioBuffer<float> procbuf(2,bufsize); | |
procbuf.clear(); | |
double outlen = m_aeng.getScoreLength(); | |
bool m_was_looping = m_aeng.m_transport_loop; | |
m_aeng.m_transport_loop = false; | |
while (m_aeng.m_phase<m_aeng.getScoreLength()*m_aeng.m_sr) | |
{ | |
m_aeng.audioDeviceIOCallbackWithContext(nullptr,0,procbuf.getArrayOfWritePointers(),2,bufsize,{}); | |
writer->writeFromAudioSampleBuffer(procbuf,0,bufsize); | |
} | |
m_aeng.m_transport_loop = m_was_looping; | |
m_aeng.setPlayState(false); | |
delete writer; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment