Forums > MaxMSP

Building a Filter

January 4, 2008 | 7:32 pm

Hello all,

I’m working through the second volume of Musimathics, by Gareth Loy, and learning quite a lot. I’d like to actually start realizing some of the topics he covers on my own in Max/MSP to help make them more concrete, and I’m having some troubles.

For instance, I’m now reading about filters, and their supporting mathematics. As a rather simple example, I’d like to build my own lowpass filter in Max/MSP. I know how to implement one through the built in filtering objects in Max/MSP, but building one on my own will give me the opportunity to better understand what’s really occuring.

He gives the equation for a lowpass filter thus:

y(nT) = x(nT) + x[(n-1)T]

where y(nT) is the input signal, n is an instantaneous sample, and T is time.

His explanation of the operation of this filter makes perfect sense, but realizing it in Max/MSP is giving me problems. I’m sure there’s a simple answer, but I’m just not getting it.

How would one realize such an equation? I appreciate your help!

Thanks,
Brennon


January 4, 2008 | 7:52 pm

Hi Brennon,

Have a look at the bufir~ object. You can build finite response filters with up to 256 points.There is a patch in the examples folder called buffir-eq-help.pat using bufir~

Here is a patch on convolution I made years ago when I was studying this. You need the lobjects for that.

have fun

falk

#P window setfont "Sans Serif" 18.;
#P window linecount 1;
#P comment 418 463 70 196626 output;
#P comment 662 177 167 196626 Impulse Response;
#P window setfont "Sans Serif" 9.;
#P message 627 102 63 196617 -1 -1 -1 -1;
#P message 215 49 43 196617 1 1 1 1;
#P message 743 142 47 196617 size 1 , 1;
#P message 293 33 23 196617 1 0;
#P newex 618 171 27 196617 t b l;
#P comment 337 582 19 196617 -1;
#P comment 340 535 19 196617 0;
#P comment 342 497 14 196617 1;
#P comment 543 298 19 196617 -1;
#P comment 546 251 19 196617 0;
#P comment 548 213 14 196617 1;
#P comment 340 159 19 196617 -1;
#P comment 343 112 19 196617 0;
#P message 835 100 41 196617 1 0.5 1;
#P message 334 32 28 196617 1 -1;
#P message 693 103 41 196617 1 0 0 0;
#P message 897 140 41 196617 0 0 0 1;
#P message 779 99 41 196617 0 0 1 0;
#P message 736 100 41 196617 0 1 0 0;
#P message 448 36 59 196617 0.5 0 1 0.5;
#P newex 370 186 69 196617 t b l l b clear;
#P newex 570 328 27 196617 t l l;
#P user multiSlider 360 499 193 103 -1. 1. 7 2937 15 0 3 2 2 0 1;
#M frgb 0 0 0;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P user multiSlider 591 210 193 103 -1. 1. 4 2937 47 0 3 2 2 0 1;
#M frgb 0 0 0;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P message 371 30 47 196617 size 1 , 1;
#P message 790 141 80 196617 1 0.75 0.5 0.25;
#P user multiSlider 370 71 193 103 -1. 1. 4 2937 47 0 3 2 2 0 1;
#M frgb 0 0 0;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P newex 407 331 27 196617 – 1;
#P newex 371 293 30 196617 uzi;
#P newex 360 466 39 196617 laccum;
#P newex 360 358 27 196617 lbuf;
#P newex 360 410 30 196617 lmult;
#P newex 360 432 151 196617 lpad;
#P newex 501 411 27 196617 – 1;
#P newex 501 389 27 196617 +;
#P newex 587 365 32 196617 zl len;
#P newex 501 267 32 196617 zl len;
#P comment 345 74 14 196617 1;
#P window linecount 4;
#P comment 220 131 100 196617 The sliders are the samples of one vectorin the soundfile;
#P window setfont "Sans Serif" 18.;
#P window linecount 1;
#P comment 240 80 75 196626 Input;
#P connect 39 0 35 0;
#P connect 37 0 35 0;
#P connect 14 0 35 0;
#P connect 26 0 35 0;
#P connect 23 0 35 0;
#P connect 22 0 35 0;
#P connect 21 0 35 0;
#P connect 24 0 35 0;
#P connect 35 1 16 0;
#P fasten 19 3 16 0 417 211 596 211;
#P connect 18 1 4 0;
#P connect 16 0 18 0;
#P fasten 4 0 5 1 592 386 523 386;
#P connect 6 0 7 3;
#P connect 5 0 6 0;
#P fasten 3 0 11 1 506 290 396 290;
#P connect 3 0 5 0;
#P fasten 19 2 3 0 403 263 506 263;
#P fasten 12 0 9 0 412 355 365 355;
#P connect 12 0 7 1;
#P fasten 11 2 12 0 396 325 412 325;
#P fasten 18 0 8 1 575 379 385 379;
#P fasten 19 1 9 1 389 269 355 269 355 319 382 319;
#P connect 19 0 11 0;
#P connect 13 0 19 0;
#P connect 38 0 13 0;
#P connect 36 0 13 0;
#P fasten 35 0 13 0 617 188 580 188 580 56 375 56;
#P connect 25 0 13 0;
#P connect 20 0 13 0;
#P connect 15 0 13 0;
#P connect 10 0 17 0;
#P connect 7 0 10 0;
#P fasten 19 4 10 0 431 206 450 206 450 177 332 177 332 458 365 458;
#P connect 8 0 7 0;
#P connect 9 0 8 0;
#P window clipboard copycount 42;


