Simulate a complete FM radio station in software — generate a message signal, modulate it onto a carrier wave, visualise the spectrum via FFT, and play the audio back. Built entirely in Scilab.
sound() function plays back the original message signal for validation, closing the loop between digital modulation simulation and perceptible audio output.Live Web Audio API implementation of the radio.sce Scilab code — tune parameters and hear FM modulation in real-time. Caution: High frequency deviation settings may produce loud audio output. Start with low values and increase gradually while monitoring volume.
// ───────────────────────────────────────────────────────── // FM Radio Signal Simulator — Priyanka Gandhi A // Create-the-own-radio-signal | ECE Project 2025 // ───────────────────────────────────────────────────────── // Audio signal parameters fs_audio = 44100; // Sampling rate (44.1 kHz) duration = 5; // 5 seconds t_audio = 0:1/fs_audio:duration; // Generate message signal (500 Hz sine tone) f_audio = 500; audio_signal = sin(2 * %pi * f_audio * t_audio); // FM modulation parameters fs = 200000; // Modulated signal sample rate (200 kHz) fc = 100000; // Carrier frequency (100 kHz) kf = 2 * %pi * 75000; // Frequency deviation (75 kHz) t = 0:1/fs:duration; // Resample audio to modulation sample rate audio_resampled = interp1(t_audio, audio_signal, t, 'linear'); // FM modulation — integrate then modulate integral_audio = cumsum(audio_resampled) / fs; fm_signal = cos(2 * %pi * fc * t + kf * integral_audio); // ── Plot 1: Audio Message Signal ────────────────────────── clf; subplot(3,1,1); plot(t_audio, audio_signal); title("Audio Signal (Message)"); xlabel("Time (s)"); ylabel("Amplitude"); // ── Plot 2: FM Modulated Signal ─────────────────────────── subplot(3,1,2); plot(t, fm_signal); title("FM Modulated Signal"); xlabel("Time (s)"); ylabel("Amplitude"); // ── Plot 3: Frequency Spectrum (FFT) ───────────────────── N = length(fm_signal); f = linspace(-fs/2, fs/2, N); FM_spectrum = abs(fftshift(fft(fm_signal)) / N); subplot(3,1,3); plot(f, FM_spectrum); title("FM Signal Spectrum"); xlabel("Frequency (Hz)"); ylabel("Magnitude"); // ── Audio Playback ──────────────────────────────────────── sound(audio_signal, fs_audio); // Play original message
interp1(), aligning its time axis with the higher-rate modulated carrier signal.cumsum() / fs computes this efficiently.cos(2π·fc·t + kf·∫audio). The frequency deviation constant kf = 2π×75000 determines how far the carrier shifts per unit of message amplitude.sound() function. This confirms the audio content that would be recovered after FM demodulation at a real receiver.Full Scilab script, documentation, and signal analysis outputs available in the public repository.