wavwrite() and wavread() on stereo signals incosistent

View: New views
3 Messages — Rating Filter:   Alert me  

wavwrite() and wavread() on stereo signals incosistent

by h_ayguen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


writing a complex (stereo) signal and reading it again,
results in negated right (2nd) channel:

% generate complex sine
N = 1024;
F = zeros( 1, N );
F(2) = 1;
s = ifft( F );
s = s / max( [ real(s) imag(s) ] );
% write as stereo file
t = [ real(s') , imag(s') ];
wavwrite( t, 'test.wav' );
% read stereo file
u = wavread( 'test.wav' );
v = u( : , 1 ) + i * u( : , 2 );
%
% result: imag(s) == - imag(v)

wavwrite() and wavread() on stereo signals incosistent

by John W. Eaton-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On  6-Sep-2009, h_ayguen wrote:

| % generate complex sine
| N = 1024;
| F = zeros( 1, N );
| F(2) = 1;
| s = ifft( F );
| s = s / max( [ real(s) imag(s) ] );
| % write as stereo file
| t = [ real(s') , imag(s') ];

This line is your problem.  Note the difference between s' and s.'.

jwe
_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave

Re: wavwrite() and wavread() on stereo signals incosistent

by h_ayguen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


changing that line to
t = [ real(s)' , imag(s)' ];
solves the problem - of course.