January 4, 2008 | 7:56 pm

On Jan 4, 2008, at 11:32 AM, Brennon wrote
>
> He gives the equation for a lowpass filter thus:
>
> y(nT) = x(nT) + x[(n-1)T]
>
> where y(nT) is the input signal, n is an instantaneous sample, and
> T is time.
>
> His explanation of the operation of this filter makes perfect
> sense, but realizing it in Max/MSP is giving me problems. I’m sure
> there’s a simple answer, but I’m just not getting it.

Well, you’d want to rearrange this to be in terms of the output signal:

x(nT) = y(nT) – x[(n-1)T]

So you subtract a 1 sample delay of the output from the input.
Unfortunately, you can’t get a 1 sample delay in a feedback path in a
Max patch. You can use comb~ or biquad~ for example, but I don’t
think that’s the autodidactic answer you were looking for…


January 4, 2008 | 8:13 pm

A couple things:

1) FYI – I recently got an email from Gareth re: the Musimat
programming language he created to demo the ideas in the books. He
gave me some detailed info on getting it to run on Intel Macs. I’ll
check with him to make sure it’s OK to post the info here, and follow
up accordingly.

2) I believe you have the interpretation of the equation slightly
wrong: y is the output, x is the input. In a nutshell, a given output
sample y(nT) is produced by averaging the current x(nT) and most
previous x((n-1)T) inputs. There should, however, be some
coefficients in there, in this case to multiply each of the two
inputs by .5 before adding them, in order to average them. That’s
what simple low-pass filtering is, averaging inputs to generate
outputs. You could achieve this in MSP by using [delay~] set to one
sample delay, and adding that to the direct signal after multiply the
delayed and direct signals by .5. This will then give you the
filtered (averaged) output. It achieves this by simply ‘slowing down’
fast-changing signals (i.e. signals with high-frequency components).

Hope this helps.

