Forums > Dev

scripting external

March 6, 2008 | 7:35 am

Hi,

I was trying to design a toolkit for a hardware by building max externals. The original library was in C++. I’m more familiar with C++ programming. I’ve pretty much transfered the library into externals.

However, I find it cumbersome sometimes to use max to design game logic for example. It is quite troublesome to do simple things like for loops and some if statements etc. Is there any external around that perhaps allow some script-like C++ commands to be written in a graphical object in the editing screen for max?

Also, how can i create graphical externals with a "drag and drop" interface? For example, I want to make a 9*5 board which i can drag and drop various items like vst instruments or effects so that when that board is click it next time that synth is triggered. My idea is that this will facilitate making simple applications for new programmers on my hardware.

Cheers,
Wei Min


March 6, 2008 | 1:39 pm

There’s actually a lot of options like this at present for max/msp.
One of the primary reason I wrote the original rtcmix~ object was to
deal with exactly the kind of logic you mention. From a textedit
object, or in an internal rtcmix~ buffer, you can say something like:

time = 0
for (i = 0; i < 7; i = i+1) {
MAXMESSAGE(time, i, irand(0, 14.8), trand(21, 25))
time = time + 0.49
}

and it will output lists of [(integer 1 to 7), (random float between
0 and 14.8), (random integer between 21 and 15)] every 0.49 seconds,
seven times. chuck~ has similar capabilities within the syntax of
the Chuck language.

And this is only one option. Max itself has java and javascript
imbedded in it, and the new ruby and python objects look very
exciting. And if you’re totally insane you can even use maxlispj and
eval lisp expressions.

brad

http://music.columbia.edu/~brad

On Mar 6, 2008, at 2:35 AM, Wei Min wrote:

>
> Hi,
>
> I was trying to design a toolkit for a hardware by building max
> externals. The original library was in C++. I’m more familiar with C
> ++ programming. I’ve pretty much transfered the library into
> externals.
>
> However, I find it cumbersome sometimes to use max to design game
> logic for example. It is quite troublesome to do simple things like
> for loops and some if statements etc. Is there any external around
> that perhaps allow some script-like C++ commands to be written in a
> graphical object in the editing screen for max?
>
> Also, how can i create graphical externals with a "drag and drop"
> interface? For example, I want to make a 9*5 board which i can drag
> and drop various items like vst instruments or effects so that when
> that board is click it next time that synth is triggered. My idea
> is that this will facilitate making simple applications for new
> programmers on my hardware.
>
> Cheers,
> Wei Min


March 7, 2008 | 3:33 am

hey,

I was looking up script at maxobject.com and your external didn’t turn up. Was looking for something that resembles C language more. Thanks.

Any idea how to make graphical "drag and drop" externals?

Cheers,
Wei Min


March 10, 2008 | 3:29 pm

Quote: Bradford Garton wrote on Thu, 06 March 2008 14:39
—————————————————-
> From a textedit
> object, or in an internal rtcmix~ buffer, you can say something like:
>
> time = 0
> for (i = 0; i < 7; i = i+1) {
> MAXMESSAGE(time, i, irand(0, 14.8), trand(21, 25))
> time = time + 0.49
> }
>
> and it will output lists of [(integer 1 to 7), (random float between
> 0 and 14.8), (random integer between 21 and 15)] every 0.49 seconds,
> seven times.
—————————————————-

What’s wrong with

#P inlet 61 16 15 0;
#P outlet 61 267 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 106 210 42 196617 * 14.8;
#P newex 61 242 101 196617 pack 0 0 0;
#P newex 106 187 42 196617 lp.shhh;
#P newex 151 186 72 196617 lp.tata 21 25;
#P newex 61 163 100 196617 t i b b;
#P newex 97 134 21 196617 t 0;
#P newex 97 110 33 196617 sel 1;
#N counter 1 7;
#X flags 0 0;
#P newobj 61 86 66 196617 counter 1 7;
#P button 61 38 15 0;
#P newex 61 60 60 196617 metro 490;
#P connect 11 0 1 0;
#P connect 8 0 10 0;
#P connect 6 0 8 2;
#P connect 9 0 8 1;
#P connect 5 2 6 0;
#P connect 7 0 9 0;
#P connect 5 1 7 0;
#P connect 2 0 5 0;
#P connect 5 0 8 0;
#P fasten 4 0 0 0 102 157 148 157 148 55 66 55;
#P connect 3 0 4 0;
#P connect 2 2 3 0;
#P connect 0 0 2 0;
#P connect 1 0 0 0;
#P window clipboard copycount 12;

?

(The Litter Power objects are in the Starter Pack, URL below)

There is no problem with designing loops and conditionals in Max, you just need to get used to the idiom. If you’re programming in C++ you get used to the object idiom; if you’re working with Perl you get used to the regexp idiom; if you program in LISP you get used to the list idiom.

Yes, of course each idiom takes getting used to. But I do wonder what response someone would get on a Perl list on writing "gee, I just can’t get used to this s/ +/t/g" business"?


March 10, 2008 | 3:34 pm

Quote: tiutababo wrote on Fri, 07 March 2008 04:33
—————————————————-
> hey,
>
> I was looking up script at maxobject.com and your external didn’t turn up. Was looking for something that resembles C language more. Thanks.
>
> Any idea how to make graphical "drag and drop" externals?
>
> Cheers,
> Wei Min
—————————————————-

Externals *are* written in C.

Abstractions are what we call patches written in the Max graphical programming environment, saved for re-use in other projects.

