how to modify the MATLAB's built in functions "wavread" and "wavwrite"?

Discussion in 'Programmer's Corner' started by annda, Aug 25, 2008.

  1. annda

    Thread Starter New Member

    Jul 2, 2008
    Does anyone know how to modify the wavread and/or wavwrite function in MATLAB so we can work with 16 bits wav files without being clipped if the amplitude range is outside [-1,1] ?

    Supposed that we read an audio file (*.wav) using wavread..
    [audio,fs,nbits]=wavread('audio.wav'); % nbits=16
    then we modify the "audio" data so that its amplitude is no longer between [-1,1]..
    then we write it to wav files using wavwrite,,

    when I use wavwrite function, with 8 or16 bits audio wav file, the data with amplitude outside the range will be clipped..

    how can we work with 16 bits audio wav files, modify it,and write it to wav files and my data still intact,, not being clipped ?

    thanks before for ur advices..
  2. Dave

    Retired Moderator

    Nov 17, 2003
    I don't currently have access to Matlab so let me have a look at the wavread.m and wavwrite.m fucntions tomorrow. A lot depends on whether the amplitude conditioning for the wav-functions is written in m-code or compiled to mex-files.

  3. annda

    Thread Starter New Member

    Jul 2, 2008
  4. blazedaces

    Active Member

    Jul 24, 2008
    While it's literally possible to modify these actual programs, what exactly is the point? Why not just write your own m files for such a task? It seems like a waste of time and effort, along with possible problems rising up during the process, to actually locate the actual m files and change them. Have you looked at the help information for these programs? Perhaps they explain the specific reason why they "clip" or filter out the data with amplitude outside a specific range (do you mean amplitude of the wave or the bits?)? Go to matlab help, do search and locate the information provided on these functions. If you typed "help wavwrite" it would output nearly all the same information, but I like the help window because it provides examples as well. Good luck, -blazed Edit: I don't know why, but no matter how many times I edit my message, it removes all line breaks and puts all of the stuff I write into one hard-to-read paragraph... Perhaps it's because I'm using linux at the moment?