#P window setfont "Sans Serif" 12.;
#P window linecount 3;
#P user com 330 175 114 196620 23;
#K set 0 17509 27745 31008 29801 28005 8297 28192 29537 28016 27749
29472 11552 24932 27253 29556 29472 26217 27764 25970 8291 30068
28518 26112;
#K end;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P hidden newex 288 116 60 196617 loadmess 1;
#P number 288 175 35 9 0 512 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 184 347 49 196617 dac~ 1 2;
#P newex 184 175 44 196617 +~;
#P newex 184 304 54 196617 +~;
#P newex 184 258 41 196617 *~ 0.5;
#P newex 228 258 41 196617 *~ 0.5;
#P newex 228 228 70 196617 delay~ 512 1;
#P user ezadc~ 184 116 228 149 0;
#P window setfont "Sans Serif" 12.;
#P window linecount 2;
#P user com 184 57 114 196620 17;
#K set 0 21353 28016 27749 8289 30309 29281 26473 28263 8300 28535
11632 24947 29472 26217 27764 25970 11776;
#K end;
#P user panel 176 212 128 128;
#X brgb 191 191 191;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P connect 9 0 3 1;
#P hidden connect 10 0 9 0;
#P connect 4 0 6 1;
#P connect 3 0 4 0;
#P connect 7 0 5 0;
#P connect 7 0 3 0;
#P connect 6 0 8 0;
#P connect 6 0 8 1;
#P connect 2 1 7 1;
#P connect 5 0 6 0;
#P connect 2 0 7 0;
#P window clipboard copycount 12;

On Jan 4, 2008, at 12:32 PM, Brennon wrote:

>
> Hello all,
>
> I’m working through the second volume of Musimathics, by Gareth
> Loy, and learning quite a lot. I’d like to actually start
> realizing some of the topics he covers on my own in Max/MSP to help
> make them more concrete, and I’m having some troubles.
>
> For instance, I’m now reading about filters, and their supporting
> mathematics. As a rather simple example, I’d like to build my own
> lowpass filter in Max/MSP. I know how to implement one through the
> built in filtering objects in Max/MSP, but building one on my own
> will give me the opportunity to better understand what’s really
> occuring.
>
> He gives the equation for a lowpass filter thus:
>
> y(nT) = x(nT) + x[(n-1)T]
>
> where y(nT) is the input signal, n is an instantaneous sample, and
> T is time.
>
> His explanation of the operation of this filter makes perfect
> sense, but realizing it in Max/MSP is giving me problems. I’m sure
> there’s a simple answer, but I’m just not getting it.
>
> How would one realize such an equation? I appreciate your help!
>

—-
Steven M. Miller
Professor, Contemporary Music Program
College of Santa Fe

Home < http://pubweb.csf.edu/~smill>
SFIFEM <
http://sfifem.csf.edu>
Atrium Sound Space <
http://atrium.csf.edu>
OVOS <
http://pubweb.csf.edu/~smill/ovos.html>
CMP <
http://www.csf.edu/csf/academics/cmp/index.html>


January 4, 2008 | 8:36 pm

Quote: Falk wrote on Fri, 04 January 2008 12:52
—————————————————-
> Hi Brennon,
>
> Have a look at the bufir~ object. You can build finite response filters with up to 256 points.There is a patch in the examples folder called buffir-eq-help.pat using bufir~
>

I’m starting to see how buffir~ might help, but it’s abstracted the problem in such a way that I don’t really see how such an equation is really operating in the filter. Is there no way to build such a filter out of "rudimentary" objects?


January 4, 2008 | 8:38 pm

Quote: lists@grahamwakefield wrote on Fri, 04 January 2008 12:56
—————————————————-
> Unfortunately, you can’t get a 1 sample delay in a feedback path in a
> Max patch. You can use comb~ or biquad~ for example, but I don’t
> think that’s the autodidactic answer you were looking for…
>

So, how are such filters built? In a separate language? If so, what language is common?

Thanks again,
Brennon


January 4, 2008 | 9:42 pm

Quote: smill wrote on Fri, 04 January 2008 13:13
—————————————————-
> A couple things:
>
> 1) FYI – I recently got an email from Gareth re: the Musimat
> programming language he created to demo the ideas in the books. He
> gave me some detailed info on getting it to run on Intel Macs. I’ll
> check with him to make sure it’s OK to post the info here, and follow
> up accordingly.
>

