PDA

View Full Version : Fun Maths problem (probably to Karlos at least)


bloodline
11-25-2004, 09:28 AM
My main Miggy HD appears to be dead, very dead. I had assumed that all my old Programming efforts would have been lost... but I did find some of my workings that I did for a Softsynth I was working on about 8 years ago...

To my surprise I have found that my idea of a "low pass filter" was, (how shall I put it?)... "novel".

It seems that I would take an average of the previous x (the higher the value of x the steeper the cutoff frequency)amount of samples and use them to generate the new value...

While this does attenuate the higher frequencies it does so in a linear fasion, also for high values of x it creates some very weird waveforms... and probably accounts for the weird sound that my soft synth produced :-D
In my defence at small values of x, it's great for cleaning up a noisey recording.

In Pseudo code (from memory):


Input_Audio_array[]
Output_Audio_array[]

x=cutoff_frequency

For i=0 to Audio_array_lenght

accumulator=0
For v=0 to x
accumulator = accumulator + Input_Audio_array[ i - v ]
Next

Output_Audio_array[x] = accumulator / x

Next


Made me smile... now to implement one properly I think :-D

Karlos
11-25-2004, 09:57 AM
Ah, filters. You have to love 'em...

Reminds me of a self adjusting bandpass filter I was experimenting with (in fact I remember making a thread about just that very idea here some time ago)...

-edit-

here, in fact... (http://www.amiga.org/forums/showthread.php?t=3260)

-/edit-

I have the maths and source (albiet zilog DSP asm) for the various hamming High Pass / Low Pass / Notch Reject / Band Pass filters someplace at home from a Zilog DSP/IceBox developer kit I managed to acquire a while ago.

I can dig them out later if you want :-)

bloodline
11-25-2004, 10:03 AM
The DSP sources wouldn't be of much use to me but it would be fun to disscuss the theory.

I just wantd to create a simple 4pole lowpass filter an then add resonance to it... my best resource is http://www.musicdsp.org

What do you know about VSTs?

Karlos
11-25-2004, 10:08 AM
VST as in Virtual Studio Tech or?

Either way, probably not very much :-) But I am generally a fast learner ;-)

(and still at work so I better not get too involved just now!)

Karlos
11-26-2004, 03:53 PM
@Bloodline

I dug around my notes, I dunno if you will find this useful.

For a given N-Tap filter, the ith output value is

O[i] = Sum(n=0 to N-1) { Cn . I[i-n]}

where

N = number of taps
O = output samples
I = input samples
C = filter coefficients of the N tap filter.

Depending on how you calculate Cn, you can create high, low, bandpass and notch reject filters.

For a basic low pass filter:

Cn = Sn . Wn

where

S are the impulse samples
W is the hamming window

Sn = sin(2.pi.Fcp.(n-(N-1)/2)/2.5/Fmax) / pi.(n-(N-1)/2)

where

n is the tap number of interest
N is the total number of taps
Fcp is the filter cut-off frequency
Fmax is the maximum possible input frequncy

The 2.5 factor is to satisfy the Nyquist rate such that the sampling frequency is 2.5*Fmax

The Hamming Window (W) is used to get a better filter behaviour, eliminating unwanted ripple:

Wn = cos(1) + (1-cos(1)).cos({2.pi.(n-(N-1)/2)}/(N-1))

By adjusting the function for S, you can create all kinds of resonance effects.

Enjoy :-)

bloodline
11-26-2004, 04:26 PM
Now I remember why I came up with my "filter approximation" from the first post... you try getting an 020 to process proper filter math in real time :-D

Your formula look cool I'll give 'em a try cheers!

Karlos
11-26-2004, 04:29 PM

Karlos
11-26-2004, 04:41 PM
Two maths related problems in as many days. I need to get out more :lol: