Translating SC patches to max

Im interested max. Is it hard to translate SC ideas to max? Specifically pattern ideas? Any tricks? Or is it a whole different approach?
Thanks

Rant incoming:

Graphical patching is a right bloody pain in the sit-upon for typical “computer science-y” types of things. I wouldn’t advise it. Part of the reason for Max’s JavaScript object is to provide an alternative to the deficiencies of graphical patchers when it comes to classical algorithms. Patchers can do looping and branching (so, if I’m not abusing a term, they are Turing complete, though someone might correct me on this), but it’s all much more laborious, both physically and mentally. Patching fans like the idea that “patching isn’t programming” so there’s not much of a formal methodology to handle basic flow of control – took me ages to figure out on my own that [t . . . .] is the patching equivalent of an expression series in other languages (and good luck if you forgot one [t] output signifier).

In SC, a stream made from a pattern has an arbitrarily rich state, including the full call stack. In Max/Pd, unless I’m missing something, you can bang an object or subpatch to push it forward but if there are patterns nested inside that, it will be difficult to forward the bang to one of multiple yield points inside a nested structure. Basically you’d be managing the call stack by hand, which is… gosh, that kind of thing is pre-Fortran, even. Too complicated to obtain a result that’s easy in languages that have coroutines.

I’m biased: I don’t like patching. I made peace with it and I can do it if I have to (I just used GEM in Pd for graphics in a concert, but the audio was in SC), but… it’s like walking waist deep in molasses. It’s tiring and I prefer to avoid it whenever possible.

hjh

4 Likes

I think I’m just going to use max as a bridge for modalys , unless someone builds something in sc, it is that cool,

use sc to make beats, and have one pattern sending osc to max .
I’m having a hard time with the options. Really trying to simplify my workflow and make a list of what exactly I’m after, there is sooo much to choose from

With latest Max 9 you can use codebox everywhere (not only i gen) and combine it with patching.

Is there a way to look somewhere in the source to see how Pdup and other patterns are made ? I imagine they are created with routines and stuff, but I’m not complete on the understanding , thanx

I thought it was Cmd-i but I’m not sure if that is the source code.

Would be nice to be able to have sc in Max, especially the patterns, isn’t that what sc was originally?
Max is kind of brute force, but it is easy to plug things together and go, but the sequencing has always been crap

It’s not simple (I don’t fully understand it either), but you can look in the Patterns.sc file to get an idea of how patterns are implemented

(You’re right, cmd-i looks up the implementation of a class or method)

For some enlightenment, maybe start here?
https://doc.sccode.org/Tutorials/A-Practical-Guide/PG_Ref01_Pattern_Internals.html

I’m curious whether Pyrite (the SC ancestor that was a max object) had anything like patterns

A specific pattern’s implementation is mainly in its embedInStream method, e.g. Pdup, with my annotations (not in the source):

	embedInStream { arg event;
		var inevent, nn;

		var stream = pattern.asStream;
		var nstream = n.asStream;

		while {
			// here it gets the thing to be repeated
			// `inevent` is a really unfortunate misnomer btw
			// this is unnecessarily confusing!
			// but this is the OUTPUT thing, not the input
			(inevent = stream.next(event)).notNil
		} {
			// here it gets the number of times to repeat
			if((nn = nstream.next(event)).notNil) {
				// and now it loops that number of times and sends out a copy of the output thing
				nn.abs.do {
					event = inevent.copy.yield;
				};
			} { ^event };  // exit upon nil
		};
		^event;  // exit upon nil (while loop ends)
	}

hjh

1 Like

Some Patterns are stateful, which is one of the other variants. Comparing some Patterns reveals that they are very different kinds of operations.

Does this model come from other experiments, or is it a JMC design?

Yes, it is entirely possible to do it all in Max, it just takes way more engineering, and the concepts are not particularly easy to make modular and reusable; You cannot easily arbitarily chain operations to change a sequence like you would using the the pattern classes within SC. I started using Supecollider specifically because of this difficulty with sequencing in Max, and have found it to be a much more expressive system so far.

Thank you. Im not a natural coder. I can do stuff, but the patterns just become numbers in the end right? Maybe the idea can be realized in max somehow.
I was thinking jitter is closest to patterns really. With the physics and the spatial ability of the objects. It’s very powerful, but im just taking a cursory glance at max at the moment.

