page 1 | 13 posts new topic Store  
thread starter

So, i'm in the design stages for a project that I hope will ease my future perform.patch coding. I got a bcr 2000 not too long ago and quickly found that the endless encoders with visual feedback make it possible to multiply the number of controllable parameters several times. there are 16 buttons in the center of the BCR, and 24 knobs on the bottom. I created a max patch that makes each of the buttons a 'page select' button; the patch stores 16 sets of 24 knob positions (each set being a 'page'). If the functionality isn't clear at this point, then plz let me know. The point is that all the sound making happens in max, but maximal command flow is diverted to java.

For a variety of reasons, I've decided that I want to make a java package to handle most of the tasks, such as preset storage, recall, sequencing, and persistence (file IO). So, i'll have the following classes:

controller: value and description (derived classes include button, knob, and on-screen control)
page: has controllers and instruments. methods include store/recall preset, save/read to file.
instruments: an oscillator has FM and PWM, LFO's have just FM, etc. basically, the members are just a set of knob descriptions. However, these are the objects that condition controller data for sending out to max.
some kind of 'book', top level class, which has pages, directs midi input to appropriate pages, sends output to max as instructed by the instruments.

So, my question is: I want a page to be the main 'owner' of all the controller objects. But, I want to have the instruments as separate classes that somehow refer to the controllers of the pages. Sorry for the long preamble for this rather simple question, but i'm new to java and i'm not sure how to do this.

What needs to happen is:
1) i turn a knob on the bcr, the book knows what page we're on and directs the midi data to the right page. The page looks at the controller number and directs the data to the right instrument. The instrument generates the appropriate string to send to max and returns it all the way up to the book which passes it to max, where the synthesis happens.
2) hit a page button on the bcr. Book directs the right page to dump all controller data back to the bcr.
3) preset saving and recall to/from ram and file. These operations should all be controlled by the pages.

anyway, it was helpful for me to write all this. hopefully y'all are also entertained
Recent Blog: ring mod idea  
Replies

i felt entertained, but can't provide any insight.

but i'm really interested, in what you come up with. might put some use to my bcr collecting dust on a shelf

I don't know how far you've gone into java, but you might have encountered this chestnut -- there is no such thing as function pointers, and hence no things like function callbacks. So what happens is you have to define an interface and then start registering that with any object that you want that eventually calls back to the initial calling object. And then you'd want to have a Data object that encapsulates whatever data that needs to be passed. After that just register to each other to simulate routing and bang away.

well, i konw there are no pointers. i'm having a bit of trouble following what you've written.

I'm not sure what the interface you're describing is supposed to do.

Let's make this a little more concrete with some examples

[code]
class terroristEnclave {
// members
terrorist[] cell;
bomb[] weaponsCache;

// contstructor
terroristEnclave {
// instantiate terrorists
// assign bombs to terrorists
}

// methods
void muhammedJihad() {
foreach (jihadi in cell) {
if (jihadi.rightWithGod()) {
jihadi.goExplodeThings();
}
}
}

int durkaDurka() {
int count=0;
foreach(holyInstrument in weaponsCache) {
if (holyInstrument.notExploded()) {
count++;
}
}
print "i have "+count+"bombs";
return count;
}
}
[/code]
code tag no worky

So how do I connect the terrorists to the bombs? I want each terrorist to know which bombs it has and i want the enclave to know how which bombs are exploded.

PS: i konw that foreach and print are not proper java syntax.

void muhammedJihad() ...

lol@void

Generally if i'm coding something, i try to keep things semantically correct, so i wouldn't have an enclave (i.e. a group) instantiate a bunch of terrorists, but i'd do that separately and insert them into the group, and keep either terrorists or jihadist as a name but not both.

But the general idea is

interface callback{
void do()
}

class ArchA implements callback{
callback cb=null;
void do(){
//do something
if(null!=cb){
cb.do();
}
}
}

A=new ArchA;
B=new ArchA;
A.cb=(callback)b;
A.do() ; // makes A do and B do too, they both do do

If you do that , it's like a chain of events. So anything, perhaps an onclick event, that calls that do() function (not sure how java & event handling is integrated with max) just propagates through the entire list. Alternatively, you could just have global flags and variables to do the collation and routing.

lol @ excellent code sample, sorry i can't help.

thanks jogn. I'll see if i can't get that callback architecture working. If not i'll just make a mapping from cc# to instruments in each page.

anyways, i haven't made any progress on this. i think i might as well just write the damn thing in c++ since it's a language i'm already familiar with, and i can have an array of function pointers .

Why do you need function pointers? Can't the terrorists have a list of bombs assigned to them, and the bombs a pointer to the terrorist they've been assigned to, and handle the updating of the pointers during the assign, unassign and explode functions?
I totally fail to see where an array of function pointers is required.. what am i missing?

I created a max patch that makes each of the buttons a 'page select' button; the patch stores 16 sets of 24 knob positions (each set being a 'page'). If the functionality isn't clear at this point, then plz let me know. The point is that all the sound making happens in max, but maximal command flow is diverted to java.


YES!!!!!
This is tits in the face.

dach said: "Why do you need function pointers? Can't the terrorists have a list of bombs assigned to them, and the bombs a pointer to the terrorist they've been assigned to, and handle the updating of the pointers during the assign, unassign and explode functions?
I totally fail to see where an array of function pointers is required.. what am i missing?"


function pointers probabyl aren't required. pointers seem to be te only way to implement the idea of assigning bombs to terrorists; the idea of the function pointer was to let the 'explode' function be explicitly refereced in the terrorist class but surely just referencing the entire bomb would make better sense. Callbacks would be feasible, but right now it doesn't ake sense to me to learn java just so i can do something I already know how to do in c++.

i'll let you know when this thing gets built. probably not for several months, given the way things have been going. The first step in this whole business is building pluggos to act as the modules for the synth. So far i've built the triangle and square wave DCO's, and i just figured out how to initialize them properly. pretty measly.

flies: did you already consider doing this in supercollider? very nice OO language (derived from smalltalk) with excellent synthesis engine built in.


Register / login
You must be a member to reply or post. signup or login