Randy Yates
2007-03-04 03:09:07 UTC
[NOTE: The following was emailed to ***@octave.org]
Octave normalizes the integers associated with wave files to 32767,
while matlab normalizes them to 32768. This means that the domain
of the signal vector x in octave is not [-1,+1] but
[-1 - 32768/32767, +1],
while the domain in matlab is
[-1, +32767/32768].
The attached zip file contains two files
1. a specially-generated .wav file, ramp.wav, that has the sequence
-32768 to +32767 repeated once;
2. a matlab script wavwritetest.m
If you extract both of these into a directory, then execute the script
wavwritetest in octave, you get this:
octave:1> wavwritetest
Input file 'ramp.wav' is RIFF format:
Total length = 262180 bytes
Number of channels = 1
Sampling rate = 48000 Hz
Data length = 131072 samples
yoctave =
-32768
-32767
-32766
-32765
-32764
-32763
-32762
-32761
-32760
-32759
ymatlab =
-32769.0000305185
-32768.0000000000
-32766.9999694815
-32765.9999389630
-32764.9999084445
-32763.9998779260
-32762.9998474075
-32761.9998168889
-32760.9997863704
-32759.9997558519
1.0e+004 *
-3.27670000000000
-3.27660000305176
-3.27650000610352
-3.27640000915527
-3.27630001220703
-3.27620001525879
-3.27610001831055
-3.27600002136230
-3.27590002441406
-3.27580002746582
ymatlab =
-32768
-32767
-32766
-32765
-32764
-32763
-32762
-32761
-32760
-32759
This illustrates the problem.
Octave normalizes the integers associated with wave files to 32767,
while matlab normalizes them to 32768. This means that the domain
of the signal vector x in octave is not [-1,+1] but
[-1 - 32768/32767, +1],
while the domain in matlab is
[-1, +32767/32768].
The attached zip file contains two files
1. a specially-generated .wav file, ramp.wav, that has the sequence
-32768 to +32767 repeated once;
2. a matlab script wavwritetest.m
If you extract both of these into a directory, then execute the script
wavwritetest in octave, you get this:
octave:1> wavwritetest
Input file 'ramp.wav' is RIFF format:
Total length = 262180 bytes
Number of channels = 1
Sampling rate = 48000 Hz
Data length = 131072 samples
yoctave =
-32768
-32767
-32766
-32765
-32764
-32763
-32762
-32761
-32760
-32759
ymatlab =
-32769.0000305185
-32768.0000000000
-32766.9999694815
-32765.9999389630
-32764.9999084445
-32763.9998779260
-32762.9998474075
-32761.9998168889
-32760.9997863704
-32759.9997558519
wavwritetest
yoctave =1.0e+004 *
-3.27670000000000
-3.27660000305176
-3.27650000610352
-3.27640000915527
-3.27630001220703
-3.27620001525879
-3.27610001831055
-3.27600002136230
-3.27590002441406
-3.27580002746582
ymatlab =
-32768
-32767
-32766
-32765
-32764
-32763
-32762
-32761
-32760
-32759
This illustrates the problem.
--
% Randy Yates % "She tells me that she likes me very much,
%% Fuquay-Varina, NC % but when I try to touch, she makes it
%%% 919-577-9882 % all too clear."
%%%% <***@ieee.org> % 'Yours Truly, 2095', *Time*, ELO
http://home.earthlink.net/~yatescr
% Randy Yates % "She tells me that she likes me very much,
%% Fuquay-Varina, NC % but when I try to touch, she makes it
%%% 919-577-9882 % all too clear."
%%%% <***@ieee.org> % 'Yours Truly, 2095', *Time*, ELO
http://home.earthlink.net/~yatescr