That would be wonderful! I’ve fought with MUSIMAT quite a bit on Mac OS X to no avail. Although it seems that most of the music/DSP-related functions he has created seem relatively easy to implement in another language (classes in Java, etc.), I’d like to be able to play with MUSIMAT, as well. Please send my congratulations to him on these two excellent volumes. I’ve also struggled my way through the Digital Audio Signal Processing anthology edited by Strawn, and Musimathics has done wonders to fill in the holes for me.

> 2) I believe you have the interpretation of the equation slightly
> wrong: y is the output, x is the input. In a nutshell, a given output
> sample y(nT) is produced by averaging the current x(nT) and most
> previous x((n-1)T) inputs. There should, however, be some
> coefficients in there, in this case to multiply each of the two
> inputs by .5 before adding them, in order to average them. That’s
> what simple low-pass filtering is, averaging inputs to generate
> outputs. You could achieve this in MSP by using [delay~] set to one
> sample delay, and adding that to the direct signal after multiply the
> delayed and direct signals by .5. This will then give you the
> filtered (averaged) output. It achieves this by simply ‘slowing down’
> fast-changing signals (i.e. signals with high-frequency components).
>
> Hope this helps.
>

Thank you for the patch (I was mistaken in believing that delay~ took as it’s argument a number of milliseconds–not samples.) And yes, I did transpose x(n) and y(n)–thank you for drawing my attention to this. Either way, I do understand what the filter is doing, and it’s nice to see it in action–even if it is merely a simple example. Just a note, Loy does specify this primitive lowpass filter without averaging (at least at this point in the text).

Thank you again,
Brennon


January 4, 2008 | 9:51 pm

On Jan 4, 2008, at 12:56 PM, Graham Wakefield wrote:

>
> Well, you’d want to rearrange this to be in terms of the output
> signal:
>
> x(nT) = y(nT) – x[(n-1)T]
>
> So you subtract a 1 sample delay of the output from the input.
> Unfortunately, you can’t get a 1 sample delay in a feedback path in
> a Max patch. You can use comb~ or biquad~ for example, but I don’t
> think that’s the autodidactic answer you were looking for…

Again, to be correct, x is an input, y is the output, so the
explanation here is a little off. There are, however, filters of this
sort (output = average of input & output), but this isn’t the same
topology as the original question, which was an example of a simple
averaging FIR filter. For FIR (finite impulse response) filters, no
feedback is need. IIR filters need feedback.

A good reference for these types of filter equations is Dodge & Jerse
‘Computer Music, 2nd Ed.’ (pp. 201-219), and/or Roads ‘Computer Music
Tutorial’ (pp. 397-419).

—-
Steven M. Miller
Professor, Contemporary Music Program
College of Santa Fe

Home < http://pubweb.csf.edu/~smill>
SFIFEM <
http://sfifem.csf.edu>
Atrium Sound Space <
http://atrium.csf.edu>
OVOS <
http://pubweb.csf.edu/~smill/ovos.html>
CMP <
http://www.csf.edu/csf/academics/cmp/index.html>


January 4, 2008 | 9:56 pm

On Jan 4, 2008, at 2:42 PM, Brennon wrote:
>
> That would be wonderful! I’ve fought with MUSIMAT quite a bit on
> Mac OS X to no avail. Although it seems that most of the music/DSP-
> related functions he has created seem relatively easy to implement
> in another language (classes in Java, etc.), I’d like to be able to
> play with MUSIMAT, as well. Please send my congratulations to him
> on these two excellent volumes. I’ve also struggled my way through
> the Digital Audio Signal Processing anthology edited by Strawn, and
> Musimathics has done wonders to fill in the holes for me.

Agreed! I’ll post the info here if/when he gives me the OK.

>
> Thank you for the patch (I was mistaken in believing that delay~
> took as it’s argument a number of milliseconds–not samples.) And
> yes, I did transpose x(n) and y(n)–thank you for drawing my
> attention to this. Either way, I do understand what the filter is
> doing, and it’s nice to see it in action–even if it is merely a
> simple example. Just a note, Loy does specify this primitive
> lowpass filter without averaging (at least at this point in the text).

