Error in converting binary to audio after recording the audio and converting it into binary .......KINDLY HELP!!
3 ビュー (過去 30 日間)
古いコメントを表示
i recorded an audio , converted it into binary and now i have to convert it back into the audio but there is noise in the audio signal which i got in the result , its not the same. what should i do to get the same audio as i recorded ...after converting it back from binary . i even normalised the values... i am new to matlab ... kindly help... i will be very grateful for this . ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/656195/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/656195/image.png)
0 件のコメント
採用された回答
Walter Roberson
2021 年 6 月 17 日
format long g
myRecording = randn(5,1)
wavebinary = dec2bin( typecast( single(myRecording(:)), 'uint16'), 16 ) - '0';
size(wavebinary)
Notice that is N x 16 where N is number of samples times 2 (you are converting myRecording to single no matter whether it is integer or single or double, so the result of the single() will be 32 bits per sample no matter what the original bits per sample. Then you typecast() into two 16 bit halves, and you convert each 16 bit value to binary. Each converted value creates a 16 bit row.
Now look further and see that you construct
sounddata = double(bin2dec( char( reshape( wavebinary, 16, []).'+'0')));
So you would take that 10 x 16 data in which the rows represent the binary of half of one sample, and you would reshape it to be 16 rows... which in this case would give you 10 columns. But that is the wrong bit order. You are taking like
1 : 16
17 : 32
33 : 48
and rearranging it like
[1 17 33 ... 16 32 48 ...]
The flaw here is that when you create wavebinary you should be doing
wavebinary = reshape((dec2bin( typecast( single(myRecording(:)), 'uint16'), 16 ) - '0').', 1, []);
and now with the transpose the bit order would follow the way you are reconstructing.
7 件のコメント
Walter Roberson
2021 年 6 月 18 日
Displaying variables in graphics format takes time and memory. In order to prevent opening a variable from potentially taking a long time and using too much memory, Mathworks made a decision to limit the display t o 524288 elements. I do not know how Mathworks choose that exact number; it is 2^19 entries
Why is the data more than 524288 elements? Well,
format long g
%you are converting elements to single() which is 32 bits each
load handel.mat
handel_samples = numel(y)
required_bits = handel_samples * 32
max_samples_supported = 524288 / 32
max_time_at_8192 = max_samples_supported / Fs
actual_time = handel_samples / Fs
So the handel data is just under 9 seconds long, but at 8192 samples per second, anything over 2 seconds would exceed the Variable Browser limit of 524288 elements.
To observe the data that was encoded into bits, at the command window ask to disp() some subset of it, such as disp(wavbin(1:100)) . Realistically speaking, there is no way that you would truly want to look by hand through all of the 2339616 bits of the data... what would you even look for by eye?
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!