AF Two Tone Generator を Scilab で作る [Simulation]
SDR を simulation するのに Scilab の勉強を始めました。 まず、AF Two Tone Generator を Scilab で作ってみました。 (グラフを subplot() 関数を使って、3つに分けました)
〔出来た波形〕
上から順に 700Hz、1700Hz、Two Tone 信号です。
このデータを wav ファイルに保存するか、PCから音データとして再生すれば、PCを使った AF Two Tone Generator の完成です。
〔プログラム〕
// AF signal
// 700Hz + 1700Hz
// Sampling frequency
// 128kHz
// simulation time
// T sec
afreq1 = 700;
afreq2 = 1700;
sf = 128000;
a1 = 0.1;
a2 = 0.1;
T = 1/sf; // calculate sampling period
while(1)
printf('\n');
st = input('input simulation time [Sec] ?? (E is exit)');
if st == ['E'] then break end;
// calculate the number of sampling points
sp = st * sf;
k = 1:sp;
// Two Tone AF signal
af1 = a1*sin(2*%pi*afreq1*k*T);
af2 = a2*sin(2*%pi*afreq2*k*T);
af = af1 + af2;
subplot(3,1,1);
plot(af1, 'r');
subplot(3,1,2);
plot(af2, 'g');
subplot(3,1,3);
plot(af, 'b'); // playsnd(af);
end
〔出来た波形〕
上から順に 700Hz、1700Hz、Two Tone 信号です。
このデータを wav ファイルに保存するか、PCから音データとして再生すれば、PCを使った AF Two Tone Generator の完成です。
〔プログラム〕
// AF signal
// 700Hz + 1700Hz
// Sampling frequency
// 128kHz
// simulation time
// T sec
afreq1 = 700;
afreq2 = 1700;
sf = 128000;
a1 = 0.1;
a2 = 0.1;
T = 1/sf; // calculate sampling period
while(1)
printf('\n');
st = input('input simulation time [Sec] ?? (E is exit)');
if st == ['E'] then break end;
// calculate the number of sampling points
sp = st * sf;
k = 1:sp;
// Two Tone AF signal
af1 = a1*sin(2*%pi*afreq1*k*T);
af2 = a2*sin(2*%pi*afreq2*k*T);
af = af1 + af2;
subplot(3,1,1);
plot(af1, 'r');
subplot(3,1,2);
plot(af2, 'g');
subplot(3,1,3);
plot(af, 'b'); // playsnd(af);
end
コメント 0