You’re welcome. See another post I just sent on this thread for other
references to filter equations & examples. Yes, Loy’s example does
omit the coefficients, but the classic examples I’ve seen all use
them in order to do actual averaging rather than simple addition of
successive samples. You can also manipulate the coefficients (as long
as they all add up to 1) to change the characteristics of the filter,
as well.

>

—-
Steven M. Miller
Professor, Contemporary Music Program
College of Santa Fe

Home < http://pubweb.csf.edu/~smill>
SFIFEM <
http://sfifem.csf.edu>
Atrium Sound Space <
http://atrium.csf.edu>
OVOS <
http://pubweb.csf.edu/~smill/ovos.html>
CMP <
http://www.csf.edu/csf/academics/cmp/index.html>


January 4, 2008 | 10:11 pm

Quote: smill wrote on Fri, 04 January 2008 14:51
—————————————————-
>
> A good reference for these types of filter equations is Dodge & Jerse
> ‘Computer Music, 2nd Ed.’ (pp. 201-219), and/or Roads ‘Computer Music
> Tutorial’ (pp. 397-419).
>

I do have the Dodge & Jerse. Thank you for drawing my attention to it again. I had pushed it to to the side when I started into Musimathics. I checked the Roads out of the library several times when I was a student, but never purchased it (quite pricey!) With what I do have handy (Loy, Dodge & Jerse, the Strawn anthology, and Allen Strange’s "Electronic Music…"), do you think the Roads will give me much more (at this point?) In which areas might it be stronger?

Thanks,
Brennon


January 4, 2008 | 10:11 pm

On 4 janv. 08, at 21:38, Brennon wrote:

> So, how are such filters built? In a separate language? If so,
> what language is common?

They are written in C. You can also write them in Java. You’ll find an
example of biquad in java in the "mxj~ examples" folder.

HTH,
ej


January 4, 2008 | 10:39 pm

In terms of the specific filtering info, I don’t think there’s much
‘value added’ in the Roads over the Dodge & Jerse. It is, however, in
general more comprehensive and wide-ranging. I recently heard from
Curtis that MIT Press gave the go-ahead on a new edition of it,
though, so you might want to wait until it’s out (he didn’t give me a
time frame…). I actually find that both books have strengths and
have slightly different takes on similar material, which is a help in
teaching.

On Jan 4, 2008, at 3:11 PM, Brennon wrote:

> I do have the Dodge & Jerse. Thank you for drawing my attention to
> it again. I had pushed it to to the side when I started into
> Musimathics. I checked the Roads out of the library several times
> when I was a student, but never purchased it (quite pricey!) With
> what I do have handy (Loy, Dodge & Jerse, the Strawn anthology, and
> Allen Strange’s "Electronic Music…"), do you think the Roads will
> give me much more (at this point?) In which areas might it be
> stronger?

—-
Steven M. Miller
Professor, Contemporary Music Program
College of Santa Fe

Home < http://pubweb.csf.edu/~smill>
SFIFEM <
http://sfifem.csf.edu>
Atrium Sound Space <
http://atrium.csf.edu>
OVOS <
http://pubweb.csf.edu/~smill/ovos.html>
CMP <
http://www.csf.edu/csf/academics/cmp/index.html>


January 5, 2008 | 10:09 am

A very nice book and a classic for intro to DSP with Java code in the back is:
Introductory Digital Signal Processing with Computer Applications, by
Lynn and Fuerst

specially if using linear difference equations (as per the low pass
discussed here)

Their example of a low pass and derivatives are very clear and informative.

here:

http://www.quantumbooks.com/p/03COMMS/0471976318

