| @@ -36,6 +36,7 @@ cp $ORIG_ZYN_DIR/tlsf/*.c $CARLA_ZYN_DIR/tlsf/ | |||
| rm $CARLA_ZYN_DIR/*/CMakeLists.txt | |||
| rm $CARLA_ZYN_DIR/UI/zynaddsubfx.xpm | |||
| sed -i "s|emplace_uint32(|emplace_uint32_cpp(|" $CARLA_ZYN_DIR/rtosc/cpp/subtree-serialize.cpp | |||
| sed -i "s|../../include/rtosc/|../|" $CARLA_ZYN_DIR/rtosc/cpp/*.cpp | |||
| sed -i "s|../../tlsf/tlsf.h|tlsf/tlsf.h|" $CARLA_ZYN_DIR/Misc/Allocator.cpp | |||
| sed -i "s|../src/globals.h|globals.h|" $CARLA_ZYN_DIR/Misc/Config.cpp | |||
| @@ -88,10 +88,18 @@ void FormantFilter::cleanup() | |||
| formant[i]->cleanup(); | |||
| } | |||
| void FormantFilter::setpos(float input) | |||
| inline float log_2(float x) | |||
| { | |||
| return logf(x) / logf(2.0f); | |||
| } | |||
| void FormantFilter::setpos(float frequency) | |||
| { | |||
| int p1, p2; | |||
| //Convert form real freq[Hz] | |||
| const float input = log_2(frequency) - 9.96578428f; //log2(1000)=9.95748f. | |||
| if(firsttime != 0) | |||
| slowinput = input; | |||
| else | |||
| @@ -188,18 +196,10 @@ void FormantFilter::setq(float q_) | |||
| void FormantFilter::setgain(float /*dBgain*/) | |||
| {} | |||
| inline float log_2(float x) | |||
| { | |||
| return logf(x) / logf(2.0f); | |||
| } | |||
| void FormantFilter::setfreq_and_q(float frequency, float q_) | |||
| { | |||
| //Convert form real freq[Hz] | |||
| const float freq = log_2(frequency) - 9.96578428f; //log2(1000)=9.95748f. | |||
| Qfactor = q_; | |||
| setpos(freq); | |||
| setpos(frequency); | |||
| } | |||
| @@ -52,6 +52,9 @@ decl {\#include "Fl_Osc_Slider.H"} {public local | |||
| decl {\#include "Fl_Osc_VSlider.H"} {public local | |||
| } | |||
| decl {\#include "Osc_IntModel.h"} {private local | |||
| } | |||
| decl {\#include "Fl_Oscilloscope.h"} {public local | |||
| } | |||
| @@ -79,6 +82,30 @@ decl {\#include "MasterUI.h"} {private local | |||
| decl {extern class MasterUI *ui;} {private local | |||
| } | |||
| class PhaseSlider {: {public Fl_Osc_TSlider} | |||
| } { | |||
| Function {PhaseSlider(int x,int y, int w, int h, const char *label=0) | |||
| :Fl_Osc_TSlider(x,y,w,h,label)} {open | |||
| } { code { | |||
| setRounding(1); | |||
| reset_value=0; | |||
| setTransform(180.0/64, 0); | |||
| }} | |||
| Function {OSC_value(int i)} {open return_type void | |||
| } { code { | |||
| value(64-i); | |||
| } {} } | |||
| Function {cb(void)} {open return_type void | |||
| } { | |||
| code { | |||
| oscWrite(ext, "i", (int)(64-Fl_Slider::value())); | |||
| if(cb_data.first) | |||
| cb_data.first(this, cb_data.second); | |||
| } {} | |||
| } | |||
| } | |||
| class ADvoicelistitem {open : {public Fl_Osc_Group} | |||
| } { | |||
| Function {make_window()} {open private | |||
| @@ -118,7 +145,7 @@ class ADvoicelistitem {open : {public Fl_Osc_Group} | |||
| Fl_Group voiceoscil {open | |||
| xywh {102 5 30 20} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179 | |||
| code0 {voiceoscil->ext = "OscilSmp/";} | |||
| code1 {oscil=new Fl_Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");} | |||
| code1 {oscil=new Fl_Oscilloscope(o->x(),o->y()+1,o->w(),o->h(),"");} | |||
| code2 {oscil->init(false);} | |||
| class Fl_Osc_Group | |||
| } {} | |||
| @@ -135,27 +162,11 @@ class ADvoicelistitem {open : {public Fl_Osc_Group} | |||
| } | |||
| Fl_Box whitenoiselabel { | |||
| label N | |||
| xywh {107 5 20 20} labelfont 1 labelsize 13 labelcolor 7 | |||
| xywh {107 5 20 20} labelfont 1 labelsize 13 labelcolor 54 hide | |||
| } | |||
| Fl_Check_Button noisehack { | |||
| callback {if (o->value()==0) { | |||
| whitenoiselabel->hide(); | |||
| voiceresonanceenabled->activate(); | |||
| detunevalueoutput->activate(); | |||
| voicedetune->activate(); | |||
| voicelfofreq->activate(); | |||
| voiceoscil->activate(); | |||
| } else { | |||
| whitenoiselabel->show(); | |||
| voiceresonanceenabled->deactivate(); | |||
| detunevalueoutput->deactivate(); | |||
| voicedetune->deactivate(); | |||
| voicelfofreq->deactivate(); | |||
| voiceoscil->deactivate(); | |||
| };} | |||
| xywh {0 0 0 0} down_box DOWN_BOX | |||
| code0 {o->init("Type");o->hide();} | |||
| class Fl_Osc_Check | |||
| Fl_Box pinknoiselabel { | |||
| label N | |||
| xywh {107 5 20 20} labelfont 1 labelsize 13 labelcolor 212 hide | |||
| } | |||
| } | |||
| Fl_Check_Button voiceenabled { | |||
| @@ -188,12 +199,47 @@ else | |||
| Function {ADvoicelistitem(int x,int y, int w, int h, const char *label=0):Fl_Osc_Group(x,y,w,h,label)} {open | |||
| } { | |||
| code {assert(osc); | |||
| voice_phase = new Osc_IntModel(osc); | |||
| voice_phase->callback=[this](int phase) { | |||
| oscil->phase=phase; | |||
| voiceoscil->redraw(); | |||
| return; | |||
| }; | |||
| sound_type = new Osc_IntModel(osc); | |||
| sound_type->callback=[this](int voice_type) { | |||
| switch (voice_type) { | |||
| case 0: | |||
| whitenoiselabel->hide(); | |||
| pinknoiselabel->hide(); | |||
| voiceresonanceenabled->activate(); | |||
| detunevalueoutput->activate(); | |||
| voicedetune->activate(); | |||
| voicelfofreq->activate(); | |||
| voiceoscil->activate(); | |||
| return; | |||
| case 1: | |||
| whitenoiselabel->show(); | |||
| pinknoiselabel->hide(); | |||
| break; | |||
| default: | |||
| pinknoiselabel->show(); | |||
| whitenoiselabel->hide(); | |||
| } | |||
| voiceresonanceenabled->deactivate(); | |||
| detunevalueoutput->deactivate(); | |||
| voicedetune->deactivate(); | |||
| voicelfofreq->deactivate(); | |||
| voiceoscil->deactivate(); | |||
| }; | |||
| nvoice=0;} {} | |||
| } | |||
| Function {init(int nvoice_, std::string loc_, Fl_Osc_Interface *osc_)} {open | |||
| } { | |||
| code {assert(osc_); | |||
| assert(!loc_.empty()); | |||
| voice_phase->doUpdate(loc_ + "Poscilphase"); | |||
| sound_type->doUpdate(loc_ + "Type"); | |||
| nvoice=nvoice_; | |||
| loc = loc_; | |||
| @@ -209,10 +255,17 @@ detunevalueoutput->do_callback(); | |||
| ADnoteVoiceListItem->redraw();} {} | |||
| } | |||
| Function {~ADvoicelistitem()} {} { | |||
| code {ADnoteVoiceListItem->hide();} {} | |||
| code {ADnoteVoiceListItem->hide(); | |||
| osc->removeLink(voice_phase); | |||
| osc->removeLink(sound_type); | |||
| } {} | |||
| } | |||
| decl {int nvoice;} {private local | |||
| } | |||
| decl {class Osc_IntModel *voice_phase;} {private local | |||
| } | |||
| decl {class Osc_IntModel *sound_type;} {private local | |||
| } | |||
| decl {Fl_Oscilloscope *oscil;} {private local | |||
| } | |||
| decl {std::string loc;} {private local | |||
| @@ -366,11 +419,11 @@ oscedit=new OscilEditor(true, loc+"FMSmp/", osc_i);} | |||
| } | |||
| Fl_Slider {} { | |||
| label Phase | |||
| callback {oscFM->phase=64-(int) o->value(); | |||
| callback {oscFM->phase=64-(int)o->value(); | |||
| fmoscil->redraw();} | |||
| xywh {645 415 105 15} type {Horz Knob} box NO_BOX labelsize 10 align 5 minimum -64 maximum 63 step 1 | |||
| code0 {o->init("PFMoscilphase", 'i');} | |||
| class Fl_Osc_Slider | |||
| xywh {645 415 105 15} type {Horz Knob} box NO_BOX labelsize 10 align 5 minimum -63 maximum 64 step 1 | |||
| code0 { o->init("PFMoscilphase", 'i'); } | |||
| class PhaseSlider | |||
| } | |||
| Fl_Choice extFMoscil { | |||
| label Use | |||
| @@ -548,11 +601,11 @@ o->redraw();} | |||
| } | |||
| Fl_Slider {} { | |||
| label Phase | |||
| callback {osc->phase=64-(int) o->value(); | |||
| callback {osc->phase=64-(int)o->value(); | |||
| voiceoscil->redraw();} | |||
| xywh {10 435 65 10} type {Horz Knob} box NO_BOX labelsize 10 align 5 minimum -64 maximum 63 step 1 | |||
| code0 {o->init("Poscilphase", 'i');} | |||
| class Fl_Osc_Slider | |||
| xywh {10 435 65 10} type {Horz Knob} box NO_BOX labelsize 10 align 5 minimum -63 maximum 64 step 1 | |||
| code0 { o->init("Poscilphase", 'i'); } | |||
| class PhaseSlider | |||
| } | |||
| Fl_Check_Button {} { | |||
| label {R.} | |||
| @@ -748,7 +801,7 @@ o->redraw();} | |||
| } | |||
| MenuItem {} { | |||
| label Pink | |||
| xywh {25 25 100 20} labelfont 1 labelsize 11 labelcolor 211 | |||
| xywh {25 25 100 20} labelfont 1 labelsize 11 labelcolor 212 | |||
| } | |||
| } | |||
| Fl_Check_Button bypassfiltercheckbutton { | |||
| @@ -779,7 +832,7 @@ bypassfiltercheckbutton->redraw();} | |||
| } | |||
| Fl_Box whitenoiselabel { | |||
| label {White Noise} | |||
| xywh {150 430 300 65} labelfont 1 labelsize 50 labelcolor 53 hide | |||
| xywh {150 430 300 65} labelfont 1 labelsize 50 labelcolor 54 hide | |||
| } | |||
| Fl_Box pinknoiselabel { | |||
| label {Pink Noise} | |||
| @@ -89,7 +89,7 @@ delete (formantparswindow);} {} | |||
| Fl_Button {} { | |||
| label P | |||
| callback {presetsui->paste(filterui->loc(),this);} | |||
| xywh {203 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7 | |||
| xywh {203 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55 | |||
| } | |||
| Fl_Group filterparamswindow { | |||
| label {Filter Parameters} | |||
| @@ -258,7 +258,7 @@ delete (formantparswindow);} {} | |||
| Fl_Button {} { | |||
| label P | |||
| callback {presetsui->paste(filterui->loc(),this,nvowel);} | |||
| xywh {665 25 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 7 | |||
| xywh {665 25 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55 | |||
| code0 {formantparswindow->osc = osc;} | |||
| code1 {formantparswindow->base = loc();} | |||
| } | |||
| @@ -473,6 +473,7 @@ filterparamswindow->redraw();} {} | |||
| Function {rebase(std::string new_base)} {open | |||
| } { | |||
| code { | |||
| formantparswindow->rebase(new_base+"VoiceFilter/"); | |||
| Fl_Osc_Group::rebase(new_base); | |||
| } {} | |||
| } | |||
| @@ -24,10 +24,10 @@ class Fl_Osc_Slider:public Fl_Slider, public Fl_Osc_Widget | |||
| int handle(int ev, int X, int Y, int W, int H); | |||
| int handle(int ev); | |||
| void cb(void); | |||
| virtual void cb(void); | |||
| static void _cb(Fl_Widget *w, void *); | |||
| float reset_value; | |||
| private: | |||
| protected: | |||
| char osc_type; | |||
| std::pair<Fl_Callback*, void*> cb_data; | |||
| }; | |||
| @@ -10,7 +10,7 @@ class Fl_Osc_TSlider:public Fl_Osc_Slider | |||
| Fl_Osc_TSlider(int x, int y, int w, int h, const char *label = 0); | |||
| ~Fl_Osc_TSlider(); | |||
| int handle(int event); | |||
| void set_transform(float scale = 1.0, float offset = 0.0); | |||
| void setTransform(float scale = 1.0, float offset = 0.0); | |||
| float transform(float x); | |||
| void setRounding(unsigned int digits = 0); | |||
| private: | |||
| @@ -53,7 +53,7 @@ int Fl_Osc_TSlider::handle(int event) | |||
| return super; | |||
| } | |||
| void Fl_Osc_TSlider::set_transform(float scale, float offset) | |||
| void Fl_Osc_TSlider::setTransform(float scale, float offset) | |||
| { | |||
| value_offset = offset; | |||
| value_scale = scale; | |||
| @@ -30,7 +30,4 @@ class Fl_Osc_VSlider:public Fl_Osc_Slider | |||
| protected: | |||
| void draw(void); | |||
| private: | |||
| char osc_type; | |||
| std::pair<Fl_Callback*, void*> cb_data; | |||
| }; | |||
| @@ -10,7 +10,7 @@ | |||
| #include <sstream> | |||
| Fl_Osc_VSlider::Fl_Osc_VSlider(int X, int Y, int W, int H, const char *label) | |||
| :Fl_Osc_Slider(X,Y,W,H,label), cb_data(NULL, NULL) | |||
| :Fl_Osc_Slider(X,Y,W,H,label) | |||
| { | |||
| //bounds(0.0f,1.0f); | |||
| Fl_Slider::callback(Fl_Osc_Slider::_cb); | |||
| @@ -21,6 +21,7 @@ class Fl_Oscilloscope : public Fl_Box, public Fl_Osc_Widget | |||
| { | |||
| phase=64; | |||
| box(FL_FLAT_BOX); | |||
| bkgnd = fl_color_average( FL_BLACK, FL_BACKGROUND_COLOR, 0.5 ); | |||
| } | |||
| ~Fl_Oscilloscope(void) | |||
| @@ -80,8 +81,8 @@ class Fl_Oscilloscope : public Fl_Box, public Fl_Osc_Widget | |||
| { | |||
| int ox=x(),oy=y(),lx=w(),ly=h()-1; | |||
| if (damage()!=1){ | |||
| fl_color( fl_color_average( FL_BLACK, FL_BACKGROUND_COLOR, 0.5 )); | |||
| if (damage()!=1) { | |||
| fl_color(bkgnd); | |||
| fl_rectf(ox,oy,lx,ly); | |||
| } | |||
| @@ -117,12 +118,16 @@ class Fl_Oscilloscope : public Fl_Box, public Fl_Osc_Widget | |||
| double ph=((phase-64.0)/128.0*oscilsize+oscilsize); | |||
| for (int i=1;i<lx;i++){ | |||
| int k2=(oscilsize*i/lx)+ph; | |||
| double y2=smps[k2%oscilsize]; | |||
| fl_vertex(i+ox,y2*ly/2.0+oy+ly/2); | |||
| fl_vertex(i+ox,(smps[k2%oscilsize]+1)*(ly-1)/2+oy+0.5); | |||
| } | |||
| fl_end_line(); | |||
| } | |||
| // Erase stray pixels on margin | |||
| fl_color(bkgnd); | |||
| fl_line_style(FL_SOLID,1); | |||
| fl_rect(ox-1,oy-1,lx+2,ly+2); | |||
| fl_line_style(FL_SOLID,0); | |||
| } | |||
| @@ -143,4 +148,5 @@ class Fl_Oscilloscope : public Fl_Box, public Fl_Osc_Widget | |||
| float *smps; | |||
| int oscilsize; | |||
| Fl_Color bkgnd; | |||
| }; | |||
| @@ -24,6 +24,8 @@ class FormantFilterGraph : public Fl_Box, public Fl_Osc_Widget { | |||
| void OSC_value(int x, const char *) override; | |||
| void OSC_value(unsigned x, void *v) override; | |||
| void rebase(std::string new_base) override; | |||
| void updateVowel(int); | |||
| void updateFormant(int); | |||
| @@ -83,6 +83,19 @@ void FormantFilterGraph::update(void) | |||
| oscWrite("Pq"); | |||
| } | |||
| void FormantFilterGraph::rebase(std::string new_base) | |||
| { | |||
| osc->renameLink(loc+"Pvowels", new_base+"Pvowels", this); | |||
| osc->renameLink(loc+"Pnumformants", new_base+"Pnumformants", this); | |||
| osc->renameLink(loc+"Pstages", new_base+"Pstages", this); | |||
| osc->renameLink(loc+"Pcenterfreq", new_base+"Pcenterfreq", this); | |||
| osc->renameLink(loc+"Poctavesfreq", new_base+"Poctavesfreq", this); | |||
| osc->renameLink(loc+"Pgain", new_base+"Pgain", this); | |||
| osc->renameLink(loc+"Pq", new_base+"Pq", this); | |||
| loc = new_base; | |||
| update(); | |||
| } | |||
| //TODO A good portion of this is copy/pasta from EnvelopUI's widget | |||
| // REFACTOR! | |||
| void FormantFilterGraph::draw() | |||
| @@ -64,6 +64,9 @@ decl {\#include "Fl_Osc_Dial.H"} {private local | |||
| decl {\#include "Osc_DataModel.h"} {private local | |||
| } | |||
| decl {\#include "Fl_Osc_TSlider.H"} {private local | |||
| } | |||
| decl {\#include "VuMasterMeter.h"} {public local | |||
| } | |||
| @@ -146,11 +149,11 @@ bankui->show();} | |||
| Fl_Slider partvolume { | |||
| xywh {10 65 30 110} type {Vert Knob} box NO_BOX minimum 127 maximum 0 step 1 value 127 | |||
| code0 {o->init("Pvolume", 'i');} | |||
| class Fl_Osc_Slider | |||
| class Fl_Osc_TSlider | |||
| } | |||
| Fl_Dial partpanning { | |||
| xywh {20 180 30 30} maximum 127 step 1 | |||
| code0 {o->init("Ppanning");} | |||
| code0 {o->init("Ppanning");o->reset_value=64;} | |||
| class Fl_Osc_Dial | |||
| } | |||
| Fl_Button {} { | |||
| @@ -471,7 +474,7 @@ if (fl_choice("The file *might* exist. \\nOverwrite it?","No","Yes",NULL)) { | |||
| Fl_Dial mastervolumedial { | |||
| label {Master Volume} | |||
| tooltip {Master Volume} xywh {15 32 55 55} box ROUND_UP_BOX labelsize 9 align 130 maximum 127 step 1 | |||
| code2 {o->init("volume");} | |||
| code2 {o->init("volume"); o->selection_color(FL_RED);} | |||
| class Fl_Osc_Dial | |||
| } | |||
| Fl_Counter masterkeyshiftcounter { | |||
| @@ -1051,8 +1054,8 @@ bankui->show();} | |||
| Fl_Slider partpanning { | |||
| label Pan | |||
| xywh {185 95 145 15} type {Horz Knob} box NO_BOX labelsize 11 maximum 127 step 1 value 64 | |||
| code0 {o->init("Ppanning",'i');} | |||
| class Fl_Osc_Slider | |||
| code0 {o->init("Ppanning",'i'); o->reset_value=64;} | |||
| class Fl_Osc_TSlider | |||
| } | |||
| Fl_Choice partrcv { | |||
| label {Midi Channel Receive} | |||
| @@ -59,7 +59,10 @@ decl {\#include "Fl_Osc_Choice.H"} {public local | |||
| decl {\#include "Fl_Osc_Counter.H"} {public local | |||
| } | |||
| decl {\#include "Fl_Osc_Slider.H"} {public local | |||
| decl {\#include "Fl_Osc_TSlider.H"} {public local | |||
| } | |||
| decl {\#include "Fl_Osc_VSlider.H"} {public local | |||
| } | |||
| decl {\#include "PresetsUI.h"} {public local | |||
| @@ -68,42 +71,27 @@ decl {\#include "PresetsUI.h"} {public local | |||
| decl {\#include <FL/fl_draw.H>} {public local | |||
| } | |||
| class PSlider {: {public Fl_Slider, public Fl_Osc_Widget} | |||
| class OGSlider {: {public Fl_Osc_TSlider} | |||
| } { | |||
| Function {PSlider(int x,int y, int w, int h, const char *label=0):Fl_Slider(x,y,w,h,label)} {open | |||
| } { | |||
| code {phase=false;} {} | |||
| } | |||
| Function {handle(int event)} {open return_type int | |||
| } { | |||
| code {int X=x(),Y=y(),W=w(),H=h(); | |||
| if ((!Fl::event_buttons())|| (event==0)||(Fl::event_shift()==0)) return(Fl_Slider::handle(event)); | |||
| if (!Fl::event_inside(X,Y,W,H)) { | |||
| if (event==FL_DRAG){ | |||
| Fl_Slider::handle(FL_RELEASE); | |||
| Fl_Slider::handle(FL_LEAVE); | |||
| deactivate(); | |||
| activate(); | |||
| return(1); | |||
| }else{ | |||
| return(Fl_Slider::handle(event)); | |||
| }; | |||
| } else { | |||
| //Fl_Slider::handle(FL_FOCUS); | |||
| Fl_Slider::handle(FL_PUSH); | |||
| }; | |||
| Function {OGSlider(int x,int y, int w, int h, const char *label=0) | |||
| :Fl_Osc_TSlider(x,y,w,h,label)} {open | |||
| } { code {phase=false; } {} } | |||
| return(1);} {} | |||
| } | |||
| Function {OSC_value(char c)} {open return_type void | |||
| } { | |||
| code {if(phase) | |||
| value(c); | |||
| else | |||
| value(127-c);} {} | |||
| } | |||
| } { code {value(phase ? c : 127-c); | |||
| selection_color(value() == reset_value ? 0 : 222); | |||
| redraw(); | |||
| } {} } | |||
| Function {cb(void)} {open return_type void | |||
| } { code { | |||
| selection_color(value() == reset_value ? 0 : 222); | |||
| if(cb_data.first) cb_data.first(this, cb_data.second); | |||
| } {} } | |||
| Function {update(void)} {open return_type void | |||
| } { code {} {} } | |||
| decl {bool phase;} {public local | |||
| } | |||
| } | |||
| @@ -117,16 +105,15 @@ class Oscilharmonic {: {public Fl_Group} | |||
| class Fl_Osc_Group visible | |||
| } { | |||
| Fl_Slider mag { | |||
| callback {int x=64; | |||
| if (Fl::event_button3()) o->value(x); | |||
| else x=128-(int)o->value(); | |||
| if (x==64) o->selection_color(0); | |||
| else o->selection_color(222); | |||
| callback {int x=127-(int)o->value(); | |||
| //if (x==64) o->selection_color(0); | |||
| // else o->selection_color(222); | |||
| o->osc->writeValue(o->loc+"magnitude"+to_s(n), (char)x); | |||
| if (x==64) { | |||
| o->osc->writeValue(o->loc+"phase"+to_s(n), (char)64); | |||
| phase->value(64); | |||
| phase->selection_color(0); | |||
| } | |||
| o->osc->requestValue(o->loc+"prepare"); | |||
| o->osc->requestValue(o->loc+"spectrum"); | |||
| @@ -136,14 +123,11 @@ display->redraw();} | |||
| xywh {0 15 15 115} type {Vert Knob} box NO_BOX selection_color 222 maximum 127 step 1 value 64 | |||
| code0 {o->phase=false;//o->value(127-oscil->Phmag[n]);} | |||
| code1 {//if (oscil->Phmag[n]==64) o->selection_color(0);} | |||
| class PSlider | |||
| class OGSlider | |||
| } | |||
| Fl_Slider phase { | |||
| callback {int x=64; | |||
| if (Fl::event_button3()) o->value(x); | |||
| else x=(int)o->value(); | |||
| o->osc->writeValue(o->loc+"phase"+to_s(n), (char) x); | |||
| callback { | |||
| o->osc->writeValue(o->loc+"phase"+to_s(n), (char) o->value()); | |||
| o->osc->requestValue(o->loc+"prepare"); | |||
| o->osc->requestValue(o->loc+"spectrum"); | |||
| o->osc->requestValue(o->loc+"waveform"); | |||
| @@ -151,7 +135,7 @@ o->osc->requestValue(o->loc+"waveform"); | |||
| display->redraw();} | |||
| xywh {0 135 15 75} type {Vert Knob} box NO_BOX selection_color 222 maximum 127 step 1 value 64 | |||
| code0 {o->phase=true;//o->value(oscil->Phphase[n]);} | |||
| class PSlider | |||
| class OGSlider | |||
| } | |||
| Fl_Box {} { | |||
| xywh {15 70 5 5} box FLAT_BOX color 45 | |||
| @@ -187,8 +171,13 @@ loc = loc_; | |||
| make_window(); | |||
| mag->osc = osc; | |||
| mag->loc = loc; | |||
| mag->reset_value = 63; | |||
| mag->setTransform(-1, 63); | |||
| phase->osc = osc; | |||
| phase->loc = loc; | |||
| phase->reset_value = 64; | |||
| phase->setRounding(1); | |||
| phase->setTransform(-180.0/64, 180.0); | |||
| osc->createLink(loc+"magnitude"+to_s(n), mag); | |||
| osc->createLink(loc+"phase"+to_s(n), phase); | |||
| @@ -201,11 +190,7 @@ harmonic->show();} {} | |||
| } { | |||
| code {osc->requestValue(loc+"magnitude"+to_s(n));//mag->value(127-oscil->Phmag[n]); | |||
| osc->requestValue(loc+"phase"+to_s(n));//phase->value(oscil->Phphase[n]); | |||
| if (mag->value()==64) | |||
| mag->selection_color(0); | |||
| else | |||
| mag->selection_color(222);} {} | |||
| } {} | |||
| } | |||
| Function {~Oscilharmonic()} {open | |||
| } { | |||
| @@ -265,10 +250,10 @@ class OscilEditor {open : {public PresetsUI_} | |||
| } | |||
| Fl_Value_Slider rndslider { | |||
| label rnd | |||
| callback {(void)o;//oscil->Prand=(int)o->value()+64; | |||
| oscildisplaygroup->redraw();} | |||
| callback {} | |||
| tooltip {Oscilator Phase Randomness: smaller than 0 is "group", larger than 0 is for each harmonic} xywh {145 290 100 10} type {Horz Knob} box NO_BOX labelsize 10 align 5 minimum -64 maximum 63 step 1 | |||
| code0 {(void)o;//if (oscil->ADvsPAD) o->hide();} | |||
| code0 {(void)o->init("Prand");//if (oscil->ADvsPAD) o->hide();} | |||
| class Fl_Osc_VSlider | |||
| } | |||
| Fl_Group {} {open | |||
| xywh {15 35 350 50} box THIN_DOWN_BOX color 32 selection_color 218 labelcolor 63 | |||
| @@ -494,8 +479,8 @@ redrawoscil();} | |||
| label {Use as base} | |||
| callback {osc->requestValue(loc+"use-as-base"); | |||
| if (autoclearbutton->value()){ | |||
| for (int i=0;i<(MAX_AD_HARMONICS - 1);i++){ | |||
| h[i]->mag->value(64); | |||
| for (int i=1;i<(MAX_AD_HARMONICS - 1);i++){ | |||
| h[i]->mag->value(63); | |||
| h[i]->mag->do_callback(); | |||
| h[i]->phase->value(64); | |||
| h[i]->phase->do_callback(); | |||
| @@ -505,6 +490,8 @@ if (autoclearbutton->value()){ | |||
| h[0]->mag->value(0); | |||
| h[0]->mag->do_callback(); | |||
| h[0]->phase->value(64); | |||
| h[0]->phase->do_callback(); | |||
| wshbutton->value(0); | |||
| wshbutton->do_callback(); | |||
| fltbutton->value(0); | |||
| @@ -528,19 +515,16 @@ redrawoscil();} | |||
| label Clear | |||
| callback {if (!fl_choice("Clear the harmonics settings?","No","Yes",NULL)) return; | |||
| for (int i=0;i<(MAX_AD_HARMONICS - 1);i++){ | |||
| h[i]->mag->value(64); | |||
| for (int i=1;i<(MAX_AD_HARMONICS - 1);i++){ | |||
| h[i]->mag->value(63); | |||
| h[i]->mag->do_callback(); | |||
| h[i]->phase->value(64); | |||
| h[i]->phase->do_callback(); | |||
| }; | |||
| h[0]->mag->value(0); | |||
| h[0]->mag->do_callback(); | |||
| //for (int i=0;i<(MAX_AD_HARMONICS - 1);i++){ | |||
| // if (oscil->Phmag[i]==64) h[i]->mag->selection_color(0); | |||
| // else h[i]->mag->selection_color(222); | |||
| //}; | |||
| h[0]->phase->value(64); | |||
| h[0]->phase->do_callback(); | |||
| //harmonics->redraw(); | |||
| osc->requestValue(loc+"prepare"); | |||
| @@ -839,10 +823,10 @@ redrawoscil();} | |||
| class Fl_Osc_Dial | |||
| } | |||
| Fl_Slider adhrpar { | |||
| code0 {o->init("Padaptiveharmonicspar");} | |||
| code0 {o->init("Padaptiveharmonicspar");o->reset_value=50;} | |||
| callback {redrawoscil();} | |||
| xywh {675 450 55 10} type {Horz Knob} box NO_BOX maximum 100 step 1 value 50 | |||
| class Fl_Osc_Slider | |||
| class Fl_Osc_TSlider | |||
| } | |||
| } | |||
| Fl_Group {} { | |||
| @@ -32,7 +32,7 @@ decl {\#include <string.h>} {private local | |||
| decl {\#include <string>} {public local | |||
| } | |||
| decl {\#include "Fl_Osc_Slider.H"} {public local | |||
| decl {\#include "Fl_Osc_TSlider.H"} {public local | |||
| } | |||
| decl {\#include "Fl_Osc_VSlider.H"} {public local | |||
| @@ -41,7 +41,7 @@ decl {\#include "Fl_Osc_Button.H"} {public local | |||
| decl {\#include "Fl_Osc_Check.H"} {public local | |||
| } | |||
| decl {\#include "Fl_Osc_Roller.H"} {public local | |||
| decl {\#include "Fl_Osc_Slider.H"} {public local | |||
| } | |||
| decl {\#include "Fl_Osc_Output.H"} {public local | |||
| @@ -99,12 +99,12 @@ redrawPADnoteApply();} | |||
| code0 {o->init("Penabled");} | |||
| class Fl_Osc_Check | |||
| } | |||
| Fl_Roller maxdb { | |||
| Fl_Slider maxdb { | |||
| callback {maxdbvo->value(o->value()); | |||
| redrawPADnoteApply();} | |||
| xywh {90 282 84 15} type Horizontal minimum 1 maximum 90 step 1 value 30 | |||
| code0 {o->init("PmaxdB");} | |||
| class Fl_Osc_Roller | |||
| code0 {o->init("PmaxdB", 'i'); o->reset_value = 30;} | |||
| class Fl_Osc_Slider | |||
| } | |||
| Fl_Value_Output maxdbvo { | |||
| label {Max.} | |||
| @@ -23,6 +23,9 @@ decl {\#include "../globals.h"} {public local | |||
| decl {\#include "Fl_Osc_VSlider.H"} {public local | |||
| } | |||
| decl {\#include "Fl_Osc_TSlider.H"} {public local | |||
| } | |||
| decl {\#include "Fl_Osc_Dial.H"} {public local | |||
| } | |||
| @@ -41,66 +44,27 @@ decl {\#include "../Params/SUBnoteParameters.h"} {public local | |||
| decl {\#include "PresetsUI.h"} {public local | |||
| } | |||
| class PPSlider {: {public Fl_Slider, public Fl_Osc_Widget} | |||
| class SUBSlider {: {public Fl_Osc_TSlider} | |||
| } { | |||
| Function {PPSlider(int x,int y, int w, int h, const char *label=0):Fl_Slider(x,y,w,h,label),Fl_Osc_Widget(this)} {open | |||
| Function {SUBSlider(int x,int y, int w, int h, const char *label=0) | |||
| :Fl_Osc_TSlider(x,y,w,h,label)} {open | |||
| } { code {}} | |||
| Function {OSC_value(char c)} {open return_type void | |||
| } { code { | |||
| value(127-c); | |||
| selection_color(value() == reset_value ? 0 : 222); | |||
| } {} } | |||
| Function {cb(void)} {open return_type void | |||
| } { | |||
| code {//Shamelessly copied from OscilGenUI.fl TODO refactor | |||
| bw=false;} {} | |||
| } | |||
| Function {handle(int event)} {open return_type int | |||
| } { | |||
| code {int X=x(),Y=y(),W=w(),H=h(); | |||
| // catch any (un)learn event first | |||
| { | |||
| bool middle_mouse = (event == FL_PUSH && Fl::event_state(FL_BUTTON2) && !Fl::event_shift()); | |||
| bool ctl_click = (event == FL_PUSH && Fl::event_state(FL_BUTTON1) && Fl::event_ctrl()); | |||
| bool shift_middle = (event == FL_PUSH && Fl::event_state(FL_BUTTON2) && Fl::event_shift()); | |||
| if(middle_mouse || ctl_click) { | |||
| osc->write("/learn", "s", (loc+ext).c_str()); | |||
| return 1; | |||
| } else if(shift_middle) { | |||
| osc->write("/unlearn", "s", (loc+ext).c_str()); | |||
| return 1; | |||
| } | |||
| code { | |||
| selection_color(value() == reset_value ? 0 : 222); | |||
| oscWrite(ext, "c", (int)(127-Fl_Slider::value())); | |||
| if(cb_data.first) | |||
| cb_data.first(this, cb_data.second); | |||
| } {} | |||
| } | |||
| } | |||
| if ((!Fl::event_buttons())|| (event==0)||(Fl::event_shift()==0)) return(Fl_Slider::handle(event)); | |||
| if (!Fl::event_inside(X,Y,W,H)) { | |||
| if (event==FL_DRAG){ | |||
| Fl_Slider::handle(FL_RELEASE); | |||
| Fl_Slider::handle(FL_LEAVE); | |||
| deactivate(); | |||
| activate(); | |||
| return(1); | |||
| }else{ | |||
| return(Fl_Slider::handle(event)); | |||
| }; | |||
| } else { | |||
| //Fl_Slider::handle(FL_FOCUS); | |||
| Fl_Slider::handle(FL_PUSH); | |||
| }; | |||
| return(1);} {} | |||
| } | |||
| Function {rebase(std::string new_base)} {return_type void | |||
| } { | |||
| code {(void) new_base;} {} | |||
| } | |||
| Function {update()} {return_type void | |||
| } { | |||
| code {} {} | |||
| } | |||
| Function {OSC_value(char c)} {open return_type void | |||
| } { | |||
| code {value(127-c+fmodf(value(), 1.0f));} {} | |||
| } | |||
| decl {bool bw;} {public local | |||
| } | |||
| } | |||
| class SUBnoteharmonic {: {public Fl_Osc_Group} | |||
| } { | |||
| Function {make_window()} {private | |||
| @@ -110,23 +74,12 @@ class SUBnoteharmonic {: {public Fl_Osc_Group} | |||
| class Fl_Osc_Group | |||
| } { | |||
| Fl_Slider mag { | |||
| callback {//TODO consider unifying this with the OscilGenUI display stuff | |||
| int x=0; | |||
| if (Fl::event_button1() || Fl::event() == FL_MOUSEWHEEL) x=127-(int)o->value(); | |||
| else o->value(127-x); | |||
| o->osc->writeValue(o->loc + o->ext, (char) x); | |||
| if (x==0) o->selection_color(0); | |||
| else o->selection_color(222);} | |||
| tooltip {harmonic's magnitude} xywh {0 15 10 135} type {Vert Knob} box FLAT_BOX selection_color 222 maximum 127 step 1 value 127 | |||
| class PPSlider | |||
| tooltip {harmonic's magnitude} xywh {0 15 10 135} type {Vert Knob} box FLAT_BOX selection_color 0 maximum 127 step 1 value 127 | |||
| class SUBSlider | |||
| } | |||
| Fl_Slider bw { | |||
| callback {int x=64; | |||
| if (Fl::event_button1() || Fl::event() == FL_MOUSEWHEEL) x=127-(int)o->value(); | |||
| else o->value(x); | |||
| o->osc->writeValue(o->loc + o->ext, (char) x)}; | |||
| tooltip {harmonic's bandwidth} xywh {0 157 10 130} type {Vert Knob} box FLAT_BOX selection_color 222 maximum 127 step 1 value 64 | |||
| class PPSlider | |||
| class SUBSlider | |||
| } | |||
| Fl_Box {} { | |||
| xywh {10 219 5 5} box FLAT_BOX color 45 | |||
| @@ -151,10 +104,14 @@ if (Fl::event_button1() || Fl::event() == FL_MOUSEWHEEL) x=127-(int)o->value(); | |||
| code {n=n_; | |||
| make_window(); | |||
| harmonic->show(); | |||
| mag->reset_value=127; | |||
| mag->ext = "Phmag" + to_s(n); | |||
| mag->oscRegister(mag->ext.c_str()); | |||
| mag->setTransform(-1, 127); | |||
| bw->reset_value=63; | |||
| bw->ext = "Phrelbw" + to_s(n); | |||
| bw->oscRegister(bw->ext.c_str()); | |||
| bw->setTransform(-1, 63); | |||
| osc->requestValue(base+"Phrelbw"+to_s(n)); | |||
| end();} {} | |||
| @@ -362,11 +319,12 @@ freqsettingsui->redraw();} | |||
| Fl_Button {} { | |||
| label Clear | |||
| callback {o->oscWrite("clear"); | |||
| for (int i=0;i<MAX_SUB_HARMONICS;i++){ | |||
| h[i]->mag->value(127); | |||
| h[i]->bw->value(64); | |||
| for (int i=1;i<MAX_SUB_HARMONICS;i++){ | |||
| h[i]->mag->oscWrite(h[i]->mag->ext, "c", 0); | |||
| h[i]->bw->oscWrite(h[i]->bw->ext, "c", 64); | |||
| }; | |||
| h[0]->mag->value(0); | |||
| h[0]->mag->oscWrite(h[0]->mag->ext, "c", 127); | |||
| h[0]->bw->oscWrite(h[0]->bw->ext, "c", 64); | |||
| SUBparameters->redraw();} | |||
| tooltip {Clear the harmonics} xywh {445 446 70 20} box THIN_UP_BOX labelfont 1 labelsize 11 | |||
| class Fl_Osc_Button | |||
| @@ -401,7 +359,7 @@ bandwidthsettingsui->redraw();} | |||
| label {B.Width Scale} | |||
| tooltip {How much I increase the BandWidth according to lower/higher harmonics} xywh {345 40 90 15} type {Horz Knob} box NO_BOX labelsize 10 align 1 minimum -64 maximum 63 step 1 | |||
| code0 {o->init("Pbwscale",'i');} | |||
| class Fl_Osc_Slider | |||
| class Fl_Osc_TSlider | |||
| } | |||
| } | |||
| Fl_Group globalfiltergroup { | |||