@@ -40,14 +40,16 @@ const char* steps_names[Steps_COUNT] = { "1-16", "17-32", "33-48", "49-64" };
4040// --------------------------------------------------------------
4141pdspSequencer::pdspSequencer () : PatchObject(" sequencer" ){
4242
43- this ->numInlets = 5 ;
43+ this ->numInlets = 6 ;
4444 this ->numOutlets = 21 ;
4545
4646 _inletParams[0 ] = new vector<float >(); // S
4747 _inletParams[1 ] = new vector<float >(); // A
4848 _inletParams[2 ] = new vector<float >(); // B
4949 _inletParams[3 ] = new vector<float >(); // C
5050 _inletParams[4 ] = new vector<float >(); // D
51+ _inletParams[5 ] = new float (); // steps
52+ *(float *)&_inletParams[5 ] = 0 .0f ;
5153
5254 _outletParams[0 ] = new float (); // step
5355 *(float *)&_outletParams[0 ] = 0 .0f ;
@@ -122,6 +124,7 @@ pdspSequencer::pdspSequencer() : PatchObject("sequencer"){
122124 step = 0 ;
123125 chapter = 0 ;
124126 maxChapter = Steps_1_16;
127+ manualSteps = CHAPTER_STEPS*(maxChapter+1 );
125128 actualSteps = CHAPTER_STEPS*(maxChapter+1 );
126129
127130 metro = false ;
@@ -141,6 +144,7 @@ void pdspSequencer::newObject(){
141144 this ->addInlet (VP_LINK_ARRAY," B" );
142145 this ->addInlet (VP_LINK_ARRAY," C" );
143146 this ->addInlet (VP_LINK_ARRAY," D" );
147+ this ->addInlet (VP_LINK_NUMERIC," steps" );
144148
145149 this ->addOutlet (VP_LINK_NUMERIC," s1" );
146150 this ->addOutlet (VP_LINK_NUMERIC," s2" );
@@ -167,6 +171,7 @@ void pdspSequencer::newObject(){
167171 this ->addOutlet (VP_LINK_NUMERIC," D" );
168172
169173 this ->setCustomVar (0 .0f ," STEPS" );
174+ this ->setCustomVar (static_cast <float >(actualSteps)," MANUAL_STEPS" );
170175
171176 for (size_t i=0 ;i<SEQUENCER_STEPS;i++){
172177 this ->setCustomVar (0 .0f ," S_" +ofToString (i+1 ));
@@ -217,12 +222,15 @@ void pdspSequencer::setupObjectContent(shared_ptr<ofAppGLFWWindow> &mainWindow){
217222
218223// --------------------------------------------------------------
219224void pdspSequencer::setupAudioOutObjectContent (pdsp::Engine &engine){
225+ unusedArgs (engine);
226+
220227 step_millis = static_cast <int >(floor (60000 / 4 / 108 ));
221228 expected_step_millis = static_cast <int >(floor (60000 / 4 / 108 ));
222229}
223230
224231// --------------------------------------------------------------
225232void pdspSequencer::updateObjectContent (map<int ,shared_ptr<PatchObject>> &patchObjects){
233+ unusedArgs (patchObjects);
226234
227235 if (bang){
228236
@@ -307,9 +315,26 @@ void pdspSequencer::updateObjectContent(map<int,shared_ptr<PatchObject>> &patchO
307315 }
308316 }
309317
318+ // steps
319+ if (this ->inletsConnected [5 ]){
320+ manualSteps = static_cast <int >(ofClamp (*(float *)&_inletParams[5 ],1 .0f ,SEQUENCER_STEPS*1 .0f ));
321+ actualSteps = manualSteps;
322+ if (actualSteps <= 16 ){
323+ maxChapter = 0 ;
324+ }else if (actualSteps > 16 && actualSteps <= 32 ){
325+ maxChapter = 1 ;
326+ }else if (actualSteps > 32 && actualSteps <= 48 ){
327+ maxChapter = 2 ;
328+ }else if (actualSteps > 48 && actualSteps <= 64 ){
329+ maxChapter = 3 ;
330+ }
331+ step = seq.frame ()%actualSteps.load ();
332+ }
333+
310334 if (!loaded){
311335 loaded = true ;
312336 maxChapter = static_cast <int >(this ->getCustomVar (" STEPS" ));
337+ manualSteps = static_cast <int >(this ->getCustomVar (" MANUAL_STEPS" ));
313338 actualSteps = CHAPTER_STEPS*(maxChapter+1 );
314339 for (size_t i=0 ;i<SEQUENCER_STEPS;i++){
315340 seqSteps[i] = this ->getCustomVar (" S_" +ofToString (i+1 ));
@@ -328,6 +353,8 @@ void pdspSequencer::updateAudioObjectContent(pdsp::Engine &engine){
328353
329354// --------------------------------------------------------------
330355void pdspSequencer::drawObjectContent (ofTrueTypeFont *font, shared_ptr<ofBaseGLRenderer>& glRenderer){
356+ unusedArgs (font,glRenderer);
357+
331358 ofSetColor (255 );
332359
333360}
@@ -455,23 +482,41 @@ void pdspSequencer::drawObjectNodeConfig(){
455482
456483 if (ImGui::SliderInt (" steps" , &maxChapter, 0 , Steps_COUNT - 1 , steps_nums[maxChapter])){
457484 actualSteps = CHAPTER_STEPS*(maxChapter+1 );
485+ manualSteps = actualSteps;
486+ step = seq.frame ()%actualSteps.load ();
458487 this ->setCustomVar (static_cast <float >(maxChapter)," STEPS" );
488+ this ->setCustomVar (static_cast <float >(manualSteps)," MANUAL_STEPS" );
489+ }
490+ ImGui::Spacing ();
491+ if (ImGui::SliderInt (" manual steps" , &manualSteps, 1 , 64 )){
492+ actualSteps = manualSteps;
493+ if (actualSteps <= 16 ){
494+ maxChapter = 0 ;
495+ }else if (actualSteps > 16 && actualSteps <= 32 ){
496+ maxChapter = 1 ;
497+ }else if (actualSteps > 32 && actualSteps <= 48 ){
498+ maxChapter = 2 ;
499+ }else if (actualSteps > 48 && actualSteps <= 64 ){
500+ maxChapter = 3 ;
501+ }
502+ step = seq.frame ()%actualSteps.load ();
503+ this ->setCustomVar (static_cast <float >(manualSteps)," MANUAL_STEPS" );
459504 }
460505 ImGui::Spacing ();
461506 ImGui::ListBox (" sections" , &chapter, &vectorSteps[0 ], vectorSteps.size (), 4 );
462507 ImGuiEx::ObjectInfo (
463508 " Up to 64 step sequencer with 5 per-step assignable controls." ,
464- " https://mosaic.d3cod3.org/reference.php?r=secuencer " , scaleFactor);
509+ " https://mosaic.d3cod3.org/reference.php?r=sequencer " , scaleFactor);
465510}
466511
467512// --------------------------------------------------------------
468513void pdspSequencer::removeObjectContent (bool removeFileFromData){
469-
514+ unusedArgs (removeFileFromData);
470515}
471516
472517// --------------------------------------------------------------
473518void pdspSequencer::audioOutObject (ofSoundBuffer &outputBuffer){
474-
519+ unusedArgs (outputBuffer);
475520}
476521
477522OBJECT_REGISTER ( pdspSequencer, " sequencer" , OFXVP_OBJECT_CAT_SOUND)
0 commit comments