QAM modulation thru Audio

6 visualizzazioni (ultimi 30 giorni)
muath albrady
muath albrady il 13 Apr 2016
Risposto: Walter Roberson il 13 Apr 2016
Hi
below is the code that I try to run but its give error said "Input must contain only finite real nonnegative integers."
in bi2de function.
If someone know how to fix it.
thanks a lot.
[y, fs, nbits]=wavread('project.wav'); % find out sampling rate,
N=length(y);
k=log2(nbits);
n = N;
numSamplesPerSymbol = 1;
rng default % Use default random number generator
dataIn = y;
dataInMatrix = reshape(dataIn,length(dataIn)/k,k);
dataSymbolsIn = bi2de(real(dataInMatrix));
dataMod = qammod(dataSymbolsIn,nbits,0); % Binary coding, phase offset = 0
dataModG = qammod(dataSymbolsIn,nbits,0,'gray'); % Gray coding, phase offset = 0
disp('Press any Key to Listen to Modulated Voice'); pause
soundsc(real(dataMod,dataModG))
EbNo = 10;
snr = EbNo + 10*log10(k) - 10*log10(numSamplesPerSymbol);
receivedSignal = awgn(dataMod,snr,'measured');
receivedSignalG = awgn(dataModG,snr,'measured');
disp('Press any Key to Listen to noise Voice'); pause
soundsc(real(receivedSignal,receivedSignalG))
dataSymbolsOut = qamdemod(receivedSignal,nbits); %dem
dataSymbolsOutG = qamdemod(receivedSignalG,nbits,0,'gray');
disp('Press any Key to Listen to Demodulated Voice'); pause
soundsc(real(dataSymbolsOu,dataSymbolsOutG))
dataOutMatrix = de2bi(dataSymbolsOut,k);
dataOut = dataOutMatrix(:); % Return data in column vector
dataOutMatrixG = de2bi(dataSymbolsOutG,k);
dataOutG = dataOutMatrixG(:); % Return data in column vector
[numErrors,ber] = biterr(dataIn,dataOut);
fprintf('\nThe binary coding bit error rate = %5.2e, based on %d errors\n', ...
ber,numErrors)
[numErrorsG,berG] = biterr(dataIn,dataOutG);
fprintf('\nThe Gray coding bit error rate = %5.2e, based on %d errors\n', ...
berG,numErrorsG)

Risposte (1)

Walter Roberson
Walter Roberson il 13 Apr 2016
Your audio data is floating point and has negative values. You arrange it in rows, and use bi2de() on it. bi2de() is for changing binary rows into decimal numbers, and bi2de() expects its input values to be only 0's and 1's.
The solution is not to use de2bi(), as de2bi() only works on non-negative integers.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by