read single channel of multi-channel wav file

21 views (last 30 days)
Hi there. I have 2- and 4-channel wav files that I need to read in to Matlab, but I only need channel 1. The files are too large to load with a single wavread. I could load in chunks, but that will require a lot of changes to the rest of the code to only deal with partial data. And this is something that is supposed to be done in a couple of days... in my spare time...
I've been searching around for awhile now, hoping that there is a simple script that someone else has come up with to read a single channel from a multi-channel wav. But so far no luck. I thought I'd ask the question, in case someone else has come across something appropriate and can steer me in the right direction.
Suggestions would be very much appreciated. Thanks so much for your help.
Michael

Accepted Answer

Walter Roberson
Walter Roberson on 16 Jan 2013
There is no supplied method to do this.
You can write your own routine and would not need to make many changes to your code. Call it wavread1.m or something like that. Make it a wrapper that loops reading chunks of data and throwing away the extra channels, until you get to the end.
Or if you need higher efficiency, then you will find that wavread is MATLAB source; you can trace through the parts of it that are actually used for your files, and edit those parts to not read in the extra channels (if that makes sens for the chunk) or to throw away the extra (if necessary for that kind of chunk.)
  2 Comments
Michael
Michael on 16 Jan 2013
Thanks for the quick response Walter. I saw that thread, but was hoping someone else had already worked out a function to do it.
Your suggestion is great. I kept thinking that if I only read in a portion of the wav, I would need to put my entire code in a giant loop and make things much more complex. Instead, I'll just loop through the wavread function and drop the channels I don't need right away, and then continue with the rest of the code. Thanks for the idea.
Michael
Walter Roberson
Walter Roberson on 16 Jan 2013
And if you create a function that does that for you, the code change would be easy.

Sign in to comment.

More Answers (0)

Categories

Find more on Audio I/O and Waveform Generation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!