help-octave
[Top][All Lists]

## Re: Audio signal

 From: Matthias Brennwald Subject: Re: Audio signal Date: Sat, 17 Nov 2007 22:32:06 +0100

```Message: 4
> Date: Sat, 17 Nov 2007 09:05:35 -0800 (PST)
> From: polmc <address@hidden>
> Subject: Audio signal
> Content-Type: text/plain; charset=us-ascii
>
>
> Ok, I have to synthetize an audio signal. I must do this by suming up the
> harmonics of the sound.
>
> So long I've got this:
>
> function sinte(f)
>
>   t=0:0.0001:0.0854;
>   Fs = 44100;
>   tau6 = 0.018;
>   A6 = 25.1;
>   f6 = f*7;
>   x6 = A6*exp(-t/tau6).*sin(2*pi*f6*t/Fs);
>
>   tau7 = 0.016;
>   A7 = 15.8;
>   f7 = f*8;
>   x7 = A7*exp(-t/tau7).*sin(2*pi*f7*t/Fs);
>
>   tau8 = 0.017;
>   A8 = 19.9;
>   f8 = f*9;
>   x8 = A8*exp(-t/tau8).*sin(2*pi*f8*t/Fs);
>
>   tau9 = 0.038;
>   A9 = 12.5;
>   f9 = f*10;
>   x9 = A9*exp(-t/tau9).*sin(2*pi*f9*t/Fs);
>
>   tau10 = 0.017;
>   A10 = 10;
>   f10 = f*11;
>   x10 = A10*exp(-t/tau10).*sin(2*pi*f10*t/Fs);
>
>   x = x6 + x7 + x8 + x9 + x9 + x10;
>
>   wavwrite(x,Fs,16,"so.wav");
>
>   endfunction
>
>
> When I play the sound, I just hear a short 'puff'.
>
> The thing is that if I take away the '/Fs', It then sounds like a normal
> 'beep', which is what I want (I guess). Does anyone know what exactly does
> the Fs mean?

My guess is that Fs is the sampling frequency, i.e. the rate at which
the signal samples are distributed in time. With a sampling frequency Fs
of 44100 Hz, signal samples occur every 1/44100-th second. A sampling
frequency of 44100 Hz is the standard for music CDs.

In your above example, you constructed your time values as follows:
t = t=0 : 0.0001 : 0.0854;
I don't think this is the best approach. I'd rather do the following:
Fs = 44100;
t = 1/Fs : 1/Fs : 5;
This will give you the time values for a signal with a duration of 5
seconds, sampled with a sampling rate of 44100 Hz.

Then, to produce your signals, remove the Fs from the sin(...)
functions, e.g.:
x6 = A6*exp(-t/tau6).*sin(2*pi*f6*t);

Also, it might help to plot your signals on screen so that you get an
idea of how they look. Just do:
plot (t,x6)
This will plot your signal x6 as a function of time.

I hope this helps.

Matthias

```

reply via email to