Mod Archive Forums

Music Production => MilkyTracker => Tracking => MilkyTracker Community => Topic started by: phate on September 22, 2008, 05:04:34

Title: Filter Algorithms
Post by: phate on September 22, 2008, 05:04:34
Milkytracker has a nice set of filters, and I know there are people around here who know a thing or two about audio processing, so I was wondering if any of you know where I can find decent resources on writing filtering algorithms. I have a decent background in digital signal processing, and I've been using Max/MSP for a few years now, but I still don't know much about the inner workings of FIR filters and Fourier transforms.

So I was wondering, what would any of you suggest for learning more about this sort of thing? I'd like to begin work on some cross-platform synthesis/audio editing tools, but until I have a firm grasp on how this stuff works, I can't really do much.
Title: Re: Filter Algorithms
Post by: pailes on September 22, 2008, 18:11:54
I recommend reading the first chapters of the DSP Guide: www.dspguide.com
No need to dig through the entire book, but it's worth reading the first few chapters.
Title: Re: Filter Algorithms
Post by: phate on September 22, 2008, 21:46:01
Thanks a ton. This is an incredible resource.

I'll probably read most of it simply because I'm interested.
Title: Re: Filter Algorithms
Post by: urban soul on September 24, 2008, 03:38:36
The simple biquad formula found in max is one of the best sounding filters here. Dont waste your time with pseudo analogue crap as long as your name is propeller_heads. Good sounding resonance type LP filters are hard to get close to. Nobody will tell you how to do it. For good sounding resonance you will need an overdrive/saturation module before the filter.

dspguide is fine. Pohlmann "Principles of Digital Audio" is better ($$$).

edit: Good luck.
As mentioned Reason is state of the art. To get close to that a lot of work will be necessary: responses of knobs are not linear - sometimes it is as simple as that. They use a homegrown filter formula too, i am pretty sure. Knowledge of tube design and a pair of good ears would be helpful in this respect. Tube design is BTW a fairly deep topic. Learn how to program a good K2. (Tubes have a quadratic characteristic + complicated saturation) I can send you papers if you are interested.
Title: Re: Filter Algorithms
Post by: phate on September 24, 2008, 05:14:03
I need a bunch of filters. I'm working on a sample-based synthesis toolkit, so I'll need every bit of DSP code I can get my hands on. Right now though, I'm just trying to get some functional HP/LP/BP filters set up. Maybe a nice graphical EQ.

Also, what is all of this about Reason? There are a number of DAWs and VSTs that offer great sounding filters, but I'm confused as to how this is relevant to my question. I'm not trying to do anything terribly fancy ATM, I just need some basic filters for sound sculpting.

Thanks for the recommendation though. I'm a bit strapped for cash right now, but maybe I'll look into it later.
Title: Re: Filter Algorithms
Post by: urban soul on September 24, 2008, 13:15:09
Bits of (c/c++) code can  be found all over the net... e.g.

http://www.dspguru.com/

What environment are you using for development?

What about Reason? Nothing. I disagree that there are a number of DAWs and VSTs that offer great sounding filters, but I am not interested in that sort of discussion.
Title: Re: Filter Algorithms
Post by: phate on September 24, 2008, 18:34:17
I'm using standard C and the Nintendo DS. The idea is to get a decent audio editor/sample-based synthesis toolkit going so that the people using Nitrotracker and other sample-based DS music apps will have something nice to prepare their sample material, without having to run to a computer to do it.
Title: Re: Filter Algorithms
Post by: urban soul on September 24, 2008, 22:05:19
most pd externals are written in plane C (open source). http://maxobjects.com/
Audacity code may also be worth a look.
Title: Re: Filter Algorithms
Post by: pailes on September 24, 2008, 22:12:18
Bits of (c/c++) code can  be found all over the net... e.g.

http://www.dspguru.com/

I would suggest reading the basics of DSP first (e.g. in DSP guide) and then start with FIR filters. There is a chapter about constructing FIR high/lowpass filters. This is very interesting reading, especially when you have never constructed a filter kernel for a basic FIR filter before.
Title: Re: Filter Algorithms
Post by: urban soul on September 24, 2008, 22:35:31
yes, dspguide is great stuff and its free. Just want to mention that FIR and IR filters are different concepts. This is all very clear described in dspguide. I personally avoid realtime implementations which depend on FFT because of artifacts in the time domain (windowing), but this is sort of OT here. 
Title: Re: Filter Algorithms
Post by: barryvan on September 25, 2008, 02:00:53
If you do want to do work with FFTs, there are ways and means to get around windowing difficulties, like sliding windows, pyramid schemes, combinations thereof, limited number of frequencies analysed, and a lot more. Bear in mind, though, that they're likely to be a tad processor-hungry for low-powerered devices like the DS.
Title: Re: Filter Algorithms
Post by: urban soul on September 25, 2008, 03:30:33
If you do want to do work with FFTs, there are ways and means to get around windowing difficulties, like sliding windows, pyramid schemes, combinations thereof, limited number of frequencies analysed, and a lot more. Bear in mind, though, that they're likely to be a tad processor-hungry for low-powerered devices like the DS.
I'd like to know more about these windowing tricks. What pyramid schemes ?

The only thing I know is, that I compared an offline convolution to a FFT based realtime convolution (reverb here) and the difference in sound quality was disappointing. The non-FFT-based implementation sounded way better to me. I also compared transposing tools in Max/MSP. The difference was not so clear and depended on source material.
Title: Re: Filter Algorithms
Post by: phate on September 25, 2008, 03:42:48
Bear in mind, though, that they're likely to be a tad processor-hungry for low-powerered devices like the DS.

Yeah, I know. Luckily, this isn't going to need realtime processing, being an audio editor and all, although I've actually seen real-time spectral analysis done on the DS, so I guess that sort of thing is possible.
Title: Re: Filter Algorithms
Post by: barryvan on September 25, 2008, 03:45:00
@urban soul: There are lots of ways to do FFTs. I investigated quite a few for my thesis. There's your plain vanilla DFT, which you should know. Then there's your frequency-limited DFT (which I use) - once I've finished my thesis, I'll put it up on the web with pseudocode on how to do that. There's sliding window analysis:
(http://test.pbc.wa.edu.au/files/imagegallerymodule/@random48964cb48ec61/gallery18/Diag_SlidingWindow_Small.png)
...which I think you know, and then there's pyramid stuff. (I've got a pretty diagram for that, too, but I haven't uploaded it yet.) Basically, pyramid analysis uses windows of different sizes overlapped to analyse different frequencies. This allows you to overcome some of the problems related to the tradeoff between the temporal resolution and the frequencies you can detect. Recall that in an FFT, you can only detect frequencies up to the Nyquist frequency; that is, you can only detect a freq if it has at least one full cycle in the window you analyse. So to detect a low freq, you need a long window; but this means that you can't pick up rapid changes in notes. :)

@ phate: Yeah. Spectral analysis on low powered devices (which is kinda my thesis' point) is best done with a limited set of frequencies - like, for example, the notes of a scale (generally 12TET). This means that you might have difficulty working with out-of-tune or untuned instruments, but meh. :)
Title: Re: Filter Algorithms
Post by: urban soul on September 25, 2008, 04:33:26
@barryvan: Oh thx, I see. You can get a pretty good trade-off between frequency selection , floating windows (frequency dependent, different types) , and FFT length. So you have to know (analyze) the input signal.