clc; close all; clear all;

f1 = 10;            % start frequency
f2 = 6000;         % final frequency
fs = 96000;         % sampling frequency
T_ = 10;            % approximative time duration

N = 4;              % order of nonlinearities

% Length of each impulse repsonse (in samples)
len_IR = 2^13;
pre_IR = len_IR/2;

%% -- generation of the signal

L = round(f1/log(f2/f1)*T_)/f1;
T = L*log(f2/f1);
t = (0:ceil(fs*T)-1)./fs;
x = sin(2*pi*f1*L*(exp(t/L)-1));

% fade-in the input signal
fd1 = 480;  % number of samlpes
fade_in = (1-cos((0:fd1-1)/fd1*pi))/2;
index = 1:fd1;
x(index) = x(index).*fade_in;

% fade-out the input signal
fd2 =  480;  % number of samlpes
fade_out = (1-cos((0:fd2-1)/fd2*pi))/2;
index = (1:fd2)-1;
x(end-index) = x(end-index).*fade_out;
wavwrite(x,fs,'sweptsine.wav')