On 04/01/2008, Steven Miller wrote:
> In terms of the specific filtering info, I don’t think there’s much
> ‘value added’ in the Roads over the Dodge & Jerse. It is, however, in
> general more comprehensive and wide-ranging. I recently heard from
> Curtis that MIT Press gave the go-ahead on a new edition of it,
> though, so you might want to wait until it’s out (he didn’t give me a
> time frame…). I actually find that both books have strengths and
> have slightly different takes on similar material, which is a help in
> teaching.
>
>
> On Jan 4, 2008, at 3:11 PM, Brennon wrote:
>
> > I do have the Dodge & Jerse. Thank you for drawing my attention to
> > it again. I had pushed it to to the side when I started into
> > Musimathics. I checked the Roads out of the library several times
> > when I was a student, but never purchased it (quite pricey!) With
> > what I do have handy (Loy, Dodge & Jerse, the Strawn anthology, and
> > Allen Strange’s "Electronic Music…"), do you think the Roads will
> > give me much more (at this point?) In which areas might it be
> > stronger?
>
>
> —-
> Steven M. Miller
> Professor, Contemporary Music Program
> College of Santa Fe
>
> Home < http://pubweb.csf.edu/~smill>
> SFIFEM <
http://sfifem.csf.edu>
> Atrium Sound Space <
http://atrium.csf.edu>
> OVOS <
http://pubweb.csf.edu/~smill/ovos.html>
> CMP <
http://www.csf.edu/csf/academics/cmp/index.html>
>
>
>


A Pereshaped definition of an Apple:
"You will never know what size worm is in your next byte"!


January 7, 2008 | 9:43 am

For 1st and 2nd order FIR and IIR filters biquad~ is your friend. For
higher order filters there is the possibility of figuring out how to
translate the coefficients so that you can use cascade~.

Or you can make your own filters in C or Java. ASAIR there is a filter
example in the examples for mxj~. Java filters will be a bit less
efficient than filters programmed in C, but it’s way simpler to code
audio objects in Java for mxj~, so it could be a good point of
departure. There is also a filter example in the Max SDK.

Tim Place and myself are currently working on a new filter object that
will be a wrapper for all kinds of filters. Once we have it up and
running it should be fairly easy to add more filters to it. It will be
implemented using the TTBlue library and included as part of Jamoma.

Best,
Trond

Brennon wrote:
> Hello all,
>
> I’m working through the second volume of Musimathics, by Gareth Loy, and learning quite a lot. I’d like to actually start realizing some of the topics he covers on my own in Max/MSP to help make them more concrete, and I’m having some troubles.
>
> For instance, I’m now reading about filters, and their supporting mathematics. As a rather simple example, I’d like to build my own lowpass filter in Max/MSP. I know how to implement one through the built in filtering objects in Max/MSP, but building one on my own will give me the opportunity to better understand what’s really occuring.
>
> He gives the equation for a lowpass filter thus:
>
> y(nT) = x(nT) + x[(n-1)T]
>
> where y(nT) is the input signal, n is an instantaneous sample, and T is time.
>
> His explanation of the operation of this filter makes perfect sense, but realizing it in Max/MSP is giving me problems. I’m sure there’s a simple answer, but I’m just not getting it.
>
> How would one realize such an equation? I appreciate your help!
>
> Thanks,
> Brennon


January 7, 2008 | 6:21 pm

Quote: Trond Lossius wrote on Mon, 07 January 2008 01:43
—————————————————-
> Or you can make your own filters in C or Java. ASAIR there is a filter
> example in the examples for mxj~. Java filters will be a bit less
> efficient than filters programmed in C, but it’s way simpler to code
> audio objects in Java for mxj~, so it could be a good point of
> departure. There is also a filter example in the Max SDK.
>

Would you have any resources to recommend on programming filters in C?

> Tim Place and myself are currently working on a new filter object that
> will be a wrapper for all kinds of filters. Once we have it up and
> running it should be fairly easy to add more filters to it. It will be
> implemented using the TTBlue library and included as part of Jamoma.
>

I look forward to it! Should I just watch maxobjects.com for updates? Or, is there somewhere else I should check?