Some things are easy: Pseq (advance on demand through a list), Pwhite (random number on demand), things like that.

Where you will have difficulty is: choose randomly from one of the following patterns, but don’t choose the same subpattern twice in a row, and let each subpattern run to completion before choosing the next subpattern.

SC: Pxrand([subpattern, subpattern, subpattern...], inf)

Max: The glue between the subpatterns will be painful. I’m opinionated, but patching is really terrible for this type of requirement.

hjh

1 Like

Here’s Pwhite, in Pd (plugdata interface here):

Already, handling the stop condition gets a bit icky, but “if you’re used to patching then it’s not so bad” :wink:

Then, Pseq([Pwhite(0.0, 1.0, 5), Pwhite(10.0, 15.0, 3), Pwhite(-2.0, 2.0, 10)], inf). (Should be OK in Pd vanilla + cyclone externals.)

Let’s say the idiom does not exactly roll off the tongue. It “can” be done, sure, but with a lot less flexibility and a lot more trouble than SC’s coroutine-powered approach.

Max will have minor differences (use [split] instead of [moses], and [gate 1] instead of [spigot]) but should be basically the same.

hjh

1 Like

EDIT: Sorry, wrong thread to write that. I will maybe delete this and eventually I will write a separate one with more details maybe.

Im sorry, I didn’t know what stop condition was , I had to ask Calude. lol. It’s a little pattern timeline, length? I guess.
Sounds like the new coding box additions added to max is the answer. SC can be a big pill to swallow if you are a visual based person. I can see he code and how its plugged into itself… But there is a lot of abstract stuff too. Autechre make really cool stuff in max. I think it’s all phasor / oscillator. Oscillators and sample and hold maybe. or shift register. Im not sure. They study other hardware sequencers and try and take ideas from those. But most sequencers are basic stuff.

1 Like

Yeah, if you want to sequence several patterns in a row, then each of the subpatterns needs to stop. In SC, with coroutines, “stop” is simply exiting from the loop – i.e. James McCartney designed the language with features to make this use case easy. Max/Pd don’t have those features, so then it becomes a matter of passing messages through or blocking them under the right conditions. It’s a different way of thinking – and what you don’t see in my screenshots are the 3-4 versions before this but didn’t behave correctly (i.e. in SC, we can write a something.do in an embedInStream method, and done, but in Max, I had to debug a bit of a tangle = time spent not creating art – and my patching style is cleaner than a lot of hacks that you’ll see around).

There’s been JavaScript in Max for a long time. Codebox improves upon code integration but coding-in-a-patch is not a new feature.

hjh

1 Like

Have you any Pdup or stutter pics in Pure Data you’ve done? There must be a way to mess with Arrays in Max, but any photos of conversions might be a big help

To be honest, part of the point of my screenshots was to illustrate why I have no interest, desire or time to develop “patterns in pd” in any sort of systematic way.

That is: Answer is no, and it will continue to be no for the foreseeable future.

hjh

1 Like

I get it, but maybe there is an easier way to do this? People find SC hard. Not the other way around. I guess if you know SC back to front and spent 2 decades on it that’s a different matter. I know a bit of SC, but I feel like I wont really reap the benefits of its true power until im 60. Im doing some final reading to undestand OO thinking and how SC is approached. Ive read practice guide. All the pattern intros and stream guides. P{plus other Help files. I’ll read the Eli Fieldsteel manual, after that. I think im switching to max cause im visual. I’ll alway be behind with SC. It is very cool . I made a nice patch for my s612. Maybe I’ll record its midi output I dont know. I also made an editor (with the help of Ai) for the akai s612 I intend to keep using, but im in over my head with sc. Everyone I ask who is really great at it says it took them over ten years to really get advanced. Not for everyone, of course, but it seems that way

As I tell my students: if it is easy in Max, it is hard in SC. If it is easy in SC, it is hard in Max.

Pick the axe you want to wield. Whichever one works the way your brain works. No one will be offended. I chose this tool because my brain works this way.

That being said, questions about Max should probably go to the Max forum. People over there will be glad to help you out.

2 Likes

I was thinking that today. Max is so gui friendly. Not so much for sc. I wish I was a coder. A true coder. My friend has a degree in programming. His stuff is great naturally. If we could put the pattern system in max, We’d have it perfect…
For me :slight_smile:
At least the Value patterns
There is some stuff like that. Maybe someday