I have copied the AudioRecordingDemo.h from the JUCE/examples repository, after making minor graphic changes, I compiled on VisualStudio 2022 and the recording process went woderfully. I then set up everything on Linux by using CMake abd VSCode fir editing. The general code of the project had no issues, no errors during compilation and the project opened as expected, but when i openend the recorder on the Project and press the Record Button nothing happened. I tried to rerun the same exact code on VisualStudio 2022 and the recorder button worked. Why can’t I get it to work on Linux, but I manage to do that on VisualStudio2022? I though the problem could have been in these two code snippet
void startRecording(const juce::File& file) {
stop();
if (sampleRate > 0) {
// Create an OutputStream to write to our destination file...
file.deleteFile();
if (auto fileStream = std::unique_ptr<juce::FileOutputStream>(
file.createOutputStream())) {
// Now create a WAV writer object that writes to our output stream...
juce::WavAudioFormat wavFormat;
if (auto writer = wavFormat.createWriterFor(fileStream.get(),
sampleRate, 1, 16, {}, 0)) {
fileStream
.release(); // (passes responsibility for deleting the stream to
// the writer object that is now using it)
/* 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 juce::AudioFormatWriter::ThreadedWriter(
writer, backgroundThread,
32768)); // init of the threaedWriter with the value of the
// writer itself, specific for the WAV
// Reset our recording thumbnail
thumbnail.reset(writer->getNumChannels(), writer->getSampleRate());
nextSampleNum = 0;
// And now, swap over our active writer pointer so that the audio
// callback will start using it..
const juce::ScopedLock sl(writerLock);
activeWriter = threadedWriter.get();
}
}
}
}
Or in this one
void startRecording() {
if (!juce::RuntimePermissions::isGranted(
juce::RuntimePermissions::writeExternalStorage)) {
SafePointer safeThis(this);
juce::RuntimePermissions::request(
juce::RuntimePermissions::writeExternalStorage,
[safeThis](bool granted) mutable {
if (granted) safeThis->startRecording();
});
return;
}
auto parentDir =
juce::File::getSpecialLocation(juce::File::globalApplicationsDirectory);
lastRecording =
parentDir.getNonexistentChildFile("JUCE Demo Audio Recording", ".wav");
recorder.startRecording(lastRecording);
recordButton.setButtonText("Stop");
recordingThumbnail.setDisplayFullThumbnail(false);
}
Or maybe
juce::RuntimePermissions::request(
juce::RuntimePermissions::recordAudio, /* necessary in order to access
the mic*/
[this](bool granted) {
int numInputChannels =
granted ? 2 : 0;
// then select the input channels
audioDeviceManager.initialise(numInputChannels, 2, nullptr, true, {},
nullptr);
});
Can someone help?
