How to to Audio Recording from microphone to wav file in Qt
i am trying to record audio from microphone to wave file.......
i did it properly this is my code what i did.....
settings.setBitRate(ui->lineEdit_2->text().toInt()); settings.setQuality(QMultimedia::HighQuality); settings.setEncodingMode(QMultimedia::ConstantQualityEncoding); audioRecorder->setEncodingSettings(settings, QVideoEncoderSettings(),"audio/x-wav"); audioRecorder->setContainerFormat("wav"); audioRecorder->setOutputLocation(QUrl("C:/Users/Kaptron3/Desktop/testprabhat5.wav")); audioRecorder->record();
but when i did add this in matlab i am getting error that "invalid wave file ..incorrect chunk size information in wave file."
Open Qt Creator -> Welcome -> Examples, and search for "Audio Recorder Example". Are you able to use that to produce a wav file?
hey JKSH i am able to create wav file but when i tried to add this file in matlab am getting error that invalid wav file..incorrevt chunk size.......
my code is given below:
@QAudioEncoderSettings settings; settings.setCodec(“audio/pcm”); settings.setSampleRate(ui->lineEdit->text().toInt());
settings.setBitRate(ui->lineEdit_2->text().toInt()); settings.setQuality(QMultimedia::HighQuality); settings.setEncodingMode(QMultimedia::ConstantQualityEncoding); audioRecorder->setEncodingSettings(settings, QVideoEncoderSettings(),“audio/x-wav”); audioRecorder->setContainerFormat(“wav”); audioRecorder->setOutputLocation(QUrl(“C:/Users/Kaptron3/Desktop/testprabhat5.wav”)); audioRecorder->record();
Yes I saw your code in your previous post.
However, I meant: Are you able to produce a .wav file using the Audio Recorder Example in Qt Creator?
Also, what happens if you open the .wav file in Windows Media Player?
hmmm i am able to produce a .wav file and i am also able to play this file in media player properly.........but when i added this file in matlab it showing inavalid wav file .....and invalid chunk size.....
Then I don't think there's anything wrong with the .wav file.
Are you sure your MATLAB code is correct? See http://www.mathworks.com.au/matlabcentral/newsreader/view_thread/108000
ya i am sure i used wavread command in matlab through which we read the wav file in matlab........i am able to read other wave file from this command.....
when i created .amr file from qt and changed this file in .wav through internet i can read this file in matlab.......so i think there is something chunk size issue ...
Can you upload a sample .wav file somewhere?
hey i have no idea how to upload my .wav file here.....
tell me your mail id ...i can send my .wav file on your mail id.
thanks for ur reply...
Sorry for the delay. You can upload your file to a file hosting site (Dropbox, Google Drive, Microsoft OneDrive, etc.) and post the link here.
Hey, i did recording from microphone using qt in .wav file.
i am able to play this file in media playe.but when i added this file in matlab for wavread this is giving a error invalid chunk size …..
and throgh matlab code i fixed the chunk size of my .wav file .
the matlab code is given below….
function wavchunksizefix( test13)
d = dir(‘test13.wav’);
fileSize = d.bytes
but i want to fix this problem throgh qt code.
plzzz give me some hint.
I downloaded your .wav file and followed the diagram at https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
Your file size is 956132 bytes.
Inside the file,
- Byte 4: ChunkSize = 956124 (= fileSize-8)
- Byte 40: Subchunk2Size = 956080
ChunkSize is correct, but Subchunk2Size is wrong (it should be 956088).
So you are right, the WAVE file that QMediaRecorder produced has a wrong value. This is a bug, but I don't know where the bug came from. Qt uses the Windows multimedia backend to record audio.
Can you check if you can produce a "good" wave file, using Windows Sound Recorder? (If you use Windows 7 or 8, follow this: http://social.technet.microsoft.com/Forums/windows/en-US/bd9563fe-a3ec-49c3-8b28-a2f8ed1082eb/record-wav-audio )
If Sound Recorder works, then it's likely to be a Qt bug. Please submit a bug report to http://bugreports.qt-project.org/