Welcome, Guest. Please login or register.

Author Topic: Fun Maths problem (probably to Karlos at least)  (Read 3271 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline bloodlineTopic starter

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12113
    • Show only replies by bloodline
    • http://www.troubled-mind.com
Fun Maths problem (probably to Karlos at least)
« on: November 25, 2004, 04:28:56 PM »
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):

Code: [Select]

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

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Fun Maths problem (probably to Karlos at least)
« Reply #1 on: November 25, 2004, 04:57:42 PM »
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...

-/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 :-)
int p; // A
 

Offline bloodlineTopic starter

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12113
    • Show only replies by bloodline
    • http://www.troubled-mind.com
Re: Fun Maths problem (probably to Karlos at least)
« Reply #2 on: November 25, 2004, 05:03:01 PM »
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?

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Fun Maths problem (probably to Karlos at least)
« Reply #3 on: November 25, 2004, 05:08:54 PM »
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!)
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Fun Maths problem (probably to Karlos at least)
« Reply #4 on: November 26, 2004, 10:53:32 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 = 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 :-)
int p; // A
 

Offline bloodlineTopic starter

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12113
    • Show only replies by bloodline
    • http://www.troubled-mind.com
Re: Fun Maths problem (probably to Karlos at least)
« Reply #5 on: November 26, 2004, 11:26:40 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!

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Fun Maths problem (probably to Karlos at least)
« Reply #6 on: November 26, 2004, 11:29:29 PM »
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Fun Maths problem (probably to Karlos at least)
« Reply #7 on: November 26, 2004, 11:41:59 PM »
Two maths related problems in as many days. I need to get out more :lol:
int p; // A