MATLAB Answers

How can represent a recorded speech signal(.wav format) as a binary matrix?

2 views (last 30 days)
A audio(in wav format) is read to variable 'p' using wavread().The sample values p contain vary between -1 and +1.what i exactly need is a binary row matrix which represent that wav file as 0's and 1's.
And how can i convert that binary row matrix back to the same audio?


Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 22 Feb 2017
[data, fs] = wavread(FileName, 'native');
Now your data is probably integers or convertible to integers. After that you use dec2bin() and transpose and reshape.


Show 7 older comments
Walter Roberson
Walter Roberson on 28 Feb 2017
If class(data) shows up as int16 rather than uint16, then
data_u16 = typecast(data, 'uint16');
row = reshape( (dec2bin(data_u16, 16) - '0').', 1, [] );
ANJANA KRISHNAN A on 28 Feb 2017
restoring original values :
recovered16 = uint16( bin2dec( char( reshape(row, 16, []).' + '0' ) ) );
recovered = typecast(recovered16, class(data));

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Translated by