Thanks for your help,
Brennon


January 7, 2008 | 8:05 pm

Hi Maxers,

OK, having got the green light from Gareth to post this, here’s some
basic instructions for getting Musimat to run on a Mac. He asked me
to alert folks that a much nicer graphical version, based on XCode on
Intel Macs, will be coming soon. Check the Musimat website for that
< http://www.musimat.com/>.

Best,

Steven

—————
From Gareth:

Steven,
I got the Musimat tutorial working on my Mac! It was relatively
straightforward. Here’s what I did.

o I downloaded Musimat.zip from http://www.Musimat.com. The Mac unzipped
it automatically and placed it as a folder on my desktop.

o I dragged the folder to be a subdirectory of my username
(garethloy for me), for convenience.

o I had to install the latest development tools from Apple to pick
up the g++ compiler and make program. There’s two ways to get these
tools.

1) Via your Mac OS X Install Disk. There should be an Xcode Tools
folder on Install Disc 1. Open it and launch XcodeTools.mpkg. When
you get to the "Installation Type" step in the installation wizard,
click the Customize button. Be sure you get Developer Tools
Software, and either gcc 3.3 or gcc 4.0 (depending on which version
of Mac OS X you have). I don’t think you need anything else.

OR

2) Via the Apple Developer Connection. Go to http://
developer.apple.com and click on "Download latest Xcode" under Quick
Links. You have to be a member of ADC, but that’s free. Just set up
an account and get the download. Choose the same elements to install
as described above.

o Now you are ready to build and run the Musimat tutorial.

o Launch the Mac terminal window. In the Finder, double-click on
Applications/Utilities/Terminal. This is effectively a UNIX shell.

o cd to the Musimat root directory. In my case it’s /Users/
garethloy/Musimat because that’s where I placed the Musimat folder
after it was downloaded. A shorthand for this directory is ~/Musimat.

$ cd ~/Musimat

o Issue the make command:

$ make

o Sit back and watch it compile and link… or not. I hit a snag.
It compiled for a while then complained Undefined symbols:
__Unwind_Resume. Google eventually told me that a Makefile was
trying to use gcc instead of g++ to link the compiled objects. The
fix is to edit all files named Makefile and change the line "CC =
gcc" to "CC = g++". You might or might not need to do this depending
upon the version of Xcode tools you are using. I used the vi editor
because I’m familiar with it, but you can also just edit them using
TextEdit.

