Mar 22 2007 | 11:42 pm

Hi all,

Can anyone point me to a good source (preferably online) for formulas/

algorithms for generating the "standard" windowing functions (i.e.

gaussian, hanning, blackman, kaiser, etc.) of 512, 1024, etc. points?

I'd like to create some 'roll-your-own' abstractions for generating

windows and storing them in buffers. I know a few people have already

implemented these kinds of things in MaxMSP; I'd like to go through

the learning curve of making my own. I plan to use them for a variety

of things, starting with granularization of sound files.

Thanks in advance,

Best,

Steven

----

Steven M. Miller

Home

SFIFEM

Atrium Sound Space

OVOS

- Mar 23 2007 | 12:10 amHi Steven,Wikipedia has formulae for a lot of them:--OwenSteven Miller wrote:> Hi all,>> Can anyone point me to a good source (preferably online) for> formulas/algorithms for generating the "standard" windowing functions> (i.e. gaussian, hanning, blackman, kaiser, etc.) of 512, 1024, etc.> points? I'd like to create some 'roll-your-own' abstractions for> generating windows and storing them in buffers. I know a few people have> already implemented these kinds of things in MaxMSP; I'd like to go> through the learning curve of making my own. I plan to use them for a> variety of things, starting with granularization of sound files.>> Thanks in advance,>> Best,>> Steven>
- Mar 23 2007 | 12:31 amOn Mar 22, 2007, at 7:42 PM, Steven Miller wrote:> I know a few people have already implemented these kinds of things> in MaxMSP; I'd like to go through the learning curve of making my> own. I plan to use them for a variety of things, starting with> granularization of sound files.Steven:I have a patch that demonstrates how to do this in the GTK. If youdownload the toolkit from the URL below, look in the extras folderfor a patch called "gtk.winMaker". This in the actual patch used tocreate all the window files used by the toolkit.Or am I one of those "few people" to which you refer? :)--Nathan-------------------Nathan Wolek, PhD --- nwolek@stetson.eduAssistant Professor of Music TechnologyStetson University - DeLand, FL
- Mar 23 2007 | 12:59 amOn 3/22/07, Steven Miller wrote:> Hi all,>> Can anyone point me to a good source (preferably online) for> formulas/algorithms for generating the "standard" windowing functions (i.e.> gaussian, hanning, blackman, kaiser, etc.) of 512, 1024, etc. points? I'd> like to create some 'roll-your-own' abstractions for generating windows and> storing them in buffers. I know a few people have already implemented these> kinds of things in MaxMSP; I'd like to go through the learning curve of> making my own. I plan to use them for a variety of things, starting with> granularization of sound files.>> Thanks in advance,>> Best,>> Steven>>> ----> Steven M. Miller>> Home SFIFEM> Atrium Sound Space> OVOS>>>>
- Mar 23 2007 | 3:53 pmThanks Owen, Nathan & Mark - much appreciated.Nathan, I recalled looking at your window maker abstraction a whileback, and was very impressed at how clean & straight-forward it was.I was avoiding looking at it right now, to force myself to figure itout on my own. I may peak (peek~?) at it if I get stuck. Thanks!Best,Steven----Steven M. MillerHomeSFIFEMAtrium Sound SpaceOVOS
- Mar 23 2007 | 4:44 pmI'm looking at the window functions on Wikipedia...so far sogood...until I get to the formula for the Kaiser window. Can anyonehelp a non-mathematician with implementing the 'zeroth order modifiedBessel function of the first kind' in this formula? I followed up tothe Wikipedia page for Bessel functions, and my eyes glazed overpretty quickly...I'm using [expr] for these window functions, if that helps.Thanks!----Steven M. MillerHomeSFIFEMAtrium Sound SpaceOVOS
- Mar 23 2007 | 5:17 pmOn Mar 23, 2007, at 11:53 AM, Steven Miller wrote:> Nathan, I recalled looking at your window maker abstraction a while> back, and was very impressed at how clean & straight-forward it> was. I was avoiding looking at it right now, to force myself to> figure it out on my own. I may peak (peek~?) at it if I get stuck.> Thanks!The hardest things for me to get my head around was the differencebetween continuous and discrete-time functions. Most of the math websites will give you the continuous expression, but sampled waveformssuch as sound files are discrete.Being a musician that got into programming then went back and tooksome engineering courses, I never understood why my math/engineeringprofessors seemed obsessed with the continuous. Just tell me what Ineed to feed the computer and keep your beautiful equations toyourself. ;)-------------------Nathan Wolek, PhD --- nwolek@stetson.eduAssistant Professor of Music TechnologyStetson University - DeLand, FL
- Mar 24 2007 | 3:32 am
- Mar 24 2007 | 4:24 pmThank you, Jose - I'll dig into this over the weekend!On Mar 23, 2007, at 9:32 PM, jose manuel berenguer wrote:> Hello>> perhaps that can be of some interest...>>> jmb----Steven M. MillerHomeSFIFEMAtrium Sound SpaceOVOS
- Mar 24 2007 | 6:09 pmThanks, Nathan,Luckily, the Wikipedia page Window_function> from which I'm sourcing my equations uses thediscrete-time versions, so all is well in that regard.I've run into some difficulty with one particular equation: I can'tseem to get the Gauss equation worked out in my [expr] and I keepgenerating 'divide by zero' errors. So, I took a look at the Gaussexample in your window maker abstraction...and you're using acompletely different equation (at least to my eye). Yours alsoincludes another input variable not called for in the Wikipediaversion. Any insights to share? You also have a 'quasi-gaussian'window - what's the difference there?Thanks,StevenOn Mar 23, 2007, at 11:17 AM, Nathan Wolek wrote:> The hardest things for me to get my head around was the difference> between continuous and discrete-time functions. Most of the math> web sites will give you the continuous expression, but sampled> waveforms such as sound files are discrete.>> Being a musician that got into programming then went back and took> some engineering courses, I never understood why my math/> engineering professors seemed obsessed with the continuous. Just> tell me what I need to feed the computer and keep your beautiful> equations to yourself. ;)>----Steven M. MillerHomeSFIFEMAtrium Sound SpaceOVOS
- Mar 24 2007 | 10:00 pmOn Mar 24, 2007, at 2:09 PM, Steven Miller wrote:> Any insights to share?I just sat down an tried to do some math juggling to make them equaland could not. I am sure I am doing something wrong. My books arein my office and I am at home, so I am trying as best I can frommemory. I did this patch pre-Wikipedia. :)Two points:1) My first variable is the same as n/N in the Wikipedia formula.This changes the math.2) The version I use has implemented a "skew" functionality. You canspecify where the peak should be, with 0.5 being the mid-point. Inthe Wikipedia version the peak is fixed at half way through thewindow. This changes the math even more.Hope that provides some insights as to why they are different. Ilikely did some other programming reductions on the math to make itcompute faster. Even though it was not for real-time audio, I amsure I could not fight the compulsion to make it more efficient.> You also have a 'quasi-gaussian' window - what's the difference there?This one is easier. The quasi-gauss was an invention of Roads forhis early work on granular synthesis. Imagine splitting the Gaussianwindow in half and using these halves as attack and decay portions ofyour envelopes. Between them you just have a sustain or "straightline". Because the duration of the sustain is now longer, the neteffect is louder grains.Remember that the Gaussian envelope in used in granular effectsprimarily as an historical artifact. It is the envelope proposed byGabor in 1947 when he dreamed up granular synthesis. He had no wayto know what it would actually sound like. Whether it is the bestremains a matter of taste, more so in granular techniques than inspectral techniques.-------------------Nathan Wolek, PhD --- nwolek@stetson.eduAssistant Professor of Music TechnologyStetson University - DeLand, FL
- Mar 24 2007 | 11:02 pmThanks Nathan, much appreciated! And the quasi-gaussian explanationvaguely jogs my memory from reading 'Microsound' a few years back.On Mar 24, 2007, at 4:00 PM, Nathan Wolek wrote:>> Hope that provides some insights as to why they are different. I> likely did some other programming reductions on the math to make it> compute faster. Even though it was not for real-time audio, I am> sure I could not fight the compulsion to make it more efficient.>----Steven M. MillerHomeSFIFEMAtrium Sound SpaceOVOS
- Mar 24 2007 | 11:40 pmHere's my implementation of the Wikipedia Gauss window function. It nolonger produces 'divide by zero' errors, but it only creates thefirst half of the function over the entire width of the window. Anyideas what I'm doing wrong?max v2;----Steven M. MillerHomeSFIFEMAtrium Sound SpaceOVOS
- Mar 25 2007 | 9:03 ammind your brackets.try this one.vmax v2;On 25 Mar 2007, at 00:40, Steven Miller wrote:>> Here's my implementation of the Wikipedia Gauss window function>. It no> longer produces 'divide by zero' errors, but it only creates the> first half of the function over the entire width of the window. Any> ideas what I'm doing wrong?>> max v2;> #N vpatcher 717 201 1324 736;> #P window setfont "Sans Serif" 9.;> #P flonum 409 155 35 9 0. 0.5 3 3 0 0 0 221 221 221 222 222 222 0 0 0;> #P message 336 111 43 196617 size $1;> #P newex 238 71 53 196617 t i i i i;> #P newex 280 91 66 196617 sampstoms~;> #P newex 238 49 91 196617 patcherargs 1024;> #P newex 106 49 67 196617 t b b;> #P newex 336 129 154 196617 buffer~ my-window 23.22;> #P newex 106 221 101 196617 peek~ my-window 1;> #P button 106 25 15 0;> #P newex 106 100 50 196617 uzi 1024;> #P newex 123 177 297 196617 expr exp(-.5*pow((($f1-($f2-1))/2)/> (($f3*($f2-1))/2)\,2));> #P newex 106 153 27 196617 t i i;> #N counter 0 0 1024;> #X flags 0 0;> #P newobj 106 129 89 196617 counter 0 0 1024;> #P connect 4 0 7 0;> #P connect 7 0 3 0;> #P connect 3 0 0 0;> #P connect 0 0 1 0;> #P connect 1 0 5 0;> #P connect 1 1 2 0;> #P fasten 10 0 3 1 243 95 151 95;> #P fasten 2 0 5 1 128 207 156 207;> #P connect 7 1 0 3;> #P fasten 10 1 0 4 257 108 187 108;> #P connect 8 0 10 0;> #P fasten 10 2 2 1 271 132 271 132;> #P connect 10 3 9 0;> #P connect 9 1 11 0;> #P connect 11 0 6 0;> #P fasten 12 0 2 2 414 174 414 174;> #P pop;>> ----> Steven M. Miller>
- Mar 25 2007 | 11:47 amOn Mar 24, 2007, at 7:40 PM, Steven Miller wrote:> Any ideas what I'm doing wrong?I can remember having this problem, however I cannot seem to recallthe solution. I played around with your [expr] formula but it didnot jog my memory. I believe this has something to do with why myformula used n/N as a variable.I'll take a few minutes on monday to look over my sources when I amback in the office. Maybe there is a problem with the wikipediaarticle?-------------------Nathan Wolek, PhD --- nwolek@stetson.eduAssistant Professor of Music TechnologyStetson University - DeLand, FL
- Apr 12 2009 | 11:41 pmhelloi am currently generating some envelopes and was wondering how this is represented with the expression object?i've had a look at the other patches but i can't quite figure which bits go where
- Apr 13 2009 | 12:37 amThe problem I always have is getting the parentheses in the right place, I always end up forgetting a pair which completely changes the equation. Other times I use them everywhere and that makes reading the actual equation impossible! Here's a patch that should show you how things are done.lh
- Apr 13 2009 | 12:47 amMike S wrote on Sun, 12 April 2009 18:41helloi am currently generating some envelopes and was wondering how this is represented with the expression object?I think this is it:
- Apr 13 2009 | 12:51 amYou need an extra set of brackets around the $f2 - 1 bit other wise it will do the division first. The "n" is counting up in integers to a certain amount and the "N" is the total number of steps. Have a look at the patch I just posted to see what I mean.lh
- Apr 13 2009 | 1:06 amsmill wrote on Thu, 22 March 2007 18:42I'd like to create some 'roll-your-own' abstractions for generating windows and storing them in buffers.Off-topic a bit, but you might also try this patch, which gets snippets of any longer buffer~ into a multislider and then into another buffer~. So depending on what kind of audio you load into the main one, you could get some interesting waveforms which might be usable in windowing (or they may sound cool just by themselves). The multislider also lets you store presets and interpolate, to make new waveforms between saved ones.
- Apr 13 2009 | 1:47 amfor musicians an oscillating and/or repetive and/or selfgenerating function is always continous, even if the same thing is a discrete time whatnot for the silly m4+h3m4+!k4nz_.when i dealt with my very first fractal function i found out that any discrete time whathefuck can be "continous" wehen you just restart it from time to time.
- Apr 13 2009 | 5:17 pmthanks for the replies, very helpfulout of interest i've been trying some of the other window functions on that page.I'd quite like to know how to do theseBartlett window (zero valued end-points)- on this one i'm not sure what the vertical lines mean in the latter part of the equationGauss window, σ=0.4; B=1.45- not sure what this part underneath is for?Nuttall window, continuous first derivativeI've had a crack at this one, but i get a bit of a different window to the one described here http://en.wikipedia.org/wiki/Window_function
- Apr 13 2009 | 10:08 pmBartlett: [expr (($i2-1)/2 - abs($i1-($i2-1)*0.5))/(($i2-1)*0.5)]Gauss: [expr exp(-0.5*pow(($i1-(($i2-1)/2))/(0.4*(($i2-1)/2)),2))]Nuttall: [expr 0.35875-(0.48829*cos((2*3.1415925635*$i1)/($i2-1)))+(0.14128*cos((4*3.1415925635*$i1)/($i2-1)))-(0.01168*cos((6*3.1415925635*$i1)/($i2-1)))]Those should do the trick if you replace the [expr] in my previous patch with them. You could change the coefficients of the Nuttall equation to get the other curves on the wikipedia page. I always find it helpful to write the equation out on paper and then re-write it with breackets onto one line, it should then be in the form you need for use in [expr].lh
- Nov 19 2009 | 6:48 amHi,This might be useful - it's an abstraction for generating a bunch of typical window functions. Not perfect, and probably there are many important ones missing, but if you add more let me know and I'll put it on maxobjects.com.Here's the help:And here's the abstraction (save as window.maxpat):Best,Graham
- Nov 19 2009 | 8:36 am>>"only going over half the buffer" ..expr exp(-.5*pow((($f1-($f2-1))/2)/(($f3*($f2-1))/2)\,2));i had that experience also when building my first cosine andhanning buffer maker. you use uzi and counter, and it counts1024, and it does not peek 1024 but only 511, and you think "wtf??"i found out that in my case it was the formula itself which waswrong because it simply had a max() or a *(x>y) at the wrong placeso that the missing samples were actually samples of all 0. foat.-110oh, graham actually revived this thread from march -- i knewi´ve read something like that here before.
- Nov 19 2009 | 10:19 amBack in Supercollider 1.x days I used to use Apgrain which had some nice properties. I was so perplexed by the different window types and why Apgrain sounded so good to my hears that i asked James McCartney about it and he said in 1997 (yikes!) about it:Apgrain gives a parabolic envelope. That is 1 - x*x evaluatedbetween -1 and +1. This happens to be a very simple envelopeto generate since it requires only a double integration (two adds).It has a shape more like a Welch envelope than a Hanning one.I actually prefer it because in the Hanning envelope the quiettails on the end are really inaudible when mixed with other grainsthat mask it, so it is just wasted CPU to output it. A Welch envelopematches the curve of an equal power panning function, so it has goodproperties when overlapping fewer grains to get a smooth sound. Thisisn't exactly true of the parabola which is too 'hot' at the midpointof the curve, but it suits my purposes fine.A hanning envelope shape is: .5 - .5 * cos(x); x = 0 to 2pi.A welch envelope shape is: sin(x); x = 0 to pi--Well, i miss that hot parabolic envelope! I always liked how that sounded for grains.(quoted from here:)