How do I read data as it is in a wave file, without any normalizations.

6 views (last 30 days)
I use a data analysis software via which I export measured data like vibration, pressure, force, etc into wav files. I wish to read these files in MATLAB. The files consist of floating point data, whose range goes beyond -1 to +1. However, wavread, by default normalizes it to -1 to +1, or to –32768 to +32767, if I use the 'native' option. What can I do to output the data in its original form? Thanks.

Answers (1)

Star Strider
Star Strider on 20 Dec 2014
The wavread function normalises to [-1,+1], but according to the documentation audioread does not. At least that is my impression.
From the documentation for audioread (under ‘Output Arguments’ -> y — Audio data):
  • Note: Where y is single or double and the BitsPerSample is 32 or 64, values in y might exceed −1.0 or +1.0.
I suggest you save your data in a .mat file instead of a sound file if at all possible, and as added security, save the maximum and minimum for your data so you can re-scale it if necessary.
  2 Comments
Chaitanya Bhat
Chaitanya Bhat on 20 Dec 2014
Thanks. Unfortunately I have Matlab 2010/12 at my disposal. audioread appears to be available in 2013/14 versions. The software I use does not directly export mat files, and the most easily readable files I can generate are wav files. Of course, if I can save the max/min values, then I can do the scaling even with wavread. However I will be exporting and processing dozens of files together, and it will become impractical to document the max/mins for each file and then rescale the data later in MATLAB. Are there any other ideas?
Star Strider
Star Strider on 20 Dec 2014
The limitations of wavwrite limits your ability to get around the scaling problem. There doesn’t seem to be a way to attach meta-data to a wavwrite file that would allow you to include the scaling data.
My only suggestion is to save each .wav file with the scaling data together in a .mat file. That way, everything is in one file and you don’t lose anything. With identical formats for each .mat file, you can likely automate the entire subsequent reading and processing and not have to intervene further.
I don’t know what you’re doing or the other software you’re using, so I cannot suggest anything more specific.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!