$ vi ~/Musimat/*/Makefile

o I’ll eventually fix the sources at http://www.Musimat.com to fix this
problem, but it won’t be for a while.

o Eventually you will succeed in compiling all the applications.
Files named *.exe are created in each subdirectory of ~/Musimat.

o For example, cd to Musimat/MusimatChapter9 and execute Chapter9.exe.

$ cd ~/Musimat/MusimatChapter9
$ ./Chapter9.exe

o (You have to say ./Chapter9.exe instead of just Chapter9.exe
because ".", the current working directory, is not in the PATH
variable by default.)

o The standard output of this program executes all the functions
discussed in Chapter 9. It goes by rather quickly! To slow it down
and watch it execute, run a debugger, such as gdb. For example,

$ gdb Chapter9.exe

o Type help to get info on gdb. But for starters, try the following
to set a breakpoint in main and then execute that far:

(gdb) help
(gdb) b main
(gdb) run

o You can then single-step the program, examine variables, etc.

(gdb) step
(gdb) list

There are better ways to use gdb than this, such as running it with
Emacs (if you know Emacs). This has the advantage of showing the
source code graphically rather than a line at a time. Another
alternative is to use SlickEdit, which is a terrific IDE/GUI. You
can get a trial for free off the web.

Let me know how it goes. Since you are my first Mac customer, you
can be my guinea pig.

Best,
Gareth

—-
Steven M. Miller
Professor, Contemporary Music Program
College of Santa Fe

Home < http://pubweb.csf.edu/~smill>
SFIFEM <
http://sfifem.csf.edu>
Atrium Sound Space <
http://atrium.csf.edu>
OVOS <
http://pubweb.csf.edu/~smill/ovos.html>
CMP <
http://www.csf.edu/academics/contemporary_music/>


January 9, 2008 | 4:59 am

Beautiful! Thanks, Steven!

–Brennon


January 9, 2008 | 9:56 am

Hi,

for building externals in Max in general the MasMSP SDK is an absolute
must. In addition you need a development environment installed (Xcode on
Mac).

If you have not programmed Max externals before, I would recommend
taking a look at the documentation for how to develop Java code for xj
and mxj~. The code is simpler and less techy to read and understand than
C/C++ code for externals, but still provides a good intro to general
concepts of what an external is made.

If you have not been programming in C or C++ before, I would recommend
that you get yourself a book providing an intruction to the languages. A
good reference is also handy. I don’t have particular suggestions for
litterature, but I’m convinced that you’ll find plenty at Amazon or
O’Reilly.

And apart from that, source code and projects for other externals that
are somewhat related to what you want to work on yourself is always
instructive.

If you have Xcode, SVN and the MaxMSP SDK installed, you could check out
the active branch of TTblue. If you have no prior experience with SVN,
you could check the Jamoma wiki at http://www.jamoma.org for information.

The TTBlue repository is available here:

http://electrotap.net:9004/ttblue

and there’s a mailing list for ttblue development:

https://lists.sourceforge.net/lists/listinfo/ttblue-devel

Best,
Trond

Brennon Bortz wrote:
> Quote: Trond Lossius wrote on Mon, 07 January 2008 01:43
> —————————————————-
>> Or you can make your own filters in C or Java. ASAIR there is a filter
>> example in the examples for mxj~. Java filters will be a bit less
>> efficient than filters programmed in C, but it’s way simpler to code
>> audio objects in Java for mxj~, so it could be a good point of
>> departure. There is also a filter example in the Max SDK.
>>
>
> Would you have any resources to recommend on programming filters in C?
>
>> Tim Place and myself are currently working on a new filter object that
>> will be a wrapper for all kinds of filters. Once we have it up and
>> running it should be fairly easy to add more filters to it. It will be
>> implemented using the TTBlue library and included as part of Jamoma.
>>
>
> I look forward to it! Should I just watch maxobjects.com for updates? Or, is there somewhere else I should check?
>
> Thanks for your help,
> Brennon
> –
> Brennon Bortz
> Composer / Engraver / Nutcase
>


January 10, 2008 | 6:58 am

Looks like I just need to check out SVN, then. Thanks for the great advice, Trond!

Best,
Brennon


April 6, 2011 | 2:25 am

I have a question, how i Must upload musimath? Is it possible to adapt some bit of code in MaxMsp.


April 24, 2012 | 2:25 am

The best way is simply to use MatLab to generate the coefficients (using the fdatool in their DSP toolbox) and then MAX can process the audio.. Both F I R & I I R filters are available.
MatLab will also process an entire sound file (not real-time) , something MAX doesn’t do .. yet.
I had the requirement to use a FIR filter to cut some noise from an field recording, and the EQs in Logic Pro, Soundtools and Ableton were lame.. an FIR can produce some impressive specs, but at 300 -1000 computation per sample, it’s not very suitable for live work


April 24, 2012 | 3:19 am

True, FIR coefficients can be difficult to compute if you’re unfamiliar with the math (but there’s also the ifft~ trick: design the desired freq response, then feed it into through ifft~…the output of ifft~ IS the impulse response for the fir filter!), but Max6 and filterdesign can create all sorts of IIR filter shapes such as the Chebychev and Butterworth filters, so you can actually get some quite steep curves. (which can also be cascaded if you need, say, a shelf and a lowpass, etc.)

In short, Max can do much more than it used to, and there’s a lot that’s worth checking into.


Viewing 22 posts - 1 through 22 (of 22 total)