%-- SEND.M: a 256-QAM transmitter for ECE4601, Fall 2003 PROJECT ------------% Rsample = 22050; % computer sample period, in seconds Ltrain = 1000; % number of training symbols to transmit f0 = 6000; % carrier frequency in Hz q = 8; % q = number of samples per baud; baud rate = Rsample/q. [re,im] = meshgrid(-15:2:15,-15:2:15); alphabet = re(:) + 1i*im(:); image = imread('mystery.jpg'); Lmsg = prod(size(image)); bits = dec2bin(double(image(:)),8)-'0'; rand('state',0); scramble = round(rand(Lmsg,8)); bits = rem(bits + scramble, 2); a = alphabet(1 + bits*2.^(0:7).'); rand('state',0); train = alphabet(ceil(256*rand(Ltrain,1))); chips = [[train.' a.']; zeros(q-1,Ltrain+Lmsg)]; % insert q-1 0's btwn ea symbl g = sinc((-20*q : 20*q) / q); s_tilde = conv(g, chips(:)); vco = exp(2i*pi*f0*(1:length(s_tilde)).'/Rsample); s = real(s_tilde .* vco); s = s/max(abs(s)); input('Start recording at receiver, then hit return to begin transmission ... ','s'); sound(s, Rsample) disp('Done. Stop recording at receiver.');