Forums > Java

Iterative/non linear/chaotic Equations at audio-rate

August 4, 2010 | 12:07 pm

Hi,
I’m trying to build a chaotic oscillator external – based on coupled neurons – in Java. I’m happy with the maths behind it, but it’ll be my first Java project and if I’m honest I’m more or less a total Java n00b.

To get me started I’m just looking for any similar mxj~ implementations of iterative/chaotic signal processing to give me an idea of how other people have done this – signal rate Lorenz attractors/logistic maps etc. Any ideas/ pointers would much very much appreciated.

(Btw – I realise this might seem a bit ambitious for a first Java project (it might not – I have no idea). It’s just hat personally I always find I learn best by just jumping in with a specific problem to solve, hacking other peoples’ code etc. and making all the mistakes for myself – if only because I have a specific reason to do it and that keeps my interest through the inital boring bits. I’d rather hack away at something that’s way beyond me for weeks than work through tutorials – at first anyway. Tutorials are good once I’m over the hump.)



efe
August 4, 2010 | 2:19 pm

If you are interested on chaotic filters maybe you should take a look here:

http://github.com/sbl

it is project developed by Stephen Lumenta which ports part of the SuperCollider UGens into msp(search the sc-max project). Among the ported materials you can get the Gendy-family. Sergio Luque wrote a really interesting thesis about it:

http://www.sergioluque.com/texts/luque_stochastic.pdf

The original UGen included different types of interpolations and itself is a very interesting source of study. Maybe it is a good starting point.

-emmanuel


August 4, 2010 | 4:43 pm

Hi Emmanuel – those links look really interesting. I’m a huge fan of Xenakis and interested in his stochastic synthesis method, so I’ll definitely be taking a look at those links. Thanks for the links.

It’s not quite what I’m asking for here though. Although the word "chaos" does bring to mind noise, there’s a difference between "stochastic" and "chaotic". Xenakis was focusing on random distributions, whereas mathematical chaos is not random but determinate given particular starting conditions – it tends to come from feedback relationships and recursive algorithms which take the output(s) of the previous step as their input(s) for the current step.

I’m looking for implementations these kind of recursive algorithms at audio rate, and specifically in MXJ~ so I can use this as a starting point to try out other determinate chaotic algorithms .

Thanks
Dan


August 4, 2010 | 5:41 pm

Hello dan b,

if you are "happy with the maths behind it" and if you are a java noob, why not coding it directly in C (with the max SDK) ? may be more easy to find DSP examples in the API ?



efe
August 4, 2010 | 6:30 pm

Hello Dan~
Indeed, stochastic and chaotic have different connotations. My point is that it would be interesting to take a look into the conversions made by Stephen Lumenta and grab inspiration(and technique) from them. When it comes to audio I am much familiar with sc than msp so I don’t know how many tweaks were needed in order to do the porting. The UGens are written in C++(though the sclang is a kind of smalltalk dialect), meaning that(theoretically) it would be easier to convert them into c(or c++)-based msp externals than java-based object. So as pizza olives suggest, maybe it is a better idea to download the SDK and read the API for writing externals. As you mentioned before, if you feel better modify pre-exisitng code this could be a good chance.
Please keep us posted about your progress, I would be interested in see(and listen) the results!
-emmanuel


August 5, 2010 | 9:32 am

Ta both, – and thanks for the clarification Emmanuel, I see your point now. Apologies if my post was a bit patronising.

Unfortunately I’m as much of a C n00b as I am a Java n00b. With the nice integration of Java Max and its portability across platforms I’d far rather start out on Java. I understand the languages are very similar though, so I’ll take a look at these and see what I can glean from them. Thanks.

And yep I’ll post the results up as soon as I have any. I’ve posted a PD expr~ implementation in one of my other threads if you’re interested.



efe
August 5, 2010 | 10:47 am

On the contrary Dan, thanks for sharing your views.
One last thing(based on my reduce experience): indeed, java is much easier to start with BUT it is significantly less documented than the SDK. That situation can make a BIG difference.
good luck!
-emmanuel


August 5, 2010 | 12:55 pm

if you don’t have any experience in writing externals (c or java), and simply want to experiment with code a little to get going, i’d say you are better off trying java. with mxj/mxj~ it’s really easy to do the first steps.
a lot of info and learning material already comes with the max5 installation.
make a bookmark of the api (Applications/Max 5/java-doc) in your favorite browser, take a look at the tutorial, check out the mxj~ examples and peek inside WritingMaxExternalsInJava.pdf.

and here is a stripped to the bones example of a simple mxj~ external.
(hopefully the formatting isn’t mangled by the forum software…)


import com.cycling74.max.*;
import com.cycling74.msp.*;

public class logistic extends MSPPerformer
{
private double xm1 = 0.1;
public double r = 3.6;

public logistic () {
declareInlets(new int[]{DataTypes.FLOAT});
declareOutlets(new int[]{SIGNAL});
createInfoOutlet(false);
}

public void reset() {
xm1 = 0.1;
r = 3.6;
}

public void inlet(float f) {
if(f>1 && f< =4) r = f;
}

public void perform(MSPSignal[] ins, MSPSignal[] outs) {
//float[] in = ins[0].vec; // we don't have signal inlets
float[] out = outs[0].vec;
int vs = outs[0].n;
double x;

for(int i=0; i
x = r*xm1*(1-xm1);
xm1 = x;

out[i] = (float)x;
}
}
}


August 5, 2010 | 1:56 pm

Thanks Volker – that’s really helpful, it’s exactly what I was looking for.
I’ve been reading through the WritingMaxExternalsInJava.pdf too – it’s a very good intro.

The code is far simpler than I expected, and I think I understand most of it, which gives me confidence. I’ll play with this alongside the bundled examples and try to hack something together.

Thanks again
Dan


May 16, 2012 | 11:20 pm

Hey Dan,

Make any progress? I’m interested in doing the same thing.

Cheers,
Jesse


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