electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » Developers' Corner
Easy filter (software)
Post new topic   Reply to topic Moderators: DrJustice
Page 1 of 1 [5 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
Kenneth



Joined: Apr 16, 2009
Posts: 43
Location: Stockholm, Sweden

PostPosted: Thu Apr 16, 2009 6:40 am    Post subject: Easy filter (software) Reply with quote  Mark this post and the followings unread

I have used computers to create "samples" for like 20 years. ATARI ST and ST Replay (8 bit mono sampler/player) was the first hardware I used, later Amiga and then PC's.

I don't have a clue what others use but I got a number of nice things I can share, first it will be my filter.

sample = Function_sinus(phase) .... returns the phase of a sinus, a float in the range -1 to 1, the ocillator I use in this example.

Then do this to the sample:

x = |sample| ... the absolute value (0-1)
s = SGN(sample) ... returns the sign of the sample (-1 or 1)

x = x^Q ... the actual filter where Q is the setting of the filter, 0-1 lowpass, 1-whatever higpass (values between 0.25 and 100 are useful, 1 is = no filter effect)

Then last

sample = x*s ... restores the sign of the sample.

Is that useful for anyone?
Back to top
View user's profile Send private message
DrJustice



Joined: Sep 13, 2004
Posts: 2114
Location: Morokulien
Audio files: 4

PostPosted: Thu Apr 16, 2009 8:36 am    Post subject: Re: Easy filter (software) Reply with quote  Mark this post and the followings unread

Kenneth wrote:
Is that useful for anyone?

Yes, this is a very useful technique thumleft

It isn't a filter tough, but rather a transfer function, or as we say in synth speak a 'waveshaper'.

This particular function, y = x^c, is often used as a soft clipper. When c = 1, the signal passes unaltered as you have observed, and as c approaches zero we get more (harder) clipping and the signal becomes more and more like a square wave. (I changed the Q to a c, so as not to confuse it with a filters Q factor, and instead c is our waveshaper 'coefficient' in the range 0-1).

In an actual filter, the output value depends on previous input values. A very simple first order lowpass filter looks like:
y(n) = x(n) + c * (y(n-1)-x(n))
where n is the sample number and c is the filter coefficient which determines the cutoff frequency. For each sample you calculate this filter and save y, then use y again it for the next sample. To find c use:
exp(-2.0*PI*(fc/fs))
where fc is the desired cutoff frequency and fs is the samplerate.

DJ
--
Back to top
View user's profile Send private message Visit poster's website
Kenneth



Joined: Apr 16, 2009
Posts: 43
Location: Stockholm, Sweden

PostPosted: Thu Apr 16, 2009 9:11 am    Post subject: Reply with quote  Mark this post and the followings unread

Thanks for the reply.

Waveshaper, yes, that makes sence. But if you use it like I do, directly after the ocillator and after that you do envelop, then it sounds wery much like a filter, that's why I always thought of it as a filter Smile

As I said, I always used my own stuff and have no clue of how to do it the "proper" way, but of course, I can learn if I need to. If I understood what you wrote a real filter is iterative. I have worked a lot with fractals so I understand iteriation well. Your filter function looks a lot like a fractal function... Hmm, maybe it is possible to create a fractal from it? Razz
Back to top
View user's profile Send private message
DrJustice



Joined: Sep 13, 2004
Posts: 2114
Location: Morokulien
Audio files: 4

PostPosted: Thu Apr 16, 2009 10:41 am    Post subject: Reply with quote  Mark this post and the followings unread

Kenneth wrote:
Waveshaper, yes, that makes sence. But if you use it like I do, directly after the ocillator and after that you do envelop, then it sounds wery much like a filter, that's why I always thought of it as a filter Smile

The sound can sometimes remind of filtering, but the major difference is that a transfer function will introduce different harmonics in the signal, whereas a filter can only amplify or attenuate the harmonics that are already in the signal. This distinction is very important. E.g. in practise a filter can not introduce aliasing, but (non bandwidth limited) waveshaping will do so.

Quote:
As I said, I always used my own stuff and have no clue of how to do it the "proper" way, but of course, I can learn if I need to. If I understood what you wrote a real filter is iterative. I have worked a lot with fractals so I understand iteriation well.

You've got that right!

Quote:
Your filter function looks a lot like a fractal function... Hmm, maybe it is possible to create a fractal from it? Razz

Not quite, but fractals are very useful in musical applications, both for waveform generation and composition. Armed with the stuff you now know, waveshaping, fractals and filtering, you can do a lot of interesting synthesis and processing.

DJ
--
Back to top
View user's profile Send private message Visit poster's website
Kenneth



Joined: Apr 16, 2009
Posts: 43
Location: Stockholm, Sweden

PostPosted: Thu Apr 16, 2009 12:34 pm    Post subject: Reply with quote  Mark this post and the followings unread

DrJustice wrote:
Quote:
Your filter function looks a lot like a fractal function... Hmm, maybe it is possible to create a fractal from it? Razz

Not quite, but..


lol

Change it to this:

Iteriation loop
{
x(n) = 2 * y(n-1) * x(n-1) + a
y(n) = x(n-1) + b * (y(n-1)-x(n-1))
}

Now I'm sure it will make a fractal, maybe not any good stuff but fractal Smile

If my HD's did not break one after the other I would have got a number of tools for creating sounds... but they are all lost by now I think (and I do not know where to look if there are any still alive, it was some years ago now).

Here I got some of my fractal works:
http://commons.wikimedia.org/wiki/User:Solkoll
http://commons.wikimedia.org/wiki/Template:Solkoll_2D
http://commons.wikimedia.org/wiki/Template:Solkoll_3D
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: DrJustice
Page 1 of 1 [5 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Developers' Corner
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use