I want to convert a .wav file to binary,modulate it,transmit,demodulate and convert the binary back to .wav file.But I am not able to write binary data back to wav file.
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
NEEMA RAJ
le 25 Sep 2018
Commenté : NEEMA RAJ
le 26 Sep 2018
wavdata = audioread('roja.wav');
wavbinary = dec2bin( typecast( single(wavdata(:)), 'uint8'), 8 ) - '0';
orig_size = size(wavdata);
wavb1=uint8(wavbinary);
w1=reshape(wavb1,15486976,1);
xmod=qammod(w1,16,0,'gray');
y1=awgn(xmod,10);
rdmod=qamdemod(y1,16,0,'gray');
% rdmod1=reshape(rdmod,1935872,8);
rdmod2=uint8(rdmod);
data = uint8(bin2dec( char( reshape( rdmod2, 8,[]).'+'0')));
audiowrite(data, 'rec_roja.wav',8000)
Error using bin2dec (line 55)
Binary string may consist only of characters 0 and 1
Error in wavb (line 14)
data = uint8(bin2dec( char( reshape( rdmod2, 8,[]).'+'0')));
also waveread is not working in r2016
6 commentaires
Réponse acceptée
Walter Roberson
le 26 Sep 2018
Which release are you using? R2016a was the last release that accepted by initial phase (0) and symbol order (gray) for qammod, with R2016b being the last release that permitted initial phase.
In current releases, the default output for qamdemod is integer, and the integers can be anywhere from 0 to M-1 where M is the order you passed (which is 16 in your case). Current releases have an option 'outputtype', 'bit'
But when you qammod(), in current releases the default input is integer as well, and you would need 'inputtype', 'bit' to specify bits.
Which is to say, you are currently telling qammod that your inputs are integers in the range 0 to 15, but it just happens that none of them are anything other than 0 or 1. You then add white noise and decode. But the white noise might happen to knock some of the symbols into a different constellation, so you when you qamdemod you can get back integers other than what you put in.
If you were using modern MATLAB, you would
xmod=qammod(w1, 16, 'gray', 'inputtype', 'bit');
and
rdmod=qamdemod(y1, 16, 'gray', 'outputtype', 'bit');
and the problem with bin2dec would no longer occur.
8 commentaires
Walter Roberson
le 26 Sep 2018
appdata = getenv('APPDATA');
if isempty(appdata)
error('No APPDATA?? Either not a PC or badly configured!');
end
mapp = fullfile(appdata, 'MATLAB');
if ~isdir(mapp)
try
mkdir(mapp);
catch ME
error('Failed to create directory "%s"', mapp);
end
end
mq = fullfile(mapp, 'Q420697');
if ~isdir(mq)
try
mkdir(mq);
catch ME
error('Failed to create directory "%s"', mq);
end
end
outfile = fullfile(mq, 'rec_roja1.wav');
audiowrite(outfile, data, 8000);
fprintf('Your file was saved to: "%s"\n', outfile);
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Eye Tracking dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!