Hello, I am trying to do an application with the purpose of being able to record phrases and have them automatically saved in a chosen directory as wav files. For this I am trying to use the QAudioRecorder class. When I hit the record button I speak something into the microphone and .wav file gets saved into the directory that I chose with the name that I want but when I playback the file it is just noise. I don’t think I am using the recording class properly.
What I have so far is :
void RecordingWidget::startRecording()
{
if(audioRecorder->state() == QMediaRecorder::StoppedState)
{
//Set Audio Input
audioRecorder->setAudioInput(audioRecorder->defaultAudioInput());
// Sets Output location where to store the file
if(!m_outputLocationSet)
setOutputLocation();
// Set recording Settings
QAudioEncoderSettings settings;
settings.setCodec("audio/amr"); // Not sure what to put here
settings.setSampleRate(16000);
settings.setBitRate(32);
settings.setQuality(QMultimedia::HighQuality);
settings.setEncodingMode(QMultimedia::ConstantQualityEncoding);
audioRecorder->setEncodingSettings(settings);
audioRecorder->record();
}
else {
stopRecording();
}
}
void RecordingWidget::startRecording()
{
if(audioRecorder->state() == QMediaRecorder::StoppedState)
{
//Set Audio Input
audioRecorder->setAudioInput(audioRecorder->defaultAudioInput());
// Sets Output location where to store the file
if(!m_outputLocationSet)
setOutputLocation();
// Set recording Settings
QAudioEncoderSettings settings;
settings.setCodec("audio/amr"); // Not sure what to put here
settings.setSampleRate(16000);
settings.setBitRate(32);
settings.setQuality(QMultimedia::HighQuality);
settings.setEncodingMode(QMultimedia::ConstantQualityEncoding);
audioRecorder->setEncodingSettings(settings);
audioRecorder->record();
}
else {
stopRecording();
}
}
To copy to clipboard, switch view to plain text mode
Any guidance on how to correctly set this up greatly appreciated! Thanks.
Bookmarks