Last active
December 8, 2017 05:16
-
-
Save AkiyukiOkayasu/1f1e7633df24d464f82a232fa80d0202 to your computer and use it in GitHub Desktop.
JUCEでWavファイルを書き出す
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
void MainContentComponent::exportWav(AudioSampleBuffer &bufferToWrite, String fileName) | |
{ | |
const double sampleRate = deviceManager.getCurrentAudioDevice()->getCurrentSampleRate();//現在のサンプルレートを取得 | |
const int numChannel = bufferToWrite.getNumChannels(); | |
const int bitDepth = 32;//32bitFloat | |
File file(File::getSpecialLocation(File::SpecialLocationType::userDesktopDirectory).getChildFile(fileName)); | |
file.deleteFile(); | |
ScopedPointer<FileOutputStream> fos(file.createOutputStream()); | |
WavAudioFormat wavFormat; | |
ScopedPointer<AudioFormatWriter> writer(wavFormat.createWriterFor(fos, sampleRate, numChannel, bitDepth, StringPairArray(), 0)); | |
fos.release(); | |
writer->writeFromAudioSampleBuffer(bufferToWrite, 0, bufferToWrite.getNumSamples()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment