function [x,t] = iec60645_3(f,Fs)
    // Tone impulse according to IEC 60645-1
    // 
    // Usage:
    //        x = iec60645_3(f,t)
    // where
    //        f:  Frequency in Hz
    //        Fs: Sample rate in Hz
    //        x:  Tone impulse
    //        t:  Time vector 
    //
    // ------------------------------
    // Author: Federico Miyara
    // Date:   2024-07-20
    
    if 1==2 then
        f = 1000;
        Fs = 44100;
    end
    
    t = 0:1/Fs:5/f;
    x = sin(2*%pi*f*t);
    
    // Period 
    T = 1/f;
    
    // Slope
    p = 1/2/T;
    
    // Length of fade in/out 
    K = round(2*Fs*T);
    
    // Envelope
    E = ones(1,length(x));
    E(1:K) = (0:K-1)*p/Fs;
    E($-K+1:$) = (K-1:-1:0)*p/Fs  
    
    // Appply envelope
    x = x.*E;
         
    if 1==2
    scf(1);
    clf(1);
    plot(t, x, t, E, t, -E)
    playsnd(0.1*x, Fs)
    end

endfunction
