How to generate a multitone noise for a notch filter in scilab

Thread Starter

GRVEN21

Joined Jul 21, 2025
9
I am designing a notch filter that removes unwanted frequencies at 60, 120 and 180 Hz for a VoIP call sampled at 180000 kHz. Here is my filter implemented in Scilab.

Code:
clc; clear; close;

fs = 16000;
F  = [60, 120, 180];
BW = 3;
Nsec = length(F);

bmat  = zeros(Nsec,3);
amat  = zeros(Nsec,3);
rvec  = zeros(1,Nsec);
w0vec = zeros(1,Nsec);

for k = 1:Nsec
    f0 = F(k);
    w0 = 2*%pi*f0/fs;
    r  = exp(-%pi * BW / fs);
    b  = [1, -2*cos(w0), 1];
    a  = [1, -2*r*cos(w0), r^2];
    bmat(k,:) = b;
    amat(k,:) = a;
    rvec(k)   = r;
    w0vec(k)  = w0;
end

mprintf("Frecuencias: %s Hz\n\n", string(F));
for k = 1:Nsec
    mprintf("Seccion %d: f0=%3d Hz\n", k, F(k));
    mprintf(" b (float) = [ %.10f, %.10f, %.10f ]\n", bmat(k,1), bmat(k,2), bmat(k,3));
    mprintf(" a (float) = [ %.10f, %.10f, %.10f ]\n\n", amat(k,1), amat(k,2), amat(k,3));
end

z = %z;
Hz_all = 1;
for k = 1:Nsec
    w0 = w0vec(k);
    z1 = exp(%i*w0);
    z2 = exp(-%i*w0);
    p1 = rvec(k)*exp(%i*w0);
    p2 = rvec(k)*exp(-%i*w0);
    num1 = real((z - z1)*(z - z2));
    den1 = real((z - p1)*(z - p2));
    Hk = num1 ./ den1;
    Hz_all = Hz_all .* Hk;
end

[h1, fr] = frmag(Hz_all, 2048);
freqHz = fr * fs;
magdB = 20*log10(h1);

figure;
plot2d(freqHz, magdB);
xtitle("Magnitude response (all notches cascaded)", "Frequency (Hz)", "Magnitude (dB)");
xgrid();

figure;
for k = 1:Nsec
    w0 = w0vec(k);
    z1 = exp(%i*w0);
    z2 = exp(-%i*w0);
    p1 = rvec(k)*exp(%i*w0);
    p2 = rvec(k)*exp(-%i*w0);
    Hk = real((z - z1).*(z - z2)) ./ real((z - p1).*(z - p2));
    [hk, frk] = frmag(Hk, 1024);
    subplot(Nsec,1,k);
    plot2d(frk*fs, 20*log10(hk));
    xtitle("Seccion "+string(k)+" Magnitude (dB)", "Freq (Hz)", "dB");
    xgrid();
end
and the floating-point coefficients I obtained.

Code:
Frecuencies: 60 Hz

Section 1: f0= 60 Hz
 b (float) = [ 1.0000000000, -1.9994448604, 1.0000000000 ]
 a (float) = [ 1.0000000000, -1.9982674370, 0.9988225964 ]

Section 2: f0=120 Hz
 b (float) = [ 1.0000000000, -1.9977797499, 1.0000000000 ]
 a (float) = [ 1.0000000000, -1.9966033070, 0.9988225964 ]

Section 3: f0=180 Hz
 b (float) = [ 1.0000000000, -1.9950055928, 1.0000000000 ]
 a (float) = [ 1.0000000000, -1.9938307836, 0.9988225964 ]

For testing, I want to generate a simple multitone test noise and visualize it with an FFT. Since I am still a student, I would like to know what characteristics the multitone noise should have to realistically simulate a VoIP call, and which practical aspects I should consider when generating that test noise.
 

Thread Starter

GRVEN21

Joined Jul 21, 2025
9
Why are you sampling a VoIP call at 180 MHz?
I'm getting the coefficients for every notch with respect to sampling frecuency. I've been told that greater frecuencies higher than those I specified can cause degradation of audio quality.
 

WBahn

Joined Mar 31, 2012
32,702
I'm getting the coefficients for every notch with respect to sampling frecuency. I've been told that greater frecuencies higher than those I specified can cause degradation of audio quality.
I'm asking why you are sampling at 180 MHz. Typical VoIP sampling rates are typically 8 kHz (i.e., 0.008 MHz), though some codecs go as high as 48 kHz. You are sampling more that twenty-two thousand times faster than most codecs. Why?
 

Thread Starter

GRVEN21

Joined Jul 21, 2025
9
I'm asking why you are sampling at 180 MHz. Typical VoIP sampling rates are typically 8 kHz (i.e., 0.008 MHz), though some codecs go as high as 48 kHz. You are sampling more that twenty-two thousand times faster than most codecs. Why?
Well in the specifications, I've been said that sampling frecuency for VoIP call are 16000 Khz, but I didnt know that I was sampling 180 Mz. It's just I dont know the notations in scilab. O'm Sorry. In which part of the code is the sampling of 180 MHz ?
 
Last edited:

Thread Starter

GRVEN21

Joined Jul 21, 2025
9
Well in the specifications, I've been said that sampling frecuency for VoIP call are 16 Khz, but I didnt know that I was sampling 180 Mz. It's just I dont know the notations in scilab. O'm Sorry, I mistake in the formulation of the problem. But I'd like to know the feature of the noise.
 
Top