Skip to content

Commit

Permalink
max and pd obejct consolidation
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesneimog committed Sep 29, 2024
1 parent 430ed7c commit 111390a
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 102 deletions.
1 change: 1 addition & 0 deletions Sources/Max/o.scofo~.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ static void oscofo_score(MaxOScofo *x, t_symbol *s){
std::string CompletePath = x->PatchDir;
CompletePath += "/";
CompletePath += s->s_name;
object_post((t_object *)x, "Loading score %s", CompletePath.c_str());
bool ok;
try {
ok = x->OpenScofo->ParseScore(CompletePath.c_str());
Expand Down
18 changes: 13 additions & 5 deletions Sources/PureData/o.scofo~.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static void oscofo_score(PdOScofo *x, t_symbol *s) {
std::string CompletePath = x->PatchDir;
CompletePath += "/";
CompletePath += s->s_name;
post("[o.scofo~] Loading score %s", CompletePath.c_str());
bool ok;
try {
ok = x->OpenScofo->ParseScore(CompletePath.c_str());
Expand Down Expand Up @@ -174,6 +175,7 @@ static t_int *oscofo_perform(t_int *w) {
x->Event = Event;
clock_delay(x->ClockEvent, 0);
}
clock_delay(x->ClockInfo, 0);
return (w + 4);
}

Expand All @@ -192,11 +194,15 @@ static void *oscofo_new(t_symbol *s, int argc, t_atom *argv) {
pd_error(nullptr, "[o.scofo~] Error creating object");
return nullptr;
}

x->EventOut = outlet_new(&x->PdObject, &s_float); // event outlet
x->TempoOut = outlet_new(&x->PdObject, &s_float); // tempo outlet

double overlap = 4;
for (int i = 0; i < argc; i++) {
if (argv[i].a_type == A_SYMBOL || argc >= i + 1) {
std::string argument = std::string(atom_getsymbol(&argv[i])->s_name);
if (argument == "@info") {
if (argument == "-info" || argument == "@info") {
x->InfoOut = outlet_new(&x->PdObject, &s_list);
int k = 0;
for (int j = i + 1; j < argc; j++) {
Expand All @@ -211,8 +217,7 @@ static void *oscofo_new(t_symbol *s, int argc, t_atom *argv) {
}
}

x->TempoOut = outlet_new(&x->PdObject, &s_float); // tempo outlet
x->EventOut = outlet_new(&x->PdObject, &s_float); // event outlet

x->ClockEvent = clock_new(x, (t_method)oscofo_tickevent);
x->ClockInfo = clock_new(x, (t_method)oscofo_tickinfo);
x->FFTSize = 4096.0f;
Expand All @@ -237,10 +242,13 @@ static void oscofo_free(PdOScofo *x) {
extern "C" void setup_o0x2escofo_tilde(void) {
OScofoObj = class_new(gensym("o.scofo~"), (t_newmethod)oscofo_new, (t_method)oscofo_free, sizeof(PdOScofo), CLASS_DEFAULT, A_GIMME, 0);

CLASS_MAINSIGNALIN(OScofoObj, PdOScofo, Sample);
class_addmethod(OScofoObj, (t_method)oscofo_adddsp, gensym("dsp"), A_CANT, 0);
// message methods
class_addmethod(OScofoObj, (t_method)oscofo_score, gensym("score"), A_SYMBOL, 0);
class_addmethod(OScofoObj, (t_method)oscofo_start, gensym("start"), A_NULL, 0);
class_addmethod(OScofoObj, (t_method)oscofo_following, gensym("follow"), A_FLOAT, 0);
class_addmethod(OScofoObj, (t_method)oscofo_set, gensym("set"), A_GIMME, 0);

// dsp
CLASS_MAINSIGNALIN(OScofoObj, PdOScofo, Sample);
class_addmethod(OScofoObj, (t_method)oscofo_adddsp, gensym("dsp"), A_CANT, 0);
}
74 changes: 27 additions & 47 deletions Tests/BWV-1013/max.maxpat
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,30 @@
"subpatcher_template" : "",
"assistshowspatchername" : 0,
"boxes" : [ {
"box" : {
"id" : "obj-21",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 576.0, 458.0, 32.0, 22.0 ],
"text" : "print"
}

}
, {
"box" : {
"format" : 6,
"id" : "obj-18",
"maxclass" : "flonum",
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 568.0, 341.0, 50.0, 22.0 ]
}

}
, {
"box" : {
"id" : "obj-13",
"maxclass" : "newobj",
Expand Down Expand Up @@ -84,19 +108,6 @@
"text" : "set threshold -60"
}

}
, {
"box" : {
"format" : 6,
"id" : "obj-16",
"maxclass" : "flonum",
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 560.0, 332.0, 103.0, 22.0 ]
}

}
, {
"box" : {
Expand Down Expand Up @@ -170,30 +181,6 @@
"patching_rect" : [ 148.0, 332.0, 144.0, 40.0 ]
}

}
, {
"box" : {
"id" : "obj-17",
"maxclass" : "toggle",
"numinlets" : 1,
"numoutlets" : 1,
"outlettype" : [ "int" ],
"parameter_enable" : 0,
"patching_rect" : [ 242.0, 201.0, 24.0, 24.0 ]
}

}
, {
"box" : {
"id" : "obj-15",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 242.0, 229.0, 56.0, 22.0 ],
"text" : "follow $1"
}

}
, {
"box" : {
Expand Down Expand Up @@ -276,7 +263,7 @@
}
, {
"patchline" : {
"destination" : [ "obj-16", 0 ],
"destination" : [ "obj-18", 0 ],
"source" : [ "obj-1", 2 ]
}

Expand Down Expand Up @@ -320,15 +307,8 @@
}
, {
"patchline" : {
"destination" : [ "obj-1", 0 ],
"source" : [ "obj-15", 0 ]
}

}
, {
"patchline" : {
"destination" : [ "obj-15", 0 ],
"source" : [ "obj-17", 0 ]
"destination" : [ "obj-21", 0 ],
"source" : [ "obj-18", 0 ]
}

}
Expand Down
30 changes: 15 additions & 15 deletions Tests/BWV-1013/pd.pd
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#N canvas 647 81 611 687 10;
#X obj 13 200 o.scofo~, f 18;
#N canvas 647 81 513 589 10;
#X obj 13 224 nbx 3 24 -1e+37 1e+37 0 0 empty empty empty 0 -9 0 20 #fcfcfc #ff0400 #ff0400 0 256;
#X obj 13 77 readsf~;
#X msg 13 18 open audio.wav \, 1;
Expand Down Expand Up @@ -73,19 +72,20 @@
#X connect 24 0 13 0;
#X connect 25 0 18 0;
#X restore 13 273 pd plaits;
#X connect 0 0 1 0;
#X obj 13 200 o.scofo~ @info db, f 18;
#X connect 0 0 14 0;
#X connect 1 0 13 0;
#X connect 1 0 15 0;
#X connect 2 0 0 0;
#X connect 2 0 14 0;
#X connect 3 0 2 0;
#X connect 3 0 11 0;
#X connect 6 0 0 0;
#X connect 2 0 1 0;
#X connect 2 0 10 0;
#X connect 5 0 15 0;
#X connect 6 0 7 0;
#X connect 7 0 8 0;
#X connect 8 0 7 1;
#X connect 8 0 9 0;
#X connect 9 0 8 1;
#X connect 9 0 10 0;
#X connect 10 0 12 0;
#X connect 11 0 7 0;
#X connect 13 0 2 0;
#X connect 14 0 4 0;
#X connect 14 0 4 1;
#X connect 9 0 11 0;
#X connect 10 0 6 0;
#X connect 12 0 1 0;
#X connect 13 0 3 0;
#X connect 13 0 3 1;
#X connect 15 0 0 0;
Loading

0 comments on commit 111390a

Please sign in to comment.