If you want to write in C (not C++), look at the Max/MSP SDK available on this HTTP Server. However, I would *strongly* recommend developing fluency with the Max `patching’ environment first. If you don’t grok the graphical programming environment, it is almost impossible to develop external objects that will work well in that same environment.


March 10, 2008 | 3:41 pm

Dang. Bug in the sample patch (that’s what I get for not testing). Change [pack 0 0 0] to [pack 0 0. 0].

BTW, this thread is likely to get yanked over to the main Max list. As it stands, that’s more where it belongs.


March 10, 2008 | 3:46 pm

On Mar 10, 2008, at 11:29 AM, Peter Castine wrote:

> Yes, of course each idiom takes getting used to. But I do wonder
> what response someone would get on a Perl list on writing "gee, I
> just can’t get used to this s/ +/t/g" business"?

True, but the point is that with all the snazzy stuff available
(including your terrific Litter work!), you can ‘choose your poison’
to a certain degree. And I don’t buy the notion that a idioms/
methodologies are transparent; I believe they exert a subtle-but-
potentially-profound influence on our thinking. I guess this is my
programming-language take on the [somewhat discredited but still
interesting] Sapir-Whorf Hypothesis. Use what seems most congenial
to your way of conceiving music. Know what range of tools are
available, and know what they do to you.

brad

http://music.columbia.edu/~brad


March 10, 2008 | 5:57 pm

Peter Castine wrote:
> There is no problem with designing loops and conditionals in Max, you just need to get used to the idiom.
>
Well, I’m afraid I have to argue about that. Actually, you can’t
designing loops in Max ‘natively’ (as for conditionals there are a lot
of different native Max objects). Of course one can solve the problem
with counter etc. objects, so there are hundreds of possible
workarounds, but I never really felt that the Max environment was
designed to support the programming concept of loops. Of course, it’s
much more hard to define what the loop concept actually means in a world
like Max, so I can absolutely understand the lack of a ‘native’
implementation of the ‘do-while’ or the ‘for’ concept. But I think one
has to admit that this feature is missing absolutely from Max. (Well, as
I told before, you can make lots of different workarounds, of course.
But there’s actually nothing you couldn’t solve with some workaround in
Max… :-) )

Cheers,
$adam


March 12, 2008 | 11:28 am

Quote: sadam wrote on Mon, 10 March 2008 18:57
—————————————————-
> Well, I’m afraid I have to argue about that. Actually, you can’t
> designing loops in Max ‘natively’
—————————————————-

I would counter (ahem;-) that uzi and counter are quintessentially native constructs for controlling loops in Max.

What was not ‘native’ about the patch I posted earlier in this thread?

I suppose this is a point of view thing: if you’re determined that the way to perform a loop is to have a [for] object with the arguments , well then you don’t have a bundled object (there *is* a 3PO, search maxobjects). But when I read ‘for(i = 0; i < 7; i++)' I immediately see [Uzi 7] in Max. And when I read 'if (blah) { foo; } else { faz; } I immediately see a gate controlling two alternate dataflow paths.

But maybe I’m just weird.


March 12, 2008 | 11:38 am

Quote: Bradford Garton wrote on Mon, 10 March 2008 16:46
—————————————————-
> And I don’t buy the notion that a idioms/
> methodologies are transparent; I believe they exert a subtle-but-
> potentially-profound influence on our thinking.
—————————————————-

Fair enough. And having lots of options is great. I just think the strength of rtcmix~ is more that you can do real-time CMIX things in it. The fact that you can use C-style for(init; cond; incr) constructs runs a far second place.

And I would argue that learning to use Max effectively also includes learning to implement iteration constructs natively in the language. It does take some getting used to, but once you’re used to it, you’re set to groove.

On the transparent idiom front, I would just add that in natural languages there are a *lot* more idiom idiosyncrasy issues, and that’s also something that people learn to deal with. But that’s a whole ‘nother thread for a different forum.


March 12, 2008 | 2:44 pm

On Mar 12, 2008, at 7:28 AM, Peter Castine wrote:

> But when I read ‘for(i = 0; i < 7; i++)' I immediately see [Uzi 7]
> in Max.

what if you wanted time to pass within your loop?

…just to reinforce brad’s point about languages shaping the way we
think about things….

it’s all good!

dt

[yes yes, i know you can do it with pause and continue and delay, but
that only illustrates the point that these look/feel quite different,
so it's nice to have options]


March 12, 2008 | 4:05 pm

On 12 Mar 2008, at 14:44, dan trueman wrote:

>> But when I read ‘for(i = 0; i < 7; i++)' I immediately see [Uzi 7]
>> in Max.
>
> what if you wanted time to pass within your loop?

[Gattling 7]

(I have one somewhere – I wrote it back around 1992…)

– N.

Nick Rothwell / Cassiel.com Limited
http://www.cassiel.com
http://www.myspace.com/cassieldotcom
http://www.last.fm/music/cassiel
http://www.reverbnation.com/cassiel
http://www.linkedin.com/in/cassiel
http://www.loadbang.net


March 12, 2008 | 11:22 pm

Quote: dan trueman wrote on Wed, 12 March 2008 15:44
—————————————————-
> what if you wanted time to pass within your loop?
—————————————————-

Dan: did you even *look* at the example patch I posted at the beginning of this thread?

Before I return to your question in Max, how do you deal with time in a C/C++ for() loop? Because C/C++ was what the original question was about.

Simula has a concept of time. Smalltalk has a concept of time. C doesn’t really have any notion of time at all (embedding a wait() call inside a for() loop doesn’t really cut it, and threading is a layer on top of the core C language).

Back to your question: if you want time in the loop, you use metro and counter. As I did in the example patch I posted.

Peter

– Who is as aware of the extent to which language colors thought processes as anyone. I’m dealing with at least three natural languages every day as well as a fistful of programming languages.


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