I have to make a spectrum analyzer for .raw 16-bit linear files.
I had a look at this but it works only with .wav files.
Do you know any tutorial/example that can help me create a spectrum analyzer for .raw files?
I have to make a spectrum analyzer for .raw 16-bit linear files.
I had a look at this but it works only with .wav files.
Do you know any tutorial/example that can help me create a spectrum analyzer for .raw files?
The WavFile
class reads a .wav
header to obtain the audio format information from the file. It's simple to modify that class to use a fixed format instead.
If you look at the documentation for the QAudioInput
class, the first code sample given shows how to set up the QAudioInput
to read a raw file with a format slightly different from yours. All you need is to adapt the parameters of the QAudioFormat
instance to match your needs.
I agree with RobbieE in the comments in that what you need is not a different tutorial, but a method to convert RAW files to WAV files. I am also currently working on an audio application in Qt, and the library I use is libsndfile by Erik de Castro Lopo. It can transfer to and from many, many formats, including RAW to WAV.
If the Qt tutorial requires the sound to be loaded as a QSound (which I assume it does), you will first have to convert the RAW file to a WAV file, save it, and then proceed to load the WAV file.