echo on
%
% Sample program for MATCOM: create and play a Bell103 modem sound
%
% (c) Copyright Yaron Keren 1995-1996
%
% Change to nbits=3000 to create a longer sound.
%
echo off

f_mark=2225;
f_space=2025;
bps=300;
fs=8192;
nbits=300;

samples_bit=round(fs/bps);
v=(0:(samples_bit-1))/fs*2*pi;
s_mark=sin(v*f_mark);
s_space=sin(v*f_space);

tx=zeros(1,nbits*samples_bit);
v=1;
state=0;
while v<nbits*samples_bit
  if rand>.5
    tx(v:(v+samples_bit-1))=s_mark;
  else
    tx(v:(v+samples_bit-1))=s_space;
  end
  v=v+samples_bit;
end
sound(tx,fs)
