commit 7b9b8e8f220ba402bb9e52b348e9f46eee0a0eb1
parent 2835ac7ce79625d8d661a60a16b83a71e3f58ddf
Author: fundamental <[email protected]>
Date: Tue, 20 Aug 2013 11:41:50 -0400
Fix EnvelopeUI and Remove Debug Info
Diffstat:
6 files changed, 105 insertions(+), 77 deletions(-)
diff --git a/src/Misc/MiddleWare.cpp b/src/Misc/MiddleWare.cpp
@@ -506,6 +506,7 @@ struct MiddleWareImpl
void handleMsg(const char *msg)
{
assert(!strstr(msg,"free"));
+ assert(msg && *msg && rindex(msg, '/')[1]);
//fprintf(stdout, "%c[%d;%d;%dm", 0x1B, 0, 6 + 30, 0 + 40);
//fprintf(stdout, "middleware: '%s'\n", msg);
//fprintf(stdout, "%c[%d;%d;%dm", 0x1B, 0, 7 + 30, 0 + 40);
@@ -680,7 +681,7 @@ class UI_Interface:public Fl_Osc_Interface
break;
}
}
- printf("[%d] removing '%s' (%p)...\n", map.size(), s.c_str(), w);
+ //printf("[%d] removing '%s' (%p)...\n", map.size(), s.c_str(), w);
}
virtual void removeLink(class Fl_Osc_Widget *w)
@@ -692,8 +693,8 @@ class UI_Interface:public Fl_Osc_Interface
processing = false;//Exit if no new elements are found
for(auto i = map.begin(); i != map.end(); ++i) {
if(i->second == w) {
- printf("[%d] removing '%s' (%p)...\n", map.size()-1,
- i->first.c_str(), w);
+ //printf("[%d] removing '%s' (%p)...\n", map.size()-1,
+ // i->first.c_str(), w);
map.erase(i);
processing = true;
break;
@@ -716,8 +717,8 @@ class UI_Interface:public Fl_Osc_Interface
{
//DEBUG
- if(strcmp(msg, "/vu-meter"))//Ignore repeated message
- printf("trying the link for a '%s'<%s>\n", msg, rtosc_argument_string(msg));
+ //if(strcmp(msg, "/vu-meter"))//Ignore repeated message
+ // printf("trying the link for a '%s'<%s>\n", msg, rtosc_argument_string(msg));
const char *handle = rindex(msg,'/');
if(handle)
++handle;
diff --git a/src/UI/EnvelopeFreeEdit.cpp b/src/UI/EnvelopeFreeEdit.cpp
@@ -3,6 +3,8 @@
#include <FL/Fl.H>
#include <FL/fl_draw.H>
#include <cstdlib>
+#include <cassert>
+#include <rtosc/rtosc.h>
EnvelopeFreeEdit::EnvelopeFreeEdit(int x,int y, int w, int h, const char *label)
:Fl_Box(x,y,w,h,label), Fl_Osc_Widget(this)
@@ -21,8 +23,25 @@ void EnvelopeFreeEdit::init(void)
oscRegister("Penvsustain");
}
-void EnvelopeFreeEdit::OSC_raw(const char *msg) const
-{}
+void EnvelopeFreeEdit::OSC_raw(const char *msg)
+{
+ const char *args = rtosc_argument_string(msg);
+ if(strstr(msg,"Penvpoints") && !strcmp(args, "c")) {
+ Penvpoints = rtosc_argument(msg, 0).i;
+ } else if(strstr(msg,"Penvdt") && !strcmp(args, "b")) {
+ rtosc_blob_t b = rtosc_argument(msg, 0).b;
+ assert(b.len == MAX_ENVELOPE_POINTS);
+ memcpy(Penvdt, b.data, MAX_ENVELOPE_POINTS);
+ } else if(strstr(msg,"Penvval") && !strcmp(args, "b")) {
+ rtosc_blob_t b = rtosc_argument(msg, 0).b;
+ assert(b.len == MAX_ENVELOPE_POINTS);
+ memcpy(Penvval, b.data, MAX_ENVELOPE_POINTS);
+ } else if(strstr(msg,"Penvsustain") && !strcmp(args, "c")) {
+ Penvsustain = rtosc_argument(msg, 0).i;
+ }
+ redraw();
+ do_callback();
+}
void EnvelopeFreeEdit::setpair(Fl_Box *pair_)
{
@@ -62,7 +81,7 @@ int EnvelopeFreeEdit::getnearest(int x,int y) const
int distance=abs(x-getpointx(i))+abs(y-getpointy(i));
if (distance<nearestval) {
nearestpoint=i;
- nearestval=distance;
+ nearestval=distance;
}
}
@@ -167,17 +186,18 @@ int EnvelopeFreeEdit::handle(int event)
if (event==FL_DRAG && currentpoint>=0){
int ny=limit(127-(int) (y_*127.0/h()), 0, 127);
-
+
Penvval[currentpoint]=ny;
const int dx=(int)((x_-cpx)*0.1);
const int newdt=limit(cpdt+dx,0,127);
-
+
if(currentpoint!=0)
Penvdt[currentpoint]=newdt;
else
Penvdt[currentpoint]=0;
+ oscWrite(to_s("Penvdt")+to_s(currentpoint), "c", newdt);
redraw();
if(pair)
@@ -190,4 +210,8 @@ int EnvelopeFreeEdit::handle(int event)
void EnvelopeFreeEdit::update(void)
{
+ oscWrite("Penvpoints");
+ oscWrite("Penvdt");
+ oscWrite("Penvval");
+ oscWrite("Penvsustain");
}
diff --git a/src/UI/EnvelopeFreeEdit.h b/src/UI/EnvelopeFreeEdit.h
@@ -21,11 +21,14 @@ class EnvelopeFreeEdit : public Fl_Box, Fl_Osc_Widget
int handle(int event);
void draw(void);
- void OSC_raw(const char *msg) const;
+ void OSC_raw(const char *msg) override;
void update(void);
int lastpoint;
+
+ //How many points
+ char Penvpoints;
private:
int getpointx(int n) const;
int getpointy(int n) const;
@@ -37,8 +40,6 @@ class EnvelopeFreeEdit : public Fl_Box, Fl_Osc_Widget
//cursor state
int currentpoint, cpx, cpdt;
- //How many points
- char Penvpoints;
//The Points
char Penvdt[MAX_ENVELOPE_POINTS];
char Penvval[MAX_ENVELOPE_POINTS];
diff --git a/src/UI/EnvelopeUI.fl b/src/UI/EnvelopeUI.fl
@@ -56,8 +56,7 @@ decl {\#include "EnvelopeFreeEdit.h"} {public local
class EnvelopeUI {open : {public Fl_Osc_Group,PresetsUI_}
} {
Function {EnvelopeUI(int x,int y, int w, int h, const char *label=0):Fl_Osc_Group(x,y,w,h,label)} {} {
- code {
-freemodeeditwindow=NULL;
+ code {freemodeeditwindow=NULL;
envADSR=NULL;
envASR=NULL;
envADSRfilter=NULL;
@@ -73,9 +72,9 @@ delete (freemodeeditwindow);} {}
Function {make_freemode_edit_window()} {open
} {
Fl_Window freemodeeditwindow {
- label Envelope
- xywh {702 801 575 180} type Double visible
- class Fl_Osc_Window
+ label Envelope open
+ xywh {702 801 575 180} type Double
+ class Fl_Osc_Window visible
} {
Fl_Button {} {
label C
@@ -91,29 +90,30 @@ delete (freemodeeditwindow);} {}
Fl_Button addpoint {
label {Add point}
callback {
- o->oscWrite("addPoint", "i", freeedit->lastpoint);
-
+if(freeedit->lastpoint >= MAX_ENVELOPE_POINTS - 1)
+ return;
+o->oscWrite("addPoint", "i", freeedit->lastpoint);
freeedit->lastpoint+=1;
-freeedit->redraw();
+freeedit->update();
envfree->redraw();
sustaincounter->update();
//sustaincounter->value(Penvsustain);
//sustaincounter->maximum(Penvpoints-2);}
xywh {115 155 80 20} box THIN_UP_BOX labelsize 11
- code0 {if (Pfreemode==0) o->hide();}
+ code0 {//if (Pfreemode==0) o->hide();}
class Fl_Osc_Button
}
Fl_Box freeedit {
label Envelope
+ callback {sustaincounter->maximum(o->Penvpoints-2);}
xywh {5 5 565 145} box FLAT_BOX color 0
code0 {o->init();}
class EnvelopeFreeEdit
}
Fl_Button deletepoint {
label {Delete point}
- callback {
- o->oscWrite("delPoint", "i", freeedit->lastpoint);
+ callback {o->oscWrite("delPoint", "i", freeedit->lastpoint);
freeedit->lastpoint-=1;
freeedit->update();
envfree->redraw();
@@ -121,7 +121,7 @@ sustaincounter->update();
//sustaincounter->value(Penvsustain);
//sustaincounter->maximum(Penvpoints-2);}
xywh {200 155 80 20} box THIN_UP_BOX labelsize 11
- code0 {if (Pfreemode==0) o->hide();}
+ code0 {//if (Pfreemode==0) o->hide();}
class Fl_Osc_Button
}
Fl_Light_Button freemodebutton {
@@ -135,8 +135,8 @@ freeedit->redraw();}
Fl_Check_Button forcedreleasecheck {
label frcR
tooltip {Forced Relase} xywh {410 165 40 15} down_box DOWN_BOX labelsize 10
- code0 {o->init("Pforcedrelease");
- //TODO code1 {if (Pfreemode==0) o->hide();}}
+ code0 {o->init("Pforcedrelease");}
+ code1 {//TODO if (Pfreemode==0) o->hide();}
class Fl_Osc_Check
}
Fl_Dial envstretchdial {
@@ -167,14 +167,14 @@ envfree->redraw();}
code0 {//o->value(Penvsustain);}
code1 {//if (Pfreemode==0) o->hide();}
code2 {//o->maximum(Penvpoints-2);}
+ code3 {o->init("Penvsustain");}
class Fl_Osc_Counter
}
}
}
- Function {make_ADSR_window()} {open
- } {
+ Function {make_ADSR_window()} {} {
Fl_Window envADSR {open
- xywh {350 911 205 70} type Double color 50 labelfont 1
+ xywh {353 911 205 70} type Double color 50 labelfont 1
class Fl_Osc_Group visible
} {
Fl_Group {} {
@@ -246,8 +246,7 @@ envfree->redraw();}
}
}
}
- Function {make_ASR_window()} {open
- } {
+ Function {make_ASR_window()} {} {
Fl_Window envASR {open
xywh {1067 911 210 70} type Double
class Fl_Osc_Group visible
@@ -315,8 +314,7 @@ envfree->redraw();}
}
}
}
- Function {make_ADSRfilter_window()} {open
- } {
+ Function {make_ADSRfilter_window()} {} {
Fl_Window envADSRfilter {open
xywh {1002 911 275 70} type Double color 50 labelfont 1
class Fl_Osc_Group visible
@@ -398,10 +396,9 @@ envfree->redraw();}
}
}
}
- Function {make_ASRbw_window()} {open
- } {
+ Function {make_ASRbw_window()} {} {
Fl_Window envASRbw {open
- xywh {368 911 210 70} type Double
+ xywh {371 911 210 70} type Double
code0 {set_module_parameters(o);}
class Fl_Osc_Group visible
} {
@@ -468,10 +465,9 @@ envfree->redraw();}
}
}
}
- Function {make_free_window()} {open
- } {
+ Function {make_free_window()} {} {
Fl_Window envfree {open
- xywh {382 911 205 70} type Double color 50 labelfont 1 resizable
+ xywh {385 911 205 70} type Double color 50 labelfont 1 resizable
code0 {set_module_parameters(o);}
class Fl_Osc_Group visible
} {
@@ -505,10 +501,9 @@ envfree->redraw();}
}
}
}
- Function {init(int env_type, Fl_Osc_Interface *osc_, std::string base_, std::string ext_)} {open selected
+ Function {init(int env_type, Fl_Osc_Interface *osc_, std::string base_, std::string ext_)} {open
} {
- code {
- osc = osc_;
+ code {osc = osc_;
base = base_;
ext = ext_;
Envmode = env_type;
@@ -543,17 +538,14 @@ refresh();} {}
}
Function {rebase(std::string new_base)} {open
} {
- code {
- printf("\\n\\n\\n\\nCAT DOG\\n\\n\\n\\n");
+ code {printf("\\n\\n\\n\\nCAT DOG\\n\\n\\n\\n");
printf("\\nNEW BASE: '%s'\\n", (new_base+ext).c_str());
Fl_Osc_Group::rebase(new_base);
- freemodeeditwindow->rebase(new_base+ext);
- } {}
+ freemodeeditwindow->rebase(new_base+ext);} {}
}
Function {reinit()} {open
} {
- code {
-if(Pfreemode){
+ code {if(Pfreemode){
int answer=fl_choice("Disable the free mode of the Envelope?","No","Yes",NULL);
freemodebutton->value(Pfreemode);
if (answer==0)
@@ -587,17 +579,22 @@ if (Pfreemode) {
addpoint->show();
deletepoint->show();
forcedreleasecheck->show();
+ sustaincounter->show();
+ envstretchdial->show();
} else{
freemodebutton->value(0);
addpoint->hide();
deletepoint->hide();
forcedreleasecheck->hide();
-};} {}
+ sustaincounter->hide();
+ envstretchdial->hide();
+};
+} {selected
+ }
}
Function {refresh()} {open
} {
- code {
- freemodebutton->value(Pfreemode);
+ code {freemodebutton->value(Pfreemode);
sustaincounter->value(Penvsustain);
sustaincounter->maximum(Penvpoints-2);
@@ -608,14 +605,19 @@ linearenvelopecheck->value(Plinearenvelope);
//Conditionally display widgets
if(Pfreemode) {
- sustaincounter->hide();
- envstretchdial->hide();
- forcedreleasecheck->hide();
- envfree->redraw();
- } else {
+ freemodebutton->value(1);
+ addpoint->show();
+ deletepoint->show();
+ forcedreleasecheck->show();
sustaincounter->show();
envstretchdial->show();
- forcedreleasecheck->show();
+ } else {
+ freemodebutton->value(0);
+ addpoint->hide();
+ deletepoint->hide();
+ forcedreleasecheck->hide();
+ sustaincounter->hide();
+ envstretchdial->hide();
}
if(Pfreemode || Envmode>2)
@@ -660,19 +662,19 @@ envwindow->resize(this->x(),this->y(),this->w(),this->h());
envwindow->show();} {}
}
- decl {int Envmode;}{private local
+ decl {int Envmode;} {private local
}
- decl {int Pfreemode;}{private local
+ decl {int Pfreemode;} {private local
}
- decl {int Penvsustain;}{private local
+ decl {int Penvsustain;} {private local
}
- decl {int Penvpoints;}{private local
+ decl {int Penvpoints;} {private local
}
- decl {int Penvstretch;}{private local
+ decl {int Penvstretch;} {private local
}
- decl {int Pforcedrelease;}{private local
+ decl {int Pforcedrelease;} {private local
}
- decl {int Plinearenvelope;}{private local
+ decl {int Plinearenvelope;} {private local
}
decl {Fl_Group *envwindow;} {private local
}
diff --git a/src/UI/Fl_Osc_Widget.cpp b/src/UI/Fl_Osc_Widget.cpp
@@ -43,8 +43,8 @@ void Fl_Osc_Widget::OSC_raw(const char *)
void Fl_Osc_Widget::oscWrite(std::string path, const char *args, ...)
{
char buffer[1024];
- puts("writing OSC");
- printf("Path = '%s'\n", path.c_str());
+ //puts("writing OSC");
+ //printf("Path = '%s'\n", path.c_str());
assert(!path.empty());
va_list va;
@@ -54,15 +54,15 @@ void Fl_Osc_Widget::oscWrite(std::string path, const char *args, ...)
osc->writeRaw(buffer);
else
puts("Dangerous Event ommision");
- //Try to pretty print basic events
- if(!strcmp(args, "c") || !strcmp(args, "i"))
- printf("Args = ['%d']\n", rtosc_argument(buffer, 0).i);
- if(!strcmp(args, "f"))
- printf("Args = ['%f']\n", rtosc_argument(buffer, 0).f);
- if(!strcmp(args, "T"))
- printf("Args = [True]\n");
- if(!strcmp(args, "F"))
- printf("Args = [False]\n");
+ ////Try to pretty print basic events
+ //if(!strcmp(args, "c") || !strcmp(args, "i"))
+ // printf("Args = ['%d']\n", rtosc_argument(buffer, 0).i);
+ //if(!strcmp(args, "f"))
+ // printf("Args = ['%f']\n", rtosc_argument(buffer, 0).f);
+ //if(!strcmp(args, "T"))
+ // printf("Args = [True]\n");
+ //if(!strcmp(args, "F"))
+ // printf("Args = [False]\n");
}
void Fl_Osc_Widget::oscWrite(std::string path)
diff --git a/src/UI/PartUI.fl b/src/UI/PartUI.fl
@@ -62,7 +62,7 @@ class PartSysEffSend {open : {public Fl_Group}
label 01
xywh {0 0 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 align 130 maximum 127 step 1
code0 {o->size(25,25);}
- code1 {o->init("sysefx"+to_s(neff)+"/part"+to_s(npart)+"/");}
+ code1 {o->init("sysefx"+to_s(neff)+"/part"+to_s(npart)+"/dummy");}
code2 {char tmp[10];snprintf(tmp,10,"%d",neff+1);o->copy_label(tmp);}
class Fl_Osc_Dial
}