commit 65fe9a6031fa248204e83e5c21d54cd0572f22aa
parent 97dfb820581b8408cfb34ddae73d6722692d445c
Author: fundamental <[email protected]>
Date: Tue, 1 Jul 2014 14:05:14 -0400
Merge origin/abs into master (using imerge)
Diffstat:
118 files changed, 10990 insertions(+), 6152 deletions(-)
diff --git a/.gitmodules b/.gitmodules
@@ -1,3 +1,6 @@
[submodule "instruments"]
path = instruments
url = git://git.code.sf.net/p/zynaddsubfx/instruments
+[submodule "rtosc"]
+ path = rtosc
+ url = https://github.com/fundamental/rtosc
diff --git a/CMakeLists.txt b/CMakeLists.txt
@@ -1,8 +1,13 @@
cmake_minimum_required(VERSION 2.8)
-set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")
+set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
project(zynaddsubfx)
set(VERSION "2.4.4")
+
+#Include RTOSC
+add_subdirectory(rtosc)
+include_directories(rtosc/include)
+
enable_testing()
include(CTestConfig.cmake)
#Currently the only directory that uses cmake
diff --git a/rtosc b/rtosc
@@ -0,0 +1 @@
+Subproject commit e40ae9fb3730b8fa0d759a40cef6968a48e70696
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
@@ -26,7 +26,7 @@ pkg_search_module(LASH lash-1.0)
mark_as_advanced(LASH_LIBRARIES)
pkg_search_module(DSSI dssi>=0.9.0)
mark_as_advanced(DSSI_LIBRARIES)
-pkg_search_module(LIBLO liblo>=0.26)
+pkg_search_module(LIBLO liblo>=0.26 REQUIRED)
mark_as_advanced(LIBLO_LIBRARIES)
CHECK_FUNCTION_EXISTS(sched_setscheduler HAVE_SCHEDULER)
@@ -127,22 +127,22 @@ option (BuildForDebug "Include gdb debugging support" OFF)
set(CMAKE_BUILD_TYPE "Release")
set (BuildOptions_x86_64AMD
- "-O3 -march=athlon64 -m64 -Wall -ffast-math -fno-finite-math-only -fomit-frame-pointer"
+ "-std=c++0x -O3 -march=athlon64 -m64 -Wall -ffast-math -fno-finite-math-only -fomit-frame-pointer"
CACHE STRING "X86_64 compiler options"
)
set (BuildOptions_X86_64Core2
- "-O3 -march=core2 -m64 -Wall -ffast-math -fno-finite-math-only -fomit-frame-pointer"
+ "-std=c++0x -O3 -march=core2 -m64 -Wall -ffast-math -fno-finite-math-only -fomit-frame-pointer"
CACHE STRING "X86_64 compiler options"
)
set (BuildOptionsBasic
- "-O3 -msse -msse2 -mfpmath=sse -ffast-math -fomit-frame-pointer"
+ "-std=c++0x -O3 -msse -msse2 -mfpmath=sse -ffast-math -fomit-frame-pointer"
CACHE STRING "basic X86 complier options"
)
set (BuildOptionsDebug
- "-O0 -g3 -ggdb -Wall -Wpointer-arith" CACHE STRING "Debug build flags")
+ "-std=c++0x -O0 -g3 -ggdb -Wall -Wpointer-arith" CACHE STRING "Debug build flags")
########### Settings dependant code ###########
# From here on, the setting variables have been prepared so concentrate
@@ -335,7 +335,8 @@ target_link_libraries(zynaddsubfx_core
${FFTW_LIBRARIES}
${MXML_LIBRARIES}
${OS_LIBRARIES}
- pthread)
+ pthread
+ rtosc rtosc-cpp)
if(CompileTests)
add_subdirectory(Tests)
@@ -346,15 +347,17 @@ message(STATUS "using link directories: ${AUDIO_LIBRARY_DIRS} ${ZLIB_LIBRARY_DIR
add_executable(zynaddsubfx main.cpp)
+#Warning: the required ordering of these to get proper linking depends upon the
+# phase of the moon
target_link_libraries(zynaddsubfx
+ ${GUI_LIBRARIES}
zynaddsubfx_core
zynaddsubfx_nio
- ${GUI_LIBRARIES}
${NIO_LIBRARIES}
${AUDIO_LIBRARIES}
)
-if (DssiEnable)
+if (DssiEnable AND FALSE)
add_library(zynaddsubfx_dssi SHARED
Output/DSSIaudiooutput.cpp
)
diff --git a/src/DSP/AnalogFilter.h b/src/DSP/AnalogFilter.h
@@ -48,6 +48,12 @@ class AnalogFilter:public Filter
void cleanup();
float H(float freq); //Obtains the response for a given frequency
+
+
+ struct Coeff {
+ float c[3], //Feed Forward
+ d[3]; //Feed Back
+ } coeff, oldCoeff;
private:
struct fstage {
@@ -55,10 +61,6 @@ class AnalogFilter:public Filter
float y1, y2; //Output History
} history[MAX_FILTER_STAGES + 1], oldHistory[MAX_FILTER_STAGES + 1];
- struct Coeff {
- float c[3], //Feed Forward
- d[3]; //Feed Back
- } coeff, oldCoeff;
//old coeffs are used for interpolation when paremeters change quickly
//Apply IIR filter to Samples, with coefficients, and past history
diff --git a/src/Effects/EQ.cpp b/src/Effects/EQ.cpp
@@ -196,3 +196,42 @@ float EQ::getfreqresponse(float freq)
}
return rap2dB(resp * outvolume);
}
+
+//full taps & three filter taps
+static void convolve(float *a, const float *filter)
+{
+ float tmp[MAX_EQ_BANDS*2+1];
+
+ for(int i=0; i<MAX_EQ_BANDS*2+1; ++i)
+ tmp[i] = a[i];
+
+ //Base Case
+ a[0] = tmp[0]*filter[0];
+ a[1] = tmp[0]*filter[1] + tmp[1]*filter[0];
+
+ for(int i=2; i<MAX_EQ_BANDS+1; ++i) {
+ a[i] = filter[0]*tmp[i] +
+ filter[1]*tmp[i-1] +
+ filter[2]*tmp[i-2];
+ }
+}
+
+//Not exactly the most efficient manner to derive the total taps, but it should
+//be fast enough in practice
+void EQ::getFilter(float *a, float *b) const
+{
+ a[0] = 1;
+ b[0] = 1;
+ for(int i = 0; i < MAX_EQ_BANDS; ++i) {
+ auto &F = filter[i];
+ if(F.Ptype == 0)
+ continue;
+ float Fb[3] = {F.l->coeff.c[0], F.l->coeff.c[1], F.l->coeff.c[2]};
+ float Fa[3] = {1.0f, -F.l->coeff.d[1], -F.l->coeff.d[2]};
+
+ for(int j=0; j<F.Pstages+1; ++j) {
+ convolve(b, Fb);
+ convolve(a, Fa);
+ }
+ }
+}
diff --git a/src/Effects/EQ.h b/src/Effects/EQ.h
@@ -38,6 +38,8 @@ class EQ:public Effect
void cleanup(void);
float getfreqresponse(float freq);
+ void getFilter(float *a/*[MAX_EQ_BANDS*MAX_FILTER_STAGES*2+1]*/,
+ float *b/*[MAX_EQ_BANDS*MAX_FILTER_STAGES*2+1]*/) const;
private:
//Parameters
unsigned char Pvolume;
@@ -48,7 +50,13 @@ class EQ:public Effect
//parameters
unsigned char Ptype, Pfreq, Pgain, Pq, Pstages;
//internal values
- class AnalogFilter * l, *r;
+
+ /* TODO
+ * The analog filters here really ought to be dumbed down some as
+ * you are just looking to do a batch convolution in the end
+ * Perhaps some static functions to do the filter design?
+ */
+ class AnalogFilter *l, *r;
} filter[MAX_EQ_BANDS];
};
diff --git a/src/Effects/EffectMgr.cpp b/src/Effects/EffectMgr.cpp
@@ -20,6 +20,10 @@
*/
+#include <rtosc/ports.h>
+#include <rtosc/port-sugar.h>
+
+
#include "EffectMgr.h"
#include "Effect.h"
#include "Reverb.h"
@@ -29,19 +33,75 @@
#include "EQ.h"
#include "DynamicFilter.h"
#include "../Misc/XMLwrapper.h"
+#include "../Misc/Util.h"
#include "../Params/FilterParams.h"
-#include <iostream>
-using namespace std;
-EffectMgr::EffectMgr(const bool insertion_, pthread_mutex_t *mutex_)
+rtosc::Ports EffectMgr::ports = {
+ RECURP(EffectMgr, FilterParams, Filter, filterpars, "Filter Parameter for Dynamic Filter"),
+ {"parameter#64::c", rProp(alias), NULL, [](const char *msg, rtosc::RtData &d)
+ {
+ EffectMgr *eff = (EffectMgr*)d.obj;
+ const char *mm = msg;
+ while(!isdigit(*mm))++mm;
+
+ if(!rtosc_narguments(msg))
+ d.reply(d.loc, "c", eff->geteffectpar(atoi(mm)));
+ else
+ eff->seteffectpar_nolock(atoi(mm), rtosc_argument(msg, 0).i);
+ }},
+ {"preset::c", rProp(alias), NULL, [](const char *msg, rtosc::RtData &d)
+ {
+ EffectMgr *eff = (EffectMgr*)d.obj;
+ if(!rtosc_narguments(msg))
+ d.reply(d.loc, "c", eff->getpreset());
+ else
+ eff->changepreset_nolock(rtosc_argument(msg, 0).i);
+ }},
+ {"eq-coeffs:", rProp(internal), NULL, [](const char *, rtosc::RtData &d)
+ {
+ EffectMgr *eff = (EffectMgr*)d.obj;
+ if(eff->nefx != 7)
+ return;
+ EQ *eq = (EQ*)eff->efx;
+ float a[MAX_EQ_BANDS*MAX_FILTER_STAGES*2+1];
+ float b[MAX_EQ_BANDS*MAX_FILTER_STAGES*2+1];
+ memset(a, 0, sizeof(a));
+ memset(b, 0, sizeof(b));
+ eq->getFilter(a,b);
+ d.reply(d.loc, "bb", sizeof(a), a, sizeof(b), b);
+ }},
+ {"efftype:", rProp(internal), NULL, [](const char *, rtosc::RtData &d)
+ {
+ EffectMgr *eff = (EffectMgr*)d.obj;
+ d.reply(d.loc, "c", eff->nefx);
+ }},
+ {"efftype:b", rProp(internal), NULL, [](const char *msg, rtosc::RtData &d)
+ {
+ EffectMgr *eff = (EffectMgr*)d.obj;
+ EffectMgr *eff_ = *(EffectMgr**)rtosc_argument(msg,0).b.data;
+
+ //Lets trade data
+ std::swap(eff->nefx,eff_->nefx);
+ std::swap(eff->efx,eff_->efx);
+ std::swap(eff->filterpars,eff_->filterpars);
+ std::swap(eff->efxoutl, eff_->efxoutl);
+ std::swap(eff->efxoutr, eff_->efxoutr);
+
+ //Return the old data for distruction
+ d.reply("/free", "sb", "EffectMgr", sizeof(EffectMgr*), &eff_);
+ }},
+
+};
+
+
+EffectMgr::EffectMgr(const bool insertion_)
:insertion(insertion_),
efxoutl(new float[synth->buffersize]),
efxoutr(new float[synth->buffersize]),
filterpars(NULL),
nefx(0),
efx(NULL),
- mutex(mutex_),
dryonly(false)
{
setpresettype("Peffect");
@@ -67,6 +127,10 @@ void EffectMgr::defaults(void)
//Change the effect
void EffectMgr::changeeffect(int _nefx)
{
+ //TODO there should be a sane way to upper bound the memory of every effect
+ //and just use placement new to eliminate any allocation/deallocation when
+ //chaning effects
+
cleanup();
if(nefx == _nefx)
return;
@@ -142,9 +206,7 @@ void EffectMgr::changepreset_nolock(unsigned char npreset)
//Change the preset of the current effect(with thread locking)
void EffectMgr::changepreset(unsigned char npreset)
{
- pthread_mutex_lock(mutex);
- changepreset_nolock(npreset);
- pthread_mutex_unlock(mutex);
+ abort();
}
@@ -159,9 +221,7 @@ void EffectMgr::seteffectpar_nolock(int npar, unsigned char value)
// Change a parameter of the current effect (with thread locking)
void EffectMgr::seteffectpar(int npar, unsigned char value)
{
- pthread_mutex_lock(mutex);
- seteffectpar_nolock(npar, value);
- pthread_mutex_unlock(mutex);
+ abort();
}
//Get a parameter of the current effect
diff --git a/src/Effects/EffectMgr.h b/src/Effects/EffectMgr.h
@@ -43,7 +43,7 @@ class XMLwrapper;
class EffectMgr:public Presets
{
public:
- EffectMgr(const bool insertion_, pthread_mutex_t *mutex_);
+ EffectMgr(const bool insertion_);
~EffectMgr();
void add2XML(XMLwrapper *xml);
@@ -76,10 +76,10 @@ class EffectMgr:public Presets
FilterParams *filterpars;
- private:
+ static rtosc::Ports ports;
int nefx;
Effect *efx;
- pthread_mutex_t *mutex;
+ private:
bool dryonly;
};
diff --git a/src/Misc/Bank.cpp b/src/Misc/Bank.cpp
@@ -23,13 +23,12 @@
*/
#include "Bank.h"
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstring>
+#include <cstdio>
+#include <cstdlib>
#include <dirent.h>
#include <sys/stat.h>
#include <algorithm>
-#include <iostream>
#include <sys/types.h>
#include <fcntl.h>
@@ -103,7 +102,7 @@ void Bank::setname(unsigned int ninstrument, const string &newname, int newslot)
if(tmpfilename[i] == ' ')
tmpfilename[i] = '0';
- newfilename = dirname + '/' + legalizeFilename(tmpfilename) + ".xiz";
+ newfilename = dirname + legalizeFilename(tmpfilename) + ".xiz";
rename(ins[ninstrument].filename.c_str(), newfilename.c_str());
@@ -121,10 +120,7 @@ bool Bank::emptyslot(unsigned int ninstrument)
if(ins[ninstrument].filename.empty())
return true;
- if(ins[ninstrument].used)
- return false;
- else
- return true;
+ return false;
}
/*
@@ -275,6 +271,7 @@ int Bank::newbank(string newbankdirname)
*/
int Bank::locked()
{
+ //XXX Fixme
return dirname.empty();
}
@@ -409,7 +406,7 @@ void Bank::clearbank()
int Bank::addtobank(int pos, string filename, string name)
{
if((pos >= 0) && (pos < BANK_SIZE)) {
- if(ins[pos].used)
+ if(!ins[pos].filename.empty())
pos = -1; //force it to find a new free position
}
else
@@ -419,7 +416,7 @@ int Bank::addtobank(int pos, string filename, string name)
if(pos < 0) //find a free position
for(int i = BANK_SIZE - 1; i >= 0; i--)
- if(!ins[i].used) {
+ if(ins[i].filename.empty()) {
pos = i;
break;
}
@@ -429,32 +426,11 @@ int Bank::addtobank(int pos, string filename, string name)
deletefrombank(pos);
- ins[pos].used = true;
ins[pos].name = name;
- ins[pos].filename = dirname + '/' + filename;
-
- //see if PADsynth is used
- if(config.cfg.CheckPADsynth) {
- XMLwrapper xml;
- xml.loadXMLfile(ins[pos].filename);
-
- ins[pos].info.PADsynth_used = xml.hasPadSynth();
- }
- else
- ins[pos].info.PADsynth_used = false;
-
+ ins[pos].filename = dirname + filename;
return 0;
}
-bool Bank::isPADsynth_used(unsigned int ninstrument)
-{
- if(config.cfg.CheckPADsynth == 0)
- return 0;
- else
- return ins[ninstrument].info.PADsynth_used;
-}
-
-
void Bank::deletefrombank(int pos)
{
if((pos < 0) || (pos >= BANK_SIZE))
@@ -463,7 +439,5 @@ void Bank::deletefrombank(int pos)
}
Bank::ins_t::ins_t()
- :used(false), name(""), filename("")
-{
- info.PADsynth_used = false;
-}
+ :name(""), filename("")
+{}
diff --git a/src/Misc/Bank.h b/src/Misc/Bank.h
@@ -38,10 +38,10 @@ class Bank
~Bank();
std::string getname(unsigned int ninstrument);
std::string getnamenumbered(unsigned int ninstrument);
+ //if newslot==-1 then this is ignored, else it will be put on that slot
void setname(unsigned int ninstrument,
const std::string &newname,
- int newslot); //if newslot==-1 then this is ignored, else it will be put on that slot
- bool isPADsynth_used(unsigned int ninstrument);
+ int newslot);
/**returns true when slot is empty*/
bool emptyslot(unsigned int ninstrument);
@@ -71,6 +71,13 @@ class Bank
};
std::vector<bankstruct> banks;
+
+ struct ins_t {
+ ins_t(void);
+ std::string name;
+ //All valid instruments must have a non-empty filename
+ std::string filename;
+ } ins[BANK_SIZE];
private:
@@ -84,17 +91,6 @@ class Bank
void clearbank();
std::string defaultinsname;
-
- struct ins_t {
- ins_t();
- bool used;
- std::string name;
- std::string filename;
- struct {
- bool PADsynth_used;
- } info;
- } ins[BANK_SIZE];
-
std::string dirname;
void scanrootdir(std::string rootdir); //scans a root dir for banks
diff --git a/src/Misc/CMakeLists.txt b/src/Misc/CMakeLists.txt
@@ -12,6 +12,7 @@ set(zynaddsubfx_misc_SRCS
Misc/Recorder.cpp
Misc/WavFile.cpp
Misc/WaveShapeSmps.cpp
+ Misc/MiddleWare.cpp
)
diff --git a/src/Misc/Master.cpp b/src/Misc/Master.cpp
@@ -28,35 +28,153 @@
#include "../Params/LFOParams.h"
#include "../Effects/EffectMgr.h"
#include "../DSP/FFTwrapper.h"
+#include "../Nio/Nio.h"
+#include <rtosc/ports.h>
+#include <rtosc/port-sugar.h>
+#include <rtosc/thread-link.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <iostream>
#include <algorithm>
#include <cmath>
+#include <atomic>
#include <unistd.h>
using namespace std;
+using namespace rtosc;
+#define rObject Master
+
+static Ports localports = {
+ rRecursp(part, 16, "Part"),//NUM_MIDI_PARTS
+ rRecursp(sysefx, 4, "System Effect"),//NUM_SYS_EFX
+ rRecursp(insefx, 8, "Insertion Effect"),//NUM_INS_EFX
+ rRecur(microtonal, "Micrtonal Mapping Functionality"),
+ rParam(Pkeyshift, "Global Key Shift"),
+ rParams(Pinsparts, NUM_INS_EFX, "Part to insert part onto"),
+ {"echo", "=documentation\0:Hidden port to echo messages\0", 0, [](const char *m, RtData&) {
+ bToU->raw_write(m-1);}},
+ {"get-vu", rDoc("Grab VU Data"), 0, [](const char *, RtData &d) {
+ Master *m = (Master*)d.obj;
+ bToU->write("/vu-meter", "bb", sizeof(m->vu), &m->vu, sizeof(float)*NUM_MIDI_PARTS, m->vuoutpeakpart);}},
+ {"reset-vu", rDoc("Grab VU Data"), 0, [](const char *, RtData &d) {
+ Master *m = (Master*)d.obj;
+ m->vuresetpeaks();}},
+ {"load-part:ib", rProp(internal) rDoc("Load Part From Middleware"), 0, [](const char *msg, RtData &d) {
+ Master *m = (Master*)d.obj;
+ Part *p = *(Part**)rtosc_argument(msg, 1).b.data;
+ int i = rtosc_argument(msg, 0).i;
+ m->part[i]->cloneTraits(*p);
+ d.reply("/free", "sb", "Part", sizeof(void*), &m->part[i]);
+ m->part[i] = p;
+ printf("part %d is now pointer %p\n", i, p);}},
+ {"volume::c", rDoc("Master Volume"), 0,
+ [](const char *m, rtosc::RtData &d) {
+ if(rtosc_narguments(m)==0) {
+ d.reply(d.loc, "c", ((Master*)d.obj)->Pvolume);
+ } else if(rtosc_narguments(m)==1 && rtosc_type(m,0)=='c') {
+ printf("looking at value %d\n", rtosc_argument(m,0).i);
+ printf("limited value is %d\n", limit<char>(
+ rtosc_argument(m,0).i, 0,127));
+ ((Master*)d.obj)->setPvolume(limit<char>(rtosc_argument(m,0).i,0,127));
+ printf("sets volume to value %d\n", ((Master*)d.obj)->Pvolume);
+ d.broadcast(d.loc, "c", ((Master*)d.obj)->Pvolume);}}},
+
+ {"noteOn:ccc", rDoc("Noteon Event"), 0,
+ [](const char *m,RtData &d){
+ Master *M = (Master*)d.obj;
+ M->noteOn(rtosc_argument(m,0).i,rtosc_argument(m,1).i,rtosc_argument(m,2).i);}},
+
+ {"noteOff:cc", rDoc("Noteoff Event"), 0,
+ [](const char *m,RtData &d){
+ Master *M = (Master*)d.obj;
+ M->noteOff(rtosc_argument(m,0).i,rtosc_argument(m,1).i);}},
+
+ {"setController:ccc", rDoc("MIDI CC Event"), 0,
+ [](const char *m,RtData &d){
+ Master *M = (Master*)d.obj;
+ M->setController(rtosc_argument(m,0).i,rtosc_argument(m,1).i,rtosc_argument(m,2).i);}},
+ {"freeze_state:", rDoc("Internal Read-only Mode"), 0,
+ [](const char *,RtData &d) {
+ Master *M = (Master*)d.obj;
+ std::atomic_thread_fence(std::memory_order_release);
+ M->frozenState = true;
+ d.reply("/state_frozen");}},
+ {"thaw_state:", rDoc("Internal Read-only Mode"), 0,
+ [](const char *,RtData &d) {
+ Master *M = (Master*)d.obj;
+ M->frozenState = false;}},
+ {"register:iis", rDoc("MIDI Mapping Registration"), 0,
+ [](const char *m,RtData &d){
+ Master *M = (Master*)d.obj;
+ M->midi.addElm(rtosc_argument(m,0).i, rtosc_argument(m,1).i,rtosc_argument(m,2).s);}},
+ {"learn:s", rDoc("Begin Learning for specified address"), 0,
+ [](const char *m, RtData &d){
+ Master *M = (Master*)d.obj;
+ printf("learning '%s'\n", rtosc_argument(m,0).s);
+ M->midi.learn(rtosc_argument(m,0).s);}}
+};
+
+Ports &Master::ports = localports;
+Master *the_master;
+
+class DataObj:public rtosc::RtData
+{
+ public:
+ DataObj(char *loc_, size_t loc_size_, void *obj_, rtosc::ThreadLink *bToU_)
+ {
+ memset(loc_, 0, sizeof(loc_size_));
+ loc = loc_;
+ loc_size = loc_size_;
+ obj = obj_;
+ bToU = bToU_;
+ }
+
+ virtual void reply(const char *path, const char *args, ...)
+ {
+ va_list va;
+ va_start(va,args);
+ char *buffer = bToU->buffer();
+ rtosc_vmessage(buffer,bToU->buffer_size(),path,args,va);
+ reply(buffer);
+ }
+ virtual void reply(const char *msg)
+ {
+ bToU->raw_write(msg);
+ }
+ virtual void broadcast(const char *path, const char *args, ...) override{
+ va_list va;
+ va_start(va,args);
+ reply("/broadcast");
+ char *buffer = bToU->buffer();
+ rtosc_vmessage(buffer,bToU->buffer_size(),path,args,va);
+ reply(buffer);}
+ virtual void broadcast(const char *msg) override
+ {
+ reply("/broadcast");
+ reply(msg);
+ };
+ private:
+ rtosc::ThreadLink *bToU;
+};
vuData::vuData(void)
:outpeakl(0.0f), outpeakr(0.0f), maxoutpeakl(0.0f), maxoutpeakr(0.0f),
rmspeakl(0.0f), rmspeakr(0.0f), clipped(0)
{}
-static Master* masterInstance = NULL;
-
Master::Master()
+:midi(Master::ports), frozenState(false)
{
+ the_master = this;
swaplr = 0;
off = 0;
smps = 0;
bufl = new float[synth->buffersize];
bufr = new float[synth->buffersize];
- pthread_mutex_init(&mutex, NULL);
- pthread_mutex_init(&vumutex, NULL);
fft = new FFTwrapper(synth->oscilsize);
shutup = 0;
@@ -66,18 +184,32 @@ Master::Master()
}
for(int npart = 0; npart < NUM_MIDI_PARTS; ++npart)
- part[npart] = new Part(µtonal, fft, &mutex);
+ part[npart] = new Part(µtonal, fft);
//Insertion Effects init
for(int nefx = 0; nefx < NUM_INS_EFX; ++nefx)
- insefx[nefx] = new EffectMgr(1, &mutex);
+ insefx[nefx] = new EffectMgr(1);
//System Effects init
for(int nefx = 0; nefx < NUM_SYS_EFX; ++nefx)
- sysefx[nefx] = new EffectMgr(0, &mutex);
+ sysefx[nefx] = new EffectMgr(0);
defaults();
+
+ midi.event_cb = [](const char *m)
+ {
+ char loc_buf[1024];
+ DataObj d{loc_buf, 1024, the_master, bToU};
+ memset(loc_buf, sizeof(loc_buf), 0);
+ printf("sending an event to the owner of '%s'\n", m);
+ Master::ports.dispatch(m+1, d);
+ };
+
+ midi.error_cb = [](const char *a, const char *b)
+ {
+ fprintf(stderr, "MIDI- got an error '%s' -- '%s'\n",a,b);
+ };
}
void Master::defaults()
@@ -112,36 +244,6 @@ void Master::defaults()
ShutUp();
}
-bool Master::mutexLock(lockset request)
-{
- switch(request) {
- case MUTEX_TRYLOCK:
- return !pthread_mutex_trylock(&mutex);
- case MUTEX_LOCK:
- return !pthread_mutex_lock(&mutex);
- case MUTEX_UNLOCK:
- return !pthread_mutex_unlock(&mutex);
- }
- return false;
-}
-
-Master &Master::getInstance()
-{
- if (!masterInstance)
- masterInstance = new Master;
-
- return *masterInstance;
-}
-
-void Master::deleteInstance()
-{
- if (masterInstance)
- {
- delete masterInstance;
- masterInstance = NULL;
- }
-}
-
/*
* Note On Messages (velocity=0 for NoteOff)
*/
@@ -191,26 +293,25 @@ void Master::polyphonicAftertouch(char chan, char note, char velocity)
*/
void Master::setController(char chan, int type, int par)
{
+ if(frozenState)
+ return;
+ midi.process(chan,type,par);
if((type == C_dataentryhi) || (type == C_dataentrylo)
|| (type == C_nrpnhi) || (type == C_nrpnlo)) { //Process RPN and NRPN by the Master (ignore the chan)
ctl.setparameternumber(type, par);
int parhi = -1, parlo = -1, valhi = -1, vallo = -1;
if(ctl.getnrpn(&parhi, &parlo, &valhi, &vallo) == 0) //this is NRPN
- //fprintf(stderr,"rcv. NRPN: %d %d %d %d\n",parhi,parlo,valhi,vallo);
switch(parhi) {
case 0x04: //System Effects
if(parlo < NUM_SYS_EFX)
sysefx[parlo]->seteffectpar_nolock(valhi, vallo);
- ;
break;
case 0x08: //Insertion Effects
if(parlo < NUM_INS_EFX)
insefx[parlo]->seteffectpar_nolock(valhi, vallo);
- ;
break;
}
- ;
}
else
if(type == C_bankselectmsb) { // Change current bank
@@ -222,7 +323,6 @@ void Master::setController(char chan, int type, int par)
for(int npart = 0; npart < NUM_MIDI_PARTS; ++npart) //Send the controller to all part assigned to the channel
if((chan == part[npart]->Prcvchn) && (part[npart]->Penabled != 0))
part[npart]->SetController(type, par);
- ;
if(type == C_allsoundsoff) { //cleanup insertion/system FX
for(int nefx = 0; nefx < NUM_SYS_EFX; ++nefx)
@@ -233,24 +333,6 @@ void Master::setController(char chan, int type, int par)
}
}
-void Master::setProgram(char chan, unsigned int pgm)
-{
- if(config.cfg.IgnoreProgramChange)
- return;
-
- for(int npart = 0; npart < NUM_MIDI_PARTS; ++npart)
- if(chan == part[npart]->Prcvchn) {
- bank.loadfromslot(pgm, part[npart]);
-
- //Hack to get pad note parameters to update
- //this is not real time safe and makes assumptions about the calling
- //convention of this function...
- pthread_mutex_unlock(&mutex);
- part[npart]->applyparameters();
- pthread_mutex_lock(&mutex);
- }
-}
-
void Master::vuUpdate(const float *outl, const float *outr)
{
//Peak computation (for vumeters)
@@ -321,11 +403,50 @@ void Master::partonoff(int npart, int what)
}
}
+
/*
* Master audio out (the final sound)
*/
void Master::AudioOut(float *outl, float *outr)
{
+ //Handle user events TODO move me to a proper location
+ char loc_buf[1024];
+ DataObj d{loc_buf, 1024, this, bToU};
+ memset(loc_buf, sizeof(loc_buf), 0);
+ int events = 0;
+ while(uToB->hasNext() && events < 10) {
+ const char *msg = uToB->read();
+
+ if(!strcmp(msg, "/load-master")) {
+ Master *this_master = this;
+ Master *new_master = *(Master**)rtosc_argument(msg, 0).b.data;
+ new_master->AudioOut(outl, outr);
+ Nio::masterSwap(new_master);
+ bToU->write("/free", "sb", "Master", sizeof(Master*), &this_master);
+ return;
+ }
+
+ //XXX yes, this is not realtime safe, but it is useful...
+ if(strcmp(msg, "/get-vu") && false) {
+ fprintf(stdout, "%c[%d;%d;%dm", 0x1B, 0, 5 + 30, 0 + 40);
+ fprintf(stdout, "backend: '%s'<%s>\n", msg,
+ rtosc_argument_string(msg));
+ fprintf(stdout, "%c[%d;%d;%dm", 0x1B, 0, 7 + 30, 0 + 40);
+ }
+ d.matches = 0;
+ //fprintf(stdout, "address '%s'\n", uToB->peak());
+ ports.dispatch(msg+1, d);
+ events++;
+ if(!d.matches && false) {
+ fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 1, 7 + 30, 0 + 40);
+ fprintf(stderr, "Unknown address '%s'\n", uToB->peak());
+ fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 0, 7 + 30, 0 + 40);
+ }
+ }
+ if(events>1 && false)
+ fprintf(stderr, "backend: %d events per cycle\n",events);
+
+
//Swaps the Left channel with Right Channel
if(swaplr)
swap(outl, outr);
@@ -335,12 +456,9 @@ void Master::AudioOut(float *outl, float *outr)
memset(outr, 0, synth->bufferbytes);
//Compute part samples and store them part[npart]->partoutl,partoutr
- for(int npart = 0; npart < NUM_MIDI_PARTS; ++npart) {
- if(part[npart]->Penabled != 0 && !pthread_mutex_trylock(&part[npart]->load_mutex)) {
+ for(int npart = 0; npart < NUM_MIDI_PARTS; ++npart)
+ if(part[npart]->Penabled)
part[npart]->ComputePartSmps();
- pthread_mutex_unlock(&part[npart]->load_mutex);
- }
- }
//Insertion effects
for(int nefx = 0; nefx < NUM_INS_EFX; ++nefx)
@@ -458,10 +576,7 @@ void Master::AudioOut(float *outl, float *outr)
outr[i] *= volume;
}
- if(!pthread_mutex_trylock(&vumutex)) {
- vuUpdate(outl, outr);
- pthread_mutex_unlock(&vumutex);
- }
+ vuUpdate(outl, outr);
//Shutup if it is asked (with fade-out)
if(shutup) {
@@ -530,9 +645,6 @@ Master::~Master()
delete sysefx[nefx];
delete fft;
-
- pthread_mutex_destroy(&mutex);
- pthread_mutex_destroy(&vumutex);
}
@@ -588,28 +700,17 @@ void Master::ShutUp()
*/
void Master::vuresetpeaks()
{
- pthread_mutex_lock(&vumutex);
vu.outpeakl = 1e-9;
vu.outpeakr = 1e-9;
vu.maxoutpeakl = 1e-9;
vu.maxoutpeakr = 1e-9;
vu.clipped = 0;
- pthread_mutex_unlock(&vumutex);
-}
-
-vuData Master::getVuData()
-{
- vuData tmp;
- pthread_mutex_lock(&vumutex);
- tmp = vu;
- pthread_mutex_unlock(&vumutex);
- return tmp;
}
-void Master::applyparameters(bool lockmutex)
+void Master::applyparameters(void)
{
for(int npart = 0; npart < NUM_MIDI_PARTS; ++npart)
- part[npart]->applyparameters(lockmutex);
+ part[npart]->applyparameters();
}
void Master::add2XML(XMLwrapper *xml)
@@ -673,9 +774,7 @@ int Master::getalldata(char **data)
xml->beginbranch("MASTER");
- pthread_mutex_lock(&mutex);
add2XML(xml);
- pthread_mutex_unlock(&mutex);
xml->endbranch();
@@ -695,9 +794,7 @@ void Master::putalldata(char *data, int /*size*/)
if(xml->enterbranch("MASTER") == 0)
return;
- pthread_mutex_lock(&mutex);
getfromXML(xml);
- pthread_mutex_unlock(&mutex);
xml->exitbranch();
diff --git a/src/Misc/Master.h b/src/Misc/Master.h
@@ -27,6 +27,7 @@
#include "../globals.h"
#include "Microtonal.h"
+#include <rtosc/miditable.h>
#include "Bank.h"
#include "Recorder.h"
@@ -35,10 +36,6 @@
#include "../Params/Controller.h"
-typedef enum {
- MUTEX_TRYLOCK, MUTEX_LOCK, MUTEX_UNLOCK
-} lockset;
-
extern Dump dump;
struct vuData {
@@ -59,9 +56,6 @@ class Master
/** Destructor*/
~Master();
- static Master &getInstance();
- static void deleteInstance();
-
/**Saves all settings to a XML file
* @return 0 for ok or <0 if there is an error*/
int saveXML(const char *filename);
@@ -75,7 +69,10 @@ class Master
/**loads all settings from a XML file
* @return 0 for ok or -1 if there is an error*/
int loadXML(const char *filename);
- void applyparameters(bool lockmutex = true);
+
+ /**Regenerate PADsynth and other non-RT parameters
+ * It is NOT SAFE to call this from a RT context*/
+ void applyparameters(void);
void getfromXML(XMLwrapper *xml);
@@ -85,18 +82,11 @@ class Master
/**put all data from the *data array to zynaddsubfx parameters (used for VST)*/
void putalldata(char *data, int size);
- //Mutex control
- /**Control the Master's mutex state.
- * @param lockset either trylock, lock, or unlock.
- * @return true when successful false otherwise.*/
- bool mutexLock(lockset request);
-
//Midi IN
void noteOn(char chan, char note, char velocity);
void noteOff(char chan, char note);
void polyphonicAftertouch(char chan, char note, char velocity);
void setController(char chan, int type, int par);
- void setProgram(char chan, unsigned int pgm);
//void NRPN...
@@ -146,11 +136,8 @@ class Master
//peaks for VU-meter
void vuresetpeaks();
- //get VU-meter data
- vuData getVuData();
//peaks for part VU-meters
- /**\todo synchronize this with a mutex*/
float vuoutpeakpart[NUM_MIDI_PARTS];
unsigned char fakepeakpart[NUM_MIDI_PARTS]; //this is used to compute the "peak" when the part is disabled
@@ -159,16 +146,22 @@ class Master
//other objects
Microtonal microtonal;
- Bank bank;
+
+ //Strictly Non-RT instrument bank object
+ Bank bank;
class FFTwrapper * fft;
- pthread_mutex_t mutex;
- pthread_mutex_t vumutex;
+ static rtosc::Ports &ports;
+ float volume;
- private:
+ //Statistics on output levels
vuData vu;
- float volume;
+
+ rtosc::MidiTable midi;//<1024,64>
+
+ bool frozenState;//read-only parameters for threadsafe actions
+ private:
float sysefxvol[NUM_SYS_EFX][NUM_MIDI_PARTS];
float sysefxsend[NUM_SYS_EFX][NUM_SYS_EFX];
int keyshift;
diff --git a/src/Misc/Microtonal.cpp b/src/Misc/Microtonal.cpp
@@ -20,16 +20,57 @@
*/
-#include <math.h>
-#include <string.h>
+#include <cmath>
+#include <cstring>
+#include <cstdio>
+
+#include <rtosc/ports.h>
+#include <rtosc/port-sugar.h>
+
+
+#include "XMLwrapper.h"
+#include "Util.h"
#include "Microtonal.h"
+
#define MAX_LINE_SIZE 80
+#define rObject Microtonal
+using namespace rtosc;
+
+/**
+ * TODO
+ * Consider how much of this should really exist on the rt side of things.
+ * All the rt side needs is a function to map notes at various keyshifts to
+ * frequencies, which does not require this many parameters...
+ *
+ * A good lookup table should be a good finalization of this
+ */
+rtosc::Ports Microtonal::ports = {
+ rToggle(Pinvertupdown, "key mapping inverse"),
+ rParam(Pinvertupdowncenter, "center of the inversion"),
+ rToggle(Penabled, "Enable for microtonal mode"),
+ rParam(PAnote, "The note for 'A'"),
+ rParamF(PAfreq, "Frequency of the 'A' note"),
+ rParam(Pscaleshift, "UNDOCUMENTED"),
+ rParam(Pfirstkey, "First key to retune"),
+ rParam(Plastkey, "Last key to retune"),
+ rParam(Pmiddlenote, "Scale degree 0 note"),
+
+ //TODO check to see if this should be exposed
+ rParam(Pmapsize, "UNDOCUMENTED"),
+ rToggle(Pmappingenabled, "Mapping Enable"),
+
+ rParams(Pmapping, "UNDOCUMENTED"),
+ rParam(Pglobalfinedetune, "Fine detune for all notes"),
+
+ rString(Pname, MICROTONAL_MAX_NAME_LEN, "Microtonal Name"),
+ rString(Pcomment, MICROTONAL_MAX_NAME_LEN, "Microtonal Name"),
+};
+
+
Microtonal::Microtonal()
{
- Pname = new unsigned char[MICROTONAL_MAX_NAME_LEN];
- Pcomment = new unsigned char[MICROTONAL_MAX_NAME_LEN];
defaults();
}
@@ -76,10 +117,7 @@ void Microtonal::defaults()
}
Microtonal::~Microtonal()
-{
- delete [] Pname;
- delete [] Pcomment;
-}
+{}
/*
* Get the size of the octave
@@ -106,13 +144,13 @@ float Microtonal::getnotefreq(int note, int keyshift) const
note = (int) Pinvertupdowncenter * 2 - note;
//compute global fine detune
- float globalfinedetunerap = powf(2.0f,
- (Pglobalfinedetune - 64.0f) / 1200.0f); //-64.0f .. 63.0f cents
+ float globalfinedetunerap =
+ powf(2.0f, (Pglobalfinedetune - 64.0f) / 1200.0f); //-64.0f .. 63.0f cents
- if(Penabled == 0)
+ if(Penabled == 0) //12tET
return powf(2.0f,
(note - PAnote
- + keyshift) / 12.0f) * PAfreq * globalfinedetunerap; //12tET
+ + keyshift) / 12.0f) * PAfreq * globalfinedetunerap;
int scaleshift =
((int)Pscaleshift - 64 + (int) octavesize * 100) % octavesize;
@@ -127,7 +165,7 @@ float Microtonal::getnotefreq(int note, int keyshift) const
}
//if the mapping is enabled
- if(Pmappingenabled != 0) {
+ if(Pmappingenabled) {
if((note < Pfirstkey) || (note > Plastkey))
return -1.0f;
//Compute how many mapped keys are from middle note to reference note
@@ -144,11 +182,11 @@ float Microtonal::getnotefreq(int note, int keyshift) const
float rap_anote_middlenote =
(deltanote ==
0) ? (1.0f) : (octave[(deltanote - 1) % octavesize].tuning);
- if(deltanote != 0)
+ if(deltanote)
rap_anote_middlenote *=
powf(octave[octavesize - 1].tuning,
(deltanote - 1) / octavesize);
- if(minus != 0)
+ if(minus)
rap_anote_middlenote = 1.0f / rap_anote_middlenote;
//Convert from note (midi) to degree (note from the tunning)
@@ -175,7 +213,7 @@ float Microtonal::getnotefreq(int note, int keyshift) const
freq *= powf(octave[octavesize - 1].tuning, degoct);
freq *= PAfreq / rap_anote_middlenote;
freq *= globalfinedetunerap;
- if(scaleshift != 0)
+ if(scaleshift)
freq /= octave[scaleshift - 1].tuning;
return freq * rap_keyshift;
}
@@ -189,11 +227,10 @@ float Microtonal::getnotefreq(int note, int keyshift) const
octave[(ntkey + octavesize - 1) % octavesize].tuning * powf(oct,
ntoct)
* PAfreq;
- if(ntkey == 0)
+ if(!ntkey)
freq /= oct;
- if(scaleshift != 0)
+ if(scaleshift)
freq /= octave[scaleshift - 1].tuning;
-// fprintf(stderr,"note=%d freq=%.3f cents=%d\n",note,freq,(int)floor(logf(freq/PAfreq)/logf(2.0f)*1200.0f+0.5f));
freq *= globalfinedetunerap;
return freq * rap_keyshift;
}
@@ -460,77 +497,51 @@ int Microtonal::loadkbm(const char *filename)
{
FILE *file = fopen(filename, "r");
int x;
+ float tmpPAfreq = 440.0f;
char tmp[500];
fseek(file, 0, SEEK_SET);
//loads the mapsize
- if(loadline(file, &tmp[0]) != 0)
- return 2;
- if(sscanf(&tmp[0], "%d", &x) == 0)
+ if(loadline(file, tmp) != 0 || sscanf(tmp, "%d", &x) == 0)
return 2;
- if(x < 1)
- x = 0;
- if(x > 127)
- x = 127; //just in case...
- Pmapsize = x;
+ Pmapsize = limit(x, 0, 127);
+
//loads first MIDI note to retune
- if(loadline(file, &tmp[0]) != 0)
+ if(loadline(file, tmp) != 0 || sscanf(tmp, "%d", &x) == 0)
return 2;
- if(sscanf(&tmp[0], "%d", &x) == 0)
- return 2;
- if(x < 1)
- x = 0;
- if(x > 127)
- x = 127; //just in case...
- Pfirstkey = x;
+ Pfirstkey = limit(x, 0, 127);
+
//loads last MIDI note to retune
- if(loadline(file, &tmp[0]) != 0)
- return 2;
- if(sscanf(&tmp[0], "%d", &x) == 0)
+ if(loadline(file, tmp) != 0 || sscanf(tmp, "%d", &x) == 0)
return 2;
- if(x < 1)
- x = 0;
- if(x > 127)
- x = 127; //just in case...
- Plastkey = x;
+ Plastkey = limit(x, 0, 127);
+
//loads last the middle note where scale fro scale degree=0
- if(loadline(file, &tmp[0]) != 0)
+ if(loadline(file, tmp) != 0 || sscanf(tmp, "%d", &x) == 0)
return 2;
- if(sscanf(&tmp[0], "%d", &x) == 0)
- return 2;
- if(x < 1)
- x = 0;
- if(x > 127)
- x = 127; //just in case...
- Pmiddlenote = x;
+ Pmiddlenote = limit(x, 0, 127);
+
//loads the reference note
- if(loadline(file, &tmp[0]) != 0)
- return 2;
- if(sscanf(&tmp[0], "%d", &x) == 0)
+ if(loadline(file, tmp) != 0 || sscanf(tmp, "%d", &x) == 0)
return 2;
- if(x < 1)
- x = 0;
- if(x > 127)
- x = 127; //just in case...
- PAnote = x;
+ PAnote = limit(x,0,127);
+
//loads the reference freq.
- if(loadline(file, &tmp[0]) != 0)
- return 2;
- float tmpPAfreq = 440.0f;
- if(sscanf(&tmp[0], "%f", &tmpPAfreq) == 0)
+ if(loadline(file, tmp) != 0 || sscanf(tmp, "%f", &tmpPAfreq) == 0)
return 2;
PAfreq = tmpPAfreq;
- //the scale degree(which is the octave) is not loaded, it is obtained by the tunnings with getoctavesize() method
+ //the scale degree(which is the octave) is not loaded,
+ //it is obtained by the tunnings with getoctavesize() method
if(loadline(file, &tmp[0]) != 0)
return 2;
//load the mappings
if(Pmapsize != 0) {
for(int nline = 0; nline < Pmapsize; ++nline) {
- if(loadline(file, &tmp[0]) != 0)
+ if(loadline(file, tmp) != 0)
return 2;
- if(sscanf(&tmp[0], "%d", &x) == 0)
+ if(sscanf(tmp, "%d", &x) == 0)
x = -1;
Pmapping[nline] = x;
}
diff --git a/src/Misc/Microtonal.h b/src/Misc/Microtonal.h
@@ -23,13 +23,12 @@
#ifndef MICROTONAL_H
#define MICROTONAL_H
+#include <cstdio>
#include "../globals.h"
-#include "XMLwrapper.h"
#define MAX_OCTAVE_SIZE 128
#define MICROTONAL_MAX_NAME_LEN 120
-
-#include <stdio.h>
+class XMLwrapper;
/**Tuning settings and microtonal capabilities*/
@@ -102,9 +101,9 @@ class Microtonal
void texttomapping(const char *text);
/**Name of Microtonal tuning*/
- unsigned char *Pname;
+ char Pname[MICROTONAL_MAX_NAME_LEN];
/**Comment about the tuning*/
- unsigned char *Pcomment;
+ char Pcomment[MICROTONAL_MAX_NAME_LEN];
void add2XML(XMLwrapper *xml) const;
void getfromXML(XMLwrapper *xml);
@@ -115,9 +114,11 @@ class Microtonal
bool operator==(const Microtonal µ) const;
bool operator!=(const Microtonal µ) const;
+ static rtosc::Ports ports;
private:
int linetotunings(unsigned int nline, const char *line);
int loadline(FILE *file, char *line); //loads a line from the text file, while ignoring the lines beggining with "!"
+ //Grab a 0..127 integer from the provided descriptor
unsigned char octavesize;
struct {
unsigned char type; //1 for cents or 2 for division
diff --git a/src/Misc/MiddleWare.cpp b/src/Misc/MiddleWare.cpp
@@ -0,0 +1,987 @@
+#include "MiddleWare.h"
+
+#include <cstring>
+#include <cstdio>
+#include <cstdlib>
+
+#include <rtosc/thread-link.h>
+#include <rtosc/ports.h>
+#include <lo/lo.h>
+
+#include <unistd.h>
+
+#include "../UI/Fl_Osc_Interface.h"
+#include "../UI/Fl_Osc_Widget.H"
+
+#include <map>
+
+#include "Master.h"
+#include "Part.h"
+#include "../Params/ADnoteParameters.h"
+#include "../Params/PADnoteParameters.h"
+#include "../Effects/EffectMgr.h"
+
+#include <string>
+#include <future>
+#include <atomic>
+
+#include <err.h>
+
+rtosc::ThreadLink *bToU = new rtosc::ThreadLink(4096*2,1024);
+rtosc::ThreadLink *uToB = new rtosc::ThreadLink(4096*2,1024);
+
+/**
+ * General local static code/data
+ */
+static lo_server server;
+static string last_url, curr_url;
+
+static void liblo_error_cb(int i, const char *m, const char *loc)
+{
+ fprintf(stderr, "liblo :-( %d-%s@%s\n",i,m,loc);
+}
+
+void path_search(const char *m)
+{
+ using rtosc::Ports;
+ using rtosc::Port;
+
+ //assumed upper bound of 32 ports (may need to be resized)
+ char types[129];
+ rtosc_arg_t args[128];
+ size_t pos = 0;
+ const Ports *ports = NULL;
+ const char *str = rtosc_argument(m,0).s;
+ const char *needle = rtosc_argument(m,1).s;
+
+ //zero out data
+ memset(types, 0, sizeof(types));
+ memset(args, 0, sizeof(args));
+
+ if(!*str) {
+ ports = &Master::ports;
+ } else {
+ const Port *port = Master::ports.apropos(rtosc_argument(m,0).s);
+ if(port)
+ ports = port->ports;
+ }
+
+ if(ports) {
+ //RTness not confirmed here
+ for(const Port &p:*ports) {
+ if(strstr(p.name, needle)!=p.name)
+ continue;
+ types[pos] = 's';
+ args[pos++].s = p.name;
+ types[pos] = 'b';
+ if(p.metadata && *p.metadata) {
+ args[pos].b.data = (unsigned char*) p.metadata;
+ auto tmp = rtosc::Port::MetaContainer(p.metadata);
+ args[pos++].b.len = tmp.length();
+ } else {
+ args[pos].b.data = (unsigned char*) NULL;
+ args[pos++].b.len = 0;
+ }
+ }
+ }
+
+
+ //Reply to requester [wow, these messages are getting huge...]
+ char buffer[1024*20];
+ size_t length = rtosc_amessage(buffer, sizeof(buffer), "/paths", types, args);
+ if(length) {
+ lo_message msg = lo_message_deserialise((void*)buffer, length, NULL);
+ lo_address addr = lo_address_new_from_url(last_url.c_str());
+ if(addr)
+ lo_send_message(addr, buffer, msg);
+ }
+}
+
+static int handler_function(const char *path, const char *types, lo_arg **argv,
+ int argc, lo_message msg, void *user_data)
+{
+ (void) types;
+ (void) argv;
+ (void) argc;
+ (void) user_data;
+ lo_address addr = lo_message_get_source(msg);
+ if(addr) {
+ const char *tmp = lo_address_get_url(addr);
+ if(tmp != last_url) {
+ uToB->write("/echo", "ss", "OSC_URL", tmp);
+ last_url = tmp;
+ }
+
+ }
+
+ char buffer[2048];
+ memset(buffer, 0, sizeof(buffer));
+ size_t size = 2048;
+ lo_message_serialise(msg, path, buffer, &size);
+ if(!strcmp(buffer, "/path-search") && !strcmp("ss", rtosc_argument_string(buffer))) {
+ path_search(buffer);
+ } else
+ uToB->raw_write(buffer);
+
+ return 0;
+}
+
+typedef void(*cb_t)(void*,const char*);
+
+
+void deallocate(const char *str, void *v)
+{
+ printf("deallocating a '%s' at '%p'\n", str, v);
+ if(!strcmp(str, "Part"))
+ delete (Part*)v;
+ else if(!strcmp(str, "Master"))
+ delete (Master*)v;
+ else if(!strcmp(str, "EffectMgr"))
+ delete (EffectMgr*)v;
+ else if(!strcmp(str, "fft_t"))
+ delete[] (fft_t*)v;
+ else
+ fprintf(stderr, "Unknown type '%s', leaking pointer %p!!\n", str, v);
+}
+
+
+
+/**
+ * - Fetches liblo messages and forward them to the backend
+ * - Grabs backend messages and distributes them to the frontends
+ */
+//void osc_check(cb_t cb, void *ui)
+//{
+//}
+
+
+
+void preparePadSynth(string path, PADnoteParameters *p)
+{
+ printf("preparing padsynth parameters\n");
+ assert(!path.empty());
+ path += "sample";
+
+ unsigned max = 0;
+ p->sampleGenerator([&max,&path]
+ (unsigned N, PADnoteParameters::Sample &s)
+ {
+ max = max<N ? N : max;
+ printf("sending info to '%s'\n", (path+to_s(N)).c_str());
+ uToB->write((path+to_s(N)).c_str(), "ifb",
+ s.size, s.basefreq, sizeof(float*), &s.smp);
+ }, []{return false;});
+ //clear out unused samples
+ for(unsigned i = max+1; i < PAD_MAX_SAMPLES; ++i) {
+ uToB->write((path+to_s(i)).c_str(), "ifb",
+ 0, 440.0f, sizeof(float*), NULL);
+ }
+}
+
+void refreshBankView(const Bank &bank, unsigned loc, Fl_Osc_Interface *osc)
+{
+ if(loc >= BANK_SIZE)
+ return;
+
+ char response[2048];
+ if(!rtosc_message(response, 1024, "/bankview", "iss",
+ loc, bank.ins[loc].name.c_str(),
+ bank.ins[loc].filename.c_str()))
+ errx(1, "Failure to handle bank update properly...");
+
+
+ osc->tryLink(response);
+}
+
+void bankList(Bank &bank, Fl_Osc_Interface *osc)
+{
+ char response[2048];
+ int i = 0;
+
+ for(auto &elm : bank.banks) {
+ if(!rtosc_message(response, 2048, "/bank-list", "iss",
+ i++, elm.name.c_str(), elm.dir.c_str()))
+ errx(1, "Failure to handle bank update properly...");
+ osc->tryLink(response);
+ }
+}
+
+void rescanForBanks(Bank &bank, Fl_Osc_Interface *osc)
+{
+ bank.rescanforbanks();
+ bankList(bank, osc);
+}
+
+void loadBank(Bank &bank, int pos, Fl_Osc_Interface *osc)
+{
+ bank.loadbank(bank.banks[pos].dir);
+ for(int i=0; i<BANK_SIZE; ++i)
+ refreshBankView(bank, i, osc);
+}
+
+void createEffect(const char *msg)
+{
+ const bool insertion = !strstr(msg, "sysefx");
+ const int efftype = rtosc_argument(msg, 0).i;
+ EffectMgr *em = new EffectMgr(insertion);
+ em->changeeffect(efftype);
+ uToB->write(msg, "b", sizeof(EffectMgr*), &em);
+}
+
+//
+//static rtosc::Ports padPorts= {
+// {"prepare:", "::Prepares the padnote instance", 0, }
+//};
+//
+//static rtosc::Ports oscilPorts = {
+// {"prepare:", "", 0, }
+//};
+
+class DummyDataObj:public rtosc::RtData
+{
+ public:
+ DummyDataObj(char *loc_, size_t loc_size_, void *obj_, cb_t cb_, void *ui_,
+ Fl_Osc_Interface *osc_)
+ {
+ memset(loc_, 0, sizeof(loc_size_));
+ //XXX Possible bug in rtosc using this buffer
+ buffer = new char[4*4096];
+ memset(buffer, 0, 4*4096);
+ loc = loc_;
+ loc_size = loc_size_;
+ obj = obj_;
+ cb = cb_;
+ ui = ui_;
+ osc = osc_;
+ }
+ ~DummyDataObj(void)
+ {
+ delete[] buffer;
+ }
+
+ virtual void reply(const char *path, const char *args, ...)
+ {
+ //printf("reply building '%s'\n", path);
+ va_list va;
+ va_start(va,args);
+ if(!strcmp(path, "/forward")) { //forward the information to the backend
+ args++;
+ path = va_arg(va, const char *);
+ fprintf(stderr, "forwarding information to the backend on '%s'<%s>\n",
+ path, args);
+ rtosc_vmessage(buffer,4*4096,path,args,va);
+ uToB->raw_write(buffer);
+ } else {
+ //printf("path = '%s' args = '%s'\n", path, args);
+ //printf("buffer = '%p'\n", buffer);
+ rtosc_vmessage(buffer,4*4096,path,args,va);
+ //printf("buffer = '%s'\n", buffer);
+ reply(buffer);
+ }
+ }
+ virtual void reply(const char *msg)
+ {
+ //DEBUG
+ //printf("reply used for '%s'\n", msg);
+ osc->tryLink(msg);
+ cb(ui, msg);
+ }
+ //virtual void broadcast(const char *path, const char *args, ...){(void)path;(void)args;};
+ //virtual void broadcast(const char *msg){(void)msg;};
+ private:
+ char *buffer;
+ cb_t cb;
+ void *ui;
+ Fl_Osc_Interface *osc;
+};
+
+
+/**
+ * Forwarding logic
+ * if(!dispatch(msg, data))
+ * forward(msg)
+ */
+
+
+static Fl_Osc_Interface *genOscInterface(struct MiddleWareImpl*);
+
+/* Implementation */
+struct MiddleWareImpl
+{
+ MiddleWareImpl(void)
+ {
+ server = lo_server_new_with_proto(NULL, LO_UDP, liblo_error_cb);
+ lo_server_add_method(server, NULL, NULL, handler_function, NULL);
+ fprintf(stderr, "lo server running on %d\n", lo_server_get_port(server));
+
+ //dummy callback for starters
+ cb = [](void*, const char*){};
+ idle = 0;
+
+ master = new Master();
+ osc = genOscInterface(this);
+
+ //Grab objects of interest from master
+ for(int i=0; i < NUM_MIDI_PARTS; ++i) {
+ for(int j=0; j < NUM_KIT_ITEMS; ++j) {
+ objmap["/part"+to_s(i)+"/kit"+to_s(j)+"/padpars/"] =
+ master->part[i]->kit[j].padpars;
+ objmap["/part"+to_s(i)+"/kit"+to_s(j)+"/padpars/oscil/"] =
+ master->part[i]->kit[j].padpars->oscilgen;
+ for(int k=0; k<NUM_VOICES; ++k) {
+ objmap["/part"+to_s(i)+"/kit"+to_s(j)+"/adpars/voice"+to_s(k)+"/oscil/"] =
+ master->part[i]->kit[j].adpars->VoicePar[k].OscilSmp;
+ objmap["/part"+to_s(i)+"/kit"+to_s(j)+"/adpars/voice"+to_s(k)+"/mod-oscil/"] =
+ master->part[i]->kit[j].adpars->VoicePar[k].FMSmp;
+ }
+ }
+ }
+
+ //Null out Load IDs
+ for(int i=0; i < NUM_MIDI_PARTS; ++i) {
+ pending_load[i] = 0;
+ actual_load[i] = 0;
+ }
+ }
+
+ ~MiddleWareImpl(void)
+ {
+ warnMemoryLeaks();
+
+ delete master;
+ delete osc;
+ }
+
+ void warnMemoryLeaks(void);
+
+ /** Threading When Saving
+ * ----------------------
+ *
+ * Procedure Middleware:
+ * 1) Middleware sends /freeze_state to backend
+ * 2) Middleware waits on /state_frozen from backend
+ * All intervening commands are held for out of order execution
+ * 3) Aquire memory
+ * At this time by the memory barrier we are guarenteed that all old
+ * writes are done and assuming the freezing logic is sound, then it is
+ * impossible for any other parameter to change at this time
+ * 3) Middleware performs saving operation
+ * 4) Middleware sends /thaw_state to backend
+ * 5) Restore in order execution
+ *
+ * Procedure Backend:
+ * 1) Observe /freeze_state and disable all mutating events (MIDI CC)
+ * 2) Run a memory release to ensure that all writes are complete
+ * 3) Send /state_frozen to Middleware
+ * time...
+ * 4) Observe /thaw_state and resume normal processing
+ */
+
+ void doReadOnlyOp(std::function<void()> read_only_fn)
+ {
+ //Copy is needed as filename WILL get trashed during the rest of the run
+ uToB->write("/freeze_state","");
+
+ std::list<const char *> fico;
+ int tries = 0;
+ while(tries++ < 10000) {
+ if(!bToU->hasNext()) {
+ usleep(500);
+ continue;
+ }
+ const char *msg = bToU->read();
+ if(!strcmp("/state_frozen", msg))
+ break;
+ size_t bytes = rtosc_message_length(msg, bToU->buffer_size());
+ char *save_buf = new char[bytes];
+ memcpy(save_buf, msg, bytes);
+ fico.push_back(save_buf);
+ }
+
+ assert(tries < 10000);//if this happens, the backend must be dead
+
+ std::atomic_thread_fence(std::memory_order_acquire);
+
+ //Now it is safe to do any read only operation
+ read_only_fn();
+
+ //Now to resume normal operations
+ uToB->write("/thaw_state","");
+ for(auto x:fico) {
+ uToB->raw_write(x);
+ delete [] x;
+ }
+ }
+
+
+ void saveMaster(const char *filename)
+ {
+ //Copy is needed as filename WILL get trashed during the rest of the run
+ std::string fname = filename;
+ printf("saving master('%s')\n", filename);
+ doReadOnlyOp([this,fname](){
+ int res = master->saveXML(fname.c_str());
+ printf("results: '%s' '%d'\n",fname.c_str(), res);});
+ }
+
+ void savePart(int npart, const char *filename)
+ {
+ //Copy is needed as filename WILL get trashed during the rest of the run
+ std::string fname = filename;
+ printf("saving part(%d,'%s')\n", npart, filename);
+ doReadOnlyOp([this,fname,npart](){
+ int res = master->part[npart]->saveXML(fname.c_str());
+ printf("results: '%s' '%d'\n",fname.c_str(), res);});
+ }
+
+ void loadPart(int npart, const char *filename, Master *master, Fl_Osc_Interface *osc)
+ {
+ printf("loading part...\n");
+ actual_load[npart]++;
+
+ if(actual_load[npart] != pending_load[npart])
+ return;
+ assert(actual_load[npart] <= pending_load[npart]);
+
+ auto alloc = std::async(std::launch::async,
+ [master,filename,this,npart](){Part *p = new Part(&master->microtonal, master->fft);
+ if(p->loadXMLinstrument(filename))
+ fprintf(stderr, "FAILED TO LOAD PART!!\n");
+
+ p->applyparameters([this,npart]{printf("%d vs %d\n", (int)actual_load[npart], (int)pending_load[npart]);return actual_load[npart] != pending_load[npart];});
+ return p;});
+ //fprintf(stderr, "loading a part!!\n");
+ //Load the part
+ if(idle) {
+ while(alloc.wait_for(std::chrono::seconds(0)) != std::future_status::ready) {
+ printf("idle...\n");
+ idle();
+ }
+ } else
+ printf("no idle\n");
+ printf("part allocated...\n");
+ Part *p = alloc.get();//new Part(&master->microtonal, master->fft);
+ //fprintf(stderr, "Part[%d] is stored in '%s'\n", npart, filename);
+ //if(p->loadXMLinstrument(filename))
+ // fprintf(stderr, "FAILED TO LOAD PART!!\n");
+
+ //p->applyparameters();
+
+ //Update the resource locators
+ string base = "/part"+to_s(npart)+"/kit";
+ for(int j=0; j < NUM_KIT_ITEMS; ++j) {
+ objmap[base+to_s(j)+"/padpars/"] =
+ p->kit[j].padpars;
+ objmap[base+to_s(j)+"/padpars/oscil/"] =
+ p->kit[j].padpars->oscilgen;
+ for(int k=0; k<NUM_VOICES; ++k) {
+ objmap[base+to_s(j)+"/adpars/voice"+to_s(k)+"/oscil/"] =
+ p->kit[j].adpars->VoicePar[k].OscilSmp;
+ objmap[base+to_s(j)+"/adpars/voice"+to_s(k)+"/mod-oscil/"] =
+ p->kit[j].adpars->VoicePar[k].FMSmp;
+ }
+ }
+
+ //Give it to the backend and wait for the old part to return for
+ //deallocation
+ //printf("writing something to the location called '%s'\n", msg);
+ uToB->write("/load-part", "ib", npart, sizeof(Part*), &p);
+ osc->damage(("/part"+to_s(npart)+"/").c_str());
+ }
+
+ //Well, you don't get much crazier than changing out all of your RT
+ //structures at once... TODO error handling
+ void loadMaster(const char *filename)
+ {
+ Master *m = new Master();
+ m->loadXML(filename);
+ m->applyparameters();
+
+ //Update resource locator table
+ objmap.clear();
+ for(int i=0; i < NUM_MIDI_PARTS; ++i) {
+ for(int j=0; j < NUM_KIT_ITEMS; ++j) {
+ objmap["/part"+to_s(i)+"/kit"+to_s(j)+"/padpars/"] =
+ m->part[i]->kit[j].padpars;
+ objmap["/part"+to_s(i)+"/kit"+to_s(j)+"/padpars/oscil/"] =
+ m->part[i]->kit[j].padpars->oscilgen;
+ for(int k=0; k<NUM_VOICES; ++k) {
+ objmap["/part"+to_s(i)+"/kit"+to_s(j)+"/adpars/voice"+to_s(k)+"/oscil/"] =
+ m->part[i]->kit[j].adpars->VoicePar[k].OscilSmp;
+ objmap["/part"+to_s(i)+"/kit"+to_s(j)+"/adpars/voice"+to_s(k)+"/mod-oscil/"] =
+ m->part[i]->kit[j].adpars->VoicePar[k].FMSmp;
+ }
+ }
+ }
+
+ master = m;
+
+ //Give it to the backend and wait for the old part to return for
+ //deallocation
+ //printf("writing something to the location called '%s'\n", msg);
+ uToB->write("/load-master", "b", sizeof(Master*), &m);
+ }
+
+ bool broadcast = false;
+
+ void bToUhandle(const char *rtmsg)
+ {
+ printf(".");fflush(stdout);//return: got a '%s'\n", rtmsg);
+ if(!strcmp(rtmsg, "/echo")
+ && !strcmp(rtosc_argument_string(rtmsg),"ss")
+ && !strcmp(rtosc_argument(rtmsg,0).s, "OSC_URL"))
+ curr_url = rtosc_argument(rtmsg,1).s;
+ else if(!strcmp(rtmsg, "/free")
+ && !strcmp(rtosc_argument_string(rtmsg),"sb")) {
+ deallocate(rtosc_argument(rtmsg, 0).s, *((void**)rtosc_argument(rtmsg, 1).b.data));
+ } else if(!strcmp(rtmsg, "/setprogram")
+ && !strcmp(rtosc_argument_string(rtmsg),"cc")) {
+ loadPart(rtosc_argument(rtmsg,0).i, master->bank.ins[rtosc_argument(rtmsg,1).i].filename.c_str(), master, osc);
+ } else if(!strcmp(rtmsg, "/broadcast")) {
+ broadcast = true;
+ } else if(broadcast) {
+ broadcast = false;
+ cb(ui, rtmsg);
+ if(curr_url != "GUI") {
+ lo_message msg = lo_message_deserialise((void*)rtmsg,
+ rtosc_message_length(rtmsg, bToU->buffer_size()), NULL);
+
+ //Send to known url
+ if(!curr_url.empty()) {
+ lo_address addr = lo_address_new_from_url(curr_url.c_str());
+ lo_send_message(addr, rtmsg, msg);
+ }
+ }
+ } else if(curr_url == "GUI") {
+ cb(ui, rtmsg); //GUI::raiseUi(gui, bToU->read());
+ } else{
+ lo_message msg = lo_message_deserialise((void*)rtmsg,
+ rtosc_message_length(rtmsg, bToU->buffer_size()), NULL);
+
+ //Send to known url
+ if(!curr_url.empty()) {
+ lo_address addr = lo_address_new_from_url(curr_url.c_str());
+ lo_send_message(addr, rtmsg, msg);
+ }
+ }
+ }
+
+ void tick(void)
+ {
+ lo_server_recv_noblock(server, 0);
+ while(bToU->hasNext()) {
+ const char *rtmsg = bToU->read();
+ bToUhandle(rtmsg);
+ }
+ }
+
+ bool handlePAD(string path, const char *msg, void *v)
+ {
+ char buffer[1024];
+ memset(buffer, 0, sizeof(buffer));
+ DummyDataObj d(buffer, 1024, v, cb, ui, osc);
+ strcpy(buffer, path.c_str());
+
+ //for(auto &p:OscilGen::ports.ports) {
+ // if(strstr(p.name,msg) && strstr(p.metadata, "realtime") &&
+ // !strcmp("b", rtosc_argument_string(msg))) {
+ // printf("sending along packet '%s'...\n", msg);
+ // return false;
+ // }
+ //}
+
+ PADnoteParameters::ports.dispatch(msg, d);
+ if(!d.matches) {
+ //fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 1, 7 + 30, 0 + 40);
+ //fprintf(stderr, "Unknown location '%s%s'<%s>\n",
+ // path.c_str(), msg, rtosc_argument_string(msg));
+ //fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 0, 7 + 30, 0 + 40);
+ }
+
+ return true;
+ }
+
+ bool handleOscil(string path, const char *msg, void *v)
+ {
+ char buffer[1024];
+ memset(buffer, 0, sizeof(buffer));
+ DummyDataObj d(buffer, 1024, v, cb, ui, osc);
+ strcpy(buffer, path.c_str());
+
+ for(auto &p:OscilGen::ports.ports) {
+ if(strstr(p.name,msg) && strstr(p.metadata, "realtime") &&
+ !strcmp("b", rtosc_argument_string(msg))) {
+ //printf("sending along packet '%s'...\n", msg);
+ return false;
+ }
+ }
+
+ OscilGen::ports.dispatch(msg, d);
+ if(!d.matches) {
+ //fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 1, 7 + 30, 0 + 40);
+ //fprintf(stderr, "Unknown location '%s%s'<%s>\n",
+ // path.c_str(), msg, rtosc_argument_string(msg));
+ //fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 0, 7 + 30, 0 + 40);
+ }
+
+ return true;
+ }
+
+ /* Should handle the following paths specially
+ * as they are all fundamentally non-realtime data
+ *
+ * BASE/part#/kititem#
+ * BASE/part#/kit#/adpars/voice#/oscil/\*
+ * BASE/part#/kit#/adpars/voice#/mod-oscil/\*
+ * BASE/part#/kit#/padpars/prepare
+ * BASE/part#/kit#/padpars/oscil/\*
+ */
+ 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);
+ const char *last_path = rindex(msg, '/');
+ if(!last_path)
+ return;
+
+
+ //printf("watching '%s' go by\n", msg);
+ //Get the object resource locator
+ string obj_rl(msg, last_path+1);
+
+ if(!strcmp(msg, "/refresh_bank") && !strcmp(rtosc_argument_string(msg), "i")) {
+ refreshBankView(master->bank, rtosc_argument(msg,0).i, osc);
+ } else if(!strcmp(msg, "/bank-list") && !strcmp(rtosc_argument_string(msg), "")) {
+ bankList(master->bank, osc);
+ } else if(!strcmp(msg, "/rescanforbanks") && !strcmp(rtosc_argument_string(msg), "")) {
+ rescanForBanks(master->bank, osc);
+ } else if(!strcmp(msg, "/loadbank") && !strcmp(rtosc_argument_string(msg), "c")) {
+ loadBank(master->bank, rtosc_argument(msg, 0).i, osc);
+ } else if(strstr(msg, "efftype") && !strcmp(rtosc_argument_string(msg), "c")) {
+ createEffect(msg);
+ } else if(objmap.find(obj_rl) != objmap.end()) {
+ //try some over simplified pattern matching
+ if(strstr(msg, "oscil/")) {
+ if(!handleOscil(obj_rl, last_path+1, objmap[obj_rl]))
+ uToB->raw_write(msg);
+ //else if(strstr(obj_rl.c_str(), "kititem"))
+ // handleKitItem(obj_rl, objmap[obj_rl],atoi(rindex(msg,'m')+1),rtosc_argument(msg,0).T);
+ } else if(strstr(msg, "padpars/prepare"))
+ preparePadSynth(obj_rl,(PADnoteParameters *) objmap[obj_rl]);
+ else if(strstr(msg, "padpars")) {
+ if(!handlePAD(obj_rl, last_path+1, objmap[obj_rl]))
+ uToB->raw_write(msg);
+ } else //just forward the message
+ uToB->raw_write(msg);
+ } else if(strstr(msg, "/save_xmz") && !strcmp(rtosc_argument_string(msg), "s")) {
+ saveMaster(rtosc_argument(msg,0).s);
+ } else if(strstr(msg, "/save_xiz") && !strcmp(rtosc_argument_string(msg), "is")) {
+ savePart(rtosc_argument(msg,0).i,rtosc_argument(msg,1).s);
+ } else if(strstr(msg, "/load_xmz") && !strcmp(rtosc_argument_string(msg), "s")) {
+ loadMaster(rtosc_argument(msg,0).s);
+ } else if(!strcmp(msg, "/load_xiz") && !strcmp(rtosc_argument_string(msg), "is")) {
+ pending_load[rtosc_argument(msg,0).i]++;
+ loadPart(rtosc_argument(msg,0).i, rtosc_argument(msg,1).s, master, osc);
+ } else if(strstr(msg, "load-part") && !strcmp(rtosc_argument_string(msg), "is")) {
+ pending_load[rtosc_argument(msg,0).i]++;
+ loadPart(rtosc_argument(msg,0).i, rtosc_argument(msg,1).s, master, osc);
+ } else
+ uToB->raw_write(msg);
+ }
+
+
+ void write(const char *path, const char *args, ...)
+ {
+ //We have a free buffer in the threadlink, so use it
+ va_list va;
+ va_start(va, args);
+ write(path, args, va);
+ }
+
+ void write(const char *path, const char *args, va_list va)
+ {
+ //printf("is that a '%s' I see there?\n", path);
+ char *buffer = uToB->buffer();
+ unsigned len = uToB->buffer_size();
+ bool success = rtosc_vmessage(buffer, len, path, args, va);
+ //printf("working on '%s':'%s'\n",path, args);
+
+ if(success)
+ handleMsg(buffer);
+ else
+ warnx("Failed to write message to '%s'", path);
+ }
+
+ //Ports
+ //oscil - base path, kit, voice, name
+ //pad - base path, kit
+
+ //Actions that may be done on these objects
+ //Oscilgen almost all parameters can be safely set
+ //Padnote can have anything set on its oscilgen and a very small set of general
+ //parameters
+
+ //Provides a mapping for non-RT objects stored inside the backend
+ /**
+ * TODO These pointers may invalidate when part/master is loaded via xml
+ */
+ std::map<std::string, void*> objmap;
+
+ //This code will own the pointer to master, be prepared for odd things if
+ //this assumption is broken
+ Master *master;
+
+ //The ONLY means that any chunk of UI code should have for interacting with the
+ //backend
+ Fl_Osc_Interface *osc;
+
+ void(*idle)(void);
+ cb_t cb;
+ void *ui;
+
+ std::atomic_int pending_load[NUM_MIDI_PARTS];
+ std::atomic_int actual_load[NUM_MIDI_PARTS];
+};
+
+/**
+ * Interface to the middleware layer via osc packets
+ */
+class UI_Interface:public Fl_Osc_Interface
+{
+ public:
+ UI_Interface(MiddleWareImpl *impl_)
+ :impl(impl_)
+ {}
+
+ void requestValue(string s) override
+ {
+ //Fl_Osc_Interface::requestValue(s);
+ if(last_url != "GUI") {
+ impl->write("/echo", "ss", "OSC_URL", "GUI");
+ last_url = "GUI";
+ }
+
+ impl->write(s.c_str(),"");
+ }
+
+ void write(string s, const char *args, ...) override
+ {
+ va_list va;
+ va_start(va, args);
+ impl->write(s.c_str(), args, va);
+ }
+
+ void writeRaw(const char *msg) override
+ {
+ fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 0, 4 + 30, 0 + 40);
+ fprintf(stderr, ".");
+ //fprintf(stderr, "write(%s)\n", msg);
+ fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 0, 7 + 30, 0 + 40);
+ impl->handleMsg(msg);
+ }
+
+ void writeValue(string s, string ss) override
+ {
+ fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 0, 4 + 30, 0 + 40);
+ fprintf(stderr, "writevalue<string>(%s,%s)\n", s.c_str(),ss.c_str());
+ fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 0, 7 + 30, 0 + 40);
+ impl->write(s.c_str(), "s", ss.c_str());
+ }
+
+ void writeValue(string s, char c) override
+ {
+ fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 0, 4 + 30, 0 + 40);
+ fprintf(stderr, "writevalue<char>(%s,%d)\n", s.c_str(),c);
+ fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 0, 7 + 30, 0 + 40);
+ impl->write(s.c_str(), "c", c);
+ }
+
+ void writeValue(string s, float f) override
+ {
+ fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 0, 4 + 30, 0 + 40);
+ fprintf(stderr, "writevalue<float>(%s,%f)\n", s.c_str(),f);
+ fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 0, 7 + 30, 0 + 40);
+ impl->write(s.c_str(), "f", f);
+ }
+
+ void createLink(string s, class Fl_Osc_Widget*w) override
+ {
+ assert(s.length() != 0);
+ Fl_Osc_Interface::createLink(s,w);
+ assert(!strstr(s.c_str(), "/part0/kit-1"));
+ map.insert(std::pair<string,Fl_Osc_Widget*>(s,w));
+ }
+
+ void renameLink(string old, string newer, Fl_Osc_Widget *w) override
+ {
+ //fprintf(stdout, "renameLink('%s','%s',%p)\n",
+ // old.c_str(), newer.c_str(), w);
+ removeLink(old, w);
+ createLink(newer, w);
+ }
+
+ void removeLink(string s, class Fl_Osc_Widget*w) override
+ {
+ for(auto i = map.begin(); i != map.end(); ++i) {
+ if(i->first == s && i->second == w) {
+ map.erase(i);
+ break;
+ }
+ }
+ //printf("[%d] removing '%s' (%p)...\n", map.size(), s.c_str(), w);
+ }
+
+ virtual void removeLink(class Fl_Osc_Widget *w)
+ {
+ bool processing = true;
+ while(processing)
+ {
+ //Verify Iterator invalidation sillyness
+ 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);
+ map.erase(i);
+ processing = true;
+ break;
+ }
+ }
+ }
+ }
+
+ //A very simplistic implementation of a UI agnostic refresh method
+ virtual void damage(const char *path)
+ {
+ //printf("\n\nDamage(\"%s\")\n", path);
+ for(auto pair:map) {
+ if(strstr(pair.first.c_str(), path)) {
+ auto *tmp = dynamic_cast<Fl_Widget*>(pair.second);
+ //if(tmp)
+ // printf("%x, %d %d [%s]\n", (int)pair.second, tmp->visible_r(), tmp->visible(), pair.first.c_str());
+ //else
+ // printf("%x, (NULL)[%s]\n", (int)pair.second,pair.first.c_str());
+ if(!tmp || tmp->visible_r())
+ pair.second->update();
+ }
+ }
+ }
+
+ void tryLink(const char *msg) override
+ {
+
+ //DEBUG
+ //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;
+
+ int found_count = 0;
+
+ auto range = map.equal_range(msg);
+ for(auto itr = range.first; itr != range.second; ++itr) {
+ auto widget = itr->second;
+ found_count++;
+ const char *arg_str = rtosc_argument_string(msg);
+
+ //Always provide the raw message
+ widget->OSC_raw(msg);
+
+ if(!strcmp(arg_str, "b")) {
+ widget->OSC_value(rtosc_argument(msg,0).b.len,
+ rtosc_argument(msg,0).b.data,
+ handle);
+ } else if(!strcmp(arg_str, "c")) {
+ widget->OSC_value((char)rtosc_argument(msg,0).i,
+ handle);
+ } else if(!strcmp(arg_str, "s")) {
+ widget->OSC_value((const char*)rtosc_argument(msg,0).s,
+ handle);
+ } else if(!strcmp(arg_str, "i")) {
+ widget->OSC_value((int)rtosc_argument(msg,0).i,
+ handle);
+ } else if(!strcmp(arg_str, "f")) {
+ widget->OSC_value((float)rtosc_argument(msg,0).f,
+ handle);
+ } else if(!strcmp(arg_str, "T") || !strcmp(arg_str, "F")) {
+ widget->OSC_value((bool)rtosc_argument(msg,0).T, handle);
+ }
+ }
+
+ if(found_count == 0
+ && strcmp(msg, "/vu-meter")
+ && strcmp(msg, "undo_change")
+ && !strstr(msg, "parameter")
+ && !strstr(msg, "Prespoint")) {
+ //fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 1, 7 + 30, 0 + 40);
+ //fprintf(stderr, "Unknown widget '%s'\n", msg);
+ //fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 0, 7 + 30, 0 + 40);
+ }
+ };
+
+ void dumpLookupTable(void)
+ {
+ if(map.size() != 0)
+ printf("Leaked controls:\n");
+ for(auto i = map.begin(); i != map.end(); ++i) {
+ printf("Known control '%s' (%p)...\n", i->first.c_str(), i->second);
+ }
+ }
+
+
+ private:
+ std::multimap<string,Fl_Osc_Widget*> map;
+ MiddleWareImpl *impl;
+};
+
+void MiddleWareImpl::warnMemoryLeaks(void)
+{
+ UI_Interface *o = (UI_Interface*)osc;
+ o->dumpLookupTable();
+}
+
+Fl_Osc_Interface *genOscInterface(struct MiddleWareImpl *impl)
+{
+ return new UI_Interface(impl);
+}
+
+//stubs
+MiddleWare::MiddleWare(void)
+ :impl(new MiddleWareImpl())
+{}
+MiddleWare::~MiddleWare(void)
+{
+ delete impl;
+}
+Master *MiddleWare::spawnMaster(void)
+{
+ return impl->master;
+}
+Fl_Osc_Interface *MiddleWare::spawnUiApi(void)
+{
+ return impl->osc;
+}
+void MiddleWare::tick(void)
+{
+ impl->tick();
+}
+
+void MiddleWare::setUiCallback(void(*cb)(void*,const char *),void *ui)
+{
+ impl->cb = cb;
+ impl->ui = ui;
+}
+
+void MiddleWare::setIdleCallback(void(*cb)(void))
+{
+ impl->idle = cb;
+}
+
+void MiddleWare::pendingSetProgram(int part)
+{
+ impl->pending_load[part]++;
+}
diff --git a/src/Misc/MiddleWare.h b/src/Misc/MiddleWare.h
@@ -0,0 +1,20 @@
+#pragma once
+
+//Link between realtime and non-realtime layers
+class MiddleWare
+{
+ public:
+ MiddleWare(void);
+ ~MiddleWare(void);
+ //return internal master pointer
+ class Master *spawnMaster(void);
+ class Fl_Osc_Interface *spawnUiApi(void);
+ void setUiCallback(void(*cb)(void*,const char *),void *ui);
+ void setIdleCallback(void(*cb)(void));
+ void tick(void);
+ void pendingSetProgram(int part);
+
+ static void preparePadSynth(const char *, class PADnoteParameters *){};
+ private:
+ struct MiddleWareImpl *impl;
+};
diff --git a/src/Misc/Part.cpp b/src/Misc/Part.cpp
@@ -35,30 +35,126 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <cassert>
+
+#include <rtosc/ports.h>
+#include <rtosc/port-sugar.h>
+
+using rtosc::Ports;
+using rtosc::RtData;
+
+#define rObject Part
+static Ports partPorts = {
+ rRecurs(kit, 16, "Kit"),//NUM_KIT_ITEMS
+ rRecursp(partefx, 3, "Part Effect"),
+ rRecur(ctl, "Controller"),
+ rToggle(Penabled, "Part enable"),
+ rParam(Pvolume, "Part Volume"),
+ rParam(Pminkey, "Min Used Key"),
+ rParam(Pmaxkey, "Max Used Key"),
+ rParam(Pkeyshift, "Part keyshift"),
+ rParam(Prcvchn, "Active MIDI channel"),
+ rParam(Ppanning, "Set Panning"),
+ rParam(Pvelsns, "Velocity sensing"),
+ rParam(Pveloffs, "Velocity offset"),
+ rToggle(Pnoteon, "If the channel accepts note on events"),
+ rToggle(Pdrummode, "Drum mode enable"),
+ rToggle(Ppolymode, "Polyphoney mode"),
+ rToggle(Plegatomode, "Legato enable"),
+ rParam(Pkeylimit, "Key limit per part"),
+ rParam(info.Ptype, "Class of Instrument"),
+ rString(info.Pauthor, MAX_INFO_TEXT_SIZE, "Instrument Author"),
+ rString(info.Pcomments, MAX_INFO_TEXT_SIZE, "Instrument Comments"),
+ rString(Pname, PART_MAX_NAME_LEN, "Kit User Specified Label"),
+ {"captureMin:", NULL, NULL, [](const char *, RtData &r)
+ {Part *p = (Part*)r.obj; p->Pminkey = p->lastnote;}},
+ {"captureMax:", NULL, NULL, [](const char *, RtData &r)
+ {Part *p = (Part*)r.obj; p->Pmaxkey = p->lastnote;}},
+ {"polyType::c:i", NULL, NULL, [](const char *msg, RtData &d)
+ {
+ Part *p = (Part*)d.obj;
+ if(!rtosc_narguments(msg)) {
+ int res = 0;
+ if(!p->Ppolymode)
+ res = p->Plegatomode ? 2 : 1;
+ d.reply(d.loc, "c", res);
+ return;
+ }
-Part::Part(Microtonal *microtonal_, FFTwrapper *fft_, pthread_mutex_t *mutex_)
+ int i = rtosc_argument(msg, 0).i;
+ if(i == 0) {
+ p->Ppolymode = 1;
+ p->Plegatomode = 0;
+ } else if(i==1) {
+ p->Ppolymode = 0;
+ p->Plegatomode = 0;
+ } else {
+ p->Ppolymode = 0;
+ p->Plegatomode = 1;
+ }}},
+
+ //{"kit#16::T:F", "::Enables or disables kit item", 0,
+ // [](const char *m, RtData &d) {
+ // Part *p = (Part*)d.obj;
+ // unsigned kitid = -1;
+ // //Note that this event will be captured before transmitted, thus
+ // //reply/broadcast don't matter
+ // for(int i=0; i<VOICES; ++i) {
+ // d.reply("/middleware/oscil", "siisb", loc, kitid, i, "oscil"
+ // sizeof(OscilGen*),
+ // p->kit[kitid]->adpars->voice[i]->OscilSmp);
+ // d.reply("/middleware/oscil", "siisb", loc, kitid, i, "oscil-mod"
+ // sizeof(OscilGen*),
+ // p->kit[kitid]->adpars->voice[i]->somethingelse);
+ // }
+ // d.reply("/middleware/pad", "sib", loc, kitid,
+ // sizeof(PADnoteParameters*),
+ // p->kit[kitid]->padpars)
+ // }}
+};
+
+#undef rObject
+#define rObject Part::Kit
+static Ports kitPorts = {
+ rRecurp(padpars, "Padnote parameters"),
+ rRecurp(adpars, "Adnote parameters"),
+ rRecurp(subpars, "Adnote parameters"),
+ rToggle(Penabled, "Kit item enable"),
+ rToggle(Pmuted, "Kit item mute"),
+ rParam(Pminkey, "Kit item min key"),
+ rParam(Pmaxkey, "Kit item max key"),
+ rToggle(Padenabled, "ADsynth enable"),
+ rToggle(Psubenabled, "SUBsynth enable"),
+ rToggle(Ppadenabled, "PADsynth enable"),
+ rParam(Psendtoparteffect, "Effect Levels"),
+ rString(Pname, PART_MAX_NAME_LEN, "Kit User Specified Label"),
+ //{"padpars:b", "::", 0
+ // [](
+};
+
+Ports &Part::Kit::ports = kitPorts;
+Ports &Part::ports = partPorts;
+
+Part::Part(Microtonal *microtonal_, FFTwrapper *fft_)
{
microtonal = microtonal_;
fft = fft_;
- mutex = mutex_;
- pthread_mutex_init(&load_mutex, NULL);
partoutl = new float [synth->buffersize];
partoutr = new float [synth->buffersize];
for(int n = 0; n < NUM_KIT_ITEMS; ++n) {
- kit[n].Pname = new unsigned char [PART_MAX_NAME_LEN];
- kit[n].adpars = NULL;
- kit[n].subpars = NULL;
- kit[n].padpars = NULL;
+ kit[n].Pname = new char [PART_MAX_NAME_LEN];
+ //XXX this is wasting memory, but making interfacing with the back
+ //layers more nice, if this seems to increase memory usage figure out a
+ //sane way of tracking the changing pointers (otherwise enjoy the bloat)
+ kit[n].adpars = new ADnoteParameters(fft);
+ kit[n].subpars = new SUBnoteParameters();
+ kit[n].padpars = new PADnoteParameters(fft);
}
- kit[0].adpars = new ADnoteParameters(fft);
- kit[0].subpars = new SUBnoteParameters();
- kit[0].padpars = new PADnoteParameters(fft, mutex);
-
//Part's Insertion Effects init
for(int nefx = 0; nefx < NUM_PART_EFX; ++nefx) {
- partefx[nefx] = new EffectMgr(1, mutex);
+ partefx[nefx] = new EffectMgr(1);
Pefxbypass[nefx] = false;
}
@@ -70,6 +166,7 @@ Part::Part(Microtonal *microtonal_, FFTwrapper *fft_, pthread_mutex_t *mutex_)
killallnotes = 0;
oldfreq = -1.0f;
+
for(int i = 0; i < POLIPHONY; ++i) {
partnote[i].status = KEY_OFF;
partnote[i].note = -1;
@@ -83,7 +180,7 @@ Part::Part(Microtonal *microtonal_, FFTwrapper *fft_, pthread_mutex_t *mutex_)
}
cleanup();
- Pname = new unsigned char [PART_MAX_NAME_LEN];
+ Pname = new char[PART_MAX_NAME_LEN];
oldvolumel = oldvolumer = 0.5f;
lastnote = -1;
@@ -92,6 +189,30 @@ Part::Part(Microtonal *microtonal_, FFTwrapper *fft_, pthread_mutex_t *mutex_)
defaults();
}
+
+void Part::cloneTraits(Part &p) const
+{
+#define CLONE(x) p.x = this->x
+ CLONE(Penabled);
+
+ p.setPvolume(this->Pvolume);
+ p.setPpanning(this->Ppanning);
+
+ CLONE(Pminkey);
+ CLONE(Pmaxkey);
+ CLONE(Pkeyshift);
+ CLONE(Prcvchn);
+
+ CLONE(Pvelsns);
+ CLONE(Pveloffs);
+
+ CLONE(Pnoteon);
+ CLONE(Ppolymode);
+ CLONE(Plegatomode);
+ CLONE(Pkeylimit);
+
+ CLONE(ctl);
+}
void Part::defaults()
{
@@ -566,10 +687,12 @@ void Part::NoteOn(unsigned char note,
// Spawn another note (but silent) if legatomodevalid==true
if(legatomodevalid) {
+
+ //if this parameter is 127 for "unprocessed"
partnote[posb].kititem[ci].sendtoparteffect =
(kit[item].Psendtoparteffect <
NUM_PART_EFX ? kit[item].Psendtoparteffect :
- NUM_PART_EFX); //if this parameter is 127 for "unprocessed"
+ NUM_PART_EFX);
if((kit[item].adpars != NULL)
&& ((kit[item].Padenabled) != 0))
@@ -580,7 +703,7 @@ void Part::NoteOn(unsigned char note,
vel,
portamento,
note,
- true); //true for silent.
+ true);//true for silent.
if((kit[item].subpars != NULL)
&& ((kit[item].Psubenabled) != 0))
partnote[posb].kititem[ci].subnote =
@@ -626,13 +749,11 @@ void Part::NoteOn(unsigned char note,
*/
void Part::NoteOff(unsigned char note) //relase the key
{
- int i;
-
// This note is released, so we remove it from the list.
- if(not monomemnotes.empty())
+ if(!monomemnotes.empty())
monomemnotes.remove(note);
- for(i = POLIPHONY - 1; i >= 0; i--) //first note in, is first out if there are same note multiple times
+ for(int i = POLIPHONY - 1; i >= 0; i--) //first note in, is first out if there are same note multiple times
if((partnote[i].status == KEY_PLAYING) && (partnote[i].note == note)) {
if(ctl.sustain.sustain == 0) { //the sustain pedal is not pushed
if((Ppolymode == 0) && (not monomemnotes.empty()))
@@ -1045,42 +1166,42 @@ void Part::setPpanning(char Ppanning_)
panning = 1.0f;
}
+template<class T>
+static inline void nullify(T &t) {delete t; t = NULL; }
+
/*
* Enable or disable a kit item
*/
-void Part::setkititemstatus(int kititem, int Penabled_)
+void Part::setkititemstatus(unsigned kititem, bool Penabled_)
{
+ //nonexistent kit item and the first kit item is always enabled
if((kititem == 0) || (kititem >= NUM_KIT_ITEMS))
- return; //nonexistent kit item and the first kit item is always enabled
- kit[kititem].Penabled = Penabled_;
+ return;
+
+ Kit &kkit = kit[kititem];
+
+ //no need to update if
+ if(kkit.Penabled == Penabled_)
+ return;
+ kkit.Penabled = Penabled_;
- bool resetallnotes = false;
if(Penabled_ == 0) {
- if(kit[kititem].adpars != NULL)
- delete (kit[kititem].adpars);
- if(kit[kititem].subpars != NULL)
- delete (kit[kititem].subpars);
- if(kit[kititem].padpars != NULL) {
- delete (kit[kititem].padpars);
- resetallnotes = true;
- }
- kit[kititem].adpars = NULL;
- kit[kititem].subpars = NULL;
- kit[kititem].padpars = NULL;
- kit[kititem].Pname[0] = '\0';
- }
- else {
- if(kit[kititem].adpars == NULL)
- kit[kititem].adpars = new ADnoteParameters(fft);
- if(kit[kititem].subpars == NULL)
- kit[kititem].subpars = new SUBnoteParameters();
- if(kit[kititem].padpars == NULL)
- kit[kititem].padpars = new PADnoteParameters(fft, mutex);
- }
+ //nullify(kkit.adpars);
+ //nullify(kkit.subpars);
+ //nullify(kkit.padpars);
+ kkit.Pname[0] = '\0';
- if(resetallnotes)
+ //Reset notes s.t. stale buffers will not get read
for(int k = 0; k < POLIPHONY; ++k)
KillNotePos(k);
+ }
+ else {
+ //All parameters must be NULL in this case
+ //assert(!(kkit.adpars || kkit.subpars || kkit.padpars));
+ //kkit.adpars = new ADnoteParameters(fft);
+ //kkit.subpars = new SUBnoteParameters();
+ //kkit.padpars = new PADnoteParameters(fft);
+ }
}
void Part::add2XMLinstrument(XMLwrapper *xml)
@@ -1195,7 +1316,7 @@ int Part::saveXML(const char *filename)
return result;
}
-int Part::loadXMLinstrument(const char *filename) /*{*/
+int Part::loadXMLinstrument(const char *filename)
{
XMLwrapper *xml = new XMLwrapper();
if(xml->loadXMLfile(filename) < 0) {
@@ -1210,14 +1331,19 @@ int Part::loadXMLinstrument(const char *filename) /*{*/
delete (xml);
return 0;
-} /*}*/
+}
-void Part::applyparameters(bool lockmutex) /*{*/
+void Part::applyparameters(void)
+{
+ applyparameters([]{return false;});
+}
+
+void Part::applyparameters(std::function<bool()> do_abort)
{
for(int n = 0; n < NUM_KIT_ITEMS; ++n)
- if((kit[n].padpars != NULL) && (kit[n].Ppadenabled != 0))
- kit[n].padpars->applyparameters(lockmutex);
-} /*}*/
+ if(kit[n].Ppadenabled && kit[n].padpars)
+ kit[n].padpars->applyparameters(do_abort);
+}
void Part::getfromXMLinstrument(XMLwrapper *xml)
{
diff --git a/src/Misc/Part.h b/src/Misc/Part.h
@@ -30,6 +30,7 @@
#include "../Misc/Microtonal.h"
#include <pthread.h>
+#include <functional>
#include <list> // For the monomemnotes list.
class EffectMgr;
@@ -46,12 +47,14 @@ class Part
public:
/**Constructor
* @param microtonal_ Pointer to the microtonal object
- * @param fft_ Pointer to the FFTwrapper
- * @param mutex_ Pointer to the master pthread_mutex_t*/
- Part(Microtonal *microtonal_, FFTwrapper *fft_, pthread_mutex_t *mutex_);
+ * @param fft_ Pointer to the FFTwrapper*/
+ Part(Microtonal *microtonal_, FFTwrapper *fft_);
/**Destructor*/
~Part();
+ // Copy misc parameters not stored in .xiz format
+ void cloneTraits(Part &part) const;
+
// Midi commands implemented
void NoteOn(unsigned char note,
unsigned char velocity,
@@ -68,8 +71,6 @@ class Part
/* The synthesizer part output */
void ComputePartSmps(); //Part output
- //instrumentonly: 0 - save all, 1 - save only instrumnet, 2 - save only instrument without the name(used in bank)
-
//saves the instrument settings to a XML file
//returns 0 for ok or <0 if there is an error
@@ -82,7 +83,8 @@ class Part
void defaults();
void defaultsinstrument();
- void applyparameters(bool lockmutex = true);
+ void applyparameters(void);
+ void applyparameters(std::function<bool()> do_abort);
void getfromXML(XMLwrapper *xml);
void getfromXMLinstrument(XMLwrapper *xml);
@@ -90,20 +92,22 @@ class Part
void cleanup(bool final = false);
//the part's kit
- struct {
+ struct Kit {
unsigned char Penabled, Pmuted, Pminkey, Pmaxkey;
- unsigned char *Pname;
+ char *Pname;
unsigned char Padenabled, Psubenabled, Ppadenabled;
unsigned char Psendtoparteffect;
ADnoteParameters *adpars;
SUBnoteParameters *subpars;
PADnoteParameters *padpars;
+
+ static rtosc::Ports &ports;
} kit[NUM_KIT_ITEMS];
//Part parameters
void setkeylimit(unsigned char Pkeylimit);
- void setkititemstatus(int kititem, int Penabled_);
+ void setkititemstatus(unsigned kititem, bool Penabled_);
unsigned char Penabled; /**<if the part is enabled*/
unsigned char Pvolume; /**<part volume*/
@@ -124,11 +128,11 @@ class Part
unsigned char Plegatomode; // 0=normal, 1=legato
unsigned char Pkeylimit; //how many keys are alowed to be played same time (0=off), the older will be relased
- unsigned char *Pname; //name of the instrument
+ char *Pname; //name of the instrument
struct { //instrument additional information
unsigned char Ptype;
- unsigned char Pauthor[MAX_INFO_TEXT_SIZE + 1];
- unsigned char Pcomments[MAX_INFO_TEXT_SIZE + 1];
+ char Pauthor[MAX_INFO_TEXT_SIZE + 1];
+ char Pcomments[MAX_INFO_TEXT_SIZE + 1];
} info;
@@ -151,12 +155,10 @@ class Part
unsigned char Pefxroute[NUM_PART_EFX]; //how the effect's output is routed(to next effect/to out)
bool Pefxbypass[NUM_PART_EFX]; //if the effects are bypassed
-
- pthread_mutex_t *mutex;
- pthread_mutex_t load_mutex;
-
int lastnote;
+ static rtosc::Ports &ports;
+
private:
void RunNote(unsigned k);
void KillNotePos(int pos);
diff --git a/src/Misc/Util.cpp b/src/Misc/Util.cpp
@@ -173,3 +173,9 @@ float cinterpolate(const float *data, size_t len, float pos)
const float leftness = pos - l_pos;
return data[l_pos] * leftness + data[r_pos] * (1.0f - leftness);
}
+
+const char *message_snip(const char *m)
+{
+ while(*m && *m!='/')++m;
+ return *m?m+1:m;
+}
diff --git a/src/Misc/Util.h b/src/Misc/Util.h
@@ -65,6 +65,12 @@ std::string stringFrom(T x)
}
template<class T>
+std::string to_s(T x)
+{
+ return stringFrom(x);
+}
+
+template<class T>
T stringTo(const char *x)
{
std::string str = x != NULL ? x : "0"; //should work for the basic float/int
@@ -74,12 +80,25 @@ T stringTo(const char *x)
return ans;
}
+
+
template<class T>
T limit(T val, T min, T max)
{
return val < min ? min : (val > max ? max : val);
}
+template<class T>
+T array_max(const T *data, size_t len)
+{
+ T max = 0;
+
+ for(unsigned i = 0; i < len; ++i)
+ if(max < data[i])
+ max = data[i];
+ return max;
+}
+
//Random number generator
typedef uint32_t prng_t;
@@ -113,4 +132,62 @@ float interpolate(const float *data, size_t len, float pos);
//Linear circular interpolation
float cinterpolate(const float *data, size_t len, float pos);
+/**
+ * Port macros - these produce easy and regular port definitions for common
+ * types
+ */
+
+///trims a path in recursions
+const char *message_snip(const char *m);
+
+///floating point parameter - with lookup code
+#define PARAMF(type, var, name, scale, _min, _max, desc) \
+{#name"::f", ":parameter\0:documentation\0=" desc "\0", 0, \
+ [](const char *m, rtosc::RtData &d) { \
+ if(rtosc_narguments(m)==0) {\
+ d.reply(d.loc, "f", ((type*)d.obj)->var); \
+ } else if(rtosc_narguments(m)==1 && rtosc_type(m,0)=='f') {\
+ ((type*)d.obj)->var = limit<float>(rtosc_argument(m,0).f,_min,_max); \
+ d.broadcast(d.loc, "f", ((type*)d.obj)->var);}}}
+
+///character parameter - with lookup code
+#define PARAMC(type, var, name, desc) \
+{#name"::c", ":parameter\0:old-param\0:documentation\0=" desc"\0", 0, \
+ [](const char *m, rtosc::RtData &d) { \
+ if(rtosc_narguments(m)==0) {\
+ d.reply(d.loc, "c", ((type*)d.obj)->var); \
+ } else if(rtosc_narguments(m)==1 && rtosc_type(m,0)=='c') {\
+ ((type*)d.obj)->var = limit<char>(rtosc_argument(m,0).i,0,127); \
+ d.broadcast(d.loc, "c", ((type*)d.obj)->var);}}}
+
+///Recur - perform a simple recursion
+#define RECUR(type, cast, name, var, desc) \
+{#name"/", ":recursion\0:documentation\0=" desc"\0", &cast::ports, [](const char *m, rtosc::RtData &d){\
+ d.obj = &(((type*)d.obj)->var); \
+ cast::ports.dispatch(message_snip(m), d);}}
+
+///Recurs - perform a ranged recursion
+#define RECURS(type, cast, name, var, length, desc) \
+{#name "#" #length "/", ":recursion\0:documentation\0=" desc"\0", &cast::ports, \
+ [](const char *m, rtosc::RtData &d){ \
+ const char *mm = m; \
+ while(!isdigit(*mm))++mm; \
+ d.obj = &(((type*)d.obj)->var)[atoi(mm)]; \
+ cast::ports.dispatch(message_snip(m), d);}}
+
+///Recur - perform a simple recursion (on pointer member)
+#define RECURP(type, cast, name, var, desc) \
+{#name"/", ":recursion\0:documentation\0=" desc"\0", &cast::ports, [](const char *m, rtosc::RtData &d){\
+ d.obj = (((type*)d.obj)->var); \
+ cast::ports.dispatch(message_snip(m), d);}}
+
+///Recurs - perform a ranged recursion (on pointer array member)
+#define RECURSP(type, cast, name, var, length, desc) \
+{#name "#" #length "/", ":recursion\0:documentation\0=" desc"\0", &cast::ports, \
+ [](const char *m, rtosc::RtData &d){ \
+ const char *mm = m; \
+ while(!isdigit(*mm))++mm; \
+ d.obj = (((type*)d.obj)->var)[atoi(mm)]; \
+ cast::ports.dispatch(message_snip(m), d);}}
+
#endif
diff --git a/src/Nio/InMgr.cpp b/src/Nio/InMgr.cpp
@@ -2,10 +2,15 @@
#include "MidiIn.h"
#include "EngineMgr.h"
#include "../Misc/Master.h"
+#include "../Misc/Part.h"
+#include "../Misc/MiddleWare.h"
+#include <rtosc/thread-link.h>
#include <iostream>
using namespace std;
+extern MiddleWare *middleware;
+
ostream &operator<<(ostream &out, const MidiEvent &ev)
{
switch(ev.type) {
@@ -41,7 +46,7 @@ InMgr &InMgr::getInstance()
}
InMgr::InMgr()
- :queue(100), master(Master::getInstance())
+ :queue(100), master(NULL)
{
current = NULL;
work.init(PTHREAD_PROCESS_PRIVATE, 0);
@@ -79,21 +84,28 @@ void InMgr::flush(unsigned frameStart, unsigned frameStop)
dump.dumpnote(ev.channel, ev.num, ev.value);
if(ev.value)
- master.noteOn(ev.channel, ev.num, ev.value);
+ master->noteOn(ev.channel, ev.num, ev.value);
else
- master.noteOff(ev.channel, ev.num);
+ master->noteOff(ev.channel, ev.num);
break;
case M_CONTROLLER:
dump.dumpcontroller(ev.channel, ev.num, ev.value);
- master.setController(ev.channel, ev.num, ev.value);
+ master->setController(ev.channel, ev.num, ev.value);
break;
case M_PGMCHANGE:
- master.setProgram(ev.channel, ev.num);
+ for(int i=0; i < NUM_MIDI_PARTS; ++i) {
+ //set the program of the parts assigned to the midi channel
+ if(master->part[i]->Prcvchn == ev.channel) {
+ bToU->write("/setprogram", "cc", i, ev.num);
+ middleware->pendingSetProgram(i);
+ }
+ }
break;
+
case M_PRESSURE:
- master.polyphonicAftertouch(ev.channel, ev.num, ev.value);
+ master->polyphonicAftertouch(ev.channel, ev.num, ev.value);
break;
}
}
@@ -139,3 +151,8 @@ MidiIn *InMgr::getIn(string name)
EngineMgr &eng = EngineMgr::getInstance();
return dynamic_cast<MidiIn *>(eng.getEng(name));
}
+
+void InMgr::setMaster(Master *master_)
+{
+ master = master_;
+}
diff --git a/src/Nio/InMgr.h b/src/Nio/InMgr.h
@@ -40,6 +40,8 @@ class InMgr
std::string getSource() const;
+ void setMaster(class Master *master);
+
friend class EngineMgr;
private:
InMgr();
@@ -49,7 +51,7 @@ class InMgr
class MidiIn * current;
/**the link to the rest of zyn*/
- class Master & master;
+ class Master *master;
};
#endif
diff --git a/src/Nio/Nio.cpp b/src/Nio/Nio.cpp
@@ -21,17 +21,22 @@ bool Nio::autoConnect = false;
string Nio::defaultSource = IN_DEFAULT;
string Nio::defaultSink = OUT_DEFAULT;
-void Nio::init(void)
+void Nio::init(class Master *master)
{
in = &InMgr::getInstance(); //Enable input wrapper
out = &OutMgr::getInstance(); //Initialize the Output Systems
eng = &EngineMgr::getInstance(); //Initialize The Engines
+
+ in->setMaster(master);
+ out->setMaster(master);
}
bool Nio::start()
{
- init();
- return eng->start();
+ if(eng)
+ return eng->start();
+ else
+ return false;
}
void Nio::stop()
@@ -117,6 +122,12 @@ void Nio::preferedSampleRate(unsigned &)
{}
#endif
+void Nio::masterSwap(Master *master)
+{
+ in->setMaster(master);
+ out->setMaster(master);
+}
+
void Nio::waveNew(class WavFile *wave)
{
out->wave->newFile(wave);
diff --git a/src/Nio/Nio.h b/src/Nio/Nio.h
@@ -4,13 +4,14 @@
#include <set>
class WavFile;
+class Master;
/**Interface to Nio Subsystem
*
* Should be only externally included header */
namespace Nio
{
- void init(void);
+ void init(Master *master);
bool start(void);
void stop(void);
@@ -32,6 +33,8 @@ namespace Nio
//Get the prefered sample rate from jack (if running)
void preferedSampleRate(unsigned &rate);
+ //Complete Master Swaps to ONLY BE CALLED FROM RT CONTEXT
+ void masterSwap(Master *master);
//Wave writing
void waveNew(class WavFile *wave);
diff --git a/src/Nio/OutMgr.cpp b/src/Nio/OutMgr.cpp
@@ -22,11 +22,10 @@ OutMgr::OutMgr()
:wave(new WavEngine()),
priBuf(new float[4096],
new float[4096]), priBuffCurrent(priBuf),
- master(Master::getInstance())
+ master(NULL)
{
currentOut = NULL;
stales = 0;
- master = Master::getInstance();
//init samples
outr = new float[synth->buffersize];
@@ -61,13 +60,9 @@ const Stereo<float *> OutMgr::tick(unsigned int frameSize)
int i=0;
while(frameSize > storedSmps()) {
if(!midi.empty()) {
- pthread_mutex_lock(&(master.mutex));
midi.flush(i*synth->buffersize, (i+1)*synth->buffersize);
- pthread_mutex_unlock(&(master.mutex));
}
- pthread_mutex_lock(&(master.mutex));
master.AudioOut(outl, outr);
- pthread_mutex_unlock(&(master.mutex));
addSmps(outl, outr);
i++;
}
@@ -118,6 +113,11 @@ string OutMgr::getSink() const
return "ERROR";
}
+void OutMgr::setMaster(Master *master_)
+{
+ master=master_;
+}
+
//perform a cheap linear interpolation for resampling
//This will result in some distortion at frame boundries
//returns number of samples produced
diff --git a/src/Nio/OutMgr.h b/src/Nio/OutMgr.h
@@ -40,6 +40,8 @@ class OutMgr
class WavEngine * wave; /**<The Wave Recorder*/
friend class EngineMgr;
+
+ void setMaster(class Master *master_);
private:
OutMgr();
void addSmps(float *l, float *r);
@@ -56,7 +58,7 @@ class OutMgr
float *outl;
float *outr;
- class Master & master;
+ class Master *master;
int stales;
};
diff --git a/src/Params/ADnoteParameters.cpp b/src/Params/ADnoteParameters.cpp
@@ -33,6 +33,198 @@
#include "../Synth/Resonance.h"
#include "FilterParams.h"
+#include <rtosc/ports.h>
+#include <rtosc/port-sugar.h>
+using rtosc::Ports;
+using rtosc::RtData;
+
+#define EXPAND(x) x
+#define rObject ADnoteVoiceParam
+
+static Ports voicePorts = {
+ RECURP(ADnoteVoiceParam, OscilGen, oscil, OscilSmp, "Primary Oscillator"),
+ RECURP(ADnoteVoiceParam, OscilGen, mod-oscil, FMSmp, "Modulating Oscillator"),
+ RECURP(ADnoteVoiceParam, LFOParams, FreqLfo, FreqLfo, "Frequency LFO"),
+ RECURP(ADnoteVoiceParam, LFOParams, AmpLfo, AmpLfo, "Amplitude LFO"),
+ RECURP(ADnoteVoiceParam, LFOParams, FilterLfo, FilterLfo, "Filter LFO"),
+ rRecurp(FreqEnvelope, "Frequency Envelope"),
+ rRecurp(AmpEnvelope, "Amplitude Envelope"),
+ rRecurp(FilterEnvelope, "Filter Envelope"),
+ rRecurp(FMFreqEnvelope, "Modulator Frequency Envelope"),
+ rRecurp(FMAmpEnvelope, "Modulator Amplitude Envelope"),
+ rRecurp(VoiceFilter, "Optional Voice Filter"),
+
+ rToggle(Enabled, "Voice Enable"),
+ rParam(Unison_size, "Number of subvoices"),
+ rParam(Unison_frequency_spread, "Subvoice detune"),
+ rParam(Unison_stereo_spread, "Subvoice L/R Separation"),
+ rParam(Unison_vibratto, "Subvoice vibratto"),
+ rParam(Unison_vibratto_speed, "Subvoice vibratto speed"),
+ rOption(Unison_invert_phase, rOptions(none, random, 50%, 33%, 25%), "Subvoice Phases"),
+ rOption(Type, rOptions(Sound,Noise), "Type of Sound"),
+ rParam(PDelay, "Voice Startup Delay"),
+ rToggle(Presonance, "Resonance Enable"),
+ rParam(Pextoscil, "External Oscilator Selection"),
+ rParam(PextFMoscil, "External FM Oscilator Selection"),
+ rParam(Poscilphase, "Oscillator Phase"),
+ rParam(PFMoscilphase, "FM Oscillator Phase"),
+ rToggle(Pfilterbypass, "Filter Bypass"),
+
+ //Freq Stuff
+ rToggle(Pfixedfreq, "If frequency is fixed"),
+ rParam(PfixedfreqET, "Equal Tempermant Parameter"),
+ rParamI(PDetune, "Fine Detune"),
+ rParamI(PCoarseDetune, "Coarse Detune"),
+ rParam(PDetuneType, "Magnitude of Detune"),
+ rToggle(PFreqEnvelopeEnabled, "Frequency Envelope Enable"),
+ rToggle(PFreqLfoEnabled, "Frequency LFO Enable"),
+
+ //Amplitude Stuff
+ rParam(PPanning, "Panning"),
+ rParam(PVolume, "Volume"),
+ rToggle(PVolumeminus, "Signal Inverter"), //do we really need this??
+ rParam(PAmpVelocityScaleFunction, "Velocity Sensing"),
+ rToggle(PAmpEnvelopeEnabled, "Amplitude Envelope Enable"),
+ rToggle(PAmpLfoEnabled, "Amplitude LFO Enable"),
+
+ //Filter Stuff
+ rToggle(PFilterEnabled, "Filter Enable"),
+ rToggle(PFilterEnvelopeEnabled, "Filter Envelope Enable"),
+ rToggle(PFilterLfoEnabled, "Filter LFO Enable"),
+
+
+ //Modulator Stuff
+ rParam(PFMEnabled, "Modulator Enable/Type"),
+ rParamI(PFMVoice, "Modulator Oscillator Selection"),
+ rParam(PFMVolume, "Modulator Magnitude"),
+ rParam(PFMVolumeDamp, "Modulator HF dampening"),
+ rParam(PFMVelocityScaleFunction, "Modulator Velocity Function"),
+ rParamI(PFMDetune, "Modulator Fine Detune"),
+ rParamI(PFMCoarseDetune, "Modulator Coarse Detune"),
+ rParam(PFMDetuneType, "Modulator Detune Magnitude"),
+ rToggle(PFMFreqEnvelopeEnabled, "Modulator Frequency Envelope"),
+ rToggle(PFMAmpEnvelopeEnabled, "Modulator Amplitude Envelope"),
+
+
+ //weird stuff for PCoarseDetune
+ {"detunevalue:", NULL, NULL, [](const char *, RtData &d)
+ {
+ rObject *obj = (rObject *)d.obj;
+ //TODO check if this is accurate or if PCoarseDetune is utilized
+ //TODO do the same for the other engines
+ d.reply(d.loc, "f", getdetune(obj->PDetuneType, 0, obj->PDetune));
+ }},
+ {"octave::c:i", NULL, NULL, [](const char *msg, RtData &d)
+ {
+ rObject *obj = (rObject *)d.obj;
+ if(!rtosc_narguments(msg)) {
+ int k=obj->PCoarseDetune/1024;
+ if (k>=8) k-=16;
+ d.reply(d.loc, "i", k);
+ } else {
+ int k=(int) rtosc_argument(msg, 0).i;
+ if (k<0) k+=16;
+ obj->PCoarseDetune = k*1024 + obj->PCoarseDetune%1024;
+ }
+ }},
+ {"coarsedetune::c:i", NULL, NULL, [](const char *msg, RtData &d)
+ {
+ rObject *obj = (rObject *)d.obj;
+ if(!rtosc_narguments(msg)) {
+ int k=obj->PCoarseDetune%1024;
+ if (k>=512) k-=1024;
+ d.reply(d.loc, "i", k);
+ } else {
+ int k=(int) rtosc_argument(msg, 0).i;
+ if (k<0) k+=1024;
+ obj->PCoarseDetune = k + (obj->PCoarseDetune/1024)*1024;
+ }
+ }},
+};
+
+#undef rObject
+#define rObject ADnoteGlobalParam
+
+static Ports globalPorts = {
+ PARAMC(ADnoteGlobalParam, PPanning, panning, "Panning (0 random, 1 left, 127 right)"),
+ RECURP(ADnoteGlobalParam, Resonance, Reson, Reson, "Resonance"),
+ RECURP(ADnoteGlobalParam, LFOParams, FreqLfo, FreqLfo, "Frequency LFO"),
+ RECURP(ADnoteGlobalParam, LFOParams, AmpLfo, AmpLfo, "Amplitude LFO"),
+ RECURP(ADnoteGlobalParam, LFOParams, FilterLfo, FilterLfo, "Filter LFO"),
+ RECURP(ADnoteGlobalParam, EnvelopeParams, FreqEnvelope, FreqEnvelope, "Frequency Envelope"),
+ RECURP(ADnoteGlobalParam, EnvelopeParams, AmpEnvelope, AmpEnvelope, "Frequency Envelope"),
+ RECURP(ADnoteGlobalParam, EnvelopeParams, FilterEnvelope, FilterEnvelope, "Frequency Envelope"),
+ RECURP(ADnoteGlobalParam, FilterParams, GlobalFilter, GlobalFilter, "Filter"),
+ rToggle(PStereo, "Mono/Stereo Enable"),
+
+ //Frequency
+ rParamI(PDetune, "Fine Detune"),
+ rParamI(PCoarseDetune, "Coarse Detune"),
+ rParam(PDetuneType, "Detune Scaling Type"),
+ rParam(PBandwidth, "Relative Fine Detune Gain"),
+
+ //Amplitude
+ rParam(PPanning, "Panning of ADsynth"),
+ rParam(PVolume, "volume control"),
+ rParam(PAmpVelocityScaleFunction, "Volume Velocity Control"),
+
+ rParam(PPunchStrength, "Punch Strength"),
+ rParam(PPunchTime, "UNKNOWN"),
+ rParam(PPunchStretch, "How Punch changes with note frequency"),
+ rParam(PPunchVelocitySensing, "Punch Velocity control"),
+
+ //Filter
+ rParam(PFilterVelocityScale, "Filter Velocity Magnitude"),
+ rParam(PFilterVelocityScaleFunction, "Filter Velocity Function Shape"),
+
+
+ //Resonance
+ rParam(Hrandgrouping, "How randomness is applied to multiple voices using the same oscil"),
+
+ //weird stuff for PCoarseDetune
+ {"detunevalue:", NULL, NULL, [](const char *, RtData &d)
+ {
+ rObject *obj = (rObject *)d.obj;
+ d.reply(d.loc, "f", getdetune(obj->PDetuneType, 0, obj->PDetune));
+ }},
+ {"octave::c:i", NULL, NULL, [](const char *msg, RtData &d)
+ {
+ rObject *obj = (rObject *)d.obj;
+ if(!rtosc_narguments(msg)) {
+ int k=obj->PCoarseDetune/1024;
+ if (k>=8) k-=16;
+ d.reply(d.loc, "i", k);
+ } else {
+ int k=(int) rtosc_argument(msg, 0).i;
+ if (k<0) k+=16;
+ obj->PCoarseDetune = k*1024 + obj->PCoarseDetune%1024;
+ }
+ }},
+ {"coarsedetune::c:i", NULL, NULL, [](const char *msg, RtData &d)
+ {
+ rObject *obj = (rObject *)d.obj;
+ if(!rtosc_narguments(msg)) {
+ int k=obj->PCoarseDetune%1024;
+ if (k>=512) k-=1024;
+ d.reply(d.loc, "i", k);
+ } else {
+ int k=(int) rtosc_argument(msg, 0).i;
+ if (k<0) k+=1024;
+ obj->PCoarseDetune = k + (obj->PCoarseDetune/1024)*1024;
+ }
+ }},
+
+};
+
+static Ports adPorts = {//XXX 16 should not be hard coded
+ RECURS(ADnoteParameters, ADnoteVoiceParam, voice, VoicePar, 16, "Voice Parameters"),
+ RECUR(ADnoteParameters, ADnoteGlobalParam, global, GlobalPar, "Adnote Parameters"),
+};
+
+Ports &ADnoteParameters::ports = adPorts;
+Ports &ADnoteVoiceParam::ports = voicePorts;
+Ports &ADnoteGlobalParam::ports = globalPorts;
+
int ADnote_unison_sizes[] =
{1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 25, 30, 40, 50, 0};
diff --git a/src/Params/ADnoteParameters.h b/src/Params/ADnoteParameters.h
@@ -111,6 +111,8 @@ struct ADnoteGlobalParam {
//how the randomness is applied to the harmonics on more voices using the same oscillator
unsigned char Hrandgrouping;
+
+ static rtosc::Ports &ports;
};
@@ -286,6 +288,8 @@ struct ADnoteVoiceParam {
/* Frequency Envelope of the Modullator */
unsigned char PFMAmpEnvelopeEnabled;
EnvelopeParams *FMAmpEnvelope;
+
+ static rtosc::Ports &ports;
};
class ADnoteParameters:public PresetsArray
@@ -305,6 +309,7 @@ class ADnoteParameters:public PresetsArray
float getUnisonFrequencySpreadCents(int nvoice);
int get_unison_size_index(int nvoice);
void set_unison_size_index(int nvoice, int index);
+ static rtosc::Ports &ports;
private:
void defaults(int n); //n is the nvoice
diff --git a/src/Params/Controller.cpp b/src/Params/Controller.cpp
@@ -21,8 +21,42 @@
*/
#include "Controller.h"
-#include <math.h>
-#include <stdio.h>
+#include <cmath>
+#include <cstdio>
+
+#include <rtosc/ports.h>
+#include <rtosc/port-sugar.h>
+using namespace rtosc;
+
+#define rObject Controller
+rtosc::Ports Controller::ports = {
+ rParam(panning.depth, "Depth of Panning MIDI Control"),
+ rParam(filtercutoff.depth, "Depth of Filter Cutoff MIDI Control"),
+ rParam(filterq.depth, "Depth of Filter Q MIDI Control"),
+ rParam(bandwidth.depth, "Depth of Bandwidth MIDI Control"),
+ rToggle(bandwidth.exponential, "Bandwidth Exponential Mode"),
+ rParam(modwheel.depth, "Depth of Modwheel MIDI Control"),
+ rToggle(modwheel.exponential, "Modwheel Exponential Mode"),
+ rParamI(pitchwheel.bendrange, "Range of MIDI Pitch Wheel"),
+ rToggle(expression.receive, "Expression MIDI Receive"),
+ rToggle(fmamp.receive, "FM amplitude MIDI Receive"),
+ rToggle(volume.receive, "Volume MIDI Receive"),
+ rToggle(sustain.receive, "Sustain MIDI Receive"),
+ rToggle(portamento.receive, "Portamento MIDI Receive"),
+ rToggle(portamento.portamento, "UNDOCUMENTED"),
+ rParam(portamento.time, "Portamento Length"),
+ rToggle(portamento.proportional, "If all portamentos are proportional to the distance they span"),
+ rParam(portamento.propRate, "Portamento proportional rate"),
+ rParam(portamento.propDepth, "Portamento proportional depth"),
+ rParam(portamento.pitchthresh, "Threshold for portamento"),
+ rToggle(portamento.pitchthreshtype, "Type of threshold"),
+ rParam(portamento.updowntimestretch, "UNDOCUMENTED"),
+ rParam(resonancecenter.depth, "Resonance Center MIDI Depth"),
+ rParam(resonancebandwidth.depth, "Resonance Bandwidth MIDI Depth"),
+ rToggle(NRPN.receive, "NRPN MIDI Enable"),
+ rAction(defaults),
+};
+
Controller::Controller()
{
diff --git a/src/Params/Controller.h b/src/Params/Controller.h
@@ -214,6 +214,7 @@ class Controller
unsigned char receive; //this is saved to disk by Master
} NRPN;
+ static rtosc::Ports ports;
private:
};
diff --git a/src/Params/EnvelopeParams.cpp b/src/Params/EnvelopeParams.cpp
@@ -20,17 +20,78 @@
*/
-#include <stdio.h>
+#include <cmath>
+#include <cstdlib>
+#include <rtosc/ports.h>
+#include <rtosc/port-sugar.h>
-#include <math.h>
-#include <stdlib.h>
#include "EnvelopeParams.h"
+#define rObject EnvelopeParams
+using namespace rtosc;
+
+static rtosc::Ports localPorts = {
+ rToggle(Pfreemode, "Complex Envelope Definitions"),
+ rParam(Penvpoints, rProp(internal), "Number of points in complex definition"),
+ rParam(Penvsustain, rProp(internal), "Location of the sustain point"),
+ rParams(Penvdt, MAX_ENVELOPE_POINTS, "Envelope Delay Times"),
+ rParams(Penvval, MAX_ENVELOPE_POINTS, "Envelope Values"),
+ rParam(Penvstretch, "Stretch with respect to frequency"),
+ rToggle(Pforcedrelease, "Force Envelope to fully evaluate"),
+ rToggle(Plinearenvelope, "Linear or Logarithmic Envelopes"),
+ rParam(PA_dt, "Attack Time"),
+ rParam(PA_val, "Attack Value"),
+ rParam(PD_dt, "Decay Time"),
+ rParam(PD_val, "Decay Value"),
+ rParam(PS_val, "Sustain Value"),
+ rParam(PR_dt, "Release Time"),
+ rParam(PR_val, "Release Value"),
+
+ {"addPoint:i", rProp(internal), NULL, [](const char *msg, RtData &d)
+ {
+ EnvelopeParams *env = (rObject*) d.obj;
+ const int curpoint = rtosc_argument(msg, 0).i;
+ //int curpoint=freeedit->lastpoint;
+ if (curpoint<0 || curpoint>env->Penvpoints || env->Penvpoints>=MAX_ENVELOPE_POINTS)
+ return;
+
+ for (int i=env->Penvpoints; i>=curpoint+1; i--) {
+ env->Penvdt[i]=env->Penvdt[i-1];
+ env->Penvval[i]=env->Penvval[i-1];
+ }
+
+ if (curpoint==0) {
+ env->Penvdt[1]=64;
+ }
+
+ env->Penvpoints++;
+ if (curpoint<=env->Penvsustain) env->Penvsustain++;
+ }},
+ {"delPoint:i", rProp(internal), NULL, [](const char *msg, RtData &d)
+ {
+ EnvelopeParams *env = (rObject*) d.obj;
+ const int curpoint=rtosc_argument(msg, 0).i;
+ if(curpoint<1 || curpoint>=env->Penvpoints-1 || env->Penvpoints<=3)
+ return;
+
+ for (int i=curpoint+1;i<env->Penvpoints;i++){
+ env->Penvdt[i-1]=env->Penvdt[i];
+ env->Penvval[i-1]=env->Penvval[i];
+ };
+
+ env->Penvpoints--;
+
+ if (curpoint<=env->Penvsustain)
+ env->Penvsustain--;
+
+ }},
+};
+
+rtosc::Ports &EnvelopeParams::ports = localPorts;
+
EnvelopeParams::EnvelopeParams(unsigned char Penvstretch_,
- unsigned char Pforcedrelease_):Presets()
+ unsigned char Pforcedrelease_):Presets()
{
- int i;
-
PA_dt = 10;
PD_dt = 10;
PR_dt = 10;
@@ -39,7 +100,7 @@ EnvelopeParams::EnvelopeParams(unsigned char Penvstretch_,
PS_val = 64;
PR_val = 64;
- for(i = 0; i < MAX_ENVELOPE_POINTS; ++i) {
+ for(int i = 0; i < MAX_ENVELOPE_POINTS; ++i) {
Penvdt[i] = 32;
Penvval[i] = 64;
}
@@ -58,10 +119,14 @@ EnvelopeParams::EnvelopeParams(unsigned char Penvstretch_,
EnvelopeParams::~EnvelopeParams()
{}
-float EnvelopeParams::getdt(char i)
+float EnvelopeParams::getdt(char i) const
+{
+ return EnvelopeParams::dt(Penvdt[(int)i]);
+}
+
+float EnvelopeParams::dt(char val)
{
- float result = (powf(2.0f, Penvdt[(int)i] / 127.0f * 12.0f) - 1.0f) * 10.0f; //miliseconds
- return result;
+ return (powf(2.0f, val / 127.0f * 12.0f) - 1.0f) * 10.0f; //miliseconds
}
diff --git a/src/Params/EnvelopeParams.h b/src/Params/EnvelopeParams.h
@@ -52,7 +52,8 @@ class EnvelopeParams:public Presets
void defaults();
void getfromXML(XMLwrapper *xml);
- float getdt(char i);
+ float getdt(char i) const;
+ static float dt(char val);
/* MIDI Parameters */
unsigned char Pfreemode; //1 daca este in modul free sau 0 daca este in mod ADSR,ASR,...
@@ -75,6 +76,7 @@ class EnvelopeParams:public Presets
// 4 for ADSR_filter parameters (filter parameters)
// 5 for ASR_bw parameters (bandwidth parameters)
+ static rtosc::Ports &ports;
private:
void store2defaults();
diff --git a/src/Params/FilterParams.cpp b/src/Params/FilterParams.cpp
@@ -22,9 +22,94 @@
#include "FilterParams.h"
#include "../Misc/Util.h"
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <cmath>
+#include <cstdio>
+#include <cstdlib>
+
+#include <rtosc/rtosc.h>
+#include <rtosc/ports.h>
+#include <rtosc/port-sugar.h>
+
+using namespace rtosc;
+
+// g++ 4.8 needs this variable saved separately, otherwise it segfaults
+constexpr int sizeof_pvowels = sizeof(FilterParams::Pvowels);
+
+#define rObject FilterParams::Pvowels_t::formants_t
+static rtosc::Ports subsubports = {
+ rParam(freq, "Formant frequency"),
+ rParam(amp, "Strength of formant"),
+ rParam(q, "Quality Factor"),
+};
+#undef rObject
+
+static rtosc::Ports subports = {
+ {"Pformants#" STRINGIFY(FF_MAX_FORMANTS) "/", NULL, &subsubports,
+ [](const char *msg, RtData &d) {
+ const char *mm = msg;
+ while(*mm && !isdigit(*mm)) ++mm;
+ unsigned idx = atoi(mm);
+
+ SNIP;
+ FilterParams::Pvowels_t *obj = (FilterParams::Pvowels_t *) d.obj;
+ d.obj = (void*) &obj->formants[idx];
+ subsubports.dispatch(msg, d);
+ }},
+};
+
+#define rObject FilterParams
+#undef rChangeCb
+#define rChangeCb obj->changed = true;
+rtosc::Ports FilterParams::ports = {
+ rParam(Pcategory, "Class of filter"),
+ rParam(Ptype, "Filter Type"),
+ rParam(Pfreq, "Center Freq"),
+ rParam(Pq, "Quality Factor (resonance/bandwidth)"),
+ rParam(Pstages, "Filter Stages + 1"),
+ rParam(Pfreqtrack, "Frequency Tracking amount"),
+ rParam(Pgain, "Output Gain"),
+ rParam(Pnumformants, "Number of formants to be used"),
+ rParam(Pformantslowness, "Rate that formants change"),
+ rParam(Pvowelclearness, "Cost for mixing vowels"),
+ rParam(Pcenterfreq, "Center Freq (formant)"),
+ rParam(Poctavesfreq, "Number of octaves for formant"),
+
+ //TODO check if FF_MAX_SEQUENCE is acutally expanded or not
+ rParam(Psequencesize, rMap(max, FF_MAX_SEQUENCE), "Length of vowel sequence"),
+ rParam(Psequencestretch, "How modulators stretch the sequence"),
+ rToggle(Psequencereversed, "If the modulator input is inverted"),
+
+ //{"Psequence#" FF_MAX_SEQUENCE "/nvowel", "", NULL, [](){}},
+
+ //UI reader
+ {"Pvowels", NULL, NULL,
+ [](const char *, RtData &d) {
+ FilterParams *obj = (FilterParams *) d.obj;
+ d.reply(d.loc, "b", sizeof_pvowels, obj->Pvowels);
+ }},
+
+ {"Pvowels#" STRINGIFY(FF_MAX_VOWELS) "/", NULL, &subports,
+ [](const char *msg, RtData &d) {
+ const char *mm = msg; \
+ while(*mm && !isdigit(*mm)) ++mm; \
+ unsigned idx = atoi(mm);
+
+ SNIP;
+ FilterParams *obj = (FilterParams *) d.obj;
+ d.obj = (void*)&obj->Pvowels[idx];
+ subports.dispatch(msg, d);
+
+ if(rtosc_narguments(msg))
+ rChangeCb;
+ }},
+ // "", NULL, [](){}},"/freq"
+ //{"Pvowels#" FF_MAX_VOWELS "/formants#" FF_MAX_FORMANTS "/amp",
+ // "", NULL, [](){}},
+ //{"Pvowels#" FF_MAX_VOWELS "/formants#" FF_MAX_FORMANTS "/q",
+ // "", NULL, [](){}},
+};
+
+
FilterParams::FilterParams(unsigned char Ptype_,
unsigned char Pfreq_,
@@ -188,8 +273,6 @@ float FilterParams::getfreqpos(float freq)
void FilterParams::formantfilterH(int nvowel, int nfreqs, float *freqs)
{
float c[3], d[3];
- float filter_freq, filter_q, filter_amp;
- float omega, sn, cs, alpha;
for(int i = 0; i < nfreqs; ++i)
freqs[i] = 0.0f;
@@ -197,22 +280,20 @@ void FilterParams::formantfilterH(int nvowel, int nfreqs, float *freqs)
//for each formant...
for(int nformant = 0; nformant < Pnumformants; ++nformant) {
//compute formant parameters(frequency,amplitude,etc.)
- filter_freq = getformantfreq(Pvowels[nvowel].formants[nformant].freq);
- filter_q = getformantq(Pvowels[nvowel].formants[nformant].q) * getq();
+ const float filter_freq = getformantfreq(Pvowels[nvowel].formants[nformant].freq);
+ float filter_q = getformantq(Pvowels[nvowel].formants[nformant].q) * getq();
if(Pstages > 0)
- filter_q =
- (filter_q >
- 1.0f ? powf(filter_q, 1.0f / (Pstages + 1)) : filter_q);
+ filter_q = (filter_q > 1.0f ? powf(filter_q, 1.0f / (Pstages + 1)) : filter_q);
- filter_amp = getformantamp(Pvowels[nvowel].formants[nformant].amp);
+ const float filter_amp = getformantamp(Pvowels[nvowel].formants[nformant].amp);
if(filter_freq <= (synth->samplerate / 2 - 100.0f)) {
- omega = 2 * PI * filter_freq / synth->samplerate_f;
- sn = sinf(omega);
- cs = cosf(omega);
- alpha = sn / (2 * filter_q);
- float tmp = 1 + alpha;
+ const float omega = 2 * PI * filter_freq / synth->samplerate_f;
+ const float sn = sinf(omega);
+ const float cs = cosf(omega);
+ const float alpha = sn / (2 * filter_q);
+ const float tmp = 1 + alpha;
c[0] = alpha / tmp *sqrt(filter_q + 1);
c[1] = 0;
c[2] = -alpha / tmp *sqrt(filter_q + 1);
@@ -224,13 +305,19 @@ void FilterParams::formantfilterH(int nvowel, int nfreqs, float *freqs)
for(int i = 0; i < nfreqs; ++i) {
- float freq = getfreqx(i / (float) nfreqs);
+ const float freq = getfreqx(i / (float) nfreqs);
+
+ //Discard frequencies above nyquist rate
if(freq > synth->samplerate / 2) {
for(int tmp = i; tmp < nfreqs; ++tmp)
freqs[tmp] = 0.0f;
break;
}
- float fr = freq / synth->samplerate * PI * 2.0f;
+
+ //Convert to normalized frequency
+ const float fr = freq / synth->samplerate * PI * 2.0f;
+
+ //Evaluate Complex domain ratio
float x = c[0], y = 0.0f;
for(int n = 1; n < 3; ++n) {
x += cosf(n * fr) * c[n];
@@ -248,6 +335,8 @@ void FilterParams::formantfilterH(int nvowel, int nfreqs, float *freqs)
freqs[i] += powf(h, (Pstages + 1.0f) / 2.0f) * filter_amp;
}
}
+
+ //Convert to logarithmic data ignoring points that are too small
for(int i = 0; i < nfreqs; ++i) {
if(freqs[i] > 0.000000001f)
freqs[i] = rap2dB(freqs[i]) + getgain();
diff --git a/src/Params/FilterParams.h b/src/Params/FilterParams.h
@@ -63,8 +63,8 @@ class FilterParams:public PresetsArray
unsigned char Pvowelclearness; //how vowels are kept clean (how much try to avoid "mixed" vowels)
unsigned char Pcenterfreq, Poctavesfreq; //the center frequency of the res. func., and the number of octaves
- struct {
- struct {
+ struct Pvowels_t {
+ struct formants_t {
unsigned char freq, amp, q; //frequency,amplitude,Q
} formants[FF_MAX_FORMANTS];
} Pvowels[FF_MAX_VOWELS];
@@ -90,6 +90,7 @@ class FilterParams:public PresetsArray
bool changed;
+ static rtosc::Ports ports;
private:
void defaults(int n);
diff --git a/src/Params/LFOParams.cpp b/src/Params/LFOParams.cpp
@@ -25,6 +25,26 @@
#include "../globals.h"
#include "LFOParams.h"
+#include <rtosc/port-sugar.h>
+#include <rtosc/ports.h>
+using namespace rtosc;
+
+
+#define rObject LFOParams
+static rtosc::Ports _ports = {
+ rParamF(Pfreq, "frequency of LFO"),
+ rParam(Pintensity, "Intensity of LFO"),
+ rParam(Pstartphase, rSpecial(random), "Starting Phase"),
+ rOption(PLFOtype,"Shape of LFO"),
+ rParam(Prandomness, rSpecial(disable), "Amplitude Randomness"),
+ rParam(Pfreqrand, rSpecial(disable), "Frequency Randomness"),
+ rParam(Pdelay, rSpecial(disable), "Delay before LFO start"),
+ rToggle(Pcontinous, "Enable for global operation"),
+ rParam(Pstretch, rCentered, "Note frequency stretch"),
+};
+
+rtosc::Ports &LFOParams::ports = _ports;
+
int LFOParams::time;
LFOParams::LFOParams(char Pfreq_,
diff --git a/src/Params/LFOParams.h b/src/Params/LFOParams.h
@@ -57,6 +57,9 @@ class LFOParams:public Presets
int fel; //what kind is the LFO (0 - frequency, 1 - amplitude, 2 - filter)
static int time; //is used by Pcontinous parameter
+
+ static rtosc::Ports &ports;
+
private:
/* Default parameters */
unsigned char Dfreq;
diff --git a/src/Params/PADnoteParameters.cpp b/src/Params/PADnoteParameters.cpp
@@ -19,17 +19,177 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <math.h>
+#include <cmath>
#include "PADnoteParameters.h"
#include "../Misc/WavFile.h"
+#include <cstdio>
-PADnoteParameters::PADnoteParameters(FFTwrapper *fft_,
- pthread_mutex_t *mutex_):Presets()
+#include <rtosc/ports.h>
+#include <rtosc/port-sugar.h>
+using namespace rtosc;
+
+
+#define PC(x) PARAMC(PADnoteParameters, P##x, P##x, "undocumented")
+
+template<int i>
+void simpleset(const char *m, rtosc::RtData &d)
+{
+ unsigned char *addr = ((unsigned char*) d.obj)+i;
+ if(!rtosc_narguments(m))
+ d.reply(d.loc, "c", *addr);
+ else
+ *addr = rtosc_argument(m, 0).i;
+}
+
+#define rObject PADnoteParameters
+
+#define P_C(x) rtosc::Port{#x "::c", "::", NULL, \
+ simpleset<__builtin_offsetof(class PADnoteParameters, P##x)>}
+static rtosc::Ports localPorts =
+{
+ RECURP(PADnoteParameters, OscilGen, oscil, oscilgen, "Oscillator"),
+ RECURP(PADnoteParameters, LFOParams, FreqLfo, FreqLfo, "Frequency LFO"),
+ RECURP(PADnoteParameters, LFOParams, AmpLfo, AmpLfo, "Amplitude LFO"),
+ RECURP(PADnoteParameters, LFOParams, FilterLfo, FilterLfo, "Filter LFO"),
+ RECURP(PADnoteParameters, Resonance, resonance, resonance, "Resonance"),
+ RECURP(PADnoteParameters, EnvelopeParams, FreqEnvelope, FreqEnvelope,
+ "Frequency Envelope"),
+ RECURP(PADnoteParameters, EnvelopeParams, AmpEnvelope, AmpEnvelope,
+ "Amplitude Envelope"),
+ RECURP(PADnoteParameters, EnvelopeParams, FilterEnvelope, FilterEnvelope,
+ "Filter Envelope"),
+ rRecurp(GlobalFilter, "Post Filter"),
+ PARAMC(PADnoteParameters, Pmode, mode,
+ "0 - bandwidth, 1 - discrete 2 - continious"),
+ PC(Volume),
+ PC(hp.base.type),
+ PC(hp.base.par1),
+ PC(hp.freqmult),
+ PC(hp.modulator.par1),
+ PC(hp.modulator.freq),
+ PC(hp.width),
+ PC(hp.amp.mode),
+ PC(hp.amp.type),
+ PC(hp.amp.par1),
+ PC(hp.amp.par2),
+ rToggle(Php.autoscale, "Autoscaling Harmonics"),
+ PC(hp.onehalf),
+
+ PC(bandwidth),
+ PC(bwscale),
+
+ PC(hrpos.type),
+ PC(hrpos.par1),
+ PC(hrpos.par2),
+ PC(hrpos.par3),
+
+ PC(quality.samplesize),
+ PC(quality.basenote),
+ PC(quality.oct),
+ PC(quality.smpoct),
+
+ PC(fixedfreq),
+ PC(fixedfreqET),
+ //TODO detune, coarse detune
+ PC(DetuneType),
+ PC(Stereo),
+ PC(Panning),
+ PC(AmpVelocityScaleFunction),
+ PC(PunchStrength),
+ PC(PunchTime),
+ PC(PunchStretch),
+ PC(PunchVelocitySensing),
+ PC(FilterVelocityScale),
+ PC(FilterVelocityScaleFunction),
+
+ {"Pbandwidth::i:c", NULL, NULL,
+ [](const char *msg, rtosc::RtData &d) {
+ PADnoteParameters *p = ((PADnoteParameters*)d.obj);
+ if(rtosc_narguments(msg)) {
+ p->setPbandwidth(rtosc_argument(msg, 0).i);
+ } else {
+ d.reply(d.loc, "i", p->Pbandwidth);
+ }}},
+
+ {"bandwidthvalue:", NULL, NULL,
+ [](const char *, rtosc::RtData &d) {
+ PADnoteParameters *p = ((PADnoteParameters*)d.obj);
+ d.reply(d.loc, "f", p->setPbandwidth(p->Pbandwidth));
+ }},
+
+
+ {"nhr:", rDoc("Returns the harmonic shifts"),
+ NULL, [](const char *, rtosc::RtData &d) {
+ PADnoteParameters *p = ((PADnoteParameters*)d.obj);
+ const unsigned n = synth->oscilsize / 2;
+ float *tmp = new float[n];
+ for(unsigned i=1; i<n; ++i)
+ tmp[i] = p->getNhr(i);
+ d.reply(d.loc, "b", n*sizeof(float), tmp);
+ delete[] tmp;}},
+ {"profile:i", rDoc("UI display of the harmonic profile"),
+ NULL, [](const char *m, rtosc::RtData &d) {
+ PADnoteParameters *p = ((PADnoteParameters*)d.obj);
+ const unsigned n = rtosc_argument(m, 0).i;
+ float *tmp = new float[n];
+ float realbw = p->getprofile(tmp, n);
+ d.reply(d.loc, "b", n*sizeof(float), tmp);
+ d.reply(d.loc, "i", realbw);
+ delete[] tmp;}},
+ {"sample#64:ifb", rDoc("Nothing to see here"), 0,
+ [](const char *m, rtosc::RtData d)
+ {
+ PADnoteParameters *p = (PADnoteParameters*)d.obj;
+ const char *mm = m;
+ while(!isdigit(*mm))++mm;
+ unsigned n = atoi(mm);
+ p->sample[n].size = rtosc_argument(m,0).i;
+ p->sample[n].basefreq = rtosc_argument(m,1).f;
+ p->sample[n].smp = *(float**)rtosc_argument(m,2).b.data;
+
+ //XXX TODO memory managment (deallocation of smp buffer)
+ }},
+ //weird stuff for PCoarseDetune
+ {"detunevalue:", NULL, NULL, [](const char *, RtData &d)
+ {
+ PADnoteParameters *obj = (PADnoteParameters *)d.obj;
+ d.reply(d.loc, "f", getdetune(obj->PDetuneType, 0, obj->PDetune));
+ }},
+ {"octave::c:i", NULL, NULL, [](const char *msg, RtData &d)
+ {
+ PADnoteParameters *obj = (PADnoteParameters *)d.obj;
+ if(!rtosc_narguments(msg)) {
+ int k=obj->PCoarseDetune/1024;
+ if (k>=8) k-=16;
+ d.reply(d.loc, "i", k);
+ } else {
+ int k=(int) rtosc_argument(msg, 0).i;
+ if (k<0) k+=16;
+ obj->PCoarseDetune = k*1024 + obj->PCoarseDetune%1024;
+ }
+ }},
+ {"coarsedetune::c:i", NULL, NULL, [](const char *msg, RtData &d)
+ {
+ PADnoteParameters *obj = (PADnoteParameters *)d.obj;
+ if(!rtosc_narguments(msg)) {
+ int k=obj->PCoarseDetune%1024;
+ if (k>=512) k-=1024;
+ d.reply(d.loc, "i", k);
+ } else {
+ int k=(int) rtosc_argument(msg, 0).i;
+ if (k<0) k+=1024;
+ obj->PCoarseDetune = k + (obj->PCoarseDetune/1024)*1024;
+ }
+ }},
+};
+
+rtosc::Ports &PADnoteParameters::ports = localPorts;
+
+PADnoteParameters::PADnoteParameters(FFTwrapper *fft_):Presets()
{
setpresettype("Ppadsynth");
fft = fft_;
- mutex = mutex_;
resonance = new Resonance();
oscilgen = new OscilGen(fft_, resonance);
@@ -50,7 +210,6 @@ PADnoteParameters::PADnoteParameters(FFTwrapper *fft_,
for(int i = 0; i < PAD_MAX_SAMPLES; ++i)
sample[i].smp = NULL;
- newsample.smp = NULL;
defaults();
}
@@ -137,10 +296,9 @@ void PADnoteParameters::deletesample(int n)
{
if((n < 0) || (n >= PAD_MAX_SAMPLES))
return;
- if(sample[n].smp != NULL) {
- delete[] sample[n].smp;
- sample[n].smp = NULL;
- }
+
+ delete[] sample[n].smp;
+ sample[n].smp = NULL;
sample[n].size = 0;
sample[n].basefreq = 440.0f;
}
@@ -323,10 +481,10 @@ float PADnoteParameters::setPbandwidth(int Pbandwidth)
float PADnoteParameters::getNhr(int n)
{
float result = 1.0f;
- float par1 = powf(10.0f, -(1.0f - Phrpos.par1 / 255.0f) * 3.0f);
- float par2 = Phrpos.par2 / 255.0f;
+ const float par1 = powf(10.0f, -(1.0f - Phrpos.par1 / 255.0f) * 3.0f);
+ const float par2 = Phrpos.par2 / 255.0f;
- float n0 = n - 1.0f;
+ const float n0 = n - 1.0f;
float tmp = 0.0f;
int thresh = 0;
switch(Phrpos.type) {
@@ -372,19 +530,51 @@ float PADnoteParameters::getNhr(int n)
break;
}
- float par3 = Phrpos.par3 / 255.0f;
+ const float par3 = Phrpos.par3 / 255.0f;
- float iresult = floor(result + 0.5f);
- float dresult = result - iresult;
+ const float iresult = floor(result + 0.5f);
+ const float dresult = result - iresult;
- result = iresult + (1.0f - par3) * dresult;
+ return iresult + (1.0f - par3) * dresult;
+}
- return result;
+//Transform non zero positive signals into ones with a max of one
+static void normalize_max(float *f, size_t len)
+{
+ float max = 0.0f;
+ for(unsigned i = 0; i < len; ++i)
+ if(f[i] > i)
+ max = f[i];
+ if(max > 0.000001f)
+ for(unsigned i = 0; i < len; ++i)
+ f[i] /= max;
+}
+
+//Translate Bandwidth scale integer into floating point value
+static float Pbwscale_translate(char Pbwscale)
+{
+ switch(Pbwscale) {
+ case 0: return 1.0f;
+ case 1: return 0.0f;
+ case 2: return 0.25f;
+ case 3: return 0.5f;
+ case 4: return 0.75f;
+ case 5: return 1.5f;
+ case 6: return 2.0f;
+ case 7: return -0.5f;
+ default: return 1.0;
+ }
}
/*
* Generates the long spectrum for Bandwidth mode (only amplitudes are generated; phases will be random)
*/
+
+//Requires
+// - bandwidth scaling power
+// - bandwidth
+// - oscilator harmonics at various frequences (oodles of data)
+// - sampled resonance
void PADnoteParameters::generatespectrum_bandwidthMode(float *spectrum,
int size,
float basefreq,
@@ -392,27 +582,22 @@ void PADnoteParameters::generatespectrum_bandwidthMode(float *spectrum,
int profilesize,
float bwadjust)
{
- for(int i = 0; i < size; ++i)
- spectrum[i] = 0.0f;
-
float harmonics[synth->oscilsize / 2];
- for(int i = 0; i < synth->oscilsize / 2; ++i)
- harmonics[i] = 0.0f;
+ memset(spectrum, 0, sizeof(float) * size);
+ memset(harmonics, 0, sizeof(float) * (synth->oscilsize / 2));
+
//get the harmonic structure from the oscillator (I am using the frequency amplitudes, only)
oscilgen->get(harmonics, basefreq, false);
//normalize
- float max = 0.0f;
- for(int i = 0; i < synth->oscilsize / 2; ++i)
- if(harmonics[i] > max)
- max = harmonics[i];
- if(max < 0.000001f)
- max = 1;
- for(int i = 0; i < synth->oscilsize / 2; ++i)
- harmonics[i] /= max;
+ normalize_max(harmonics, synth->oscilsize / 2);
+
+ //Constants across harmonics
+ const float power = Pbwscale_translate(Pbwscale);
+ const float bandwidthcents = setPbandwidth(Pbandwidth);
for(int nh = 1; nh < synth->oscilsize / 2; ++nh) { //for each harmonic
- float realfreq = getNhr(nh) * basefreq;
+ const float realfreq = getNhr(nh) * basefreq;
if(realfreq > synth->samplerate_f * 0.49999f)
break;
if(realfreq < 20.0f)
@@ -421,51 +606,23 @@ void PADnoteParameters::generatespectrum_bandwidthMode(float *spectrum,
continue;
//compute the bandwidth of each harmonic
- float bandwidthcents = setPbandwidth(Pbandwidth);
- float bw =
- (powf(2.0f, bandwidthcents / 1200.0f) - 1.0f) * basefreq / bwadjust;
- float power = 1.0f;
- switch(Pbwscale) {
- case 0:
- power = 1.0f;
- break;
- case 1:
- power = 0.0f;
- break;
- case 2:
- power = 0.25f;
- break;
- case 3:
- power = 0.5f;
- break;
- case 4:
- power = 0.75f;
- break;
- case 5:
- power = 1.5f;
- break;
- case 6:
- power = 2.0f;
- break;
- case 7:
- power = -0.5f;
- break;
- }
- bw = bw * powf(realfreq / basefreq, power);
- int ibw = (int)((bw / (synth->samplerate_f * 0.5f) * size)) + 1;
+ const float bw =
+ ((powf(2.0f, bandwidthcents / 1200.0f) - 1.0f) * basefreq / bwadjust)
+ * powf(realfreq / basefreq, power);
+ const int ibw = (int)((bw / (synth->samplerate_f * 0.5f) * size)) + 1;
float amp = harmonics[nh - 1];
if(resonance->Penabled)
amp *= resonance->getfreqresponse(realfreq);
if(ibw > profilesize) { //if the bandwidth is larger than the profilesize
- float rap = sqrt((float)profilesize / (float)ibw);
- int cfreq =
+ const float rap = sqrt((float)profilesize / (float)ibw);
+ const int cfreq =
(int) (realfreq
/ (synth->samplerate_f * 0.5f) * size) - ibw / 2;
for(int i = 0; i < ibw; ++i) {
- int src = (int)(i * rap * rap);
- int spfreq = i + cfreq;
+ const int src = i * rap * rap;
+ const int spfreq = i + cfreq;
if(spfreq < 0)
continue;
if(spfreq >= size)
@@ -474,13 +631,12 @@ void PADnoteParameters::generatespectrum_bandwidthMode(float *spectrum,
}
}
else { //if the bandwidth is smaller than the profilesize
- float rap = sqrt((float)ibw / (float)profilesize);
- float ibasefreq = realfreq / (synth->samplerate_f * 0.5f) * size;
+ const float rap = sqrt((float)ibw / (float)profilesize);
+ const float ibasefreq = realfreq / (synth->samplerate_f * 0.5f) * size;
for(int i = 0; i < profilesize; ++i) {
- float idfreq = i / (float)profilesize - 0.5f;
- idfreq *= ibw;
- int spfreq = (int) (idfreq + ibasefreq);
- float fspfreq = fmodf((float)idfreq + ibasefreq, 1.0f);
+ const float idfreq = (i / (float)profilesize - 0.5f) * ibw;
+ const int spfreq = (int) (idfreq + ibasefreq);
+ const float fspfreq = fmodf((float)idfreq + ibasefreq, 1.0f);
if(spfreq <= 0)
continue;
if(spfreq >= size - 1)
@@ -500,55 +656,46 @@ void PADnoteParameters::generatespectrum_otherModes(float *spectrum,
int size,
float basefreq)
{
- for(int i = 0; i < size; ++i)
- spectrum[i] = 0.0f;
-
float harmonics[synth->oscilsize / 2];
- for(int i = 0; i < synth->oscilsize / 2; ++i)
- harmonics[i] = 0.0f;
+ memset(spectrum, 0, sizeof(float) * size);
+ memset(harmonics, 0, sizeof(float) * (synth->oscilsize / 2));
+
//get the harmonic structure from the oscillator (I am using the frequency amplitudes, only)
oscilgen->get(harmonics, basefreq, false);
//normalize
- float max = 0.0f;
- for(int i = 0; i < synth->oscilsize / 2; ++i)
- if(harmonics[i] > max)
- max = harmonics[i];
- if(max < 0.000001f)
- max = 1;
- for(int i = 0; i < synth->oscilsize / 2; ++i)
- harmonics[i] /= max;
+ normalize_max(harmonics, synth->oscilsize / 2);
for(int nh = 1; nh < synth->oscilsize / 2; ++nh) { //for each harmonic
- float realfreq = getNhr(nh) * basefreq;
-
- ///sa fac aici interpolarea si sa am grija daca frecv descresc
+ const float realfreq = getNhr(nh) * basefreq;
+ //take care of interpolation if frequency decreases
if(realfreq > synth->samplerate_f * 0.49999f)
break;
if(realfreq < 20.0f)
break;
-// if (harmonics[nh-1]<1e-4) continue;
float amp = harmonics[nh - 1];
if(resonance->Penabled)
amp *= resonance->getfreqresponse(realfreq);
- int cfreq = (int) (realfreq / (synth->samplerate_f * 0.5f) * size);
+ const int cfreq = realfreq / (synth->samplerate_f * 0.5f) * size;
spectrum[cfreq] = amp + 1e-9;
}
- if(Pmode != 1) {
+ //In continous mode the spectrum gets additional interpolation between the
+ //spectral peaks
+ if(Pmode != 1) { //continous mode
int old = 0;
for(int k = 1; k < size; ++k)
if((spectrum[k] > 1e-10) || (k == (size - 1))) {
- int delta = k - old;
- float val1 = spectrum[old];
- float val2 = spectrum[k];
- float idelta = 1.0f / delta;
+ const int delta = k - old;
+ const float val1 = spectrum[old];
+ const float val2 = spectrum[k];
+ const float idelta = 1.0f / delta;
for(int i = 0; i < delta; ++i) {
- float x = idelta * i;
+ const float x = idelta * i;
spectrum[old + i] = val1 * (1.0f - x) + val2 * x;
}
old = k;
@@ -559,17 +706,46 @@ void PADnoteParameters::generatespectrum_otherModes(float *spectrum,
/*
* Applies the parameters (i.e. computes all the samples, based on parameters);
*/
-void PADnoteParameters::applyparameters(bool lockmutex)
+void PADnoteParameters::applyparameters()
+{
+ applyparameters([]{return false;});
+}
+
+void PADnoteParameters::applyparameters(std::function<bool()> do_abort)
+{
+ if(do_abort())
+ return;
+ unsigned max = 0;
+ sampleGenerator([&max,this]
+ (unsigned N, PADnoteParameters::Sample &smp) {
+ delete[] sample[N].smp;
+ sample[N] = smp;
+ max = max < N ? N : max;
+ },
+ do_abort);
+
+ //Delete remaining unused samples
+ for(unsigned i = max; i < PAD_MAX_SAMPLES; ++i)
+ deletesample(i);
+}
+
+//Requires
+// - Pquality.samplesize
+// - Pquality.basenote
+// - Pquality.oct
+// - Pquality.smpoct
+// - spectrum at various frequencies (oodles of data)
+void PADnoteParameters::sampleGenerator(PADnoteParameters::callback cb,
+ std::function<bool()> do_abort)
{
const int samplesize = (((int) 1) << (Pquality.samplesize + 14));
- int spectrumsize = samplesize / 2;
+ const int spectrumsize = samplesize / 2;
float *spectrum = new float[spectrumsize];
- int profilesize = 512;
+ const int profilesize = 512;
float profile[profilesize];
- float bwadjust = getprofile(profile, profilesize);
-// for (int i=0;i<profilesize;i++) profile[i]*=profile[i];
+ const float bwadjust = getprofile(profile, profilesize);
float basefreq = 65.406f * powf(2.0f, Pquality.basenote / 2);
if(Pquality.basenote % 2 == 1)
basefreq *= 1.5f;
@@ -587,16 +763,19 @@ void PADnoteParameters::applyparameters(bool lockmutex)
if(samplemax == 0)
samplemax = 1;
- //prepare a BIG FFT stuff
+ //prepare a BIG FFT
FFTwrapper *fft = new FFTwrapper(samplesize);
fft_t *fftfreqs = new fft_t[samplesize / 2];
- float adj[samplemax]; //this is used to compute frequency relation to the base frequency
+ //this is used to compute frequency relation to the base frequency
+ float adj[samplemax];
for(int nsample = 0; nsample < samplemax; ++nsample)
adj[nsample] = (Pquality.oct + 1.0f) * (float)nsample / samplemax;
for(int nsample = 0; nsample < samplemax; ++nsample) {
- float tmp = adj[nsample] - adj[samplemax - 1] * 0.5f;
- float basefreqadjust = powf(2.0f, tmp);
+ if(do_abort())
+ goto exit;
+ const float basefreqadjust =
+ powf(2.0f, adj[nsample] - adj[samplemax - 1] * 0.5f);
if(Pmode == 0)
generatespectrum_bandwidthMode(spectrum,
@@ -609,13 +788,18 @@ void PADnoteParameters::applyparameters(bool lockmutex)
generatespectrum_otherModes(spectrum, spectrumsize,
basefreq * basefreqadjust);
- const int extra_samples = 5; //the last samples contains the first samples (used for linear/cubic interpolation)
+ //the last samples contains the first samples
+ //(used for linear/cubic interpolation)
+ const int extra_samples = 5;
+ PADnoteParameters::Sample newsample;
newsample.smp = new float[samplesize + extra_samples];
newsample.smp[0] = 0.0f;
for(int i = 1; i < spectrumsize; ++i) //randomize the phases
- fftfreqs[i] = std::polar(spectrum[i], (float)RND * 6.29f);
- fft->freqs2smps(fftfreqs, newsample.smp); //that's all; here is the only ifft for the whole sample; no windows are used ;-)
+ fftfreqs[i] = std::polar(spectrum[i], (float)RND * 2 * PI);
+ //that's all; here is the only ifft for the whole sample;
+ //no windows are used ;-)
+ fft->freqs2smps(fftfreqs, newsample.smp);
//normalize(rms)
@@ -625,7 +809,7 @@ void PADnoteParameters::applyparameters(bool lockmutex)
rms = sqrt(rms);
if(rms < 0.000001f)
rms = 1.0f;
- rms *= sqrt(262144.0f / samplesize);
+ rms *= sqrt(262144.0f / samplesize);//262144=2^18
for(int i = 0; i < samplesize; ++i)
newsample.smp[i] *= 1.0f / rms * 50.0f;
@@ -633,43 +817,22 @@ void PADnoteParameters::applyparameters(bool lockmutex)
for(int i = 0; i < extra_samples; ++i)
newsample.smp[i + samplesize] = newsample.smp[i];
- //replace the current sample with the new computed sample
- if(lockmutex) {
- pthread_mutex_lock(mutex);
- deletesample(nsample);
- sample[nsample].smp = newsample.smp;
- sample[nsample].size = samplesize;
- sample[nsample].basefreq = basefreq * basefreqadjust;
- pthread_mutex_unlock(mutex);
- }
- else {
- deletesample(nsample);
- sample[nsample].smp = newsample.smp;
- sample[nsample].size = samplesize;
- sample[nsample].basefreq = basefreq * basefreqadjust;
- }
- newsample.smp = NULL;
+ //yield new sample
+ newsample.size = samplesize;
+ newsample.basefreq = basefreq * basefreqadjust;
+ cb(nsample, newsample);
}
+exit:
+
+ //Cleanup
delete (fft);
delete[] fftfreqs;
delete[] spectrum;
-
- //delete the additional samples that might exists and are not useful
- if(lockmutex) {
- pthread_mutex_lock(mutex);
- for(int i = samplemax; i < PAD_MAX_SAMPLES; ++i)
- deletesample(i);
- pthread_mutex_unlock(mutex);
- }
- else
- for(int i = samplemax; i < PAD_MAX_SAMPLES; ++i)
- deletesample(i);
- ;
}
void PADnoteParameters::export2wav(std::string basefilename)
{
- applyparameters(true);
+ applyparameters();
basefilename += "_PADsynth_";
for(int k = 0; k < PAD_MAX_SAMPLES; ++k) {
if(sample[k].smp == NULL)
diff --git a/src/Params/PADnoteParameters.h b/src/Params/PADnoteParameters.h
@@ -35,12 +35,22 @@
#include "FilterParams.h"
#include "Presets.h"
#include <string>
-#include <pthread.h>
-
+#include <functional>
+
+/**
+ * Parameters for PAD synthesis
+ *
+ * Note - unlike most other parameter objects significant portions of this
+ * object are `owned' by the non-realtime context. The realtime context only
+ * needs the samples generated by the PADsynth algorithm and modulators (ie
+ * envelopes/filters/LFOs) for amplitude, frequency, and filters.
+ * The ownership will be unclear for the time being, but it should be made more
+ * explicit with time.
+ */
class PADnoteParameters:public Presets
{
public:
- PADnoteParameters(FFTwrapper *fft_, pthread_mutex_t *mutex_);
+ PADnoteParameters(FFTwrapper *fft_);
~PADnoteParameters();
void defaults();
@@ -145,17 +155,25 @@ class PADnoteParameters:public Presets
float setPbandwidth(int Pbandwidth); //returns the BandWidth in cents
float getNhr(int n); //gets the n-th overtone position relatively to N harmonic
- void applyparameters(bool lockmutex);
+ void applyparameters(void);
+ void applyparameters(std::function<bool()> do_abort);
void export2wav(std::string basefilename);
OscilGen *oscilgen;
Resonance *resonance;
- struct {
+ //RT sample data
+ struct Sample {
int size;
float basefreq;
float *smp;
- } sample[PAD_MAX_SAMPLES], newsample;
+ } sample[PAD_MAX_SAMPLES];
+
+ typedef std::function<void(int,PADnoteParameters::Sample&)> callback;
+ void sampleGenerator(PADnoteParameters::callback cb,
+ std::function<bool()> do_abort);
+
+ static rtosc::Ports &ports;
private:
void generatespectrum_bandwidthMode(float *spectrum,
@@ -171,7 +189,6 @@ class PADnoteParameters:public Presets
void deletesample(int n);
FFTwrapper *fft;
- pthread_mutex_t *mutex;
};
diff --git a/src/Params/SUBnoteParameters.cpp b/src/Params/SUBnoteParameters.cpp
@@ -22,9 +22,93 @@
#include "../globals.h"
#include "SUBnoteParameters.h"
+#include "EnvelopeParams.h"
+#include "../Misc/Util.h"
#include <stdio.h>
#include <cmath>
+#include <rtosc/ports.h>
+#include <rtosc/port-sugar.h>
+
+#define rObject SUBnoteParameters
+using namespace rtosc;
+static rtosc::Ports localPorts = {
+ rToggle(Pstereo, "Stereo Enable"),
+ rParam(PVolume, "Volume"),
+ rParam(PPanning, "Left Right Panning"),
+ rParam(PAmpVelocityScaleFunction, "Amplitude Velocity Sensing function"),
+ rParamI(PDetune, "Detune in detune type units"),
+ rParamI(PCoarseDetune, "Coarse Detune"),
+ //Real values needed
+ rOption(PDetuneType, rOptions("100 cents", "200 cents", "500 cents"), "Detune Scale"),
+ rToggle(PFreqEnvelopeEnabled, "Enable for Frequency Envelope"),
+ rToggle(PBandWidthEnvelopeEnabled, "Enable for Bandwidth Envelope"),
+ rToggle(PGlobalFilterEnabled, "Enable for Global Filter"),
+ rParam(PGlobalFilterVelocityScale, "Filter Velocity Magnitude"),
+ rParam(PGlobalFilterVelocityScaleFunction, "Filter Velocity Function Shape"),
+ //rRecur(FreqEnvelope, EnvelopeParams),
+ //rToggle(),//continue
+ rToggle(Pfixedfreq, "Base frequency fixed frequency enable"),
+ rParam(PfixedfreqET, "Equal temeperate control for fixed frequency operation"),
+ rParam(Pnumstages, rMap(min, 1), rMap(max, 5), "Number of filter stages"),
+ rParam(Pbandwidth, "Bandwidth of filters"),
+ rParam(Phmagtype, "How the magnitudes are computed (0=linear,1=-60dB,2=-60dB)"),
+ rArray(Phmag, MAX_SUB_HARMONICS, "Harmonic magnitudes"),
+ rArray(Phrelbw, MAX_SUB_HARMONICS, "Relative bandwidth"),
+ rParam(Pbwscale, "Bandwidth scaling with frequency"),
+ rRecurp(AmpEnvelope, "Amplitude envelope"),
+ rRecurp(FreqEnvelope, "Frequency Envelope"),
+ rRecurp(BandWidthEnvelope, "Bandwidth Envelope"),
+ rRecurp(GlobalFilterEnvelope, "Post Filter Envelope"),
+ rRecurp(GlobalFilter, "Post Filter"),
+ rOption(Pstart, rOptions("zero", "random", "ones"), "How harmonics are initialized"),
+
+ {"clear:", NULL, NULL, [](const char *, RtData &d)
+ {
+ SUBnoteParameters *obj = (SUBnoteParameters *)d.obj;
+ for(int i=0; i<MAX_SUB_HARMONICS; ++i) {
+ obj->Phmag[i] = 0;
+ obj->Phrelbw[i] = 64;
+ }
+ obj->Phmag[0] = 127;
+ }},
+ {"detunevalue:", NULL, NULL, [](const char *, RtData &d)
+ {
+ SUBnoteParameters *obj = (SUBnoteParameters *)d.obj;
+ d.reply(d.loc, "f", getdetune(obj->PDetuneType, 0, obj->PDetune));
+ }},
+ //weird stuff for PCoarseDetune
+ {"octave::c:i", NULL, NULL, [](const char *msg, RtData &d)
+ {
+ SUBnoteParameters *obj = (SUBnoteParameters *)d.obj;
+ if(!rtosc_narguments(msg)) {
+ int k=obj->PCoarseDetune/1024;
+ if (k>=8) k-=16;
+ d.reply(d.loc, "i", k);
+ } else {
+ int k=(int) rtosc_argument(msg, 0).i;
+ if (k<0) k+=16;
+ obj->PCoarseDetune = k*1024 + obj->PCoarseDetune%1024;
+ }
+ }},
+ {"coarsedetune::c:i", NULL, NULL, [](const char *msg, RtData &d)
+ {
+ SUBnoteParameters *obj = (SUBnoteParameters *)d.obj;
+ if(!rtosc_narguments(msg)) {
+ int k=obj->PCoarseDetune%1024;
+ if (k>=512) k-=1024;
+ d.reply(d.loc, "i", k);
+ } else {
+ int k=(int) rtosc_argument(msg, 0).i;
+ if (k<0) k+=1024;
+ obj->PCoarseDetune = k + (obj->PCoarseDetune/1024)*1024;
+ }
+ }},
+
+};
+
+rtosc::Ports &SUBnoteParameters::ports = localPorts;
+
SUBnoteParameters::SUBnoteParameters():Presets()
{
setpresettype("Psubsynth");
diff --git a/src/Params/SUBnoteParameters.h b/src/Params/SUBnoteParameters.h
@@ -25,10 +25,10 @@
#include "../globals.h"
#include "../Misc/XMLwrapper.h"
-#include "EnvelopeParams.h"
#include "FilterParams.h"
#include "Presets.h"
+class EnvelopeParams;
class SUBnoteParameters:public Presets
{
public:
@@ -105,7 +105,7 @@ class SUBnoteParameters:public Presets
//how the harmonics start("0"=0,"1"=random,"2"=1)
unsigned char Pstart;
-
+ static rtosc::Ports &ports;
private:
};
diff --git a/src/Synth/OscilGen.cpp b/src/Synth/OscilGen.cpp
@@ -23,10 +23,153 @@
#include "OscilGen.h"
#include "../Misc/WaveShapeSmps.h"
+int main_thread = 0;
#include <cassert>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
+#include <stddef.h>
+
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#include <rtosc/ports.h>
+
+//template<int i>
+//void simpleset(const char *m, rtosc::RtData &d)
+//{
+// unsigned char *addr = ((unsigned char*) d.obj)+i;
+// if(!rtosc_narguments(m))
+// d.reply(d.loc, "c", *addr);
+// else
+// *addr = rtosc_argument(m, 0).i;
+//}
+//#undef PARAMC
+//#define PARAMC(x) rtosc::Port{#x "::c", "::", NULL, \
+// simpleset<__builtin_offsetof(class OscilGen, P##x)>}
+#define PC(x) PARAMC(OscilGen, P##x, x, "")
+
+static rtosc::Ports localPorts = {
+ PC(hmagtype),
+ PC(currentbasefunc),
+ PC(basefuncpar),
+ PC(basefuncpar),
+ PC(basefuncmodulation),
+ PC(basefuncmodulationpar1),
+ PC(basefuncmodulationpar2),
+ PC(basefuncmodulationpar3),
+ PC(waveshaping),
+ PC(waveshapingfunction),
+ PC(filtertype),
+ PC(filterpar1),
+ PC(filterpar2),
+ PC(filterbeforews),
+ PC(satype),
+ PC(sapar),
+ //FIXME missing int stuff
+ PC(modulation),
+ PC(modulationpar1),
+ PC(modulationpar2),
+ PC(modulationpar3),
+ //FIXME realtime parameters lurking below
+ PC(rand),
+ PC(amprandpower),
+ PC(amprandtype),
+ PC(adaptiveharmonics),
+ PC(adaptiveharmonicsbasefreq),
+ PC(adaptiveharmonicspower),
+ PC(adaptiveharmonicspar),
+
+ {"phase#128::c", "::Sets harmonic phase",
+ NULL, [](const char *m, rtosc::RtData &d) {
+ const char *mm = m;
+ while(*mm && !isdigit(*mm)) ++mm;
+ unsigned char &phase = ((OscilGen*)d.obj)->Phphase[atoi(mm)];
+ if(!rtosc_narguments(m))
+ d.reply(d.loc, "c", phase);
+ else
+ phase = rtosc_argument(m,0).i;
+ }},
+ {"magnitude#128::c", "::Sets harmonic magnitude",
+ NULL, [](const char *m, rtosc::RtData &d) {
+ //printf("I'm at '%s'\n", d.loc);
+ const char *mm = m;
+ while(*mm && !isdigit(*mm)) ++mm;
+ unsigned char &mag = ((OscilGen*)d.obj)->Phmag[atoi(mm)];
+ if(!rtosc_narguments(m))
+ d.reply(d.loc, "c", mag);
+ else
+ mag = rtosc_argument(m,0).i;
+ }},
+ {"base-spectrum:", "::Returns spectrum of base waveshape",
+ NULL, [](const char *m, rtosc::RtData &d) {
+ const unsigned n = synth->oscilsize / 2;
+ float *spc = new float[n];
+ memset(spc, 0, 4*n);
+ ((OscilGen*)d.obj)->getspectrum(n,spc,1);
+ d.reply(d.loc, "b", n*sizeof(float), spc);
+ delete[] spc;
+ }},
+ {"base-waveform:", "::Returns base waveshape points",
+ NULL, [](const char *m, rtosc::RtData &d) {
+ const unsigned n = synth->oscilsize;
+ float *smps = new float[n];
+ memset(smps, 0, 4*n);
+ ((OscilGen*)d.obj)->getcurrentbasefunction(smps);
+ d.reply(d.loc, "b", n*sizeof(float), smps);
+ delete[] smps;
+ }},
+ {"spectrum:", "::Returns spectrum of waveform",
+ NULL, [](const char *m, rtosc::RtData &d) {
+ const unsigned n = synth->oscilsize / 2;
+ float *spc = new float[n];
+ memset(spc, 0, 4*n);
+ ((OscilGen*)d.obj)->getspectrum(n,spc,0);
+ d.reply(d.loc, "b", n*sizeof(float), spc);
+ delete[] spc;
+ }},
+ {"waveform:", "::Returns waveform points",
+ NULL, [](const char *m, rtosc::RtData &d) {
+ const unsigned n = synth->oscilsize;
+ float *smps = new float[n];
+ memset(smps, 0, 4*n);
+ OscilGen *o = ((OscilGen*)d.obj);
+ //printf("%d\n", o->needPrepare());
+ ((OscilGen*)d.obj)->get(smps,-1.0);
+ //printf("wave: %f %f %f %f\n", smps[0], smps[1], smps[2], smps[3]);
+ d.reply(d.loc, "b", n*sizeof(float), smps);
+ delete[] smps;
+ }},
+ {"prepare:", "::Performs setup operation to oscillator",
+ NULL, [](const char *m, rtosc::RtData &d) {
+ //fprintf(stderr, "prepare: got a message from '%s'\n", m);
+ OscilGen &o = *(OscilGen*)d.obj;
+ fft_t *data = new fft_t[synth->oscilsize / 2];
+ o.prepare(data);
+ //fprintf(stderr, "sending '%p' of fft data\n", data);
+ d.reply("/forward", "sb", d.loc, sizeof(fft_t*), &data);
+ o.pendingfreqs = data;
+ }},
+ {"convert2sine:", "::Translates waveform into FS",
+ NULL, [](const char *m, rtosc::RtData &d) {
+ ((OscilGen*)d.obj)->convert2sine();
+ }},
+ {"prepare:b", ":'pointer','realtime':Sets prepared fft data",
+ NULL, [](const char *m, rtosc::RtData &d) {
+ //fprintf(stderr, "prepare:b got a message from '%s'\n", m);
+ OscilGen &o = *(OscilGen*)d.obj;
+ assert(rtosc_argument(m,0).b.len == sizeof(void*));
+ d.reply("/free", "sb", "fft_t", sizeof(void*), &o.oscilFFTfreqs);
+ //fprintf(stderr, "\n\n");
+ //fprintf(stderr, "The ID of this of this thread is: %ld\n", (long int)syscall(224));
+ //fprintf(stderr, "o.oscilFFTfreqs = %p\n", o.oscilFFTfreqs);
+ assert(main_thread != syscall(224));
+ assert(o.oscilFFTfreqs !=*(fft_t**)rtosc_argument(m,0).b.data);
+ o.oscilFFTfreqs = *(fft_t**)rtosc_argument(m,0).b.data;
+ }},
+};
+
+rtosc::Ports &OscilGen::ports = localPorts;
//operations on FFTfreqs
@@ -112,6 +255,7 @@ OscilGen::OscilGen(FFTwrapper *fft_, Resonance *res_):Presets()
outoscilFFTfreqs = new fft_t[synth->oscilsize / 2];
oscilFFTfreqs = new fft_t[synth->oscilsize / 2];
basefuncFFTfreqs = new fft_t[synth->oscilsize / 2];
+ pendingfreqs = oscilFFTfreqs;
randseed = 1;
ADvsPAD = false;
@@ -317,7 +461,7 @@ void OscilGen::getbasefunction(float *smps)
/*
* Filter the oscillator
*/
-void OscilGen::oscilfilter()
+void OscilGen::oscilfilter(fft_t *freqs)
{
if(Pfiltertype == 0)
return;
@@ -327,16 +471,16 @@ void OscilGen::oscilfilter()
filter_func filter = getFilter(Pfiltertype);
for(int i = 1; i < synth->oscilsize / 2; ++i)
- oscilFFTfreqs[i] *= filter(i, par, par2);
+ freqs[i] *= filter(i, par, par2);
- normalize(oscilFFTfreqs);
+ normalize(freqs);
}
/*
* Change the base function
*/
-void OscilGen::changebasefunction()
+void OscilGen::changebasefunction(void)
{
if(Pcurrentbasefunc != 0) {
getbasefunction(tmpsmps);
@@ -372,20 +516,20 @@ inline void normalize(float *smps, size_t N)
/*
* Waveshape
*/
-void OscilGen::waveshape()
+void OscilGen::waveshape(fft_t *freqs)
{
oldwaveshapingfunction = Pwaveshapingfunction;
oldwaveshaping = Pwaveshaping;
if(Pwaveshapingfunction == 0)
return;
- clearDC(oscilFFTfreqs);
+ clearDC(freqs);
//reduce the amplitude of the freqs near the nyquist
for(int i = 1; i < synth->oscilsize / 8; ++i) {
float gain = i / (synth->oscilsize / 8.0f);
- oscilFFTfreqs[synth->oscilsize / 2 - i] *= gain;
+ freqs[synth->oscilsize / 2 - i] *= gain;
}
- fft->freqs2smps(oscilFFTfreqs, tmpsmps);
+ fft->freqs2smps(freqs, tmpsmps);
//Normalize
normalize(tmpsmps, synth->oscilsize);
@@ -393,17 +537,15 @@ void OscilGen::waveshape()
//Do the waveshaping
waveShapeSmps(synth->oscilsize, tmpsmps, Pwaveshapingfunction, Pwaveshaping);
- fft->smps2freqs(tmpsmps, oscilFFTfreqs); //perform FFT
+ fft->smps2freqs(tmpsmps, freqs); //perform FFT
}
/*
* Do the Frequency Modulation of the Oscil
*/
-void OscilGen::modulation()
+void OscilGen::modulation(fft_t *freqs)
{
- int i;
-
oldmodulation = Pmodulation;
oldmodulationpar1 = Pmodulationpar1;
oldmodulationpar2 = Pmodulationpar2;
@@ -435,26 +577,26 @@ void OscilGen::modulation()
break;
}
- clearDC(oscilFFTfreqs); //remove the DC
+ clearDC(freqs); //remove the DC
//reduce the amplitude of the freqs near the nyquist
- for(i = 1; i < synth->oscilsize / 8; ++i) {
- float tmp = i / (synth->oscilsize / 8.0f);
- oscilFFTfreqs[synth->oscilsize / 2 - i] *= tmp;
+ for(int i = 1; i < synth->oscilsize / 8; ++i) {
+ const float tmp = i / (synth->oscilsize / 8.0f);
+ freqs[synth->oscilsize / 2 - i] *= tmp;
}
- fft->freqs2smps(oscilFFTfreqs, tmpsmps);
- int extra_points = 2;
+ fft->freqs2smps(freqs, tmpsmps);
+ const int extra_points = 2;
float *in = new float[synth->oscilsize + extra_points];
//Normalize
normalize(tmpsmps, synth->oscilsize);
- for(i = 0; i < synth->oscilsize; ++i)
+ for(int i = 0; i < synth->oscilsize; ++i)
in[i] = tmpsmps[i];
- for(i = 0; i < extra_points; ++i)
+ for(int i = 0; i < extra_points; ++i)
in[i + synth->oscilsize] = tmpsmps[i];
//Do the modulation
- for(i = 0; i < synth->oscilsize; ++i) {
+ for(int i = 0; i < synth->oscilsize; ++i) {
float t = i * 1.0f / synth->oscilsize;
switch(Pmodulation) {
@@ -476,21 +618,21 @@ void OscilGen::modulation()
t = (t - floor(t)) * synth->oscilsize;
- int poshi = (int) t;
- float poslo = t - floor(t);
+ const int poshi = (int) t;
+ const float poslo = t - floor(t);
tmpsmps[i] = in[poshi] * (1.0f - poslo) + in[poshi + 1] * poslo;
}
delete [] in;
- fft->smps2freqs(tmpsmps, oscilFFTfreqs); //perform FFT
+ fft->smps2freqs(tmpsmps, freqs); //perform FFT
}
/*
* Adjust the spectrum
*/
-void OscilGen::spectrumadjust()
+void OscilGen::spectrumadjust(fft_t *freqs)
{
if(Psatype == 0)
return;
@@ -512,7 +654,7 @@ void OscilGen::spectrumadjust()
}
- normalize(oscilFFTfreqs);
+ normalize(freqs);
for(int i = 0; i < synth->oscilsize / 2; ++i) {
float mag = abs(oscilFFTfreqs, i);
@@ -532,11 +674,11 @@ void OscilGen::spectrumadjust()
mag = 1.0f;
break;
}
- oscilFFTfreqs[i] = std::polar<fftw_real>(mag, phase);
+ freqs[i] = std::polar<fftw_real>(mag, phase);
}
}
-void OscilGen::shiftharmonics()
+void OscilGen::shiftharmonics(fft_t *freqs)
{
if(Pharmonicshift == 0)
return;
@@ -550,8 +692,8 @@ void OscilGen::shiftharmonics()
if(oldh < 0)
h = 0.0f;
else
- h = oscilFFTfreqs[oldh + 1];
- oscilFFTfreqs[i + 1] = h;
+ h = freqs[oldh + 1];
+ freqs[i + 1] = h;
}
else
for(int i = 0; i < synth->oscilsize / 2 - 1; ++i) {
@@ -559,21 +701,26 @@ void OscilGen::shiftharmonics()
if(oldh >= (synth->oscilsize / 2 - 1))
h = 0.0f;
else {
- h = oscilFFTfreqs[oldh + 1];
+ h = freqs[oldh + 1];
if(abs(h) < 0.000001f)
h = 0.0f;
}
- oscilFFTfreqs[i + 1] = h;
+ freqs[i + 1] = h;
}
- clearDC(oscilFFTfreqs);
+ clearDC(freqs);
}
/*
* Prepare the Oscillator
*/
-void OscilGen::prepare()
+void OscilGen::prepare(void)
+{
+ prepare(oscilFFTfreqs);
+}
+
+void OscilGen::prepare(fft_t *freqs)
{
if((oldbasepar != Pbasefuncpar) || (oldbasefunc != Pcurrentbasefunc)
|| DIFF(basefuncmodulation) || DIFF(basefuncmodulationpar1)
@@ -613,10 +760,10 @@ void OscilGen::prepare()
hmag[i] = 0.0f;
- clearAll(oscilFFTfreqs);
+ clearAll(freqs);
if(Pcurrentbasefunc == 0) //the sine case
for(int i = 0; i < MAX_AD_HARMONICS - 1; ++i) {
- oscilFFTfreqs[i + 1] =
+ freqs[i + 1] =
std::complex<float>(-hmag[i] * sinf(hphase[i] * (i + 1)) / 2.0f,
hmag[i] * cosf(hphase[i] * (i + 1)) / 2.0f);
}
@@ -628,30 +775,30 @@ void OscilGen::prepare()
int k = i * (j + 1);
if(k >= synth->oscilsize / 2)
break;
- oscilFFTfreqs[k] += basefuncFFTfreqs[i] * std::polar<fftw_real>(
+ freqs[k] += basefuncFFTfreqs[i] * std::polar<fftw_real>(
hmag[j],
hphase[j] * k);
}
}
if(Pharmonicshiftfirst != 0)
- shiftharmonics();
+ shiftharmonics(freqs);
if(Pfilterbeforews == 0) {
- waveshape();
- oscilfilter();
+ waveshape(freqs);
+ oscilfilter(freqs);
}
else {
- oscilfilter();
- waveshape();
+ oscilfilter(freqs);
+ waveshape(freqs);
}
- modulation();
- spectrumadjust();
+ modulation(freqs);
+ spectrumadjust(freqs);
if(Pharmonicshiftfirst == 0)
- shiftharmonics();
+ shiftharmonics(freqs);
- clearDC(oscilFFTfreqs);
+ clearDC(freqs);
oldhmagtype = Phmagtype;
oldharmonicshift = Pharmonicshift + Pharmonicshiftfirst * 256;
@@ -659,6 +806,11 @@ void OscilGen::prepare()
oscilprepared = 1;
}
+fft_t operator*(float a, fft_t b)
+{
+ return std::complex<float>(a*b.real(), a*b.imag());
+}
+
void OscilGen::adaptiveharmonic(fft_t *f, float freq)
{
if(Padaptiveharmonics == 0 /*||(freq<1.0f)*/)
@@ -672,7 +824,6 @@ void OscilGen::adaptiveharmonic(fft_t *f, float freq)
clearAll(f);
clearDC(inf);
- float hc = 0.0f, hs = 0.0f;
float basefreq = 30.0f * powf(10.0f, Padaptiveharmonicsbasefreq / 128.0f);
float power = (Padaptiveharmonicspower + 1.0f) / 101.0f;
@@ -687,41 +838,22 @@ void OscilGen::adaptiveharmonic(fft_t *f, float freq)
}
for(int i = 0; i < synth->oscilsize / 2 - 2; ++i) {
- float h = i * rap;
- int high = (int)(i * rap);
- float low = fmod(h, 1.0f);
+ const int high = (int)(i * rap);
+ const float low = fmod(i * rap, 1.0f);
if(high >= (synth->oscilsize / 2 - 2))
break;
- else {
- if(down) {
- f[high] =
- std::complex<float>(f[high].real() + inf[i].real() * (1.0f - low),
- f[high].imag() + inf[i].imag() * (1.0f - low));
- f[high + 1] = std::complex<float>(f[high + 1].real() + inf[i].real() * low,
- f[high + 1].imag() + inf[i].imag() * low);
- }
- else {
- hc = inf[high].real()
- * (1.0f - low) + inf[high + 1].real() * low;
- hs = inf[high].imag()
- * (1.0f - low) + inf[high + 1].imag() * low;
- }
- if(fabs(hc) < 0.000001f)
- hc = 0.0f;
- if(fabs(hs) < 0.000001f)
- hs = 0.0f;
+ if(down) {
+ f[high] += (1.0f - low) * inf[i];
+ f[high + 1] += low * inf[i];
}
-
- if(!down) {
- if(i == 0) { //corect the aplitude of the first harmonic
- hc *= rap;
- hs *= rap;
- }
- f[i] = fft_t(hc, hs);
+ else {
+ f[i] = (1.0f - low) * inf[high] + low * inf[high + 1];
}
}
+ if(!down)//corect the aplitude of the first harmonic
+ f[0] *= rap;
f[1] += f[0];
clearDC(f);
@@ -816,6 +948,8 @@ short int OscilGen::get(float *smps, float freqHz, int resonance)
if(needPrepare())
prepare();
+ fft_t *input = freqHz > 0.0f ? oscilFFTfreqs : pendingfreqs;
+
int outpos =
(int)((RND * 2.0f
- 1.0f) * synth->oscilsize_f * (Prand - 64.0f) / 64.0f);
@@ -837,7 +971,7 @@ short int OscilGen::get(float *smps, float freqHz, int resonance)
if(Padaptiveharmonics != 0)
nyquist = synth->oscilsize / 2;
for(int i = 1; i < nyquist - 1; ++i)
- outoscilFFTfreqs[i] = oscilFFTfreqs[i];
+ outoscilFFTfreqs[i] = input[i];
adaptiveharmonic(outoscilFFTfreqs, freqHz);
adaptiveharmonicpostprocess(&outoscilFFTfreqs[1],
@@ -904,6 +1038,31 @@ short int OscilGen::get(float *smps, float freqHz, int resonance)
return 0;
}
+///*
+// * Get the oscillator function's harmonics
+// */
+//void OscilGen::getPad(float *smps, float freqHz)
+//{
+// if(needPrepare())
+// prepare();
+//
+// clearAll(outoscilFFTfreqs);
+//
+// const int nyquist = (synth->oscilsize / 2);
+//
+// //Process harmonics
+// for(int i = 1; i < nyquist - 1; ++i)
+// outoscilFFTfreqs[i] = oscilFFTfreqs[i];
+//
+// adaptiveharmonic(outoscilFFTfreqs, freqHz);
+// adaptiveharmonicpostprocess(&outoscilFFTfreqs[1], nyquist - 1);
+//
+// rmsNormalize(outoscilFFTfreqs);
+//
+// for(int i = 1; i < nyquist; ++i)
+// smps[i - 1] = abs(outoscilFFTfreqs, i);
+//}
+//
/*
* Get the spectrum of the oscillator for the UI
@@ -915,7 +1074,7 @@ void OscilGen::getspectrum(int n, float *spc, int what)
for(int i = 1; i < n; ++i) {
if(what == 0)
- spc[i - 1] = abs(oscilFFTfreqs, i);
+ spc[i - 1] = abs(pendingfreqs, i);
else {
if(Pcurrentbasefunc == 0)
spc[i - 1] = ((i == 1) ? (1.0f) : (0.0f));
diff --git a/src/Synth/OscilGen.h b/src/Synth/OscilGen.h
@@ -38,6 +38,8 @@ class OscilGen:public Presets
/**computes the full spectrum of oscil from harmonics,phases and basefunc*/
void prepare();
+ void prepare(fft_t *data);
+
/**do the antialiasing(cut off higher freqs.),apply randomness and do a IFFT*/
//returns where should I start getting samples, used in block type randomness
short get(float *smps, float freqHz, int resonance = 0);
@@ -81,27 +83,30 @@ class OscilGen:public Presets
unsigned char Pbasefuncmodulationpar1, Pbasefuncmodulationpar2,
Pbasefuncmodulationpar3; //the parameter of the base function modulation
- /*the Randomness:
- 64=no randomness
- 63..0 - block type randomness - 0 is maximum
- 65..127 - each harmonic randomness - 127 is maximum*/
- unsigned char Prand;
unsigned char Pwaveshaping, Pwaveshapingfunction;
unsigned char Pfiltertype, Pfilterpar1, Pfilterpar2;
unsigned char Pfilterbeforews;
unsigned char Psatype, Psapar; //spectrum adjust
- unsigned char Pamprandpower, Pamprandtype; //amplitude randomness
int Pharmonicshift; //how the harmonics are shifted
int Pharmonicshiftfirst; //if the harmonic shift is done before waveshaping and filter
+ unsigned char Pmodulation; //what modulation is applied to the oscil
+ unsigned char Pmodulationpar1, Pmodulationpar2, Pmodulationpar3; //the parameter of the parameters
+
+ /**Realtime parameters for ADnote*/
+
+ /*the Randomness:
+ 64=no randomness
+ 63..0 - block type randomness - 0 is maximum
+ 65..127 - each harmonic randomness - 127 is maximum*/
+ unsigned char Prand;
+ unsigned char Pamprandpower, Pamprandtype; //amplitude randomness
unsigned char Padaptiveharmonics; //the adaptive harmonics status (off=0,on=1,etc..)
unsigned char Padaptiveharmonicsbasefreq; //the base frequency of the adaptive harmonic (30..3000Hz)
unsigned char Padaptiveharmonicspower; //the strength of the effect (0=off,100=full)
unsigned char Padaptiveharmonicspar; //the parameters in 2,3,4.. modes of adaptive harmonics
- unsigned char Pmodulation; //what modulation is applied to the oscil
- unsigned char Pmodulationpar1, Pmodulationpar2, Pmodulationpar3; //the parameter of the parameters
//makes a new random seed for Amplitude Randomness
@@ -110,33 +115,43 @@ class OscilGen:public Presets
bool ADvsPAD; //if it is used by ADsynth or by PADsynth
+ static rtosc::Ports &ports;
+
+ /* Oscillator Frequencies -
+ * this is different than the hamonics set-up by the user,
+ * it may contains time-domain data if the antialiasing is turned off*/
+ fft_t *oscilFFTfreqs;
+
+ fft_t *pendingfreqs;
private:
//This array stores some termporary data and it has OSCIL_SIZE elements
float *tmpsmps;
fft_t *outoscilFFTfreqs;
float hmag[MAX_AD_HARMONICS], hphase[MAX_AD_HARMONICS]; //the magnituides and the phases of the sine/nonsine harmonics
-// private:
+
FFTwrapper *fft;
//computes the basefunction and make the FFT; newbasefunc<0 = same basefunc
- void changebasefunction();
+ void changebasefunction(void);
//Waveshaping
- void waveshape();
+ void waveshape(fft_t *freqs);
//Filter the oscillator accotding to Pfiltertype and Pfilterpar
- void oscilfilter();
+ void oscilfilter(fft_t *freqs);
//Adjust the spectrum
- void spectrumadjust();
+ void spectrumadjust(fft_t *freqs);
//Shift the harmonics
- void shiftharmonics();
+ void shiftharmonics(fft_t *freqs);
//Do the oscil modulation stuff
- void modulation();
+ void modulation(fft_t *freqs);
+ public:
//Check system for needed updates
bool needPrepare(void);
+ private:
//Do the adaptive harmonic stuff
void adaptiveharmonic(fft_t *f, float freq);
@@ -158,7 +173,6 @@ class OscilGen:public Presets
fft_t *basefuncFFTfreqs; //Base Function Frequencies
- fft_t *oscilFFTfreqs; //Oscillator Frequencies - this is different than the hamonics set-up by the user, it may contains time-domain data if the antialiasing is turned off
int oscilprepared; //1 if the oscil is prepared, 0 if it is not prepared and is need to call ::prepare() before ::get()
Resonance *res;
diff --git a/src/Synth/Resonance.cpp b/src/Synth/Resonance.cpp
@@ -19,9 +19,35 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <math.h>
-#include <stdlib.h>
+#include <cmath>
+#include <cstdlib>
#include "Resonance.h"
+#include "../Misc/Util.h"
+
+#include <rtosc/ports.h>
+#include <rtosc/port-sugar.h>
+
+#define rObject Resonance
+
+using namespace rtosc;
+rtosc::Ports Resonance::ports = {
+ rToggle(Penabled, "resonance enable"),
+ rToggle(Pprotectthefundamental, "Disable resonance filter on first harmonic"),
+ rParams(Prespoints, N_RES_POINTS, "Resonance data points"),
+ rParam(PmaxdB, "how many dB the signal may be amplified"),
+ rParam(Pcenterfreq, "Center frequency"),
+ rParam(Poctavesfreq, "The number of octaves..."),
+ rActioni(randomize, rMap(min,0), rMap(max, 2), "Randomize frequency response"),
+ rActioni(interpolatepeaks, rMap(min,0), rMap(max, 2), "Generate response from peak values"),
+ rAction(smooth, "Smooth out frequency response"),
+ rAction(zero, "Reset frequency response"),
+ //UI Value listeners
+ {"centerfreq:", "", NULL, [](const char *, RtData &d)
+ {d.reply(d.loc, "f", ((rObject*)d.obj)->getcenterfreq());}},
+ {"octavesfreq:", "", NULL, [](const char *, RtData &d)
+ {d.reply(d.loc, "f", ((rObject*)d.obj)->getoctavesfreq());}},
+
+};
Resonance::Resonance():Presets()
{
@@ -29,11 +55,11 @@ Resonance::Resonance():Presets()
defaults();
}
-Resonance::~Resonance()
+Resonance::~Resonance(void)
{}
-void Resonance::defaults()
+void Resonance::defaults(void)
{
Penabled = 0;
PmaxdB = 20;
@@ -59,37 +85,27 @@ void Resonance::setpoint(int n, unsigned char p)
/*
* Apply the resonance to FFT data
*/
-void Resonance::applyres(int n, fft_t *fftdata, float freq)
+void Resonance::applyres(int n, fft_t *fftdata, float freq) const
{
if(Penabled == 0)
return; //if the resonance is disabled
- float sum = 0.0f,
- l1 = logf(getfreqx(0.0f) * ctlcenter),
- l2 = logf(2.0f) * getoctavesfreq() * ctlbw;
- for(int i = 0; i < N_RES_POINTS; ++i)
- if(sum < Prespoints[i])
- sum = Prespoints[i];
- if(sum < 1.0f)
- sum = 1.0f;
+ const float l1 = logf(getfreqx(0.0f) * ctlcenter),
+ l2 = logf(2.0f) * getoctavesfreq() * ctlbw;
+
+ //Provide an upper bound for resonance
+ const float upper =
+ limit<float>(array_max(Prespoints, N_RES_POINTS), 1.0f, INFINITY);
for(int i = 1; i < n; ++i) {
- float x = (logf(freq * i) - l1) / l2; //compute where the n-th hamonics fits to the graph
- if(x < 0.0f)
- x = 0.0f;
-
- x *= N_RES_POINTS;
- float dx = x - floor(x);
- x = floor(x);
- int kx1 = (int)x;
- if(kx1 >= N_RES_POINTS)
- kx1 = N_RES_POINTS - 1;
- int kx2 = kx1 + 1;
- if(kx2 >= N_RES_POINTS)
- kx2 = N_RES_POINTS - 1;
+ //compute where the n-th hamonics fits to the graph
+ const float x = limit((logf(freq) - l1) / l2, 0.0f, INFINITY) * N_RES_POINTS;
+ const float dx = x - floor(x);
+ const int kx1 = limit<int>(floor(x), 0, N_RES_POINTS - 1);
+ const int kx2 = limit<int>(kx1 + 1, 0, N_RES_POINTS - 1);
float y =
- (Prespoints[kx1]
- * (1.0f - dx) + Prespoints[kx2] * dx) / 127.0f - sum / 127.0f;
+ ((Prespoints[kx1] * (1.0f - dx) + Prespoints[kx2] * dx)
+ - upper) / 127.0f;
y = powf(10.0f, y * PmaxdB / 20.0f);
@@ -103,42 +119,35 @@ void Resonance::applyres(int n, fft_t *fftdata, float freq)
/*
* Gets the response at the frequency "freq"
*/
-
-float Resonance::getfreqresponse(float freq)
+//Requires
+// - resonance data
+// - max resonance
+// - mapping from resonance data to frequency
+float Resonance::getfreqresponse(float freq) const
{
- float l1 = logf(getfreqx(0.0f) * ctlcenter),
- l2 = logf(2.0f) * getoctavesfreq() * ctlbw, sum = 0.0f;
-
- for(int i = 0; i < N_RES_POINTS; ++i)
- if(sum < Prespoints[i])
- sum = Prespoints[i];
- if(sum < 1.0f)
- sum = 1.0f;
-
- float x = (logf(freq) - l1) / l2; //compute where the n-th hamonics fits to the graph
- if(x < 0.0f)
- x = 0.0f;
- x *= N_RES_POINTS;
- float dx = x - floor(x);
- x = floor(x);
- int kx1 = (int)x;
- if(kx1 >= N_RES_POINTS)
- kx1 = N_RES_POINTS - 1;
- int kx2 = kx1 + 1;
- if(kx2 >= N_RES_POINTS)
- kx2 = N_RES_POINTS - 1;
- float result =
- (Prespoints[kx1]
- * (1.0f - dx) + Prespoints[kx2] * dx) / 127.0f - sum / 127.0f;
- result = powf(10.0f, result * PmaxdB / 20.0f);
- return result;
+ const float l1 = logf(getfreqx(0.0f) * ctlcenter),
+ l2 = logf(2.0f) * getoctavesfreq() * ctlbw;
+
+ //Provide an upper bound for resonance
+ const float upper =
+ limit<float>(array_max(Prespoints, N_RES_POINTS), 1.0f, INFINITY);
+
+ //compute where the n-th hamonics fits to the graph
+ const float x = limit((logf(freq) - l1) / l2, 0.0f, INFINITY) * N_RES_POINTS;
+ const float dx = x - floor(x);
+ const int kx1 = limit<int>(floor(x), 0, N_RES_POINTS - 1);
+ const int kx2 = limit<int>(kx1 + 1, 0, N_RES_POINTS - 1);
+ //Interpolate
+ const float result =
+ ((Prespoints[kx1] * (1.0f - dx) + Prespoints[kx2] * dx) - upper) / 127.0f;
+ return powf(10.0f, result * PmaxdB / 20.0f);
}
/*
* Smooth the resonance function
*/
-void Resonance::smooth()
+void Resonance::smooth(void)
{
float old = Prespoints[0];
for(int i = 0; i < N_RES_POINTS; ++i) {
@@ -172,6 +181,12 @@ void Resonance::randomize(int type)
smooth();
}
+void Resonance::zero(void)
+{
+ for(int i=0; i<N_RES_POINTS; ++i)
+ setpoint(i,64);
+}
+
/*
* Interpolate the peaks
*/
@@ -195,18 +210,16 @@ void Resonance::interpolatepeaks(int type)
/*
* Get the frequency from x, where x is [0..1]; x is the x coordinate
*/
-float Resonance::getfreqx(float x)
+float Resonance::getfreqx(float x) const
{
- if(x > 1.0f)
- x = 1.0f;
- float octf = powf(2.0f, getoctavesfreq());
- return getcenterfreq() / sqrt(octf) * powf(octf, x);
+ const float octf = powf(2.0f, getoctavesfreq());
+ return getcenterfreq() / sqrt(octf) * powf(octf, limit(x, 0.0f, 1.0f));
}
/*
* Get the x coordinate from frequency (used by the UI)
*/
-float Resonance::getfreqpos(float freq)
+float Resonance::getfreqpos(float freq) const
{
return (logf(freq) - logf(getfreqx(0.0f))) / logf(2.0f) / getoctavesfreq();
}
@@ -214,7 +227,7 @@ float Resonance::getfreqpos(float freq)
/*
* Get the center frequency of the resonance graph
*/
-float Resonance::getcenterfreq()
+float Resonance::getcenterfreq() const
{
return 10000.0f * powf(10, -(1.0f - Pcenterfreq / 127.0f) * 2.0f);
}
@@ -222,7 +235,7 @@ float Resonance::getcenterfreq()
/*
* Get the number of octave that the resonance functions applies to
*/
-float Resonance::getoctavesfreq()
+float Resonance::getoctavesfreq() const
{
return 0.25f + 10.0f * Poctavesfreq / 127.0f;
}
@@ -235,9 +248,6 @@ void Resonance::sendcontroller(MidiControllers ctl, float par)
ctlbw = par;
}
-
-
-
void Resonance::add2XML(XMLwrapper *xml)
{
xml->addparbool("enabled", Penabled);
diff --git a/src/Synth/Resonance.h b/src/Synth/Resonance.h
@@ -33,24 +33,26 @@
class Resonance:public Presets
{
public:
- Resonance();
- ~Resonance();
+ Resonance(void);
+ ~Resonance(void);
void setpoint(int n, unsigned char p);
- void applyres(int n, fft_t *fftdata, float freq);
- void smooth();
+ void applyres(int n, fft_t *fftdata, float freq) const;
+ void smooth(void);
void interpolatepeaks(int type);
void randomize(int type);
+ void zero(void);
void add2XML(XMLwrapper *xml);
- void defaults();
+ void defaults(void);
void getfromXML(XMLwrapper *xml);
- float getfreqpos(float freq);
- float getfreqx(float x);
- float getfreqresponse(float freq);
- float getcenterfreq();
- float getoctavesfreq();
+ //TODO remove unused methods
+ float getfreqpos(float freq) const;
+ float getfreqx(float x) const;
+ float getfreqresponse(float freq) const;
+ float getcenterfreq(void) const;
+ float getoctavesfreq(void) const;
void sendcontroller(MidiControllers ctl, float par);
//parameters
@@ -64,7 +66,7 @@ class Resonance:public Presets
float ctlcenter; //center frequency(relative)
float ctlbw; //bandwidth(relative)
- private:
+ static rtosc::Ports ports;
};
#endif
diff --git a/src/Tests/MicrotonalTest.h b/src/Tests/MicrotonalTest.h
@@ -22,6 +22,7 @@
#include <cxxtest/TestSuite.h>
#include <iostream>
#include "../Misc/Microtonal.h"
+#include "../Misc/XMLwrapper.h"
#include <cstring>
#include <string>
#include <cstdio>
diff --git a/src/Tests/PadNoteTest.h b/src/Tests/PadNoteTest.h
@@ -71,7 +71,7 @@ class PadNoteTest:public CxxTest::TestSuite
fft = new FFTwrapper(synth->oscilsize);
//prepare the default settings
- PADnoteParameters *defaultPreset = new PADnoteParameters(fft,NULL);
+ PADnoteParameters *defaultPreset = new PADnoteParameters(fft);
//Assert defaults
@@ -92,7 +92,7 @@ class PadNoteTest:public CxxTest::TestSuite
//defaultPreset->defaults();
- defaultPreset->applyparameters(false);
+ defaultPreset->applyparameters();
//verify xml was loaded
///TS_ASSERT(defaultPreset->VoicePar[1].Enabled);
@@ -151,7 +151,7 @@ class PadNoteTest:public CxxTest::TestSuite
#endif
sampleCount += synth->buffersize;
- TS_ASSERT_DELTA(outL[255], 0.0660f, 0.0001f);
+ TS_ASSERT_DELTA(outL[255], 0.0660f, 0.0005f);
note->relasekey();
@@ -159,7 +159,7 @@ class PadNoteTest:public CxxTest::TestSuite
note->noteout(outL, outR);
sampleCount += synth->buffersize;
- TS_ASSERT_DELTA(outL[255], -0.0729f, 0.0001f);
+ TS_ASSERT_DELTA(outL[255], -0.0729f, 0.0005f);
note->noteout(outL, outR);
sampleCount += synth->buffersize;
diff --git a/src/UI/ADnoteUI.fl b/src/UI/ADnoteUI.fl
@@ -1,175 +1,202 @@
# data file for the Fltk User Interface Designer (fluid)
-version 1.0110
+version 1.0302
header_name {.h}
code_name {.cc}
-decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {}
+decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {private local
+}
+
+decl {//License: GNU GPL version 2 or later} {private local
+}
+
+decl {\#include "../Params/ADnoteParameters.h"} {public local
+}
+
+decl {\#include "../Misc/Util.h"} {public local
+}
+
+decl {\#include "ResonanceUI.h"} {public local
+}
-decl {//License: GNU GPL version 2 or later} {}
+decl {\#include "Fl_Osc_Slider.H"} {public local
+}
-decl {\#include "../Params/ADnoteParameters.h"} {public
+decl {\#include <FL/Fl_Box.H>} {public local
}
-decl {\#include "../Misc/Util.h"} {public
+decl {\#include <FL/Fl_Group.H>} {public local
}
-decl {\#include "../Misc/Master.h"} {public
+decl {\#include <math.h>} {private local
}
-decl {\#include "ResonanceUI.h"} {public
+decl {\#include <stdio.h>} {private local
}
-decl {\#include <FL/Fl_Box.H>} {public
+decl {\#include <stdlib.h>} {private local
}
-decl {\#include <FL/Fl_Group.H>} {public
+decl {\#include <string.h>} {private local
}
-decl {\#include <math.h>} {}
+decl {\#include "Fl_Osc_Pane.H"} {public local
+}
-decl {\#include <stdio.h>} {}
+decl {\#include "Fl_Osc_Dial.H"} {public local
+}
-decl {\#include <stdlib.h>} {}
+decl {\#include "Fl_Osc_Check.H"} {public local
+}
-decl {\#include <string.h>} {}
+decl {\#include "Fl_Osc_Choice.H"} {public local
+}
+
+decl {\#include "Fl_Osc_Slider.H"} {public local
+}
+
+decl {\#include "Fl_Osc_VSlider.H"} {public local
+}
-decl {\#include "WidgetPDial.h"} {public
+decl {\#include "Fl_Oscilloscope.h"} {public local
}
-decl {\#include "EnvelopeUI.h"} {public
+decl {\#include "EnvelopeUI.h"} {public local
}
-decl {\#include "LFOUI.h"} {public
+decl {\#include "LFOUI.h"} {public local
}
-decl {\#include "FilterUI.h"} {public
+decl {\#include "FilterUI.h"} {public local
}
-decl {\#include "OscilGenUI.h"} {public
+decl {\#include "OscilGenUI.h"} {public local
}
-decl {\#include "PresetsUI.h"} {public
+decl {\#include "PresetsUI.h"} {public local
}
-class ADvoicelistitem {open : {public Fl_Group}
+class ADvoicelistitem {open : {public Fl_Osc_Group}
} {
Function {make_window()} {open private
} {
Fl_Window ADnoteVoiceListItem {open
- private xywh {262 736 615 100} type Double box UP_FRAME
- class Fl_Group visible
+ private xywh {346 881 615 100} type Double box UP_FRAME
+ class Fl_Osc_Group visible
} {
- Fl_Group voicelistitemgroup {
+ Fl_Box {} {
+ xywh {0 0 0 0}
+ code0 {ADnoteVoiceListItem->base = loc;}
+ }
+ Fl_Group voicelistitemgroup {open
private xywh {50 0 570 25}
- code0 {if (pars->VoicePar[nvoice].Enabled==0) o->deactivate();}
+ class Fl_Osc_Group
} {
Fl_Value_Slider voicevolume {
- callback {pars->VoicePar[nvoice].PVolume=(int)o->value();}
tooltip Volume xywh {90 5 115 20} type {Horz Knob} box NO_BOX labelsize 8 align 5 maximum 127 step 1
- code0 {o->value(pars->VoicePar[nvoice].PVolume);}
+ code1 {o->init("PVolume");}
+ class Fl_Osc_VSlider
}
Fl_Check_Button voiceresonanceenabled {
- callback {pars->VoicePar[nvoice].Presonance=(int)o->value();}
tooltip {Resonance On/Off} xywh {245 7 15 17} down_box DOWN_BOX labeltype EMBOSSED_LABEL labelfont 1 labelsize 11 align 4
- code0 {o->value(pars->VoicePar[nvoice].Presonance);}
+ code0 {o->init("Presonance");}
+ class Fl_Osc_Check
}
Fl_Value_Slider voicelfofreq {
- callback {pars->VoicePar[nvoice].FreqLfo->Pintensity=(int)o->value();}
tooltip {Frequency LFO amount} xywh {500 5 115 20} type {Horz Knob} box NO_BOX labelsize 8 align 5 maximum 127 step 1
- code0 {o->value(pars->VoicePar[nvoice].FreqLfo->Pintensity);}
+ code0 {o->init("FreqLfo/Pintensity");}
+ class Fl_Osc_Slider
}
Fl_Dial voicepanning {
- callback {pars->VoicePar[nvoice].PPanning=(int) o->value();}
tooltip {Panning (leftmost is Random)} xywh {215 5 20 20} box ROUND_UP_BOX labelsize 10 align 4 maximum 127 step 1
- code0 {o->value(pars->VoicePar[nvoice].PPanning);}
- class WidgetPDial
+ code0 {o->init("PPanning");}
+ class Fl_Osc_Dial
}
Fl_Group voiceoscil {open
xywh {60 5 30 20} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179
- code0 {osc=new Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");}
- code1 {osc->init(pars->VoicePar[nvoice].OscilSmp,0,pars->VoicePar[nvoice].Poscilphase,master);}
- code2 {if (pars->VoicePar[nvoice].Pextoscil != -1) {osc->init(pars->VoicePar[pars->VoicePar[nvoice].Pextoscil].OscilSmp,master);}}
+ code0 {voiceoscil->ext = "oscil/";}
+ code1 {oscil=new Fl_Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");}
+ code2 {oscil->init(false);}
+ class Fl_Osc_Group
} {}
Fl_Value_Output detunevalueoutput {
- callback {o->value(getdetune((pars->VoicePar[nvoice].PDetuneType==0)?(pars->GlobalPar.PDetuneType) : (pars->VoicePar[nvoice].PDetuneType),0,pars->VoicePar[nvoice].PDetune)*pars->getBandwidthDetuneMultiplier());}
+ callback {/*o->value(getdetune((pars->VoicePar[nvoice].PDetuneType==0)?(pars->GlobalPar.PDetuneType) : (pars->VoicePar[nvoice].PDetuneType),0,pars->VoicePar[nvoice].PDetune)*pars->getBandwidthDetuneMultiplier());*/}
xywh {265 5 45 20} labelsize 10 align 5 minimum -5000 maximum 5000 step 0.01 textfont 1 textsize 10
- code0 {o->value(getdetune(pars->VoicePar[nvoice].PDetuneType,0,pars->VoicePar[nvoice].PDetune)*pars->getBandwidthDetuneMultiplier());}
+ code0 {/*o->value(getdetune(pars->VoicePar[nvoice].PDetuneType,0,pars->VoicePar[nvoice].PDetune)*pars->getBandwidthDetuneMultiplier());*/}
}
Fl_Slider voicedetune {
- callback {pars->VoicePar[nvoice].PDetune=(int)o->value()+8192;
-detunevalueoutput->do_callback();}
+ callback {//detunevalueoutput->do_callback();}
tooltip {Fine Detune (cents)} xywh {315 5 185 20} type {Horz Knob} box NO_BOX minimum -8192 maximum 8191 step 1
- code0 {o->value(pars->VoicePar[nvoice].PDetune-8192);}
+ code0 {o->init("PDetune",'i');}
+ class Fl_Osc_Slider
}
Fl_Box noiselabel {
label N
- callback {if (pars->VoicePar[nvoice].Type==0) {
- o->hide();
+ xywh {65 5 20 20} labelfont 1 labelsize 13 labelcolor 7
+ }
+ Fl_Check_Button noisehack {
+ callback {if (o->value()==0) {
+ noiselabel->hide();
voiceresonanceenabled->activate();
detunevalueoutput->activate();
voicedetune->activate();
voicelfofreq->activate();
voiceoscil->activate();
} else {
- o->show();
+ noiselabel->show();
voiceresonanceenabled->deactivate();
detunevalueoutput->deactivate();
voicedetune->deactivate();
voicelfofreq->deactivate();
voiceoscil->deactivate();
};}
- xywh {65 5 20 20} labelfont 1 labelsize 13 labelcolor 53
- code0 {if (pars->VoicePar[nvoice].Type==0) o->hide();}
+ xywh {0 0 0 0} down_box DOWN_BOX
+ code0 {o->init("Type");o->hide();}
+ class Fl_Osc_Check
}
}
Fl_Check_Button voiceenabled {
label 01
- callback {pars->VoicePar[nvoice].Enabled=(int)o->value();
-if (o->value()==0) voicelistitemgroup->deactivate();
+ callback {if (o->value()==0) voicelistitemgroup->deactivate();
else voicelistitemgroup->activate();
o->redraw();}
private xywh {30 5 20 20} down_box DOWN_BOX labeltype EMBOSSED_LABEL labelfont 1 labelsize 13 align 4
code0 {char tmp[10];snprintf(tmp,10,"%d",nvoice+1);o->label(strdup(tmp));}
- code1 {o->value(pars->VoicePar[nvoice].Enabled);}
+ code1 {o->init("Enabled");}
+ class Fl_Osc_Check
}
}
}
- Function {ADvoicelistitem(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
- code {nvoice=0;
-pars=NULL;} {}
+ 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);
+ nvoice=0;} {}
}
- Function {init(ADnoteParameters *parameters,int nvoice_,Master *master_)} {} {
- code {pars=parameters;
+ Function {init(int nvoice_, std::string loc_, Fl_Osc_Interface *osc_)} {open
+ } {
+ code {assert(osc_);
+assert(!loc_.empty());
+
nvoice=nvoice_;
-master=master_;
+loc = loc_;
make_window();
ADnoteVoiceListItem->show();
end();} {}
}
- Function {refreshlist()} {} {
- code {voiceenabled->value(pars->VoicePar[nvoice].Enabled);
-voiceresonanceenabled->value(pars->VoicePar[nvoice].Presonance);
-voicevolume->value(pars->VoicePar[nvoice].PVolume);
-voicedetune->value(pars->VoicePar[nvoice].PDetune-8192);
-voicepanning->value(pars->VoicePar[nvoice].PPanning);
-voicelfofreq->value(pars->VoicePar[nvoice].FreqLfo->Pintensity);
-if (pars->VoicePar[nvoice].Pextoscil != -1) {
- osc->init(pars->VoicePar[pars->VoicePar[nvoice].Pextoscil].OscilSmp,0,pars->VoicePar[nvoice].Poscilphase,master);
-} else
- osc->init(pars->VoicePar[nvoice].OscilSmp,0,pars->VoicePar[nvoice].Poscilphase,master);
-if (pars->VoicePar[nvoice].Enabled==0) voicelistitemgroup->deactivate();
+ Function {refreshlist()} {open
+ } {
+ code {if (voiceenabled->value()==0) voicelistitemgroup->deactivate();
else voicelistitemgroup->activate();
detunevalueoutput->do_callback();
-noiselabel->do_callback();
ADnoteVoiceListItem->redraw();} {}
}
Function {~ADvoicelistitem()} {} {
- code {ADnoteVoiceListItem->hide();
-//delete(ADnoteVoiceListItem);} {}
+ code {ADnoteVoiceListItem->hide();} {}
+ }
+ decl {int nvoice;} {private local
+ }
+ decl {Fl_Oscilloscope *oscil;} {private local
+ }
+ decl {std::string loc;} {private local
}
- decl {ADnoteParameters *pars;} {}
- decl {int nvoice;} {}
- decl {Oscilloscope *osc;} {}
- decl {Master *master;} {}
}
class ADvoiceUI {open : {public Fl_Group}
@@ -178,12 +205,17 @@ class ADvoiceUI {open : {public Fl_Group}
} {
Fl_Window ADnoteVoiceParameters {
label Voice open
- xywh {863 89 765 595} type Double box NO_BOX
- class Fl_Group visible
+ xywh {512 391 765 595} type Double box NO_BOX
+ class Fl_Osc_Group visible
} {
+ Fl_Box {} {
+ label label
+ xywh {25 25 35 16}
+ code0 {ADnoteVoiceParameters->base = base+"voice"+to_s(nvoice)+"/";}
+ code1 {ADnoteVoiceParameters->osc = osc_i;}
+ }
Fl_Group voiceparametersgroup {open
xywh {0 0 770 590} color 48
- code0 {if (pars->VoicePar[nvoice].Enabled==0) o->deactivate();}
} {
Fl_Group voicemodegroup {open
xywh {0 5 770 585} color 64
@@ -191,7 +223,6 @@ class ADvoiceUI {open : {public Fl_Group}
Fl_Group voiceFMparametersgroup {
label MODULATOR open
xywh {530 5 230 580} box UP_FRAME color 48 labeltype EMBOSSED_LABEL labelfont 1 labelsize 13 align 17
- code0 {if (pars->VoicePar[nvoice].PFMEnabled==0) o->deactivate();}
} {
Fl_Group modfrequency {
label {Mod.FREQUENCY}
@@ -200,62 +231,51 @@ class ADvoiceUI {open : {public Fl_Group}
Fl_Group voiceFMfreqenvgroup {
label {ADSynth Modulator - Frequency Envelope}
xywh {540 300 210 70} box FLAT_BOX color 51 align 144
- code0 {o->init(pars->VoicePar[nvoice].FMFreqEnvelope);}
- code1 {if (pars->VoicePar[nvoice].PFMFreqEnvelopeEnabled==0) o->deactivate();}
+ code0 {o->init(ENV_ASR, osc_i, loc, "FMFreqEnvelope/");}
class EnvelopeUI
} {}
Fl_Check_Button {} {
label On
- callback {pars->VoicePar[nvoice].PFMFreqEnvelopeEnabled=(int)o->value();
-if (o->value()==0) voiceFMfreqenvgroup->deactivate();
+ callback {if (o->value()==0) voiceFMfreqenvgroup->deactivate();
else voiceFMfreqenvgroup->activate();
o->redraw();}
tooltip {Forced Relase} xywh {545 305 50 10} down_box DOWN_BOX labelfont 1 labelsize 11
- code0 {o->value(pars->VoicePar[nvoice].PFMFreqEnvelopeEnabled);}
+ code0 {o->init("PFMFreqEnvelopeEnabled");}
+ class Fl_Osc_Check
}
Fl_Counter {} {
label {Coarse Det.}
- callback {int k=(int) o->value();
-if (k<0) k+=1024;
-pars->VoicePar[nvoice].PFMCoarseDetune = k+
- (pars->VoicePar[nvoice].PFMCoarseDetune/1024)*1024;}
tooltip {Coarse Detune} xywh {685 280 60 15} labelsize 10 align 1 minimum -64 maximum 63 step 1 textfont 1 textsize 11
- code0 {int k=pars->VoicePar[nvoice].PFMCoarseDetune%1024;}
- code1 {if (k>=512) k-=1024;}
- code2 {o->value(k);}
+ code0 {o->init("FMcoarsedetune");}
code3 {o->lstep(10);}
+ class Fl_Osc_Counter
}
Fl_Counter {} {
label Octave
- callback {int k=(int) o->value();
-if (k<0) k+=16;
-pars->VoicePar[nvoice].PFMCoarseDetune = k*1024+
- pars->VoicePar[nvoice].PFMCoarseDetune%1024;}
tooltip Octave xywh {625 280 45 15} type Simple labelsize 10 align 1 minimum -8 maximum 7 step 1 textfont 1 textsize 11
- code0 {int k=pars->VoicePar[nvoice].PFMCoarseDetune/1024;}
- code1 {if (k>=8) k-=16;}
- code2 {o->value(k);}
+ code0 {o->init("FMoctave");}
+ class Fl_Osc_Counter
}
Fl_Slider {} {
- callback {pars->VoicePar[nvoice].PFMDetune=(int)o->value()+8192;
-fmdetunevalueoutput->do_callback();}
+ callback {o->oscWrite("detunevalue");}
tooltip {Fine Detune (cents)} xywh {590 245 155 15} type {Horz Knob} box NO_BOX minimum -8192 maximum 8191 step 1
- code0 {o->value(pars->VoicePar[nvoice].PFMDetune-8192);}
+ code0 {o->init("PFMDetune", 'i');}
+ class Fl_Osc_Slider
}
Fl_Value_Output fmdetunevalueoutput {
label Detune
- callback {o->value(getdetune((pars->VoicePar[nvoice].PFMDetuneType==0)?(pars->GlobalPar.PDetuneType) : (pars->VoicePar[nvoice].PFMDetuneType),0,pars->VoicePar[nvoice].PFMDetune));}
+ callback {//o->value(getdetune((pars->VoicePar[nvoice].PFMDetuneType==0)?(pars->GlobalPar.PDetuneType) : (pars->VoicePar[nvoice].PFMDetuneType),0,pars->VoicePar[nvoice].PFMDetune));}
xywh {540 245 45 18} labelsize 8 align 5 minimum -5000 maximum 5000 step 0.01 textfont 1 textsize 8
- code0 {o->value(getdetune((pars->VoicePar[nvoice].PFMDetuneType==0)?(pars->GlobalPar.PDetuneType) : (pars->VoicePar[nvoice].PFMDetuneType),0,pars->VoicePar[nvoice].PFMDetune));}
- code1 {//o->value(getdetune(pars->VoicePar[nvoice].PFMDetuneType,0,pars->VoicePar[nvoice].PFMDetune));}
+ code0 {o->init("FMdetunevalue");}
+ class Fl_Osc_Output
}
Fl_Choice {} {
label {Detune Type}
- callback {pars->VoicePar[nvoice].PFMDetuneType=(int) o->value();
-fmdetunevalueoutput->do_callback();} open
+ callback {fmdetunevalueoutput->do_callback();} open
xywh {540 280 75 15} down_box BORDER_BOX labelsize 10 align 5 textfont 1 textsize 10
code0 {o->add("Default");o->add("L35cents");o->add("L10cents");o->add("E100cents");o->add("E1200cents");}
- code1 {o->value(pars->VoicePar[nvoice].PFMDetuneType);}
+ code1 {o->init("PFMDetuneType");}
+ class Fl_Osc_Choice
} {}
}
Fl_Group {} {
@@ -264,37 +284,37 @@ fmdetunevalueoutput->do_callback();} open
} {
Fl_Value_Slider {} {
label Vol
- callback {pars->VoicePar[nvoice].PFMVolume=(int)o->value();}
tooltip Volume xywh {540 80 160 15} type {Horz Knob} box NO_BOX labelsize 11 align 8 maximum 127 step 1
- code0 {o->value(pars->VoicePar[nvoice].PFMVolume);}
+ code0 {o->init("PFMVolume", 'c');}
+ class Fl_Osc_Slider
}
Fl_Value_Slider {} {
label {V.Sns}
- callback {pars->VoicePar[nvoice].PFMVelocityScaleFunction=(int) o->value();}
tooltip {Velocity Sensing Function (rightmost to disable)} xywh {540 100 160 15} type {Horz Knob} box NO_BOX labelsize 11 align 8 maximum 127 step 1
- code0 {o->value(pars->VoicePar[nvoice].PFMVelocityScaleFunction);}
+ code0 {o->init("PFMVelocityScaleFunction");}
+ class Fl_Osc_VSlider
}
Fl_Group voiceFMampenvgroup {
label {ADSynth Modulator - Amplitude Envelope} open
xywh {540 145 205 70} box FLAT_BOX color 51 align 144
- code0 {o->init(pars->VoicePar[nvoice].FMAmpEnvelope);}
- code1 {if (pars->VoicePar[nvoice].PFMAmpEnvelopeEnabled==0) o->deactivate();}
+ code0 {o->init(//pars->VoicePar[nvoice].FMAmpEnvelope,
+ ENV_ADSR, osc_i, loc, "FMAmpEnvelope/");}
class EnvelopeUI
} {}
Fl_Check_Button {} {
label On
- callback {pars->VoicePar[nvoice].PFMAmpEnvelopeEnabled=(int)o->value();
-if (o->value()==0) voiceFMampenvgroup->deactivate();
+ callback {if (o->value()==0) voiceFMampenvgroup->deactivate();
else voiceFMampenvgroup->activate();
o->redraw();}
tooltip {Forced Relase} xywh {545 150 50 10} down_box DOWN_BOX labelfont 1 labelsize 11
- code0 {o->value(pars->VoicePar[nvoice].PFMAmpEnvelopeEnabled);}
+ code0 {o->init("PFMAmpEnvelopeEnabled");}
+ class Fl_Osc_Check
}
Fl_Value_Slider {} {
label {F.Damp}
- callback {pars->VoicePar[nvoice].PFMVolumeDamp=(int) o->value()+64;}
tooltip {Modulator Damp at Higher frequency} xywh {540 120 160 15} type {Horz Knob} box NO_BOX labelsize 11 align 8 minimum -64 maximum 63 step 1
- code0 {o->value(pars->VoicePar[nvoice].PFMVolumeDamp-64);}
+ code0 {o->init("PFMVolumeDamp",'c');}
+ class Fl_Osc_Slider
}
}
Fl_Group modoscil {open
@@ -302,9 +322,11 @@ o->redraw();}
} {
Fl_Group fmoscil {open
xywh {535 440 220 140} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179
- code0 {oscFM=new Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");}
- code1 {int nv=nvoice; if (pars->VoicePar[nvoice].PextFMoscil>=0) nv=pars->VoicePar[nvoice].PextFMoscil;}
- code2 {oscFM->init(pars->VoicePar[nv].FMSmp,0,pars->VoicePar[nvoice].PFMoscilphase,master);}
+ code0 {fmoscil->base = loc; fmoscil->ext="mod-oscil/";fmoscil->osc = osc_i;fmoscil->begin();}
+ code1 {oscFM=new Fl_Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");}
+ code2 {//int nv=nvoice; if (pars->VoicePar[nvoice].PextFMoscil>=0) nv=pars->VoicePar[nvoice].PextFMoscil;}
+ code3 {oscFM->parent(fmoscil);oscFM->init(false);oscFM->update();fmoscil->end();}
+ class Fl_Osc_Group
} {}
Fl_Box {} {
label {Mod.Oscillator}
@@ -312,44 +334,45 @@ o->redraw();}
}
Fl_Button changeFMoscilbutton {
label Change
- callback {if (oscedit!=NULL) delete(oscedit);
+ callback {if (oscedit!=NULL)
+ delete(oscedit);
int nv=nvoice;
-if (pars->VoicePar[nvoice].PextFMoscil>=0) nv=pars->VoicePar[nvoice].PextFMoscil;
+if (extFMoscil->value()>=0)
+ nv=extFMoscil->value();
-oscedit=new OscilEditor(pars->VoicePar[nv].FMSmp,fmoscil,NULL,NULL,master);}
+oscedit=new OscilEditor(true, loc+"mod-oscil/", osc_i);}
xywh {700 380 55 15} box THIN_UP_BOX labelfont 1 labelsize 11
- code0 {if (pars->VoicePar[nvoice].PextFMoscil>=0) o->labelcolor(FL_BLUE);}
+ code0 {/*if (extFMoscil->value()>=0) o->labelcolor(FL_BLUE);*/}
}
Fl_Slider {} {
label Phase
- callback {pars->VoicePar[nvoice].PFMoscilphase=64-(int)o->value();
-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->value(64-pars->VoicePar[nvoice].PFMoscilphase);}
+ code0 {o->init("PFMoscilphase", 'c');}
+ class Fl_Osc_Slider
}
- Fl_Choice {} {
+ Fl_Choice extFMoscil {
label Use
- callback {pars->VoicePar[nvoice].PextFMoscil=(int)o->value()-1;
-if ((int) o->value() != 0) {
- oscFM->init(pars->VoicePar[(int) o->value()-1].FMSmp,master);
+ callback {if ((int) o->value() != 0) {
+ oscFM->init(false);
changeFMoscilbutton->labelcolor(FL_BLUE);
} else {
- oscFM->init(pars->VoicePar[nvoice].FMSmp,master);
+ oscFM->init(false);
changeFMoscilbutton->labelcolor(FL_BLACK);
};
voiceFMparametersgroup->redraw();} open
xywh {560 410 75 20} down_box BORDER_BOX labelsize 10 textfont 1 textsize 10
code0 {o->add("Internal");}
code1 {char tmp[50]; for (int i=0;i<nvoice;i++) {sprintf(tmp,"ExtM.%2d",i+1);o->add(tmp);};}
- code3 {o->value(pars->VoicePar[nvoice].PextFMoscil+1);}
+ code3 {o->init("PextFMoscil",1);}
+ class Fl_Osc_Choice
} {}
}
Fl_Choice {} {
label {External Mod.}
- callback {pars->VoicePar[nvoice].PFMVoice=(int)o->value()-1;
-if ((int) o->value() != 0) {
+ callback {if ((int) o->value() != 0) {
modoscil->deactivate();
modfrequency->deactivate();
} else {
@@ -360,18 +383,19 @@ voiceFMparametersgroup->redraw();} open
xywh {635 40 85 20} down_box BORDER_BOX labelsize 10 align 5 textfont 1 textsize 10
code0 {o->add("OFF");}
code1 {char tmp[50]; for (int i=0;i<nvoice;i++) {sprintf(tmp,"ExtMod.%2d",i+1);o->add(tmp);};}
- code2 {o->value(pars->VoicePar[nvoice].PFMVoice+1);}
+ code2 {o->init("PFMVoice",-1);}
code3 {if ((int) o->value() != 0) {modoscil->deactivate();modfrequency->deactivate();}}
+ class Fl_Osc_Choice
} {}
}
Fl_Choice {} {
label {Type:}
- callback {pars->VoicePar[nvoice].PFMEnabled=(int)o->value();
-if (o->value()==0) voiceFMparametersgroup->deactivate();
+ callback {if (o->value()==0) voiceFMparametersgroup->deactivate();
else voiceFMparametersgroup->activate();
o->redraw();}
xywh {535 40 80 20} down_box BORDER_BOX align 5
- code0 {o->value(pars->VoicePar[nvoice].PFMEnabled);}
+ code0 {o->init("PFMEnabled");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label OFF
@@ -399,118 +423,105 @@ o->redraw();}
}
}
Fl_Group {} {
- label FREQUENCY
+ label FREQUENCY open
xywh {5 265 525 120} box UP_FRAME labeltype EMBOSSED_LABEL labelfont 1 labelsize 13 align 17
} {
Fl_Group voicefreqenvgroup {
label {ADSynth Voice - Frequency Envelope} open
xywh {10 305 205 70} box FLAT_BOX color 51 align 144
- code0 {o->init(pars->VoicePar[nvoice].FreqEnvelope);}
- code1 {if (pars->VoicePar[nvoice].PFreqEnvelopeEnabled==0) o->deactivate();}
+ code0 {o->init(//pars->VoicePar[nvoice].FreqEnvelope,
+ ENV_ASR, osc_i, loc, "FreqEnvelope/");}
class EnvelopeUI
} {}
Fl_Check_Button {} {
label On
- callback {pars->VoicePar[nvoice].PFreqEnvelopeEnabled=(int)o->value();
-if (o->value()==0) voicefreqenvgroup->deactivate();
+ callback {if (o->value()==0) voicefreqenvgroup->deactivate();
else voicefreqenvgroup->activate();
o->redraw();}
tooltip {Forced Relase} xywh {15 310 50 10} down_box DOWN_BOX labelfont 1 labelsize 11
- code0 {o->value(pars->VoicePar[nvoice].PFreqEnvelopeEnabled);}
+ code0 {o->init("PFreqEnvelopeEnabled");}
+ class Fl_Osc_Check
}
Fl_Group voicefreqlfogroup {
label {Frequency LFO } open
xywh {220 305 230 70} box FLAT_BOX color 47 align 144
- code0 {o->init(pars->VoicePar[nvoice].FreqLfo);}
- code1 {if (pars->VoicePar[nvoice].PFreqLfoEnabled==0) o->deactivate();}
+ code0 {o->init(osc_i, loc,"FreqLfo/");}
class LFOUI
} {}
Fl_Check_Button {} {
label On
- callback {pars->VoicePar[nvoice].PFreqLfoEnabled=(int)o->value();
-if (o->value()==0) voicefreqlfogroup->deactivate();
+ callback {if (o->value()==0) voicefreqlfogroup->deactivate();
else voicefreqlfogroup->activate();
o->redraw();}
tooltip {Forced Relase} xywh {225 311 55 10} down_box DOWN_BOX labelfont 1 labelsize 11
- code0 {o->value(pars->VoicePar[nvoice].PFreqLfoEnabled);}
+ code0 {o->init("PFreqLfoEnabled");}
+ class Fl_Osc_Check
}
Fl_Counter {} {
label Octave
- callback {int k=(int) o->value();
-if (k<0) k+=16;
-pars->VoicePar[nvoice].PCoarseDetune = k*1024+
- pars->VoicePar[nvoice].PCoarseDetune%1024;}
tooltip Octave xywh {470 285 45 15} type Simple labelsize 10 align 1 minimum -8 maximum 7 step 1 textfont 1 textsize 11
- code0 {int k=pars->VoicePar[nvoice].PCoarseDetune/1024;}
- code1 {if (k>=8) k-=16;}
- code2 {o->value(k);}
+ code0 {o->init("octave");}
+ class Fl_Osc_Counter
}
Fl_Counter {} {
label {Coarse Det.}
- callback {int k=(int) o->value();
-if (k<0) k+=1024;
-pars->VoicePar[nvoice].PCoarseDetune = k+
- (pars->VoicePar[nvoice].PCoarseDetune/1024)*1024;}
tooltip {Coarse Detune} xywh {455 355 60 20} labelsize 10 align 1 minimum -64 maximum 63 step 1 textfont 1 textsize 11
- code0 {int k=pars->VoicePar[nvoice].PCoarseDetune%1024;}
- code1 {if (k>=512) k-=1024;}
- code2 {o->value(k);}
+ code0 {o->init("coarsedetune");}
code3 {o->lstep(10);}
+ class Fl_Osc_Counter
}
Fl_Slider {} {
- callback {pars->VoicePar[nvoice].PDetune=(int)o->value()+8192;
-detunevalueoutput->do_callback();}
+ callback {detunevalueoutput->do_callback();}
tooltip {Fine Detune (cents)} xywh {58 287 392 13} type {Horz Knob} box NO_BOX minimum -8192 maximum 8191 step 1
- code0 {o->value(pars->VoicePar[nvoice].PDetune-8192);}
+ code0 {o->init("PDetune", 'i');}
+ class Fl_Osc_Slider
}
Fl_Value_Output detunevalueoutput {
label Detune
- callback {o->value(getdetune((pars->VoicePar[nvoice].PDetuneType==0)?(pars->GlobalPar.PDetuneType) : (pars->VoicePar[nvoice].PDetuneType),0,pars->VoicePar[nvoice].PDetune)*pars->getBandwidthDetuneMultiplier());}
+ callback {//o->value(getdetune((pars->VoicePar[nvoice].PDetuneType==0)?(pars->GlobalPar.PDetuneType) : (pars->VoicePar[nvoice].PDetuneType),0,pars->VoicePar[nvoice].PDetune)*pars->getBandwidthDetuneMultiplier());}
xywh {10 287 45 15} labelsize 10 align 5 minimum -5000 maximum 5000 step 0.01 textfont 1 textsize 10
- code0 {o->value(getdetune((pars->VoicePar[nvoice].PDetuneType==0)?(pars->GlobalPar.PDetuneType) : (pars->VoicePar[nvoice].PDetuneType),0,pars->VoicePar[nvoice].PDetune)*pars->getBandwidthDetuneMultiplier());}
}
Fl_Check_Button {} {
label 440Hz
- callback {int x=(int) o->value();
-pars->VoicePar[nvoice].Pfixedfreq=x;
-if (x==0) fixedfreqetdial->deactivate();
+ callback {if (o->value()==0) fixedfreqetdial->deactivate();
else fixedfreqetdial->activate();}
tooltip {Set the voice base frequency to 440Hz} xywh {345 268 55 15} down_box DOWN_BOX labelfont 1 labelsize 11
- code0 {o->value(pars->VoicePar[nvoice].Pfixedfreq);}
+ code0 {o->init("Pfixedfreq");}
+ class Fl_Osc_Check
}
Fl_Dial fixedfreqetdial {
label {Eq.T.}
- callback {pars->VoicePar[nvoice].PfixedfreqET=(int) o->value();}
tooltip {How the frequency varies acording to the keyboard (leftmost for fixed frequency)} xywh {405 270 15 15} box ROUND_UP_BOX labelsize 10 align 8 maximum 127 step 1
- code0 {o->value(pars->VoicePar[nvoice].PfixedfreqET);}
- code1 {if (pars->VoicePar[nvoice].Pfixedfreq==0) o->deactivate();}
- class WidgetPDial
+ code0 {o->init("PfixedfreqET");}
+ class Fl_Osc_Dial
}
Fl_Choice {} {
label {Detune Type}
- callback {pars->VoicePar[nvoice].PDetuneType=(int) o->value();
-detunevalueoutput->do_callback();} open
+ callback {detunevalueoutput->do_callback();} open
xywh {455 320 70 15} down_box BORDER_BOX labelsize 10 align 5 textfont 1 textsize 10
code0 {o->add("Default");o->add("L35cents");o->add("L10cents");o->add("E100cents");o->add("E1200cents");}
- code1 {o->value(pars->VoicePar[nvoice].PDetuneType);}
+ code1 {o->init("PDetuneType");}
+ class Fl_Osc_Choice
} {}
}
Fl_Group voiceoscil {
xywh {80 390 445 145} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179
- code0 {osc=new Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");}
- code1 {int nv=nvoice; if (pars->VoicePar[nvoice].Pextoscil>=0) nv=pars->VoicePar[nvoice].Pextoscil;}
- code2 {osc->init(pars->VoicePar[nv].OscilSmp,0,pars->VoicePar[nvoice].Poscilphase,master);}
+ code0 {voiceoscil->base = loc;voiceoscil->ext="oscil/";voiceoscil->begin();//int nv=nvoice; if (extoscil->value()>=0) nv=extoscil->value();}
+ code1 {osc=new Fl_Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");}
+ code2 {voiceoscil->osc = osc_i;}
+ code3 {osc->parent(voiceoscil); osc->init(false);voiceoscil->end();}
+ class Fl_Osc_Group
} {}
Fl_Button changevoiceoscilbutton {
label Change
- callback {if (oscedit!=NULL) delete(oscedit);
-
-int nv=nvoice;
-if (pars->VoicePar[nvoice].Pextoscil>=0) nv=pars->VoicePar[nvoice].Pextoscil;
+ callback {delete oscedit;
+ int nv=nvoice;
+ if(extoscil->value()>=0)
+ nv=extoscil->value();
-oscedit=new OscilEditor(pars->VoicePar[nv].OscilSmp,voiceoscil,NULL,NULL,master);}
+ oscedit=new OscilEditor(true,loc+"oscil/", osc_i);}
xywh {5 490 65 20} box THIN_UP_BOX labelfont 1 labelsize 11
- code0 {if (pars->VoicePar[nvoice].Pextoscil>=0) o->labelcolor(FL_BLUE);}
+ code0 {/*if (extoscil->value()>=0) o->labelcolor(FL_BLUE);*/}
}
Fl_Box {} {
label {Voice Oscillator}
@@ -518,26 +529,25 @@ oscedit=new OscilEditor(pars->VoicePar[nv].OscilSmp,voiceoscil,NULL,NULL,master)
}
Fl_Slider {} {
label Phase
- callback {pars->VoicePar[nvoice].Poscilphase=64-(int)o->value();
-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->value(64-pars->VoicePar[nvoice].Poscilphase);}
+ code0 {o->init("Poscilphase", 'c');}
+ class Fl_Osc_Slider
}
Fl_Check_Button {} {
label {R.}
- callback {pars->VoicePar[nvoice].Presonance=(int) o->value();}
tooltip {Resonance On/Off} xywh {210 5 35 35} box THIN_UP_BOX down_box DOWN_BOX labelfont 1 labelsize 11
- code0 {o->value(pars->VoicePar[nvoice].Presonance);}
+ code0 {o->init("Presonance");}
+ class Fl_Osc_Check
}
- Fl_Choice {} {
+ Fl_Choice extoscil {
label {Use Oscil.}
- callback {pars->VoicePar[nvoice].Pextoscil=(int)o->value()-1;
-if ((int) o->value() != 0) {
- osc->init(pars->VoicePar[(int) o->value()-1].OscilSmp,master);
+ callback {if ((int) o->value() != 0) {
+ osc->init(false);
changevoiceoscilbutton->labelcolor(FL_BLUE);
} else {
- osc->init(pars->VoicePar[nvoice].OscilSmp,master);
+ osc->init(false);
changevoiceoscilbutton->labelcolor(FL_BLACK);
};
@@ -546,58 +556,57 @@ voiceonbutton->redraw();} open
xywh {5 470 65 15} down_box BORDER_BOX labelsize 10 align 5 textfont 1 textsize 10
code0 {o->add("Internal");}
code1 {char tmp[50]; for (int i=0;i<nvoice;i++) {sprintf(tmp,"Ext.%2d",i+1);o->add(tmp);};}
- code3 {o->value(pars->VoicePar[nvoice].Pextoscil+1);}
+ code3 {o->init("Pextoscil",1);}
+ class Fl_Osc_Choice
} {}
Fl_Group {} {open
xywh {5 540 520 50} box UP_FRAME
} {
Fl_Dial {} {
label Stereo
- callback {pars->VoicePar[nvoice].Unison_stereo_spread=(int)o->value();}
tooltip {Stereo Spread} xywh {322 555 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->VoicePar[nvoice].Unison_stereo_spread);}
- class WidgetPDial
+ code0 {o->init("Unison_stereo_spread");}
+ class Fl_Osc_Dial
}
Fl_Choice {} {
label Unison
- callback {pars->set_unison_size_index(nvoice,(int) o->value());} open
+ callback {//pars->set_unison_size_index(nvoice,(int) o->value());} open
tooltip {Unison size} xywh {10 560 75 20} down_box BORDER_BOX labelfont 1 align 5 textfont 1 textsize 10
code0 {o->add("OFF");char tmp[100];for (int i=1;ADnote_unison_sizes[i];i++){snprintf(tmp,100,"size %d",ADnote_unison_sizes[i]);o->add(tmp);};}
- code1 {o->value(pars->get_unison_size_index(nvoice));}
+ code1 {o->init("Unison_size");//pars->get_unison_size_index(nvoice));}
+ class Fl_Osc_Choice
} {}
Fl_Dial {} {
label Vibrato
- callback {pars->VoicePar[nvoice].Unison_vibratto=(int)o->value();}
tooltip Vibrato xywh {364 555 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->VoicePar[nvoice].Unison_vibratto);}
- class WidgetPDial
+ code0 {o->init("Unison_vibratto");}
+ class Fl_Osc_Dial
}
Fl_Choice {} {
label Invert
- callback {pars->VoicePar[nvoice].Unison_invert_phase=(int) o->value();} open
tooltip {Phase Invert} xywh {445 560 65 15} down_box BORDER_BOX labelsize 11 align 5 textfont 1 textsize 10
code0 {o->add("None");o->add("Random");char tmp[100];for (int i=2;i<=5;i++){snprintf(tmp,100,"%d %%",100/i);o->add(tmp);};}
- code1 {o->value(pars->VoicePar[nvoice].Unison_invert_phase);}
+ code1 {o->init("Unison_invert_phase");}
+ class Fl_Osc_Choice
} {}
Fl_Slider {} {
label {Frequency Spread}
- callback {pars->VoicePar[nvoice].Unison_frequency_spread=(int)o->value();
-unisonspreadoutput->do_callback();}
+ callback {//unisonspreadoutput->do_callback();}
tooltip {Frequency Spread of the Unison} xywh {95 562 125 13} type {Horz Knob} box NO_BOX labelsize 12 align 1 maximum 127 step 1 value 64
- code0 {o->value(pars->VoicePar[nvoice].Unison_frequency_spread);}
+ code0 {o->init("Unison_frequency_spread", 'c');}
+ class Fl_Osc_Slider
}
Fl_Value_Output unisonspreadoutput {
label {(cents)}
- callback {o->value(pars->getUnisonFrequencySpreadCents(nvoice));}
xywh {225 560 40 15} labelsize 10 align 5 maximum 1000 step 0.1 textfont 1 textsize 10
- code0 {o->value(pars->getUnisonFrequencySpreadCents(nvoice));}
+ code0 {o->init("unisonFrequencySpreadCents");//o->value(pars->getUnisonFrequencySpreadCents(nvoice));}
+ class Fl_Osc_Output
}
Fl_Dial {} {
label {V.speed}
- callback {pars->VoicePar[nvoice].Unison_vibratto_speed=(int)o->value();} selected
tooltip {Vibrato Average Speed} xywh {406 555 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->VoicePar[nvoice].Unison_vibratto_speed);}
- class WidgetPDial
+ code0 {o->init("Unison_vibratto_speed");}
+ class Fl_Osc_Dial
}
Fl_Dial {} {
label {Ph.rand}
@@ -614,104 +623,100 @@ unisonspreadoutput->do_callback();}
} {
Fl_Value_Slider {} {
label Vol
- callback {pars->VoicePar[nvoice].PVolume=(int)o->value();}
tooltip Volume xywh {10 60 160 15} type {Horz Knob} box NO_BOX labelsize 11 align 8 maximum 127 step 1
- code0 {o->value(pars->VoicePar[nvoice].PVolume);}
+ code0 {o->init("PVolume");}
+ class Fl_Osc_VSlider
}
Fl_Value_Slider {} {
label {V.Sns}
- callback {pars->VoicePar[nvoice].PAmpVelocityScaleFunction=(int) o->value();}
tooltip {Velocity Sensing Function (rightmost to disable)} xywh {10 80 160 15} type {Horz Knob} box NO_BOX labelsize 11 align 8 maximum 127 step 1
- code0 {o->value(pars->VoicePar[nvoice].PAmpVelocityScaleFunction);}
+ code0 {o->init("PAmpVelocityScaleFunction");}
+ class Fl_Osc_VSlider
}
Fl_Group voiceampenvgroup {
label {ADSynth Voice - Amplitude Envelope} open
xywh {10 105 205 70} box FLAT_BOX color 51 align 144
- code0 {o->init(pars->VoicePar[nvoice].AmpEnvelope);}
- code1 {if (pars->VoicePar[nvoice].PAmpEnvelopeEnabled==0) o->deactivate();}
+ code0 {o->init(//pars->VoicePar[nvoice].AmpEnvelope,
+ ENV_ADSR, osc_i, loc, "AmpEnvelope/");}
class EnvelopeUI
} {}
Fl_Dial {} {
label Pan
- callback {pars->VoicePar[nvoice].PPanning=(int) o->value();}
tooltip {Panning (leftmost is Random)} xywh {210 60 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(pars->VoicePar[nvoice].PPanning);}
- class WidgetPDial
+ code0 {o->init("PPanning");}
+ class Fl_Osc_Dial
}
Fl_Check_Button {} {
label On
- callback {pars->VoicePar[nvoice].PAmpEnvelopeEnabled=(int)o->value();
-if (o->value()==0) voiceampenvgroup->deactivate();
+ callback {if (o->value()==0) voiceampenvgroup->deactivate();
else voiceampenvgroup->activate();
o->redraw();}
tooltip {Forced Relase} xywh {15 110 50 10} down_box DOWN_BOX labelfont 1 labelsize 11
- code0 {o->value(pars->VoicePar[nvoice].PAmpEnvelopeEnabled);}
+ code0 {o->init("PAmpEnvelopeEnabled");}
+ class Fl_Osc_Check
}
Fl_Group voiceamplfogroup {
label {Amplitude LFO } open
xywh {10 180 230 75} box FLAT_BOX color 47 align 144
- code0 {o->init(pars->VoicePar[nvoice].AmpLfo);}
- code1 {if (pars->VoicePar[nvoice].PAmpLfoEnabled==0) o->deactivate();}
+ code0 {o->init(osc_i, loc, "AmpLfo/");}
class LFOUI
} {}
Fl_Check_Button {} {
label On
- callback {pars->VoicePar[nvoice].PAmpLfoEnabled=(int)o->value();
-if (o->value()==0) voiceamplfogroup->deactivate();
+ callback {if (o->value()==0) voiceamplfogroup->deactivate();
else voiceamplfogroup->activate();
o->redraw();}
tooltip {Forced Relase} xywh {15 185 55 10} down_box DOWN_BOX labelfont 1 labelsize 11
- code0 {o->value(pars->VoicePar[nvoice].PAmpLfoEnabled);}
+ code0 {o->init("PAmpLfoEnabled");}
+ class Fl_Osc_Check
}
Fl_Check_Button {} {
label Minus
- callback {pars->VoicePar[nvoice].PVolumeminus=(int)o->value();}
xywh {10 45 50 10} down_box DOWN_BOX labelfont 1 labelsize 10
- code0 {o->value(pars->VoicePar[nvoice].PVolumeminus);}
+ code0 {o->init("PVolumeminus");}
+ class Fl_Osc_Check
}
}
Fl_Group voicefiltergroup {
label FILTER open
xywh {245 5 285 260} box UP_FRAME labeltype EMBOSSED_LABEL labelfont 1 labelsize 13 align 17
- code0 {if (pars->VoicePar[nvoice].PFilterEnabled==0) o->deactivate();}
} {
Fl_Group {} {
label {ADsynth Voice - Filter} open
xywh {250 30 275 75} box FLAT_BOX color 50 align 144
- code0 {o->init(pars->VoicePar[nvoice].VoiceFilter,NULL,NULL);}
+ code0 {o->init("", osc_i, loc, "VoiceFilter/");}
class FilterUI
} {}
Fl_Group voicefilterenvgroup {
label {ADSynth Voice - Filter Envelope} open
xywh {250 115 275 70} box FLAT_BOX color 51 align 144
- code0 {o->init(pars->VoicePar[nvoice].FilterEnvelope);}
- code1 {if (pars->VoicePar[nvoice].PFilterEnvelopeEnabled==0) o->deactivate();}
+ code0 {o->init(
+ ENV_ADSR_FILTER, osc_i, loc, "FilterEnvelope/");}
class EnvelopeUI
} {}
Fl_Check_Button {} {
label On
- callback {pars->VoicePar[nvoice].PFilterEnvelopeEnabled=(int)o->value();
-if (o->value()==0) voicefilterenvgroup->deactivate();
+ callback {if (o->value()==0) voicefilterenvgroup->deactivate();
else voicefilterenvgroup->activate();
o->redraw();}
tooltip {Forced Relase} xywh {255 119 55 10} down_box DOWN_BOX labelfont 1 labelsize 11
- code0 {o->value(pars->VoicePar[nvoice].PFilterEnvelopeEnabled);}
+ code0 {o->init("PFilterEnvelopeEnabled");}
+ class Fl_Osc_Check
}
Fl_Group voicefilterlfogroup {
label {Filter LFO } open
xywh {250 190 230 70} box FLAT_BOX color 47 align 144
- code0 {o->init(pars->VoicePar[nvoice].FilterLfo);}
- code1 {if (pars->VoicePar[nvoice].PFilterLfoEnabled==0) o->deactivate();}
+ code0 {o->init(osc_i, loc, "FilterLfo/");}
class LFOUI
} {}
Fl_Check_Button {} {
label On
- callback {pars->VoicePar[nvoice].PFilterLfoEnabled=(int)o->value();
-if (o->value()==0) voicefilterlfogroup->deactivate();
+ callback {if (o->value()==0) voicefilterlfogroup->deactivate();
else voicefilterlfogroup->activate();
o->redraw();}
tooltip {Forced Relase} xywh {255 196 55 10} down_box DOWN_BOX labelfont 1 labelsize 11
- code0 {o->value(pars->VoicePar[nvoice].PFilterLfoEnabled);}
+ code0 {o->init("PFilterLfoEnabled");}
+ class Fl_Osc_Check
}
}
Fl_Group {} {
@@ -720,14 +725,11 @@ o->redraw();}
code0 {char tmp[10];snprintf(tmp,10,"%d",nvoice+1);o->label(strdup(tmp));}
} {}
Fl_Choice {} {
- callback {int x=(int) o->value();
-pars->VoicePar[nvoice].Type=x;
-if (x==0) voicemodegroup->activate();
- else voicemodegroup->deactivate();
-noiselabel->do_callback();}
+ callback {if (o->value()==0){ voicemodegroup->activate(); noiselabel->hide();}
+ else{ voicemodegroup->deactivate(); noiselabel->show();}}
tooltip {Oscillator Type (sound/noise)} xywh {5 515 65 20} down_box BORDER_BOX labelsize 10 textfont 1 textsize 10
- code0 {o->value(pars->VoicePar[nvoice].Type);}
- code1 {if (pars->VoicePar[nvoice].Type!=0) voicemodegroup->deactivate();}
+ code0 {o->init("Type");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label Sound
@@ -740,58 +742,58 @@ noiselabel->do_callback();}
}
Fl_Check_Button bypassfiltercheckbutton {
label {Bypass Global F.}
- callback {pars->VoicePar[nvoice].Pfilterbypass=(int)o->value();}
xywh {425 10 100 20} down_box DOWN_BOX labelfont 1 labelsize 10 align 148
- code0 {o->value(pars->VoicePar[nvoice].Pfilterbypass);}
+ code0 {o->init("Pfilterbypass");}
+ class Fl_Osc_Check
}
Fl_Group {} {open
xywh {115 5 95 35} box THIN_UP_BOX
} {
Fl_Value_Slider {} {
label Delay
- callback {pars->VoicePar[nvoice].PDelay=(int)o->value();}
tooltip Volume xywh {120 21 84 12} type {Horz Knob} box NO_BOX labelsize 11 align 5 maximum 127 step 1
- code0 {o->value(pars->VoicePar[nvoice].PDelay);}
+ code0 {o->init("PDelay");}
+ class Fl_Osc_VSlider
}
}
Fl_Check_Button {} {
label On
- callback {pars->VoicePar[nvoice].PFilterEnabled=(int)o->value();
-if (o->value()==0) voicefiltergroup->deactivate();
+ callback {if (o->value()==0) voicefiltergroup->deactivate();
else voicefiltergroup->activate();
o->redraw();
bypassfiltercheckbutton->redraw();}
tooltip {Enable Filter} xywh {250 15 60 15} down_box DOWN_BOX labelfont 1 labelsize 11
- code0 {o->value(pars->VoicePar[nvoice].PFilterEnabled);}
+ code0 {o->init("PFilterEnabled");}
+ class Fl_Osc_Check
}
Fl_Box noiselabel {
label {White Noise}
- callback {if (pars->VoicePar[nvoice].Type==0) o->hide(); else o->show();}
xywh {150 430 300 65} labelfont 1 labelsize 50 labelcolor 53
- code0 {if (pars->VoicePar[nvoice].Type==0) o->hide(); else o->show();}
}
}
Fl_Check_Button voiceonbutton {
label On
- callback {pars->VoicePar[nvoice].Enabled=(int)o->value();
-if (o->value()==0) voiceparametersgroup->deactivate();
+ callback {if (o->value()==0) voiceparametersgroup->deactivate();
else voiceparametersgroup->activate();
o->redraw();}
xywh {60 5 55 35} box THIN_UP_BOX down_box DOWN_BOX labelfont 1 labelsize 13
- code0 {o->value(pars->VoicePar[nvoice].Enabled);}
+ code0 {o->init("Enabled");}
+ class Fl_Osc_Check
}
}
}
Function {ADvoiceUI(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
code {nvoice=0;
-pars=NULL;
oscedit=NULL;} {}
}
- Function {init(ADnoteParameters *parameters,int nvoice_,Master *master_)} {open
+ Function {init(int nvoice_, std::string loc_, Fl_Osc_Interface *osc_)} {open
} {
- code {pars=parameters;
+ code {assert(osc_);
+assert(!loc_.empty());
nvoice=nvoice_;
-master=master_;
+loc=loc_+"voice"+to_s(nvoice)+"/";
+base = loc_;
+osc_i=osc_;
make_window();
end();
ADnoteVoiceParameters->show();} {}
@@ -800,17 +802,29 @@ ADnoteVoiceParameters->show();} {}
} {
code {ADnoteVoiceParameters->hide();
hide();
-if (oscedit!=NULL) {
- delete(oscedit);
-};
+delete(oscedit);
//delete (ADnoteVoiceParameters);} {}
}
- decl {int nvoice;} {}
- decl {ADnoteParameters *pars;} {}
- decl {OscilEditor *oscedit;} {}
- decl {Oscilloscope *osc;} {}
- decl {Oscilloscope *oscFM;} {}
- decl {Master *master;} {}
+ Function {change_voice(int nvoice_)} {open
+ } {
+ code {nvoice = nvoice_;
+ADnoteVoiceParameters->rebase(base+"voice"+to_s(nvoice)+"/");} {selected
+ }
+ }
+ decl {int nvoice;} {private local
+ }
+ decl {OscilEditor *oscedit;} {private local
+ }
+ decl {Fl_Oscilloscope *osc;} {private local
+ }
+ decl {Fl_Oscilloscope *oscFM;} {private local
+ }
+ decl {std::string loc;} {private local
+ }
+ decl {std::string base;} {private local
+ }
+ decl {Fl_Osc_Interface *osc_i;} {private local
+ }
}
class ADnoteUI {open : {public PresetsUI_}
@@ -819,8 +833,13 @@ class ADnoteUI {open : {public PresetsUI_}
} {
Fl_Window ADnoteGlobalParameters {
label {ADsynth Global Parameters of the Instrument} open
- xywh {457 319 540 430} type Double visible
+ xywh {688 551 540 430} type Double
+ class Fl_Osc_Window visible
} {
+ Fl_Box {} {
+ xywh {0 0 0 0}
+ code0 {ADnoteGlobalParameters->base = loc + "global/"; ADnoteGlobalParameters->osc = osc;}
+ }
Fl_Group {} {
label FREQUENCY open
xywh {5 280 530 115} box UP_FRAME labeltype EMBOSSED_LABEL labelfont 1 labelsize 13 align 17
@@ -828,168 +847,152 @@ class ADnoteUI {open : {public PresetsUI_}
Fl_Group freqenv {
label {ADSynth Global - Frequency Envelope} open
xywh {10 320 205 70} box FLAT_BOX color 51 align 144
- code0 {o->init(pars->GlobalPar.FreqEnvelope);}
+ code0 {o->init(ENV_ASR, osc, loc, "global/FreqEnvelope/");}
class EnvelopeUI
} {}
Fl_Counter octave {
label Octave
- callback {int k=(int) o->value();
-if (k<0) k+=16;
-pars->GlobalPar.PCoarseDetune = k*1024+
- pars->GlobalPar.PCoarseDetune%1024;}
tooltip Octave xywh {455 300 45 15} type Simple labelsize 10 align 1 minimum -8 maximum 7 step 1 textfont 1 textsize 11
- code0 {int k=pars->GlobalPar.PCoarseDetune/1024;if (k>=8) k-=16;}
- code2 {o->value(k);}
+ code0 {o->init("octave");}
+ class Fl_Osc_Counter
}
Fl_Counter coarsedet {
label {Coarse det.}
- callback {int k=(int) o->value();
-if (k<0) k+=1024;
-pars->GlobalPar.PCoarseDetune = k+
- (pars->GlobalPar.PCoarseDetune/1024)*1024;}
tooltip {Coarse Detune} xywh {460 370 60 20} type Simple labelsize 10 align 5 minimum -64 maximum 63 step 1 textfont 1 textsize 11
- code0 {int k=pars->GlobalPar.PCoarseDetune%1024;if (k>=512) k-=1024;}
- code2 {o->value(k);}
+ code0 {o->init("coarsedetune");}
code3 {o->lstep(10);}
+ class Fl_Osc_Counter
}
Fl_Group freqlfo {
label {Frequency LFO } open
xywh {220 320 230 70} box FLAT_BOX color 47 align 144
- code0 {o->init(pars->GlobalPar.FreqLfo);}
+ code0 {o->init(osc, loc, "global/FreqLfo/");}
class LFOUI
} {}
- Fl_Slider freq {
- callback {pars->GlobalPar.PDetune=(int)o->value()+8192;
-detunevalueoutput->do_callback();}
+ Fl_Slider detune {
+ callback {o->oscWrite("detunevalue");}
tooltip {Fine Detune (cents)} xywh {60 300 385 15} type {Horz Knob} box NO_BOX minimum -8192 maximum 8191 step 1
- code0 {o->value(pars->GlobalPar.PDetune-8192);}
+ code0 {o->init("PDetune", 'i');}
+ class Fl_Osc_Slider
}
Fl_Value_Output detunevalueoutput {
label Detune
- callback {o->value(getdetune(pars->GlobalPar.PDetuneType,0,pars->GlobalPar.PDetune));}
xywh {12 300 45 15} labelsize 10 align 5 minimum -5000 maximum 5000 step 0.01 textfont 1 textsize 10
- code0 {o->value(getdetune(pars->GlobalPar.PDetuneType,0,pars->GlobalPar.PDetune));}
+ code0 {o->init("detunevalue");}
+ class Fl_Osc_Output
}
Fl_Choice detunetype {
label {Detune Type}
- callback {pars->GlobalPar.PDetuneType=(int) o->value()+1;
-detunevalueoutput->do_callback();} open
+ callback {o->oscWrite("detunevalue");} open
xywh {455 340 75 15} down_box BORDER_BOX labelsize 10 align 5 textfont 1 textsize 10
code0 {o->add("L35cents");o->add("L10cents");o->add("E100cents");o->add("E1200cents");}
- code1 {o->value(pars->GlobalPar.PDetuneType-1);}
+ code1 {o->init("PDetuneType",1);}
+ class Fl_Osc_Choice
} {}
Fl_Dial {} {
label relBW
- callback {pars->GlobalPar.PBandwidth=(int) o->value();
-
-pars->getBandwidthDetuneMultiplier();
-
-for (int i=0;i<NUM_VOICES;i++){
+ callback {for (int i=0;i<NUM_VOICES;i++){
voicelistitem[i]->refreshlist();
};}
tooltip {Bandwidth - how the relative fine detune of the voice are changed} xywh {505 295 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->GlobalPar.PBandwidth);}
- class WidgetPDial
+ code0 {o->init("PBandwidth");}
+ class Fl_Osc_Dial
}
}
Fl_Group {} {
- label AMPLITUDE
+ label AMPLITUDE open
xywh {5 5 240 260} box UP_FRAME labeltype EMBOSSED_LABEL labelfont 1 labelsize 13 align 17
} {
Fl_Value_Slider volume {
label Vol
- callback {pars->GlobalPar.PVolume=(int)o->value();}
tooltip Volume xywh {10 30 160 15} type {Horz Knob} box NO_BOX labelsize 11 align 8 maximum 127 step 1
- code0 {o->value(pars->GlobalPar.PVolume);}
+ code0 {o->init("PVolume");}
+ class Fl_Osc_VSlider
}
Fl_Value_Slider vsns {
label {V.Sns}
- callback {pars->GlobalPar.PAmpVelocityScaleFunction=(int) o->value();}
tooltip {Velocity Sensing Function (rightmost to disable)} xywh {10 50 160 15} type {Horz Knob} box NO_BOX labelsize 11 align 8 maximum 127 step 1
- code0 {o->value(pars->GlobalPar.PAmpVelocityScaleFunction);}
+ code0 {o->init("PAmpVelocityScaleFunction");}
+ class Fl_Osc_VSlider
}
Fl_Dial pan {
label Pan
- callback {pars->GlobalPar.PPanning=(int) o->value();}
tooltip {Panning (leftmost is Random)} xywh {210 25 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(pars->GlobalPar.PPanning);}
- class WidgetPDial
+ code0 {o->init("PPanning");}
+ class Fl_Osc_Dial
}
Fl_Dial pstr {
label {P.Str.}
- callback {pars->GlobalPar.PPunchStrength=(int) o->value();}
tooltip {Punch Strength} xywh {125 237 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->GlobalPar.PPunchStrength);}
- class WidgetPDial
+ code0 {o->init("PPunchStrength");}
+ class Fl_Osc_Dial
}
Fl_Dial pt {
label {P.t.}
- callback {pars->GlobalPar.PPunchTime=(int) o->value();}
tooltip {Punch Time (duration)} xywh {155 237 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->GlobalPar.PPunchTime);}
- class WidgetPDial
+ code0 {o->init("PPunchTime");}
+ class Fl_Osc_Dial
}
Fl_Dial pstc {
label {P.Stc.}
- callback {pars->GlobalPar.PPunchStretch=(int) o->value();}
tooltip {Punch Stretch} xywh {185 237 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->GlobalPar.PPunchStretch);}
- class WidgetPDial
+ code0 {o->init("PPunchStretch");}
+ class Fl_Osc_Dial
}
Fl_Dial pvel {
label {P.Vel.}
- callback {pars->GlobalPar.PPunchVelocitySensing=(int) o->value();}
tooltip {Punch Velocity Sensing} xywh {215 237 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->GlobalPar.PPunchVelocitySensing);}
- class WidgetPDial
+ code0 {o->init("PPunchVelocitySensing");}
+ class Fl_Osc_Dial
}
Fl_Group ampenv {
label {ADSynth Global - Amplitude Envelope} open
xywh {10 75 205 70} box FLAT_BOX color 51 align 144
- code0 {o->init(pars->GlobalPar.AmpEnvelope);}
+ code0 {o->init(ENV_ADSR, osc, loc, "global/AmpEnvelope/");}
class EnvelopeUI
} {}
Fl_Group amplfo {
label {Amplitude LFO } open
xywh {10 150 230 70} box FLAT_BOX color 47 align 144
- code0 {o->init(pars->GlobalPar.AmpLfo);}
+ code0 {o->init(osc, loc, "global/AmpLfo/");}
class LFOUI
} {}
Fl_Check_Button rndgrp {
label {Rnd Grp}
- callback {pars->GlobalPar.Hrandgrouping=(int) o->value();}
tooltip {How the Harmonic Amplitude is applied to voices that use the same oscillator} xywh {70 235 40 25} down_box DOWN_BOX labelsize 10 align 148
- code0 {o->value(pars->GlobalPar.Hrandgrouping);}
+ code0 {o->init("Hrandgrouping");}
+ class Fl_Osc_Check
}
}
Fl_Group {} {
- label FILTER open selected
+ label FILTER open
xywh {250 5 285 265} box UP_FRAME labeltype EMBOSSED_LABEL labelfont 1 labelsize 13 align 17
} {
Fl_Group filterenv {
label {ADSynth Global - Filter Envelope} open
xywh {255 118 275 70} box FLAT_BOX color 51 align 144
- code0 {o->init(pars->GlobalPar.FilterEnvelope);}
+ code0 {o->init(ENV_ADSR_FILTER, osc, loc, "global/FilterEnvelope/");}
class EnvelopeUI
} {}
Fl_Group filterlfo {
label {Filter LFO} open
xywh {255 195 230 70} box FLAT_BOX color 47 align 144
- code0 {o->init(pars->GlobalPar.FilterLfo);}
+ code0 {o->init(osc, loc, "global/FilterLfo/");}
class LFOUI
} {}
Fl_Group filterui {
label {ADsynth Global - Filter} open
xywh {255 35 275 75} box FLAT_BOX color 50 align 144
- code0 {o->init(pars->GlobalPar.GlobalFilter,&pars->GlobalPar.PFilterVelocityScale,&pars->GlobalPar.PFilterVelocityScaleFunction);}
+ code0 {o->init(loc + "global/PFilter",
+ osc, loc, "global/GlobalFilter/");}
class FilterUI
} {}
}
Fl_Check_Button stereo {
label Stereo
- callback {pars->GlobalPar.PStereo=(int) o->value();}
xywh {5 230 65 35} down_box DOWN_BOX labelsize 11
- code0 {o->value(pars->GlobalPar.PStereo);}
+ code0 {o->init("PStereo");}
+ class Fl_Osc_Check
}
Fl_Button {} {
label {Show Voice List}
@@ -1017,22 +1020,28 @@ resui->resonancewindow->show();}
}
Fl_Button {} {
label C
- callback {presetsui->copyArray(pars);}
+ callback {/*presetsui->copyArray(pars);*/}
xywh {405 405 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
}
Fl_Button {} {
label P
- callback {presetsui->pasteArray(pars,this);}
+ callback {/*presetsui->pasteArray(pars,this);*/}
xywh {435 405 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
}
}
Fl_Window ADnoteVoice {
label {ADsynth Voice Parameters} open
- xywh {1142 229 765 630} type Double visible
+ xywh {48 361 765 630} type Double
+ class Fl_Osc_Window visible
} {
+ Fl_Box {} {
+ xywh {0 0 0 0}
+ code0 {ADnoteVoice->base = loc;}
+ code1 {ADnoteVoice->osc = osc;}
+ }
Fl_Group advoice {open
xywh {0 0 765 595}
- code0 {o->init(pars,nvoice,master);}
+ code0 {o->init(nvoice,loc, osc);}
code1 {o->show();}
class ADvoiceUI
} {}
@@ -1044,32 +1053,31 @@ resui->resonancewindow->show();}
Fl_Counter currentvoicecounter {
label {Current Voice}
callback {nvoice=(int)o->value()-1;
-advoice->hide();
-ADnoteVoice->remove(advoice);
-delete advoice;
-advoice=new ADvoiceUI(0,0,765,590);
-ADnoteVoice->add(advoice);
-advoice->init(pars,nvoice,master);
-advoice->show();
-ADnoteVoice->redraw();}
+advoice->change_voice(nvoice);}
xywh {10 601 130 25} type Simple labelfont 1 align 8 minimum 0 maximum 2 step 1 value 1 textfont 1 textsize 13
code0 {o->bounds(1,NUM_VOICES);}
}
Fl_Button {} {
label C
- callback {presetsui->copy(pars,nvoice);}
+ callback {/*presetsui->copy(pars,nvoice);*/}
xywh {705 609 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
}
Fl_Button {} {
label P
- callback {presetsui->paste(pars,this,nvoice);}
+ callback {/*presetsui->paste(pars,this,nvoice);*/}
xywh {735 609 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
}
}
Fl_Window ADnoteVoiceList {
- label {ADsynth Voices list}
+ label {ADsynth Voices list} open
xywh {32 266 650 260} type Double hide
+ class Fl_Osc_Window
} {
+ Fl_Box {} {
+ xywh {0 0 0 0}
+ code0 {ADnoteVoiceList->base = loc;}
+ code1 {ADnoteVoiceList->osc = osc;}
+ }
Fl_Text_Display {} {
label {No.}
xywh {10 15 30 10} box NO_BOX labelfont 1 labelsize 11
@@ -1104,50 +1112,35 @@ ADnoteVoice->redraw();}
} {
Fl_Pack {} {open
xywh {0 20 620 210}
- code0 {for (int i=0;i<NUM_VOICES;i++){voicelistitem[i]=new ADvoicelistitem(0,0,620,25,"");voicelistitem[i]->init(pars,i,master);}}
+ code0 {o->begin();for (int i=0;i<NUM_VOICES;i++){voicelistitem[i]=new ADvoicelistitem(0,0,620,25,"");voicelistitem[i]->init(i,loc+"voice"+to_s(i)+"/",osc);}o->end();}
} {}
}
}
}
- Function {ADnoteUI(ADnoteParameters *parameters,Master *master_)} {} {
- code {pars=parameters;
-master=master_;
+ Function {ADnoteUI(std::string loc_, Fl_Osc_Interface *osc_)} {open
+ } {
+ code {assert(osc_);
+assert(!loc_.empty());
+
nvoice=0;
-resui=new ResonanceUI(pars->GlobalPar.Reson);
+resui=new ResonanceUI(osc_, loc_+"global/Reson/");
+loc=loc_;
+osc=osc_;
make_window();} {}
}
- Function {~ADnoteUI()} {} {
+ Function {~ADnoteUI()} {open
+ } {
code {ADnoteVoiceList->hide();
ADnoteGlobalParameters->hide();
ADnoteVoice->hide();
-delete(ADnoteVoiceList);
-delete(ADnoteGlobalParameters);
-delete(ADnoteVoice);
-delete(resui);} {}
+delete ADnoteVoiceList;
+delete ADnoteGlobalParameters;
+delete ADnoteVoice;
+delete resui;} {}
}
- Function {refresh()} {} {
- code {volume->value(pars->GlobalPar.PVolume);
-vsns->value(pars->GlobalPar.PAmpVelocityScaleFunction);
-pan->value(pars->GlobalPar.PPanning);
-
-stereo->value(pars->GlobalPar.PStereo);
-rndgrp->value(pars->GlobalPar.Hrandgrouping);
-
-pstr->value(pars->GlobalPar.PPunchStrength);
-pt->value(pars->GlobalPar.PPunchTime);
-pstc->value(pars->GlobalPar.PPunchStretch);
-pvel->value(pars->GlobalPar.PPunchVelocitySensing);
-
-detunevalueoutput->value(getdetune(pars->GlobalPar.PDetuneType,0,pars->GlobalPar.PDetune));
-freq->value(pars->GlobalPar.PDetune-8192);
-
-int k=pars->GlobalPar.PCoarseDetune/1024;if (k>=8) k-=16;
-octave->value(k);
-
-detunetype->value(pars->GlobalPar.PDetuneType-1);
-k=pars->GlobalPar.PCoarseDetune%1024;if (k>=512) k-=1024;
-coarsedet->value(k);
-amplfo->refresh();
+ Function {refresh()} {open
+ } {
+ code {amplfo->refresh();
freqlfo->refresh();
filterlfo->refresh();
@@ -1161,9 +1154,14 @@ for (int i=0;i<NUM_VOICES;i++) voicelistitem[i]->refreshlist();
resui->refresh();
currentvoicecounter->do_callback();} {}
}
- decl {ADnoteParameters *pars;} {}
- decl {ResonanceUI *resui;} {}
- decl {Master *master;} {}
- decl {int nvoice;} {}
- decl {ADvoicelistitem *voicelistitem[NUM_VOICES];} {}
+ decl {ResonanceUI *resui;} {private local
+ }
+ decl {int nvoice;} {private local
+ }
+ decl {ADvoicelistitem *voicelistitem[NUM_VOICES];} {private local
+ }
+ decl {std::string loc;} {private local
+ }
+ decl {Fl_Osc_Interface *osc;} {private local
+ }
}
diff --git a/src/UI/BankUI.fl b/src/UI/BankUI.fl
@@ -1,186 +1,78 @@
# data file for the Fltk User Interface Designer (fluid)
-version 1.0110
+version 1.0302
header_name {.h}
code_name {.cc}
-decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {}
-
-decl {//License: GNU GPL version 2 or later} {}
-
-decl {\#include <stdlib.h>} {public
+decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {private local
}
-decl {\#include <stdio.h>} {public
+decl {//License: GNU GPL version 2 or later} {private local
}
-decl {\#include <string.h>} {public
+decl {\#include <stdlib.h>} {public local
}
-decl {\#include <FL/Fl_Button.H>} {public
+decl {\#include <stdio.h>} {public local
}
-decl {\#include <FL/Fl_File_Chooser.H>} {public
+decl {\#include <string.h>} {public local
}
-decl {\#include "../Misc/Master.h"} {public
+decl {\#include <FL/Fl_Button.H>} {public local
}
-decl {\#include "../Misc/Part.h"} {public
+decl {\#include <FL/Fl_File_Chooser.H>} {public local
}
-decl {\#include "../Misc/Bank.h"} {public
+decl {\#include "Fl_Osc_Interface.h"} {public local
}
-decl {\#include "../Misc/Config.h"} {public
+decl {\#include "../Misc/Master.h"} {public local
}
-decl {\#include "../Misc/Util.h"} {public
+decl {\#include "../Misc/Part.h"} {public local
}
-class BankProcess_ {} {
- Function {process()} {open return_type {virtual void}
- } {
- code {;} {}
- }
- decl {Bank *bank;} {public
- }
+decl {\#include "../Misc/Bank.h"} {public local
}
-class BankSlot {open : {public Fl_Button,BankProcess_}
-} {
- Function {BankSlot(int x,int y, int w, int h, const char *label=0):Fl_Button(x,y,w,h,label)} {open
- } {
- code {what=NULL;
-whatslot=NULL;
-nslot=0;
-nselected=NULL;} {selected
- }
- }
- Function {handle(int event)} {return_type int
- } {
- code {if (what==NULL) return(0);
-if (Fl::event_inside(this)){
- *what=0;*whatslot=nslot;
- if ((event==FL_RELEASE)&&(Fl::event_button()==1))*what=1;
- if ((event==FL_RELEASE)&&(Fl::event_button()==3))*what=2;
- if (event==FL_PUSH) highlight=1;
-}else highlight=0;
-
-int tmp=Fl_Button::handle(event);
-if ((*what!=0) && Fl::event_inside(this)) (bp->*fnc)();
-return(tmp);} {}
- }
- Function {init(int nslot_, int *what_, int *whatslot_,void (BankProcess_:: *fnc_)(void),BankProcess_ *bp_,Bank *bank_,int *nselected_)} {} {
- code {nslot=nslot_;
-what=what_;
-whatslot=whatslot_;
-fnc=fnc_;
-bp=bp_;
-bank=bank_;
-nselected=nselected_;
-box(FL_THIN_UP_BOX);
-labelfont(0);
-labelsize(13);
-align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
-
-highlight=0;
-refresh();} {}
- }
- Function {refresh()} {} {
- code {if (bank->emptyslot(nslot))
- color(46);
-else if (bank->isPADsynth_used(nslot))
- color(124);
-else
- color(51);
-
-
-if (*nselected==nslot)
- color(6);
+decl {\#include "../Misc/Config.h"} {public local
+}
+decl {\#include "../Misc/Util.h"} {public local
+}
-copy_label(bank->getnamenumbered(nslot).c_str());} {}
- }
- decl {int *what,*whatslot,nslot,highlight, *nselected;} {}
- decl {void (BankProcess_:: *fnc)(void);} {}
- decl {BankProcess_ *bp;} {}
+decl {\#include "BankView.h"} {public local
}
-class BankUI {open : {public BankProcess_}
+class BankUI {open
} {
Function {make_window()} {open
} {
Fl_Window bankuiwindow {
- label Bank
+ label Bank open
xywh {492 406 785 575} type Double
- code0 {o->label(bank->bankfiletitle.c_str());}
- code1 {if (bank->bankfiletitle.empty()) o->label ("Choose a bank from the bank list on the left (or go to settings if to configure the bank location) or choose 'New Bank...' to make a new bank.");} visible
+ code0 {/*o->label(bank->bankfiletitle.c_str());*/}
+ code1 {/*if (bank->bankfiletitle.empty()) o->label ("Choose a bank from the bank list on the left (or go to settings if to configure the bank location) or choose 'New Bank...' to make a new bank.");*/} visible
+ class Fl_Osc_Window
} {
+ Fl_Box {} {
+ xywh {0 0 0 0}
+ code0 {bankuiwindow->osc = osc;}
+ code1 {bankuiwindow->base = "/";}
+ }
Fl_Button {} {
label Close
callback {bankuiwindow->hide();}
xywh {705 546 70 24} box THIN_UP_BOX
}
- Fl_Group {} {
+ Fl_Group bankview {open
xywh {5 34 772 491} box ENGRAVED_FRAME
- } {
- Fl_Pack {} {
- xywh {10 39 150 481} box BORDER_FRAME
- code0 {o->box(FL_NO_BOX);}
- code1 {for (int i=0;i<32;i++){bs[i]=new BankSlot (0,0,o->w(),15," ");bs[i]->init(i,&what,&slot,&BankProcess_::process,(BankProcess_ *)this,bank,&nselected);};}
- } {}
- Fl_Pack {} {
- xywh {163 39 150 481} box BORDER_FRAME
- code0 {o->box(FL_NO_BOX);}
- code1 {for (int i=32;i<64;i++){bs[i]=new BankSlot (0,0,o->w(),15," ");bs[i]->init(i,&what,&slot,&BankProcess_::process,(BankProcess_ *)this,bank,&nselected);};}
- } {}
- Fl_Pack {} {
- xywh {316 39 150 481} box BORDER_FRAME
- code0 {o->box(FL_NO_BOX);}
- code1 {for (int i=64;i<96;i++){bs[i]=new BankSlot (0,0,o->w(),15," ");bs[i]->init(i,&what,&slot,&BankProcess_::process,(BankProcess_ *)this,bank,&nselected);};}
- } {}
- Fl_Pack {} {
- xywh {469 39 150 481} box BORDER_FRAME
- code0 {o->box(FL_NO_BOX);}
- code1 {for (int i=96;i<128;i++){bs[i]=new BankSlot (0,0,o->w(),15," ");bs[i]->init(i,&what,&slot,&BankProcess_::process,(BankProcess_ *)this,bank,&nselected);};}
- } {}
- Fl_Pack {} {
- xywh {622 39 150 481} box BORDER_FRAME
- code0 {o->box(FL_NO_BOX);}
- code1 {for (int i=128;i<160;i++){bs[i]=new BankSlot (0,0,o->w(),15," ");bs[i]->init(i,&what,&slot,&BankProcess_::process,(BankProcess_ *)this,bank,&nselected);};}
- } {}
- }
- Fl_Group modeselect {
+ class BankView
+ } {}
+ Fl_Group modeselect {open
xywh {5 528 425 42} box ENGRAVED_BOX
- } {
- Fl_Check_Button writebutton {
- label WRITE
- callback {if (o->value()>0.5) mode=2;
-removeselection();}
- xywh {116 534 99 30} type Radio box UP_BOX down_box DOWN_BOX labelfont 1 labelsize 13
- code0 {if (bank->locked()) o->deactivate();}
- }
- Fl_Check_Button readbutton {
- label READ selected
- callback {if (o->value()>0.5) mode=1;
-removeselection();}
- xywh {11 534 99 30} type Radio box UP_BOX down_box DOWN_BOX labelfont 1 labelsize 13
- code0 {o->value(1);}
- }
- Fl_Check_Button clearbutton {
- label CLEAR
- callback {if (o->value()>0.5) mode=3;
-removeselection();}
- xywh {221 534 99 30} type Radio box UP_BOX down_box DOWN_BOX labelfont 1 labelsize 13
- code0 {if (bank->locked()) o->deactivate();}
- }
- Fl_Check_Button swapbutton {
- label SWAP
- callback {if (o->value()>0.5) mode=4;
-removeselection();}
- xywh {325 534 99 30} type Radio box UP_BOX down_box DOWN_BOX labelfont 1 labelsize 13
- code0 {if (bank->locked()) o->deactivate();}
- }
- }
+ class BankViewControls
+ } {}
Fl_Button {} {
label {New Bank...}
callback {const char *dirname;
@@ -189,9 +81,8 @@ dirname=fl_input("New empty Bank:");
if (dirname==NULL) return;
-int result=bank->newbank(dirname);
-
-if (result!=0) fl_alert("Error: Could not make a new bank (directory)..");
+osc->write("/newbank", "s", dirname);
+/*if (result!=0) fl_alert("Error: Could not make a new bank (directory)..");*/
refreshmainwindow();}
xywh {685 5 93 25} labelfont 1 labelsize 11 align 128
@@ -203,15 +94,16 @@ refreshmainwindow();}
code0 {o->value(config.cfg.BankUIAutoClose);}
}
Fl_Choice banklist {
- callback {int n=o->value();
-std::string dirname=bank->banks[n].dir;
-if (dirname.empty()) return;
-
-if (bank->loadbank(dirname)==2)
- fl_alert("Error: Could not load the bank from the directory\\n%s.",dirname.c_str());
-for (int i=0;i<BANK_SIZE;i++) bs[i]->refresh();
+ callback { //int n=o->value();
+//std::string dirname="";/*bank->banks[n].dir;*/
+//if (dirname.empty()) return;
+//osc->write("/loadbank", "s", dirname.c_str());
+/*if (bank->loadbank(dirname)==2)
+ fl_alert("Error: Could not load the bank from the directory\\n%s.",dirname.c_str());*/
refreshmainwindow();}
xywh {5 8 220 20} down_box BORDER_BOX labelfont 1 align 0 textfont 1 textsize 11
+ code0 {o->init("loadbank");}
+ class BankList
} {}
Fl_Button {} {
label {Refresh bank list}
@@ -219,150 +111,65 @@ refreshmainwindow();}
banklist->value(0);}
tooltip {Refresh the bank list (rescan)} xywh {230 8 105 20} box THIN_UP_BOX color 50 labelsize 11
}
- Fl_Check_Button {} {
- label {Show PADsynth status}
- callback {config.cfg.CheckPADsynth=(int) o->value();
-refreshmainwindow();}
- xywh {435 530 150 15} down_box DOWN_BOX labelsize 11
- code0 {o->value(config.cfg.CheckPADsynth);}
- }
}
}
- Function {BankUI(Master *master_,int *npart_)} {} {
- code {fnc=&BankProcess_::process;
-master=master_;
-npart=npart_;
-bank=&master_->bank;
-what=0;
-nselected=-1;
+ Function {BankUI(int *npart_, Fl_Osc_Interface *osc_)} {open
+ } {
+ code {npart=*npart_;
+osc =osc_;
make_window();
-mode=1;} {}
+bankview->init(osc, modeselect, npart_);} {}
}
- Function {~BankUI()} {return_type virtual
+ Function {~BankUI()} {open return_type virtual
} {
code {bankuiwindow->hide();
-delete(bankuiwindow);} {}
+delete bankuiwindow;} {}
}
- Function {show()} {} {
+ Function {show()} {open
+ } {
code {bankuiwindow->show();
simplesetmode(config.cfg.UserInterfaceMode==2);} {}
}
- Function {hide()} {} {
+ Function {hide()} {open
+ } {
code {bankuiwindow->hide();} {}
}
- Function {init(Fl_Valuator *cbwig_)} {} {
+ Function {init(Fl_Valuator *cbwig_)} {open
+ } {
code {cbwig=cbwig_;
rescan_for_banks();} {}
}
- Function {process()} {return_type void
+ Function {process()} {open return_type void
} {
- code {int slot=this->slot;
-
-if ((what==2)&&(bank->emptyslot(slot)==0)&&(mode!=4)) {//Rename slot
- const char *tmp=fl_input("Slot (instrument) name:",bank->getname(slot).c_str());
- if (tmp!=NULL) bank->setname(slot,tmp,-1);
- bs[slot]->refresh();
-};
-
-if ((what==1)&&(mode==1)&&(!bank->emptyslot(slot))){//Reads from slot
- pthread_mutex_lock(&master->part[*npart]->load_mutex);
- bank->loadfromslot(slot,master->part[*npart]);
- pthread_mutex_unlock(&master->part[*npart]->load_mutex);
- master->part[*npart]->applyparameters();
- snprintf((char *)master->part[*npart]->Pname,PART_MAX_NAME_LEN,"%s",bank->getname(slot).c_str());
- cbwig->do_callback();
-
- if (config.cfg.BankUIAutoClose!=0)
- bankuiwindow->hide();
-
-};
-
-if ((what==1)&&(mode==2)){//save(write) to slot
- if (!bank->emptyslot(slot)){
- if (!fl_choice("Overwrite the slot no. %d ?","No","Yes",NULL,slot+1)) goto nooverwriteslot;
- };
- pthread_mutex_lock(&master->part[*npart]->load_mutex);
- bank->savetoslot(slot,master->part[*npart]);
- pthread_mutex_unlock(&master->part[*npart]->load_mutex);
-
- bs[slot]->refresh();
- mode=1;readbutton->value(1);writebutton->value(0);
- nooverwriteslot:;
-};
-
-
-
-if ((what==1)&&(mode==3)&&(!bank->emptyslot(slot))){//Clears the slot
- if (fl_choice("Clear the slot no. %d ?","No","Yes",NULL,slot+1)){
- bank->clearslot(slot);
- bs[slot]->refresh();
- };
-};
-
-if (mode==4){//swap
- bool done=false;
- if ((what==1)&&(nselected>=0)){
- bank->swapslot(nselected,slot);
- int ns=nselected;
- nselected=-1;
- bs[slot]->refresh();
- bs[ns]->refresh();
- done=true;
- };
- if (((nselected<0)||(what==2))&&(!done)){
- int ns=nselected;
- nselected=slot;
- if (ns>0) bs[ns]->refresh();
- bs[slot]->refresh();
- };
-};
-if (mode!=4) refreshmainwindow();} {}
+ code {} {}
}
- Function {refreshmainwindow()} {} {
- code {bankuiwindow->label(bank->bankfiletitle.c_str());
-mode=1;readbutton->value(1);writebutton->value(0);clearbutton->value(0);swapbutton->value(0);
-nselected=-1;
-if (bank->locked()){
- writebutton->deactivate();
- clearbutton->deactivate();
- swapbutton->deactivate();
-} else {
- writebutton->activate();
- clearbutton->activate();
- swapbutton->activate();
-};
-for (int i=0;i<BANK_SIZE;i++)
- bs[i]->refresh();} {}
- }
- Function {removeselection()} {} {
- code {if (nselected>=0) {
- int ns=nselected;
- nselected=-1;
- bs[ns]->refresh();
-};} {}
+ Function {refreshmainwindow()} {open
+ } {
+ code {/*bankuiwindow->label(bank->bankfiletitle.c_str());*/
+bankview->refresh();} {}
}
- Function {rescan_for_banks()} {} {
+ Function {rescan_for_banks()} {open
+ } {
code {banklist->clear();
-bank->rescanforbanks();
+ osc->write("/rescanforbanks");
+/*
for (unsigned int i=0;i<bank->banks.size();i++) {
banklist->add(bank->banks[i].name.c_str());
}
+*/
if (banklist->size() == 0)
banklist->add(" ");} {}
}
- Function {simplesetmode(bool beginnerui)} {} {
- code {readbutton->value(1);
-mode=1;
-removeselection();
-if (beginnerui) modeselect->hide();
+ Function {simplesetmode(bool beginnerui)} {open
+ } {
+ code {if (beginnerui) modeselect->hide();
else modeselect->show();} {}
}
- decl {BankSlot *bs[BANK_SIZE];} {}
- decl {int slot,what;//"what"=what button is pressed} {}
- decl {int mode,*npart,nselected;} {}
- decl {Master *master;} {}
- decl {void (BankProcess_::* fnc)(void);} {}
- decl {Fl_Valuator *cbwig;} {public
+ decl {Fl_Osc_Interface *osc;} {private local
+ }
+ decl {Fl_Valuator *cbwig;} {public local
+ }
+ decl {int npart;} {private local
}
}
diff --git a/src/UI/BankView.cpp b/src/UI/BankView.cpp
@@ -0,0 +1,315 @@
+#include "BankView.h"
+#include "../Misc/Util.h"
+#include <FL/Fl.H>
+#include <FL/Fl_Light_Button.H>
+#include <FL/fl_ask.H>
+#include <rtosc/rtosc.h>
+#include <cstdio>
+#include <cstring>
+#include <cassert>
+
+BankList::BankList(int x,int y, int w, int h, const char *label)
+ :Fl_Osc_Choice(x,y,w,h,label)
+{}
+
+void BankList::init(std::string path)
+{
+ ext = path;
+ oscRegister(path.c_str());
+ osc->createLink("/bank-list", this);
+}
+
+void BankList::OSC_raw(const char *msg)
+{
+ if(strcmp(msg, "/bank-list"))
+ return;
+
+ const int pos = rtosc_argument(msg, 0).i;
+ const char *path = rtosc_argument(msg, 1).s;
+
+ if(pos == 0)
+ this->clear();
+
+ this->add(path);
+}
+
+BankSlot::BankSlot(int x,int y, int w, int h, const char *label)
+:Fl_Button(x,y,w,h,label), nslot(-1)
+{
+ memset(labelstr, 0, sizeof(labelstr));
+ box(FL_THIN_UP_BOX);
+ labelfont(0);
+ labelsize(13);
+ align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
+}
+
+int BankSlot::handle(int event)
+{
+ int what = 0;
+ if (Fl::event_inside(this))
+ {
+ what=0;
+ if ((event==FL_RELEASE)&&(Fl::event_button()==1))
+ what=1;
+ if ((event==FL_RELEASE)&&(Fl::event_button()==3))
+ what=2;
+ }
+
+ int tmp=Fl_Button::handle(event);
+
+ if (what && Fl::event_inside(this))
+ bv->react(what, nslot);
+
+ return tmp;
+}
+
+void BankSlot::init(int nslot_, BankView *bv_)
+{
+ nslot = nslot_;
+ bv = bv_;
+
+ snprintf(labelstr, 127, "%d.", nslot_);
+ label(labelstr);
+}
+
+void BankSlot::update(const char *name__, const char *fname__)
+{
+ name_ = name__;
+ filename_ = fname__;
+ snprintf(labelstr, 127, "%d. %s", nslot, name_.c_str());
+ label(labelstr);
+
+ color(empty() ? 46 : 51);
+}
+
+bool BankSlot::empty(void) const
+{
+ return filename_.empty();
+}
+
+const char *BankSlot::name(void) const
+{
+ return name_.c_str();
+}
+
+const char *BankSlot::filename(void) const
+{
+ return filename_.c_str();
+}
+
+/*
+ void BankSlot::init(int nslot_, int *what_, int *whatslot_,void (BankProcess_:: *fnc_)(void),BankProcess_ *bp_,Bank *bank_,int *nselected_) {
+ nslot=nslot_;
+ what=what_;
+ whatslot=whatslot_;
+ fnc=fnc_;
+ bp=bp_;
+//bank=bank_;
+nselected=nselected_;
+box(FL_THIN_UP_BOX);
+labelfont(0);
+labelsize(13);
+align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
+
+highlight=0;
+//refresh();
+}
+*/
+
+/*
+ void BankSlot::refresh() {
+ if (bank->emptyslot(nslot))
+ color(46);
+ else if (bank->isPADsynth_used(nslot))
+ color(26);
+ else
+ color(51);
+
+
+ if (*nselected==nslot)
+ color(6);
+
+
+ copy_label(bank->getnamenumbered(nslot).c_str());
+ }
+ */
+static int modeCb(const char *label)
+{
+ if(!strcmp("Read", label))
+ return 1;
+ else if(!strcmp("Write", label))
+ return 2;
+ else if(!strcmp("Clear", label))
+ return 3;
+ else if(!strcmp("Swap", label))
+ return 4;
+ return -1;
+}
+
+static void control_widget_cb(Fl_Light_Button *button, void *bvc_)
+{
+ BankViewControls *bvc = (BankViewControls*)bvc_;
+ bvc->mode(modeCb(button->label()));
+ //TODO removeselection?
+}
+
+BankViewControls::BankViewControls(int x, int y, int w, int h, const char *label)
+ :Fl_Group(x,y,w,h,label)
+{
+ //Margin
+ const int m = 10;
+ //Width per elm
+ const float W = w/4;
+
+ read = new Fl_Light_Button(x+m+0*W, y+m, W-2*m, h-2*m, "Read");
+ write = new Fl_Light_Button(x+m+1*W, y+m, W-2*m, h-2*m, "Write");
+ clear = new Fl_Light_Button(x+m+2*W, y+m, W-2*m, h-2*m, "Clear");
+ swap = new Fl_Light_Button(x+m+3*W, y+m, W-2*m, h-2*m, "Swap");
+ mode(1);
+}
+
+int BankViewControls::mode(void) const
+{
+ return mode_;
+}
+
+void BankViewControls::mode(int m)
+{
+ mode_ = m;
+ int M = m-1;
+ assert(0 <= M && M <= 3);
+ Fl_Button *buttons[4]{read, write, clear, swap};
+
+ for(int i=0; i<3; ++i)
+ buttons[i]->value(i==M);
+}
+
+
+BankView::BankView(int x,int y, int w, int h, const char *label)
+ :Fl_Group(x,y,w,h,label)
+{}
+
+
+BankView::~BankView(void)
+{
+ if(osc)
+ osc->removeLink("/bankview", this);
+}
+
+void BankView::init(Fl_Osc_Interface *osc_, BankViewControls *bvc_, int *npart_)
+{
+ assert(osc_);
+
+ osc = osc_;
+ bvc = bvc_;
+ npart = npart_;
+
+ osc->createLink("/bankview", this);
+
+ //Element Size
+ const float width = w()/5.0;
+ const float height = h()/32.0;
+
+ //Offsets
+ const int X = x();
+ const int Y = y();
+
+ begin();
+ //Place All Slots
+ for(int i=0; i<5; ++i)
+ for(int j=0; j<32; ++j)
+ slots[i*32 + j] =
+ new BankSlot(X + i*width, Y + j*height, width, height);
+
+ end();
+
+ //Initialize callbacks
+ for(int i=0; i<160; ++i)
+ slots[i]->init(i, this);
+
+ //Request Values
+ for(int i=0; i<160; ++i)
+ osc->write("/refresh_bank", "i", i);
+}
+
+/*
+ * React to user input.
+ * This consists of the events:
+ * - Rename Slot (right click)
+ * - Read From Slot
+ * - Write To Slot
+ * - Swap Slot First Selection
+ * - Swap Slot Second Selction
+ *
+ * TODO restore autoclose functionality
+ */
+void BankView::react(int event, int nslot)
+{
+ printf("reacting...\n");
+ BankSlot &slot = *slots[nslot];
+ const bool isempty = slot.empty();
+ const int mode = bvc->mode();
+ printf("mode = %d\n", mode);
+
+ //Rename slot
+ if (event==2 && !isempty && mode!=4)
+ if(const char *name=fl_input("Slot (instrument) name:", slot.name()))
+ osc->write("/bank-rename", "is", nslot, name);
+
+ //Reads from slot
+ if ((event==1)&&(mode==1)&&(!slot.empty())){
+ printf("Loading a part #%d with file '%s'\n", nslot, slot.filename());
+ osc->write("/load-part", "is", *npart, slot.filename());
+ osc->writeValue("/part"+to_s(*npart)+"/name", slot.name());
+ }
+
+ //save(write) to slot
+ if(event==1 && mode==2){
+ if(!isempty && !fl_choice("Overwrite the slot no. %d ?","No","Yes",NULL,nslot+1))
+ return;
+
+ osc->write("/save-bank-part", "i", npart);
+ //pthread_mutex_lock(&master->part[*npart]->load_mutex);
+ //bank->savetoslot(slot,master->part[*npart]);
+ //pthread_mutex_unlock(&master->part[*npart]->load_mutex);
+
+ bvc->mode(1);//readbutton->value(1);writebutton->value(0);
+ }
+
+
+ //Clears the slot
+ if(event==1 && mode==3 && !isempty)
+ if (fl_choice("Clear the slot no. %d ?","No","Yes",NULL, nslot+1))
+ osc->write("/clear-bank-slot", "i", nslot);
+
+ //Swap
+ if(mode==4) {
+ if(event==1 && nselected>=0){
+ osc->write("/swap-bank-slots", "ii", nselected, nslot);
+ //bank->swapslot(nselected,slot);
+ nselected=-1;
+ } else if(nselected<0 || event==2) {
+ nselected=nslot;
+ };
+ };
+}
+
+void BankView::OSC_raw(const char *msg)
+{
+ if(strcmp(rtosc_argument_string(msg), "iss"))
+ return;
+
+ int nslot = rtosc_argument(msg,0).i;
+ const char *name = rtosc_argument(msg,1).s;
+ const char *fname = rtosc_argument(msg,2).s;
+
+ if(0 <= nslot && nslot < 160)
+ slots[nslot]->update(name, fname);
+}
+
+void BankView::refresh(void)
+{
+ for(int i=0; i<160; ++i)
+ osc->write("/refresh_bank", "i", i);
+}
+
diff --git a/src/UI/BankView.h b/src/UI/BankView.h
@@ -0,0 +1,96 @@
+#ifndef BANKVIEW_H
+#define BANKVIEW_H
+
+#include "Fl_Osc_Widget.H"
+#include "Fl_Osc_Choice.H"
+#include <FL/Fl_Group.H>
+#include <FL/Fl_Button.H>
+#include <string>
+
+#include "common.H"
+
+class Bank;
+class BankView;
+class Fl_Light_Button;
+
+class BankList : public Fl_Osc_Choice
+{
+ public:
+ BankList(int x,int y, int w, int h, const char *label=0);
+ void init(std::string path);
+ void OSC_raw(const char *msg);
+};
+
+class BankSlot : public Fl_Button
+{
+ public:
+ BankSlot(int x,int y, int w, int h, const char *label=0);
+ int handle(int event);
+ void init(int nslot_, BankView *bv_);
+
+ void update(const char *name__, const char *fname__);
+
+ bool empty(void) const;
+ const char *name(void) const;
+ const char *filename(void) const;
+ private:
+ std::string name_;
+ std::string filename_;
+ char labelstr[128];
+ int nslot;
+ BankView *bv;
+};
+
+class BankViewControls: public Fl_Group
+{
+ public:
+ BankViewControls(int x,int y, int w, int h, const char *label=0);
+ void init(BankView *bv_);
+
+
+ int mode(void) const;
+ void mode(int);
+
+ private:
+ Fl_Light_Button *read;
+ Fl_Light_Button *write;
+ Fl_Light_Button *clear;
+ Fl_Light_Button *swap;
+
+ //1 -> read
+ //2 -> write
+ //3 -> clear
+ //4 -> swap
+ int mode_;
+
+ static void cb_clearbutton(Fl_Light_Button*, void*);
+ static void cb_readbutton(Fl_Light_Button*, void*);
+ static void cb_writebutton(Fl_Light_Button*, void*);
+};
+
+class BankView: public Fl_Group, public Fl_Osc_Widget
+{
+ public:
+ BankView(int x,int y, int w, int h, const char *label=0);
+ ~BankView(void);
+ void init(Fl_Osc_Interface *osc_, BankViewControls *bvc_, int *npart_);
+
+ void react(int event, int slot);
+
+ virtual void OSC_raw(const char *msg) override;
+
+ void refresh(void);
+ private:
+ BankViewControls *bvc;
+ BankSlot *slots[160];
+
+ Fl_Osc_Interface *osc;
+ std::string loc;
+
+ //XXX TODO locked banks...
+ int mode;
+ int nselected;
+ int *npart;
+};
+
+#endif
diff --git a/src/UI/CMakeLists.txt b/src/UI/CMakeLists.txt
@@ -34,6 +34,27 @@ add_library(zynaddsubfx_gui STATIC
${zynaddsubfx_gui_FLTK_UI_SRCS}
NioUI.cpp
WidgetPDial.cpp
+ PartNameButton.cpp
+ Fl_Osc_Pane.cpp
+ Fl_Osc_Widget.cpp
+ Fl_Osc_Dial.cpp
+ Fl_Osc_DialF.cpp
+ Fl_Osc_Slider.cpp
+ Fl_Osc_VSlider.cpp
+ Fl_Osc_Button.cpp
+ Fl_Osc_Check.cpp
+ Fl_Osc_Choice.cpp
+ Fl_Osc_Roller.cpp
+ Fl_Osc_Output.cpp
+ Fl_Osc_Counter.cpp
+ Fl_Osc_Input.cpp
+ Fl_Osc_Value.cpp
+ Fl_Resonance_Graph.cpp
+ Fl_EQGraph.cpp
+ FormantFilterGraph.cpp
+ EnvelopeFreeEdit.cpp
+ BankView.cpp
+ Connection.cpp
)
if(NtkGui)
diff --git a/src/UI/Connection.cpp b/src/UI/Connection.cpp
@@ -0,0 +1,157 @@
+#include "Connection.h"
+#include "Fl_Osc_Interface.h"
+#include "../globals.h"
+
+#include <rtosc/rtosc.h>
+#include <rtosc/ports.h>
+
+#include <FL/Fl.H>
+#include "Fl_Osc_Tree.H"
+#include "common.H"
+#include "MasterUI.h"
+
+#ifdef NTK_GUI
+#include <FL/Fl_Shared_Image.H>
+#include <FL/Fl_Tiled_Image.H>
+#include <FL/Fl_Dial.H>
+#endif // NTK_GUI
+
+using namespace GUI;
+MasterUI *ui;
+
+Fl_Osc_Interface *osc;//TODO: the scope of this should be narrowed
+
+#ifdef NTK_GUI
+static Fl_Tiled_Image *module_backdrop;
+#endif
+
+void
+set_module_parameters ( Fl_Widget *o )
+{
+#ifdef NTK_GUI
+ o->box( FL_DOWN_FRAME );
+ o->align( o->align() | FL_ALIGN_IMAGE_BACKDROP );
+ o->color( FL_BLACK );
+ o->image( module_backdrop );
+ o->labeltype( FL_SHADOW_LABEL );
+#else
+ o->box( FL_PLASTIC_UP_BOX );
+ o->color( FL_CYAN );
+ o->labeltype( FL_EMBOSSED_LABEL );
+#endif
+}
+
+ui_handle_t GUI::createUi(Fl_Osc_Interface *osc, void *exit)
+{
+ ::osc = osc;
+#ifdef NTK_GUI
+ fl_register_images();
+
+ Fl_Dial::default_style(Fl_Dial::PIXMAP_DIAL);
+
+ if(Fl_Shared_Image *img = Fl_Shared_Image::get(PIXMAP_PATH "/knob.png"))
+ Fl_Dial::default_image(img);
+ else
+ Fl_Dial::default_image(Fl_Shared_Image::get(SOURCE_DIR "/../pixmaps/knob.png"));
+
+ if(Fl_Shared_Image *img = Fl_Shared_Image::get(PIXMAP_PATH "/window_backdrop.png"))
+ Fl::scheme_bg(new Fl_Tiled_Image(img));
+ else
+ Fl::scheme_bg(new Fl_Tiled_Image(Fl_Shared_Image::get(SOURCE_DIR "/../pixmaps/window_backdrop.png")));
+
+ if(Fl_Shared_Image *img = Fl_Shared_Image::get(PIXMAP_PATH "/module_backdrop.png"))
+ module_backdrop = new Fl_Tiled_Image(img);
+ else
+ module_backdrop = new Fl_Tiled_Image(Fl_Shared_Image::get(SOURCE_DIR "/../pixmaps/module_backdrop.png"));
+
+ Fl::background(50, 50, 50);
+ Fl::background2(70, 70, 70);
+ Fl::foreground(255, 255, 255);
+#endif
+
+ Fl_Window *midi_win = new Fl_Double_Window(400, 400, "Midi connections");
+ Fl_Osc_Tree *tree = new Fl_Osc_Tree(0,0,400,400);
+ midi_win->resizable(tree);
+ tree->root_ports = &Master::ports;
+ tree->osc = osc;
+ midi_win->show();
+
+ return (void*) (ui = new MasterUI((int*)exit, osc));
+}
+void GUI::destroyUi(ui_handle_t ui)
+{
+ delete static_cast<MasterUI*>(ui);
+}
+
+#define BEGIN(x) {x,"",NULL,[](const char *m, rtosc::RtData d){ \
+ MasterUI *ui = static_cast<MasterUI*>(d.obj); \
+ rtosc_arg_t a0 = rtosc_argument(m,0);
+ //rtosc_arg_t a1 = rtosc_argument(m,1); \
+ //rtosc_arg_t a2 = rtosc_argument(m,2); \
+ //rtosc_arg_t a3 = rtosc_argument(m,3);
+#define END }},
+
+//DSL based ports
+static rtosc::Ports ports = {
+ BEGIN("show:T") {
+ ui->showUI();
+ } END
+ BEGIN("alert:s") {
+ fl_alert(a0.s);
+ } END
+ BEGIN("session-type:s") {
+ if(strcmp(a0.s,"LASH"))
+ return;
+ ui->sm_indicator1->value(1);
+ ui->sm_indicator2->value(1);
+ ui->sm_indicator1->tooltip("LASH");
+ ui->sm_indicator2->tooltip("LASH");
+ } END
+ BEGIN("save-master:s") {
+ ui->do_save_master(a0.s);
+ } END
+ BEGIN("load-master:s") {
+ ui->do_load_master(a0.s);
+ } END
+ BEGIN("vu-meter:bb") {
+ rtosc_arg_t a1 = rtosc_argument(m,1);
+ if(a0.b.len == sizeof(vuData) &&
+ a1.b.len == sizeof(float)*NUM_MIDI_PARTS) {
+ //Refresh the primary VU meters
+ ui->simplemastervu->update((vuData*)a0.b.data);
+ ui->mastervu->update((vuData*)a0.b.data);
+
+ float *partvu = (float*)a1.b.data;
+ for(int i=0; i<NUM_MIDI_PARTS; ++i)
+ ui->panellistitem[i]->partvu->update(partvu[i]);
+ }
+ } END
+};
+
+void GUI::raiseUi(ui_handle_t gui, const char *message)
+{
+ MasterUI *mui = (MasterUI*)gui;
+ mui->osc->tryLink(message);
+ //printf("got message for UI '%s'\n", message);
+ char buffer[1024];
+ memset(buffer, 0, sizeof(buffer));
+ rtosc::RtData d;
+ d.loc = buffer;
+ d.loc_size = 1024;
+ d.obj = gui;
+ ports.dispatch(message+1, d);
+}
+
+void GUI::raiseUi(ui_handle_t gui, const char *dest, const char *args, ...)
+{
+ char buffer[1024];
+ va_list va;
+ va_start(va,args);
+ if(rtosc_vmessage(buffer,1024,dest,args,va))
+ raiseUi(gui, buffer);
+}
+
+void GUI::tickUi(ui_handle_t)
+{
+ Fl::wait(0.02f);
+}
diff --git a/src/UI/Connection.h b/src/UI/Connection.h
@@ -0,0 +1,15 @@
+//Defines the methods of communication for the GUI
+//Expect this code to mutate into some sort of ugly beast that will slowly
+//remove the tendrils of the UI from the RT code
+
+class Fl_Osc_Interface;
+namespace GUI
+{
+typedef void *ui_handle_t;
+
+ui_handle_t createUi(Fl_Osc_Interface *osc, void *exit);
+void destroyUi(ui_handle_t);
+void raiseUi(ui_handle_t, const char *);
+void raiseUi(ui_handle_t, const char *, const char *, ...);
+void tickUi(ui_handle_t);
+};
diff --git a/src/UI/ConnectionDummy.cpp b/src/UI/ConnectionDummy.cpp
@@ -0,0 +1,18 @@
+
+ui_handle_t createUi(message_cb, void *Master, void *exit)
+{
+ return NULL;
+}
+void destroyUi(ui_handle_t)
+{
+}
+void raiseUi(ui_handle_t, const char *)
+{
+}
+void raiseUi(ui_handle_t, const char *, const char *, ...)
+{
+}
+void tickUi(ui_handle_t)
+{
+ usleep(100000);
+}
diff --git a/src/UI/EffUI.fl b/src/UI/EffUI.fl
@@ -1,173 +1,56 @@
# data file for the Fltk User Interface Designer (fluid)
-version 1.0110
+version 1.0302
header_name {.h}
code_name {.cc}
-decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {}
-
-decl {//License: GNU GPL version 2 or later} {}
-
-decl {\#include <stdlib.h>} {public
+decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {private local
}
-decl {\#include <stdio.h>} {public
+decl {//License: GNU GPL version 2 or later} {private local
}
-decl {\#include <string.h>} {public
+decl {\#include <stdlib.h>} {public local
}
-decl {\#include "../globals.h"} {public
+decl {\#include <stdio.h>} {public local
}
-decl {\#include "WidgetPDial.h"} {public
+decl {\#include <string.h>} {public local
}
-decl {\#include "EnvelopeUI.h"} {public
+decl {\#include "../globals.h"} {public local
}
-decl {\#include "FilterUI.h"} {public
+decl {\#include "Fl_Osc_Dial.H"} {public local
}
-decl {\#include "../Misc/Util.h"} {public
+decl {\#include "Fl_Osc_Check.H"} {public local
}
-decl {\#include "../Effects/EffectMgr.h"} {public
+decl {\#include "Fl_EQGraph.H"} {public local
}
-decl {\#include "PresetsUI.h"} {public
+decl {\#include "EnvelopeUI.h"} {public local
}
-decl {\#include "common.H"} {public
+decl {\#include "FilterUI.h"} {public local
}
-class EQGraph {: {public Fl_Box}
-} {
- Function {EQGraph(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} {
- code {eff=NULL;
-maxdB=30;} {}
- }
- Function {init(EffectMgr *eff_)} {} {
- code {eff=eff_;
-oldx=-1;
-khzval=-1;} {}
- }
- Function {draw_freq_line(float freq,int type)} {} {
- code {fl_color(FL_GRAY);
-float freqx=getfreqpos(freq);
-switch(type){
- case 0:if (active_r()) fl_color(FL_WHITE);
- else fl_color(205,205,205);
- fl_line_style(FL_SOLID);
- break;
- case 1:fl_line_style(FL_DOT);break;
- case 2:fl_line_style(FL_DASH);break;
-};
-
-
-if ((freqx>0.0)&&(freqx<1.0))
- fl_line(x()+(int) (freqx*w()),y(),
- x()+(int) (freqx*w()),y()+h());} {}
- }
- Function {draw()} {} {
- code {int ox=x(),oy=y(),lx=w(),ly=h(),i;
- double iy,oiy;
-float freqx;
-
-if (active_r()) fl_color(fl_darker(FL_GRAY));
- else fl_color(FL_GRAY);
-fl_rectf(ox,oy,lx,ly);
-
-
-//draw the lines
-fl_color(fl_lighter( FL_GRAY));
-
-fl_line_style(FL_SOLID);
-fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);
-
-freqx=getfreqpos(1000.0);
-if ((freqx>0.0)&&(freqx<1.0))
- fl_line(ox+(int) (freqx*lx),oy,
- ox+(int) (freqx*lx),oy+ly);
-
-for (i=1;i<10;i++){
- if(i==1){
- draw_freq_line(i*100.0,0);
- draw_freq_line(i*1000.0,0);
- }else
- if (i==5){
- draw_freq_line(i*10.0,2);
- draw_freq_line(i*100.0,2);
- draw_freq_line(i*1000.0,2);
- }else{
- draw_freq_line(i*10.0,1);
- draw_freq_line(i*100.0,1);
- draw_freq_line(i*1000.0,1);
- };
-};
-
-draw_freq_line(10000.0,0);
-draw_freq_line(20000.0,1);
-
-
-fl_line_style(FL_DOT);
-int GY=6;if (ly<GY*3) GY=-1;
-for (i=1;i<GY;i++){
- int tmp=(int)(ly/(float)GY*i);
- fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
-};
-
-
-//draw the frequency response
-if (active_r()) fl_color(FL_YELLOW);
- else fl_color(200,200,80);
-fl_line_style(FL_SOLID,2);
-fl_color( fl_color_add_alpha( fl_color(), 127 ) );
-oiy=getresponse(ly,getfreqx(0.0));
-fl_begin_line();
-for (i=1;i<lx;i++){
- float frq=getfreqx(i/(float) lx);
- if (frq>synth->samplerate/2) break;
- iy=getresponse(ly,frq);
- if ((oiy>=0) && (oiy<ly) &&
- (iy>=0) && (iy<ly) )
- fl_vertex(ox+i,oy+ly-iy);
- oiy=iy;
-};
-fl_end_line();
-fl_line_style(FL_SOLID,0);} {}
- }
- Function {getresponse(int maxy,float freq)} {return_type double
- } {
- code {float dbresp=eff->getEQfreqresponse(freq);
-int idbresp=(int) ((dbresp/maxdB+1.0)*maxy/2.0);
-
+decl {\#include "../Misc/Util.h"} {public local
+}
-//fprintf(stderr,"%.5f\\n",(dbresp/maxdB+1.0)*maxy/2.0);
+decl {\#include "../Effects/EffectMgr.h"} {public local
+}
+decl {\#include "PresetsUI.h"} {public local
+}
-return(idbresp);} {}
- }
- Function {getfreqx(float x)} {return_type float
- } {
- code {if (x>1.0) x=1.0;
-return(20.0*pow((float)1000.0,x));} {}
- }
- Function {getfreqpos(float freq)} {return_type float
- } {
- code {if (freq<0.00001) freq=0.00001;
-return(log(freq/20.0)/log(1000.0));} {}
- }
- decl {int oldx,oldy;} {}
- decl {float khzval;} {public
- }
- decl {EffectMgr *eff;} {}
- decl {int maxdB;} {}
+decl {\#include "common.H"} {public local
}
-class EffUI {open : {public Fl_Group,public PresetsUI_}
+class EffUI {open : {public Fl_Osc_Group,public PresetsUI_}
} {
- Function {EffUI(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
- code {eff=NULL;
-filterwindow=NULL;} {}
+ Function {EffUI(int x,int y, int w, int h, const char *label=0):Fl_Osc_Group(x,y,w,h,label)} {} {
+ code {filterwindow=NULL;} {}
}
Function {~EffUI()} {} {
code {effnullwindow->hide();//delete (effnullwindow);
@@ -185,29 +68,26 @@ if (filterwindow!=NULL){
delete(filterwindow);
};} {}
}
- Function {make_null_window()} {open
- } {
+ Function {make_null_window()} {} {
Fl_Window effnullwindow {
label {No Effect}
- xywh {612 881 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 align 16
+ xywh {621 881 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19
code0 {set_module_parameters(o);}
class Fl_Group visible
} {}
}
- Function {make_reverb_window()} {open
- } {
+ Function {make_reverb_window()} {} {
Fl_Window effreverbwindow {
label Reverb open
- xywh {377 636 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 align 25
+ xywh {386 705 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19
code0 {set_module_parameters(o);}
class Fl_Group visible
} {
Fl_Choice revp {
label Preset
- callback {eff->changepreset((int)o->value());
-
-refresh(eff);}
xywh {10 15 90 15} box UP_BOX down_box BORDER_BOX color 14 selection_color 7 labelfont 1 labelsize 10 align 5 textfont 1 textsize 10
+ code0 {o->init("preset");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label {Cathedral 1}
@@ -264,10 +144,11 @@ refresh(eff);}
}
Fl_Choice revp10 {
label Type
- callback {eff->seteffectpar(10,(int) o->value());
-if (eff->geteffectpar(10)==2) revp12->activate();
+ callback {if(o->value()==2) revp12->activate();
else revp12->deactivate();}
xywh {110 15 85 15} down_box BORDER_BOX color 14 selection_color 7 labelfont 1 labelsize 10 align 5 textfont 1 textsize 10
+ code0 {o->init("parameter10");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label Random
@@ -284,89 +165,84 @@ if (eff->geteffectpar(10)==2) revp12->activate();
}
Fl_Dial revp0 {
label Vol
- callback {eff->seteffectpar(0,(int) o->value());}
tooltip {Effect Volume} xywh {10 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter0");}
+ class Fl_Osc_Dial
}
Fl_Dial revp1 {
label Pan
- callback {eff->seteffectpar(1,(int) o->value());}
xywh {45 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter1");}
+ class Fl_Osc_Dial
}
Fl_Dial revp2 {
label Time
- callback {eff->seteffectpar(2,(int) o->value());}
tooltip {Duration of Effect} xywh {80 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter2");}
+ class Fl_Osc_Dial
}
Fl_Dial revp3 {
label {I.del}
- callback {eff->seteffectpar(3,(int) o->value());}
tooltip {Initial Delay} xywh {120 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 when 4 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter3");}
+ class Fl_Osc_Dial
}
Fl_Dial revp4 {
label {I.delfb}
- callback {eff->seteffectpar(4,(int) o->value());}
tooltip {Initial Delay Feedback} xywh {155 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter4");}
+ class Fl_Osc_Dial
}
Fl_Dial revp12 {
label bw
- callback {eff->seteffectpar(12,(int) o->value());}
xywh {200 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 when 4 maximum 127 deactivate
- code0 {if (eff->geteffectpar(10)==2) o->activate();}
- class WidgetPDial
+ code0 {o->init("parameter12");}
+ class Fl_Osc_Dial
}
Fl_Dial revp6 {
label {E/R}
- callback {eff->seteffectpar(6,(int) o->value());}
xywh {235 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127 deactivate
- class WidgetPDial
+ code0 {o->init("parameter6");}
+ class Fl_Osc_Dial
}
Fl_Dial revp7 {
label LPF
- callback {eff->seteffectpar(7,(int) o->value());}
tooltip {Low Pass Filter} xywh {270 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter7");}
+ class Fl_Osc_Dial
}
Fl_Dial revp8 {
label HPF
- callback {eff->seteffectpar(8,(int) o->value());}
tooltip {High Pass Filter} xywh {305 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter8");}
+ class Fl_Osc_Dial
}
Fl_Dial revp9 {
label Damp
- callback {eff->seteffectpar(9,(int) o->value());}
tooltip Dampening xywh {340 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 minimum 64 maximum 127 step 1
- class WidgetPDial
+ code0 {o->init("parameter9");}
+ class Fl_Osc_Dial
}
Fl_Dial revp11 {
label {R.S.}
- callback {int x=64;
-if (Fl::event_button1()) x=(int)o->value();
- else o->value(x);
-eff->seteffectpar(11,x);}
tooltip RoomSize xywh {200 10 25 25} box ROUND_UP_BOX labelfont 1 labelsize 8 align 8 minimum 1 maximum 127 step 1
- class WidgetPDial
+ code0 {o->init("parameter11");}
+ class Fl_Osc_Dial
}
}
}
- Function {make_echo_window()} {open
- } {
+ Function {make_echo_window()} {} {
Fl_Window effechowindow {
label Echo
- xywh {897 611 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 align 25
+ xywh {897 680 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19
code0 {set_module_parameters(o);}
class Fl_Group visible
} {
Fl_Choice echop {
label Preset
- callback {eff->changepreset((int)o->value());
-refresh(eff);}
xywh {11 15 95 15} box UP_BOX down_box BORDER_BOX color 14 selection_color 7 labelfont 1 labelsize 10 align 5 textfont 1 textsize 10
+ code0 {o->init("preset");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label {Echo 1}
@@ -407,61 +283,60 @@ refresh(eff);}
}
Fl_Dial echop0 {
label Vol
- callback {eff->seteffectpar(0,(int) o->value());}
tooltip {Effect Volume} xywh {10 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter0");}
+ class Fl_Osc_Dial
}
Fl_Dial echop1 {
label Pan
- callback {eff->seteffectpar(1,(int) o->value());}
xywh {45 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter1");}
+ class Fl_Osc_Dial
}
Fl_Dial echop2 {
label Delay
- callback {eff->seteffectpar(2,(int) o->value());}
xywh {80 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 when 4 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter2");}
+ class Fl_Osc_Dial
}
Fl_Dial echop3 {
label {LRdl.}
- callback {eff->seteffectpar(3,(int) o->value());}
tooltip {Delay Between L/R} xywh {120 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 when 4 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter3");}
+ class Fl_Osc_Dial
}
Fl_Dial echop4 {
label {LRc.}
- callback {eff->seteffectpar(4,(int) o->value());}
tooltip {L/R Crossover} xywh {155 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter4");}
+ class Fl_Osc_Dial
}
Fl_Dial echop5 {
label {Fb.}
- callback {eff->seteffectpar(5,(int) o->value());}
tooltip Feedback xywh {195 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter5");}
+ class Fl_Osc_Dial
}
Fl_Dial echop6 {
label Damp
- callback {eff->seteffectpar(6,(int) o->value());}
tooltip Dampening xywh {235 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter6");}
+ class Fl_Osc_Dial
}
}
}
- Function {make_chorus_window()} {open
- } {
+ Function {make_chorus_window()} {} {
Fl_Window effchoruswindow {
label Chorus open
- xywh {467 742 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 align 25
+ xywh {476 811 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19
code0 {set_module_parameters(o);}
class Fl_Group visible
} {
Fl_Choice chorusp {
label Preset
- callback {eff->changepreset((int)o->value());
-refresh(eff);}
xywh {10 15 90 15} box UP_BOX down_box BORDER_BOX color 14 selection_color 7 labelfont 1 labelsize 10 align 5 textfont 1 textsize 10
+ code0 {o->init("preset");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label {Chorus 1}
@@ -506,73 +381,75 @@ refresh(eff);}
}
Fl_Dial chorusp0 {
label Vol
- callback {eff->seteffectpar(0,(int) o->value());}
xywh {10 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter0");}
+ class Fl_Osc_Dial
}
Fl_Dial chorusp1 {
label Pan
- callback {eff->seteffectpar(1,(int) o->value());}
xywh {45 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter1");}
+ class Fl_Osc_Dial
}
Fl_Dial chorusp2 {
label Freq
- callback {eff->seteffectpar(2,(int) o->value());}
tooltip {LFO Frequency} xywh {85 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter2");}
+ class Fl_Osc_Dial
}
Fl_Dial chorusp3 {
label Rnd
- callback {eff->seteffectpar(3,(int) o->value());}
tooltip {LFO Randomness} xywh {120 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 when 4 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter3");}
+ class Fl_Osc_Dial
}
Fl_Dial chorusp5 {
label {St.df}
- callback {eff->seteffectpar(5,(int) o->value());}
tooltip {L/R Phase Shift} xywh {200 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter5");}
+ class Fl_Osc_Dial
}
Fl_Dial chorusp6 {
label Dpth
- callback {eff->seteffectpar(6,(int) o->value());}
tooltip {LFO Depth} xywh {235 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter6");}
+ class Fl_Osc_Dial
}
Fl_Dial chorusp7 {
label Delay
- callback {eff->seteffectpar(7,(int) o->value());}
xywh {270 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter7");}
+ class Fl_Osc_Dial
}
Fl_Dial chorusp8 {
label Fb
- callback {eff->seteffectpar(8,(int) o->value());}
tooltip Feedback xywh {305 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter8");}
+ class Fl_Osc_Dial
}
Fl_Dial chorusp9 {
label {L/R}
- callback {eff->seteffectpar(9,(int) o->value());}
tooltip {Channel Routing} xywh {340 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter9");}
+ class Fl_Osc_Dial
}
Fl_Check_Button {} {
label Flange
- callback {eff->seteffectpar(10,(int) o->value());}
xywh {120 10 55 20} box THIN_UP_BOX down_box DOWN_BOX color 230 labelfont 1 labelsize 10 hide deactivate
- code0 {o->value(eff->geteffectpar(10));}
+ code0 {o->init("parameter10");}
+ class Fl_Osc_Check
}
Fl_Check_Button chorusp11 {
label Substract
- callback {eff->seteffectpar(11,(int) o->value());}
tooltip {inverts the output} xywh {185 10 70 20} box THIN_UP_BOX down_box DOWN_BOX color 51 labelsize 10
+ code0 {o->init("parameter11");}
+ class Fl_Osc_Check
}
Fl_Choice chorusp4 {
label {LFO type}
- callback {eff->seteffectpar(4,(int) o->value());}
tooltip {LFO function} xywh {155 50 40 15} down_box BORDER_BOX labelfont 1 labelsize 10 align 130 textsize 8
+ code0 {o->init("parameter4");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label SINE
@@ -585,19 +462,18 @@ refresh(eff);}
}
}
}
- Function {make_phaser_window()} {open
- } {
+ Function {make_phaser_window()} {} {
Fl_Window effphaserwindow {
label Phaser open
- xywh {101 232 380 95} type Double box UP_BOX color 221 labelfont 1 labelsize 19 align 25
+ xywh {110 301 380 95} type Double box UP_BOX color 221 labelfont 1 labelsize 19
code0 {set_module_parameters(o);}
class Fl_Group visible
} {
Fl_Choice phaserp {
label Preset
- callback {eff->changepreset((int)o->value());
-refresh(eff);}
xywh {10 15 100 15} box UP_BOX down_box BORDER_BOX color 14 selection_color 7 labelfont 1 labelsize 10 align 5 textfont 1 textsize 10
+ code0 {o->init("preset");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label {Phaser 1}
@@ -650,32 +526,33 @@ refresh(eff);}
}
Fl_Dial phaserp0 {
label Vol
- callback {eff->seteffectpar(0,(int) o->value());}
tooltip {Effect Volume} xywh {10 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter0");}
+ class Fl_Osc_Dial
}
Fl_Dial phaserp1 {
label Pan
- callback {eff->seteffectpar(1,(int) o->value());}
xywh {45 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter1");}
+ class Fl_Osc_Dial
}
Fl_Dial phaserp2 {
label Freq
- callback {eff->seteffectpar(2,(int) o->value());}
tooltip {LFO frequency} xywh {85 45 25 25} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter2");}
+ class Fl_Osc_Dial
}
Fl_Dial phaserp3 {
label Rnd
- callback {eff->seteffectpar(3,(int) o->value());}
tooltip {LFO randomness} xywh {120 45 25 25} box ROUND_UP_BOX labelfont 1 labelsize 11 when 4 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter3");}
+ class Fl_Osc_Dial
}
Fl_Choice phaserp4 {
label LFO
- callback {eff->seteffectpar(4,(int) o->value());}
tooltip {LFO function} xywh {245 55 40 15} down_box BORDER_BOX labelfont 1 labelsize 10 align 130 textsize 8
+ code0 {o->init("parameter4");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label SIN
@@ -688,76 +565,79 @@ refresh(eff);}
}
Fl_Dial phaserp5 {
label {St.df}
- callback {eff->seteffectpar(5,(int) o->value());}
tooltip {Left/Right Channel Phase Shift} xywh {155 45 25 25} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter5");}
+ class Fl_Osc_Dial
}
Fl_Dial phaserp6 {
label Dpth
- callback {eff->seteffectpar(6,(int) o->value());}
tooltip {LFO Depth} xywh {120 5 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter6");}
+ class Fl_Osc_Dial
}
Fl_Dial phaserp7 {
label Fb
- callback {eff->seteffectpar(7,(int) o->value());}
tooltip Feedback xywh {185 45 25 25} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter7");}
+ class Fl_Osc_Dial
}
Fl_Counter phaserp8 {
label Stages
- callback {eff->seteffectpar(8,(int) o->value());}
xywh {290 55 35 15} type Simple labelfont 1 labelsize 11 minimum 0 maximum 127 step 1
code0 {o->range(1,MAX_PHASER_STAGES);}
+ code1 {o->init("parameter8");}
+ class Fl_Osc_Counter
}
Fl_Dial phaserp9 {
label {L/R}
- callback {eff->seteffectpar(9,(int) o->value());}
tooltip {Channel Routing} xywh {215 45 25 25} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter9");}
+ class Fl_Osc_Dial
}
Fl_Check_Button phaserp10 {
label Substract
- callback {eff->seteffectpar(10,(int) o->value());} selected
tooltip {inverts output} xywh {200 10 74 20} box THIN_UP_BOX down_box DOWN_BOX color 51 labelfont 1 labelsize 10
+ code0 {o->init("parameter10");}
+ class Fl_Osc_Check
}
Fl_Dial phaserp11 {
label Phase
- callback {eff->seteffectpar(11,(int) o->value());}
xywh {155 5 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter11");}
+ class Fl_Osc_Dial
}
Fl_Check_Button phaserp12 {
label {hyp.}
- callback {eff->seteffectpar(12,(int) o->value());}
tooltip hyper xywh {245 35 55 15} down_box DOWN_BOX
+ code0 {o->init("parameter12");}
+ class Fl_Osc_Check
}
Fl_Dial phaserp13 {
label dist
- callback {eff->seteffectpar(13,(int) o->value());}
tooltip Distortion xywh {340 50 25 25} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter13");}
+ class Fl_Osc_Dial
}
Fl_Check_Button phaserp14 {
label Analog
- callback {eff->seteffectpar(14,(int) o->value());}
xywh {305 35 70 15} down_box DOWN_BOX
+ code0 {o->init("parameter14");}
+ class Fl_Osc_Check
}
}
}
- Function {make_alienwah_window()} {open
- } {
+ Function {make_alienwah_window()} {} {
Fl_Window effalienwahwindow {
label AlienWah
- xywh {253 353 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 align 25
+ xywh {262 422 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19
code0 {set_module_parameters(o);}
class Fl_Group visible
} {
Fl_Choice awp {
label Preset
- callback {eff->changepreset((int)o->value());
-refresh(eff);}
xywh {10 15 90 15} box UP_BOX down_box BORDER_BOX color 14 selection_color 7 labelfont 1 labelsize 10 align 5 textfont 1 textsize 10
+ code0 {o->init("preset");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label {Alienwah 1}
@@ -778,56 +658,57 @@ refresh(eff);}
}
Fl_Dial awp0 {
label Vol
- callback {eff->seteffectpar(0,(int) o->value());}
tooltip {Effect Volume} xywh {10 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter0");}
+ class Fl_Osc_Dial
}
Fl_Dial awp1 {
label Pan
- callback {eff->seteffectpar(1,(int) o->value());}
xywh {45 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter1");}
+ class Fl_Osc_Dial
}
Fl_Dial awp2 {
label Freq
- callback {eff->seteffectpar(2,(int) o->value());}
tooltip {LFO Frequency} xywh {85 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter2");}
+ class Fl_Osc_Dial
}
Fl_Dial awp3 {
label Rnd
- callback {eff->seteffectpar(3,(int) o->value());}
tooltip {LFO Randomness} xywh {120 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 when 4 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter3");}
+ class Fl_Osc_Dial
}
Fl_Dial awp5 {
label {St.df}
- callback {eff->seteffectpar(5,(int) o->value());}
tooltip {Left/Right Channel Phase Shift} xywh {200 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter5");}
+ class Fl_Osc_Dial
}
Fl_Dial awp6 {
label Dpth
- callback {eff->seteffectpar(6,(int) o->value());}
tooltip Depth xywh {235 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter6");}
+ class Fl_Osc_Dial
}
Fl_Dial awp7 {
label Fb
- callback {eff->seteffectpar(7,(int) o->value());}
tooltip Feedback xywh {270 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter7");}
+ class Fl_Osc_Dial
}
Fl_Dial awp9 {
label {L/R}
- callback {eff->seteffectpar(9,(int) o->value());}
xywh {345 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter9");}
+ class Fl_Osc_Dial
}
Fl_Choice awp4 {
label {LFO type}
- callback {eff->seteffectpar(4,(int) o->value());}
tooltip {LFO function} xywh {155 50 40 15} down_box BORDER_BOX labelfont 1 labelsize 10 align 130 textsize 8
+ code0 {o->init("parameter4");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label SINE
@@ -840,31 +721,31 @@ refresh(eff);}
}
Fl_Dial awp10 {
label Phase
- callback {eff->seteffectpar(10,(int) o->value());}
xywh {160 5 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter10");}
+ class Fl_Osc_Dial
}
Fl_Counter awp8 {
label Delay
- callback {eff->seteffectpar(8,(int) o->value());}
xywh {305 55 35 15} type Simple labelfont 1 labelsize 11 minimum 0 maximum 127 step 1
code0 {o->range(1,MAX_ALIENWAH_DELAY);}
+ code1 {o->init("parameter8");}
+ class Fl_Osc_Counter
}
}
}
- Function {make_distorsion_window()} {open
- } {
+ Function {make_distorsion_window()} {} {
Fl_Window effdistorsionwindow {
label Distortion open
- xywh {544 217 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 align 25
+ xywh {553 286 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19
code0 {set_module_parameters(o);}
class Fl_Group visible
} {
Fl_Choice distp {
label Preset
- callback {eff->changepreset((int)o->value());
-refresh(eff);}
xywh {11 15 95 15} box UP_BOX down_box BORDER_BOX color 14 selection_color 7 labelfont 1 labelsize 10 align 5 textfont 1 textsize 10
+ code0 {o->init("preset");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label {Overdrive 1}
@@ -893,50 +774,51 @@ refresh(eff);}
}
Fl_Dial distp0 {
label Vol
- callback {eff->seteffectpar(0,(int) o->value());}
tooltip {Effect Volume} xywh {10 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter0");}
+ class Fl_Osc_Dial
}
Fl_Dial distp1 {
label Pan
- callback {eff->seteffectpar(1,(int) o->value());}
xywh {45 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter1");}
+ class Fl_Osc_Dial
}
Fl_Dial distp2 {
label {LRc.}
- callback {eff->seteffectpar(2,(int) o->value());}
tooltip {L/R Mix} xywh {80 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 when 4 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter2");}
+ class Fl_Osc_Dial
}
Fl_Dial distp3 {
label Drive
- callback {eff->seteffectpar(3,(int) o->value());}
tooltip {Input Amplification} xywh {120 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 when 4 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter3");}
+ class Fl_Osc_Dial
}
Fl_Dial distp4 {
label Level
- callback {eff->seteffectpar(4,(int) o->value());}
tooltip {Output Amplification} xywh {155 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter4");}
+ class Fl_Osc_Dial
}
Fl_Dial distp7 {
label LPF
- callback {eff->seteffectpar(7,(int) o->value());}
tooltip {Low Pass Filter} xywh {285 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter7");}
+ class Fl_Osc_Dial
}
Fl_Dial distp8 {
label HPF
- callback {eff->seteffectpar(8,(int) o->value());}
tooltip {High Pass Filter} xywh {320 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter8");}
+ class Fl_Osc_Dial
}
Fl_Choice distp5 {
label Type
- callback {eff->seteffectpar(5,(int) o->value());}
xywh {190 50 60 20} box UP_BOX down_box BORDER_BOX labelfont 1 labelsize 11 align 2 textsize 10
+ code0 {o->init("parameter5");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label Atan
@@ -997,108 +879,95 @@ refresh(eff);}
}
Fl_Check_Button distp6 {
label {Neg.}
- callback {eff->seteffectpar(6,(int) o->value());}
xywh {260 55 15 15} down_box DOWN_BOX labelfont 1 labelsize 11 align 2
+ code0 {o->init("parameter6");}
+ class Fl_Osc_Check
}
Fl_Check_Button distp9 {
label {St.}
- callback {eff->seteffectpar(9,(int) o->value());}
tooltip Stereo xywh {355 60 15 15} down_box DOWN_BOX labelfont 1 labelsize 11 align 2
+ code0 {o->init("parameter9");}
+ class Fl_Osc_Check
}
Fl_Check_Button distp10 {
label PF
- callback {eff->seteffectpar(10,(int) o->value());}
tooltip {Applies the filters(before or after) the distorsion} xywh {355 44 15 15} down_box DOWN_BOX labelfont 1 labelsize 11 align 1
+ code0 {o->init("parameter10");}
+ class Fl_Osc_Check
}
}
}
- Function {make_eq_window()} {open
- } {
+ Function {make_eq_window()} {} {
Fl_Window effeqwindow {
label EQ open
- xywh {682 881 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 align 25
+ xywh {691 881 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19
code0 {set_module_parameters(o);}
class Fl_Group visible
} {
Fl_Dial eqp0 {
label Gain
- callback {eff->seteffectpar(0,(int) o->value());
-eqgraph->redraw();}
+ callback {eqgraph->redraw();}
xywh {10 35 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter0");}
+ class Fl_Osc_Dial
}
Fl_Counter bandcounter {
label {B.}
callback {eqband=(int) o->value();
int npb=eqband*5+10;
-int type=eff->geteffectpar(npb);
-typechoice->value(type);
-
-if (type>6) gaindial->activate();
- else gaindial->deactivate();
-
-if (type==0) bandgroup->deactivate();
-else bandgroup->activate();
-
-int freq=eff->geteffectpar(npb+1);
-freqdial->value(freq);
-
-int gain=eff->geteffectpar(npb+2);
-gaindial->value(gain);
-
-int q=eff->geteffectpar(npb+3);
-qdial->value(q);
-
-int dbl=eff->geteffectpar(npb+4);
-stagescounter->value(dbl);}
+typechoice->oscMove("parameter"+to_s(npb));
+freqdial->oscMove("parameter"+to_s(npb+1));
+gaindial->oscMove("parameter"+to_s(npb+2));
+qdial->oscMove("parameter"+to_s(npb+3));
+stagescounter->oscMove("parameter"+to_s(npb+4));}
tooltip {Band no.} xywh {240 20 45 15} type Simple labelfont 1 labelsize 11 align 1 minimum 0 maximum 1 step 1 textfont 1 textsize 11
code0 {o->bounds(0,MAX_EQ_BANDS-1);}
}
Fl_Group bandgroup {
xywh {245 40 130 50} box ENGRAVED_FRAME
- code0 {if (eff->geteffectpar(10)==0) o->deactivate();}
} {
Fl_Dial freqdial {
label Freq
- callback {int np=eqband*5+11;
-eff->seteffectpar(np,(int) o->value());
-eqgraph->redraw();}
+ callback {eqgraph->update();}
xywh {250 50 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 when 3 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter11");}
+ class Fl_Osc_Dial
}
Fl_Dial gaindial {
label Gain
- callback {int np=eqband*5+12;
-eff->seteffectpar(np,(int) o->value());
-eqgraph->redraw();}
+ callback {eqgraph->update();}
xywh {280 50 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 when 3 maximum 127 step 1
- class WidgetPDial
+ code0 {o->init("parameter12");}
+ class Fl_Osc_Dial
}
Fl_Dial qdial {
label Q
- callback {int np=eqband*5+13;
-eff->seteffectpar(np,(int) o->value());
-eqgraph->redraw();}
+ callback {eqgraph->update();}
tooltip {Resonance/Bandwidth} xywh {310 50 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 when 3 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter13");}
+ class Fl_Osc_Dial
}
Fl_Counter stagescounter {
label {St.}
- callback {int np=eqband*5+14;
-eff->seteffectpar(np,(int) o->value());
-eqgraph->redraw();}
+ callback {eqgraph->update();}
tooltip {Additional filter stages} xywh {340 60 30 15} type Simple labelfont 1 labelsize 10 minimum 1 maximum 127 step 1 textfont 1 textsize 11
- code0 {o->bounds(0,MAX_FILTER_STAGES-1);}
+ code0 {o->init("parameter14");}
+ class Fl_Osc_Counter
}
}
Fl_Choice typechoice {
label {T.}
- callback {int np=eqband*5+10;
-eff->seteffectpar(np,(int) o->value());
-bandcounter->do_callback();
-eqgraph->redraw();}
+ callback {int type = o->value();
+if (type>6) gaindial->activate();
+ else gaindial->deactivate();
+
+if (type==0) bandgroup->deactivate();
+else bandgroup->activate();
+eqgraph->update();}
tooltip Type xywh {290 20 40 15} down_box BORDER_BOX labelfont 1 labelsize 10 align 1 when 6 textsize 10
+ code0 {o->init("parameter15");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label OFF
@@ -1143,24 +1012,22 @@ eqgraph->redraw();}
}
Fl_Box eqgraph {
xywh {45 10 190 75} box BORDER_BOX color 50
- code0 {o->init(eff);}
- class EQGraph
+ class Fl_EQGraph
}
}
}
- Function {make_dynamicfilter_window()} {open
- } {
+ Function {make_dynamicfilter_window()} {} {
Fl_Window effdynamicfilterwindow {
label DynFilter open
- xywh {819 290 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19 align 25
+ xywh {828 359 380 100} type Double box UP_BOX color 221 labelfont 1 labelsize 19
code0 {set_module_parameters(o);}
class Fl_Group visible
} {
Fl_Choice dfp {
label Preset
- callback {eff->changepreset((int)o->value());
-refresh(eff);}
xywh {10 15 90 15} box UP_BOX down_box BORDER_BOX color 14 selection_color 7 labelfont 1 labelsize 10 align 5 textfont 1 textsize 10
+ code0 {o->init("preset");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label WahWah
@@ -1185,44 +1052,45 @@ refresh(eff);}
}
Fl_Dial dfp0 {
label Vol
- callback {eff->seteffectpar(0,(int) o->value());}
tooltip {Effect Volume} xywh {10 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter0");}
+ class Fl_Osc_Dial
}
Fl_Dial dfp1 {
label Pan
- callback {eff->seteffectpar(1,(int) o->value());}
xywh {45 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter1");}
+ class Fl_Osc_Dial
}
Fl_Dial dfp2 {
label Freq
- callback {eff->seteffectpar(2,(int) o->value());}
tooltip {LFO Frequency} xywh {85 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter2");}
+ class Fl_Osc_Dial
}
Fl_Dial dfp3 {
label Rnd
- callback {eff->seteffectpar(3,(int) o->value());}
tooltip {LFO Randomness} xywh {120 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 when 4 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter3");}
+ class Fl_Osc_Dial
}
Fl_Dial dfp5 {
label {St.df}
- callback {eff->seteffectpar(5,(int) o->value());}
tooltip {Left/Right Channel Phase Shift} xywh {200 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter5");}
+ class Fl_Osc_Dial
}
Fl_Dial dfp6 {
label LfoD
- callback {eff->seteffectpar(6,(int) o->value());}
tooltip {LFO Depth} xywh {235 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter6");}
+ class Fl_Osc_Dial
}
Fl_Choice dfp4 {
label {LFO type}
- callback {eff->seteffectpar(4,(int) o->value());}
tooltip {LFO function} xywh {155 50 40 15} down_box BORDER_BOX labelfont 1 labelsize 10 align 130 textsize 8
+ code0 {o->init("parameter4");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label SINE
@@ -1243,35 +1111,35 @@ refresh(eff);}
} {
Fl_Dial dfp7 {
label {A.S.}
- callback {eff->seteffectpar(7,(int) o->value());}
tooltip {Filter vs Amplitude} xywh {275 45 25 25} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter7");}
+ class Fl_Osc_Dial
}
Fl_Dial dfp9 {
label {A.M}
- callback {eff->seteffectpar(9,(int) o->value());}
tooltip {rate that amplitude changes the filter} xywh {305 45 25 25} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter9");}
+ class Fl_Osc_Dial
}
Fl_Check_Button dfp8 {
label {A.Inv.}
- callback {eff->seteffectpar(8,(int) o->value());}
tooltip {enable for filter frequency to lower with higher input amplitude} xywh {345 55 15 15} down_box DOWN_BOX labelfont 1 labelsize 11 align 2
+ code0 {o->init("parameter8");}
+ class Fl_Osc_Check
}
}
}
}
- Function {make_filter_window()} {open
- } {
+ Function {make_filter_window()} {} {
Fl_Window filterwindow {
label {Filter Parameters for DynFilter Eff.}
- xywh {801 474 290 110} type Double
+ xywh {810 543 290 110} type Double
code0 {set_module_parameters(o);} visible
} {
Fl_Group {} {
label {DynFilter effect - Filter}
xywh {5 5 275 75} box FLAT_BOX color 50 align 144
- code0 {o->init(eff->filterpars,NULL,NULL);}
+ code0 {o->init("",osc, loc(), "Filter/");}
code1 {o->use_for_dynamic_filter();}
class FilterUI
} {}
@@ -1282,8 +1150,10 @@ refresh(eff);}
}
}
}
- Function {init(EffectMgr *eff_)} {} {
- code {eff=eff_;
+ Function {init(bool ins_)} {open
+ } {
+ code {efftype = 0;
+ insertion = ins_;
make_null_window();
make_reverb_window();
@@ -1308,12 +1178,13 @@ effdistorsionwindow->position(px,py);
effeqwindow->position(px,py);
effdynamicfilterwindow->position(px,py);
-refresh(eff);} {}
+refresh();} {}
}
- Function {refresh(EffectMgr *eff_)} {open
+ Function {refresh()} {open
} {
- code {eff=eff_;
-this->hide();
+ code {this->hide();
+for(int i=0; i<32; ++i)
+ osc->requestValue(loc()+"parameter"+to_s(i));
effnullwindow->hide();
effreverbwindow->hide();
@@ -1327,134 +1198,48 @@ effdynamicfilterwindow->hide();
eqband=0;
-if (filterwindow!=NULL){
+if (filterwindow){
filterwindow->hide();
delete(filterwindow);
filterwindow=NULL;
};
+
+ if(insertion) {
+ revp0->label("D/W");
+ echop0->label("D/W");
+ chorusp0->label("D/W");
+ phaserp0->label("D/W");
+ awp0->label("D/W");
+ distp0->label("D/W");
+ dfp0->label("D/W");
+ }
-switch(eff->geteffect()){
+switch(efftype){
case 1:
- revp->value(eff->getpreset());
- revp0->value(eff->geteffectpar(0));if (eff->insertion!=0) revp0->label("D/W");
- revp1->value(eff->geteffectpar(1));
- revp2->value(eff->geteffectpar(2));
- revp3->value(eff->geteffectpar(3));
- revp4->value(eff->geteffectpar(4));
- //revp5->value(eff->geteffectpar(5));
- revp6->value(eff->geteffectpar(6));
- revp7->value(eff->geteffectpar(7));
- revp8->value(eff->geteffectpar(8));
- revp9->value(eff->geteffectpar(9));
- revp10->value(eff->geteffectpar(10));
- revp11->value(eff->geteffectpar(11));
- revp12->value(eff->geteffectpar(12));
-
effreverbwindow->show();
break;
case 2:
- echop->value(eff->getpreset());
- echop0->value(eff->geteffectpar(0));if (eff->insertion!=0) echop0->label("D/W");
- echop1->value(eff->geteffectpar(1));
- echop2->value(eff->geteffectpar(2));
- echop3->value(eff->geteffectpar(3));
- echop4->value(eff->geteffectpar(4));
- echop5->value(eff->geteffectpar(5));
- echop6->value(eff->geteffectpar(6));
effechowindow->show();
break;
case 3:
- chorusp->value(eff->getpreset());
- chorusp0->value(eff->geteffectpar(0));if (eff->insertion!=0) chorusp0->label("D/W");
- chorusp1->value(eff->geteffectpar(1));
- chorusp2->value(eff->geteffectpar(2));
- chorusp3->value(eff->geteffectpar(3));
- chorusp4->value(eff->geteffectpar(4));
- chorusp5->value(eff->geteffectpar(5));
- chorusp6->value(eff->geteffectpar(6));
- chorusp7->value(eff->geteffectpar(7));
- chorusp8->value(eff->geteffectpar(8));
- chorusp9->value(eff->geteffectpar(9));
- chorusp11->value(eff->geteffectpar(11));
effchoruswindow->show();
break;
case 4:
- phaserp->value(eff->getpreset());
- phaserp0->value(eff->geteffectpar(0));if (eff->insertion!=0) phaserp0->label("D/W");
- phaserp1->value(eff->geteffectpar(1));
- phaserp2->value(eff->geteffectpar(2));
- phaserp3->value(eff->geteffectpar(3));
- phaserp4->value(eff->geteffectpar(4));
- phaserp5->value(eff->geteffectpar(5));
- phaserp6->value(eff->geteffectpar(6));
- phaserp7->value(eff->geteffectpar(7));
- phaserp8->value(eff->geteffectpar(8));
- phaserp9->value(eff->geteffectpar(9));
- phaserp10->value(eff->geteffectpar(10));
- phaserp11->value(eff->geteffectpar(11));
- phaserp12->value(eff->geteffectpar(12));
- phaserp13->value(eff->geteffectpar(13));
- phaserp14->value(eff->geteffectpar(14));
effphaserwindow->show();
break;
case 5:
- awp->value(eff->getpreset());
- awp0->value(eff->geteffectpar(0));if (eff->insertion!=0) awp0->label("D/W");
- awp1->value(eff->geteffectpar(1));
- awp2->value(eff->geteffectpar(2));
- awp3->value(eff->geteffectpar(3));
- awp4->value(eff->geteffectpar(4));
- awp5->value(eff->geteffectpar(5));
- awp6->value(eff->geteffectpar(6));
- awp7->value(eff->geteffectpar(7));
- awp8->value(eff->geteffectpar(8));
- awp9->value(eff->geteffectpar(9));
- awp10->value(eff->geteffectpar(10));
-
effalienwahwindow->show();
break;
case 6:
- distp->value(eff->getpreset());
- distp0->value(eff->geteffectpar(0));if (eff->insertion!=0) distp0->label("D/W");
- distp1->value(eff->geteffectpar(1));
- distp2->value(eff->geteffectpar(2));
- distp3->value(eff->geteffectpar(3));
- distp4->value(eff->geteffectpar(4));
- distp5->value(eff->geteffectpar(5));
- distp6->value(eff->geteffectpar(6));
- distp7->value(eff->geteffectpar(7));
- distp8->value(eff->geteffectpar(8));
- distp9->value(eff->geteffectpar(9));
- distp10->value(eff->geteffectpar(10));
effdistorsionwindow->show();
break;
case 7:eqband=0;
- eqp0->value(eff->geteffectpar(0));
bandcounter->value(eqband);
bandcounter->do_callback();
- typechoice->value(eff->geteffectpar(10));
eqgraph->redraw();
- freqdial->value(eff->geteffectpar(11));
- gaindial->value(eff->geteffectpar(12));
- if (eff->geteffectpar(10)<6) gaindial->deactivate();
- qdial->value(eff->geteffectpar(13));
- stagescounter->value(eff->geteffectpar(14));
- eqgraph->init(eff);
effeqwindow->show();
break;
case 8:make_filter_window();
- dfp->value(eff->getpreset());
- dfp0->value(eff->geteffectpar(0));if (eff->insertion!=0) dfp0->label("D/W");
- dfp1->value(eff->geteffectpar(1));
- dfp2->value(eff->geteffectpar(2));
- dfp3->value(eff->geteffectpar(3));
- dfp4->value(eff->geteffectpar(4));
- dfp5->value(eff->geteffectpar(5));
- dfp6->value(eff->geteffectpar(6));
- dfp7->value(eff->geteffectpar(7));
- dfp8->value(eff->geteffectpar(8));
- dfp9->value(eff->geteffectpar(9));
-
effdynamicfilterwindow->show();
break;
@@ -1462,20 +1247,21 @@ switch(eff->geteffect()){
break;
};
-this->show();} {}
+this->show();} {selected
+ }
}
- Function {refresh()} {open
- } {
- code {refresh(eff);} {}
+ decl {int eqband;} {private local
+ }
+ decl {bool insertion;} {public local
+ }
+ decl {int efftype;} {public local
}
- decl {EffectMgr *eff;} {}
- decl {int eqband;} {}
}
-class SimpleEffUI {open : {public Fl_Group,public PresetsUI_}
+class SimpleEffUI {open : {public Fl_Osc_Group,public PresetsUI_}
} {
- Function {SimpleEffUI(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
- code {eff=NULL;} {}
+ Function {SimpleEffUI(int x,int y, int w, int h, const char *label=0):Fl_Osc_Group(x,y,w,h,label)} {} {
+ code {} {}
}
Function {~SimpleEffUI()} {} {
code {effnullwindow->hide();//delete (effnullwindow);
@@ -1488,29 +1274,26 @@ effdistorsionwindow->hide();//delete (effdistorsionwindow);
effeqwindow->hide();//delete (effeqwindow);
effdynamicfilterwindow->hide();//delete (effdynamicfilterwindow);} {}
}
- Function {make_null_window()} {open
- } {
+ Function {make_null_window()} {} {
Fl_Window effnullwindow {
label {No Effect} open
- xywh {1047 755 230 95} type Double box UP_BOX color 221 labelfont 1 labelsize 19 align 16
+ xywh {1047 824 230 95} type Double box UP_BOX color 221 labelfont 1 labelsize 19
code0 {set_module_parameters(o);}
class Fl_Group visible
} {}
}
- Function {make_reverb_window()} {open
- } {
+ Function {make_reverb_window()} {} {
Fl_Window effreverbwindow {
label Reverb open
- xywh {1047 463 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 align 25
+ xywh {1047 532 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19
code3 {set_module_parameters(o);}
class Fl_Group visible
} {
Fl_Choice revp {
label Preset
- callback {eff->changepreset((int)o->value());
-
-refresh(eff);}
xywh {10 15 90 15} down_box BORDER_BOX color 47 selection_color 7 labelfont 1 labelsize 10 align 5 textfont 1 textsize 10
+ code0 {o->init("preset");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label {Cathedral 1}
@@ -1567,43 +1350,42 @@ refresh(eff);}
}
Fl_Dial revp0 {
label Vol
- callback {eff->seteffectpar(0,(int) o->value());}
tooltip {Effect Volume} xywh {10 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter0");}
+ class Fl_Osc_Dial
}
Fl_Dial revp2 {
label Time
- callback {eff->seteffectpar(2,(int) o->value());}
tooltip {Duration of Reverb} xywh {45 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter2");}
+ class Fl_Osc_Dial
}
Fl_Dial revp3 {
label {I.del}
- callback {eff->seteffectpar(3,(int) o->value());}
tooltip {Initial Delay} xywh {85 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 when 4 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter3");}
+ class Fl_Osc_Dial
}
Fl_Dial revp9 {
label Damp
- callback {eff->seteffectpar(9,(int) o->value());}
tooltip Dampening xywh {120 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 minimum 64 maximum 127 step 1
- class WidgetPDial
+ code0 {o->init("parameter9");}
+ class Fl_Osc_Dial
}
}
}
- Function {make_echo_window()} {open
- } {
+ Function {make_echo_window()} {} {
Fl_Window effechowindow {
label Echo open
- xywh {428 823 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 align 25
+ xywh {437 881 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19
code3 {set_module_parameters(o);}
class Fl_Group visible
} {
Fl_Choice echop {
label Preset
- callback {eff->changepreset((int)o->value());
-refresh(eff);}
xywh {11 15 95 15} box UP_BOX down_box BORDER_BOX color 47 selection_color 7 labelfont 1 labelsize 10 align 5 textfont 1 textsize 10
+ code0 {o->init("preset");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label {Echo 1}
@@ -1644,37 +1426,36 @@ refresh(eff);}
}
Fl_Dial echop0 {
label Vol
- callback {eff->seteffectpar(0,(int) o->value());}
tooltip {Effect Volume} xywh {10 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter0");}
+ class Fl_Osc_Dial
}
Fl_Dial echop2 {
label Delay
- callback {eff->seteffectpar(2,(int) o->value());}
xywh {45 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 when 4 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter2");}
+ class Fl_Osc_Dial
}
Fl_Dial echop5 {
label {Fb.}
- callback {eff->seteffectpar(5,(int) o->value());}
tooltip Feedback xywh {80 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter5");}
+ class Fl_Osc_Dial
}
}
}
- Function {make_chorus_window()} {open
- } {
+ Function {make_chorus_window()} {} {
Fl_Window effchoruswindow {
label Chorus open
- xywh {719 588 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 align 25
+ xywh {728 657 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19
code3 {set_module_parameters(o);}
class Fl_Group visible
} {
Fl_Choice chorusp {
label Preset
- callback {eff->changepreset((int)o->value());
-refresh(eff);}
xywh {10 15 90 15} box UP_BOX down_box BORDER_BOX color 47 selection_color 7 labelfont 1 labelsize 10 align 5 textfont 1 textsize 10
+ code0 {o->init("preset");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label {Chorus 1}
@@ -1719,55 +1500,54 @@ refresh(eff);}
}
Fl_Dial chorusp0 {
label Vol
- callback {eff->seteffectpar(0,(int) o->value());}
tooltip {Effect Volume} xywh {10 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter0");}
+ class Fl_Osc_Dial
}
Fl_Dial chorusp2 {
label Freq
- callback {eff->seteffectpar(2,(int) o->value());}
tooltip {LFO Frequency} xywh {45 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter2");}
+ class Fl_Osc_Dial
}
Fl_Dial chorusp6 {
label Dpth
- callback {eff->seteffectpar(6,(int) o->value());}
tooltip Depth xywh {80 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter6");}
+ class Fl_Osc_Dial
}
Fl_Dial chorusp7 {
label Delay
- callback {eff->seteffectpar(7,(int) o->value());}
xywh {115 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter7");}
+ class Fl_Osc_Dial
}
Fl_Dial chorusp8 {
label Fb
- callback {eff->seteffectpar(8,(int) o->value());}
tooltip Feedback xywh {150 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter8");}
+ class Fl_Osc_Dial
}
Fl_Check_Button {} {
label Flange
- callback {eff->seteffectpar(10,(int) o->value());}
xywh {120 10 55 20} box THIN_UP_BOX down_box DOWN_BOX color 230 labelfont 1 labelsize 10 hide deactivate
- code0 {o->value(eff->geteffectpar(10));}
+ code0 {o->init("parameter10");}
+ class Fl_Osc_Check
}
}
}
- Function {make_phaser_window()} {open
- } {
+ Function {make_phaser_window()} {} {
Fl_Window effphaserwindow {
label Phaser open
- xywh {1047 831 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 align 25
+ xywh {1047 881 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19
code3 {set_module_parameters(o);}
class Fl_Group visible
} {
Fl_Choice phaserp {
label Preset
- callback {eff->changepreset((int)o->value());
-refresh(eff);}
xywh {10 15 90 15} box UP_BOX down_box BORDER_BOX color 47 selection_color 0 labelfont 1 labelsize 10 labelcolor 55 align 5 textfont 1 textsize 10 textcolor 7
+ code0 {o->init("preset");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label {Phaser 1}
@@ -1796,55 +1576,55 @@ refresh(eff);}
}
Fl_Dial phaserp0 {
label Vol
- callback {eff->seteffectpar(0,(int) o->value());}
tooltip {Effect Volume} xywh {10 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter0");}
+ class Fl_Osc_Dial
}
Fl_Dial phaserp2 {
label Freq
- callback {eff->seteffectpar(2,(int) o->value());}
tooltip {LFO frequency} xywh {45 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter2");}
+ class Fl_Osc_Dial
}
Fl_Dial phaserp5 {
label {St.df}
- callback {eff->seteffectpar(5,(int) o->value());}
tooltip {Left/Right Channel Phase Shift} xywh {80 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter5");}
+ class Fl_Osc_Dial
}
Fl_Dial phaserp6 {
label Dpth
- callback {eff->seteffectpar(6,(int) o->value());}
tooltip Depth xywh {115 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter6");}
+ class Fl_Osc_Dial
}
Fl_Dial phaserp7 {
label Fb
- callback {eff->seteffectpar(7,(int) o->value());}
tooltip Feedback xywh {150 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter7");}
+ class Fl_Osc_Dial
}
Fl_Counter phaserp8 {
label Stages
- callback {eff->seteffectpar(8,(int) o->value());}
xywh {185 55 35 15} type Simple labelfont 1 labelsize 11 minimum 0 maximum 127 step 1
code0 {o->range(1,MAX_PHASER_STAGES);}
+ code1 {o->init("parameter8");}
+ class Fl_Osc_Counter
}
}
}
- Function {make_alienwah_window()} {open
- } {
+ Function {make_alienwah_window()} {} {
Fl_Window effalienwahwindow {
label AlienWah open
- xywh {403 480 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 align 25
+ xywh {412 549 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19
code3 {set_module_parameters(o);}
class Fl_Group visible
} {
Fl_Choice awp {
label Preset
- callback {eff->changepreset((int)o->value());
-refresh(eff);}
xywh {10 15 90 15} box UP_BOX down_box BORDER_BOX color 47 selection_color 7 labelfont 1 labelsize 10 align 5 textfont 1 textsize 10
+ code0 {o->init("preset");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label {Alienwah 1}
@@ -1865,43 +1645,43 @@ refresh(eff);}
}
Fl_Dial awp0 {
label Vol
- callback {eff->seteffectpar(0,(int) o->value());}
tooltip {Effect Volume} xywh {10 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter0");}
+ class Fl_Osc_Dial
}
Fl_Dial awp2 {
label Freq
- callback {eff->seteffectpar(2,(int) o->value());}
tooltip {LFO frequency} xywh {45 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter2");}
+ class Fl_Osc_Dial
}
Fl_Dial awp6 {
label Dpth
- callback {eff->seteffectpar(6,(int) o->value());}
tooltip Depth xywh {85 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter6");}
+ class Fl_Osc_Dial
}
Fl_Counter awp8 {
label Delay
- callback {eff->seteffectpar(8,(int) o->value());}
xywh {125 55 35 15} type Simple labelfont 1 labelsize 11 minimum 0 maximum 127 step 1
code0 {o->range(1,MAX_ALIENWAH_DELAY);}
+ code1 {o->init("parameter8");}
+ class Fl_Osc_Counter
}
}
}
- Function {make_distorsion_window()} {open
- } {
+ Function {make_distorsion_window()} {} {
Fl_Window effdistorsionwindow {
label Distortion open
- xywh {353 881 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 align 25
+ xywh {88 881 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19
code3 {set_module_parameters(o);}
class Fl_Group visible
} {
Fl_Choice distp {
label Preset
- callback {eff->changepreset((int)o->value());
-refresh(eff);}
xywh {11 15 95 15} box UP_BOX down_box BORDER_BOX color 47 selection_color 7 labelfont 1 labelsize 10 align 5 textfont 1 textsize 10
+ code0 {o->init("preset");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label {Overdrive 1}
@@ -1930,32 +1710,33 @@ refresh(eff);}
}
Fl_Dial distp0 {
label Vol
- callback {eff->seteffectpar(0,(int) o->value());}
tooltip {Effect Volume} xywh {10 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter0");}
+ class Fl_Osc_Dial
}
Fl_Dial distp3 {
label Drive
- callback {eff->seteffectpar(3,(int) o->value());}
tooltip {Input amplification} xywh {45 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 when 4 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter3");}
+ class Fl_Osc_Dial
}
Fl_Dial distp4 {
label Level
- callback {eff->seteffectpar(4,(int) o->value());}
tooltip {Output Amplification} xywh {80 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter4");}
+ class Fl_Osc_Dial
}
Fl_Dial distp7 {
label LPF
- callback {eff->seteffectpar(7,(int) o->value());}
tooltip {Low Pass Filter} xywh {190 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter7");}
+ class Fl_Osc_Dial
}
Fl_Choice distp5 {
label Type
- callback {eff->seteffectpar(5,(int) o->value());}
xywh {120 50 60 20} box UP_BOX down_box BORDER_BOX labelfont 1 labelsize 11 align 2 textsize 10
+ code0 {o->init("parameter5");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label Atan
@@ -2016,11 +1797,10 @@ refresh(eff);}
}
}
}
- Function {make_eq_window()} {open
- } {
+ Function {make_eq_window()} {} {
Fl_Window effeqwindow {
label EQ open
- xywh {1047 881 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 align 25
+ xywh {1047 881 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19
code3 {set_module_parameters(o);}
class Fl_Group visible
} {
@@ -2028,74 +1808,59 @@ refresh(eff);}
label Band
callback {eqband=(int) o->value();
int npb=eqband*5+10;
-
-int type=eff->geteffectpar(npb);
-typechoice->value(type);
-
-if (type>6) gaindial->activate();
- else gaindial->deactivate();
-
-if (type==0) bandgroup->deactivate();
-else bandgroup->activate();
-
-int freq=eff->geteffectpar(npb+1);
-freqdial->value(freq);
-
-int gain=eff->geteffectpar(npb+2);
-gaindial->value(gain);
-
-int q=eff->geteffectpar(npb+3);
-qdial->value(q);
-
-int dbl=eff->geteffectpar(npb+4);
-stagescounter->value(dbl);}
+typechoice->oscMove("parameter"+to_s(npb));
+freqdial->oscMove("parameter"+to_s(npb+1));
+gaindial->oscMove("parameter"+to_s(npb+2));
+qdial->oscMove("parameter"+to_s(npb+3));
+stagescounter->oscMove("parameter"+to_s(npb+4));}
tooltip {Band no.} xywh {85 15 45 15} type Simple labelfont 1 labelsize 11 align 1 minimum 0 maximum 1 step 1 textfont 1 textsize 11
code0 {o->bounds(0,MAX_EQ_BANDS-1);}
}
Fl_Group bandgroup {
xywh {5 5 75 85} box UP_FRAME
- code0 {if (eff->geteffectpar(10)==0) o->deactivate();}
} {
Fl_Dial freqdial {
label Freq
- callback {int np=eqband*5+11;
-eff->seteffectpar(np,(int) o->value());
-eqgraph->redraw();}
+ callback {eqgraph->redraw();}
xywh {10 10 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 when 3 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter11");}
+ class Fl_Osc_Dial
}
Fl_Dial gaindial {
label Gain
- callback {int np=eqband*5+12;
-eff->seteffectpar(np,(int) o->value());
-eqgraph->redraw();}
+ callback {eqgraph->redraw();}
xywh {45 10 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 when 3 maximum 127 step 1
- class WidgetPDial
+ code0 {o->init("parameter12");}
+ class Fl_Osc_Dial
}
Fl_Dial qdial {
label Q
- callback {int np=eqband*5+13;
-eff->seteffectpar(np,(int) o->value());
-eqgraph->redraw();}
+ callback {eqgraph->redraw();}
tooltip {Bandwidth/Resonance} xywh {10 50 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 when 3 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter13");}
+ class Fl_Osc_Dial
}
Fl_Counter stagescounter {
label Stages
- callback {int np=eqband*5+14;
-eff->seteffectpar(np,(int) o->value());
-eqgraph->redraw();}
+ callback {eqgraph->redraw();}
tooltip {Additional filter stages} xywh {40 55 30 15} type Simple labelfont 1 labelsize 10 minimum 1 maximum 127 step 1 textfont 1 textsize 11
code0 {o->bounds(0,MAX_FILTER_STAGES-1);}
+ code1 {o->init("parameter14");}
+ class Fl_Osc_Counter
}
}
Fl_Choice typechoice {
label Type
- callback {int np=eqband*5+10;
-eff->seteffectpar(np,(int) o->value());
-bandcounter->do_callback();
+ callback {int type = o->value();
+if (type>6) gaindial->activate();
+ else gaindial->deactivate();
+
+if (type==0) bandgroup->deactivate();
+else bandgroup->activate();
eqgraph->redraw();}
tooltip Type xywh {135 15 40 15} down_box BORDER_BOX labelfont 1 labelsize 10 align 1 when 6 textsize 10
+ code0 {o->init("parameter10");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label OFF
@@ -2140,24 +1905,22 @@ eqgraph->redraw();}
}
Fl_Box eqgraph {
xywh {85 35 140 55} box BORDER_BOX color 50
- code0 {o->init(eff);}
- class EQGraph
+ class Fl_EQGraph
}
}
}
- Function {make_dynamicfilter_window()} {open
- } {
+ Function {make_dynamicfilter_window()} {} {
Fl_Window effdynamicfilterwindow {
label DynFilter open
- xywh {965 527 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19 align 25
+ xywh {974 596 230 100} type Double box UP_BOX color 51 labelfont 1 labelsize 19
code3 {set_module_parameters(o);}
class Fl_Group visible
} {
Fl_Choice dfp {
label Preset
- callback {eff->changepreset((int)o->value());
-refresh(eff);}
xywh {10 15 90 15} box UP_BOX down_box BORDER_BOX color 47 selection_color 7 labelfont 1 labelsize 10 align 5 textfont 1 textsize 10
+ code0 {o->init("preset");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label WahWah
@@ -2182,44 +1945,44 @@ refresh(eff);}
}
Fl_Dial dfp0 {
label Vol
- callback {eff->seteffectpar(0,(int) o->value());}
tooltip {Effect Volume} xywh {10 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter0");}
+ class Fl_Osc_Dial
}
Fl_Dial dfp2 {
label Freq
- callback {eff->seteffectpar(2,(int) o->value());}
tooltip {LFO frequency} xywh {45 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter2");}
+ class Fl_Osc_Dial
}
Fl_Dial dfp6 {
label LfoD
- callback {eff->seteffectpar(6,(int) o->value());}
tooltip {LFO depth} xywh {80 40 30 30} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter6");}
+ class Fl_Osc_Dial
}
Fl_Group {} {
xywh {115 40 65 45} box UP_FRAME
} {
Fl_Dial dfp7 {
label {A.S.}
- callback {eff->seteffectpar(7,(int) o->value());}
tooltip {how filter varies with amplitude} xywh {120 45 25 25} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter7");}
+ class Fl_Osc_Dial
}
Fl_Dial dfp9 {
label {A.M}
- callback {eff->seteffectpar(9,(int) o->value());}
tooltip {how quickly the filter varies with amplitude} xywh {150 45 25 25} box ROUND_UP_BOX labelfont 1 labelsize 11 maximum 127
- class WidgetPDial
+ code0 {o->init("parameter9");}
+ class Fl_Osc_Dial
}
}
}
}
- Function {init(EffectMgr *eff_)} {open
+ Function {init(bool ins_)} {open
} {
- code {eff=eff_;
-
+ code {efftype = 0;
+ insertion = ins_;
make_null_window();
make_reverb_window();
make_echo_window();
@@ -2241,13 +2004,14 @@ effphaserwindow->position(px,py);
effalienwahwindow->position(px,py);
effdistorsionwindow->position(px,py);
effeqwindow->position(px,py);
-effdynamicfilterwindow->position(px,py);
-
-refresh(eff);} {}
+effdynamicfilterwindow->position(px,py);} {}
}
- Function {refresh(EffectMgr *eff_)} {} {
- code {eff=eff_;
-this->hide();
+ Function {refresh()} {open
+ } {
+ code {this->hide();
+
+for(int i=0; i<32; ++i)
+ osc->requestValue(loc()+"parameter"+to_s(i));
effnullwindow->hide();
effreverbwindow->hide();
@@ -2261,81 +2025,41 @@ effdynamicfilterwindow->hide();
eqband=0;
+ if(insertion) {
+ revp0->label("D/W");
+ echop0->label("D/W");
+ chorusp0->label("D/W");
+ phaserp0->label("D/W");
+ awp0->label("D/W");
+ distp0->label("D/W");
+ dfp0->label("D/W");
+ }
-switch(eff->geteffect()){
+switch(efftype){
case 1:
- revp->value(eff->getpreset());
- revp0->value(eff->geteffectpar(0));if (eff->insertion!=0) revp0->label("D/W");
- revp2->value(eff->geteffectpar(2));
- revp3->value(eff->geteffectpar(3));
- revp9->value(eff->geteffectpar(9));
effreverbwindow->show();
break;
case 2:
- echop->value(eff->getpreset());
- echop0->value(eff->geteffectpar(0));if (eff->insertion!=0) echop0->label("D/W");
- echop2->value(eff->geteffectpar(2));
- echop5->value(eff->geteffectpar(5));
effechowindow->show();
break;
case 3:
- chorusp->value(eff->getpreset());
- chorusp0->value(eff->geteffectpar(0));if (eff->insertion!=0) chorusp0->label("D/W");
- chorusp2->value(eff->geteffectpar(2));
- chorusp6->value(eff->geteffectpar(6));
- chorusp7->value(eff->geteffectpar(7));
- chorusp8->value(eff->geteffectpar(8));
effchoruswindow->show();
break;
case 4:
- phaserp->value(eff->getpreset());
- phaserp0->value(eff->geteffectpar(0));if (eff->insertion!=0) phaserp0->label("D/W");
- phaserp2->value(eff->geteffectpar(2));
- phaserp5->value(eff->geteffectpar(5));
- phaserp6->value(eff->geteffectpar(6));
- phaserp7->value(eff->geteffectpar(7));
- phaserp8->value(eff->geteffectpar(8));
effphaserwindow->show();
break;
case 5:
- awp->value(eff->getpreset());
- awp0->value(eff->geteffectpar(0));if (eff->insertion!=0) awp0->label("D/W");
- awp2->value(eff->geteffectpar(2));
- awp6->value(eff->geteffectpar(6));
- awp8->value(eff->geteffectpar(8));
effalienwahwindow->show();
break;
case 6:
- distp->value(eff->getpreset());
- distp0->value(eff->geteffectpar(0));if (eff->insertion!=0) distp0->label("D/W");
- distp3->value(eff->geteffectpar(3));
- distp4->value(eff->geteffectpar(4));
- distp5->value(eff->geteffectpar(5));
- distp7->value(eff->geteffectpar(7));
effdistorsionwindow->show();
break;
case 7:
bandcounter->value(eqband);
bandcounter->do_callback();
- typechoice->value(eff->geteffectpar(10));
- eqgraph->redraw();
- freqdial->value(eff->geteffectpar(11));
- gaindial->value(eff->geteffectpar(12));
- if (eff->geteffectpar(10)<6) gaindial->deactivate();
- qdial->value(eff->geteffectpar(13));
- stagescounter->value(eff->geteffectpar(14));
- eqgraph->init(eff);
effeqwindow->show();
break;
case 8:
- dfp->value(eff->getpreset());
- dfp0->value(eff->geteffectpar(0));if (eff->insertion!=0) dfp0->label("D/W");
- dfp2->value(eff->geteffectpar(2));
- dfp6->value(eff->geteffectpar(6));
- dfp7->value(eff->geteffectpar(7));
- dfp9->value(eff->geteffectpar(9));
-
-
effdynamicfilterwindow->show();
break;
default:effnullwindow->show();
@@ -2344,9 +2068,10 @@ switch(eff->geteffect()){
this->show();} {}
}
- Function {refresh()} {} {
- code {refresh(eff);} {}
+ decl {int eqband;} {private local
+ }
+ decl {bool insertion;} {public local
+ }
+ decl {int efftype;} {public local
}
- decl {EffectMgr *eff;} {}
- decl {int eqband;} {}
}
diff --git a/src/UI/EnvelopeFreeEdit.cpp b/src/UI/EnvelopeFreeEdit.cpp
@@ -0,0 +1,217 @@
+#include "EnvelopeFreeEdit.h"
+#include "../Misc/Util.h"
+#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)
+{
+ pair=NULL;
+ currentpoint=-1;
+ cpx=0;
+ lastpoint=-1;
+}
+
+void EnvelopeFreeEdit::init(void)
+{
+ oscRegister("Penvpoints");
+ oscRegister("Penvdt");
+ oscRegister("Penvval");
+ oscRegister("Penvsustain");
+}
+
+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_)
+{
+ pair=pair_;
+}
+
+int EnvelopeFreeEdit::getpointx(int n) const
+{
+ const int lx=w()-10;
+ int npoints=Penvpoints;
+
+ float sum=0;
+ for(int i=1; i<npoints; ++i)
+ sum+=getdt(i)+1;
+
+ float sumbefore=0;//the sum of all points before the computed point
+ for(int i=1; i<=n; ++i)
+ sumbefore+=getdt(i)+1;
+
+ return (int) (sumbefore/(float) sum*lx);
+}
+
+int EnvelopeFreeEdit::getpointy(int n) const
+{
+ const int ly=h()-10;
+
+ return (1.0-Penvval[n]/127.0)*ly;
+}
+
+int EnvelopeFreeEdit::getnearest(int x,int y) const
+{
+ x-=5;y-=5;
+
+ int nearestpoint=0;
+ int nearestval=1000000;//a big value
+ for(int i=0; i<Penvpoints; ++i){
+ int distance=abs(x-getpointx(i))+abs(y-getpointy(i));
+ if (distance<nearestval) {
+ nearestpoint=i;
+ nearestval=distance;
+ }
+ }
+
+ return nearestpoint;
+}
+
+float EnvelopeFreeEdit::getdt(int i) const
+{
+ return EnvelopeParams::dt(Penvdt[i]);
+}
+
+void EnvelopeFreeEdit::draw(void)
+{
+ int ox=x(),oy=y(),lx=w(),ly=h();
+ //if (env->Pfreemode==0)
+ // env->converttofree();
+ const int npoints=Penvpoints;
+
+ if (active_r()) fl_color(FL_BLACK);
+ else fl_color(90,90,90);
+ if (!active_r()) currentpoint=-1;
+
+ fl_rectf(ox,oy,lx,ly);
+
+ //Margins
+ ox+=5;oy+=5;lx-=10;ly-=10;
+
+ //draw the lines
+ fl_color(FL_GRAY);
+
+ fl_line_style(FL_SOLID);
+ fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);
+
+ //draws the evelope points and lines
+ Fl_Color alb=FL_WHITE;
+ if (!active_r()) alb=fl_rgb_color(180,180,180);
+ fl_color(alb);
+ int oldxx=0,xx=0,oldyy=0,yy=getpointy(0);
+ fl_rectf(ox-3,oy+yy-3,6,6);
+ for (int i=1; i<npoints; ++i){
+ oldxx=xx;oldyy=yy;
+ xx=getpointx(i);yy=getpointy(i);
+ if (i==currentpoint) fl_color(FL_RED);
+ else fl_color(alb);
+ fl_line(ox+oldxx,oy+oldyy,ox+xx,oy+yy);
+ fl_rectf(ox+xx-3,oy+yy-3,6,6);
+ }
+
+ //draw the last moved point point (if exists)
+ if (lastpoint>=0){
+ fl_color(FL_CYAN);
+ fl_rectf(ox+getpointx(lastpoint)-5,oy+getpointy(lastpoint)-5,10,10);
+ }
+
+ //draw the sustain position
+ if(Penvsustain>0){
+ fl_color(FL_YELLOW);
+ xx=getpointx(Penvsustain);
+ fl_line(ox+xx,oy+0,ox+xx,oy+ly);
+ }
+
+ //Show the envelope duration and the current line duration
+ fl_font(FL_HELVETICA|FL_BOLD,10);
+ float time=0.0;
+ if (currentpoint<=0){
+ fl_color(alb);
+ for(int i=1; i<npoints; ++i)
+ time+=getdt(i);
+ } else {
+ fl_color(255,0,0);
+ time=getdt(currentpoint);
+ }
+ char tmpstr[20];
+ if (time<1000.0)
+ snprintf((char *)&tmpstr,20,"%.1fms",time);
+ else
+ snprintf((char *)&tmpstr,20,"%.2fs",time/1000.0);
+ fl_draw(tmpstr,ox+lx-20,oy+ly-10,20,10,FL_ALIGN_RIGHT,NULL,0);
+}
+
+int EnvelopeFreeEdit::handle(int event)
+{
+ const int x_=Fl::event_x()-x();
+ const int y_=Fl::event_y()-y();
+
+ if (event==FL_PUSH) {
+ currentpoint=getnearest(x_,y_);
+ cpx=x_;
+ cpdt=Penvdt[currentpoint];
+ lastpoint=currentpoint;
+ redraw();
+ if (pair)
+ pair->redraw();
+ }
+
+ if (event==FL_RELEASE){
+ currentpoint=-1;
+ redraw();
+ if (pair)
+ pair->redraw();
+ }
+
+ 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)
+ pair->redraw();
+ }
+
+
+ return 1;
+}
+
+void EnvelopeFreeEdit::update(void)
+{
+ oscWrite("Penvpoints");
+ oscWrite("Penvdt");
+ oscWrite("Penvval");
+ oscWrite("Penvsustain");
+}
diff --git a/src/UI/EnvelopeFreeEdit.h b/src/UI/EnvelopeFreeEdit.h
@@ -0,0 +1,48 @@
+#include <FL/Fl_Box.H>
+#include "../Params/EnvelopeParams.h"
+#include "Fl_Osc_Widget.H"
+
+
+//Define the types of envelope (TODO a properly located enum)
+//TODO check if ASR should be ASR *OR* ADR
+
+#define ENV_ADSR 1
+//#define ENV_ADSR 2
+#define ENV_ASR 3
+#define ENV_ADSR_FILTER 4
+#define ENV_ADSR_BW 5
+
+class EnvelopeFreeEdit : public Fl_Box, Fl_Osc_Widget
+{
+ public:
+ EnvelopeFreeEdit(int x,int y, int w, int h, const char *label=0);
+ void init(void);
+ void setpair(Fl_Box *pair_);
+ int handle(int event);
+
+ void draw(void);
+ 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;
+ int getnearest(int x,int y) const;
+ float getdt(int i) const;
+
+ Fl_Box *pair; //XXX what the heck is this?
+
+ //cursor state
+ int currentpoint, cpx, cpdt;
+
+ //The Points
+ char Penvdt[MAX_ENVELOPE_POINTS];
+ char Penvval[MAX_ENVELOPE_POINTS];
+ //The Sustain point
+ char Penvsustain;
+};
diff --git a/src/UI/EnvelopeUI.fl b/src/UI/EnvelopeUI.fl
@@ -1,239 +1,62 @@
# data file for the Fltk User Interface Designer (fluid)
-version 1.0110
+version 1.0302
header_name {.h}
code_name {.cc}
-decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {}
-
-decl {//License: GNU GPL version 2 or later} {}
-
-decl {\#include "WidgetPDial.h"} {public
+decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {private local
}
-decl {\#include <stdio.h>} {public
+decl {//License: GNU GPL version 2 or later} {private local
}
-decl {\#include <stdlib.h>} {public
+decl {\#include "Fl_Osc_Dial.H"} {public local
}
-decl {\#include "../globals.h"} {public
+decl {\#include "Fl_Osc_Check.H"} {public local
}
-decl {\#include <FL/Fl_Group.H>} {public
+decl {\#include "Fl_Osc_Button.H"} {public local
}
-decl {\#include "../Params/EnvelopeParams.h"} {public
+decl {\#include "Fl_Osc_Counter.H"} {public local
}
-decl {\#include <FL/Fl_Box.H>} {public
+decl {\#include <stdio.h>} {public local
}
-decl {\#include <FL/fl_draw.H>} {public
+decl {\#include <stdlib.h>} {public local
}
-decl {\#include <FL/fl_ask.H>} {public
+decl {\#include "../globals.h"} {public local
}
-decl {\#include "PresetsUI.h"} {public
+decl {\#include <FL/Fl_Group.H>} {public local
}
-decl {\#include "common.H"} {public
+decl {\#include "../Params/EnvelopeParams.h"} {public local
}
-class EnvelopeFreeEdit {: {public Fl_Box}
-} {
- Function {EnvelopeFreeEdit(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} {
- code {env=NULL;
-pair=NULL;} {}
- }
- Function {init(EnvelopeParams *env_)} {} {
- code {env=env_;
-oldx=-1;
-currentpoint=-1;
-cpx=0;
-lastpoint=-1;
-ctrldown=false;} {}
- }
- Function {setpair(Fl_Box *pair_)} {} {
- code {pair=pair_;} {}
- }
- Function {getpointx(int n)} {return_type int
- } {
- code {int lx=w()-10;
-int npoints=env->Penvpoints;
-
-float sum=0;
-for (int i=1;i<npoints;i++) sum+=env->getdt(i)+1;
-
-float sumbefore=0;//the sum of all points before the computed point
-for (int i=1;i<=n;i++) sumbefore+=env->getdt(i)+1;
-
-return((int) (sumbefore/(float) sum*lx));} {}
- }
- Function {getpointy(int n)} {return_type int
- } {
- code {int ly=h()-10;
-
-return((int) ((1.0-env->Penvval[n]/127.0)*ly));} {}
- }
- Function {getnearest(int x,int y)} {return_type int
- } {
- code {x-=5;y-=5;
-
-int nearestpoint=0;
-int nearestval=1000000;//a big value
-for (int i=0;i<env->Penvpoints;i++){
- int distance=abs(x-getpointx(i))+abs(y-getpointy(i));
- if (distance<nearestval) {
- nearestpoint=i;
- nearestval=distance;
- };
-};
-return(nearestpoint);} {}
- }
- Function {draw()} {private
- } {
- code {int ox=x(),oy=y(),lx=w(),ly=h();
-if (env->Pfreemode==0) env->converttofree();
-int npoints=env->Penvpoints;
-
-if (active_r()) fl_color(FL_BLACK);
- else fl_color(90,90,90);
-if (!active_r()) currentpoint=-1;
-
-fl_rectf(ox,oy,lx,ly);
-
-ox+=5;oy+=5;lx-=10;ly-=10;
-
-//draw the lines
-fl_color(FL_GRAY);
-
-fl_line_style(FL_SOLID);
-fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);
-
-//draws the evelope points and lines
-Fl_Color alb=FL_WHITE;
-if (!active_r()) alb=fl_rgb_color(180,180,180);
-fl_color(alb);
-int oldxx=0,xx=0,oldyy=0,yy=getpointy(0);
-fl_rectf(ox-3,oy+yy-3,6,6);
-for (int i=1;i<npoints;i++){
- oldxx=xx;oldyy=yy;
- xx=getpointx(i);yy=getpointy(i);
- if (i==currentpoint) fl_color(FL_RED);
- else fl_color(alb);
- fl_line(ox+oldxx,oy+oldyy,ox+xx,oy+yy);
- fl_rectf(ox+xx-3,oy+yy-3,6,6);
-};
-
-//draw the last moved point point (if exists)
-if (lastpoint>=0){
- fl_color(FL_CYAN);
- fl_rectf(ox+getpointx(lastpoint)-5,oy+getpointy(lastpoint)-5,10,10);
-};
-
-//draw the sustain position
-if (env->Penvsustain>0){
- fl_color(FL_YELLOW);
- xx=getpointx(env->Penvsustain);
- fl_line(ox+xx,oy+0,ox+xx,oy+ly);
-};
-
-//Show the envelope duration and the current line duration
-fl_font(FL_HELVETICA|FL_BOLD,10);
-float time=0.0;
-if (currentpoint<=0 && (!ctrldown||lastpoint <= 0)){
- fl_color(alb);
- for (int i=1;i<npoints;i++) time+=env->getdt(i);
-} else {
- fl_color(255,0,0);
- time=env->getdt(lastpoint);
-};
-char tmpstr[20];
-if (time<1000.0) snprintf((char *)&tmpstr,20,"%.1fms",time);
- else snprintf((char *)&tmpstr,20,"%.2fs",time/1000.0);
-fl_draw(tmpstr,ox+lx-20,oy+ly-10,20,10,FL_ALIGN_RIGHT,NULL,0);
-if (lastpoint>=0){
- snprintf((char *)&tmpstr,20,"%d", env->Penvval[lastpoint]);
- fl_draw(tmpstr,ox+lx-20,oy+ly-23,20,10,FL_ALIGN_RIGHT,NULL,0);
-}} {}
- }
- Function {handle(int event)} {return_type int
- } {
- code {int x_=Fl::event_x()-x();
-int y_=Fl::event_y()-y();
-
-// Some window magic makes us lose focus, so reassert it.
-if (event==FL_ENTER)
- Fl::focus(this);
-
-if ((event==FL_KEYDOWN || event==FL_KEYUP)){
- int key = Fl::event_key();
- if (key==FL_Control_L || key==FL_Control_R){
- ctrldown = (event==FL_KEYDOWN);
- redraw();
- if (pair!=NULL) pair->redraw();
- }
-}
-
-if (event==FL_MOUSEWHEEL && lastpoint>=0) {
- if (!ctrldown) {
- int ny=env->Penvval[lastpoint] - Fl::event_dy();
- env->Penvval[lastpoint]=ny < 0 ? 0 : ny > 127 ? 127 : ny;
- } else if (lastpoint > 0) {
- int newdt = Fl::event_dy() + env->Penvdt[lastpoint];
- env->Penvdt[lastpoint] = newdt < 0 ? 0 : newdt > 127 ? 127 : newdt;
- }
- redraw();
- if (pair!=NULL) pair->redraw();
-}
-
-if (event==FL_PUSH) {
- currentpoint=getnearest(x_,y_);
- cpx=x_;
- cpdt=env->Penvdt[currentpoint];
- lastpoint=currentpoint;
- redraw();
- if (pair!=NULL) pair->redraw();
-};
-
-if (event==FL_RELEASE){
- currentpoint=-1;
- redraw();
- if (pair!=NULL) pair->redraw();
-};
+decl {\#include <FL/Fl_Box.H>} {public local
+}
-if ((event==FL_DRAG)&&(currentpoint>=0)){
- int ny=127-(int) (y_*127.0/h());
- if (ny<0) ny=0;if (ny>127) ny=127;
- env->Penvval[currentpoint]=ny;
+decl {\#include <FL/fl_draw.H>} {public local
+}
- int dx=(int)((x_-cpx)*0.1);
- int newdt=cpdt+dx;
- if (newdt<0) newdt=0;if (newdt>127) newdt=127;
- if (currentpoint!=0) env->Penvdt[currentpoint]=newdt;
- else env->Penvdt[currentpoint]=0;
+decl {\#include <FL/fl_ask.H>} {public local
+}
- redraw();
- if (pair!=NULL) pair->redraw();
-};
+decl {\#include "PresetsUI.h"} {public local
+}
+decl {\#include "common.H"} {public local
+}
-return(1);} {}
- }
- decl {Fl_Box *pair;} {}
- decl {EnvelopeParams *env;} {}
- decl {int oldx,oldy;} {}
- decl {int currentpoint,cpx,cpdt;} {}
- decl {int lastpoint;} {public
- }
- decl {bool ctrldown;} {}
+decl {\#include "EnvelopeFreeEdit.h"} {public local
}
-class EnvelopeUI {open : {public Fl_Group,PresetsUI_}
+class EnvelopeUI {open : {public Fl_Osc_Group,PresetsUI_}
} {
- Function {EnvelopeUI(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
- code {env=NULL;
-freemodeeditwindow=NULL;
+ 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;
envADSR=NULL;
envASR=NULL;
envADSRfilter=NULL;
@@ -249,68 +72,57 @@ delete (freemodeeditwindow);} {}
Function {make_freemode_edit_window()} {open
} {
Fl_Window freemodeeditwindow {
- label Envelope
- xywh {702 269 575 180} type Double visible
+ label Envelope open
+ xywh {702 801 575 180} type Double
+ class Fl_Osc_Window visible
} {
- Fl_Box freeedit {
- label Envelope
- xywh {5 5 565 145} box FLAT_BOX color 0
- code0 {o->init(env);}
- class EnvelopeFreeEdit
+ Fl_Button {} {
+ label C
+ callback {/*presetsui->copy(env);*/}
+ xywh {465 160 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
+ code0 {freemodeeditwindow->osc = osc; freemodeeditwindow->base = loc();}
+ }
+ Fl_Button {} {
+ label P
+ callback {/*presetsui->paste(env,this);*/}
+ xywh {482 160 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
}
Fl_Button addpoint {
label {Add point}
- callback {int curpoint=freeedit->lastpoint;
-if (curpoint<0) return;
-//if (curpoint>=env->Penvpoints-1) return;
-if (env->Penvpoints>=MAX_ENVELOPE_POINTS) return;
-
-for (int i=env->Penvpoints;i>=curpoint+1;i--){
- env->Penvdt[i]=env->Penvdt[i-1];
- env->Penvval[i]=env->Penvval[i-1];
-};
-
-if (curpoint==0) {
- env->Penvdt[1]=64;
-};
-
-env->Penvpoints++;
-if (curpoint<=env->Penvsustain) env->Penvsustain++;
-
+ callback {
+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(env->Penvsustain);
-sustaincounter->maximum(env->Penvpoints-2);}
+//sustaincounter->value(Penvsustain);
+//sustaincounter->maximum(Penvpoints-2);}
xywh {115 155 80 20} box THIN_UP_BOX labelsize 11
- code0 {if (env->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 {int curpoint=freeedit->lastpoint;
-if (curpoint<1) return;
-if (curpoint>=env->Penvpoints-1) return;
-if (env->Penvpoints<=3) return;
-
-for (int i=curpoint+1;i<env->Penvpoints;i++){
- env->Penvdt[i-1]=env->Penvdt[i];
- env->Penvval[i-1]=env->Penvval[i];
-};
-
-env->Penvpoints--;
-
-if (curpoint<=env->Penvsustain) env->Penvsustain--;
-
-
+ callback {o->oscWrite("delPoint", "i", freeedit->lastpoint);
freeedit->lastpoint-=1;
-freeedit->redraw();
+freeedit->update();
envfree->redraw();
-
-sustaincounter->value(env->Penvsustain);
-sustaincounter->maximum(env->Penvpoints-2);}
+sustaincounter->update();
+//sustaincounter->value(Penvsustain);
+//sustaincounter->maximum(Penvpoints-2);}
xywh {200 155 80 20} box THIN_UP_BOX labelsize 11
- code0 {if (env->Pfreemode==0) o->hide();}
+ code0 {//if (Pfreemode==0) o->hide();}
+ class Fl_Osc_Button
}
Fl_Check_Button freemodebutton {
label FreeMode
@@ -322,18 +134,17 @@ freeedit->redraw();}
}
Fl_Check_Button forcedreleasecheck {
label frcR
- callback {env->Pforcedrelease=(int)o->value();}
tooltip {Forced Relase} xywh {410 165 40 15} down_box DOWN_BOX labelsize 10
- code0 {o->value(env->Pforcedrelease);}
- code1 {if (env->Pfreemode==0) o->hide();}
+ code0 {o->init("Pforcedrelease");}
+ code1 {//TODO if (Pfreemode==0) o->hide();}
+ class Fl_Osc_Check
}
Fl_Dial envstretchdial {
label {Str.}
- callback {env->Penvstretch=(int)o->value();}
tooltip {Envelope stretch (on lower notes make the envelope longer)} xywh {380 155 25 25} box ROUND_UP_BOX labelsize 10 align 4 maximum 127 step 1
- code0 {o->value(env->Penvstretch);}
- code1 {if (env->Pfreemode==0) o->hide();}
- class WidgetPDial
+ code0 {o->init("Penvstretch");}
+ code1 {//TODO if (Pfreemode==0) o->hide();}
+ class Fl_Osc_Dial
}
Fl_Button {} {
label Close
@@ -342,88 +153,84 @@ freeedit->redraw();}
}
Fl_Check_Button linearenvelopecheck {
label L
- callback {env->Plinearenvelope=(int)o->value();}
tooltip {Linear Envelope} xywh {410 151 30 15} down_box DOWN_BOX labelsize 10
- code0 {o->value(env->Plinearenvelope);}
- code1 {if ((env->Pfreemode==0)||(env->Envmode>2)) o->hide();}
+ code0 {o->init("Plinearenvelope");}
+ code1 {//TODO if ((Pfreemode==0)||(Envmode>2)) o->hide();}
+ class Fl_Osc_Check
}
Fl_Counter sustaincounter {
label Sust
- callback {env->Penvsustain=(int) o->value();
+ callback {//Penvsustain=(int) o->value();
freeedit->redraw();
envfree->redraw();}
tooltip {Sustain (0 is disabled)} xywh {315 155 40 15} type Simple labelsize 11 align 4 minimum 0 maximum 127 step 1
- code0 {o->value(env->Penvsustain);}
- code1 {if (env->Pfreemode==0) o->hide();}
- code2 {o->maximum(env->Penvpoints-2);}
- }
- Fl_Button {} {
- label C
- callback {presetsui->copy(env);}
- xywh {465 160 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
- }
- Fl_Button {} {
- label P
- callback {presetsui->paste(env,this);}
- xywh {482 160 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
+ 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 {344 788 205 70} type Double color 50 labelfont 1
- class Fl_Group visible
+ xywh {353 911 205 70} type Double color 50 labelfont 1
+ class Fl_Osc_Group visible
} {
Fl_Group {} {
label {Amplitude Envelope}
xywh {0 0 205 70} box UP_BOX color 223 labeltype ENGRAVED_LABEL labelsize 10 align 17
code0 {set_module_parameters(o);}
} {
+ Fl_Button {} {
+ label C
+ callback {/*presetsui->copy(env);*/}
+ xywh {150 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
+ }
+ Fl_Button {} {
+ label P
+ callback {/*presetsui->paste(env,this);*/}
+ xywh {167 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
+ }
Fl_Dial e1adt {
label {A.dt}
- callback {env->PA_dt=(int)o->value();
-freeedit->redraw();}
+ callback {freeedit->redraw();}
tooltip {Attack time} xywh {5 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->PA_dt);}
- class WidgetPDial
+ code0 {o->init("PA_dt");}
+ class Fl_Osc_Dial
}
Fl_Dial e1ddt {
label {D.dt}
- callback {env->PD_dt=(int)o->value();
-freeedit->redraw();}
+ callback {freeedit->redraw();}
tooltip {Decay time} xywh {40 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->PD_dt);}
- class WidgetPDial
+ code0 {o->init("PD_dt");}
+ class Fl_Osc_Dial
}
Fl_Dial e1rdt {
label {R.dt}
- callback {env->PR_dt=(int)o->value();
-freeedit->redraw();}
+ callback {freeedit->redraw();}
tooltip {Release time} xywh {110 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->PR_dt);}
- class WidgetPDial
+ code0 {o->init("PR_dt");}
+ class Fl_Osc_Dial
}
Fl_Dial e1sval {
label {S.val}
- callback {env->PS_val=(int)o->value();
-freeedit->redraw();}
+ callback {freeedit->redraw();}
tooltip {Sustain value} xywh {75 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->PS_val);}
- class WidgetPDial
+ code0 {o->init("PS_val");}
+ class Fl_Osc_Dial
}
Fl_Check_Button e1forcedrelease {
label frcR
- callback {env->Pforcedrelease=(int)o->value();}
tooltip {Forced Relase} xywh {180 35 20 15} down_box DOWN_BOX labelsize 10 align 6
- code0 {o->value(env->Pforcedrelease);}
+ code0 {o->init("Pforcedrelease");}
+ class Fl_Osc_Check
}
Fl_Dial e1envstretch {
label Stretch
- callback {env->Penvstretch=(int)o->value();}
tooltip {Envelope stretch (on lower notes makes the envelope longer)} xywh {145 25 25 25} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->Penvstretch);}
- class WidgetPDial
+ code0 {o->init("Penvstretch");}
+ class Fl_Osc_Dial
}
Fl_Button {} {
label E
@@ -432,88 +239,72 @@ freeedit->redraw();}
}
Fl_Check_Button e1linearenvelope {
label L
- callback {env->Plinearenvelope=(int)o->value();}
tooltip {The evelope is linear} xywh {180 20 15 15} down_box DOWN_BOX labelsize 10 align 4
- code0 {o->value(env->Plinearenvelope);}
- }
- Fl_Button {} {
- label C
- callback {presetsui->copy(env);}
- xywh {150 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
- }
- Fl_Button {} {
- label P
- callback {presetsui->paste(env,this);}
- xywh {167 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
+ code0 {o->init("Plinearenvelope");}
+ class Fl_Osc_Check
}
}
}
}
- Function {make_ASR_window()} {open
- } {
+ Function {make_ASR_window()} {} {
Fl_Window envASR {open
- xywh {648 667 210 70} type Double
- class Fl_Group visible
+ xywh {1067 911 210 70} type Double
+ class Fl_Osc_Group visible
} {
Fl_Group {} {
label {Frequency Envelope}
xywh {0 0 210 70} box UP_BOX color 223 labeltype ENGRAVED_LABEL labelsize 10 align 17
code0 {set_module_parameters(o);}
} {
+ Fl_Button {} {
+ label C
+ callback {/*presetsui->copy(env);*/}
+ xywh {155 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
+ }
+ Fl_Button {} {
+ label P
+ callback {/*presetsui->paste(env,this);*/}
+ xywh {172 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
+ }
Fl_Dial e2aval {
label {A.val}
- callback {env->PA_val=(int)o->value();
-freeedit->redraw();}
+ callback {freeedit->redraw();}
tooltip {Starting value} xywh {5 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->PA_val);}
- class WidgetPDial
+ code0 {o->init("PA_val");}
+ class Fl_Osc_Dial
}
Fl_Dial e2adt {
label {A.dt}
- callback {env->PA_dt=(int)o->value();
-freeedit->redraw();}
+ callback {freeedit->redraw();}
tooltip {Attack time} xywh {40 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->PA_dt);}
- class WidgetPDial
+ code0 {o->init("PA_dt");}
+ class Fl_Osc_Dial
}
Fl_Dial e2rval {
label {R.val}
- callback {env->PR_val=(int)o->value();
-freeedit->redraw();}
+ callback {freeedit->redraw();}
tooltip {Release value} xywh {110 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->PR_val);}
- class WidgetPDial
+ code0 {o->init("PR_val");}
+ class Fl_Osc_Dial
}
Fl_Dial e2rdt {
label {R.dt}
- callback {env->PR_dt=(int)o->value();
-freeedit->redraw();}
+ callback {freeedit->redraw();}
tooltip {Release time} xywh {75 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->PR_dt);}
- class WidgetPDial
+ code0 {o->init("PR_dt");}
+ class Fl_Osc_Dial
}
Fl_Dial e2envstretch {
label Stretch
- callback {env->Penvstretch=(int)o->value();}
tooltip {Envelope stretch (on lower notes makes the envelope longer)} xywh {145 25 25 25} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->Penvstretch);}
- class WidgetPDial
+ code0 {o->init("Penvstretch");}
+ class Fl_Osc_Dial
}
Fl_Check_Button e2forcedrelease {
label frcR
- callback {env->Pforcedrelease=(int)o->value();}
tooltip {Forced release} xywh {180 25 15 25} down_box DOWN_BOX labelsize 10 align 6
- code0 {o->value(env->Pforcedrelease);}
- }
- Fl_Button {} {
- label C
- callback {presetsui->copy(env);}
- xywh {155 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
- }
- Fl_Button {} {
- label P
- callback {presetsui->paste(env,this);}
- xywh {172 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
+ code0 {o->init("Pforcedrelease");}
+ class Fl_Osc_Check
}
}
Fl_Button {} {
@@ -523,162 +314,148 @@ freeedit->redraw();}
}
}
}
- Function {make_ADSRfilter_window()} {open
- } {
- Fl_Window envADSRfilter {open selected
- xywh {627 569 275 70} type Double color 50 labelfont 1
- class Fl_Group visible
+ Function {make_ADSRfilter_window()} {} {
+ Fl_Window envADSRfilter {open
+ xywh {1002 911 275 70} type Double color 50 labelfont 1
+ class Fl_Osc_Group visible
} {
Fl_Group {} {
label {Filter Envelope}
xywh {0 0 275 70} box UP_BOX color 223 labeltype ENGRAVED_LABEL labelsize 10 align 17
code0 {set_module_parameters(o);}
} {
+ Fl_Button {} {
+ label C
+ callback {/*presetsui->copy(env);*/}
+ xywh {220 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
+ }
+ Fl_Button {} {
+ label P
+ callback {/*presetsui->paste(env,this);*/}
+ xywh {237 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
+ }
Fl_Dial e3aval {
label {A.val}
- callback {env->PA_val=(int)o->value();
-freeedit->redraw();}
+ callback {freeedit->redraw();}
tooltip {Starting value} xywh {5 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->PA_val);}
- class WidgetPDial
+ code0 {o->init("PA_val");}
+ class Fl_Osc_Dial
}
Fl_Dial e3adt {
label {A.dt}
- callback {env->PA_dt=(int)o->value();
-freeedit->redraw();}
+ callback {freeedit->redraw();}
tooltip {Attack time} xywh {40 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->PA_dt);}
- class WidgetPDial
+ code0 {o->init("PA_dt");}
+ class Fl_Osc_Dial
}
Fl_Dial e3dval {
label {D.val}
- callback {env->PD_val=(int)o->value();
-freeedit->redraw();}
+ callback {freeedit->redraw();}
tooltip {decay value} xywh {75 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->PD_val);}
- class WidgetPDial
+ code0 {o->init("PD_val");}
+ class Fl_Osc_Dial
}
Fl_Dial e3ddt {
label {D.dt}
- callback {env->PD_dt=(int)o->value();
-freeedit->redraw();}
+ callback {freeedit->redraw();}
tooltip {decay time} xywh {110 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->PD_dt);}
- class WidgetPDial
+ code0 {o->init("PD_dt");}
+ class Fl_Osc_Dial
}
Fl_Dial e3rdt {
label {R.dt}
- callback {env->PR_dt=(int)o->value();
-freeedit->redraw();}
+ callback {freeedit->redraw();}
tooltip {Release time} xywh {145 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->PR_dt);}
- class WidgetPDial
+ code0 {o->init("PR_dt");}
+ class Fl_Osc_Dial
}
Fl_Dial e3rval {
label {R.val}
- callback {env->PR_val=(int)o->value();
-freeedit->redraw();}
+ callback {freeedit->redraw();}
tooltip {Release value} xywh {180 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->PR_val);}
- class WidgetPDial
+ code0 {o->init("PR_val");}
+ class Fl_Osc_Dial
}
Fl_Dial e3envstretch {
label Stretch
- callback {env->Penvstretch=(int)o->value();}
tooltip {Envelope stretch (on lower notes makes the envelope longer)} xywh {215 25 25 25} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->Penvstretch);}
- class WidgetPDial
+ code0 {o->init("Penvstretch");}
+ class Fl_Osc_Dial
}
Fl_Check_Button e3forcedrelease {
label frcR
- callback {env->Pforcedrelease=(int)o->value();}
tooltip {Forced Relase} xywh {250 30 15 20} down_box DOWN_BOX labelsize 10 align 6
- code0 {o->value(env->Pforcedrelease);}
+ code0 {o->init("Pforcedrelease");}
+ class Fl_Osc_Check
}
Fl_Button {} {
label E
callback {freemodeeditwindow->show();}
xywh {255 5 15 15} labelfont 1 labelsize 10
}
- Fl_Button {} {
- label C
- callback {presetsui->copy(env);}
- xywh {220 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
- }
- Fl_Button {} {
- label P
- callback {presetsui->paste(env,this);}
- xywh {237 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
- }
}
}
}
- Function {make_ASRbw_window()} {open
- } {
+ Function {make_ASRbw_window()} {} {
Fl_Window envASRbw {open
- xywh {362 642 210 70} type Double
+ xywh {371 911 210 70} type Double
code0 {set_module_parameters(o);}
- class Fl_Group visible
+ class Fl_Osc_Group visible
} {
Fl_Group {} {
label {BandWidth Envelope}
xywh {0 0 210 70} box UP_BOX color 223 labeltype ENGRAVED_LABEL labelsize 10 align 17
code0 {set_module_parameters(o);}
} {
+ Fl_Button {} {
+ label C
+ callback {/*presetsui->copy(env);*/}
+ xywh {155 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
+ }
+ Fl_Button {} {
+ label P
+ callback {/*presetsui->paste(env,this);*/}
+ xywh {172 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
+ }
Fl_Dial e4aval {
label {A.val}
- callback {env->PA_val=(int)o->value();
-freeedit->redraw();}
+ callback {freeedit->redraw();}
tooltip {Starting value} xywh {5 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->PA_val);}
- class WidgetPDial
+ code0 {o->init("PA_val");}
+ class Fl_Osc_Dial
}
Fl_Dial e4adt {
label {A.dt}
- callback {env->PA_dt=(int)o->value();
-freeedit->redraw();}
+ callback {freeedit->redraw();}
tooltip {Attack time} xywh {40 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->PA_dt);}
- class WidgetPDial
+ code0 {o->init("PA_dt");}
+ class Fl_Osc_Dial
}
Fl_Dial e4rval {
label {R.val}
- callback {env->PR_val=(int)o->value();
-freeedit->redraw();}
+ callback {freeedit->redraw();}
tooltip {Release value} xywh {110 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->PR_val);}
- class WidgetPDial
+ code0 {o->init("PR_val");}
+ class Fl_Osc_Dial
}
Fl_Dial e4rdt {
label {R.dt}
- callback {env->PR_dt=(int)o->value();
-freeedit->redraw();}
+ callback {freeedit->redraw();}
tooltip {Release time} xywh {75 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->PR_dt);}
- class WidgetPDial
+ code0 {o->init("PR_dt");}
+ class Fl_Osc_Dial
}
Fl_Dial e4envstretch {
label Stretch
- callback {env->Penvstretch=(int)o->value();}
tooltip {Envelope stretch (on lower notes makes the envelope longer)} xywh {145 25 25 25} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(env->Penvstretch);}
- class WidgetPDial
+ code0 {o->init("Penvstretch");}
+ class Fl_Osc_Dial
}
Fl_Check_Button e4forcedrelease {
label frcR
- callback {env->Pforcedrelease=(int)o->value();}
tooltip {Forced release} xywh {180 25 15 25} down_box DOWN_BOX labelsize 10 align 6
- code0 {o->value(env->Pforcedrelease);}
- }
- Fl_Button {} {
- label C
- callback {presetsui->copy(env);}
- xywh {155 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
- }
- Fl_Button {} {
- label P
- callback {presetsui->paste(env,this);}
- xywh {172 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
+ code0 {o->init("Pforcedrelease");}
+ class Fl_Osc_Check
}
}
Fl_Button {} {
@@ -688,46 +465,55 @@ freeedit->redraw();}
}
}
}
- Function {make_free_window()} {open
- } {
+ Function {make_free_window()} {} {
Fl_Window envfree {open
- xywh {376 436 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_Group visible
+ class Fl_Osc_Group visible
} {
Fl_Group envfreegroup {
label {Amplitude Envelope}
xywh {0 0 205 70} box UP_BOX color 223 labeltype ENGRAVED_LABEL labelsize 10 align 17 resizable
code0 {set_module_parameters(o);}
} {
+ Fl_Button {} {
+ label E
+ callback {freemodeeditwindow->show();}
+ xywh {185 5 15 15} labelfont 1 labelsize 10
+ }
Fl_Box freeeditsmall {
label Envelope
callback {envfree->redraw();}
xywh {5 20 195 45} box FLAT_BOX color 0 resizable
- code0 {o->init(env);}
+ code0 {o->init();}
class EnvelopeFreeEdit
}
Fl_Button {} {
- label E
- callback {freemodeeditwindow->show();}
- xywh {185 5 15 15} labelfont 1 labelsize 10
- }
- Fl_Button {} {
label C
- callback {presetsui->copy(env);}
+ callback {/*presetsui->copy(env);*/}
xywh {150 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
}
Fl_Button {} {
label P
- callback {presetsui->paste(env,this);}
+ callback {/*presetsui->paste(env,this);*/}
xywh {167 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
}
}
}
}
- Function {init(EnvelopeParams *env_)} {open
+ Function {init(int env_type, Fl_Osc_Interface *osc_, std::string base_, std::string ext_)} {open
} {
- code {env=env_;
+ code {osc = osc_;
+ base = base_;
+ ext = ext_;
+ Envmode = env_type;
+ Pfreemode = false;
+ Penvsustain = false;
+ Penvpoints = 3;
+ Penvstretch = 0;
+ Pforcedrelease = 0;
+ Plinearenvelope = 0;
+ assert(osc);
make_ADSR_window();
make_ASR_window();
make_ADSRfilter_window();
@@ -737,9 +523,9 @@ make_free_window();
make_freemode_edit_window();
envwindow=NULL;
-if (env->Envmode==3) envfreegroup->label("Frequency Envelope");
-if (env->Envmode==4) envfreegroup->label("Filter Envelope");
-if (env->Envmode==5) envfreegroup->label("Bandwidth Envelope");
+if(Envmode==3) envfreegroup->label("Frequency Envelope");
+if(Envmode==4) envfreegroup->label("Filter Envelope");
+if(Envmode==5) envfreegroup->label("Bandwidth Envelope");
freemodeeditwindow->label(this->label());
@@ -750,20 +536,27 @@ freeedit->setpair(freeeditsmall);
refresh();} {}
}
- Function {reinit()} {} {
- code {if (env->Pfreemode!=0){
- int answer=fl_choice("Disable the free mode of the Envelope?","No","Yes",NULL);
- if (env->Pfreemode!=0) freemodebutton->value(1);
- else freemodebutton->value(0);
- if (answer==0) return;
+ Function {rebase(std::string new_base)} {open
+ } {
+ 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);} {}
+ }
+ Function {reinit()} {open
+ } {
+ code {if(Pfreemode){
+ int answer=fl_choice("Disable the free mode of the Envelope?","No","Yes",NULL);
+ freemodebutton->value(Pfreemode);
+ if (answer==0)
+ return;
};
-if (env->Pfreemode==0) env->Pfreemode=1;
- else env->Pfreemode=0;
+Pfreemode = !Pfreemode;
hide();
-int winx=freemodeeditwindow->x();
-int winy=freemodeeditwindow->y();
+const int winx=freemodeeditwindow->x();
+const int winy=freemodeeditwindow->y();
freemodeeditwindow->hide();
@@ -781,38 +574,58 @@ show();
freemodeeditwindow->position(winx,winy);
freemodeeditwindow->show();
-if (env->Pfreemode!=0) {
+if (Pfreemode) {
freemodebutton->value(1);
addpoint->show();
deletepoint->show();
forcedreleasecheck->show();
-}else{
+ 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(env->Pfreemode);
-
-sustaincounter->value(env->Penvsustain);
-if (env->Pfreemode==0) sustaincounter->hide();
- else sustaincounter->show();
-sustaincounter->maximum(env->Penvpoints-2);
-
-envstretchdial->value(env->Penvstretch);
-if (env->Pfreemode==0) envstretchdial->hide();
- else envstretchdial->show();
+ code {freemodebutton->value(Pfreemode);
+
+ sustaincounter->value(Penvsustain);
+ sustaincounter->maximum(Penvpoints-2);
+
+ envstretchdial->value(Penvstretch);
+
+linearenvelopecheck->value(Plinearenvelope);
+
+//Conditionally display widgets
+ if(Pfreemode) {
+ freemodebutton->value(1);
+ addpoint->show();
+ deletepoint->show();
+ forcedreleasecheck->show();
+ sustaincounter->show();
+ envstretchdial->show();
+ } else {
+ freemodebutton->value(0);
+ addpoint->hide();
+ deletepoint->hide();
+ forcedreleasecheck->hide();
+ sustaincounter->hide();
+ envstretchdial->hide();
+ }
-linearenvelopecheck->value(env->Plinearenvelope);
-if ((env->Pfreemode==0)||(env->Envmode>2)) linearenvelopecheck->hide();
- else linearenvelopecheck->show();
+ if(Pfreemode || Envmode>2)
+ linearenvelopecheck->hide();
+ else
+ linearenvelopecheck->show();
-forcedreleasecheck->value(env->Pforcedrelease);
-if (env->Pfreemode==0) forcedreleasecheck->hide();
- else forcedreleasecheck->show();
+ forcedreleasecheck->value(Pforcedrelease);
if (env->Pfreemode==0){
addpoint->hide();
@@ -822,73 +635,25 @@ if (env->Pfreemode==0){
deletepoint->show();
}
-freeedit->redraw();
-
-if (env->Pfreemode==0){
- switch(env->Envmode){
- case(1):
- case(2):
- e1adt->value(env->PA_dt);
- e1ddt->value(env->PD_dt);
- e1sval->value(env->PS_val);
- e1rdt->value(env->PR_dt);
- e1envstretch->value(env->Penvstretch);
- e1linearenvelope->value(env->Plinearenvelope);
- e1forcedrelease->value(env->Pforcedrelease);
- break;
- case(3):
- e2aval->value(env->PA_val);
- e2adt->value(env->PA_dt);
- e2rdt->value(env->PR_dt);
- e2rval->value(env->PR_val);
- e2envstretch->value(env->Penvstretch);
- e2forcedrelease->value(env->Pforcedrelease);
- break;
- case(4):
- e3aval->value(env->PA_val);
- e3adt->value(env->PA_dt);
- e3dval->value(env->PD_val);
- e3ddt->value(env->PD_dt);
- e3rdt->value(env->PR_dt);
- e3rval->value(env->PR_val);
- e3envstretch->value(env->Penvstretch);
- e3forcedrelease->value(env->Pforcedrelease);
- break;
- case(5):
- e4aval->value(env->PA_val);
- e4adt->value(env->PA_dt);
- e4rdt->value(env->PR_dt);
- e4rval->value(env->PR_val);
- e4envstretch->value(env->Penvstretch);
- e4forcedrelease->value(env->Pforcedrelease);
- break;
- default:
- break;
- };
-}else{
- envfree->redraw();
-};
-
-
envADSR->hide();
envASR->hide();
envADSRfilter->hide();
envASRbw->hide();
envfree->hide();
-if (env->Pfreemode==0){
- switch(env->Envmode){
- case(1):
- case(2):
+if (Pfreemode==0){
+ switch(Envmode){
+ case 1:
+ case 2:
envwindow=envADSR;
break;
- case(3):
+ case 3:
envwindow=envASR;
break;
- case(4):
+ case 4:
envwindow=envADSRfilter;
break;
- case(5):
+ case 5:
envwindow=envASRbw;
break;
default:
@@ -898,10 +663,25 @@ if (env->Pfreemode==0){
envwindow=envfree;
};
+assert(envwindow);
envwindow->resize(this->x(),this->y(),this->w(),this->h());
envwindow->show();} {}
}
- decl {EnvelopeParams *env;} {}
- decl {Fl_Group *envwindow;} {}
+ decl {int Envmode;} {private local
+ }
+ decl {int Pfreemode;} {private local
+ }
+ decl {int Penvsustain;} {private local
+ }
+ decl {int Penvpoints;} {private local
+ }
+ decl {int Penvstretch;} {private local
+ }
+ decl {int Pforcedrelease;} {private local
+ }
+ decl {int Plinearenvelope;} {private local
+ }
+ decl {Fl_Group *envwindow;} {private local
+ }
}
diff --git a/src/UI/FilterUI.fl b/src/UI/FilterUI.fl
@@ -1,170 +1,74 @@
# data file for the Fltk User Interface Designer (fluid)
-version 1.0110
+version 1.0302
header_name {.h}
code_name {.cc}
-decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {}
-
-decl {//License: GNU GPL version 2 or later} {}
-
-decl {\#include "WidgetPDial.h"} {public
+decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {private local
}
-decl {\#include <cmath>} {}
-
-decl {\#include <stdio.h>} {global
+decl {//License: GNU GPL version 2 or later} {private local
}
-decl {\#include <stdlib.h>} {global
+decl {\#include "Fl_Osc_Dial.H"} {public local
}
-decl {\#include "../globals.h"} {public
+decl {\#include "Fl_Osc_Choice.H"} {public local
}
-decl {\#include <FL/Fl_Group.H>} {public
+decl {\#include "Fl_Osc_Check.H"} {public local
}
-decl {\#include "../Params/FilterParams.h"} {public
+decl {\#include "Fl_Osc_Counter.H"} {public local
}
-decl {\#include <FL/Fl_Box.H>} {public
+decl {\#include "Fl_Osc_Output.H"} {public local
}
-decl {\#include <FL/fl_draw.H>} {public
+decl {\#include "Fl_Osc_Slider.H"} {public local
}
-decl {\#include <FL/fl_ask.H>} {public
+decl {\#include <cmath>} {private local
}
-decl {\#include "PresetsUI.h"} {public
+decl {\#include <stdio.h>} {private global
}
-decl {\#include "common.H"} {public
+decl {\#include <stdlib.h>} {private global
}
-class FormantFilterGraph {open : {public Fl_Box}
-} {
- Function {FormantFilterGraph(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} {
- code {pars=NULL;
-nvowel=NULL;
-nformant=NULL;
-graphpoints=NULL;} {}
- }
- Function {init(FilterParams *pars_,int *nvowel_,int *nformant_)} {} {
- code {pars=pars_;
-nvowel=nvowel_;
-nformant=nformant_;
-oldx=-1;
-graphpoints=new float [w()];} {}
- }
- Function {draw_freq_line(float freq,int type)} {} {
- code {float freqx=pars->getfreqpos(freq);
-switch(type){
- case 0:fl_line_style(FL_SOLID);break;
- case 1:fl_line_style(FL_DOT);break;
- case 2:fl_line_style(FL_DASH);break;
-};
-
-
-if ((freqx>0.0)&&(freqx<1.0))
- fl_line(x()+(int) (freqx*w()),y(),
- x()+(int) (freqx*w()),y()+h());} {}
- }
- Function {draw()} {open
- } {
- code {int maxdB=30;
-int ox=x(),oy=y(),lx=w(),ly=h(),i,oiy;
-float freqx;
-
-fl_color(FL_BLACK);
-fl_rectf(ox,oy,lx,ly);
-
-
-//draw the lines
-fl_color(FL_GRAY);
-
-fl_line_style(FL_SOLID);
-//fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);
-
-freqx=pars->getfreqpos(1000.0);
-if ((freqx>0.0)&&(freqx<1.0))
- fl_line(ox+(int) (freqx*lx),oy,
- ox+(int) (freqx*lx),oy+ly);
-
-for (i=1;i<10;i++){
- if(i==1){
- draw_freq_line(i*100.0,0);
- draw_freq_line(i*1000.0,0);
- }else
- if (i==5){
- draw_freq_line(i*100.0,2);
- draw_freq_line(i*1000.0,2);
- }else{
- draw_freq_line(i*100.0,1);
- draw_freq_line(i*1000.0,1);
- };
-};
-
-draw_freq_line(10000.0,0);
-draw_freq_line(20000.0,1);
-
-fl_line_style(FL_DOT);
-int GY=10;if (ly<GY*3) GY=-1;
-for (i=1;i<GY;i++){
- int tmp=(int)(ly/(float)GY*i);
- fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
-};
+decl {\#include "../globals.h"} {public local
+}
-fl_color(FL_YELLOW);
-fl_font(FL_HELVETICA,10);
-if (*nformant<pars->Pnumformants){
- draw_freq_line(pars->getformantfreq(pars->Pvowels[*nvowel].formants[*nformant].freq),2);
+decl {\#include "../Misc/Util.h"} {public local
+}
-//show some information (like current formant frequency,amplitude)
- char tmpstr[20];
+decl {\#include <FL/Fl_Group.H>} {public local
+}
- snprintf(tmpstr,20,"%.2f kHz",pars->getformantfreq(pars->Pvowels[*nvowel].formants[*nformant].freq)*0.001);
- fl_draw(tmpstr,ox+1,oy+1,40,12,FL_ALIGN_LEFT,NULL,0);
+decl {\#include "../Params/FilterParams.h"} {public local
+}
- snprintf(tmpstr,20,"%d dB",(int)( rap2dB(1e-9 + pars->getformantamp(pars->Pvowels[*nvowel].formants[*nformant].amp)) + pars->getgain() ));
- fl_draw(tmpstr,ox+1,oy+15,40,12,FL_ALIGN_LEFT,NULL,0);
+decl {\#include <FL/Fl_Box.H>} {public local
+}
-};
+decl {\#include <FL/fl_draw.H>} {public local
+}
-//draw the data
+decl {\#include <FL/fl_ask.H>} {public local
+}
-fl_color(FL_RED);
-fl_line_style(FL_SOLID);
+decl {\#include "PresetsUI.h"} {public local
+}
-pars->formantfilterH(*nvowel,lx,graphpoints);
+decl {\#include "common.H"} {public local
+}
-fl_line_style( FL_SOLID, 2 );
-fl_begin_line();
-oiy=(int) ((graphpoints[0]/maxdB+1.0)*ly/2.0);
-for (i=1;i<lx;i++){
- double iy= ((graphpoints[i]/maxdB+1.0)*ly/2.0);
- if ((iy>=0)&&(oiy>=0)&&(iy<ly)&&(oiy<lx))
- fl_vertex(ox+i,oy+ly-iy);
- oiy=iy;
-};
-fl_end_line();
-fl_line_style(FL_SOLID,0);} {}
- }
- Function {~FormantFilterGraph()} {} {
- code {delete [] graphpoints;} {}
- }
- decl {FilterParams *pars;} {}
- decl {int oldx,oldy;} {}
- decl {int *nvowel,*nformant;} {}
- decl {float *graphpoints;} {}
+decl {\#include "FormantFilterGraph.H"} {public local
}
-class FilterUI {open : {public Fl_Group,PresetsUI_}
+class FilterUI {open : {public Fl_Osc_Group,PresetsUI_}
} {
- Function {FilterUI(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
- code {pars=NULL;
-velsnsamp=NULL;
-velsns=NULL;
-nvowel=0;nformant=0;nseqpos=0;} {}
+ Function {FilterUI(int x,int y, int w, int h, const char *label=0):Fl_Osc_Group(x,y,w,h,label)} {} {
+ code {nvowel=0;nformant=0;nseqpos=0;} {}
}
Function {~FilterUI()} {} {
code {filterui->hide();
@@ -176,9 +80,14 @@ delete (formantparswindow);} {}
Function {make_window()} {open
} {
Fl_Window filterui {open
- xywh {498 346 275 70} type Double color 50 labelfont 1
- class Fl_Group visible
+ xywh {516 484 275 70} type Double color 50 labelfont 1
+ class Fl_Osc_Group visible
} {
+ Fl_Button {} {
+ label P
+ callback {/*presetsui->paste(pars,this);*/}
+ xywh {203 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 7
+ }
Fl_Group filterparamswindow {
label {Filter Parameters}
xywh {0 0 275 75} box UP_FRAME color 183 labeltype ENGRAVED_LABEL labelsize 10 align 17
@@ -186,10 +95,9 @@ delete (formantparswindow);} {}
} {
Fl_Choice analogfiltertypechoice {
label FilterType
- callback {pars->Ptype=(int)o->value();
-pars->changed=true;}
tooltip {The Filter type} xywh {10 50 50 15} down_box BORDER_BOX labelsize 10 align 5 textsize 10
- code1 {o->value(pars->Ptype);}
+ code1 {o->init("Ptype");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label LPF1
@@ -230,10 +138,9 @@ pars->changed=true;}
}
Fl_Choice svfiltertypechoice {
label FilterType
- callback {pars->Ptype=(int)o->value();
-pars->changed=true;}
tooltip {The Filter type} xywh {10 50 50 15} down_box BORDER_BOX labelsize 10 align 5 textsize 10
- code1 {o->value(pars->Ptype);}
+ code1 {o->init("Ptype");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label 1LPF
@@ -254,10 +161,10 @@ pars->changed=true;}
}
Fl_Choice filtertype {
label Category
- callback {switchcategory((int)o->value());
-pars->changed=true;}
+ callback {refresh();}
tooltip {The Category of the Filter (Analog/Formantic/etc.)} xywh {10 20 60 15} down_box BORDER_BOX labelsize 10 align 5 textsize 10
- code0 {o->value(pars->Pcategory);}
+ code0 {o->init("Pcategory");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label Analog
@@ -274,55 +181,51 @@ pars->changed=true;}
}
Fl_Dial cfreqdial {
label {C.Freq}
- callback {pars->Pfreq=(int)o->value();}
tooltip {Center Frequency of the Filter or the base position in the vowel's sequence} xywh {75 25 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(pars->Pfreq);}
- class WidgetPDial
+ code0 {o->init("Pfreq");}
+ class Fl_Osc_Dial
}
Fl_Dial qdial {
label Q
- callback {pars->Pq=(int)o->value();
-formantfiltergraph->redraw();}
+ callback {formantfiltergraph->redraw();}
tooltip {Filter resonance or bandwidth} xywh {110 25 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(pars->Pq);}
- class WidgetPDial
+ code0 {o->init("Pq");}
+ class Fl_Osc_Dial
}
Fl_Dial freqtrdial {
label {freq.tr.}
- callback {pars->Pfreqtrack=(int) o->value();}
tooltip {Filter frequency tracking (left is negative, middle is 0, and right is positive)} xywh {215 25 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(pars->Pfreqtrack);}
- class WidgetPDial
+ code0 {o->init("Pfreqtrack");}
+ class Fl_Osc_Dial
}
Fl_Dial vsnsadial {
label {V.SnsA.}
- callback {if (velsnsamp!=NULL) *velsnsamp=(int)o->value();}
tooltip {Velocity sensing amount of the Filter} xywh {145 25 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- class WidgetPDial
+ code0 {if(!alt_root.empty()) o->alt_init(alt_root, "VelocityScale"); }
+ code1 {else {o->deactivate(); o->value(127);o->mark_dead();}}
+ class Fl_Osc_Dial
}
Fl_Dial vsnsdial {
label {V.Sns.}
- callback {if (velsns!=NULL) *velsns=(int)o->value();}
tooltip {Velocity Sensing Function of the Filter} xywh {180 25 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- class WidgetPDial
+ code0 {if(!alt_root.empty()) o->alt_init(alt_root, "VelocityScaleFunction"); }
+ code1 {else {o->deactivate(); o->value(127);o->mark_dead();}}
+ class Fl_Osc_Dial
}
Fl_Dial gaindial {
label gain
- callback {pars->Pgain=(int)o->value();
-formantfiltergraph->redraw();
-pars->changed=true;}
+ callback {formantfiltergraph->redraw();}
tooltip {Filter output gain/damp} xywh {250 35 20 20} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(pars->Pgain);}
- class WidgetPDial
+ code0 {o->init("Pgain");}
+ class Fl_Osc_Dial
}
Fl_Choice stcounter {
label St
- callback {pars->Pstages=(int)o->value();
-formantfiltergraph->redraw();
-pars->changed=true;} open
+ callback {formantfiltergraph->redraw();} open
tooltip {Filter stages (in order to increase dB/oct. value and the order of the filter)} xywh {235 5 35 15} down_box BORDER_BOX labelsize 10 textfont 1 textsize 10
code1 {for (int i=0;i<MAX_FILTER_STAGES;i++) {char tmp[10];snprintf(tmp,10,"%dx",i+1);o->add(tmp);};}
- code2 {o->value(pars->Pstages);}
+ code2 {o->init("Pstages");}
+ class Fl_Osc_Choice
} {}
}
Fl_Button editbutton {
@@ -332,12 +235,12 @@ pars->changed=true;} open
}
Fl_Button {} {
label C
- callback {presetsui->copyArray(pars);}
+ callback {/*presetsui->copyArray(pars);*/}
xywh {186 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
}
Fl_Button {} {
label P
- callback {presetsui->pasteArray(pars,this);}
+ callback {/*presetsui->pasteArray(pars,this);*/}
xywh {203 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
}
}
@@ -345,15 +248,25 @@ pars->changed=true;} open
Function {make_formant_window()} {open
} {
Fl_Window formantparswindow {
- label {Formant Filter Parameters} selected
- xywh {518 473 700 205} type Double visible
+ label {Formant Filter Parameters} open
+ xywh {536 611 700 205} type Double
+ class Fl_Osc_Window visible
} {
- Fl_Group {} {
+ Fl_Button {} {
+ label P
+ callback {/*presetsui->paste(pars,this,nvowel);*/}
+ xywh {665 25 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 7
+ code0 {formantparswindow->osc = osc;}
+ code1 {formantparswindow->base = loc();}
+ }
+ Fl_Group {} {open
xywh {485 47 105 113} box THIN_UP_BOX
+ class Fl_Osc_Group
} {
Fl_Counter {} {
label {Formant }
callback {nformant=(int) o->value();
+ formantparsgroup->rebase(loc()+"Pvowels"+to_s(nvowel)+"/Pformants"+to_s(nformant)+"/");
update_formant_window();
formantfiltergraph->redraw();}
xywh {545 80 40 15} type Simple labelfont 1 labelsize 10 align 4 minimum 0 maximum 127 step 1 textsize 10
@@ -363,142 +276,138 @@ formantfiltergraph->redraw();}
Fl_Counter {} {
label {Vowel no.}
callback {nvowel=(int) o->value();
+ formantparsgroup->rebase(loc()+"Pvowels"+to_s(nvowel)+"/Pformants"+to_s(nformant)+"/");
update_formant_window();
formantfiltergraph->redraw();}
xywh {545 55 40 20} type Simple labelfont 1 labelsize 10 align 4 minimum 0 maximum 127 step 1 textfont 1 textsize 11
code0 {o->bounds(0,FF_MAX_VOWELS-1);}
code1 {o->value(nvowel);}
}
- Fl_Group formantparsgroup {
+ Fl_Group formantparsgroup {open
xywh {490 105 95 50} box ENGRAVED_FRAME
+ class Fl_Osc_Group
} {
+ Fl_Box {} {
+ label dummy selected
+ xywh {515 130 35 16} hide deactivate
+ code0 {formantparsgroup->ext = "Pvowels0/Pformants0/";}
+ }
Fl_Dial formant_freq_dial {
label freq
- callback {pars->Pvowels[nvowel].formants[nformant].freq=(int) o->value();
-formantfiltergraph->redraw();
-pars->changed=true;}
+ callback {//pars->Pvowels[nvowel].formants[nformant].freq=(int) o->value();
+ formantfiltergraph->update();}
tooltip {Formant frequency} xywh {495 115 25 25} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- class WidgetPDial
+ code0 {//TODO get widget renaming working here!!!}
+ code1 {o->init("freq");}
+ class Fl_Osc_Dial
}
Fl_Dial formant_q_dial {
label Q
- callback {pars->Pvowels[nvowel].formants[nformant].q=(int) o->value();
-formantfiltergraph->redraw();
-pars->changed=true;}
+ callback {//pars->Pvowels[nvowel].formants[nformant].q=(int) o->value();
+formantfiltergraph->update();}
tooltip {Formant's Q} xywh {525 115 24 25} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- class WidgetPDial
+ code0 {o->init("q");}
+ class Fl_Osc_Dial
}
Fl_Dial formant_amp_dial {
label amp
- callback {pars->Pvowels[nvowel].formants[nformant].amp=(int) o->value();
-formantfiltergraph->redraw();
-pars->changed=true;}
+ callback {//pars->Pvowels[nvowel].formants[nformant].amp=(int) o->value();
+formantfiltergraph->update();}
tooltip {Formant amplitude} xywh {555 115 24 25} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- class WidgetPDial
+ code0 {o->init("amp");}
+ class Fl_Osc_Dial
}
}
}
- Fl_Group {} {
+ Fl_Group {} {open
xywh {590 47 100 113} box THIN_UP_BOX
+ class Fl_Osc_Group
} {
- Fl_Counter {} {
+ Fl_Counter sequencesize {
label {Seq.Size}
- callback {pars->Psequencesize=(int) o->value();
-update_formant_window();
-pars->changed=true;}
+ callback {update_formant_window();}
xywh {595 62 55 20} type Simple labelfont 1 labelsize 10 align 5 minimum 0 maximum 127 step 1 textfont 1 textsize 11
code0 {o->bounds(1,FF_MAX_SEQUENCE-1);}
- code1 {o->value(pars->Psequencesize);}
+ code1 {o->init("Psequencesize");}
+ class Fl_Osc_Counter
}
Fl_Counter {} {
label {S.Pos.}
- callback {nseqpos=(int) o->value();
-update_formant_window();
-pars->changed=true;}
+ callback {nseqpos = o->value();update_formant_window();}
tooltip {Current position from the sequence} xywh {595 97 40 15} type Simple labelfont 1 labelsize 10 align 9 minimum 0 maximum 127 step 1 textsize 10
code0 {o->bounds(0,FF_MAX_SEQUENCE-2);}
code1 {o->value(nseqpos);}
}
Fl_Counter vowel_counter {
label Vowel
- callback {pars->Psequence[nseqpos].nvowel=(int) o->value();
-pars->changed=true;}
+ callback {//pars->Psequence[nseqpos].nvowel=(int) o->value(); pars->changed=true;}
xywh {640 97 40 15} type Simple labelsize 10 align 1 minimum 0 maximum 127 step 1 textsize 10
code0 {o->bounds(0,FF_MAX_VOWELS-1);}
}
Fl_Check_Button {} {
label {Neg.Input}
- callback {pars->Psequencereversed=(int) o->value();
-pars->changed=true;}
tooltip {Negate the input from LFO/envelopes/etc.} xywh {625 132 60 20} down_box DOWN_BOX labelsize 10
- code0 {o->value(pars->Psequencereversed);}
+ code0 {o->init("Psequencereversed");}
+ class Fl_Osc_Check
}
Fl_Dial strchdial {
label Strch
- callback {pars->Psequencestretch=(int) o->value();
-pars->changed=true;}
tooltip {Sequence Stretch} xywh {595 130 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->Psequencestretch);}
- class WidgetPDial
+ code0 {o->init("Psequencestretch");}
+ class Fl_Osc_Dial
}
}
- Fl_Counter {} {
+ Fl_Counter numformants {
label {Num.Formants}
- callback {pars->Pnumformants=(int) o->value();
-update_formant_window();
-pars->changed=true;
+ callback {update_formant_window();
formantfiltergraph->redraw();}
xywh {485 15 65 20} type Simple labelfont 1 labelsize 10 align 5 minimum 0 maximum 127 step 1
code0 {o->bounds(1,FF_MAX_FORMANTS);}
- code1 {o->value(pars->Pnumformants);}
+ code1 {o->init("Pnumformants");}
+ class Fl_Osc_Counter
}
Fl_Dial frsldial {
label {Fr.Sl.}
- callback {pars->Pformantslowness=(int) o->value();
-pars->changed=true;}
tooltip {Formant's Slowness (Morphing)} xywh {565 15 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->Pformantslowness);}
- class WidgetPDial
+ code0 {o->init("Pformantslowness");}
+ class Fl_Osc_Dial
}
Fl_Value_Output centerfreqvo {
label {C.f.}
- callback {o->value(pars->getcenterfreq()/1000.0);}
+ callback {o->value(o->newvalue()/1000.0);}
tooltip {Center Frequency (kHz)} xywh {515 164 33 18} when 3 minimum 1 maximum 10 step 0.01 value 1 textfont 1
- code0 {o->value(pars->getcenterfreq()/1000.0);}
+ code0 {o->init("centerfreq");}
+ class Fl_Osc_Output
}
Fl_Value_Output octavesfreqvo {
label {Oct.}
- callback {o->value(pars->getoctavesfreq());}
+ callback {o->value(o->newvalue());}
tooltip {No. of octaves} xywh {515 182 33 18} when 3 minimum 1 maximum 127 step 1 value 5 textfont 1
- code0 {o->value(pars->getoctavesfreq());}
+ code0 {o->init("octavesfreq");}
+ class Fl_Osc_Output
}
Fl_Slider cfknob {
- callback {pars->Pcenterfreq=(int)o->value();
-centerfreqvo->do_callback();
-formantfiltergraph->redraw();
-pars->changed=true;}
+ callback {/*formantfiltergraph->redraw();*/}
xywh {551 167 84 15} type {Horz Knob} box FLAT_BOX maximum 127
- code0 {o->value(pars->Pcenterfreq);}
+ code0 {o->init("Pcenterfreq", 'c');}
+ class Fl_Osc_Slider
}
Fl_Slider octknob {
- callback {pars->Poctavesfreq=(int)o->value();
-octavesfreqvo->do_callback();
-formantfiltergraph->redraw();}
+ callback {/*formantfiltergraph->redraw();*/}
xywh {551 185 84 15} type {Horz Knob} box FLAT_BOX maximum 127
- code0 {o->value(pars->Poctavesfreq);}
+ code0 {o->init("Poctavesfreq", 'c');}
+ class Fl_Osc_Slider
}
Fl_Box formantfiltergraph {
xywh {5 5 475 195} box BORDER_BOX
- code0 {o->init(pars,&nvowel,&nformant);}
+ code0 {o->init(&nvowel,&nformant);}
class FormantFilterGraph
}
Fl_Dial wvknob {
label {Vw.Cl.}
- callback {pars->Pvowelclearness=(int) o->value();
-pars->changed=true;}
tooltip {Vowel "clearness" (how the mixed vowels are avoided)} xywh {600 15 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->Pvowelclearness);}
- class WidgetPDial
+ code0 {o->init("Pvowelclearness");}
+ class Fl_Osc_Dial
}
Fl_Button {} {
label Close
@@ -507,14 +416,9 @@ pars->changed=true;}
}
Fl_Button {} {
label C
- callback {presetsui->copy(pars,nvowel);}
+ callback {/*presetsui->copy(pars,nvowel);*/}
xywh {635 25 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
}
- Fl_Button {} {
- label P
- callback {presetsui->paste(pars,this,nvowel);}
- xywh {665 25 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
- }
Fl_Box {} {
label Vowel
xywh {635 10 55 15}
@@ -523,36 +427,29 @@ pars->changed=true;}
}
Function {update_formant_window()} {open
} {
- code {formant_freq_dial->value(pars->Pvowels[nvowel].formants[nformant].freq);
-formant_q_dial->value(pars->Pvowels[nvowel].formants[nformant].q);
-formant_amp_dial->value(pars->Pvowels[nvowel].formants[nformant].amp);
-if (nformant<pars->Pnumformants) formantparsgroup->activate();
+ code {//formant_freq_dial->value(pars->Pvowels[nvowel].formants[nformant].freq);
+//formant_q_dial->value(pars->Pvowels[nvowel].formants[nformant].q);
+//formant_amp_dial->value(pars->Pvowels[nvowel].formants[nformant].amp);
+if (nformant<numformants->value()) formantparsgroup->activate();
else formantparsgroup->deactivate();
-if (nseqpos<pars->Psequencesize) vowel_counter->activate();
+if (nseqpos<sequencesize->value()) vowel_counter->activate();
else vowel_counter->deactivate();
-vowel_counter->value(pars->Psequence[nseqpos].nvowel);} {}
+//vowel_counter->value(pars->Psequence[nseqpos].nvowel);} {}
}
- Function {refresh()} {} {
+ Function {refresh()} {open
+ } {
code {update_formant_window();
formantfiltergraph->redraw();
+const int Pcategory = filtertype->value();
+const int Ptype = analogfiltertypechoice->value();
-if (pars->Pcategory==2) svfiltertypechoice->value(pars->Ptype);
-if (pars->Pcategory==0) analogfiltertypechoice->value(pars->Ptype);
+if (Pcategory==2) svfiltertypechoice->value(Ptype);
+if (Pcategory==0) analogfiltertypechoice->value(Ptype);
-filtertype->value(pars->Pcategory);
-
-cfreqdial->value(pars->Pfreq);
-qdial->value(pars->Pq);
-
-freqtrdial->value(pars->Pfreqtrack);
-gaindial->value(pars->Pgain);
-
-stcounter->value(pars->Pstages);
-
-int categ=pars->Pcategory;
+const int categ=Pcategory;
if ((categ==0)||(categ==2)) {
if (categ==0) {
analogfiltertypechoice->show();
@@ -573,10 +470,22 @@ if ((categ==0)||(categ==2)) {
filterparamswindow->redraw();} {}
}
- Function {init(FilterParams *filterpars_,unsigned char *velsnsamp_,unsigned char *velsns_)} {} {
- code {pars=filterpars_;
-velsnsamp=velsnsamp_;
-velsns=velsns_;
+ Function {rebase(std::string new_base)} {open
+ } {
+ code {
+ printf("\\n\\n\\n\\nRABBIT HORSE\\n\\n\\n\\n");
+ printf("\\nNEW BASE: '%s'\\n", (new_base+ext).c_str());
+ Fl_Osc_Group::rebase(new_base);
+ formantparswindow->rebase(new_base+ext);
+ } {}
+ }
+ Function {init(std::string alt_root_, Fl_Osc_Interface *osc_, std::string base_, std::string ext_)} {} {
+ code {alt_root = alt_root_;
+osc = osc_;
+base = base_;
+ext = ext_;
+
+assert(osc);
make_window();
end();
@@ -585,19 +494,7 @@ make_formant_window();
filterui->resize(this->x(),this->y(),this->w(),this->h());
-
-if (velsnsamp==NULL){
- vsnsadial->deactivate();
- vsnsadial->value(127);
- } else vsnsadial->value(*velsnsamp);
-
-if (velsns==NULL){
- vsnsdial->deactivate();
- vsnsdial->value(127);
- } else vsnsdial->value(*velsns);
-
-switchcategory(pars->Pcategory);
-
+switchcategory(0);
formantparswindow->label(this->label());
@@ -605,16 +502,8 @@ update_formant_window();} {}
}
Function {switchcategory(int newcat)} {open
} {
- code {if (pars->Pcategory!=newcat){
- pars->Pgain=64;
- gaindial->value(64);
- analogfiltertypechoice->value(0);
- analogfiltertypechoice->do_callback();
- svfiltertypechoice->value(0);
- svfiltertypechoice->do_callback();
-};
-pars->Pcategory=newcat;
-
+ code {
+ //TODO update Pgain & filter type on switch Pgain=64;
refresh();} {}
}
Function {use_for_dynamic_filter()} {open
@@ -632,7 +521,8 @@ formant_q_dial->when(0);
formant_amp_dial->when(0);
strchdial->when(0);} {}
}
- decl {FilterParams *pars;} {}
- decl {unsigned char *velsnsamp,*velsns;} {}
- decl {int nvowel,nformant,nseqpos;} {}
+ decl {std::string alt_root;} {private local
+ }
+ decl {int nvowel,nformant,nseqpos;} {private local
+ }
}
diff --git a/src/UI/Fl_EQGraph.H b/src/UI/Fl_EQGraph.H
@@ -0,0 +1,28 @@
+#pragma once
+#include "Fl_Osc_Widget.H"
+#include <FL/Fl_Box.H>
+#include "../globals.h"
+
+class EffectMgr;
+class Fl_Osc_Interface;
+class Fl_EQGraph:public Fl_Box, public Fl_Osc_Widget
+{
+ public:
+ Fl_EQGraph(int x,int y, int w, int h, const char *label=0);
+ virtual ~Fl_EQGraph(void);
+ void draw(void);
+
+ void OSC_raw(const char *msg);
+ void update(void);
+
+ private:
+ void draw_freq_line(float freq,int type);
+
+ double getresponse(int maxy,float freq) const;
+
+ float getfreqx(float x) const;
+ float getfreqpos(float freq) const;
+
+ float num[MAX_EQ_BANDS*MAX_FILTER_STAGES*2+1];
+ float dem[MAX_EQ_BANDS*MAX_FILTER_STAGES*2+1];
+};
diff --git a/src/UI/Fl_EQGraph.cpp b/src/UI/Fl_EQGraph.cpp
@@ -0,0 +1,164 @@
+#include <FL/Fl.H>
+#include <FL/fl_draw.H>
+#include "Fl_EQGraph.H"
+#include "common.H"
+#include "../Effects/EffectMgr.h"
+#include "../globals.h"
+
+#include <rtosc/rtosc.h>
+
+#define MAX_DB 30
+
+Fl_EQGraph::Fl_EQGraph(int x,int y, int w, int h, const char *label)
+ :Fl_Box(x,y,w,h,label), Fl_Osc_Widget(this)
+{
+ memset(num, 0, sizeof(num));
+ memset(dem, 0, sizeof(dem));
+ num[0] = 1;
+ dem[0] = 1;
+ ext = "eq-coeffs";
+ oscRegister("eq-coeffs");
+}
+
+Fl_EQGraph::~Fl_EQGraph(void)
+{}
+
+void Fl_EQGraph::OSC_raw(const char *msg)
+{
+ memcpy(dem, rtosc_argument(msg, 0).b.data, sizeof(dem));
+ memcpy(num, rtosc_argument(msg, 1).b.data, sizeof(dem));
+ redraw();
+}
+
+void Fl_EQGraph::update(void)
+{
+ oscWrite("eq-coeffs");
+}
+
+void Fl_EQGraph::draw_freq_line(float freq, int type)
+{
+ fl_color(FL_GRAY);
+ float freqx=getfreqpos(freq);
+ switch(type){
+ case 0:if (active_r()) fl_color(FL_WHITE);
+ else fl_color(205,205,205);
+ fl_line_style(FL_SOLID);
+ break;
+ case 1:fl_line_style(FL_DOT);break;
+ case 2:fl_line_style(FL_DASH);break;
+ };
+
+
+ if ((freqx>0.0)&&(freqx<1.0))
+ fl_line(x()+(int) (freqx*w()),y(),
+ x()+(int) (freqx*w()),y()+h());
+}
+
+void Fl_EQGraph::draw(void)
+{
+ int ox=x(),oy=y(),lx=w(),ly=h(),i;
+ double iy,oiy;
+ float freqx;
+
+ if (active_r()) fl_color(fl_darker(FL_GRAY));
+ else fl_color(FL_GRAY);
+ fl_rectf(ox,oy,lx,ly);
+
+
+ //draw the lines
+ fl_color(fl_lighter(FL_GRAY));
+
+ fl_line_style(FL_SOLID);
+ fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);
+
+ freqx=getfreqpos(1000.0);
+ if ((freqx>0.0)&&(freqx<1.0))
+ fl_line(ox+(int) (freqx*lx),oy,
+ ox+(int) (freqx*lx),oy+ly);
+
+ for (i=1;i<10;i++) {
+ if(i==1) {
+ draw_freq_line(i*100.0,0);
+ draw_freq_line(i*1000.0,0);
+ } else
+ if (i==5) {
+ draw_freq_line(i*10.0,2);
+ draw_freq_line(i*100.0,2);
+ draw_freq_line(i*1000.0,2);
+ } else {
+ draw_freq_line(i*10.0,1);
+ draw_freq_line(i*100.0,1);
+ draw_freq_line(i*1000.0,1);
+ };
+ };
+
+ draw_freq_line(10000.0,0);
+ draw_freq_line(20000.0,1);
+
+
+ fl_line_style(FL_DOT);
+ int GY=6;if (ly<GY*3) GY=-1;
+ for (i=1;i<GY;i++){
+ int tmp=(int)(ly/(float)GY*i);
+ fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
+ };
+
+
+ //draw the frequency response
+ if (active_r()) fl_color(FL_YELLOW);
+ else fl_color(200,200,80);
+ fl_line_style(FL_SOLID,2);
+ //fl_color( fl_color_add_alpha( fl_color(), 127 ) );
+ oiy=getresponse(ly,getfreqx(0.0));
+ fl_begin_line();
+ for (i=1;i<lx;i++){
+ float frq=getfreqx(i/(float) lx);
+ if (frq>synth->samplerate/2) break;
+ iy=getresponse(ly,frq);
+ if ((oiy>=0) && (oiy<ly) &&
+ (iy>=0) && (iy<ly) )
+ fl_vertex(ox+i,oy+ly-iy);
+ oiy=iy;
+ };
+ fl_end_line();
+ fl_line_style(FL_SOLID,0);
+}
+
+/*
+ * For those not too familiar with digital filters, what is happening here is an
+ * evaluation of the filter's frequency response through the evaluation of
+ * H(z^{-1}) via z^{-1}=e^{j\omega}.
+ * This will yield a complex result which will indicate the phase and magnitude
+ * transformation of the input at the set frequency denoted by \omega
+ */
+double Fl_EQGraph::getresponse(int maxy,float freq) const
+{
+ const float angle = 2*PI*freq/synth->samplerate_f;
+ std::complex<float> num_res = 0;
+ std::complex<float> dem_res = 0;
+
+
+ for(int i = 0; i < MAX_EQ_BANDS*MAX_FILTER_STAGES*2+1; ++i) {
+ num_res += std::polar<float>(num[i], i*angle);
+ dem_res += std::polar<float>(dem[i], i*angle);
+ }
+
+ float dbresp=20*log(abs(num_res/dem_res))/log(10);
+
+ //rescale
+ return (int) ((dbresp/MAX_DB+1.0)*maxy/2.0);
+}
+
+float Fl_EQGraph::getfreqx(float x) const
+{
+ if(x>1.0)
+ x=1.0;
+ return(20.0*pow((float)1000.0,x));
+}
+
+float Fl_EQGraph::getfreqpos(float freq) const
+{
+ if(freq<0.00001)
+ freq=0.00001;
+ return(log(freq/20.0)/log(1000.0));
+}
diff --git a/src/UI/Fl_Osc_Button.H b/src/UI/Fl_Osc_Button.H
@@ -0,0 +1,24 @@
+#pragma once
+#include <FL/Fl_Button.H>
+#include "Fl_Osc_Widget.H"
+#include <string>
+
+using std::string; //yes this is bad form FIXME
+
+class Fl_Osc_Button:public Fl_Button, public Fl_Osc_Widget
+{
+
+ public:
+ Fl_Osc_Button(int X, int Y, int W, int H, const char *label);
+
+ virtual ~Fl_Osc_Button(void);
+ virtual void OSC_value(bool);
+
+ virtual void rebase(std::string) override;
+
+ //void init(Fl_Osc_Interface *, std::string);
+ //void init(std::string);
+
+ //void cb(void);
+ //static void _cb(Fl_Widget *w, void *);
+};
diff --git a/src/UI/Fl_Osc_Button.cpp b/src/UI/Fl_Osc_Button.cpp
@@ -0,0 +1,25 @@
+#include "Fl_Osc_Button.H"
+#include "Fl_Osc_Interface.h"
+#include "Fl_Osc_Pane.H"
+#include <cstdlib>
+#include <cstring>
+#include <cmath>
+#include <cassert>
+#include <sstream>
+
+Fl_Osc_Button::Fl_Osc_Button(int X, int Y, int W, int H, const char *label)
+ :Fl_Button(X,Y,W,H,label), Fl_Osc_Widget(this)
+{
+}
+
+Fl_Osc_Button::~Fl_Osc_Button(void)
+{}
+
+void Fl_Osc_Button::OSC_value(bool v)
+{
+ Fl_Button::value(v);
+}
+
+void Fl_Osc_Button::rebase(std::string)
+{
+}
diff --git a/src/UI/Fl_Osc_Check.H b/src/UI/Fl_Osc_Check.H
@@ -0,0 +1,28 @@
+#pragma once
+#include <FL/Fl_Check_Button.H>
+#include "Fl_Osc_Widget.H"
+#include <string>
+
+using std::string; //yes this is bad form FIXME
+
+class Fl_Osc_Check:public Fl_Check_Button, public Fl_Osc_Widget
+{
+
+ public:
+ Fl_Osc_Check(int X, int Y, int W, int H, const char *label = NULL);
+ //string name,
+ // const char *metadata);
+
+ virtual ~Fl_Osc_Check(void);
+ virtual void OSC_value(bool) override;
+ using Fl_Osc_Widget::OSC_value;
+
+ void init(std::string loc, char type = 'T');
+ void callback(Fl_Callback *cb, void *p = NULL);
+ void cb(void);
+ static void _cb(Fl_Widget *w, void *);
+ int is_osc;
+ private:
+ std::pair<Fl_Callback*, void*> cb_data;
+ char type;
+};
diff --git a/src/UI/Fl_Osc_Check.cpp b/src/UI/Fl_Osc_Check.cpp
@@ -0,0 +1,58 @@
+#include "Fl_Osc_Check.H"
+#include "Fl_Osc_Interface.h"
+#include "Fl_Osc_Pane.H"
+#include <cstdlib>
+#include <cstring>
+#include <cmath>
+#include <cassert>
+#include <sstream>
+
+Fl_Osc_Check::Fl_Osc_Check(int X, int Y, int W, int H, const char *label)
+ :Fl_Check_Button(X,Y,W,H,label), Fl_Osc_Widget(this), is_osc(false), cb_data(NULL, NULL)
+{
+ Fl_Check_Button::callback(Fl_Osc_Check::_cb);
+}
+
+Fl_Osc_Check::~Fl_Osc_Check(void)
+{}
+
+void Fl_Osc_Check::OSC_value(bool v)
+{
+ value(v);
+
+ is_osc = true;
+ if(cb_data.first)
+ cb_data.first(this, cb_data.second);
+ is_osc = false;
+}
+
+void Fl_Osc_Check::init(std::string path, char type)
+{
+ this->ext = path;
+ this->type = type;
+ oscRegister(path.c_str());
+}
+
+void Fl_Osc_Check::cb(void)
+{
+ //Order is significant for takeback style callbacks
+ if(cb_data.first)
+ cb_data.first(this, cb_data.second);
+
+
+ if(type == 'T')
+ oscWrite(ext, value() ? "T" : "F");
+ else
+ oscWrite(ext, "c", value());
+}
+
+void Fl_Osc_Check::callback(Fl_Callback *cb, void *p)
+{
+ cb_data.first = cb;
+ cb_data.second = p;
+}
+
+void Fl_Osc_Check::_cb(Fl_Widget *w, void *)
+{
+ static_cast<Fl_Osc_Check*>(w)->cb();
+}
diff --git a/src/UI/Fl_Osc_Choice.H b/src/UI/Fl_Osc_Choice.H
@@ -0,0 +1,27 @@
+#pragma once
+#include <FL/Fl_Choice.H>
+#include "Fl_Osc_Widget.H"
+#include <string>
+
+class Fl_Osc_Choice:public Fl_Choice, public Fl_Osc_Widget
+{
+
+ public:
+ Fl_Osc_Choice(int X, int Y, int W, int H, const char *label = NULL);
+ virtual ~Fl_Osc_Choice(void);
+ //Base is for braindead choices that don't actually start at zero
+ void init(std::string path, int base =0);
+
+
+ //void OSC_value(float);
+ void OSC_value(char);
+
+ //Refetch parameter information
+ void update(void);
+ void callback(Fl_Callback *cb, void *p = NULL);
+
+ void cb(void);
+ private:
+ int min;
+ std::pair<Fl_Callback*, void*> cb_data;
+};
diff --git a/src/UI/Fl_Osc_Choice.cpp b/src/UI/Fl_Osc_Choice.cpp
@@ -0,0 +1,73 @@
+#include "Fl_Osc_Choice.H"
+#include "Fl_Osc_Interface.h"
+#include "Fl_Osc_Pane.H"
+#include <cstdlib>
+#include <cstring>
+#include <cmath>
+#include <cassert>
+#include <sstream>
+
+static Fl_Osc_Pane *fetch_osc_pane(Fl_Widget *w)
+{
+ if(!w)
+ return NULL;
+
+ Fl_Osc_Pane *pane = dynamic_cast<Fl_Osc_Pane*>(w->parent());
+ if(pane)
+ return pane;
+ return fetch_osc_pane(w->parent());
+}
+
+static void callback_fn(Fl_Widget *w, void *v)
+{
+ ((Fl_Osc_Choice*)w)->cb();
+}
+
+Fl_Osc_Choice::Fl_Osc_Choice(int X, int Y, int W, int H, const char *label)
+ :Fl_Choice(X,Y,W,H, label), Fl_Osc_Widget(this), cb_data(NULL, NULL)
+{
+ min = 0;
+ Fl_Choice::callback(callback_fn, NULL);
+}
+
+void Fl_Osc_Choice::init(std::string path_, int base)
+{
+ min = base;
+ ext = path_;
+ Fl_Osc_Pane *pane = fetch_osc_pane(this);
+ assert(pane);
+ assert(pane->osc);
+ osc = pane->osc;
+ oscRegister(path_.c_str());
+};
+
+Fl_Osc_Choice::~Fl_Osc_Choice(void)
+{}
+
+void Fl_Osc_Choice::callback(Fl_Callback *cb, void *p)
+{
+ cb_data.first = cb;
+ cb_data.second = p;
+}
+
+void Fl_Osc_Choice::OSC_value(char v)
+{
+ value(v-min);
+ if(cb_data.first)
+ cb_data.first(this, cb_data.second);
+}
+
+void Fl_Osc_Choice::cb(void)
+{
+ assert(osc);
+ oscWrite(ext, "c", value()+min);
+ if(cb_data.first)
+ cb_data.first(this, cb_data.second);
+}
+
+void Fl_Osc_Choice::update(void)
+{
+ assert(osc);
+ oscWrite(ext);
+}
+
diff --git a/src/UI/Fl_Osc_Counter.H b/src/UI/Fl_Osc_Counter.H
@@ -0,0 +1,23 @@
+#pragma once
+#include <FL/Fl_Counter.H>
+#include "Fl_Osc_Widget.H"
+#include <string>
+
+class Fl_Osc_Counter: public Fl_Counter, public Fl_Osc_Widget
+{
+ public:
+ Fl_Osc_Counter(int x, int y, int w, int h, const char *label=0);
+ void init(const char *path_, char type_ = 'c');
+ void OSC_value(char);
+ void OSC_value(int);
+ using Fl_Osc_Widget::OSC_value;
+
+ //Refetch parameters
+ void update(void);
+ void callback(Fl_Callback *cb, void *p = NULL);
+
+ void cb(void);
+ char cb_type;
+ private:
+ std::pair<Fl_Callback*, void*> cb_data;
+};
diff --git a/src/UI/Fl_Osc_Counter.cpp b/src/UI/Fl_Osc_Counter.cpp
@@ -0,0 +1,53 @@
+#include "Fl_Osc_Counter.H"
+
+static void callback_fn(Fl_Widget *w, void *)
+{
+ ((Fl_Osc_Counter*)w)->cb();
+}
+
+Fl_Osc_Counter::Fl_Osc_Counter(int x, int y, int w, int h, const char *label)
+ :Fl_Counter(x,y,w,h,label), Fl_Osc_Widget(this)
+{
+ Fl_Counter::callback(callback_fn);
+}
+
+void Fl_Osc_Counter::update(void)
+{
+ oscWrite(ext);
+}
+
+void Fl_Osc_Counter::init(const char *path_, char type_)
+{
+ oscRegister(path_);
+ ext = path_;
+ cb_type = type_;
+}
+
+void Fl_Osc_Counter::callback(Fl_Callback *cb, void *p)
+{
+ cb_data.first = cb;
+ cb_data.second = p;
+}
+
+void Fl_Osc_Counter::OSC_value(int v)
+{
+ value(v);
+}
+
+void Fl_Osc_Counter::OSC_value(char v)
+{
+ value(v);
+}
+
+void Fl_Osc_Counter::cb(void)
+{
+ assert(osc);
+
+ if(cb_type == 'c')
+ oscWrite(ext, "c", (char)(value()));
+ else
+ oscWrite(ext, "i", (int)value());
+
+ if(cb_data.first)
+ cb_data.first(this, cb_data.second);
+}
diff --git a/src/UI/Fl_Osc_Dial.H b/src/UI/Fl_Osc_Dial.H
@@ -0,0 +1,37 @@
+#pragma once
+#include <FL/Fl_Dial.H>
+#include "WidgetPDial.h"
+#include "Fl_Osc_Widget.H"
+#include <string>
+
+class Fl_Osc_Dial:public WidgetPDial, public Fl_Osc_Widget
+{
+
+ public:
+ Fl_Osc_Dial(int X, int Y, int W, int H, const char *label = NULL);
+ virtual ~Fl_Osc_Dial(void);
+
+ //Hack to get non-local controls up and running
+ void alt_init(std::string base, std::string path_);
+
+
+ //Normal Initialization
+ void init(std::string path);
+ //void OSC_value(float);
+ void OSC_value(int);
+ void OSC_value(char);
+ using Fl_Osc_Widget::OSC_value;
+
+ //Refetch parameter information
+ void update(void);
+ void callback(Fl_Callback *cb, void *p = NULL);
+
+ void mark_dead(void);
+ virtual void rebase(std::string new_base) override;
+
+ void cb(void);
+ private:
+ bool alt_style;
+ bool dead;
+ std::pair<Fl_Callback*, void*> cb_data;
+};
diff --git a/src/UI/Fl_Osc_Dial.cpp b/src/UI/Fl_Osc_Dial.cpp
@@ -0,0 +1,130 @@
+#include "Fl_Osc_Dial.H"
+#include "Fl_Osc_Interface.h"
+#include "Fl_Osc_Pane.H"
+#include <cstdlib>
+#include <cstring>
+#include <cmath>
+#include <cassert>
+#include <sstream>
+
+static void callback_fn(Fl_Widget *w, void *)
+{
+ ((Fl_Osc_Dial*)w)->cb();
+}
+
+Fl_Osc_Pane *fetch_osc_pane(Fl_Widget *w)
+{
+ if(!w)
+ return NULL;
+
+ Fl_Osc_Pane *pane = dynamic_cast<Fl_Osc_Pane*>(w->parent());
+ if(pane)
+ return pane;
+ return fetch_osc_pane(w->parent());
+}
+
+Fl_Osc_Dial::Fl_Osc_Dial(int X, int Y, int W, int H, const char *label)
+ :WidgetPDial(X,Y,W,H, label), Fl_Osc_Widget(this), alt_style(false), dead(false)
+{
+ bounds(0.0, 127.0f);
+ WidgetPDial::callback(callback_fn);
+}
+
+
+void Fl_Osc_Dial::init(std::string path_)
+{
+ assert(osc);
+ ext = path_;
+ oscRegister(path_.c_str());
+};
+
+void Fl_Osc_Dial::alt_init(std::string base, std::string path_)
+{
+ Fl_Osc_Pane *pane = fetch_osc_pane(this);
+ assert(pane);
+ osc = pane->osc;
+ assert(osc);
+ loc = base;
+ oscRegister(path_.c_str());
+ ext = path_;
+ alt_style = true;
+}
+
+Fl_Osc_Dial::~Fl_Osc_Dial(void)
+{}
+
+void Fl_Osc_Dial::callback(Fl_Callback *cb, void *p)
+{
+ cb_data.first = cb;
+ cb_data.second = p;
+}
+
+void Fl_Osc_Dial::OSC_value(int v)
+{
+ value(v+minimum());
+}
+
+void Fl_Osc_Dial::OSC_value(char v)
+{
+ value(v+minimum());
+}
+
+void Fl_Osc_Dial::update(void)
+{
+ osc->requestValue(loc+ext);
+}
+
+void Fl_Osc_Dial::cb(void)
+{
+ assert(osc);
+
+ if((maximum()-minimum()) == 127 || (maximum()-minimum()) == 255)
+ oscWrite(ext, "c", (char)(value()-minimum()));
+ else
+ oscWrite(ext, "i", (int)(value()-minimum()));
+
+ if(cb_data.first)
+ cb_data.first(this, cb_data.second);
+}
+
+void Fl_Osc_Dial::mark_dead(void)
+{
+ dead = true;
+}
+
+
+void Fl_Osc_Dial::rebase(std::string new_base)
+{
+ if(dead)
+ return;
+ if(!alt_style) {
+ Fl_Osc_Widget::rebase(new_base);
+ return;
+ }
+
+ //ok, for a simple hack here lets just assume that there is one branch
+ //missing
+ int depth = 0;
+ for(int i=0; i<(int)loc.size(); ++i)
+ depth += loc[i] == '/';
+ int match_depth = 0;
+ int match_pos = 0;
+ for(int i=0; i<(int)new_base.size(); ++i) {
+ match_depth += new_base[i] == '/';
+ if(match_depth == depth) {
+ match_pos = i;
+ break;
+ }
+ }
+
+ if(match_pos == 0) {
+ //well, that didn't work
+ assert(!"good enough hack");
+ }
+
+ std::string new_loc = new_base.substr(0, match_pos+1);
+ printf("Moving '%s' to\n", (loc+ext).c_str());
+ printf(" '%s'\n", (new_loc+ext).c_str());
+ oscMove(loc+ext, new_loc+ext);
+ loc = new_loc;
+}
diff --git a/src/UI/Fl_Osc_DialF.H b/src/UI/Fl_Osc_DialF.H
@@ -0,0 +1,23 @@
+#pragma once
+#include <FL/Fl_Dial.H>
+#include "WidgetPDial.h"
+#include "Fl_Osc_Widget.H"
+#include <string>
+
+class Fl_Osc_DialF:public WidgetPDial, Fl_Osc_Widget
+{
+
+ public:
+ Fl_Osc_DialF(int X, int Y, int W, int H, const char *label = NULL);
+ virtual ~Fl_Osc_DialF(void);
+ void init(const char *path);
+ void OSC_value(float);
+
+ //Refetch parameter information
+ void update(void);
+ void callback(Fl_Callback *cb, void *p = NULL);
+
+ void cb(void);
+ private:
+ std::pair<Fl_Callback*, void*> cb_data;
+};
diff --git a/src/UI/Fl_Osc_DialF.cpp b/src/UI/Fl_Osc_DialF.cpp
@@ -0,0 +1,85 @@
+#include "Fl_Osc_DialF.H"
+#include "Fl_Osc_Interface.h"
+#include "Fl_Osc_Pane.H"
+#include <cstdlib>
+#include <cstring>
+#include <cmath>
+#include <cassert>
+#include <sstream>
+
+template<typename A, typename B>
+B string_cast(const A &a)
+{
+ std::stringstream s;
+ s.precision(3);
+ B b;
+ s << " " << a << " ";
+ s >> b;
+ return b;
+}
+
+static void callback_fn(Fl_Widget *w, void *v)
+{
+ ((Fl_Osc_DialF*)w)->cb();
+}
+
+static Fl_Osc_Pane *fetch_osc_pane(Fl_Widget *w)
+{
+ if(!w)
+ return NULL;
+
+ Fl_Osc_Pane *pane = dynamic_cast<Fl_Osc_Pane*>(w->parent());
+ if(pane)
+ return pane;
+ return fetch_osc_pane(w->parent());
+}
+
+Fl_Osc_DialF::Fl_Osc_DialF(int X, int Y, int W, int H, const char *label)
+ :WidgetPDial(X,Y,W,H, label), Fl_Osc_Widget()
+{
+ //bounds(0.0, 127.0f);
+ WidgetPDial::callback(callback_fn);
+}
+
+
+void Fl_Osc_DialF::init(const char *path)
+{
+ Fl_Osc_Pane *pane = fetch_osc_pane(this);
+ assert(pane);
+ osc = pane->osc;
+ ext = path;
+ loc = pane->base;
+ oscRegister(path);
+};
+
+Fl_Osc_DialF::~Fl_Osc_DialF(void)
+{}
+
+void Fl_Osc_DialF::callback(Fl_Callback *cb, void *p)
+{
+ cb_data.first = cb;
+ cb_data.second = p;
+}
+
+void Fl_Osc_DialF::OSC_value(float v)
+{
+ value(v);
+}
+
+void Fl_Osc_DialF::update(void)
+{
+ oscWrite(ext);
+}
+
+void Fl_Osc_DialF::cb(void)
+{
+ assert(osc);
+
+ oscWrite(ext, "f", (float)value());
+
+ if(cb_data.first)
+ cb_data.first(this, cb_data.second);
+// label_str = string_cast<float,string>(val);
+// label(" ");
+// label(label_str.c_str());
+}
diff --git a/src/UI/Fl_Osc_Input.H b/src/UI/Fl_Osc_Input.H
@@ -0,0 +1,15 @@
+#pragma once
+#include <FL/Fl_Input.H>
+#include "Fl_Osc_Widget.H"
+
+class Fl_Osc_Input: public Fl_Input, public Fl_Osc_Widget
+{
+ public:
+ Fl_Osc_Input(int X, int Y, int W, int H, const char *label = NULL);
+ virtual ~Fl_Osc_Input(void);
+
+ //Normal Initialization
+ void init(const char *path);
+
+ virtual void OSC_value(const char *value) override;
+};
diff --git a/src/UI/Fl_Osc_Input.cpp b/src/UI/Fl_Osc_Input.cpp
@@ -0,0 +1,20 @@
+#include "Fl_Osc_Input.H"
+
+Fl_Osc_Input::Fl_Osc_Input(int X, int Y, int W, int H, const char *label)
+ :Fl_Input(X,Y,W,H, label), Fl_Osc_Widget(this)
+{
+}
+
+Fl_Osc_Input::~Fl_Osc_Input(void)
+{}
+
+void Fl_Osc_Input::init(const char *path)
+{
+ ext = path;
+ oscRegister(path);
+}
+
+void Fl_Osc_Input::OSC_value(const char *v)
+{
+ value(v);
+}
diff --git a/src/UI/Fl_Osc_Interface.h b/src/UI/Fl_Osc_Interface.h
@@ -0,0 +1,33 @@
+#pragma once
+#include <stdio.h>
+#include <string>
+using std::string;
+
+class Fl_Osc_Interface
+{
+ public:
+ virtual ~Fl_Osc_Interface(void){};
+ //It is assumed that you want to have a registry for all of these
+ //elements
+ virtual void createLink(string, class Fl_Osc_Widget *) {};
+ virtual void renameLink(string,string,class Fl_Osc_Widget*){};
+ virtual void removeLink(string,class Fl_Osc_Widget*){};
+ virtual void removeLink(class Fl_Osc_Widget*){};
+
+ //and to be able to give them events
+ virtual void tryLink(const char *){};
+
+ //Damage the values of a collection of widgets
+ virtual void damage(const char*){};
+
+ //Communication link
+ virtual void requestValue(string s) { printf("request: '%s'...\n", s.c_str()); };
+ virtual void writeValue(string s, float f){printf("%s -> %f\n",s.c_str(), f); };
+ virtual void writeValue(string s, char c){printf("%s->%d\n", s.c_str(), c);};
+ virtual void writeValue(string, int){};
+ virtual void writeValue(string, bool){};
+ virtual void writeValue(string, string){};
+ virtual void write(string s) {write(s, "");};//{printf("write: '%s'\n", s.c_str());};
+ virtual void write(string, const char *, ...) {};//{printf("write: '%s'\n", s.c_str());};
+ virtual void writeRaw(const char *) {}
+};
diff --git a/src/UI/Fl_Osc_Output.H b/src/UI/Fl_Osc_Output.H
@@ -0,0 +1,24 @@
+#pragma once
+#include <FL/Fl_Value_Output.H>
+#include "Fl_Osc_Widget.H"
+
+class Fl_Osc_Output:public Fl_Value_Output, Fl_Osc_Widget
+{
+ public:
+ Fl_Osc_Output(int x, int y, int w, int h, const char *label = NULL);
+ void init(const char *path);
+ void OSC_value(char);
+ void OSC_value(float);
+ using Fl_Osc_Widget::OSC_value;
+
+ void update(void);
+ void callback(Fl_Callback *cb, void *p = NULL);
+
+ float newvalue() const;
+
+ void cb(void);
+ private:
+ float newvalue_;
+ std::string name;
+ std::pair<Fl_Callback*, void*> cb_data;
+};
diff --git a/src/UI/Fl_Osc_Output.cpp b/src/UI/Fl_Osc_Output.cpp
@@ -0,0 +1,65 @@
+#include "Fl_Osc_Output.H"
+#include <cstdlib>
+#include <cstring>
+#include <cmath>
+#include <cassert>
+#include <sstream>
+
+static void callback_fn(Fl_Widget *w, void *v)
+{
+ ((Fl_Osc_Output*)w)->cb();
+}
+
+Fl_Osc_Output::Fl_Osc_Output(int X, int Y, int W, int H, const char *label)
+ :Fl_Value_Output(X,Y,W,H, label), Fl_Osc_Widget(this)
+{
+ Fl_Value_Output::callback(callback_fn);
+}
+
+
+void Fl_Osc_Output::init(const char *path)
+{
+ name = path;
+ oscRegister(path);
+};
+
+void Fl_Osc_Output::callback(Fl_Callback *cb, void *p)
+{
+ cb_data.first = cb;
+ cb_data.second = p;
+}
+
+void Fl_Osc_Output::OSC_value(char v)
+{
+ newvalue_ = v;
+ value(v);
+
+ //Hide the fact that this widget is async
+ if(cb_data.first)
+ cb_data.first(this, cb_data.second);
+}
+
+void Fl_Osc_Output::OSC_value(float v)
+{
+ newvalue_ = v;
+ value(v);
+
+ //Hide the fact that this widget is async
+ if(cb_data.first)
+ cb_data.first(this, cb_data.second);
+}
+
+void Fl_Osc_Output::update(void)
+{
+ oscWrite(name);
+}
+
+float Fl_Osc_Output::newvalue(void) const
+{
+ return newvalue_;
+}
+
+void Fl_Osc_Output::cb(void)
+{
+ oscWrite(name);
+}
diff --git a/src/UI/Fl_Osc_Pane.H b/src/UI/Fl_Osc_Pane.H
@@ -0,0 +1,40 @@
+#ifndef FL_OSC_PANE_H
+#define FL_OSC_PANE_H
+#include <FL/Fl_Group.H>
+#include <FL/Fl_Double_Window.H>
+#include <string>
+
+class Fl_Osc_Pane
+{
+ public:
+ Fl_Osc_Pane(void);
+ class Fl_Osc_Interface *osc;
+ std::string base;
+ virtual std::string loc(void) const = 0;
+ virtual void rebase(std::string new_base) = 0;
+};
+
+class Fl_Osc_Window:public Fl_Double_Window, public Fl_Osc_Pane
+{
+ public:
+ Fl_Osc_Window(int w, int h, const char *L=0);
+
+ void init(Fl_Osc_Interface *osc_, std::string loc_);
+ virtual std::string loc(void) const;
+ virtual void rebase(std::string new_base);
+};
+
+
+class Fl_Osc_Group:public Fl_Osc_Pane, public Fl_Group
+{
+ public:
+ Fl_Osc_Group(int x, int y, int w, int h, const char *L=0);
+
+ std::string ext;
+
+ virtual std::string loc(void) const;
+ virtual void reext(std::string new_base);
+ virtual void rebase(std::string new_ext);
+};
+#endif
+
diff --git a/src/UI/Fl_Osc_Pane.cpp b/src/UI/Fl_Osc_Pane.cpp
@@ -0,0 +1,96 @@
+#include "Fl_Osc_Pane.H"
+#include "Fl_Osc_Widget.H"
+#include <cassert>
+#include <cstdio>
+
+Fl_Osc_Pane::Fl_Osc_Pane(void)
+ :osc(NULL), base()
+{}
+
+
+Fl_Osc_Window::Fl_Osc_Window(int w, int h, const char *L)
+ :Fl_Double_Window(w,h,L)
+{}
+
+void Fl_Osc_Window::init(Fl_Osc_Interface *osc_, std::string loc_)
+{
+ osc = osc_;
+ base = loc_;
+}
+
+std::string Fl_Osc_Window::loc(void) const
+{
+ return base;
+}
+
+static void nested_rebase(Fl_Group *g, std::string new_base)
+{
+ unsigned nchildren = g->children();
+ for(unsigned i=0; i < nchildren; ++i) {
+ Fl_Widget *widget = g->child(i);
+ if(Fl_Osc_Widget *o = dynamic_cast<Fl_Osc_Widget*>(widget)) {
+ o->rebase(new_base);
+ } else if(Fl_Osc_Group *o = dynamic_cast<Fl_Osc_Group*>(widget)) {
+ o->rebase(new_base);
+ } else if(Fl_Group *o = dynamic_cast<Fl_Group*>(widget)) {
+ nested_rebase(o, new_base);
+ }
+
+ }
+}
+
+void Fl_Osc_Window::rebase(std::string new_base)
+{
+ unsigned nchildren = this->children();
+ for(unsigned i=0; i < nchildren; ++i) {
+ Fl_Widget *widget = this->child(i);
+ if(Fl_Osc_Widget *o = dynamic_cast<Fl_Osc_Widget*>(widget)) {
+ o->rebase(new_base);
+ }
+ if(Fl_Osc_Group *o = dynamic_cast<Fl_Osc_Group*>(widget))
+ o->rebase(new_base);
+ else if(dynamic_cast<Fl_Group*>(widget))
+ nested_rebase(dynamic_cast<Fl_Group*>(widget), new_base);
+ }
+}
+
+static Fl_Osc_Pane *find_osc_pane(Fl_Widget *root)
+{
+ if(!root)
+ return NULL;
+ Fl_Group *next = root->parent();
+
+ if(auto *p = dynamic_cast<Fl_Osc_Pane*>(next))
+ return p;
+ else
+ return find_osc_pane(next);
+}
+
+Fl_Osc_Group::Fl_Osc_Group(int x, int y, int w, int h, const char *L)
+:Fl_Group(x,y,w,h,L)
+{
+ if(auto *p = find_osc_pane(this)) {
+ osc = p->osc;
+ base = p->loc();
+ assert(osc);
+ }
+};
+
+
+std::string Fl_Osc_Group::loc(void) const
+{
+ return base + ext;
+}
+
+
+void Fl_Osc_Group::rebase(std::string new_base)
+{
+ nested_rebase(this, new_base+ext);
+ base = new_base;
+}
+
+void Fl_Osc_Group::reext(std::string new_ext)
+{
+ nested_rebase(this, base+new_ext);
+ ext = new_ext;
+}
diff --git a/src/UI/Fl_Osc_Roller.H b/src/UI/Fl_Osc_Roller.H
@@ -0,0 +1,24 @@
+#pragma once
+#include <FL/Fl_Roller.H>
+#include "Fl_Osc_Widget.H"
+
+class Fl_Osc_Roller:public Fl_Roller, Fl_Osc_Widget
+{
+
+ public:
+ Fl_Osc_Roller(int X, int Y, int W, int H, const char *label = NULL);
+ virtual ~Fl_Osc_Roller(void);
+ void init(const char *path);
+ //void OSC_value(float);
+ void OSC_value(char) override;
+ using Fl_Osc_Widget::OSC_value;
+
+ //Refetch parameter information
+ void update(void);
+ void callback(Fl_Callback *cb, void *p = NULL);
+
+ void cb(void);
+ private:
+ std::string name;
+ std::pair<Fl_Callback*, void*> cb_data;
+};
diff --git a/src/UI/Fl_Osc_Roller.cpp b/src/UI/Fl_Osc_Roller.cpp
@@ -0,0 +1,52 @@
+#include "Fl_Osc_Roller.H"
+#include <cstdlib>
+#include <cstring>
+#include <cmath>
+#include <cassert>
+#include <sstream>
+
+static void callback_fn(Fl_Widget *w, void *)
+{
+ ((Fl_Osc_Roller*)w)->cb();
+}
+
+Fl_Osc_Roller::Fl_Osc_Roller(int X, int Y, int W, int H, const char *label)
+ :Fl_Roller(X,Y,W,H, label), Fl_Osc_Widget(this)
+{
+ Fl_Roller::callback(callback_fn);
+ bounds(0.0, 127.0f);
+}
+
+
+void Fl_Osc_Roller::init(const char *path)
+{
+ name = path;
+ oscRegister(path);
+};
+
+Fl_Osc_Roller::~Fl_Osc_Roller(void)
+{}
+
+void Fl_Osc_Roller::callback(Fl_Callback *cb, void *p)
+{
+ cb_data.first = cb;
+ cb_data.second = p;
+}
+
+void Fl_Osc_Roller::OSC_value(char v)
+{
+ value(v);
+}
+
+void Fl_Osc_Roller::update(void)
+{
+ oscWrite(name);
+}
+
+void Fl_Osc_Roller::cb(void)
+{
+ oscWrite(name, "c", (unsigned char)value());
+
+ if(cb_data.first)
+ cb_data.first(this, cb_data.second);
+}
diff --git a/src/UI/Fl_Osc_Slider.H b/src/UI/Fl_Osc_Slider.H
@@ -0,0 +1,30 @@
+#pragma once
+#include <FL/Fl_Slider.H>
+#include "Fl_Osc_Widget.H"
+#include <string>
+
+class Fl_Osc_Slider:public Fl_Slider, public Fl_Osc_Widget
+{
+
+ public:
+ Fl_Osc_Slider(int X, int Y, int W, int H, const char *label = NULL);
+ // string name,
+ // const char *metadata);
+
+ virtual ~Fl_Osc_Slider(void);
+ void OSC_value(int) override;
+ void OSC_value(float) override;
+ void OSC_value(char) override;
+ void init(std::string, char type = 'f');
+
+ //Refetch parameter information
+ void update(void);
+ void callback(Fl_Callback *cb, void *p = NULL);
+
+ void cb(void);
+ static void _cb(Fl_Widget *w, void *);
+ private:
+ double real_value;
+ char osc_type;
+ std::pair<Fl_Callback*, void*> cb_data;
+};
diff --git a/src/UI/Fl_Osc_Slider.cpp b/src/UI/Fl_Osc_Slider.cpp
@@ -0,0 +1,80 @@
+#include "Fl_Osc_Slider.H"
+#include "Fl_Osc_Interface.h"
+#include "Fl_Osc_Pane.H"
+#include <cstdlib>
+#include <cstring>
+#include <cmath>
+#include <cassert>
+#include <sstream>
+
+static double min__(double a, double b)
+{
+ return a<b?a:b;
+}
+
+Fl_Osc_Slider::Fl_Osc_Slider(int X, int Y, int W, int H, const char *label)
+ :Fl_Slider(X,Y,W,H,label), Fl_Osc_Widget(this), cb_data(NULL, NULL)
+{
+ //bounds(0.0f,1.0f);
+ Fl_Slider::callback(Fl_Osc_Slider::_cb);
+}
+
+void Fl_Osc_Slider::init(std::string path_, char type_)
+{
+ osc_type = type_;
+ ext = path_;
+ oscRegister(ext.c_str());
+}
+
+Fl_Osc_Slider::~Fl_Osc_Slider(void)
+{}
+
+void Fl_Osc_Slider::OSC_value(int v)
+{
+ const float min_ = min__(minimum(), maximum());//flipped sliders
+ Fl_Slider::value(v+min_);
+}
+
+void Fl_Osc_Slider::OSC_value(float v)
+{
+ const float min_ = min__(minimum(), maximum());//flipped sliders
+ Fl_Slider::value(v+min_);
+}
+
+void Fl_Osc_Slider::OSC_value(char v)
+{
+ const float min_ = min__(minimum(), maximum());//flipped sliders
+ Fl_Slider::value(v+min_);
+}
+
+void Fl_Osc_Slider::cb(void)
+{
+ const float min_ = min__(minimum(), maximum());//flipped sliders
+ const float val = Fl_Slider::value();
+ if(osc_type == 'f')
+ oscWrite(ext, "f", val-min_);
+ else if(osc_type == 'i')
+ oscWrite(ext, "i", (int)(val-min_));
+ else
+ oscWrite(ext, "c", (char)(val-min_));
+ //OSC_value(val);
+
+ if(cb_data.first)
+ cb_data.first(this, cb_data.second);
+}
+
+void Fl_Osc_Slider::callback(Fl_Callback *cb, void *p)
+{
+ cb_data.first = cb;
+ cb_data.second = p;
+}
+
+void Fl_Osc_Slider::update(void)
+{
+ oscWrite(ext, "");
+}
+
+void Fl_Osc_Slider::_cb(Fl_Widget *w, void *)
+{
+ static_cast<Fl_Osc_Slider*>(w)->cb();
+}
diff --git a/src/UI/Fl_Osc_Tree.H b/src/UI/Fl_Osc_Tree.H
@@ -0,0 +1,111 @@
+#pragma once
+#include <rtosc/ports.h>
+#include "Fl_Osc_Interface.h"
+#include <FL/Fl_Tree.H>
+
+class Fl_Osc_Tree: public Fl_Tree
+{
+ public:
+ Fl_Osc_Tree(int X, int Y, int W, int H, const char *L=0)
+ :Fl_Tree(X,Y,W,H,L)
+ {
+ root_label("");
+ add("nil");
+ add("/nil/nil");
+ close(first());
+ callback(Fl_Osc_Tree::cb, NULL);
+ }
+
+ void sprout(std::string s)
+ {
+ if(s[s.length()-1] == '/') {
+ attach(s);
+ attach(s+"nil");
+ close(s.c_str());
+ } else
+ attach(s);
+ }
+
+ void attach(std::string s)
+ {
+ if(!find_item(s.c_str()))
+ add(s.c_str());
+ }
+
+ static void cb(Fl_Widget *w, void*)
+ {
+ using namespace rtosc;
+ Fl_Osc_Tree *t=(Fl_Osc_Tree*)w;
+ int reason = t->callback_reason();
+
+ char pathname[1024];
+ t->item_pathname(pathname, sizeof(pathname), t->callback_item());
+
+
+ if(reason==1) {
+ char *colon = index(pathname, ':');
+ if(colon) {
+ *colon = 0;
+ t->osc->writeValue("/learn", string(pathname));
+ }
+ }
+
+ if(reason==3) //Populate fields
+ {
+ const Ports &p = *Fl_Osc_Tree::subtree_lookup(t->root_ports,pathname+1);
+ printf("ok, I got the tree\n");
+ if(auto *i = t->find_item((std::string(pathname)+"/"+"nil").c_str()))
+ t->remove(i);
+ for(const Port &port : p) {
+ printf("handling '%s'\n", port.name);
+ const bool subnodes = index(port.name, '/');
+ const bool enumerated = index(port.name, '#');
+ const string path = std::string(pathname)+"/"+port.name;
+ if(!enumerated) {
+ t->sprout(path);
+ } else {
+ char tmpa[1024];
+ char tmpb[1024];
+ strncpy(tmpa, path.c_str(), 1024);
+ char *pound = index(tmpa, '#');
+ int N = atoi(pound+1);
+ *pound = 0;
+ char terminal = subnodes ? '/' : '\0';
+
+ for(int i = 0; i < N; ++i) {
+ snprintf(tmpb, 1024, "%s%d%c",
+ tmpa, i, terminal);
+ t->sprout(tmpb);
+ }
+ }
+ }
+
+ }
+ }
+
+ static const rtosc::Ports *subtree_lookup(const rtosc::Ports *p, std::string s)
+ {
+ using namespace rtosc;
+ if(s=="")
+ return p;
+
+ if(s[s.length()-1] != '/')
+ s += '/';
+
+ for(const Port &port : *p) {
+ const char *name = port.name;
+ if(!index(name, '/'))//only accept objects that will have subports
+ continue;
+ if(rtosc_match(name, s.c_str())) {
+ return subtree_lookup(port.ports,
+ s.substr(index(s.c_str(), '/')-s.c_str()+1));
+ }
+ }
+
+ //TODO else case
+ return p;
+ }
+
+ rtosc::Ports *root_ports;
+ Fl_Osc_Interface *osc;
+};
diff --git a/src/UI/Fl_Osc_VSlider.H b/src/UI/Fl_Osc_VSlider.H
@@ -0,0 +1,27 @@
+#pragma once
+#include <FL/Fl_Value_Slider.H>
+#include "Fl_Osc_Widget.H"
+#include <string>
+
+class Fl_Osc_VSlider:public Fl_Value_Slider, public Fl_Osc_Widget
+{
+
+ public:
+ Fl_Osc_VSlider(int X, int Y, int W, int H, const char *label = NULL);
+
+ virtual ~Fl_Osc_VSlider(void);
+ void OSC_value(char);
+ void OSC_value(float);
+ void init(std::string, char type = 'c');
+
+ //Refetch parameter information
+ void update(void);
+ void callback(Fl_Callback *cb, void *p = NULL);
+
+ void cb(void);
+ static void _cb(Fl_Widget *w, void *);
+ private:
+ double real_value;
+ char osc_type;
+ std::pair<Fl_Callback*, void*> cb_data;
+};
diff --git a/src/UI/Fl_Osc_VSlider.cpp b/src/UI/Fl_Osc_VSlider.cpp
@@ -0,0 +1,66 @@
+#include "Fl_Osc_VSlider.H"
+#include "Fl_Osc_Interface.h"
+#include "Fl_Osc_Pane.H"
+#include <cstdlib>
+#include <cstring>
+#include <cmath>
+#include <cassert>
+#include <sstream>
+
+Fl_Osc_VSlider::Fl_Osc_VSlider(int X, int Y, int W, int H, const char *label)
+ :Fl_Value_Slider(X,Y,W,H,label), Fl_Osc_Widget(this), cb_data(NULL, NULL)
+{
+ //bounds(0.0f,1.0f);
+ Fl_Slider::callback(Fl_Osc_VSlider::_cb);
+}
+
+void Fl_Osc_VSlider::init(std::string path_, char type_)
+{
+ osc_type = type_;
+ ext = path_;
+ oscRegister(ext.c_str());
+}
+
+Fl_Osc_VSlider::~Fl_Osc_VSlider(void)
+{}
+
+void Fl_Osc_VSlider::OSC_value(char v)
+{
+ Fl_Slider::value(v+minimum());
+}
+
+void Fl_Osc_VSlider::OSC_value(float v)
+{
+ Fl_Slider::value(v+minimum());
+}
+
+void Fl_Osc_VSlider::cb(void)
+{
+ const float val = Fl_Slider::value();
+ if(osc_type == 'f')
+ oscWrite(ext, "f", val-minimum());
+ else if(osc_type == 'i')
+ oscWrite(ext, "i", (int)(val-minimum()));
+ else
+ oscWrite(ext, "c", (char)(val-minimum()));
+ //OSC_value(val);
+
+ if(cb_data.first)
+ cb_data.first(this, cb_data.second);
+}
+
+void Fl_Osc_VSlider::callback(Fl_Callback *cb, void *p)
+{
+ cb_data.first = cb;
+ cb_data.second = p;
+}
+
+void Fl_Osc_VSlider::update(void)
+{
+ oscWrite(ext, "");
+}
+
+void Fl_Osc_VSlider::_cb(Fl_Widget *w, void *)
+{
+ static_cast<Fl_Osc_VSlider*>(w)->cb();
+}
diff --git a/src/UI/Fl_Osc_Value.H b/src/UI/Fl_Osc_Value.H
@@ -0,0 +1,12 @@
+#include <FL/Fl_Value_Input.H>
+#include "Fl_Osc_Widget.H"
+
+class Fl_Osc_Value: public Fl_Value_Input, public Fl_Osc_Widget
+{
+ public:
+ Fl_Osc_Value(int X, int Y, int W, int H, const char *label = NULL);
+ virtual ~Fl_Osc_Value(void);
+
+ //Normal Initialization
+ void init(const char *path);
+};
diff --git a/src/UI/Fl_Osc_Value.cpp b/src/UI/Fl_Osc_Value.cpp
@@ -0,0 +1,12 @@
+#include "Fl_Osc_Value.H"
+
+Fl_Osc_Value::Fl_Osc_Value(int X, int Y, int W, int H, const char *label)
+ :Fl_Value_Input(X,Y,W,H, label), Fl_Osc_Widget(this)
+{
+}
+
+Fl_Osc_Value::~Fl_Osc_Value(void)
+{}
+
+void Fl_Osc_Value::init(const char *path)
+{}
diff --git a/src/UI/Fl_Osc_Widget.H b/src/UI/Fl_Osc_Widget.H
@@ -0,0 +1,57 @@
+#pragma once
+#include <string>
+#include <cstring>
+#include <cassert>
+#include <cmath>
+#include "Fl_Osc_Interface.h"
+#include "Fl_Osc_Pane.H"
+#include <FL/Fl_Group.H>
+
+class Fl_Osc_Widget
+{
+ public:
+ Fl_Osc_Widget(void); //Deprecated
+ Fl_Osc_Widget(Fl_Widget *self);
+ virtual ~Fl_Osc_Widget(void);
+
+ //Callback methods
+ virtual void OSC_value(float);
+ virtual void OSC_value(bool);
+ virtual void OSC_value(int);
+ virtual void OSC_value(char);
+ virtual void OSC_value(unsigned,void*);
+ virtual void OSC_value(const char *);
+
+ //labeled forwarding methods
+ virtual void OSC_value(float x, const char *);
+ virtual void OSC_value(bool x, const char *);
+ virtual void OSC_value(int x, const char *);
+ virtual void OSC_value(char x, const char *);
+ virtual void OSC_value(unsigned x, void *v, const char *);
+ virtual void OSC_value(const char *x, const char *);
+
+ //Raw messages
+ virtual void OSC_raw(const char *);
+
+ //Widget methods
+ void oscWrite(std::string path, const char *args, ...);
+ void oscWrite(std::string path);
+ void oscRegister(const char *path);
+
+ //Forces an update of parameters as they have become stale somehow
+ virtual void update(void);
+
+ //Smoothly change the base path
+ virtual void rebase(std::string new_base);
+ void oscMove(std::string new_ext);
+ //Explict version for weirdly routed controls
+ void oscMove(std::string old_loc, std::string new_loc);
+
+ //Base path
+ std::string loc;
+ //Extension
+ std::string ext;
+ Fl_Osc_Interface *osc;
+ protected:
+ Fl_Osc_Pane *fetch_osc_pane(Fl_Widget *w);
+};
diff --git a/src/UI/Fl_Osc_Widget.cpp b/src/UI/Fl_Osc_Widget.cpp
@@ -0,0 +1,113 @@
+#include "Fl_Osc_Widget.H"
+#include <rtosc/rtosc.h>
+
+Fl_Osc_Widget::Fl_Osc_Widget(void) //Deprecated
+:loc(), osc(NULL)
+{}
+
+Fl_Osc_Widget:: Fl_Osc_Widget(Fl_Widget *self)
+{
+ assert(fetch_osc_pane(self));
+ if(auto *pane = fetch_osc_pane(self)) {
+ osc = pane->osc;
+ loc = pane->loc();
+ }
+ assert(osc);
+}
+
+Fl_Osc_Widget::~Fl_Osc_Widget(void)
+{
+ if(osc)
+ osc->removeLink(this);
+};
+
+void Fl_Osc_Widget::OSC_value(float) {}
+void Fl_Osc_Widget::OSC_value(bool) {}
+void Fl_Osc_Widget::OSC_value(int) {}
+void Fl_Osc_Widget::OSC_value(char) {}
+void Fl_Osc_Widget::OSC_value(unsigned,void*) {}
+void Fl_Osc_Widget::OSC_value(const char *) {}
+
+//labeled forwarding methods
+void Fl_Osc_Widget::OSC_value(float x, const char *) {OSC_value(x);}
+void Fl_Osc_Widget::OSC_value(bool x, const char *) {OSC_value(x);}
+void Fl_Osc_Widget::OSC_value(int x, const char *) {OSC_value(x);}
+void Fl_Osc_Widget::OSC_value(char x, const char *) {OSC_value(x);}
+void Fl_Osc_Widget::OSC_value(unsigned x, void *v, const char *) {OSC_value(x,v);}
+void Fl_Osc_Widget::OSC_value(const char *x, const char *) {OSC_value(x);}
+
+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());
+
+ va_list va;
+ va_start(va, args);
+
+ if(rtosc_vmessage(buffer, 1024, (loc+path).c_str(), args, va))
+ 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");
+}
+
+void Fl_Osc_Widget::oscWrite(std::string path)
+{
+ osc->requestValue(loc+path);
+}
+
+void Fl_Osc_Widget::oscRegister(const char *path)
+{
+ osc->createLink(loc+path, this);
+ osc->requestValue(loc+path);
+}
+
+void Fl_Osc_Widget::update(void)
+{
+ osc->requestValue(loc+ext);
+}
+
+Fl_Osc_Pane *Fl_Osc_Widget::fetch_osc_pane(Fl_Widget *w)
+{
+ if(!w)
+ return NULL;
+
+ Fl_Osc_Pane *pane = dynamic_cast<Fl_Osc_Pane*>(w->parent());
+ if(pane)
+ return pane;
+ return fetch_osc_pane(w->parent());
+}
+
+
+void Fl_Osc_Widget::rebase(std::string new_base)
+{
+ osc->renameLink(loc+ext, new_base+ext, this);
+ loc = new_base;
+ osc->requestValue(loc+ext);
+}
+
+void Fl_Osc_Widget::oscMove(std::string new_ext)
+{
+ osc->renameLink(loc+ext, loc+new_ext, this);
+ ext = new_ext;
+ osc->requestValue(loc+ext);
+}
+
+void Fl_Osc_Widget::oscMove(std::string old_loc, std::string new_loc)
+{
+ osc->renameLink(old_loc, new_loc, this);
+ osc->requestValue(new_loc);
+}
diff --git a/src/UI/Fl_OscilSpectrum.h b/src/UI/Fl_OscilSpectrum.h
@@ -0,0 +1,119 @@
+#include <cassert>
+
+//consider merging with Fl_Oscilloscope
+class Fl_OscilSpectrum : public Fl_Box, Fl_Osc_Widget
+{
+ public:
+ Fl_OscilSpectrum(int x,int y, int w, int h, const char *label=0)
+ :Fl_Box(x,y,w,h,label), nsamples(0), spc(NULL)
+ {}
+
+ ~Fl_OscilSpectrum(void)
+ {
+ delete[] spc;
+ osc->removeLink(loc, (Fl_Osc_Widget*) this);
+ }
+
+ void init(bool base_spectrum_p)
+ {
+ Fl_Osc_Pane *og = fetch_osc_pane(this);
+ assert(og);
+
+ loc = og->base + (base_spectrum_p ? "base-spectrum": "spectrum");
+ osc = og->osc;
+ assert(osc);
+
+ osc->createLink(loc, (Fl_Osc_Widget*) this);
+ update();
+ }
+
+ void update(void)
+ {
+ osc->requestValue(loc);
+ }
+
+ virtual void OSC_value(unsigned N, void *data) override
+ {
+ assert(!(N%4));
+ const size_t new_samples = N / 4;
+
+ //resize buffer if needed
+ if(new_samples != nsamples) {
+ delete [] spc;
+ spc = new float[new_samples];
+ nsamples = new_samples;
+ }
+
+ memcpy(spc, data, N);
+
+ //normalize
+ float max=0;
+ for (unsigned i=0; i<nsamples; i++){
+ float x=fabs(spc[i]);
+ if (max<x) max=x;
+ }
+ if (max<0.000001) max=1.0;
+ max=max*1.05;
+
+ for(unsigned i=0; i<nsamples; ++i)
+ spc[i]/=max;
+
+ //Get widget to redraw new data
+ redraw();
+ }
+
+ void draw(void)
+ {
+ const int ox=x(),oy=y(),lx=w(),ly=h();
+ const int maxdb=60;//must be multiple of 10
+ const int GX=2;
+ int n=lx/GX-1;
+ if (n>synth->oscilsize/2)
+ n=synth->oscilsize/2;
+
+ //draw
+ if(this->active_r())
+ fl_color(this->parent()->labelcolor());
+ else
+ fl_color(this->parent()->color());
+ fl_line_style(FL_DOT);
+
+ for(int i=1; i<maxdb/10; i++){
+ const int ky=((int)((float)i*ly*10.0/maxdb)/2)*2;
+ fl_line(ox,oy+ky-1,ox+lx-2,oy+ky-1);
+ }
+
+ for(int i=2; i<n; i++){
+ int tmp=i*GX-2;
+ if(i%10==1)
+ fl_line_style(0);
+ else
+ fl_line_style(FL_DOT);
+ fl_line(ox+tmp,oy+2,ox+tmp,oy+ly-2);
+ }
+
+ if (this->active_r())
+ fl_color(this->parent()->selection_color());
+ else
+ fl_color(this->parent()->color());
+ fl_line_style(0);
+
+ if(!spc)
+ return;
+ //draws the spectrum
+ for(int i=0; i<n; i++){
+ int tmp=i*GX+2;
+ float x=spc[i];
+
+ if (x>dB2rap(-maxdb)) x=rap2dB(x)/maxdb+1;
+ else x=0;
+
+ int val=(int) ((ly-2)*x);
+ if (val>0) fl_line(ox+tmp,oy+ly-2-val,ox+tmp,oy+ly-2);
+ }
+ }
+ private:
+
+ size_t nsamples;
+ float *spc;
+};
diff --git a/src/UI/Fl_Oscilloscope.h b/src/UI/Fl_Oscilloscope.h
@@ -0,0 +1,130 @@
+#pragma once
+
+#include "Fl_Osc_Pane.H"
+#include <FL/Fl_Box.H>
+#include <FL/fl_draw.H>
+#include "Fl_Osc_Widget.H"
+#include "Fl_Osc_Pane.H"
+#include "Fl_Osc_Interface.h"
+#include "common.H"
+#include <cassert>
+#include <cstdio>
+#include "../globals.h"
+
+class Fl_Osc_Group;
+//Consider merging in Fl_OscilSpectrum
+class Fl_Oscilloscope : public Fl_Box, Fl_Osc_Widget
+{
+ public:
+ Fl_Oscilloscope(int x,int y, int w, int h, const char *label=0)
+ :Fl_Box(x,y,w,h,label), Fl_Osc_Widget(this)
+ {
+ smps = new float[synth->oscilsize];
+ memset(smps, 0, synth->oscilsize*sizeof(float));
+ phase=64;
+ box(FL_FLAT_BOX);
+ }
+
+ ~Fl_Oscilloscope(void)
+ {
+ delete[] smps;
+ }
+
+ void init(bool base_waveform_p)
+ {
+ ext = (base_waveform_p ? "base-waveform": "waveform");
+ assert(osc);
+ oscRegister(ext.c_str());
+ }
+
+ void update(void)
+ {
+ oscWrite(ext);
+ }
+
+ virtual void OSC_value(unsigned N, void *data) override
+ {
+ assert(N==(unsigned)(synth->oscilsize*4));
+
+ memcpy(smps, data, N);
+
+ //normalize
+ float max=0;
+ for (int i=0;i<synth->oscilsize;i++)
+ if(max<fabs(smps[i]))
+ max=fabs(smps[i]);
+ if (max<0.00001) max=1.0;
+ max *= -1.05;
+
+ for(int i=0; i < synth->oscilsize; ++i)
+ smps[i] /= max;
+
+ //Get widget to redraw new data
+ redraw();
+ }
+
+ void draw(void)
+ {
+ 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 ));
+ fl_rectf(ox,oy,lx,ly);
+ }
+
+ //draw
+ fl_line_style(FL_DASH);
+ if (this->active_r()) fl_color(this->parent()->labelcolor());
+ else fl_color(this->parent()->color());
+
+ int GX=16;if (lx<GX*3) GX=-1;
+ for (int i=1;i<GX;i++){
+ int tmp=(int)(lx/(float)GX*i);
+ fl_line(ox+tmp,oy+2,ox+tmp,oy+ly-2);
+ }
+
+ int GY=8; if (ly<GY*3) GY=-1;
+ for (int i=1;i<GY;i++){
+ int tmp=(int)(ly/(float)GY*i);
+ fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
+ }
+
+ //draw the function
+ fl_line_style(0,1);
+ fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);
+ if (this->active_r()) fl_color(this->parent()->selection_color());
+ else fl_color(this->parent()->labelcolor());
+
+ fl_color( fl_color_add_alpha( fl_color(), 127 ) );
+
+ int lw=2;
+ fl_line_style(FL_SOLID,lw);
+ fl_begin_line();
+ double ph=((phase-64.0)/128.0*synth->oscilsize+synth->oscilsize);
+ for (int i=1;i<lx;i++){
+ int k2=(synth->oscilsize*i/lx)+ph;
+ double y2=smps[k2%synth->oscilsize];
+ fl_vertex(i+ox,y2*ly/2.0+oy+ly/2);
+ }
+ fl_end_line();
+
+ fl_line_style(FL_SOLID,0);
+ }
+
+ //allows UI to manipuate phase of displayed waveform
+ int phase;
+
+ private:
+ Fl_Osc_Pane *fetch_osc_pane(Fl_Widget *w)
+ {
+ if(!w)
+ return NULL;
+
+ Fl_Osc_Pane *pane = dynamic_cast<Fl_Osc_Pane*>(w->parent());
+ if(pane)
+ return pane;
+ return fetch_osc_pane(w->parent());
+ }
+
+ float *smps;
+};
diff --git a/src/UI/Fl_PADnoteHarmonicProfile.h b/src/UI/Fl_PADnoteHarmonicProfile.h
@@ -0,0 +1,125 @@
+
+class PADnoteHarmonicProfile: public Fl_Box, public Fl_Osc_Widget
+{
+ public:
+ PADnoteHarmonicProfile(int x,int y, int w, int h, const char *label=0)
+ :Fl_Box(x,y,w,h,label), smps(new float[w]), realbw(0.0f)
+ {
+ memset(smps, 0, w*sizeof(float));
+ }
+
+ ~PADnoteHarmonicProfile(void)
+ {
+ osc->removeLink(loc, (Fl_Osc_Widget*) this);
+ delete[] smps;
+ }
+
+ void init(void)
+ {
+ Fl_Osc_Pane *og = fetch_osc_pane(this);
+ assert(og);
+
+ loc = og->base + "profile";
+ osc = og->osc;
+ assert(osc);
+
+ osc->createLink(loc, (Fl_Osc_Widget*) this);
+ update();
+ }
+
+ void update(void)
+ {
+ osc->write(loc, "i", w());
+ }
+
+ void OSC_value(unsigned N, void *data, const char *name) override
+ {
+ assert(!strcmp(name, "profile"));
+ assert(N==w()*sizeof(float));
+ memcpy(smps, data, N);
+ redraw();
+ }
+
+ void OSC_value(float x, const char *name) override
+ {
+ assert(!strcmp(name, "profile"));
+ realbw = x;
+ redraw();
+ }
+
+ void draw(void)
+ {
+ int ox=x(),oy=y(),lx=w(),ly=h();
+ const bool active=active_r();
+ if(!visible())
+ return;
+
+ if (damage()!=1){
+ fl_color(fl_color_average(FL_BLACK,
+ FL_BACKGROUND_COLOR, 0.5 ));
+ fl_rectf(ox,oy,lx,ly);
+ }
+
+ //draw the equivalent bandwidth
+ if (active) fl_color(220,220,220);
+ else fl_color(160,165,165);
+ fl_line_style(FL_DASH);
+ int rbw=(int)(realbw*(lx-1.0)/2.0);
+ fl_begin_line();
+ for(int i=lx/2-rbw;i<(lx/2+rbw); ++i)
+ fl_vertex(ox+i,oy);
+ fl_end_line();
+
+ fl_line_style(FL_DASH);
+ if(active)
+ fl_color(200,200,200);
+ else
+ fl_color(160,160,160);
+
+ for (int i=1;i<10;i++){
+ const int kx=(int)(lx/10.0*i);
+ fl_line(ox + kx, oy, ox + kx, oy + ly - 1);
+ }
+ for (int i=1;i<5;i++){
+ const int ky=(int)(ly/5.0*i);
+ fl_line(ox,oy+ly-ky,ox+lx,oy+ly-ky-1);
+ }
+
+
+ fl_color(120,120,120);
+ fl_line_style(FL_DASH);
+ fl_line(ox+lx/2,oy,ox+lx/2,oy+ly);
+
+ //draw the graph
+ fl_line_style(FL_SOLID);
+ if (active)
+ fl_color(180,210,240);
+ else
+ fl_color(150,150,155);
+
+ fl_color(fl_color_add_alpha(fl_color(), 127));
+
+ fl_begin_polygon();
+ fl_vertex(ox, oy + h());
+ for (int i=0; i<lx; ++i){
+ int val=(int) ((ly-2)*smps[i]);
+ fl_vertex(ox+i,oy+ly-1-val);
+ }
+ fl_vertex(ox + w(), oy + h());
+ fl_end_polygon();
+
+
+ fl_line_style(FL_DASH);
+ if (active)
+ fl_color(0,100,220);
+ else
+ fl_color(150,160,170);
+ fl_line(ox+lx/2-rbw,oy,ox+lx/2-rbw,oy+ly-1);
+ fl_line(ox+lx/2+rbw,oy,ox+lx/2+rbw,oy+ly-1);
+
+ fl_line_style(0);
+ }
+ private:
+ float *smps;
+ float realbw;
+};
diff --git a/src/UI/Fl_PADnoteOvertonePosition.h b/src/UI/Fl_PADnoteOvertonePosition.h
@@ -0,0 +1,188 @@
+#include <cstring>
+#include <cassert>
+#include <FL/Fl.H>
+#include <FL/Fl_Box.H>
+#include "../globals.h"
+#include "Fl_Osc_Widget.H"
+#include "Fl_Osc_Interface.h"
+
+class PADnoteOvertonePosition: public Fl_Box, Fl_Osc_Widget
+{
+ public:
+ PADnoteOvertonePosition(int x,int y, int w, int h, const char *label=0)
+ :Fl_Box(x,y,w,h,label), nsamples(synth->oscilsize/2),
+ spc(new float[synth->oscilsize/2]),
+ nhr(new float[synth->oscilsize/2]),
+ spectrum(new float[w]),
+ mode(0), osc(NULL)
+ {
+ memset(spectrum, 0, w*sizeof(float));
+ memset(spc, 0, synth->oscilsize/2*sizeof(float));
+ memset(nhr, 0, synth->oscilsize/2*sizeof(float));
+ }
+
+ ~PADnoteOvertonePosition(void)
+ {
+ osc->removeLink(base_path + "oscil/spectrum",
+ (Fl_Osc_Widget*) this);
+ osc->removeLink(base_path + "nhr",
+ (Fl_Osc_Widget*) this);
+ osc->removeLink(base_path + "mode",
+ (Fl_Osc_Widget*) this);
+ delete [] spc;
+ }
+
+ void init(void)
+ {
+ Fl_Osc_Pane *og = fetch_osc_pane(this);
+ assert(og);
+
+ base_path = og->base;
+ osc = og->osc;
+ assert(osc);
+
+ osc->createLink(base_path + "nhr",
+ (Fl_Osc_Widget*) this);
+ osc->createLink(base_path + "oscil/spectrum",
+ (Fl_Osc_Widget*) this);
+ osc->createLink(base_path + "mode",
+ (Fl_Osc_Widget*) this);
+
+ fprintf(stderr, "registered at my location '%s'\n", (base_path + "nhr").c_str());
+ update();
+ }
+
+ void update(void)
+ {
+ osc->requestValue(base_path + "nhr");
+ osc->requestValue(base_path + "oscil/spectrum");
+ osc->requestValue(base_path + "mode");
+ }
+
+ virtual void OSC_value(unsigned N, void *data, const char *name)
+ override
+ {
+ assert(N==(4*nsamples));
+ float *d = (float*)data;
+ if(!strcmp(name, "spectrum"))
+ updateSpectrum(d);
+ else if(!strcmp(name, "nhr"))
+ updateHarmonicPos(d);
+ else
+ assert(false);
+ }
+ virtual void OSC_value(char x, const char *name) override
+ {
+ assert(!strcmp(name, "mode"));
+ mode = x;
+ regenerateOvertones();
+ }
+
+ private:
+ void updateSpectrum(float *data)
+ {
+ //normalize
+ float max=0;
+ for (unsigned i=0; i<nsamples; i++){
+ const float x=fabs(data[i]);
+ if (max<x) max=x;
+ }
+ if (max<0.000001) max=1.0;
+ max=max*1.05;
+
+ for(unsigned i=0; i<nsamples; ++i)
+ spc[i] = data[i]/max;
+ regenerateOvertones();
+ }
+
+ void updateHarmonicPos(float *data)
+ {
+ memcpy(nhr, data, nsamples*sizeof(float));
+ regenerateOvertones();
+ }
+
+ void regenerateOvertones(void)
+ {
+ const int ox=x(),oy=y(),lx=w(),ly=h();
+ (void)ox;(void)oy;(void)lx;(void)ly;
+ const int maxharmonic=64;
+
+ memset(spectrum, 0, lx*sizeof(float));
+
+ for (unsigned i=1;i<nsamples;i++){
+ int kx=(int)(lx/(float)maxharmonic*nhr[i]);
+ if ((kx<0)||(kx>=lx)) continue;
+
+ spectrum[kx]=spc[i-1]+1e-9;
+ }
+
+
+ if(mode==2) {
+ int old=0;
+ for (int i=1;i<lx;i++){
+ if ((spectrum[i]>1e-10)||(i==(lx-1))){
+ const int delta=i-old;
+ const float val1=spectrum[old];
+ const float val2=spectrum[i];
+
+ const float idelta=1.0/delta;
+ for (int j=0;j<delta;j++) {
+ const float x=idelta*j;
+ spectrum[old+j]=val1*(1.0-x)+val2*x;
+ }
+ old=i;
+ }
+
+ }
+ }
+ redraw();
+ }
+
+ void draw(void)
+ {
+ const int ox=x(),oy=y(),lx=w(),ly=h();
+ const int maxharmonic=64;
+ const int maxdb=60;
+
+ if (!visible())
+ return;
+
+ if (damage()!=1){
+ fl_color(fl_color_average(FL_BLACK,
+ FL_BACKGROUND_COLOR, 0.5 ));
+ fl_rectf(ox,oy,lx,ly);
+ }
+
+
+ for (int i=1;i<maxharmonic;i++){
+ fl_color(100,100,100);
+ fl_line_style(FL_DOT);
+ if (i%5==0) fl_line_style(0);
+ if (i%10==0) fl_color(120,120,120);
+ int kx=(int)(lx/(float)maxharmonic*i);
+ fl_line(ox+kx,oy,ox+kx,oy+ly);
+ };
+
+ fl_color(180,0,0);
+ fl_line_style(0);
+
+ for (int i=0;i<lx;i++){
+ float x=spectrum[i];
+ if (x>dB2rap(-maxdb)) x=rap2dB(x)/maxdb+1;
+ else continue;
+ int yy=(int)(x*ly);
+ fl_line(ox+i,oy+ly-1-yy,ox+i,oy+ly-1);
+
+ }
+ }
+
+ private:
+ size_t nsamples;
+ float *spc;
+ float *nhr;
+ float *spectrum;
+ char mode;
+
+ std::string base_path;
+ Fl_Osc_Interface *osc;
+};
diff --git a/src/UI/Fl_Resonance_Graph.H b/src/UI/Fl_Resonance_Graph.H
@@ -0,0 +1,45 @@
+// generated by Fast Light User Interface Designer (fluid) version 1.0302
+
+#ifndef Fl_Resonance_Graph_H
+#define Fl_Resonance_Graph_H
+#include <FL/Fl_Box.H>
+#include "../Synth/Resonance.h"
+#include "Fl_Osc_Widget.H"
+
+class Fl_Value_Output;
+class Fl_Widget;
+class Fl_Resonance_Graph : public Fl_Box, public Fl_Osc_Widget {
+ public:
+ Fl_Resonance_Graph(int x,int y, int w, int h, const char *label=0);
+ virtual ~Fl_Resonance_Graph(void);
+ void init(Fl_Value_Output *khzvalue_,Fl_Value_Output *dbvalue_);
+ void draw_freq_line(float freq,int type);
+ void draw();
+ int handle(int event);
+ void setcbwidget(Fl_Widget *cbwidget,Fl_Widget *applybutton);
+ void update(void);
+
+ float khzval;
+
+ void OSC_raw(const char *msg);
+
+ private:
+ float getfreqx(float x) const;
+ float getfreqpos(float freq) const;
+ float getcenterfreq() const;
+ float getoctavesfreq() const;
+
+ void setPoint(int idx, int val);
+
+ Fl_Value_Output *khzvalue;
+ Fl_Value_Output *dbvalue;
+ int oldx,oldy;
+ Fl_Widget *cbwidget,*applybutton;
+
+ //duplicate data required to render response
+ unsigned char Prespoints[N_RES_POINTS];
+ char Pcenterfreq;
+ char Poctavesfreq;
+ char PmaxdB;
+};
+#endif
diff --git a/src/UI/Fl_Resonance_Graph.cpp b/src/UI/Fl_Resonance_Graph.cpp
@@ -0,0 +1,246 @@
+#include "Fl_Resonance_Graph.H"
+#include <FL/Fl.H>
+#include <FL/fl_draw.H>
+#include <FL/Fl_Value_Output.H>
+#include <rtosc/rtosc.h>
+
+Fl_Resonance_Graph::Fl_Resonance_Graph(int x,int y, int w, int h, const char *label)
+ :Fl_Box(x,y,w,h,label), Fl_Osc_Widget(this), khzvalue(NULL), dbvalue(NULL),
+ oldx(-1), oldy(-1), cbwidget(NULL), applybutton(NULL), Pcenterfreq(0), Poctavesfreq(0),
+ PmaxdB(0)
+{
+ memset(Prespoints, 64, N_RES_POINTS);
+ //Get values
+ oscRegister("Prespoints");
+ oscRegister("Pcenterfreq");
+ oscRegister("Poctavesfreq");
+ oscRegister("PmaxdB");
+
+ cbwidget=NULL;
+ applybutton=NULL;
+}
+
+Fl_Resonance_Graph::~Fl_Resonance_Graph(void)
+{
+}
+
+void Fl_Resonance_Graph::init(Fl_Value_Output *khzvalue_,Fl_Value_Output *dbvalue_)
+{
+ khzvalue=khzvalue_;
+ dbvalue=dbvalue_;
+ oldx=-1;
+ khzval=-1;
+}
+
+void Fl_Resonance_Graph::draw_freq_line(float freq,int type)
+{
+ const float freqx=getfreqpos(freq);//XXX
+ switch(type){
+ case 0:fl_line_style(FL_SOLID);break;
+ case 1:fl_line_style(FL_DOT);break;
+ case 2:fl_line_style(FL_DASH);break;
+ }
+
+
+ if ((freqx>0.0)&&(freqx<1.0))
+ fl_line(x()+(int) (freqx*w()),y(),
+ x()+(int) (freqx*w()),y()+h());
+}
+
+void Fl_Resonance_Graph::draw()
+{
+ const int ox=x(),oy=y(),lx=w(),ly=h();
+
+ fl_color(FL_DARK1);
+ fl_rectf(ox,oy,lx,ly);
+
+
+ //draw the lines
+ fl_color(FL_GRAY);
+
+ fl_line_style(FL_SOLID);
+ fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);
+
+
+ //Draw 1kHz line
+ const float freqx=getfreqpos(1000.0);//XXX
+ if ((freqx>0.0)&&(freqx<1.0))
+ fl_line(ox+(int) (freqx*lx),oy,
+ ox+(int) (freqx*lx),oy+ly);
+
+ //Draw other frequency lines
+ for (int i=1; i<10; ++i){
+ if(i==1) {
+ draw_freq_line(i*100.0,0);
+ draw_freq_line(i*1000.0,0);
+ } else
+ if (i==5) {
+ draw_freq_line(i*100.0,2);
+ draw_freq_line(i*1000.0,2);
+ } else {
+ draw_freq_line(i*100.0,1);
+ draw_freq_line(i*1000.0,1);
+ }
+ }
+
+ draw_freq_line(10000.0,0);
+ draw_freq_line(20000.0,1);
+
+ //Draw dotted grid
+ fl_line_style(FL_DOT);
+ int GY=10;if (ly<GY*3) GY=-1;
+ for (int i=1; i<GY; ++i){
+ int tmp=(int)(ly/(float)GY*i);
+ fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
+ }
+
+
+
+ //draw the data
+ fl_color(FL_RED);
+ fl_line_style(FL_SOLID,2);
+ fl_begin_line();
+ int oiy = ly*Prespoints[0]/128.0;//XXX easy
+ for (int i=1; i<N_RES_POINTS; ++i){
+ const int ix=(i*1.0/N_RES_POINTS*lx);
+ const int iy= ly*Prespoints[i]/128.0;//XXX easy
+ fl_vertex(ox+ix,oy+ly-oiy);
+ oiy=iy;
+ }
+ fl_end_line();
+ fl_line_style(FL_SOLID,0);
+}
+
+int Fl_Resonance_Graph::handle(int event)
+{
+ int x_=Fl::event_x()-x();
+ int y_=Fl::event_y()-y();
+ if((x_>=0)&&(x_<w()) && (y_>=0)&&(y_<h())){
+ khzvalue->value(getfreqx(x_*1.0/w())/1000.0);//XXX
+ dbvalue->value((1.0-y_*2.0/h())*PmaxdB);//XXX
+ }
+
+ if((event==FL_PUSH)||(event==FL_DRAG)){
+ const bool leftbutton = Fl::event_button() == FL_LEFT_MOUSE;
+
+ if (x_<0) x_=0;if (y_<0) y_=0;
+ if (x_>=w()) x_=w();if (y_>=h()-1) y_=h()-1;
+
+ if ((oldx<0)||(oldx==x_)){
+ int sn=(int)(x_*1.0/w()*N_RES_POINTS);
+ int sp=127-(int)(y_*1.0/h()*127);
+ if(leftbutton)
+ setPoint(sn,sp);
+ //oscWrite("setpoint", "ii", sn, sp);//respar->setpoint(sn,sp);//XXX easy
+ else
+ setPoint(sn,sp);
+ //oscWrite("setpoint", "ii", sn, 64);//respar->setpoint(sn,64);//XXX easy
+ } else {
+ int x1=oldx;
+ int x2=x_;
+ int y1=oldy;
+ int y2=y_;
+ if (oldx>x_){
+ x1=x_;y1=y_;
+ x2=oldx;y2=oldy;
+ }
+ for (int i=0;i<x2-x1;i++){
+ int sn=(int)((i+x1)*1.0/w()*N_RES_POINTS);
+ float yy=(y2-y1)*1.0/(x2-x1)*i;
+ int sp=127-(int)((y1+yy)/h()*127);
+ if(leftbutton) //respar->setpoint(sn,sp);//XXX easy
+ setPoint(sn, sp);
+ //oscWrite("setpoint", "ii", sn, sp);
+ else //respar->setpoint(sn,64);//XXX easy
+ setPoint(sn, sp);
+ //oscWrite("setpoint", "ii", sn, sp);
+ }
+ }
+
+ oldx=x_;oldy=y_;
+ redraw();
+ }
+
+ if(event==FL_RELEASE) {
+ oldx=-1;
+ if(cbwidget) {
+ cbwidget->do_callback();
+ if(applybutton) {
+ applybutton->color(FL_RED);
+ applybutton->redraw();
+ }
+ }
+ }
+
+ return 1;
+}
+
+void Fl_Resonance_Graph::setcbwidget(Fl_Widget *cbwidget,Fl_Widget *applybutton)
+{
+ this->cbwidget=cbwidget;
+ this->applybutton=applybutton;
+}
+
+void Fl_Resonance_Graph::update(void)
+{
+ oscWrite("Prespoints");
+ oscWrite("Pcenterfreq");
+ oscWrite("Poctavesfreq");
+ oscWrite("PmaxdB");
+}
+
+void Fl_Resonance_Graph::OSC_raw(const char *msg)
+{
+ //TODO check the types (OSC regex)
+ if(strstr(msg, "Prespoints")) {
+ rtosc_blob_t arg = rtosc_argument(msg, 0).b;
+ assert(arg.len == N_RES_POINTS);
+ memcpy(Prespoints, arg.data, N_RES_POINTS);
+ } else if(strstr(msg, "Pcenterfreq"))
+ Pcenterfreq = rtosc_argument(msg, 0).i;
+ else if(strstr(msg, "Poctavesfreq"))
+ Poctavesfreq = rtosc_argument(msg, 0).i;
+ else if(strstr(msg, "PmaxdB"))
+ PmaxdB = rtosc_argument(msg, 0).i;
+ else
+ puts("I got an unknown message...");
+
+ redraw();
+}
+
+float Fl_Resonance_Graph::getfreqx(float x) const
+{
+ const float octf = powf(2.0f, getoctavesfreq());
+ return getcenterfreq() / sqrt(octf) * powf(octf, limit(x, 0.0f, 1.0f));
+}
+
+/*
+ * Get the x coordinate from frequency (used by the UI)
+ */
+float Fl_Resonance_Graph::getfreqpos(float freq) const
+{
+ return (logf(freq) - logf(getfreqx(0.0f))) / logf(2.0f) / getoctavesfreq();
+}
+
+/*
+ * Get the center frequency of the resonance graph
+ */
+float Fl_Resonance_Graph::getcenterfreq() const
+{
+ return 10000.0f * powf(10, -(1.0f - Pcenterfreq / 127.0f) * 2.0f);
+}
+
+/*
+ * Get the number of octave that the resonance functions applies to
+ */
+float Fl_Resonance_Graph::getoctavesfreq() const
+{
+ return 0.25f + 10.0f * Poctavesfreq / 127.0f;
+}
+
+void Fl_Resonance_Graph::setPoint(int idx, int val)
+{
+ Prespoints[idx] = val;
+ oscWrite(std::string("Prespoints")+to_s(idx), "c", val);
+ redraw();
+}
diff --git a/src/UI/FormantFilterGraph.H b/src/UI/FormantFilterGraph.H
@@ -0,0 +1,62 @@
+#pragma once
+
+#include <FL/Fl.H>
+#include "Fl_Osc_Widget.H"
+#include "WidgetPDial.h"
+#include "../globals.h"
+#include <FL/Fl_Group.H>
+#include "../Params/FilterParams.h"
+#include <FL/Fl_Box.H>
+#include <FL/fl_draw.H>
+#include <FL/fl_ask.H>
+#include "common.H"
+
+class FilterParams;
+
+class FormantFilterGraph : public Fl_Box, Fl_Osc_Widget {
+ public:
+ FormantFilterGraph(int x,int y, int w, int h, const char *label=0);
+ void init(int *nvowel_, int *nformant_);
+ void draw_freq_line(float freq,int type);
+ void draw();
+ virtual ~FormantFilterGraph(void);
+
+ void OSC_value(char x, const char *) override;
+ void OSC_value(unsigned x, void *v) override;
+
+ void updateVowel(int);
+ void updateFormant(int);
+
+ void update(void);
+
+ private:
+ int *nvowel,*nformant;
+ float *graphpoints;
+
+ struct {
+ struct {
+ unsigned char freq, amp, q; //frequency,amplitude,Q
+ } formants[FF_MAX_FORMANTS];
+ } Pvowels[FF_MAX_VOWELS];
+
+ int Pnumformants;
+ int Pstages;
+ int Pcenterfreq;
+ int Pgain;
+
+ int Pq;
+ int Poctavesfreq;
+
+
+ float getfreqx(float);
+
+ float getfreqpos(float);
+ float getformantfreq(unsigned char);
+ float getformantamp(unsigned char);
+ float getoctavesfreq(void);
+ float getcenterfreq(void);
+ float getgain(void);
+ float getq(void);
+ float getformantq(unsigned char q);
+ void formantfilterH(int, int, float*);
+};
diff --git a/src/UI/FormantFilterGraph.cpp b/src/UI/FormantFilterGraph.cpp
@@ -0,0 +1,321 @@
+#include "FormantFilterGraph.H"
+#include <cmath>
+#include <cstdio>
+#include <cstdlib>
+
+FormantFilterGraph::FormantFilterGraph(int x,int y, int w, int h, const char *label)
+:Fl_Box(x,y,w,h,label), Fl_Osc_Widget(this)
+{
+ memset(Pvowels, 0, sizeof(Pvowels));
+ Pnumformants = 0;
+ Pstages = 0;
+ Pgain = 0;
+ Pcenterfreq = 0;
+ Pq = 0;
+ Poctavesfreq = 0;
+ nvowel=NULL;
+ nformant=NULL;
+ graphpoints=NULL;
+}
+
+void FormantFilterGraph::init(int *nvowel_,int *nformant_)
+{
+ nvowel=nvowel_;
+ nformant=nformant_;
+ graphpoints=new float [w()];
+
+ oscRegister("Pvowels");
+ oscRegister("Pnumformants");
+ oscRegister("Pstages");
+ oscRegister("Pcenterfreq");
+ oscRegister("Poctavesfreq");
+ oscRegister("Pgain");
+ oscRegister("Pq");
+}
+
+void FormantFilterGraph::OSC_value(char x, const char *loc)
+{
+ if(strstr(loc, "Pnumformants"))
+ Pnumformants = x;
+ else if(strstr(loc, "Pstages"))
+ Pstages = x;
+ else if(strstr(loc, "Pcenterfreq"))
+ Pcenterfreq = x;
+ else if(strstr(loc, "Pgain"))
+ Pgain = x;
+ else if(strstr(loc, "Pq"))
+ Pq = x;
+ else if(strstr(loc, "Poctavesfreq"))
+ Poctavesfreq = x;
+
+ redraw();
+}
+void FormantFilterGraph::OSC_value(unsigned x, void *v)
+{
+ assert(x = sizeof(Pvowels));
+ memcpy(&Pvowels[0], v, x);
+ redraw();
+}
+
+void FormantFilterGraph::draw_freq_line(float freq,int type)
+{
+ const float freqx=getfreqpos(freq);
+ switch(type){
+ case 0:fl_line_style(FL_SOLID);break;
+ case 1:fl_line_style(FL_DOT);break;
+ case 2:fl_line_style(FL_DASH);break;
+ };
+
+
+ if ((freqx>0.0)&&(freqx<1.0))
+ fl_line(x()+(int) (freqx*w()),y(),
+ x()+(int) (freqx*w()),y()+h());
+}
+
+void FormantFilterGraph::update(void)
+{
+ oscWrite("Pvowels");
+ oscWrite("Pnumformants");
+ oscWrite("Pstages");
+ oscWrite("Pcenterfreq");
+ oscWrite("Poctavesfreq");
+ oscWrite("Pgain");
+ oscWrite("Pq");
+}
+
+//TODO A good portion of this is copy/pasta from EnvelopUI's widget
+// REFACTOR!
+void FormantFilterGraph::draw()
+{
+ const int maxdB=30;
+ const int ox=x(),oy=y(),lx=w(),ly=h();
+
+ fl_color(FL_BLACK);
+ fl_rectf(ox,oy,lx,ly);
+
+
+ //draw the lines
+ fl_color(FL_GRAY);
+
+ fl_line_style(FL_SOLID);
+ //fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);
+
+ const float freqx = getfreqpos(1000.0);
+ if ((freqx>0.0)&&(freqx<1.0))
+ fl_line(ox+(int) (freqx*lx),oy,
+ ox+(int) (freqx*lx),oy+ly);
+
+ for(int i=1;i<10;i++){
+ if(i==1){
+ draw_freq_line(i*100.0,0);
+ draw_freq_line(i*1000.0,0);
+ }else
+ if (i==5){
+ draw_freq_line(i*100.0,2);
+ draw_freq_line(i*1000.0,2);
+ }else{
+ draw_freq_line(i*100.0,1);
+ draw_freq_line(i*1000.0,1);
+ };
+ };
+
+ draw_freq_line(10000.0,0);
+ draw_freq_line(20000.0,1);
+
+ fl_line_style(FL_DOT);
+ int GY=10;if (ly<GY*3) GY=-1;
+ for (int i=1;i<GY;i++){
+ int tmp=(int)(ly/(float)GY*i);
+ fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
+ };
+
+ fl_color(FL_YELLOW);
+ fl_font(FL_HELVETICA,10);
+ if (*nformant < Pnumformants){
+ draw_freq_line(getformantfreq(Pvowels[*nvowel].formants[*nformant].freq),2);
+
+ //show some information (like current formant frequency,amplitude)
+ char tmpstr[20];
+
+ snprintf(tmpstr,20,"%.2f kHz",getformantfreq(Pvowels[*nvowel].formants[*nformant].freq)*0.001);
+ fl_draw(tmpstr,ox+1,oy+1,40,12,FL_ALIGN_LEFT,NULL,0);
+
+ snprintf(tmpstr,20,"%d dB",(int)( rap2dB(1e-9 +
+ getformantamp(Pvowels[*nvowel].formants[*nformant].amp))
+ + getgain()));
+ fl_draw(tmpstr,ox+1,oy+15,40,12,FL_ALIGN_LEFT,NULL,0);
+
+ };
+
+ //draw the data
+
+ fl_color(FL_RED);
+ fl_line_style(FL_SOLID);
+
+ formantfilterH(*nvowel,lx,graphpoints);
+
+ fl_line_style( FL_SOLID, 2 );
+ fl_begin_line();
+ int oiy=(int) ((graphpoints[0]/maxdB+1.0)*ly/2.0);
+ for(int i=1;i<lx;i++){
+ double iy= ((graphpoints[i]/maxdB+1.0)*ly/2.0);
+ if ((iy>=0)&&(oiy>=0)&&(iy<ly)&&(oiy<lx))
+ fl_vertex(ox+i,oy+ly-iy);
+ oiy=iy;
+ };
+ fl_end_line();
+ fl_line_style(FL_SOLID,0);
+}
+
+FormantFilterGraph::~FormantFilterGraph(void)
+{
+ delete [] graphpoints;
+}
+
+/*
+ * Parameter control
+ */
+float FormantFilterGraph::getgain()
+{
+ return (Pgain / 64.0f - 1.0f) * 30.0f; //-30..30dB
+}
+
+float FormantFilterGraph::getq()
+{
+ return expf(powf((float) Pq / 127.0f, 2) * logf(1000.0f)) - 0.9f;
+}
+
+/*
+ * Get the center frequency of the formant's graph
+ */
+float FormantFilterGraph::getcenterfreq()
+{
+ return 10000.0f * powf(10, -(1.0f - Pcenterfreq / 127.0f) * 2.0f);
+}
+
+/*
+ * Get the number of octave that the formant functions applies to
+ */
+float FormantFilterGraph::getoctavesfreq()
+{
+ return 0.25f + 10.0f * Poctavesfreq / 127.0f;
+}
+
+/*
+ * Get the frequency from x, where x is [0..1]
+ */
+float FormantFilterGraph::getfreqx(float x)
+{
+ if(x > 1.0f)
+ x = 1.0f;
+ float octf = powf(2.0f, getoctavesfreq());
+ return getcenterfreq() / sqrt(octf) * powf(octf, x);
+}
+
+/*
+ * Get the x coordinate from frequency (used by the UI)
+ */
+float FormantFilterGraph::getfreqpos(float freq)
+{
+ return (logf(freq) - logf(getfreqx(0.0f))) / logf(2.0f) / getoctavesfreq();
+}
+
+
+/*
+ * Get the freq. response of the formant filter
+ */
+void FormantFilterGraph::formantfilterH(int nvowel, int nfreqs, float *freqs)
+{
+ float c[3], d[3];
+
+ for(int i = 0; i < nfreqs; ++i)
+ freqs[i] = 0.0f;
+
+ //for each formant...
+ for(int nformant = 0; nformant < Pnumformants; ++nformant) {
+ //compute formant parameters(frequency,amplitude,etc.)
+ const float filter_freq = getformantfreq(Pvowels[nvowel].formants[nformant].freq);
+ float filter_q = getformantq(Pvowels[nvowel].formants[nformant].q) * getq();
+ if(Pstages > 0)
+ filter_q = (filter_q > 1.0f ? powf(filter_q, 1.0f / (Pstages + 1)) : filter_q);
+
+ const float filter_amp = getformantamp(Pvowels[nvowel].formants[nformant].amp);
+
+ printf("NFORMANT %d\n", nformant);
+ printf("CHARACTERISTICS: FREQ %f Q %f AMP %f\n", filter_freq, filter_q, filter_amp);
+
+
+ if(filter_freq <= (synth->samplerate / 2 - 100.0f)) {
+ const float omega = 2 * PI * filter_freq / synth->samplerate_f;
+ const float sn = sinf(omega);
+ const float cs = cosf(omega);
+ const float alpha = sn / (2 * filter_q);
+ const float tmp = 1 + alpha;
+ c[0] = alpha / tmp *sqrt(filter_q + 1);
+ c[1] = 0;
+ c[2] = -alpha / tmp *sqrt(filter_q + 1);
+ d[1] = -2 * cs / tmp * (-1);
+ d[2] = (1 - alpha) / tmp * (-1);
+ }
+ else
+ continue;
+
+
+ for(int i = 0; i < nfreqs; ++i) {
+ const float freq = getfreqx(i / (float) nfreqs);
+
+ //Discard frequencies above nyquist rate
+ if(freq > synth->samplerate / 2) {
+ for(int tmp = i; tmp < nfreqs; ++tmp)
+ freqs[tmp] = 0.0f;
+ break;
+ }
+
+ //Convert to normalized frequency
+ const float fr = freq / synth->samplerate * PI * 2.0f;
+
+ //Evaluate Complex domain ratio
+ float x = c[0], y = 0.0f;
+ for(int n = 1; n < 3; ++n) {
+ x += cosf(n * fr) * c[n];
+ y -= sinf(n * fr) * c[n];
+ }
+ float h = x * x + y * y;
+ x = 1.0f;
+ y = 0.0f;
+ for(int n = 1; n < 3; ++n) {
+ x -= cosf(n * fr) * d[n];
+ y += sinf(n * fr) * d[n];
+ }
+ h = h / (x * x + y * y);
+
+ freqs[i] += powf(h, (Pstages + 1.0f) / 2.0f) * filter_amp;
+ }
+ }
+
+ //Convert to logarithmic data ignoring points that are too small
+ for(int i = 0; i < nfreqs; ++i) {
+ if(freqs[i] > 0.000000001f)
+ freqs[i] = rap2dB(freqs[i]) + getgain();
+ else
+ freqs[i] = -90.0f;
+ }
+}
+
+/*
+ * Transforms a parameter to the real value
+ */
+float FormantFilterGraph::getformantfreq(unsigned char freq)
+{
+ return getfreqx(freq / 127.0f);
+}
+
+float FormantFilterGraph::getformantamp(unsigned char amp)
+{
+ return powf(0.1f, (1.0f - amp / 127.0f) * 4.0f);
+}
+
+float FormantFilterGraph::getformantq(unsigned char q)
+{
+ return powf(25.0f, (q - 32.0f) / 64.0f);
+}
diff --git a/src/UI/LFOUI.fl b/src/UI/LFOUI.fl
@@ -1,99 +1,104 @@
# data file for the Fltk User Interface Designer (fluid)
-version 1.0110
+version 1.0302
header_name {.h}
code_name {.cc}
-decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {}
+decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {private local
+}
-decl {//License: GNU GPL version 2 or later} {}
+decl {//License: GNU GPL version 2 or later} {private local
+}
-decl {\#include "WidgetPDial.h"} {public
+decl {\#include "Fl_Osc_Dial.H"} {public local
}
-decl {\#include <stdio.h>} {public
+decl {\#include "Fl_Osc_DialF.H"} {public local
}
-decl {\#include <stdlib.h>} {public
+decl {\#include "Fl_Osc_Choice.H"} {public local
}
-decl {\#include "../globals.h"} {public
+decl {\#include "Fl_Osc_Check.H"} {public local
}
-decl {\#include <FL/Fl_Group.H>} {public
+decl {\#include "../globals.h"} {private global
}
-decl {\#include "../Params/LFOParams.h"} {public
+decl {\#include <FL/Fl_Group.H>} {private global
}
-decl {\#include <FL/Fl_Box.H>} {public
+decl {\#include <FL/Fl_Box.H>} {private global
}
-decl {\#include <FL/fl_draw.H>} {public
+decl {\#include <FL/fl_draw.H>} {private global
}
-decl {\#include <FL/fl_ask.H>} {public
+decl {\#include <string>} {public local
}
-decl {\#include "PresetsUI.h"} {public
+decl {\#include "PresetsUI.h"} {public local
}
-decl {\#include "common.H"} {public
+decl {\#include "common.H"} {public local
}
-class LFOUI {open : {public Fl_Group, PresetsUI_}
+class LFOUI {open : {public Fl_Osc_Group, PresetsUI_}
} {
- Function {LFOUI(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
- code {pars=NULL;} {}
+ Function {LFOUI(int x,int y, int w, int h, const char *label=0):Fl_Osc_Group(x,y,w,h,label)} {open
+ } {
+ code {} {}
}
- Function {~LFOUI()} {} {
+ Function {~LFOUI()} {open
+ } {
code {lfoui->hide();
-hide();
-//delete (lfoui);} {}
+hide();} {}
}
Function {make_window()} {open
} {
- Fl_Window lfoui {open selected
- xywh {630 351 230 70} type Double color 50 labelfont 1
+ Fl_Window lfoui {open
+ xywh {636 397 230 70} type Double color 50 labelfont 1
class Fl_Group visible
} {
Fl_Group lfoparamswindow {
- label LFO
+ label LFO open
xywh {0 0 230 70} box UP_BOX color 223 labeltype ENGRAVED_LABEL labelsize 10 align 17
code0 {set_module_parameters(o);}
+ class Fl_Osc_Group
} {
Fl_Dial freq {
- label {Freq.}
- callback {pars->Pfreq=o->value();}
+ label {Freq.} selected
tooltip {LFO Frequency} xywh {5 20 30 30} box ROUND_UP_BOX labelsize 10 step 1e-05
- class WidgetPDial
+ code0 {o->init("Pfreq");}
+ class Fl_Osc_DialF
}
Fl_Dial intensity {
label Depth
- callback {pars->Pintensity=(int)o->value();}
tooltip {LFO Amount} xywh {40 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- class WidgetPDial
+ code0 {o->init("Pintensity");}
+ class Fl_Osc_Dial
}
Fl_Dial delay {
label Delay
- callback {pars->Pdelay=(int)o->value();}
tooltip {LFO delay} xywh {110 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- class WidgetPDial
+ code0 {o->init("Pdelay");}
+ class Fl_Osc_Dial
}
Fl_Dial startphase {
label Start
- callback {pars->Pstartphase=(int)o->value();}
tooltip {LFO Startphase (leftmost is Random)} xywh {75 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- class WidgetPDial
+ code0 {o->init("Pstartphase");}
+ class Fl_Osc_Dial
}
Fl_Dial randomness {
label {A.R.}
- callback {pars->Prandomness=(int)o->value();}
tooltip {LFO Amplitude Randomness} xywh {180 7 20 20} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- class WidgetPDial
+ code0 {o->init("Prandomness");}
+ class Fl_Osc_Dial
}
Fl_Choice LFOtype {
label Type
- callback {pars->PLFOtype=(int)o->value();}
tooltip {LFO function} xywh {180 40 45 15} down_box BORDER_BOX labelsize 10 align 2 textsize 8
+ code0 {o->init("PLFOtype");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label SINE
@@ -126,47 +131,52 @@ hide();
}
Fl_Check_Button continous {
label {C.}
- callback {pars->Pcontinous=(int)o->value();}
tooltip {Continous LFO} xywh {165 35 15 15} down_box DOWN_BOX labelsize 10 align 2
+ code0 {o->init("Pcontinous");}
+ class Fl_Osc_Check
}
Fl_Dial freqrand {
label {F.R.}
- callback {pars->Pfreqrand=(int)o->value();}
tooltip {LFO Frequency Randomness} xywh {205 7 20 20} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- class WidgetPDial
+ code0 {o->init("Pfreqrand");}
+ class Fl_Osc_Dial
}
Fl_Dial stretch {
label {Str.}
- callback {pars->Pstretch=(int)o->value();}
tooltip {LFO stretch} xywh {144 30 20 20} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- class WidgetPDial
+ code0 {o->init("Pstretch");}
+ class Fl_Osc_Dial
}
Fl_Button {} {
label C
- callback {presetsui->copy(pars);}
- xywh {145 10 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
+ callback {//presetsui->copy(pars);}
+ xywh {145 10 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55 deactivate
}
Fl_Button {} {
label P
- callback {presetsui->paste(pars,this);}
- xywh {162 10 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
+ callback {//presetsui->paste(pars,this);}
+ xywh {162 10 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55 deactivate
}
}
}
}
- Function {refresh()} {} {
- code {freq->value(pars->Pfreq);
-intensity->value(pars->Pintensity);
-startphase->value(pars->Pstartphase);
-delay->value(pars->Pdelay);
-continous->value(pars->Pcontinous);
-stretch->value(pars->Pstretch);
-randomness->value(pars->Prandomness);
-freqrand->value(pars->Pfreqrand);
-LFOtype->value(pars->PLFOtype);} {}
+ Function {refresh()} {open
+ } {
+ code {freq->update();
+intensity->update();
+startphase->update();
+delay->update();
+continous->update();
+stretch->update();
+randomness->update();
+freqrand->update();
+LFOtype->update();} {}
}
- Function {init(LFOParams *lfopars_)} {} {
- code {pars=lfopars_;
+ Function {init(Fl_Osc_Interface *osc_, std::string base_, std::string ext_)} {open
+ } {
+ code {base = base_;
+ ext = ext_;
+osc = osc_;
make_window();
end();
@@ -177,5 +187,4 @@ lfoui->resize(this->x(),this->y(),this->w(),this->h());
lfoparamswindow->label(this->label());} {}
}
- decl {LFOParams *pars;} {}
}
diff --git a/src/UI/MasterUI.fl b/src/UI/MasterUI.fl
@@ -1,288 +1,96 @@
# data file for the Fltk User Interface Designer (fluid)
-version 1.0110
+version 1.0302
header_name {.h}
code_name {.cc}
-decl {//Copyright (c) 2002-2009 Nasca Octavian Paul} {}
+decl {//Copyright (c) 2002-2009 Nasca Octavian Paul} {private local
+}
-decl {//License: GNU GPL version 2 or later} {}
+decl {//License: GNU GPL version 2 or later} {private local
+}
-decl {\#include <stdlib.h>} {public
+decl {\#include <stdlib.h>} {public local
}
-decl {\#include <stdio.h>} {public
+decl {\#include <stdio.h>} {public local
}
-decl {\#include <string.h>} {public
+decl {\#include <string.h>} {public local
}
-decl {\#include "WidgetPDial.h"} {public
+decl {\#include "WidgetPDial.h"} {public local
}
-decl {\#include "ADnoteUI.h"} {public
+decl {\#include "ADnoteUI.h"} {public local
}
-decl {\#include "SUBnoteUI.h"} {public
+decl {\#include "SUBnoteUI.h"} {public local
}
-decl {\#include "EffUI.h"} {public
+decl {\#include "EffUI.h"} {public local
}
-decl {\#include "VirKeyboard.h"} {public
+decl {\#include "VirKeyboard.h"} {public local
}
-decl {\#include "ConfigUI.h"} {public
+decl {\#include "ConfigUI.h"} {public local
}
-decl {\#include "BankUI.h"} {public
+decl {\#include "BankUI.h"} {public local
}
-decl {\#include "PartUI.h"} {public
+decl {\#include "PartUI.h"} {public local
}
-decl {\#include "MicrotonalUI.h"} {public
+decl {\#include "MicrotonalUI.h"} {public local
}
-decl {\#include "PresetsUI.h"} {public
+decl {\#include "PresetsUI.h"} {public local
}
decl {\#include "NioUI.h"} {public global
}
-decl {\#include "../Misc/Master.h"} {public
+decl {\#include "VuPartMeter.h"} {public local
}
-decl {\#include "../Misc/Part.h"} {public
+decl {\#include "Fl_Osc_Dial.H"} {private local
}
-decl {\#include "../Misc/Util.h"} {public
+decl {\#include "VuMasterMeter.h"} {public local
}
-decl {\#include "common.H"} {public
+decl {\#include "PartNameButton.h"} {public local
}
-decl {\#if USE_NSM
-\#include "NSM.H"
-extern NSM_Client *nsm;
-\#endif} {public
+decl {\#include "../Misc/Master.h"} {public local
}
-decl {\#include "../globals.h"} {public
+decl {\#include "../Misc/Part.h"} {public local
}
-class VUMeter {: {public Fl_Box}
-} {
- Function {VUMeter(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} {
- code {master=NULL;
-npart=-1;} {}
- }
- Function {init(Master *master_,int part_)} {} {
- code {//the "part_" parameters sets the part (if it is >=0), else it sets the master
-master=master_;
-label(NULL);
-npart=part_;
-olddbl=0.0;
-olddbr=0.0;
-oldrmsdbl=0.0;
-oldrmsdbr=0.0;} {}
- }
- Function {draw_master()} {} {
- code {\#define MIN_DB (-48)
-
-int ox=x(); int oy=y(); int lx=w(); int ly=h();
-
-vuData data = master->getVuData();
-
-//pthread_mutex_lock(&master->mutex);
-float dbl=rap2dB(data.outpeakl);
-float dbr=rap2dB(data.outpeakr);
-float rmsdbl=rap2dB(data.rmspeakl);
-float rmsdbr=rap2dB(data.rmspeakr);
-float maxdbl=rap2dB(data.maxoutpeakl);
-float maxdbr=rap2dB(data.maxoutpeakr);
-int clipped=data.clipped;
-//pthread_mutex_unlock(&master->mutex);
-
-dbl=(MIN_DB-dbl)/MIN_DB;
-if (dbl<0.0) dbl=0.0;
- else if (dbl>1.0)dbl=1.0;
-
-dbr=(MIN_DB-dbr)/MIN_DB;
-if (dbr<0.0) dbr=0.0;
- else if (dbr>1.0) dbr=1.0;
-
-dbl=dbl*0.4+olddbl*0.6;
-dbr=dbr*0.4+olddbr*0.6;
-
-if ( damage() & FL_DAMAGE_USER1 )
-{
- if ( olddbl == dbl && olddbr == dbr )
- return;
-}
-
-olddbl=dbl;
-olddbr=dbr;
-
-\#define VULENX (lx-35)
-\#define VULENY (ly/2-3)
-
-dbl*=VULENX;dbr*=VULENX;
-
-int idbl=(int) dbl;
-int idbr=(int) dbr;
-
-//compute RMS - start
-rmsdbl=(MIN_DB-rmsdbl)/MIN_DB;
-if (rmsdbl<0.0) rmsdbl=0.0;
- else if (rmsdbl>1.0) rmsdbl=1.0;
-
-rmsdbr=(MIN_DB-rmsdbr)/MIN_DB;
-if (rmsdbr<0.0) rmsdbr=0.0;
- else if (rmsdbr>1.0) rmsdbr=1.0;
-
-rmsdbl=rmsdbl*0.4+oldrmsdbl*0.6;
-rmsdbr=rmsdbr*0.4+oldrmsdbr*0.6;
-
-oldrmsdbl=rmsdbl;
-oldrmsdbr=rmsdbr;
-
-
-rmsdbl*=VULENX;rmsdbr*=VULENX;
-
-int irmsdbl=(int) rmsdbl;
-int irmsdbr=(int) rmsdbr;
-//compute RMS - end
-
-
-
-//draw the vu-meter lines
-//db
-fl_rectf(ox,oy,idbr,VULENY,0,200,255);
-fl_rectf(ox,oy+ly/2,idbl,VULENY,0,200,255);
-//black
-fl_rectf(ox+idbr,oy,VULENX-idbr,VULENY,0,0,0);
-fl_rectf(ox+idbl,oy+ly/2,VULENX-idbl,VULENY,0,0,0);
-
-//draw the scales
-float tmp=VULENX*1.0/MIN_DB;
-for (int i=1;i<1-MIN_DB;i++){
- int tx=VULENX+(int) (tmp*i);
- fl_rectf(ox+tx,oy,1,VULENY+ly/2,0,160,200);
- if (i%5==0) fl_rectf(ox+tx,oy,1,VULENY+ly/2,0,230,240);
- if (i%10==0) fl_rectf(ox+tx-1,oy,2,VULENY+ly/2,0,225,255);
-};
-
-//rms
-if (irmsdbr>2) fl_rectf(ox+irmsdbr-1,oy,3,VULENY,255,255,0);
-if (irmsdbl>2) fl_rectf(ox+irmsdbl-1,oy+ly/2,3,VULENY,255,255,0);
-
-
-//draw the red box if clipping has occured
-if (clipped==0) fl_rectf(ox+VULENX+2,oy+1,lx-VULENX-3,ly-4,0,0,10);
- else fl_rectf(ox+VULENX+2,oy+1,lx-VULENX-3,ly-4,250,10,10);
-
-//draw the maxdB
-fl_font(FL_HELVETICA|FL_BOLD,10);
-fl_color(255,255,255);
-char tmpstr[10];
-if ((maxdbl>MIN_DB-20)){
- snprintf((char *)&tmpstr,10,"%ddB",(int)maxdbr);
- fl_draw(tmpstr,ox+VULENX+1,oy+1,lx-VULENX-1,VULENY,FL_ALIGN_RIGHT,NULL,0);
-};
-if ((maxdbr>MIN_DB-20)){
- snprintf((char *)&tmpstr,10,"%ddB",(int)maxdbl);
- fl_draw(tmpstr,ox+VULENX+1,oy+ly/2+1,lx-VULENX-1,VULENY,FL_ALIGN_RIGHT,NULL,0);
-};} {}
- }
- Function {draw_part()} {} {
- code {\#define MIN_DB (-48)
-int ox=x(); int oy=y(); int lx=w(); int ly=h();
-
-if (!active_r()){
- pthread_mutex_lock(&master->vumutex);
- int fakedb=master->fakepeakpart[npart];
- pthread_mutex_unlock(&master->vumutex);
- fl_rectf(ox,oy,lx,ly,140,140,140);
- if (fakedb>0){
- fakedb=(int)(fakedb/255.0*ly)+4;
- fl_rectf(ox+2,oy+ly-fakedb,lx-4,fakedb,0,0,0);
- };
-
- return;
-};
-
-//draw the vu lines
-pthread_mutex_lock(&master->vumutex);
- float db=rap2dB(master->vuoutpeakpart[npart]);
-pthread_mutex_unlock(&master->vumutex);
-
-db=(MIN_DB-db)/MIN_DB;
-if (db<0.0) db=0.0;
- else if (db>1.0) db=1.0;
-
-db*=ly-2;
-
-int idb=(int) db;
+decl {\#include "../Misc/Util.h"} {public local
+}
-fl_rectf(ox,oy+ly-idb,lx,idb,0,200,255);
-fl_rectf(ox,oy,lx,ly-idb,0,0,0);
+decl {\#include "common.H"} {public local
+}
+decl {\#if USE_NSM
+\#include "NSM.H"
+extern NSM_Client *nsm;
+\#endif} {public local
+}
-//draw the scales
-float tmp=ly*1.0/MIN_DB;
- for (int i=1;i<1-MIN_DB;i++){
- int ty=ly+(int) (tmp*i);
- if (i%5==0) fl_rectf(ox,oy+ly-ty,lx,1,0,160,200);
- if (i%10==0) fl_rectf(ox,oy+ly-ty,lx,1,0,230,240);
-};} {}
- }
- Function {draw()} {} {
- code {if (npart>=0) draw_part();
- else draw_master();} {}
- }
- Function {tickdraw(VUMeter *o)} {return_type {static void}
- } {
- code {o->damage(FL_DAMAGE_USER1);} {}
- }
- Function {tick(void *v)} {return_type {static void}
- } {
- code {tickdraw((VUMeter *) v);
- Fl::repeat_timeout(1.0/18.0,tick,v);//18 fps} {}
- }
- Function {handle(int event)} {return_type int
- } {
- code {switch(event){
- case FL_SHOW:
- Fl::add_timeout(1.0/18.0,tick,this);
- break;
- case FL_HIDE:
- Fl::remove_timeout(tick,this);
- break;
- case FL_PUSH:
- if (npart>=0) break;
- pthread_mutex_lock(&master->mutex);
- master->vuresetpeaks();
- pthread_mutex_unlock(&master->mutex);
- break;
-};
-return(1);} {}
- }
- decl {Master *master;} {}
- decl {int npart;} {}
- decl {float olddbl,olddbr;} {}
- decl {float oldrmsdbl,oldrmsdbr;} {}
+decl {\#include "../globals.h"} {public local
}
-class SysEffSend {open : {public WidgetPDial}
+class SysEffSend {: {public Fl_Osc_Dial}
} {
- Function {SysEffSend(int x,int y, int w, int h, const char *label=0):WidgetPDial(x,y,w,h,label)} {} {
- code {master=NULL;
-neff1=0;
-neff2=0;} {}
+ Function {SysEffSend(int x,int y, int w, int h, const char *label=0):Fl_Osc_Dial(x,y,w,h,label)} {} {
+ code {} {}
}
- Function {init(Master *master_,int neff1_,int neff2_)} {} {
- code {neff1=neff1_;
-neff2=neff2_;
-master=master_;
+ Function {init(int neff1,int neff2)} {} {
+ code {
+ //TODO figure out if this extra class is even needed
minimum(0);
maximum(127);
step(1);
@@ -290,47 +98,35 @@ labelfont(1);
labelsize(10);
align(FL_ALIGN_TOP);
-value(master->Psysefxsend[neff1][neff2]);
+Fl_Osc_Dial::init("part"+to_s(neff1)+"/sysefxsend"+to_s(neff2));
char tmp[20];snprintf(tmp,20,"%d->%d",neff1+1,neff2+1);
this->copy_label(tmp);} {}
}
Function {~SysEffSend()} {} {
code {hide();} {}
}
- Function {handle(int event)} {return_type int
- } {
- code {if ((event==FL_PUSH) || (event==FL_DRAG)){
- master->setPsysefxsend(neff1,neff2,(int) value());
-};
-
-return(WidgetPDial::handle(event));} {}
- }
- decl {Master *master;} {}
- decl {int neff1;} {}
- decl {int neff2;} {}
}
-class Panellistitem {open : {public Fl_Group}
+class Panellistitem {open : {public Fl_Osc_Group}
} {
Function {make_window()} {open private
} {
Fl_Window panellistitem {open
- private xywh {608 711 100 260} type Double box NO_BOX
+ private xywh {638 721 100 260} type Double box NO_BOX
class Fl_Group visible
} {
Fl_Group panellistitemgroup {open
private xywh {0 20 70 240} box UP_FRAME
- code0 {if (master->part[npart]->Penabled==0) o->deactivate();}
+ code0 {/*if (master->part[npart]->Penabled==0) o->deactivate();*/}
code1 {set_module_parameters( o );}
} {
- Fl_Group {} {
+ Fl_Group {} {open
xywh {45 65 15 110} box ENGRAVED_FRAME
} {
- Fl_Box {} {
+ Fl_Box partvu {
label {V U}
xywh {45 65 15 110} box FLAT_BOX color 0 selection_color 75 labelcolor 55 align 128
- code0 {o->init(master,npart);}
- class VUMeter
+ class VuPartMeter
}
}
Fl_Button partname {
@@ -341,17 +137,18 @@ class Panellistitem {open : {public Fl_Group}
};
bankui->show();}
xywh {5 27 60 30} box THIN_DOWN_BOX down_box FLAT_BOX labelfont 1 labelsize 10 align 208
+ code0 {o->ext = "Pname";o->oscRegister("Pname");}
+ class PartNameButton
}
Fl_Slider partvolume {
- callback {master->part[npart]->setPvolume((int) o->value());}
xywh {10 65 30 110} type {Vert Knob} box NO_BOX minimum 127 maximum 0 step 1 value 127
- code0 {o->value(master->part[npart]->Pvolume);}
+ code0 {o->init("Pvolume", 'c');}
+ class Fl_Osc_Slider
}
Fl_Dial partpanning {
- callback {master->part[npart]->setPpanning((int) o->value());}
xywh {20 180 30 30} maximum 127 step 1
- code0 {o->value(master->part[npart]->Ppanning);}
- class WidgetPDial
+ code0 {o->init("Ppanning");}
+ class Fl_Osc_Dial
}
Fl_Button {} {
label edit
@@ -362,58 +159,48 @@ bankui->show();}
xywh {15 235 40 20} labelsize 10
}
Fl_Choice partrcv {
- callback {master->part[npart]->Prcvchn=(int) o->value();}
tooltip {receive from Midi channel} xywh {10 213 50 15} down_box BORDER_BOX labelsize 10 align 5 textfont 1 textsize 10
code0 {char nrstr[10]; for(int i=0;i<NUM_MIDI_CHANNELS;i++){sprintf(nrstr,"Ch%d",i+1);if (i!=9) o->add(nrstr); else o->add("Dr10");};}
- code1 {o->value(master->part[npart]->Prcvchn);}
+ code1 {o->init("Prcvchn");}
+ class Fl_Osc_Choice
} {}
}
Fl_Check_Button partenabled {
label 01
- callback {pthread_mutex_lock(&master->mutex);
- master->partonoff(npart,(int) o->value());
-pthread_mutex_unlock(&master->mutex);
-
+ callback {o->oscWrite("Penabled", o->value() ? "T" : "F");
if ((int) o->value()==0) panellistitemgroup->deactivate();
else {
panellistitemgroup->activate();
+ /*
if ((int)bankui->cbwig->value()!=(npart+1)){
bankui->cbwig->value(npart+1);
bankui->cbwig->do_callback();
- };
+ };*/
};
o->redraw();}
private xywh {5 0 45 20} down_box DOWN_BOX labeltype EMBOSSED_LABEL labelfont 1 labelsize 13 align 24
code0 {char tmp[10];snprintf(tmp,10,"%d",npart+1);o->copy_label(tmp);}
- code1 {o->value(master->part[npart]->Penabled);}
+ code1 {o->init("Penabled");}
+ class Fl_Osc_Check
}
}
}
- Function {Panellistitem(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
+ Function {Panellistitem(int x,int y, int w, int h, const char *label=0):Fl_Osc_Group(x,y,w,h,label)} {} {
code {npart=0;
-master=NULL;
bankui=NULL;} {}
}
- Function {init(Master *master_, int npart_,BankUI *bankui_)} {} {
+ Function {init(int npart_,BankUI *bankui_)} {} {
code {npart=npart_;
-master=master_;
bankui=bankui_;
+ext = "part"+to_s(npart)+"/";
make_window();
panellistitem->show();
end();} {}
}
Function {refresh()} {} {
- code {partenabled->value(master->part[npart]->Penabled);
-if (master->part[npart]->Penabled!=0) panellistitemgroup->activate();
- else panellistitemgroup->deactivate();
-
-partvolume->value(master->part[npart]->Pvolume);
-partpanning->value(master->part[npart]->Ppanning);
-partrcv->value(master->part[npart]->Prcvchn);
-
-partname->label((char *)master->part[npart]->Pname);
+ code {
if ((int)bankui->cbwig->value()!=(npart+1))
panellistitemgroup->color(fl_rgb_color(160,160,160));
@@ -423,12 +210,12 @@ else
panellistitemgroup->redraw();} {}
}
Function {~Panellistitem()} {} {
- code {panellistitem->hide();
-//delete(panellistitem);} {}
+ code {} {}
+ }
+ decl {int npart;} {private local
+ }
+ decl {BankUI *bankui;} {private local
}
- decl {int npart;} {}
- decl {Master *master;} {}
- decl {BankUI *bankui;} {}
}
class MasterUI {open
@@ -450,23 +237,27 @@ class MasterUI {open
*exitprogram=1;
};
} open
- xywh {80 370 390 525} type Double xclass zynaddsubfx visible
+ xywh {330 365 390 525} type Double xclass zynaddsubfx visible
} {
- Fl_Menu_Bar mastermenu {
- xywh {-5 0 690 25}
+ Fl_Group win_root {open
+ xywh {0 0 390 525}
+ class Fl_Osc_Group
} {
- Submenu {} {
- label {&File}
- xywh {0 0 100 20}
+ Fl_Menu_Bar mastermenu {
+ xywh {0 5 690 25}
} {
- MenuItem {} {
- label {&New (erase all)...}
- callback {do_new_master();}
- xywh {20 20 100 20}
- }
- MenuItem {} {
- label {&Open Parameters...}
- callback {\#if USE_NSM
+ Submenu {} {
+ label {&File}
+ xywh {5 5 100 20}
+ } {
+ MenuItem {} {
+ label {&New (erase all)...}
+ callback {do_new_master();}
+ xywh {25 25 100 20}
+ }
+ MenuItem {} {
+ label {&Open Parameters...}
+ callback {\#if USE_NSM
if ( nsm && nsm->is_active() )
{
do_load_master();
@@ -477,11 +268,11 @@ class MasterUI {open
{
do_load_master();
}}
- xywh {20 20 100 20}
- }
- MenuItem {} {
- label {&Save All Parameters...}
- callback {\#if USE_NSM
+ xywh {25 25 100 20}
+ }
+ MenuItem {} {
+ label {&Save All Parameters...}
+ callback {\#if USE_NSM
if ( nsm && nsm->is_active() )
{
do_save_master( nsm->project_filename );
@@ -491,33 +282,23 @@ class MasterUI {open
{
do_save_master();
}}
- xywh {10 10 100 20} divider
- }
- MenuItem {} {
- label {&Load Scale Settings...}
- callback {char *filename;
+ xywh {15 15 100 20} divider
+ }
+ MenuItem {} {
+ label {&Load Scale Settings...}
+ callback {char *filename;
filename=fl_file_chooser("Open:","({*.xsz})",NULL,0);
if (filename==NULL) return;
-pthread_mutex_lock(&master->mutex);
- //clear all parameters
- master->microtonal.defaults();
-
- //load the data
- int result=master->microtonal.loadXML(filename);
-pthread_mutex_unlock(&master->mutex);
-
-
- delete microtonalui;
- microtonalui=new MicrotonalUI(&master->microtonal);
-
+osc->write("/load_xsz", "s", filename);
+/*
if (result==-10) fl_alert("Error: Could not load the file\\nbecause it is not a scale file.");
- else if (result<0) fl_alert("Error: Could not load the file.");}
- xywh {35 35 100 20}
- }
- MenuItem {} {
- label {Save Sc&ale Settings ..}
- callback {char *filename;
+ else if (result<0) fl_alert("Error: Could not load the file.");*/}
+ xywh {40 40 100 20}
+ }
+ MenuItem {} {
+ label {Save Sc&ale Settings ..}
+ callback {char *filename;
int result=0;
filename=fl_file_chooser("Save:","({*.xsz})",NULL,0);
@@ -532,90 +313,72 @@ if (result) {
};
-pthread_mutex_lock(&master->mutex);
-result=master->microtonal.saveXML(filename);
-pthread_mutex_unlock(&master->mutex);
-
-if (result<0) fl_alert("Error: Could not save the file.");
-
+osc->write("/save_xsz", "s", filename);
-updatepanel();}
- xywh {25 25 100 20}
- }
- MenuItem {} {
- label {Show Scale Settings...}
- callback {microtonalui->show();}
- xywh {0 0 100 20} divider
- }
- MenuItem {} {
- label {&Settings...}
- callback {configui->show();}
- xywh {25 25 100 20}
- }
- MenuItem {} {
- label {N&io Settings}
- callback {nioui.refresh();
+/*if (result<0) fl_alert("Error: Could not save the file.");*/
+}
+ xywh {30 30 100 20}
+ }
+ MenuItem {} {
+ label {Show Scale Settings...}
+ callback {microtonalui->show();}
+ xywh {5 5 100 20} divider
+ }
+ MenuItem {} {
+ label {&Settings...}
+ callback {configui->show();}
+ xywh {30 30 100 20}
+ }
+ MenuItem {} {
+ label {N&io Settings}
+ callback {nioui.refresh();
nioui.show();}
- xywh {0 0 36 21} divider
- }
- MenuItem {} {
- label {&Copyright...}
- callback {aboutwindow->show();}
- xywh {15 15 100 20} divider
- }
- MenuItem {} {
- label {E&xit}
- callback {masterwindow->do_callback();}
- xywh {10 10 100 20}
+ xywh {5 5 36 21} divider
+ }
+ MenuItem {} {
+ label {&Copyright...}
+ callback {aboutwindow->show();}
+ xywh {20 20 100 20} divider
+ }
+ MenuItem {} {
+ label {E&xit}
+ callback {masterwindow->do_callback();}
+ xywh {15 15 100 20}
+ }
}
- }
- Submenu {} {
- label {&Instrument}
- xywh {10 10 100 20}
- } {
- MenuItem {} {
- label {&Clear Instrument...}
- callback {if (fl_choice("Clear instrument's parameters ?","No","Yes",NULL)){
+ Submenu {} {
+ label {&Instrument}
+ xywh {15 15 100 20}
+ } {
+ MenuItem {} {
+ label {&Clear Instrument...}
+ callback {if (fl_choice("Clear instrument's parameters ?","No","Yes",NULL)){
// int npart=(int)npartcounter->value()-1;
- pthread_mutex_lock(&master->mutex);
- master->part[npart]->defaultsinstrument();
- pthread_mutex_unlock(&master->mutex);
-
- npartcounter->do_callback();
+ osc->write("/part"+to_s(npart)+"/clear");
};
updatepanel();}
- xywh {35 35 100 20}
- }
- MenuItem {} {
- label {&Open Instrument...}
- callback {const char *filename;
+ xywh {40 40 100 20}
+ }
+ MenuItem {} {
+ label {&Open Instrument...}
+ callback {const char *filename;
filename=fl_file_chooser("Load:","({*.xiz})",NULL,0);
if (filename==NULL) return;
-pthread_mutex_lock(&master->mutex);
-// int npart=(int)npartcounter->value()-1;
-
- //clear all instrument parameters, first
- master->part[npart]->defaultsinstrument();
-
- //load the instr. parameters
- int result=master->part[npart]->loadXMLinstrument(filename);
-
-pthread_mutex_unlock(&master->mutex);
-master->part[npart]->applyparameters();
-
+osc->write("/load_xiz", "is", npart, filename);
npartcounter->do_callback();
updatepanel();
+/*
if (result==-10) fl_alert("Error: Could not load the file\\nbecause it is not an instrument file.");
- else if (result<0) fl_alert("Error: Could not load the file.");}
- xywh {30 30 100 20}
- }
- MenuItem {} {
- label {&Save Instrument ...}
- callback {char *filename;
+ else if (result<0) fl_alert("Error: Could not load the file.");*/}
+ xywh {35 35 100 20}
+ }
+ MenuItem {} {
+ label {&Save Instrument ...}
+ callback {char *filename;
filename=fl_file_chooser("Save:","({*.xiz})",NULL,0);
if (filename==NULL) return;
@@ -628,34 +391,29 @@ if (result) {
};
-
-pthread_mutex_lock(&master->mutex);
-result=master->part[npart]->saveXML(filename);
-pthread_mutex_unlock(&master->mutex);
-
-if (result<0) fl_alert("Error: Could not save the file.");
-
-updatepanel();}
- xywh {20 20 100 20} divider
- }
- MenuItem {} {
- label {Show Instrument &Bank...}
- callback {bankui->show();}
- xywh {0 0 100 20} divider
- }
- MenuItem {} {
- label {&Virtual Keyboard...}
- callback {virkeyboard->show();}
- xywh {10 10 100 20}
+osc->write("/save_xiz", "is", npart, filename);
+/*if (result<0) fl_alert("Error: Could not save the file.");*/
+}
+ xywh {25 25 100 20} divider
+ }
+ MenuItem {} {
+ label {Show Instrument &Bank...}
+ callback {bankui->show();}
+ xywh {5 5 100 20} divider
+ }
+ MenuItem {} {
+ label {&Virtual Keyboard...}
+ callback {virkeyboard->show();}
+ xywh {15 15 100 20}
+ }
}
- }
- Submenu recordmenu {
- label {&Record}
- xywh {0 0 100 20}
- } {
- MenuItem {} {
- label {&Choose WAV file...}
- callback {char *filename;
+ Submenu recordmenu {
+ label {&Record}
+ xywh {5 5 100 20}
+ } {
+ MenuItem {} {
+ label {&Choose WAV file...}
+ callback {char *filename;
recordbutton->deactivate();
pausebutton->deactivate();
pauselabel->deactivate();
@@ -664,165 +422,176 @@ filename=fl_file_chooser("Record to audio file:","(*.wav)",NULL,0);
if (filename==NULL) return;
fl_filename_setext(filename,".wav");
-int result=master->HDDRecorder.preparefile(filename,0);
-if (result==1) {
- result=0;
- if (fl_choice("The file exists. \\nOverwrite it?","No","Yes",NULL))
- master->HDDRecorder.preparefile(filename,1);
-};
-if (result==0) recordbutton->activate();
+//TODO TODO Test if a file exists
+if (fl_choice("The file *might* exist. \\nOverwrite it?","No","Yes",NULL)) {
+ osc->write("/HDDRecorder/preparefile", "T");
+ recordbutton->activate();//TODO make this button osc controlled
+}
-if (result!=0) fl_alert("Error: Could not save the file.");}
- xywh {0 0 100 20}
+/*if (result!=0) fl_alert("Error: Could not save the file.");*/}
+ xywh {5 5 100 20}
+ }
}
- }
- Submenu {} {
- label Misc
- xywh {10 10 100 20}
- } {
- MenuItem {} {
- label {Switch User Interface Mode}
- callback {if (fl_choice("Switch the User Interface to Beginner mode ?","No","Yes",NULL)){
+ Submenu {} {
+ label Misc
+ xywh {15 15 100 20}
+ } {
+ MenuItem {} {
+ label {Switch User Interface Mode}
+ callback {if (fl_choice("Switch the User Interface to Beginner mode ?","No","Yes",NULL)){
masterwindow->hide();
refresh_master_ui();
simplemasterwindow->show();
config.cfg.UserInterfaceMode=2;
};}
- xywh {10 10 100 20}
+ xywh {15 15 100 20}
+ }
}
}
- }
- Fl_Dial mastervolumedial {
- label {Master Volume}
- callback {master->setPvolume((int) o->value());}
- tooltip {Master Volume} xywh {15 32 55 55} box ROUND_UP_BOX labelsize 9 align 130 maximum 127 step 1
- code0 {o->value(master->Pvolume);}
- class WidgetPDial
- }
- Fl_Counter masterkeyshiftcounter {
- label {Master KeyShift}
- callback {master->setPkeyshift((int) o->value()+64);}
- xywh {150 97 120 23} type Simple labelsize 9 minimum -64 maximum 64 step 1
- code0 {o->lstep(12);}
- code1 {o->value(master->Pkeyshift-64);}
- }
- Fl_Button {} {
- label {Panic!}
- callback {virkeyboard->relaseallkeys();
-pthread_mutex_lock(&master->mutex);
-master->shutup=1;
-pthread_mutex_unlock(&master->mutex);}
- xywh {280 29 105 53} color 90 labelfont 1
- }
- Fl_Group partuigroup {open
- xywh {0 310 390 205}
- } {
- Fl_Group partui {open selected
- xywh {0 310 383 175}
- code0 {o->init(master->part[0],master,0,bankui);}
- code1 {o->show();}
- class PartUI
- } {}
- }
- Fl_Tabs {} {open
- xywh {0 145 390 165} box UP_FRAME
- } {
- Fl_Group {} {
- label {System Effects} open
- xywh {0 162 390 145} labelsize 15 align 9
+ Fl_Box dummy {
+ xywh {25 25 25 25}
+ code0 {win_root->osc = osc;}
+ code1 {win_root->base = "/";}
+ }
+ Fl_Dial mastervolumedial {
+ label {Master Volume}
+ tooltip {Master Volume} xywh {20 37 55 55} box ROUND_UP_BOX labelsize 9 align 130 maximum 127 step 1
+ code2 {o->init("volume");}
+ class Fl_Osc_Dial
+ }
+ Fl_Counter masterkeyshiftcounter {
+ label {Master KeyShift}
+ xywh {155 102 120 23} type Simple labelsize 9 minimum -64 maximum 64 step 1
+ code0 {o->lstep(12);}
+ code1 {o->init("Pkeyshift");}
+ class Fl_Osc_Counter
+ }
+ Fl_Button {} {
+ label {Panic!}
+ callback {virkeyboard->relaseallkeys();
+ o->oscWrite("Panic");}
+ xywh {285 34 105 53} color 90 labelfont 1
+ class Fl_Osc_Button
+ }
+ Fl_Group partuigroup {open
+ xywh {5 315 390 205}
} {
- Fl_Counter syseffnocounter {
- label {Sys.Effect No.}
- callback {nsyseff=(int) o->value()-1;
-sysefftype->value(master->sysefx[nsyseff]->geteffect());
-syseffectui->refresh(master->sysefx[nsyseff]);}
- xywh {5 181 80 22} type Simple labelfont 1 labelsize 10 align 1 minimum 0 maximum 127 step 1 value 1 textfont 1
- code0 {o->bounds(1,NUM_SYS_EFX);}
- code1 {o->value(nsyseff+1);}
- }
- Fl_Choice sysefftype {
- label EffType
- callback {pthread_mutex_lock(&master->mutex);
-master->sysefx[nsyseff]->changeeffect((int) o->value());
-pthread_mutex_unlock(&master->mutex);
-syseffectui->refresh(master->sysefx[nsyseff]);}
- xywh {285 176 100 22} down_box BORDER_BOX labelsize 10
- code0 {o->value(master->sysefx[nsyseff]->geteffect());}
+ Fl_Group partui {open
+ xywh {5 315 383 175}
+ code0 {o->init("/part0/", 0,bankui,"/part0/", osc);}
+ code1 {o->show();}
+ class PartUI
+ } {}
+ }
+ Fl_Tabs {} {open
+ xywh {5 150 390 165} box UP_FRAME
+ } {
+ Fl_Group {} {
+ label {System Effects}
+ xywh {5 167 390 145} labelsize 15 align 9 hide
} {
- MenuItem {} {
- label {No Effect}
- xywh {10 10 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label Reverb
- xywh {20 20 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label Echo
- xywh {30 30 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label Chorus
- xywh {40 40 100 20} labelfont 1 labelsize 10
+ Fl_Counter syseffnocounter {
+ label {Sys.Effect No.}
+ callback {nsyseff=(int) o->value()-1;
+ syseffectuigroup->reext("sysefx"+to_s(nsyseff)+"/");
+ sysefftype->oscMove("sysefx"+to_s(nsyseff)+"/efftype");
+syseffectui->refresh();}
+ xywh {10 186 80 22} type Simple labelfont 1 labelsize 10 align 1 minimum 0 maximum 127 step 1 value 1 textfont 1
+ code0 {o->bounds(1,NUM_SYS_EFX);}
+ code1 {o->value(nsyseff+1);}
}
- MenuItem {} {
- label Phaser
- xywh {50 50 100 20} labelfont 1 labelsize 10
+ Fl_Choice sysefftype {
+ label EffType
+ callback {syseffectui->efftype = o->value();
+syseffectui->refresh();}
+ xywh {290 181 100 22} down_box BORDER_BOX labelsize 10
+ code0 {o->init("sysefx"+to_s(nsyseff)+"/efftype");}
+ class Fl_Osc_Choice
+ } {
+ MenuItem {} {
+ label {No Effect}
+ xywh {15 15 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Reverb
+ xywh {25 25 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Echo
+ xywh {35 35 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Chorus
+ xywh {45 45 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Phaser
+ xywh {55 55 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label AlienWah
+ xywh {65 65 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Distortion
+ xywh {75 75 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label EQ
+ xywh {85 85 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label DynFilter
+ xywh {95 95 100 20} labelfont 1 labelsize 10
+ }
}
- MenuItem {} {
- label AlienWah
- xywh {60 60 100 20} labelfont 1 labelsize 10
+ Fl_Group syseffectuigroup {
+ xywh {10 208 380 95} color 48
+ class Fl_Osc_Group
+ } {
+ Fl_Box {} {
+ xywh {0 0 0 0}
+ code0 {syseffectuigroup->ext = "sysefx0/";}
+ }
+ Fl_Group syseffectui {
+ xywh {10 208 380 95}
+ code0 {o->init(false);}
+ class EffUI
+ } {}
}
- MenuItem {} {
- label Distortion
- xywh {70 70 100 20} labelfont 1 labelsize 10
+ Fl_Button {} {
+ label {Send to...}
+ callback {syseffsendwindow->show();}
+ xywh {95 186 85 22} box THIN_UP_BOX labelfont 1 labelsize 11
}
- MenuItem {} {
- label EQ
- xywh {80 80 100 20} labelfont 1 labelsize 10
+ Fl_Button {} {
+ label C
+ callback {/*presetsui->copy(master->sysefx[nsyseff]);*/}
+ xywh {185 192 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 7
}
- MenuItem {} {
- label DynFilter
- xywh {90 90 100 20} labelfont 1 labelsize 10
+ Fl_Button {} {
+ label P
+ callback {/*pthread_mutex_lock(&master->mutex);
+presetsui->paste(master->sysefx[nsyseff],syseffectui);
+pthread_mutex_unlock(&master->mutex);*/}
+ xywh {215 192 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
}
}
- Fl_Group syseffectuigroup {open
- xywh {5 203 380 95} color 48
+ Fl_Group {} {
+ label {Insertion Effects} open
+ xywh {5 170 390 145} labelsize 15 align 9
} {
- Fl_Group syseffectui {
- xywh {5 203 380 95}
- code0 {o->init(master->sysefx[nsyseff]);}
- class EffUI
- } {}
- }
- Fl_Button {} {
- label {Send to...}
- callback {syseffsendwindow->show();}
- xywh {90 181 85 22} box THIN_UP_BOX labelfont 1 labelsize 11
- }
- Fl_Button {} {
- label C
- callback {presetsui->copy(master->sysefx[nsyseff]);}
- xywh {180 187 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
- }
- Fl_Button {} {
- label P
- callback {pthread_mutex_lock(&master->mutex);
-presetsui->paste(master->sysefx[nsyseff],syseffectui);
-pthread_mutex_unlock(&master->mutex);}
- xywh {210 187 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
- }
- }
- Fl_Group {} {
- label {Insertion Effects} open
- xywh {0 165 390 145} labelsize 15 align 9 hide
- } {
- Fl_Counter inseffnocounter {
- label {Ins.Effect No.}
- callback {ninseff=(int) o->value()-1;
+ Fl_Counter inseffnocounter {
+ label {Ins.Effect No.}
+ callback {ninseff=(int) o->value()-1;
+ insefftype->oscMove("insefx"+to_s(ninseff)+"/efftype");
+ inseffectuigroup->reext("insefx"+to_s(ninseff)+"/");
+ inseffpart->oscMove("Pinsparts"+to_s(ninseff));
+
+ /*
insefftype->value(master->insefx[ninseff]->geteffect());
inseffpart->value(master->Pinsparts[ninseff]+2);
-inseffectui->refresh(master->insefx[ninseff]);
+inseffectui->refresh();
if (master->Pinsparts[ninseff]!=-1) {
insefftype->activate();
@@ -832,72 +601,79 @@ if (master->Pinsparts[ninseff]!=-1) {
insefftype->deactivate();
inseffectui->deactivate();
inseffectuigroup->deactivate();
-};}
- xywh {5 183 80 22} type Simple labelfont 1 labelsize 10 align 1 minimum 0 maximum 127 step 1 value 1 textfont 1
- code0 {o->bounds(1,NUM_INS_EFX);}
- code1 {o->value(ninseff+1);}
- }
- Fl_Choice insefftype {
- label EffType
- callback {pthread_mutex_lock(&master->mutex);
+};*/}
+ xywh {10 188 80 22} type Simple labelfont 1 labelsize 10 align 1 minimum 0 maximum 127 step 1 value 1 textfont 1
+ code0 {o->bounds(1,NUM_INS_EFX);}
+ code1 {o->value(ninseff+1);}
+ }
+ Fl_Choice insefftype {
+ label EffType
+ callback {/*pthread_mutex_lock(&master->mutex);
master->insefx[ninseff]->changeeffect((int) o->value());
-pthread_mutex_unlock(&master->mutex);
-inseffectui->refresh(master->insefx[ninseff]);
+pthread_mutex_unlock(&master->mutex);*/
+inseffectui->efftype = o->value();
+inseffectui->refresh();
inseffectui->show();}
- xywh {285 173 100 22} down_box BORDER_BOX labelsize 10
- code0 {o->value(master->insefx[ninseff]->geteffect());}
- code1 {if (master->Pinsparts[ninseff]== -1) o->deactivate();}
- } {
- MenuItem {} {
- label {No Effect}
- xywh {25 25 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label Reverb
- xywh {35 35 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label Echo
- xywh {45 45 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label Chorus
- xywh {55 55 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label Phaser
- xywh {60 60 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label AlienWah
- xywh {70 70 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label Distortion
- xywh {80 80 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label EQ
- xywh {90 90 100 20} labelfont 1 labelsize 10
+ xywh {290 178 100 22} down_box BORDER_BOX labelsize 10
+ code0 {/*o->value(master->insefx[ninseff]->geteffect());*/}
+ code1 {/*if (master->Pinsparts[ninseff]== -1) o->deactivate();*/}
+ code2 {o->init("insefx"+to_s(ninseff)+"/efftype");}
+ class Fl_Osc_Choice
+ } {
+ MenuItem {} {
+ label {No Effect}
+ xywh {30 30 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Reverb
+ xywh {40 40 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Echo
+ xywh {50 50 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Chorus
+ xywh {60 60 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Phaser
+ xywh {65 65 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label AlienWah
+ xywh {75 75 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Distortion
+ xywh {85 85 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label EQ
+ xywh {95 95 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label DynFilter
+ xywh {105 105 100 20} labelfont 1 labelsize 10
+ }
}
- MenuItem {} {
- label DynFilter
- xywh {100 100 100 20} labelfont 1 labelsize 10
+ Fl_Group inseffectuigroup {open selected
+ xywh {10 210 380 95} box FLAT_BOX color 48
+ class Fl_Osc_Group
+ } {
+ Fl_Box {} {
+ xywh {0 0 0 0}
+ code0 {inseffectuigroup->ext = "insefx0/";}
+ }
+ Fl_Group inseffectui {
+ xywh {10 210 380 90} box UP_FRAME
+ code0 {o->init(true);}
+ class EffUI
+ } {}
}
- }
- Fl_Group inseffectuigroup {open
- xywh {5 205 380 95} box FLAT_BOX color 48
- } {
- Fl_Group inseffectui {
- xywh {5 205 380 90} box UP_FRAME
- code0 {o->init(master->insefx[ninseff]);}
- code1 {if (master->Pinsparts[ninseff]== -1) o->deactivate();}
- class EffUI
- } {}
- }
- Fl_Choice inseffpart {
- label {Insert To.}
- callback {master->Pinsparts[ninseff]=(int) o->value()-2;
+ Fl_Choice inseffpart {
+ label {Insert To.}
+ callback {/*master->Pinsparts[ninseff]=(int) o->value()-2;*/
if ((int) o->value()==1){
inseffectuigroup->deactivate();
insefftype->deactivate();
@@ -907,137 +683,145 @@ if ((int) o->value()==1){
insefftype->activate();
inseffectui->activate();
};
-master->insefx[ninseff]->cleanup();} open
- xywh {95 183 80 22} down_box BORDER_BOX labelfont 1 labelsize 10 align 5 textsize 10
- code0 {o->add("Master Out");o->add("Off");}
- code1 {char tmp[50]; for (int i=0;i<NUM_MIDI_PARTS;i++) {sprintf(tmp,"Part %2d",i+1);o->add(tmp);};}
- code3 {o->value(master->Pinsparts[ninseff]+2);}
- } {}
- Fl_Button {} {
- label C
- callback {presetsui->copy(master->insefx[ninseff]);}
- xywh {180 185 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
- }
- Fl_Button {} {
- label P
- callback {pthread_mutex_lock(&master->mutex);
+/*master->insefx[ninseff]->cleanup();*/} open
+ xywh {100 188 80 22} down_box BORDER_BOX labelfont 1 labelsize 10 align 5 textsize 10
+ code0 {o->add("Master Out");o->add("Off");}
+ code1 {char tmp[50]; for (int i=0;i<NUM_MIDI_PARTS;i++) {sprintf(tmp,"Part %2d",i+1);o->add(tmp);};}
+ code3 {o->init("Pinsparts"+to_s(ninseff),2);}
+ class Fl_Osc_Choice
+ } {}
+ Fl_Button {} {
+ label C
+ callback {/*presetsui->copy(master->insefx[ninseff]);*/}
+ xywh {185 190 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
+ }
+ Fl_Button {} {
+ label P
+ callback {/*pthread_mutex_lock(&master->mutex);
presetsui->paste(master->insefx[ninseff],inseffectui);
-pthread_mutex_unlock(&master->mutex);}
- xywh {210 185 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
+pthread_mutex_unlock(&master->mutex);*/}
+ xywh {215 190 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
+ }
}
}
- }
- Fl_Button {} {
- label Scales
- callback {microtonalui->show();}
- xywh {320 87 65 23} color 51 labelfont 1
- }
- Fl_Group {} {
- xywh {150 40 117 45} box UP_FRAME
- } {
- Fl_Button recordbutton {
- label {Rec.}
- callback {o->deactivate();
+ Fl_Button {} {
+ label Scales
+ callback {microtonalui->show();}
+ xywh {325 92 65 23} color 51 labelfont 1
+ }
+ Fl_Group {} {
+ xywh {155 45 117 45} box UP_FRAME
+ } {
+ Fl_Button recordbutton {
+ label {Rec.}
+ callback {o->deactivate();
recordmenu->deactivate();
recordmenu->label("&Record(*)");
stopbutton->activate();
pausebutton->activate();
pauselabel->activate();
-master->HDDRecorder.start();
-master->vuresetpeaks();
+o->oscWrite("HDDRecorder/start");
+o->oscWrite("resetvu");
mastermenu->redraw();}
- tooltip {Start Recording} xywh {159 46 21 21} box ROUND_UP_BOX color 88 labelfont 1 labelsize 10 align 2 deactivate
- }
- Fl_Button stopbutton {
- label Stop
- callback {o->deactivate();
-master->HDDRecorder.stop();
+ tooltip {Start Recording} xywh {164 51 21 21} box ROUND_UP_BOX color 88 labelfont 1 labelsize 10 align 2 deactivate
+ class Fl_Osc_Button
+ }
+ Fl_Button stopbutton {
+ label Stop
+ callback {o->deactivate();
+ o->oscWrite("HDDRecorder/stop");
recordbutton->deactivate();
pausebutton->deactivate();
pauselabel->deactivate();
recordmenu->activate();
recordmenu->label("&Record");
mastermenu->redraw();}
- tooltip {Stop Recording and close the audio file} xywh {237 46 21 21} box THIN_UP_BOX color 4 labelfont 1 labelsize 10 align 2 deactivate
- }
- Fl_Button pausebutton {
- label {@||}
- callback {o->deactivate();
-master->HDDRecorder.pause();
+ tooltip {Stop Recording and close the audio file} xywh {242 51 21 21} box THIN_UP_BOX color 4 labelfont 1 labelsize 10 align 2 deactivate
+ class Fl_Osc_Button
+ }
+ Fl_Button pausebutton {
+ label {@||}
+ callback {o->deactivate();
+o->oscWrite("HDDRecorder/pause");
recordbutton->activate();
mastermenu->redraw();}
- tooltip {Pause Recording} xywh {198 46 21 21} box THIN_UP_BOX color 4 selection_color 4 labelfont 1 labelcolor 3 align 16 deactivate
+ tooltip {Pause Recording} xywh {203 51 21 21} box THIN_UP_BOX color 4 selection_color 4 labelfont 1 labelcolor 3 align 16 deactivate
+ class Fl_Osc_Button
+ }
+ Fl_Box pauselabel {
+ label Pause
+ xywh {197 71 30 15} labelfont 1 labelsize 10 deactivate
+ }
}
- Fl_Box pauselabel {
- label Pause
- xywh {192 66 30 15} labelfont 1 labelsize 10 deactivate
+ Fl_Group {} {
+ xywh {6 495 389 55}
+ } {
+ Fl_Box mastervu {
+ label {VU-Meter}
+ xywh {10 495 380 30} box FLAT_BOX color 48 selection_color 75
+ code0 {o->init(osc);}
+ class VuMasterMeter
+ }
}
- }
- Fl_Group {} {open
- xywh {1 490 389 55}
- } {
- Fl_Box {} {
- label {VU-Meter}
- xywh {5 490 380 30} box FLAT_BOX color 48 selection_color 75
- code0 {o->init(master,-1);}
- class VUMeter
+ Fl_Check_Button nrpnbutton {
+ label NRPN
+ tooltip {Receive NRPNs} xywh {15 120 60 25} down_box DOWN_BOX labelsize 12
+ code0 {o->init("ctl.NRPN.receive");}
+ class Fl_Osc_Check
}
- }
- Fl_Check_Button nrpnbutton {
- label NRPN
- callback {master->ctl.NRPN.receive=(int) o->value();}
- tooltip {Receive NRPNs} xywh {10 115 60 25} down_box DOWN_BOX labelsize 12
- code0 {o->value(master->ctl.NRPN.receive);}
- }
- Fl_Counter npartcounter {
- callback {int nval=(int) o->value()-1;
-partuigroup->remove(partui);
+ Fl_Counter npartcounter {
+ callback {int nval=(int) o->value()-1;
+/*partuigroup->remove(partui);
delete partui;
partui=new PartUI(0,0,765,525);
partuigroup->add(partui);
-partui->init(master->part[nval],master,nval,bankui);
+char buffer[1024];
+snprintf(buffer, 1024, "/part%d/", nval);
+partui->init(master->part[nval], buffer, master, nval, bankui, "/part"+to_s(nval)+"/", osc);
partui->redraw();
o->redraw();
+*/
npart=nval;
+partui->rebase("/part"+to_s(npart)+"/");
updatepanel();
simplenpartcounter->value(nval+1);
simplenpartcounter->do_callback();}
- tooltip {The part number} xywh {5 312 50 18} type Simple labelfont 1 minimum 0 maximum 127 step 1 value 1 textfont 1
- code0 {o->bounds(1,NUM_MIDI_PARTS);}
- code1 {bankui->init(o);}
- }
- Fl_Button {} {
- label vK
- callback {virkeyboard->show();}
- tooltip {Virtual Keyboard} xywh {280 87 40 23} color 51 labelfont 1
- }
- Fl_Group {} {open
- xywh {85 32 55 110} box UP_FRAME
- } {
+ tooltip {The part number} xywh {10 317 50 18} type Simple labelfont 1 minimum 0 maximum 127 step 1 value 1 textfont 1
+ code0 {o->bounds(1,NUM_MIDI_PARTS);}
+ code1 {bankui->init(o);}
+ }
Fl_Button {} {
- label Reset
- callback {globalfinedetuneslider->value(64.0);
-globalfinedetuneslider->do_callback();}
- tooltip {Master fine detune reset} xywh {90 37 45 23} box THIN_UP_BOX labelsize 10
+ label vK
+ callback {virkeyboard->show();}
+ tooltip {Virtual Keyboard} xywh {285 92 40 23} color 51 labelfont 1
}
- Fl_Dial globalfinedetuneslider {
- label {Fine Detune}
- callback {master->microtonal.Pglobalfinedetune=(int) o->value();}
- tooltip {global fine detune} xywh {90 68 45 45} box ROUND_UP_BOX labelsize 9 align 130 maximum 127 step 1 value 64
- code0 {o->value(master->microtonal.Pglobalfinedetune);}
- class WidgetPDial
+ Fl_Group {} {
+ xywh {90 37 55 110} box UP_FRAME
+ } {
+ Fl_Button {} {
+ label Reset
+ callback {globalfinedetuneslider->value(64.0);
+globalfinedetuneslider->do_callback();}
+ tooltip {Master fine detune reset} xywh {95 42 45 23} box THIN_UP_BOX labelsize 10
+ }
+ Fl_Dial globalfinedetuneslider {
+ label {Fine Detune}
+ tooltip {global fine detune} xywh {95 73 45 45} box ROUND_UP_BOX labelsize 9 align 130 maximum 127 step 1 value 64
+ code0 {o->init("microtonal.Pglobalfinedetune");}
+ class Fl_Osc_Dial
+ }
}
- }
- Fl_Button {} {
- label {Panel Window}
- callback {updatepanel();
+ Fl_Button {} {
+ label {Panel Window}
+ callback {updatepanel();
panelwindow->show();}
- tooltip {Panel Window} xywh {280 112 105 23} color 51 labelfont 1 labelsize 10
- }
- Fl_Button sm_indicator1 {
- label SM
- xywh {350 5 35 15} box ROUNDED_BOX down_box ROUNDED_BOX color 45 selection_color 93 labelfont 3 labelcolor 39 deactivate
+ tooltip {Panel Window} xywh {285 117 105 23} color 51 labelfont 1 labelsize 10
+ }
+ Fl_Button sm_indicator1 {
+ label SM
+ xywh {355 10 35 15} box ROUNDED_BOX down_box ROUNDED_BOX color 45 selection_color 93 labelfont 3 labelcolor 39 deactivate
+ }
}
}
Fl_Window aboutwindow {
@@ -1070,11 +854,17 @@ GNU General Public License for details.}
Fl_Window syseffsendwindow {
label {System Effects Send}
xywh {171 234 120 250} type Double hide resizable
+ class Fl_Osc_Window
} {
- Fl_Scroll {} {open
+ Fl_Box {} {
+ xywh {0 0 0 0}
+ code0 {syseffsendwindow->osc = osc; assert(osc);}
+ code1 {syseffsendwindow->base = "/sysefx/";}
+ }
+ Fl_Scroll syseffscroll {open
xywh {0 45 120 170} box FLAT_BOX resizable
- code0 {for (int neff1=0;neff1<NUM_SYS_EFX;neff1++) for (int neff2=neff1+1;neff2<NUM_SYS_EFX;neff2++)}
- code1 {{syseffsend[neff1][neff2]=new SysEffSend(o->x()+(neff2-1)*35,o->y()+15+neff1*50,30,30);syseffsend[neff1][neff2]->label("aaa");syseffsend[neff1][neff2]->init(master,neff1,neff2);};}
+ code0 {syseffsendwindow->begin();for (int neff1=0;neff1<NUM_SYS_EFX;neff1++) for (int neff2=neff1+1;neff2<NUM_SYS_EFX;neff2++)}
+ code1 {{syseffsend[neff1][neff2]=new SysEffSend(o->x()+(neff2-1)*35,o->y()+15+neff1*50,30,30);syseffsend[neff1][neff2]->label("aaa");syseffsend[neff1][neff2]->init(neff1,neff2);};syseffsendwindow->end();}
} {}
Fl_Button {} {
label Close
@@ -1087,23 +877,29 @@ GNU General Public License for details.}
}
}
Fl_Window panelwindow {
- label {ZynAddSubFX Panel}
- xywh {89 59 630 635} type Double hide
+ label {ZynAddSubFX Panel} open
+ xywh {621 253 630 635} type Double
+ class Fl_Osc_Window visible
} {
- Fl_Scroll {} {
+ Fl_Box {} {
+ xywh {0 0 0 0}
+ code0 {panelwindow->osc = osc;}
+ code1 {panelwindow->base = "/";}
+ }
+ Fl_Scroll {} {open
xywh {0 5 570 310} type HORIZONTAL box THIN_UP_BOX
} {
- Fl_Pack {} {
+ Fl_Pack {} {open
xywh {5 10 560 285} type HORIZONTAL
- code0 {for (int i=0;i<NUM_MIDI_PARTS/2;i++){panellistitem[i]=new Panellistitem(0,0,70,260,"");panellistitem[i]->init(master,i,bankui);}}
+ code0 {for (int i=0;i<NUM_MIDI_PARTS/2;i++){panellistitem[i]=new Panellistitem(0,0,70,260,"");panellistitem[i]->init(i,bankui);}}
} {}
}
- Fl_Scroll {} {
+ Fl_Scroll {} {open
xywh {0 320 570 310} type HORIZONTAL box THIN_UP_BOX
} {
- Fl_Pack {} {
+ Fl_Pack {} {open
xywh {5 325 560 285} type HORIZONTAL
- code0 {for (int i=NUM_MIDI_PARTS/2;i<NUM_MIDI_PARTS;i++){panellistitem[i]=new Panellistitem(0,0,70,260,"");panellistitem[i]->init(master,i,bankui);}}
+ code0 {for (int i=NUM_MIDI_PARTS/2;i<NUM_MIDI_PARTS;i++){panellistitem[i]=new Panellistitem(0,0,70,260,"");panellistitem[i]->init(i,bankui);}}
} {}
}
Fl_Button {} {
@@ -1128,8 +924,13 @@ if (fl_choice("Exit and leave the unsaved data?","No","Yes",NULL))
*exitprogram=1;
};
} open
- xywh {283 262 600 335} type Double visible
+ xywh {661 384 600 335} type Double visible
} {
+ Fl_Box {} {
+ xywh {0 0 0 0}
+ code0 {simplemasterwindow->osc = osc;}
+ code1 {simplemasterwindow->base = "/";}
+ }
Fl_Menu_Bar simplemastermenu {
xywh {0 0 690 25}
} {
@@ -1188,22 +989,11 @@ filename=fl_file_chooser("Load:","({*.xiz})",NULL,0);
if (filename==NULL) return;
-pthread_mutex_lock(&master->mutex);
-// int npart=(int)npartcounter->value()-1;
-
- //clear all instrument parameters, first
- master->part[npart]->defaultsinstrument();
-
- //load the instr. parameters
- int result=master->part[npart]->loadXMLinstrument(filename);
-
-pthread_mutex_unlock(&master->mutex);
-master->part[npart]->applyparameters();
-
+osc->write("/load_xiz", "si", filename, npart);
simplenpartcounter->do_callback();
-
+/*
if (result==-10) fl_alert("Error: Could not load the file\\nbecause it is not an instrument file.");
- else if (result<0) fl_alert("Error: Could not load the file.");}
+ else if (result<0) fl_alert("Error: Could not load the file.");*/}
xywh {40 40 100 20}
}
MenuItem {} {
@@ -1228,10 +1018,14 @@ if (result==-10) fl_alert("Error: Could not load the file\\nbecause it is not an
}
}
}
- Fl_Group simplelistitemgroup {open
+ Fl_Group simplelistitemgroup {
private xywh {125 65 215 145} box UP_FRAME
- code0 {if (master->part[npart]->Penabled==0) o->deactivate();}
+ class Fl_Osc_Group
} {
+ Fl_Box {} {
+ xywh {0 0 0 0}
+ code0 {simplelistitemgroup->ext = "part0/";}
+ }
Fl_Button partname {
callback {if ((int)bankui->cbwig->value()!=(npart+1)){
bankui->cbwig->value(npart+1);
@@ -1239,27 +1033,28 @@ if (result==-10) fl_alert("Error: Could not load the file\\nbecause it is not an
};
bankui->show();}
xywh {130 72 205 18} box THIN_DOWN_BOX down_box FLAT_BOX color 50 labelfont 1 labelsize 11 align 208
+ code0 {o->ext = "Pname";o->oscRegister("Pname");}
+ class PartNameButton
}
Fl_Slider partpanning {
label Pan
- callback {master->part[npart]->setPpanning((int) o->value());}
xywh {185 95 145 15} type {Horz Knob} box NO_BOX labelsize 11 maximum 127 step 1 value 64
- code0 {o->value(master->part[npart]->Ppanning);}
+ code0 {o->init("Ppanning",'c');}
+ class Fl_Osc_Slider
}
Fl_Choice partrcv {
label {Midi Channel Receive}
callback {virkeys->relaseallkeys(0);
-master->part[npart]->Prcvchn=(int) o->value();
virkeys->midich=(int) o->value();} open
tooltip {receive from Midi channel} xywh {140 157 65 18} down_box BORDER_BOX labelsize 10 align 130 textfont 1
code0 {char nrstr[10]; for(int i=0;i<NUM_MIDI_CHANNELS;i++){sprintf(nrstr,"Ch%d",i+1);if (i!=9) o->add(nrstr); else o->add("Dr10");};}
- code1 {o->value(master->part[npart]->Prcvchn);}
+ code1 {o->init("Prcvchn");}
+ class Fl_Osc_Choice
} {}
Fl_Dial partvolume {
- callback {master->part[npart]->setPvolume((int) o->value());}
xywh {135 95 45 40} labelsize 9 maximum 127 step 1
- code0 {o->value(master->part[npart]->Pvolume);}
- class WidgetPDial
+ code0 {o->init("Pvolume");}
+ class Fl_Osc_Dial
}
Fl_Box {} {
label Volume
@@ -1267,40 +1062,37 @@ virkeys->midich=(int) o->value();} open
}
Fl_Check_Button simplepartportamento {
label Portamento
- callback {master->part[npart]->ctl.portamento.portamento=(int) o->value();}
tooltip {Enable/Disable the portamento} xywh {193 127 79 23} down_box DOWN_BOX labelsize 9
- code0 {o->value(master->part[npart]->ctl.portamento.portamento);}
+ code0 {o->init("ctl/portamento.portamento");}
+ class Fl_Osc_Check
}
Fl_Counter simpleminkcounter {
label {Min.key}
- callback {master->part[npart]->Pminkey=(int) o->value();
-if (master->part[npart]->Pminkey>master->part[npart]->Pmaxkey) o->textcolor(FL_RED);
- else o->textcolor(FL_BLACK);}
+ callback {if (simpleminkcounter->value()>simplemaxkcounter->value()) o->textcolor(FL_RED);
+ else o->textcolor(FL_BLACK);}
tooltip {Minimum key (that the part receives NoteOn messages)} xywh {210 158 40 15} type Simple labelsize 10 minimum 0 maximum 127 step 1 textsize 10
- code0 {o->value(master->part[npart]->Pminkey);}
+ code0 {o->init("Pminkey");}
+ class Fl_Osc_Counter
}
Fl_Counter simplemaxkcounter {
label {Max.key}
- callback {master->part[npart]->Pmaxkey=(int) o->value();
-
-if (master->part[npart]->Pminkey>master->part[npart]->Pmaxkey) o->textcolor(FL_RED);
- else o->textcolor(FL_BLACK);}
+ callback {if (simpleminkcounter->value()>simplemaxkcounter->value()) o->textcolor(FL_RED);
+ else o->textcolor(FL_BLACK);}
tooltip {Maximum key (that the part receives NoteOn messages)} xywh {255 158 40 15} type Simple labelsize 10 minimum 0 maximum 127 step 1 textsize 10
- code0 {o->value(master->part[npart]->Pmaxkey);}
+ code0 {o->init("Pmaxkey");}
+ class Fl_Osc_Counter
}
Fl_Button {} {
label m
- callback {if (master->part[npart]->lastnote>=0) simpleminkcounter->value(master->part[npart]->lastnote);
-simpleminkcounter->do_callback();
-simplemaxkcounter->do_callback();}
+ callback {o->oscWrite("grabMinNote");}
tooltip {set the minimum key to the last pressed key} xywh {230 188 15 12} box THIN_UP_BOX labelsize 10
+ class Fl_Osc_Button
}
Fl_Button {} {
label M
- callback {if (master->part[npart]->lastnote>=0) simplemaxkcounter->value(master->part[npart]->lastnote);
-simplemaxkcounter->do_callback();
-simpleminkcounter->do_callback();}
+ callback {o->oscWrite("grabMaxNote");}
tooltip {set the maximum key to the last pressed key} xywh {260 188 15 12} box THIN_UP_BOX labelsize 10
+ class Fl_Osc_Button
}
Fl_Button {} {
label R
@@ -1312,15 +1104,15 @@ simplemaxkcounter->do_callback();}
}
Fl_Counter simplepartkeyshiftcounter {
label KeyShift
- callback {master->part[npart]->Pkeyshift=(int) o->value()+64;}
xywh {280 120 50 20} type Simple labelsize 11 minimum -64 maximum 64 step 1
code0 {o->lstep(12);}
- code1 {o->value(master->part[npart]->Pkeyshift-64);}
+ code1 {o->init("Pkeyshift");}
+ class Fl_Osc_Counter
}
Fl_Dial simplesyseffsend {
- callback {master->setPsysefxvol(npart,nsyseff,(int) o->value());}
xywh {300 160 30 30} maximum 127 step 1
- class WidgetPDial
+ code0 {o->init("Psysefxvol");}
+ class Fl_Osc_Dial
}
Fl_Box {} {
label Effect
@@ -1329,11 +1121,7 @@ simplemaxkcounter->do_callback();}
}
Fl_Check_Button partenabled {
label Enabled
- callback {pthread_mutex_lock(&master->mutex);
- master->partonoff(npart,(int) o->value());
-pthread_mutex_unlock(&master->mutex);
-
-if ((int) o->value()==0) simplelistitemgroup->deactivate();
+ callback {if ((int) o->value()==0) simplelistitemgroup->deactivate();
else {
simplelistitemgroup->activate();
if ((int)bankui->cbwig->value()!=(npart+1)){
@@ -1345,29 +1133,30 @@ if ((int) o->value()==0) simplelistitemgroup->deactivate();
o->redraw();}
private xywh {250 40 85 20} down_box DOWN_BOX labeltype EMBOSSED_LABEL labelfont 1 labelsize 13 align 24
code0 {//char tmp[10];snprintf(tmp,10,"%d",npart+1);o->copy_label(tmp);}
- code1 {o->value(master->part[npart]->Penabled);}
+ code1 {o->init("Penabled");}
+ class Fl_Osc_Check
}
Fl_Box virkeys {
label Keyboard
xywh {5 215 590 80} box BORDER_BOX color 17
- code0 {o->init(master);}
+ code0 {o->init(osc, "/");}
class VirKeys
}
- Fl_Group {} {open
+ Fl_Group {} {
xywh {340 30 255 185}
} {
- Fl_Tabs {} {open
+ Fl_Tabs {} {
xywh {345 35 245 175} box UP_FRAME align 18
} {
Fl_Group {} {
- label {System Effects} open
+ label {System Effects}
xywh {345 55 245 155} box UP_FRAME labelfont 1 labelsize 12 align 18
} {
Fl_Counter simplesyseffnocounter {
label {Sys.Effect No.}
callback {nsyseff=(int) o->value()-1;
-simplesysefftype->value(master->sysefx[nsyseff]->geteffect());
-simplesyseffectui->refresh(master->sysefx[nsyseff]);
+/*simplesysefftype->value(master->sysefx[nsyseff]->geteffect());*/
+simplesyseffectui->refresh();
simplerefresh();}
xywh {350 75 80 20} type Simple labelfont 1 labelsize 10 align 1 minimum 0 maximum 127 step 1 value 1 textfont 1
code0 {o->bounds(1,NUM_SYS_EFX);}
@@ -1375,12 +1164,14 @@ simplerefresh();}
}
Fl_Choice simplesysefftype {
label EffType
- callback {pthread_mutex_lock(&master->mutex);
+ callback {/*pthread_mutex_lock(&master->mutex);
master->sysefx[nsyseff]->changeeffect((int) o->value());
pthread_mutex_unlock(&master->mutex);
-simplesyseffectui->refresh(master->sysefx[nsyseff]);}
+simplesyseffectui->efftype = o->value();
+simplesyseffectui->refresh();*/}
xywh {515 80 70 15} down_box BORDER_BOX labelsize 10 align 5
- code0 {o->value(master->sysefx[nsyseff]->geteffect());}
+ code0 {o->init("sysefx"+to_s(nsyseff)+"/efftype");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label {No Effect}
@@ -1419,12 +1210,17 @@ simplesyseffectui->refresh(master->sysefx[nsyseff]);}
xywh {100 100 100 20} labelfont 1 labelsize 10
}
}
- Fl_Group simplesyseffectuigroup {open
+ Fl_Group simplesyseffectuigroup {
xywh {350 95 235 95} color 48
+ class Fl_Osc_Group
} {
+ Fl_Box {} {
+ xywh {0 0 0 0}
+ code0 {simplesyseffectuigroup->ext = "sysefx0/";}
+ }
Fl_Group simplesyseffectui {
xywh {350 95 234 95}
- code0 {o->init(master->sysefx[nsyseff]);}
+ code0 {o->init(false);}
class SimpleEffUI
} {}
}
@@ -1435,9 +1231,9 @@ simplesyseffectui->refresh(master->sysefx[nsyseff]);}
}
Fl_Button {} {
label P
- callback {pthread_mutex_lock(&master->mutex);
+ callback {/*pthread_mutex_lock(&master->mutex);
presetsui->paste(master->sysefx[nsyseff],simplesyseffectui);
-pthread_mutex_unlock(&master->mutex);}
+pthread_mutex_unlock(&master->mutex);*/}
xywh {560 65 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
}
}
@@ -1448,10 +1244,11 @@ pthread_mutex_unlock(&master->mutex);}
Fl_Counter simpleinseffnocounter {
label {Ins.Effect No.}
callback {ninseff=(int) o->value()-1;
-simpleinsefftype->value(master->insefx[ninseff]->geteffect());
-simpleinseffpart->value(master->Pinsparts[ninseff]+2);
-simpleinseffectui->refresh(master->insefx[ninseff]);
+/*simpleinsefftype->value(master->insefx[ninseff]->geteffect());
+simpleinseffpart->value(master->Pinsparts[ninseff]+2);*/
+simpleinseffectui->refresh();
+/*
if (master->Pinsparts[ninseff]!=-1) {
simpleinsefftype->activate();
simpleinseffectui->activate();
@@ -1460,21 +1257,24 @@ if (master->Pinsparts[ninseff]!=-1) {
simpleinsefftype->deactivate();
simpleinseffectui->deactivate();
simpleinseffectuigroup->deactivate();
-};}
+};*/}
xywh {350 75 80 20} type Simple labelfont 1 labelsize 10 align 1 minimum 0 maximum 127 step 1 value 1 textfont 1
code0 {o->bounds(1,NUM_INS_EFX);}
code1 {o->value(ninseff+1);}
}
Fl_Choice simpleinsefftype {
label EffType
- callback {pthread_mutex_lock(&master->mutex);
+ callback {/*pthread_mutex_lock(&master->mutex);
master->insefx[ninseff]->changeeffect((int) o->value());
-pthread_mutex_unlock(&master->mutex);
-simpleinseffectui->refresh(master->insefx[ninseff]);
+pthread_mutex_unlock(&master->mutex);*/
+simpleinseffectui->efftype = o->value();
+simpleinseffectui->refresh();
simpleinseffectui->show();}
xywh {515 80 70 15} down_box BORDER_BOX labelsize 10 align 5
- code0 {o->value(master->insefx[ninseff]->geteffect());}
- code1 {if (master->Pinsparts[ninseff]== -1) o->deactivate();}
+ code0 {/*o->value(master->insefx[ninseff]->geteffect());*/}
+ code1 {/*if (master->Pinsparts[ninseff]== -1) o->deactivate();*/}
+ code2 {o->init("insefx"+to_s(ninseff)+"/efftype");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label {No Effect}
@@ -1515,17 +1315,21 @@ simpleinseffectui->show();}
}
Fl_Group simpleinseffectuigroup {
xywh {350 95 234 95} box FLAT_BOX color 48
+ class Fl_Osc_Group
} {
+ Fl_Box {} {
+ xywh {0 0 0 0}
+ code0 {simpleinseffectuigroup->ext = "insefx0/";}
+ }
Fl_Group simpleinseffectui {
xywh {350 95 234 95}
- code0 {o->init(master->insefx[ninseff]);}
- code1 {if (master->Pinsparts[ninseff]== -1) o->deactivate();}
+ code0 {o->init(true);}
class SimpleEffUI
} {}
}
Fl_Choice simpleinseffpart {
label {Insert To.}
- callback {master->Pinsparts[ninseff]=(int) o->value()-2;
+ callback {/*master->Pinsparts[ninseff]=(int) o->value()-2;*/
if ((int) o->value()==1){
simpleinseffectuigroup->deactivate();
simpleinsefftype->deactivate();
@@ -1535,53 +1339,51 @@ if ((int) o->value()==1){
simpleinsefftype->activate();
simpleinseffectui->activate();
};
-master->insefx[ninseff]->cleanup();} open
+/*master->insefx[ninseff]->cleanup();*/} open
xywh {435 75 80 20} down_box BORDER_BOX labelfont 1 labelsize 10 align 5 textsize 10
code0 {o->add("Master Out");o->add("Off");}
code1 {char tmp[50]; for (int i=0;i<NUM_MIDI_PARTS;i++) {sprintf(tmp,"Part %2d",i+1);o->add(tmp);};}
- code3 {o->value(master->Pinsparts[ninseff]+2);}
+ code3 {/*o->value(master->Pinsparts[ninseff]+2);*/}
} {}
Fl_Button {} {
label P
- callback {pthread_mutex_lock(&master->mutex);
+ callback {/*pthread_mutex_lock(&master->mutex);
presetsui->paste(master->insefx[ninseff],simpleinseffectui);
-pthread_mutex_unlock(&master->mutex);}
+pthread_mutex_unlock(&master->mutex);*/}
xywh {560 65 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
}
}
}
}
- Fl_Group {} {open
+ Fl_Group {} {
xywh {5 300 590 30} box ENGRAVED_FRAME
} {
- Fl_Box {} {
+ Fl_Box simplemastervu {
label {VU-Meter}
xywh {5 300 590 30} box FLAT_BOX color 41 selection_color 75
- code0 {o->init(master,-1);}
- class VUMeter
+ code0 {o->init(osc);}
+ class VuMasterMeter
}
}
Fl_Dial simplemastervolumedial {
label {Master Volume}
- callback {master->setPvolume((int) o->value());}
tooltip {Master Volume} xywh {10 35 40 40} box ROUND_UP_BOX labelfont 1 labelsize 11 align 130 maximum 127 step 1
- code0 {o->value(master->Pvolume);}
- class WidgetPDial
+ code0 {o->init("Pvolume");}
+ class Fl_Osc_Dial
}
Fl_Counter simplemasterkeyshiftcounter {
label {Master KeyShift}
- callback {master->setPkeyshift((int) o->value()+64);}
xywh {15 110 90 20} labelsize 11 minimum -64 maximum 64 step 1
code0 {o->lstep(12);}
- code1 {o->value(master->Pkeyshift-64);}
+ code1 {o->init("Pkeyshift");}
+ class Fl_Osc_Counter
}
Fl_Button {} {
label {Stop ALL sounds!}
callback {virkeyboard->relaseallkeys();
-pthread_mutex_lock(&master->mutex);
-master->shutup=1;
-pthread_mutex_unlock(&master->mutex);}
+ o->oscWrite("Panic");}
xywh {5 149 115 31} color 90 labelfont 1 labelsize 10
+ class Fl_Osc_Button
}
Fl_Button {} {
label Reset
@@ -1591,10 +1393,9 @@ simpleglobalfinedetuneslider->do_callback();}
}
Fl_Dial simpleglobalfinedetuneslider {
label {Fine Detune}
- callback {master->microtonal.Pglobalfinedetune=(int) o->value();}
tooltip {global fine detune} xywh {80 50 30 30} box ROUND_UP_BOX labelsize 11 align 130 maximum 127 step 1 value 64
- code0 {o->value(master->microtonal.Pglobalfinedetune);}
- class WidgetPDial
+ code0 {o->init("microtonal.Pglobalfinedetune");}
+ class Fl_Osc_Dial
}
Fl_Counter simplenpartcounter {
label Part
@@ -1602,8 +1403,7 @@ simpleglobalfinedetuneslider->do_callback();}
npartcounter->value(o->value());
npart=(int) o->value()-1;
-simplerefresh();
-virkeys->midich=master->part[npart]->Prcvchn;}
+simplerefresh();}
tooltip {The part number} xywh {170 40 70 20} type Simple labelfont 1 align 4 minimum 0 maximum 127 step 1 value 1 textfont 1
code0 {o->bounds(1,NUM_MIDI_PARTS);}
}
@@ -1662,9 +1462,9 @@ config.cfg.UserInterfaceMode=2;}
}
}
Function {updatesendwindow()} {} {
- code {for (int neff1=0;neff1<NUM_SYS_EFX;neff1++)
+ code {/*for (int neff1=0;neff1<NUM_SYS_EFX;neff1++)
for (int neff2=neff1+1;neff2<NUM_SYS_EFX;neff2++)
- syseffsend[neff1][neff2]->value(master->Psysefxsend[neff1][neff2]);} {}
+ syseffsend[neff1][neff2]->value(master->Psysefxsend[neff1][neff2]);*/} {}
}
Function {updatepanel()} {} {
code {for (int npart=0;npart<NUM_MIDI_PARTS;npart++){
@@ -1678,9 +1478,10 @@ masterwindowlabel[99]='\\0';
masterwindow->label(&masterwindowlabel[0]);
simplemasterwindow->label(&masterwindowlabel[0]);} {}
}
- Function {MasterUI(Master *master_,int *exitprogram_)} {} {
- code {master=master_;
-exitprogram=exitprogram_;
+ Function {MasterUI(int *exitprogram_, class Fl_Osc_Interface *osc_)} {open
+ } {
+ code {exitprogram=exitprogram_;
+osc=osc_;
ninseff=0;
nsyseff=0;
npart=0;
@@ -1689,9 +1490,9 @@ for (int i=0;i<NUM_SYS_EFX;i++)
for (int j=0;j<NUM_SYS_EFX;j++)
syseffsend[i][j]=NULL;
-microtonalui=new MicrotonalUI(&master->microtonal);
-virkeyboard=new VirKeyboard(master);
-bankui=new BankUI(master,&npart);
+microtonalui=new MicrotonalUI(osc, "/microtonal/");
+virkeyboard=new VirKeyboard(osc, "/");
+bankui=new BankUI(&npart, osc);
configui=new ConfigUI();
make_window();
@@ -1730,32 +1531,18 @@ delete selectuiwindow;} {}
};} {}
}
Function {simplerefresh()} {} {
- code {partenabled->value(master->part[npart]->Penabled);
-if (master->part[npart]->Penabled!=0) simplelistitemgroup->activate();
- else simplelistitemgroup->deactivate();
-
-partvolume->value(master->part[npart]->Pvolume);
-partpanning->value(master->part[npart]->Ppanning);
-partrcv->value(master->part[npart]->Prcvchn);
-
-if (master->part[npart]->Pname[0]!=0) partname->label((char *)master->part[npart]->Pname);
- else partname->label("Click here to load a instrument");
+ code {
+/*
+ if (master->part[npart]->Pname[0]!=0) partname->label((char *)master->part[npart]->Pname);
+ else partname->label("Click here to load a instrument");
+ */
simplelistitemgroup->redraw();
-simplepartportamento->value(master->part[npart]->ctl.portamento.portamento);
-simpleminkcounter->value(master->part[npart]->Pminkey);
-simplemaxkcounter->value(master->part[npart]->Pmaxkey);
-
-simplepartkeyshiftcounter->value(master->part[npart]->Pkeyshift-64);
-simplesyseffsend->value(master->Psysefxvol[nsyseff][npart]);} {}
- }
+ }{}}
Function {do_new_master_unconditional()} {} {
code {delete microtonalui;
- pthread_mutex_lock(&master->mutex);
- master->defaults();
- pthread_mutex_unlock(&master->mutex);
-
+ osc->write("/reset_master");
npartcounter->value(1);
refresh_master_ui();
updatepanel();} {}
@@ -1767,23 +1554,14 @@ simplesyseffsend->value(master->Psysefxvol[nsyseff][npart]);} {}
}
Function {do_load_master_unconditional(const char *filename, const char *display_name)} {return_type int
} {
- code {pthread_mutex_lock(&master->mutex);
- //clear all parameters
- master->defaults();
-
- //load the data
- int result=master->loadXML(filename);
-
- master->applyparameters(false);
- pthread_mutex_unlock(&master->mutex);
-
- npartcounter->value(1);
+ code {
+ osc->write("/load_xmz", "s", filename);
refresh_master_ui();
updatepanel();
- if (result>=0) setfilelabel(display_name);
+ setfilelabel(display_name);
- return result;} {}
+ return 1;} {}
}
Function {do_load_master(const char* file = NULL)} {} {
code {const char *filename;
@@ -1821,10 +1599,7 @@ char *tmp;
}
-pthread_mutex_lock(&master->mutex);
-result=master->saveXML(filename);
-pthread_mutex_unlock(&master->mutex);
-
+ osc->write("/save_xmz", "s", filename);
if (result<0) fl_alert("Error: Could not save the file.");
else
{
@@ -1846,11 +1621,7 @@ npart=0;
npartcounter->do_callback();
syseffnocounter->do_callback();
inseffnocounter->do_callback();
-masterkeyshiftcounter->value(master->Pkeyshift-64);
-mastervolumedial->value(master->Pvolume);
-globalfinedetuneslider->value(master->microtonal.Pglobalfinedetune);
-microtonalui=new MicrotonalUI(&master->microtonal);
-nrpnbutton->value(master->ctl.NRPN.receive);
+microtonalui=new MicrotonalUI(osc, "/microtonal/");
updatesendwindow();
updatepanel();
@@ -1861,25 +1632,34 @@ simpleinseffnocounter->value(1);
simplenpartcounter->do_callback();
simplesyseffnocounter->do_callback();
simpleinseffnocounter->do_callback();
-simplemasterkeyshiftcounter->value(master->Pkeyshift-64);
-simplemastervolumedial->value(master->Pvolume);
-simpleglobalfinedetuneslider->value(master->microtonal.Pglobalfinedetune);
-virkeys->midich=master->part[npart]->Prcvchn;
simplerefresh();
bankui->hide();} {}
}
- decl {Master *master;} {}
- decl {MicrotonalUI *microtonalui;} {}
- decl {BankUI *bankui;} {}
- decl {int ninseff,npart;} {}
- decl {int nsyseff;} {}
- decl {int *exitprogram;} {}
- decl {SysEffSend *syseffsend[NUM_SYS_EFX][NUM_SYS_EFX];} {}
- decl {VirKeyboard *virkeyboard;} {}
- decl {ConfigUI *configui;} {}
- decl {int swapefftype;} {}
- decl {char masterwindowlabel[100];} {}
- decl {Panellistitem *panellistitem[NUM_MIDI_PARTS];} {}
- decl {NioUI nioui;} {}
+ decl {MicrotonalUI *microtonalui;} {private local
+ }
+ decl {BankUI *bankui;} {private local
+ }
+ decl {int ninseff,npart;} {private local
+ }
+ decl {int nsyseff;} {private local
+ }
+ decl {int *exitprogram;} {private local
+ }
+ decl {SysEffSend *syseffsend[NUM_SYS_EFX][NUM_SYS_EFX];} {private local
+ }
+ decl {VirKeyboard *virkeyboard;} {private local
+ }
+ decl {ConfigUI *configui;} {private local
+ }
+ decl {int swapefftype;} {private local
+ }
+ decl {char masterwindowlabel[100];} {private local
+ }
+ decl {Panellistitem *panellistitem[NUM_MIDI_PARTS];} {public local
+ }
+ decl {NioUI nioui;} {private local
+ }
+ decl {class Fl_Osc_Interface *osc;} {public local
+ }
}
diff --git a/src/UI/MicrotonalUI.fl b/src/UI/MicrotonalUI.fl
@@ -21,38 +21,60 @@ decl {\#include <FL/Fl_File_Chooser.H>} {public
decl {\#include <FL/fl_ask.H>} {public
}
+decl {\#include "Fl_Osc_Pane.H"} {public
+}
+
+decl {\#include "Fl_Osc_Value.H"} {public
+}
+
+decl {\#include "Fl_Osc_Check.H"} {public
+}
+
+decl {\#include "Fl_Osc_Counter.H"} {public
+}
+
+decl {\#include "Fl_Osc_Input.H"} {public
+}
+
+decl {\#include "Fl_Osc_Output.H"} {public
+}
+
decl {\#include "../Misc/Microtonal.h"} {public
}
class MicrotonalUI {} {
- Function {make_window()} {} {
+ Function {make_window(Fl_Osc_Interface *osc, std::string base)} {} {
Fl_Window microtonaluiwindow {
label Scales
xywh {99 164 405 450} type Double hide
+ class Fl_Osc_Window
} {
+ Fl_Box {} {
+ xywh {0 0 0 0}
+ code0 {microtonaluiwindow->osc = osc;}
+ code1 {microtonaluiwindow->base = base;}
+ }
Fl_Group {} {
tooltip {Center where the note's freqs. are turned upside-down} xywh {249 2 155 45} box ENGRAVED_FRAME
} {
Fl_Check_Button {} {
label {Invert keys}
- callback {microtonal->Pinvertupdown=(int) o->value();
-if (microtonal->Pinvertupdown==0) centerinvertcounter->deactivate();
+ callback {if (o->value()==0) centerinvertcounter->deactivate();
else centerinvertcounter->activate();}
tooltip {Turn upside-down the note frequencies} xywh {254 13 55 30} down_box DOWN_BOX labelfont 1 labelsize 11 align 148
- code0 {o->value(microtonal->Pinvertupdown);}
+ code0 {o->init("Pinvertupdown");}
+ class Fl_Osc_Check
}
Fl_Counter centerinvertcounter {
label Center
- callback {microtonal->Pinvertupdowncenter=(int) o->value();}
xywh {319 13 80 20} labelfont 1 labelsize 11 align 130 minimum 0 maximum 127 step 1 textfont 1
- code0 {o->lstep(microtonal->getoctavesize());}
- code1 {o->value(microtonal->Pinvertupdowncenter);}
- code2 {if (microtonal->Pinvertupdown==0) o->deactivate();}
+ code0 {o->lstep(12/*microtonal->getoctavesize()*/);}
+ code1 {o->init("Pinvertupdowncenter");}
+ class Fl_Osc_Counter
}
}
Fl_Group microtonalgroup {selected
xywh {3 49 402 398} box ENGRAVED_FRAME
- code0 {if (microtonal->Penabled==0) o->deactivate();}
} {
Fl_Button applybutton {
label Retune
@@ -61,15 +83,16 @@ if (microtonal->Pinvertupdown==0) centerinvertcounter->deactivate();
}
Fl_Value_Output octavesizeoutput {
label {nts./oct.}
- callback {o->value(microtonal->getoctavesize());}
tooltip {Notes/Octave} xywh {150 423 35 17} labelsize 10 align 5 maximum 500 step 1 value 12 textfont 1
- code0 {o->value(microtonal->getoctavesize());}
+ code0 {o->init("octavesize");}
+ class Fl_Osc_Output
}
Fl_Input nameinput {
label {Name:}
- callback {snprintf((char *)microtonal->Pname,MICROTONAL_MAX_NAME_LEN,"%s",o->value());}
xywh {8 64 285 25} labelfont 1 labelsize 11 align 5
- code0 {o->insert((char *)microtonal->Pname);}
+ code0 {o->maximum_size(MICROTONAL_MAX_NAME_LEN);}
+ code1 {o->init("Pname");}
+ class Fl_Osc_Input
}
Fl_Input tuningsinput {
label {Tunings:}
@@ -78,19 +101,20 @@ if (microtonal->Pinvertupdown==0) centerinvertcounter->deactivate();
}
Fl_Input commentinput {
label {Comment:}
- callback {snprintf((char *)microtonal->Pcomment,MICROTONAL_MAX_NAME_LEN,"%s",o->value());}
xywh {8 104 391 25} labelfont 1 labelsize 11 align 5
- code0 {o->insert((char *)microtonal->Pcomment);}
+ code0 {o->maximum_size(MICROTONAL_MAX_NAME_LEN);}
+ code1 {o->init("Pcomment");}
+ class Fl_Osc_Input
}
Fl_Counter {} {
label Shift
- callback {microtonal->Pscaleshift=(int) o->value()+64;}
- xywh {313 69 70 20} type Simple labelsize 11 align 1 minimum -63 maximum 64 step 1 textfont 1
- code0 {o->value(microtonal->Pscaleshift-64);}
+ xywh {313 69 70 20} type Simple labelsize 11 align 1 minimum -64 maximum 63 step 1 textfont 1
+ code0 {o->init("Pscaleshift");}
+ class Fl_Osc_Counter
}
Fl_Button {} {
label {Import .SCL file}
- callback {const char *filename;
+ callback {/*const char *filename;
filename=fl_file_chooser("Open:","(*.scl)",NULL,0);
if (filename==NULL) return;
int result=microtonal->loadscl(filename);
@@ -106,7 +130,7 @@ if (result==0) {
octavesizeoutput->do_callback();
} else {
fl_alert("Error: Could not load the file.");
- };}
+ };*/}
tooltip {Inport Scala .scl file (tunnings)} xywh {243 411 84 15} box THIN_UP_BOX labelfont 1 labelsize 10
}
Fl_Group keymappinggroup {
@@ -119,62 +143,59 @@ if (result==0) {
}
Fl_Counter firstnotecounter {
label {First note}
- callback {microtonal->Pfirstkey=(int) o->value();}
tooltip {First MIDI note number} xywh {199 195 42 18} type Simple labelsize 10 align 5 minimum 0 maximum 127 step 1 textfont 1 textsize 11
- code0 {o->value(microtonal->Pfirstkey);}
+ code0 {o->init("Pfirstkey");}
+ class Fl_Osc_Counter
}
Fl_Counter lastnotecounter {
label {Last note}
- callback {microtonal->Plastkey=(int) o->value();}
tooltip {Last MIDI note number} xywh {199 225 42 18} type Simple labelsize 10 align 5 minimum 0 maximum 127 step 1 value 127 textfont 1 textsize 11
- code0 {o->value(microtonal->Plastkey);}
+ code0 {o->init("Plastkey");}
+ class Fl_Osc_Counter
}
Fl_Counter middlenotecounter {
label {Midle note}
- callback {microtonal->Pmiddlenote=(int) o->value();}
tooltip {Midle note (where scale degree 0 is mapped to)} xywh {199 267 42 18} type Simple labelsize 10 align 5 minimum 0 maximum 127 step 1 value 60 textfont 1 textsize 11
- code0 {o->value(microtonal->Pmiddlenote);}
+ code0 {o->init("Pmiddlenote");}
+ class Fl_Osc_Counter
}
Fl_Value_Output mapsizeoutput {
label {Map Size}
- callback {o->value(microtonal->Pmapsize);}
xywh {201 382 44 20} labelsize 10 align 5 maximum 500 step 1 value 12 textfont 1
- code0 {o->value(microtonal->Pmapsize);}
+ code0 {o->init("Pmapsize");}
+ class Fl_Osc_Output
}
}
Fl_Check_Button mappingenabledbutton {
label ON
- callback {int x=(int) o->value();
-microtonal->Pmappingenabled=x;
-if (x==0) keymappinggroup->deactivate();
+ callback {if (o->value()==0) keymappinggroup->deactivate();
else keymappinggroup->activate();
o->show();}
tooltip {Enable the Mapping (otherwise the mapping is linear)} xywh {198 150 48 21} box FLAT_BOX down_box DOWN_BOX labelfont 1
- code0 {o->value(microtonal->Pmappingenabled);}
- code1 {if (microtonal->Pmappingenabled==0) keymappinggroup->deactivate();}
+ code0 {o->init("Pmappingenabled");}
+ class Fl_Osc_Check
}
Fl_Button {} {
label {Import .kbm file}
- callback {const char *filename;
+ callback {
+ //TODO Disabled until this can be moved into middleware
+ /*const char *filename;
filename=fl_file_chooser("Open:","(*.kbm)",NULL,0);
if (filename==NULL) return;
int result=microtonal->loadkbm(filename);
if (result==0) {
updateMappingInput();
mappinginput->position(0);
- mapsizeoutput->do_callback();
- firstnotecounter->value(microtonal->Pfirstkey);
- lastnotecounter->value(microtonal->Plastkey);
- middlenotecounter->value(microtonal->Pmiddlenote);
- mapsizeoutput->do_callback();
- mappingenabledbutton->value(microtonal->Pmappingenabled);
- mappingenabledbutton->do_callback();
- afreqinput->value(microtonal->PAfreq);
- anotecounter->value(microtonal->PAnote);
- anotecounter->do_callback();
+ mapsizeoutput->update();
+ firstnotecounter->update();
+ lastnotecounter->update();
+ middlenotecounter->update();
+ mappingenabledbutton->update();
+ afreqinput->update();
+ anotecounter->update();
} else {
fl_alert("Error: Could not load the file.");
- };}
+ };*/}
tooltip {Inport Scala .kbm file (keyboard mapping)} xywh {243 428 84 16} box THIN_UP_BOX labelfont 1 labelsize 10
}
}
@@ -183,20 +204,21 @@ if (result==0) {
} {
Fl_Counter anotecounter {
label {"A" Note}
- callback {microtonal->PAnote=(int) o->value();
-if (microtonal->getnotefreq(microtonal->PAnote,0)<0.0) o->textcolor(FL_RED);
- else o->textcolor(FL_BLACK);
+ callback {
+ /*if (microtonal->getnotefreq(o->value(),0)<0.0) o->textcolor(FL_RED);
+ else o->textcolor(FL_BLACK);*/
o->redraw();}
tooltip {The "A" note (the reference note for which freq. ("A" freq) is given)} xywh {173 17 65 20} labelfont 1 labelsize 10 align 129 minimum 0 maximum 127 step 1 value 69 textfont 1 textsize 10
code0 {o->lstep(12);}
- code1 {o->value(microtonal->PAnote);}
+ code1 {o->init("PAnote");}
+ class Fl_Osc_Counter
}
Fl_Value_Input afreqinput {
label {"A" Freq.}
- callback {microtonal->PAfreq=o->value();}
tooltip {The freq. of "A" note (default=440.0)} xywh {118 17 45 20} labelfont 1 labelsize 10 align 1 minimum 1 maximum 20000 step 0.001 value 440 textfont 1 textsize 10
- code0 {o->value(microtonal->PAfreq);}
+ code0 {o->init("PAfreq");}
+ class Fl_Osc_Value
}
}
Fl_Button {} {
@@ -206,17 +228,18 @@ o->redraw();}
}
Fl_Check_Button {} {
label {Enable Microtonal}
- callback {microtonal->Penabled=(int) o->value();
-if (microtonal->Penabled==0) microtonalgroup->deactivate();
+ callback {if (o->value()==0) microtonalgroup->deactivate();
else microtonalgroup->activate();}
xywh {3 3 102 45} box UP_BOX down_box DOWN_BOX labelfont 1 labelsize 11 align 148
- code0 {o->value(microtonal->Penabled);}
+ code0 {o->init("Penabled");}
+ class Fl_Osc_Check
}
}
}
Function {updateTuningsInput()} {} {
code {char *tmpbuf=new char[100];
+/*
tuningsinput->cut(0,tuningsinput->maximum_size());
for (int i=0;i<microtonal->getoctavesize();i++){
@@ -224,12 +247,14 @@ for (int i=0;i<microtonal->getoctavesize();i++){
microtonal->tuningtoline(i,tmpbuf,100);
tuningsinput->insert(tmpbuf);
};
+*/
delete []tmpbuf;} {}
}
Function {updateMappingInput()} {} {
code {char *tmpbuf=new char[100];
+/*
mappinginput->cut(0,tuningsinput->maximum_size());
for (int i=0;i<microtonal->Pmapsize;i++){
@@ -239,13 +264,12 @@ for (int i=0;i<microtonal->Pmapsize;i++){
else snprintf(tmpbuf,100,"%d",microtonal->Pmapping[i]);
mappinginput->insert(tmpbuf);
};
+*/
delete []tmpbuf;} {}
}
- Function {MicrotonalUI(Microtonal *microtonal_)} {} {
- code {microtonal=microtonal_;
-
-make_window();} {}
+ Function {MicrotonalUI(Fl_Osc_Interface *osc, std::string base)} {} {
+ code {make_window(osc, base);} {}
}
Function {~MicrotonalUI()} {} {
code {microtonaluiwindow->hide();
@@ -255,7 +279,7 @@ delete(microtonaluiwindow);} {}
code {microtonaluiwindow->show();} {}
}
Function {apply()} {} {
- code {int err=microtonal->texttotunings(tuningsinput->value());
+ code {/*int err=microtonal->texttotunings(tuningsinput->value());
if (err>=0) fl_alert("Parse Error: The input may contain only numbers (like 232.59)\\n or divisions (like 121/64).");
if (err==-2) fl_alert("Parse Error: The input is empty.");
octavesizeoutput->do_callback();
@@ -263,8 +287,7 @@ octavesizeoutput->do_callback();
microtonal->texttomapping(mappinginput->value());
mapsizeoutput->do_callback();
anotecounter->do_callback();
-
+*/
//applybutton->color(FL_GRAY);} {}
}
- decl {Microtonal *microtonal;} {}
}
diff --git a/src/UI/OscilGenUI.fl b/src/UI/OscilGenUI.fl
@@ -1,140 +1,74 @@
# data file for the Fltk User Interface Designer (fluid)
-version 1.0110
+version 1.0300
header_name {.h}
code_name {.cc}
-decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {}
-
-decl {//License: GNU GPL version 2 or later} {}
+decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {private local
+}
-decl {\#include "../Synth/OscilGen.h"} {public
+decl {//License: GNU GPL version 2 or later} {private local
}
-decl {\#include "../Misc/Util.h"} {public
+decl {\#include "../Synth/OscilGen.h"} {public local
}
-decl {\#include "../Misc/Master.h"} {public
+decl {\#include "../Misc/Util.h"} {public local
}
-decl {\#include "ResonanceUI.h"} {public
+decl {\#include "ResonanceUI.h"} {public local
}
-decl {\#include <FL/Fl_Box.H>} {public
+decl {\#include "Fl_Oscilloscope.h"} {public local
}
-decl {\#include <FL/Fl_Group.H>} {public
+decl {\#include "Fl_OscilSpectrum.h"} {public local
}
-decl {\#include <FL/Fl_Slider.H>} {public
+decl {\#include "Fl_Osc_Interface.h"} {public local
}
-decl {\#include <math.h>} {}
+decl {\#include <FL/Fl_Box.H>} {public local
+}
-decl {\#include <stdio.h>} {}
+decl {\#include <FL/Fl_Group.H>} {public local
+}
-decl {\#include <stdlib.h>} {}
+decl {\#include <FL/Fl_Slider.H>} {public local
+}
-decl {\#include <string.h>} {}
+decl {\#include <math.h>} {private local
+}
-decl {\#include "WidgetPDial.h"} {public
+decl {\#include <stdio.h>} {private local
}
-decl {\#include "EnvelopeUI.h"} {public
+decl {\#include <stdlib.h>} {private local
}
-decl {\#include "LFOUI.h"} {public
+decl {\#include <string.h>} {private local
}
-decl {\#include "FilterUI.h"} {public
+decl {\#include "Fl_Osc_Pane.H"} {public local
}
-decl {\#include "PresetsUI.h"} {public
+decl {\#include "Fl_Osc_Dial.H"} {public local
}
-decl {\#include <FL/fl_draw.H>} {public
+decl {\#include "Fl_Osc_Choice.H"} {public local
}
-class OscilSpectrum {: {public Fl_Box}
-} {
- Function {OscilSpectrum(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} {
- code {oscil=NULL;} {}
- }
- Function {init(OscilGen *oscil_,int oscbase_,Master *master_)} {} {
- code {oscil=oscil_;
-oscbase=oscbase_;
-master=master_;} {}
- }
- Function {draw()} {} {
- code {int ox=x(),oy=y(),lx=w(),ly=h(),i;
-const int maxdb=60;//must be multiple of 10
-int GX=2;
-int n=lx/GX-1;
-if (n>synth->oscilsize/2) n=synth->oscilsize/2;
-
-float x;
-float* spc=new float[n];
-for (i=0;i<n;i++) spc[i]=0.0;
-
-pthread_mutex_lock(&master->mutex);
-if (oscbase==0) oscil->getspectrum(n,spc,0);
- else oscil->getspectrum(n,spc,1);
-pthread_mutex_unlock(&master->mutex);
-
-//normalize
-float max=0;
-for (i=0;i<n;i++){
- x=fabs(spc[i]);
- if (max<x) max=x;
-}
-if (max<0.000001) max=1.0;
-max=max*1.05;
-
-//draw
-
-if (this->active_r()) fl_color(this->parent()->selection_color());
- else fl_color(this->parent()->color());
-fl_line_style(FL_DOT);
-
-for (i=1;i<maxdb/10;i++){
- int ky=(int)((float)i*ly*10.0/maxdb)/2;
- ky*=2;
- fl_line(ox,oy+ky-1,ox+lx-2,oy+ky-1);
-};
+decl {\#include "PresetsUI.h"} {public local
+}
-for (i=2;i<n;i++){
- int tmp=i*GX-2;
- if (i%10==1) fl_line_style(0);
- else fl_line_style(FL_DOT);
- fl_line(ox+tmp,oy+2,ox+tmp,oy+ly-2);
-}
-
-if (this->active_r()) fl_color(this->parent()->labelcolor());
- else fl_color(this->parent()->color());
-fl_line_style(0);
-
-//draws the spectrum
-for (i=0;i<n;i++){
- int tmp=i*GX+2;
- x=spc[i]/max;
-
- if (x>dB2rap(-maxdb)) x=rap2dB(x)/maxdb+1;
- else x=0;
-
- int val=(int) ((ly-2)*x);
- if (val>0) fl_line(ox+tmp,oy+ly-2-val,ox+tmp,oy+ly-2);
-}
-delete [] spc;} {}
- }
- decl {OscilGen *oscil;} {}
- decl {int oscbase;} {}
- decl {Master *master;} {}
+decl {\#include <FL/fl_draw.H>} {public local
}
-class PSlider {: {public Fl_Slider}
+class PSlider {: {public Fl_Slider, public Fl_Osc_Widget}
} {
- Function {PSlider(int x,int y, int w, int h, const char *label=0):Fl_Slider(x,y,w,h,label)} {} {
- code {;} {}
+ 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)} {return_type int
+ Function {handle(int event)} {open return_type int
} {
code {int X=x(),Y=y(),W=w(),H=h();
@@ -157,96 +91,15 @@ if (!Fl::event_inside(X,Y,W,H)) {
return(1);} {}
}
-}
-
-class Oscilloscope {open : {public Fl_Box}
-} {
- Function {Oscilloscope(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {open
+ Function {OSC_value(char c)} {open return_type void
} {
- code {oscil=NULL;
-phase=64;
-oscbase=0;
-box(FL_FLAT_BOX);} {}
- }
- Function {init(OscilGen *oscil_,Master *master_)} {} {
- code {oscil=oscil_;
-master=master_;} {}
+ code {if(phase)
+ value(c);
+else
+ value(127-c);} {}
}
- Function {init(OscilGen *oscil_,int oscbase_,Master *master_)} {} {
- code {oscil=oscil_;
-oscbase=oscbase_;
-master=master_;} {}
+ decl {bool phase;} {public local
}
- Function {init(OscilGen *oscil_,int oscbase_,int phase_,Master *master_)} {} {
- code {oscil=oscil_;
-oscbase=oscbase_;
-phase=phase_;
-master=master_;} {}
- }
- Function {draw()} {open
- } {
- code {int ox=x(),oy=y(),lx=w(),ly=h()-1,i;
-float smps[synth->oscilsize];
-pthread_mutex_lock(&master->mutex);
-if (oscbase==0) oscil->get(smps,-1.0);
- else oscil->getcurrentbasefunction(smps);
-pthread_mutex_unlock(&master->mutex);
-
-if (damage()!=1){
- fl_color( fl_color_average( FL_BLACK, FL_BACKGROUND_COLOR, 0.5 ));
- fl_rectf(ox,oy,lx,ly);
-};
-
-//normalize
-float max=0;
-for (i=0;i<synth->oscilsize;i++)
- if (max<fabs(smps[i])) max=fabs(smps[i]);
-//fprintf(stderr,"%.4f\\n",max);
-if (max<0.00001) max=1.0;
-max=-max*1.05;
-
-//draw
-fl_line_style(FL_DASH);
-if (this->active_r()) fl_color(this->parent()->labelcolor());
- else fl_color(this->parent()->color());
-int GX=16;if (lx<GX*3) GX=-1;
-for (i=1;i<GX;i++){
- int tmp=(int)(lx/(float)GX*i);
- fl_line(ox+tmp,oy+2,ox+tmp,oy+ly-2);
-};
-int GY=8;if (ly<GY*3) GY=-1;
-for (i=1;i<GY;i++){
- int tmp=(int)(ly/(float)GY*i);
- fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
-};
-
-//draw the function
-fl_line_style(0,1);
-fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);
-if (this->active_r()) fl_color(this->parent()->selection_color());
- else fl_color(this->parent()->labelcolor());
-
-fl_color( fl_color_add_alpha( fl_color(), 127 ) );
-
-int lw=2;
-//if ((lx<135)||(ly<135)) lw=1;
-fl_line_style(FL_SOLID,lw);
-fl_begin_line();
-double ph=((phase-64.0)/128.0*synth->oscilsize+synth->oscilsize);
-for (i=1;i<lx;i++){
- int k2=(synth->oscilsize*i/lx)+ph;
- double y2=smps[k2%synth->oscilsize]/max;
- fl_vertex(i+ox,y2*ly/2.0+oy+ly/2);
-};
-fl_end_line();
-
-fl_line_style(FL_SOLID,0);} {}
- }
- decl {OscilGen *oscil;} {}
- decl {int oscbase;} {}
- decl {int phase;} {public
- }
- decl {Master *master;} {}
}
class Oscilharmonic {: {public Fl_Group}
@@ -254,8 +107,8 @@ class Oscilharmonic {: {public Fl_Group}
Function {make_window()} {open private
} {
Fl_Window harmonic {open
- private xywh {338 259 100 225} type Double box NO_BOX
- class Fl_Group visible
+ private xywh {467 756 100 225} type Double box NO_BOX
+ class Fl_Osc_Group visible
} {
Fl_Slider mag {
callback {int x=64;
@@ -264,25 +117,19 @@ if (Fl::event_button3()) o->value(x);
if (x==64) o->selection_color(0);
else o->selection_color(222);
-pthread_mutex_lock(&master->mutex);
- oscil->Phmag[n]=x;
+ o->osc->writeValue(o->loc+"magnitude"+to_s(n), (char)x);
if (x==64) {
- oscil->Phphase[n]=64;
+ o->osc->writeValue(o->loc+"phase"+to_s(n), (char)64);
phase->value(64);
- };
- oscil->prepare();
-pthread_mutex_unlock(&master->mutex);
-
-display->redraw();
-oldosc->redraw();
-if (cbwidget!=NULL) {
- cbwidget->do_callback();
- applybutton->color(FL_RED);
- applybutton->redraw();
-};}
+ }
+ o->osc->requestValue(o->loc+"prepare");
+ o->osc->requestValue(o->loc+"spectrum");
+ o->osc->requestValue(o->loc+"waveform");
+
+display->redraw();}
xywh {0 15 15 115} type {Vert Knob} box NO_BOX selection_color 222 maximum 127 step 1 value 64
- code0 {o->value(127-oscil->Phmag[n]);}
- code1 {if (oscil->Phmag[n]==64) o->selection_color(0);}
+ code0 {o->phase=false;//o->value(127-oscil->Phmag[n]);}
+ code1 {//if (oscil->Phmag[n]==64) o->selection_color(0);}
class PSlider
}
Fl_Slider phase {
@@ -290,20 +137,14 @@ if (cbwidget!=NULL) {
if (Fl::event_button3()) o->value(x);
else x=(int)o->value();
-pthread_mutex_lock(&master->mutex);
- oscil->Phphase[n]=x;
- oscil->prepare();
-pthread_mutex_unlock(&master->mutex);
-
-display->redraw();
-oldosc->redraw();
-if (cbwidget!=NULL) {
- cbwidget->do_callback();
- applybutton->color(FL_RED);
- applybutton->redraw();
-};}
+o->osc->writeValue(o->loc+"phase"+to_s(n), (char) x);
+o->osc->requestValue(o->loc+"prepare");
+o->osc->requestValue(o->loc+"spectrum");
+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->value(oscil->Phphase[n]);}
+ code0 {o->phase=true;//o->value(oscil->Phphase[n]);}
class PSlider
}
Fl_Box {} {
@@ -326,39 +167,56 @@ if (cbwidget!=NULL) {
}
Function {Oscilharmonic(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
code {n=0;
-oscil=NULL;
-display=NULL;
-applybutton=NULL;
-cbwidget=NULL;} {}
+display=NULL;} {}
}
- Function {init(OscilGen *oscil_,int n_,Fl_Group *display_,Fl_Widget *oldosc_,Fl_Widget *cbwidget_,Fl_Widget *applybutton_, Master *master_)} {} {
- code {oscil=oscil_;
+ Function {init(int n_,Fl_Group *display_, std::string loc_, Fl_Osc_Interface *osc_)} {open
+ } {
+ code {assert(osc_);
+assert(!loc_.empty());
+
n=n_;
display=display_;
-master=master_;
-oldosc=oldosc_;
-cbwidget=cbwidget_;
-applybutton=applybutton_;
+osc = osc_;
+loc = loc_;
make_window();
+mag->osc = osc;
+mag->loc = loc;
+phase->osc = osc;
+phase->loc = loc;
+
+osc->createLink(loc+"magnitude"+to_s(n), mag);
+osc->createLink(loc+"phase"+to_s(n), phase);
+osc->requestValue(loc+"magnitude"+to_s(n));
+osc->requestValue(loc+"phase"+to_s(n));
end();
harmonic->show();} {}
}
- Function {refresh()} {} {
- code {mag->value(127-oscil->Phmag[n]);
-phase->value(oscil->Phphase[n]);
+ Function {refresh()} {open
+ } {
+ 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
+ } {
+ code {osc->removeLink(loc+"magnitude"+to_s(n), mag);
+osc->removeLink(loc+"phase"+to_s(n), phase);
-if (oscil->Phmag[n]==64) mag->selection_color(0);
- else mag->selection_color(222);} {}
+harmonic->hide();
+delete harmonic;} {}
+ }
+ decl {Fl_Group *display;} {private local
+ }
+ decl {int n;} {private local
}
- Function {~Oscilharmonic()} {} {
- code {harmonic->hide();
-//delete(harmonic);} {}
+ decl {Fl_Osc_Interface *osc;} {private local
+ }
+ decl {std::string loc;} {private local
}
- decl {OscilGen *oscil;} {}
- decl {Fl_Group *display;} {}
- decl {int n;} {}
- decl {Fl_Widget *oldosc,*cbwidget,*applybutton;} {}
- decl {Master *master;} {}
}
class OscilEditor {open : {public PresetsUI_}
@@ -367,274 +225,283 @@ class OscilEditor {open : {public PresetsUI_}
} {
Fl_Window osceditUI {
label {ADsynth Oscillator Editor} open
- xywh {542 193 735 595} type Double
- code0 {if (oscil->ADvsPAD) o->label("PADsynth Harmonic Content Editor");} visible
+ xywh {52 100 735 595} type Double
+ code0 {//if (oscil->ADvsPAD) o->label("PADsynth Harmonic Content Editor");} visible
} {
- Fl_Button applybutton {
- label Apply
- callback {applybutton->color(FL_GRAY);
-applybutton->redraw();
-if (cbapplywidget!=NULL) {
- cbapplywidget->do_callback();
- cbapplywidget->color(FL_GRAY);
- cbapplywidget->redraw();
-};}
- xywh {300 280 60 20} box THIN_UP_BOX labelfont 1
- code0 {if (!oscil->ADvsPAD) o->hide();}
- }
- Fl_Group oscildisplaygroup {
- xywh {5 5 360 300} box UP_FRAME
+ Fl_Group dummy {open
+ xywh {0 0 735 595} box FLAT_BOX
+ class Fl_Osc_Group
} {
- Fl_Group {} {open
- xywh {10 85 350 190} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179
- code0 {Oscilloscope *osc=new Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");}
- code1 {osc->init(oscil,master);}
- } {}
- Fl_Box {} {
- label Oscillator
- xywh {120 10 110 20} labelfont 1
- }
- Fl_Value_Slider rndslider {
- label rnd
- callback {oscil->Prand=(int)o->value()+64;
-oscildisplaygroup->redraw();
-oldosc->redraw();}
- tooltip {Oscilator Phase Randomness: smaller than 0 is "group", larger than 0 is for each harmonic} xywh {140 285 100 10} type {Horz Knob} box NO_BOX labelsize 10 align 5 minimum -64 maximum 63 step 1
- code0 {if (oscil->ADvsPAD) o->hide();}
+ Fl_Button applybutton {
+ label Apply
+ callback {//applybutton->color(FL_GRAY);
+//applybutton->redraw();
+//if (cbapplywidget!=NULL) {
+// cbapplywidget->do_callback();
+// cbapplywidget->color(FL_GRAY);
+// cbapplywidget->redraw();
+//};}
+ xywh {305 285 60 20} box THIN_UP_BOX labelfont 1
+ code0 {if(adnotep) o->hide();}
+ code1 {dummy->base = loc;}
+ code2 {dummy->osc = osc;}
}
- Fl_Group {} {open
- xywh {10 30 350 50} box THIN_DOWN_BOX color 32 selection_color 218 labelcolor 63
- code0 {OscilSpectrum *spc=new OscilSpectrum(o->x(),o->y(),o->w(),o->h(),"");}
- code1 {spc->init(oscil,0,master);}
- } {}
- Fl_Group {} {
- xywh {246 277 115 25} box UP_FRAME
- code0 {if (oscil->ADvsPAD) o->hide();}
+ Fl_Group oscildisplaygroup {open
+ xywh {10 10 360 300} box UP_FRAME
} {
- Fl_Choice hrndtype {
- label {H.rnd}
- callback {oscil->Pamprandtype=(int) o->value();}
- tooltip {Harmonic Amplitude Randomness} xywh {281 282 50 15} down_box BORDER_BOX labelsize 10 textsize 10
+ Fl_Group {} {open
+ xywh {15 90 350 190} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179
+ code0 {oscilo=new Fl_Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");}
+ code1 {oscilo->parent(o);oscilo->init(false);}
+ } {}
+ Fl_Box {} {
+ label Oscillator
+ xywh {125 15 110 20} labelfont 1
+ }
+ Fl_Value_Slider rndslider {
+ label rnd
+ callback {//oscil->Prand=(int)o->value()+64;
+oscildisplaygroup->redraw();}
+ 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 {//if (oscil->ADvsPAD) o->hide();}
+ }
+ Fl_Group {} {open
+ xywh {15 35 350 50} box THIN_DOWN_BOX color 32 selection_color 218 labelcolor 63
+ code0 {oscils=new Fl_OscilSpectrum(o->x(),o->y(),o->w(),o->h(),"");}
+ code1 {oscils->parent(o);oscils->init(false);}
+ } {}
+ Fl_Group {} {open
+ xywh {251 282 115 25} box UP_FRAME
+ code0 {if (!adnotep) o->hide();}
+ } {
+ Fl_Choice hrndtype {
+ label {H.rnd}
+ callback {//oscil->Pamprandtype=(int) o->value();}
+ tooltip {Harmonic Amplitude Randomness} xywh {286 287 50 15} down_box BORDER_BOX labelsize 10 textsize 10
+ code0 {o->init("amprandtype");}
+ class Fl_Osc_Choice
+ } {
+ MenuItem {} {
+ label None
+ xywh {65 65 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Pow
+ xywh {75 75 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Sin
+ xywh {85 85 100 20} labelfont 1 labelsize 10
+ }
+ }
+ Fl_Dial hrnddial {
+ tooltip {Oscillator's spectrum adjust parameter} xywh {345 285 18 18} maximum 127 step 1
+ code0 {o->init("amprandpower");}
+ class Fl_Osc_Dial
+ }
+ }
+ Fl_Choice magtype {
+ label {Mag.Type}
+ callback {//oscil->Phmagtype=(int) o->value();
+redrawoscil();}
+ xywh {75 285 65 20} down_box BORDER_BOX labelsize 11 when 1 textsize 11
+ code0 {o->init("hmagtype");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
- label None
- xywh {60 60 100 20} labelfont 1 labelsize 10
+ label Linear
+ xywh {10 10 100 20} labelfont 1 labelsize 11
}
MenuItem {} {
- label Pow
- xywh {70 70 100 20} labelfont 1 labelsize 10
+ label {-40dB}
+ xywh {20 20 100 20} labelfont 1 labelsize 11
}
MenuItem {} {
- label Sin
- xywh {80 80 100 20} labelfont 1 labelsize 10
+ label {-60dB}
+ xywh {30 30 100 20} labelfont 1 labelsize 11
+ }
+ MenuItem {} {
+ label {-80dB}
+ xywh {40 40 100 20} labelfont 1 labelsize 11
+ }
+ MenuItem {} {
+ label {-100dB}
+ xywh {50 50 100 20} labelfont 1 labelsize 11
}
}
- Fl_Dial hrnddial {
- callback {oscil->Pamprandpower=(int) o->value();}
- tooltip {Oscillator's spectrum adjust parameter} xywh {338 280 18 18} maximum 127 step 1
- class WidgetPDial
- }
- }
- }
- Fl_Group basefuncdisplaygroup {open selected
- xywh {365 5 360 300} box UP_FRAME
- } {
- Fl_Group {} {
- xywh {370 85 350 190} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179
- code0 {Oscilloscope *osc=new Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");}
- code1 {osc->init(oscil,1,master);}
- } {}
- Fl_Dial bfslider {
- callback {oscil->Pbasefuncpar=(int)o->value()+64;
-basefuncdisplaygroup->redraw();
-bfparval->value(oscil->Pbasefuncpar-64);
-
-redrawoscil();}
- tooltip {Base Function Parameter} xywh {520 280 20 20} minimum -64 maximum 63 step 1
- class WidgetPDial
}
- Fl_Choice bftype {
- label {Base.F..}
- callback {oscil->Pcurrentbasefunc=(int) o->value();
+ Fl_Group basefuncdisplaygroup {open
+ xywh {370 10 360 300} box UP_FRAME
+ code0 {o->base = loc;}
+ code1 {o->osc = osc;}
+ code2 {assert(osc);}
+ class Fl_Osc_Group
+ } {
+ Fl_Group {} {
+ xywh {375 90 350 190} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179
+ code0 {oscilo_base=new Fl_Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");}
+ code1 {oscilo_base->parent(o);oscilo_base->init(true);}
+ } {}
+ Fl_Dial bfslider {
+ callback {redrawoscil();}
+ tooltip {Base Function Parameter} xywh {525 285 20 20} minimum -64 maximum 63 step 1
+ code0 {o->init("basefuncpar");}
+ class Fl_Osc_Dial
+ }
+ Fl_Choice bftype {
+ label {Base.F..}
+ callback {//oscil->Pcurrentbasefunc=(int) o->value();
basefuncdisplaygroup->redraw();
redrawoscil();
-if ((oscil->Pcurrentbasefunc==0)||(oscil->Pcurrentbasefunc==127)) basefuncmodulation->deactivate();
- else basefuncmodulation->activate();}
- xywh {370 285 90 15} down_box BORDER_BOX labelsize 10 align 5 textsize 11
- } {
- MenuItem {} {
- label Sine
- xywh {10 10 100 20} labelfont 1 labelsize 11
- }
- MenuItem {} {
- label Triangle
- xywh {20 20 100 20} labelfont 1 labelsize 11
- }
- MenuItem {} {
- label Pulse
- xywh {30 30 100 20} labelfont 1 labelsize 11
- }
- MenuItem {} {
- label Saw
- xywh {40 40 100 20} labelfont 1 labelsize 11
- }
- MenuItem {} {
- label Power
- xywh {50 50 100 20} labelfont 1 labelsize 11
- }
- MenuItem {} {
- label Gauss
- xywh {50 50 100 20} labelfont 1 labelsize 11
- }
- MenuItem {} {
- label Diode
- xywh {60 60 100 20} labelfont 1 labelsize 11
- }
- MenuItem {} {
- label AbsSine
- xywh {70 70 100 20} labelfont 1 labelsize 11
- }
- MenuItem {} {
- label PulseSine
- xywh {80 80 100 20} labelfont 1 labelsize 11
- }
- MenuItem {} {
- label StrchSine
- xywh {90 90 100 20} labelfont 1 labelsize 11
- }
- MenuItem {} {
- label Chirp
- xywh {100 100 100 20} labelfont 1 labelsize 11
- }
- MenuItem {} {
- label AbsStrSine
- xywh {102 102 100 20} labelfont 1 labelsize 11
- }
- MenuItem {} {
- label Chebyshev
- xywh {112 112 100 20} labelfont 1 labelsize 11
- }
- MenuItem {} {
- label Sqr
- xywh {122 122 100 20} labelfont 1 labelsize 11
- }
- MenuItem {} {
- label Spike
- xywh {122 122 100 20} labelfont 1 labelsize 11
- }
- MenuItem {} {
- label Circle
- xywh {122 122 100 20} labelfont 1 labelsize 11
- }
- }
- Fl_Box {} {
- label {Base Func.}
- xywh {480 10 110 20} labelfont 1
- }
- Fl_Group {} {open
- xywh {370 30 350 50} box THIN_DOWN_BOX color 32 selection_color 218 labelcolor 63
- code0 {OscilSpectrum *spc=new OscilSpectrum (o->x(),o->y(),o->w(),o->h(),"");}
- code1 {spc->init(oscil,1,master);}
- } {}
- Fl_Value_Output bfparval {
- label {Par.}
- xywh {490 285 25 15} labelsize 12 minimum -63 maximum 63 step 1
- }
- Fl_Group basefuncmodulation {
- xywh {550 276 169 25} box UP_FRAME
- code0 {if ((oscil->Pcurrentbasefunc==0)||(oscil->Pcurrentbasefunc==127)) basefuncmodulation->deactivate();}
- } {
- Fl_Choice bfmodtype {
- label {B.F.Mod.}
- callback {oscil->Pbasefuncmodulation=(int) o->value();
-basefuncdisplaygroup->redraw();
-redrawoscil();}
- tooltip {Base function modulation} xywh {601 281 50 15} down_box BORDER_BOX labelsize 10 textsize 10
+//if ((oscil->Pcurrentbasefunc==0)||(oscil->Pcurrentbasefunc==127)) basefuncmodulation->deactivate();
+ //else basefuncmodulation->activate();}
+ xywh {375 290 90 15} down_box BORDER_BOX labelsize 10 align 5 when 1 textsize 11
+ code0 {o->init("currentbasefunc");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
- label None
- xywh {50 50 100 20} labelfont 1 labelsize 10
+ label Sine
+ xywh {15 15 100 20} labelfont 1 labelsize 11
}
MenuItem {} {
- label Rev
- xywh {60 60 100 20} labelfont 1 labelsize 10
+ label Triangle
+ xywh {25 25 100 20} labelfont 1 labelsize 11
}
MenuItem {} {
- label Sine
- xywh {70 70 100 20} labelfont 1 labelsize 10
+ label Pulse
+ xywh {35 35 100 20} labelfont 1 labelsize 11
}
MenuItem {} {
- label Pow
- xywh {80 80 100 20} labelfont 1 labelsize 10
+ label Saw
+ xywh {45 45 100 20} labelfont 1 labelsize 11
+ }
+ MenuItem {} {
+ label Power
+ xywh {55 55 100 20} labelfont 1 labelsize 11
+ }
+ MenuItem {} {
+ label Gauss
+ xywh {55 55 100 20} labelfont 1 labelsize 11
+ }
+ MenuItem {} {
+ label Diode
+ xywh {65 65 100 20} labelfont 1 labelsize 11
+ }
+ MenuItem {} {
+ label AbsSine
+ xywh {75 75 100 20} labelfont 1 labelsize 11
+ }
+ MenuItem {} {
+ label PulseSine
+ xywh {85 85 100 20} labelfont 1 labelsize 11
+ }
+ MenuItem {} {
+ label StrchSine
+ xywh {95 95 100 20} labelfont 1 labelsize 11
+ }
+ MenuItem {} {
+ label Chirp
+ xywh {105 105 100 20} labelfont 1 labelsize 11
+ }
+ MenuItem {} {
+ label AbsStrSine
+ xywh {107 107 100 20} labelfont 1 labelsize 11
+ }
+ MenuItem {} {
+ label Chebyshev
+ xywh {117 117 100 20} labelfont 1 labelsize 11
+ }
+ MenuItem {} {
+ label Sqr
+ xywh {127 127 100 20} labelfont 1 labelsize 11
+ }
+ MenuItem {} {
+ label Spike
+ xywh {127 127 100 20} labelfont 1 labelsize 11
+ }
+ MenuItem {} {
+ label Circle
+ xywh {127 127 100 20} labelfont 1 labelsize 11
}
}
- Fl_Dial bfmodpar1 {
- callback {oscil->Pbasefuncmodulationpar1=(int)o->value();
-basefuncdisplaygroup->redraw();
-redrawoscil();}
- tooltip {Oscillator's modulation parameter 1} xywh {659 281 15 15} maximum 127 step 1
- class WidgetPDial
- }
- Fl_Dial bfmodpar2 {
- callback {oscil->Pbasefuncmodulationpar2=(int)o->value();
-basefuncdisplaygroup->redraw();
-redrawoscil();}
- tooltip {Oscillator's modulation parameter 2} xywh {679 281 15 15} maximum 127 step 1
- class WidgetPDial
- }
- Fl_Dial bfmodpar3 {
- callback {oscil->Pbasefuncmodulationpar3=(int)o->value();
+ Fl_Box {} {
+ label {Base Func.}
+ xywh {485 15 110 20} labelfont 1
+ }
+ Fl_Group {} {open
+ xywh {375 35 350 50} box THIN_DOWN_BOX color 32 selection_color 218 labelcolor 63
+ code0 {oscils_base=new Fl_OscilSpectrum (o->x(),o->y(),o->w(),o->h(),"");}
+ code1 {oscils_base->parent(o);oscils_base->init(true);}
+ } {}
+ Fl_Value_Output bfparval {
+ label {Par.}
+ xywh {495 290 25 15} labelsize 12 minimum -63 maximum 63 step 1
+ }
+ Fl_Group basefuncmodulation {open
+ xywh {555 281 169 25} box UP_FRAME
+ code0 {//if ((oscil->Pcurrentbasefunc==0)||(oscil->Pcurrentbasefunc==127)) basefuncmodulation->deactivate();}
+ } {
+ Fl_Choice bfmodtype {
+ label {B.F.Mod.}
+ callback {//oscil->Pbasefuncmodulation=(int) o->value();
basefuncdisplaygroup->redraw();
redrawoscil();}
- tooltip {Oscillator's modulation parameter 3} xywh {699 281 15 15} maximum 127 step 1
- class WidgetPDial
+ tooltip {Base function modulation} xywh {604 286 50 15} down_box BORDER_BOX labelsize 10 when 1 textsize 10
+ code0 {o->init("basefuncmodulation");}
+ class Fl_Osc_Choice
+ } {
+ MenuItem {} {
+ label None
+ xywh {55 55 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Rev
+ xywh {65 65 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Sine
+ xywh {75 75 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Pow
+ xywh {85 85 100 20} labelfont 1 labelsize 10
+ }
+ }
+ Fl_Dial bfmodpar1 {
+ callback {redrawoscil();}
+ tooltip {Oscillator's modulation parameter 1} xywh {664 286 15 15} maximum 127 step 1
+ code0 {o->init("basefuncmodulationpar1");}
+ class Fl_Osc_Dial
+ }
+ Fl_Dial bfmodpar2 {
+ callback {redrawoscil();}
+ tooltip {Oscillator's modulation parameter 2} xywh {684 286 15 15} maximum 127 step 1
+ code0 {o->init("basefuncmodulationpar2");}
+ class Fl_Osc_Dial
+ }
+ Fl_Dial bfmodpar3 {
+ callback {redrawoscil();} selected
+ tooltip {Oscillator's modulation parameter 3} xywh {704 286 15 15} maximum 127 step 1
+ code0 {o->init("basefuncmodulationpar3");}
+ class Fl_Osc_Dial
+ }
}
}
- }
- Fl_Choice magtype {
- label {Mag.Type}
- callback {oscil->Phmagtype=(int) o->value();
-basefuncdisplaygroup->redraw();
-
-redrawoscil();}
- xywh {70 280 65 20} down_box BORDER_BOX labelsize 11 textsize 11
- } {
- MenuItem {} {
- label Linear
- xywh {0 0 100 20} labelfont 1 labelsize 11
- }
- MenuItem {} {
- label {-40dB}
- xywh {10 10 100 20} labelfont 1 labelsize 11
- }
- MenuItem {} {
- label {-60dB}
- xywh {20 20 100 20} labelfont 1 labelsize 11
- }
- MenuItem {} {
- label {-80dB}
- xywh {30 30 100 20} labelfont 1 labelsize 11
- }
- MenuItem {} {
- label {-100dB}
- xywh {40 40 100 20} labelfont 1 labelsize 11
- }
- }
- Fl_Button {} {
- label {Use as base}
- callback {oscil->useasbase();
+ Fl_Button {} {
+ label {Use as base}
+ callback {//oscil->useasbase();
if (autoclearbutton->value()){
for (int i=0;i<MAX_AD_HARMONICS;i++){
h[i]->mag->value(64);
- oscil->Phmag[i]=64;
+ //oscil->Phmag[i]=64;
h[i]->phase->value(64);
- oscil->Phphase[i]=64;
+ //oscil->Phphase[i]=64;
};
- oscil->Phmag[0]=127;
+ //oscil->Phmag[0]=127;
- oscil->Pharmonicshift=0;
+ //oscil->Pharmonicshift=0;
harmonicshiftcounter->value(0);
h[0]->mag->value(0);
@@ -646,505 +513,532 @@ if (autoclearbutton->value()){
sabutton->do_callback();
};
-pthread_mutex_lock(&master->mutex);
- for (int i=0;i<MAX_AD_HARMONICS;i++){
- if (oscil->Phmag[i]==64) h[i]->mag->selection_color(0);
- else h[i]->mag->selection_color(222);
- };
- oscil->prepare();
-pthread_mutex_unlock(&master->mutex);
+ osc->requestValue(loc+"prepare");
basefuncdisplaygroup->redraw();
redrawoscil();}
- tooltip {Use this Oscillator as base function} xywh {5 313 85 20} box THIN_UP_BOX labelfont 1 labelsize 11
- }
- Fl_Button {} {
- label Close
- callback {osceditUI->hide();}
- xywh {668 565 62 25} box THIN_UP_BOX
- }
- Fl_Button {} {
- label Clear
- callback {if (!fl_choice("Clear the harmonics settings?","No","Yes",NULL)) return;
+ tooltip {Use this Oscillator as base function} xywh {10 318 85 20} box THIN_UP_BOX labelfont 1 labelsize 11
+ }
+ Fl_Button {} {
+ label Close
+ callback {osceditUI->hide();}
+ xywh {673 570 62 25} box THIN_UP_BOX
+ }
+ Fl_Button {} {
+ label Clear
+ callback {if (!fl_choice("Clear the harmonics settings?","No","Yes",NULL)) return;
for (int i=0;i<MAX_AD_HARMONICS;i++){
h[i]->mag->value(64);
- oscil->Phmag[i]=64;
+ //oscil->Phmag[i]=64;
h[i]->phase->value(64);
- oscil->Phphase[i]=64;
+ //oscil->Phphase[i]=64;
};
-oscil->Phmag[0]=127;
+//oscil->Phmag[0]=127;
h[0]->mag->value(0);
-for (int i=0;i<MAX_AD_HARMONICS;i++){
- if (oscil->Phmag[i]==64) h[i]->mag->selection_color(0);
- else h[i]->mag->selection_color(222);
-};
+//for (int i=0;i<MAX_AD_HARMONICS;i++){
+// if (oscil->Phmag[i]==64) h[i]->mag->selection_color(0);
+// else h[i]->mag->selection_color(222);
+//};
//harmonics->redraw();
-
-pthread_mutex_lock(&master->mutex);
- oscil->prepare();
-pthread_mutex_unlock(&master->mutex);
-
+osc->requestValue(loc+"prepare");
redrawoscil();}
- xywh {670 505 55 15} box THIN_UP_BOX labelfont 1 labelsize 11
- }
- Fl_Group {} {
- xywh {136 308 150 30} box UP_FRAME
- } {
- Fl_Choice wshbutton {
- label {Wsh.}
- callback {oscil->Pwaveshapingfunction=(int) o->value();
-basefuncdisplaygroup->redraw();
-redrawoscil();} open
- tooltip {Waveshaping function} xywh {166 313 55 20} down_box BORDER_BOX labelsize 10 textsize 10
+ xywh {675 510 55 15} box THIN_UP_BOX labelfont 1 labelsize 11
+ }
+ Fl_Group {} {
+ xywh {140 313 150 30} box UP_FRAME
} {
- MenuItem {} {
- label None
- xywh {25 25 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label Atan
- xywh {35 35 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label Asym1
- xywh {45 45 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label Pow
- xywh {55 55 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label Sine
- xywh {65 65 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label Qnts
- xywh {75 75 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label Zigzg
- xywh {85 85 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label Lmt
- xywh {95 95 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label LmtU
- xywh {105 105 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label LmtL
- xywh {115 115 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label ILmt
- xywh {127 127 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label Clip
- xywh {137 137 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label Asym2
- xywh {85 85 100 20} labelfont 1 labelsize 10
+ Fl_Choice wshbutton {
+ label {Wsh.}
+ callback {//oscil->Pwaveshapingfunction=(int) o->value();
+basefuncdisplaygroup->redraw();
+redrawoscil();}
+ tooltip {Waveshaping function} xywh {170 320 55 20} down_box BORDER_BOX labelsize 10 when 1 textsize 10
+ code0 {o->init("waveshapingfunction");}
+ class Fl_Osc_Choice
+ } {
+ MenuItem {} {
+ label None
+ xywh {30 30 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Atan
+ xywh {40 40 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Asym1
+ xywh {50 50 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Pow
+ xywh {60 60 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Sine
+ xywh {70 70 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Qnts
+ xywh {80 80 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Zigzg
+ xywh {90 90 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Lmt
+ xywh {100 100 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label LmtU
+ xywh {110 110 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label LmtL
+ xywh {120 120 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label ILmt
+ xywh {132 132 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Clip
+ xywh {142 142 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Asym2
+ xywh {90 90 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Pow2
+ xywh {100 100 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Sgm
+ xywh {95 95 100 20} labelfont 1 labelsize 10
+ }
}
- MenuItem {} {
- label Pow2
- xywh {95 95 100 20} labelfont 1 labelsize 10
+ Fl_Dial wshpar {
+ callback {redrawoscil();}
+ tooltip {Waveshaping Parameter} xywh {265 318 20 20} minimum -64 maximum 63 step 1
+ code0 {o->init("waveshaping");}
+ class Fl_Osc_Dial
}
- MenuItem {} {
- label Sgm
- xywh {90 90 100 20} labelfont 1 labelsize 10
+ Fl_Value_Output wsparval {
+ xywh {233 321 25 15} labelsize 12 minimum -63 maximum 63 step 1
}
}
- Fl_Dial wshpar {
- callback {oscil->Pwaveshaping=(int)o->value()+64;
-wsparval->value(oscil->Pwaveshaping-64);
-redrawoscil();}
- tooltip {Waveshaping Parameter} xywh {261 313 20 20} minimum -64 maximum 63 step 1
- class WidgetPDial
- }
- Fl_Value_Output wsparval {
- xywh {229 316 25 15} labelsize 12 minimum -63 maximum 63 step 1
+ Fl_Light_Button autoclearbutton {
+ label {Clr.}
+ tooltip {Auto clear when using the oscillator as base function} xywh {100 318 35 20} box THIN_UP_BOX value 1 labelfont 1 labelsize 10
}
- }
- Fl_Check_Button autoclearbutton {
- label {Clr.}
- tooltip {Auto clear when using the oscillator as base function} xywh {94 313 38 20} box THIN_UP_BOX value 1 labelfont 1 labelsize 10
- }
- Fl_Group {} {
- xywh {287 308 155 30} box UP_FRAME
- } {
- Fl_Choice fltbutton {
- label Filter
- callback {oscil->Pfiltertype=(int) o->value();
+ Fl_Group {} {
+ xywh {290 313 155 30} box UP_FRAME
+ } {
+ Fl_Choice fltbutton {
+ label Filter
+ callback {//oscil->Pfiltertype=(int) o->value();
redrawoscil();}
- tooltip {Oscillator's filter type} xywh {317 313 50 20} down_box BORDER_BOX labelsize 10 textsize 10
- } {
- MenuItem {} {
- label None
- xywh {35 35 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label LP1
- xywh {45 45 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label HP1a
- xywh {55 55 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label HP1b
- xywh {65 65 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label BP1
- xywh {75 75 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label BS1
- xywh {85 85 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label LP2
- xywh {55 55 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label HP2
- xywh {65 65 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label BP2
- xywh {65 65 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label BS2
- xywh {75 75 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label Cos
- xywh {75 75 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label Sin
- xywh {85 85 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label LSh
- xywh {95 95 100 20} labelfont 1 labelsize 10
+ tooltip {Oscillator's filter type} xywh {320 318 50 20} down_box BORDER_BOX labelsize 10 when 1 textsize 10
+ code0 {o->init("filtertype");}
+ class Fl_Osc_Choice
+ } {
+ MenuItem {} {
+ label None
+ xywh {40 40 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label LP1
+ xywh {50 50 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label HP1a
+ xywh {60 60 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label HP1b
+ xywh {70 70 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label BP1
+ xywh {80 80 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label BS1
+ xywh {90 90 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label LP2
+ xywh {60 60 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label HP2
+ xywh {70 70 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label BP2
+ xywh {70 70 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label BS2
+ xywh {80 80 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Cos
+ xywh {80 80 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Sin
+ xywh {90 90 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label LSh
+ xywh {100 100 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label S
+ xywh {110 110 100 20} labelfont 1 labelsize 10
+ }
}
- MenuItem {} {
- label S
- xywh {105 105 100 20} labelfont 1 labelsize 10
+ Fl_Dial filtervalue1 {
+ callback {redrawoscil();}
+ tooltip {Oscillator's filter parameter1} xywh {372 318 20 20} maximum 127 step 1
+ code0 {o->init("filterpar1");}
+ class Fl_Osc_Dial
}
- }
- Fl_Dial filtervalue1 {
- callback {oscil->Pfilterpar1=(int)o->value();
-
-redrawoscil();}
- tooltip {Oscillator's filter parameter1} xywh {369 313 20 20} maximum 127 step 1
- class WidgetPDial
- }
- Fl_Check_Button filterpref {
- label p
- callback {oscil->Pfilterbeforews=(int)o->value();
-
-redrawoscil();}
- tooltip {Apply the filter before the waveshaping} xywh {417 313 20 20} down_box DOWN_BOX labelsize 10 align 24
- }
- Fl_Dial filtervalue2 {
- callback {oscil->Pfilterpar2=(int)o->value();
+ Fl_Check_Button filterpref {
+ label p
+ callback {//oscil->Pfilterbeforews=(int)o->value();
redrawoscil();}
- tooltip {Oscillator's filter parameter2} xywh {394 313 20 20} maximum 127 step 1
- class WidgetPDial
- }
- }
- Fl_Group {} {
- xywh {594 308 135 30} box UP_FRAME
- } {
- Fl_Choice sabutton {
- label {Sp.adj.}
- callback {oscil->Psatype=(int) o->value();
-redrawoscil();}
- tooltip {Oscillator's spectrum adjust} xywh {635 313 60 20} down_box BORDER_BOX labelsize 10 textsize 10
- } {
- MenuItem {} {
- label None
- xywh {55 55 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label Pow
- xywh {65 65 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label ThrsD
- xywh {75 75 100 20} labelfont 1 labelsize 10
+ tooltip {Apply the filter before the waveshaping} xywh {420 318 20 20} down_box DOWN_BOX labelsize 10 align 24
}
- MenuItem {} {
- label ThrsU
- xywh {85 85 100 20} labelfont 1 labelsize 10
+ Fl_Dial filtervalue2 {
+ callback {redrawoscil();}
+ tooltip {Oscillator's filter parameter2} xywh {395 318 20 20} maximum 127 step 1
+ code0 {o->init("filterpar2");}
+ class Fl_Osc_Dial
}
}
- Fl_Dial sadjpar {
- callback {oscil->Psapar=(int)o->value();
+ Fl_Group {} {
+ xywh {595 313 135 30} box UP_FRAME
+ } {
+ Fl_Choice sabutton {
+ label {Sp.adj.}
+ callback {//oscil->Psatype=(int) o->value();
redrawoscil();}
- tooltip {Oscillator's spectrum adjust parameter} xywh {702 313 20 20} maximum 127 step 1
- class WidgetPDial
+ tooltip {Oscillator's spectrum adjust} xywh {635 318 60 20} down_box BORDER_BOX labelsize 10 when 1 textsize 10
+ code0 {o->init("satype");}
+ class Fl_Osc_Choice
+ } {
+ MenuItem {} {
+ label None
+ xywh {60 60 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Pow
+ xywh {70 70 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label ThrsD
+ xywh {80 80 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label ThrsU
+ xywh {90 90 100 20} labelfont 1 labelsize 10
+ }
+ }
+ Fl_Dial sadjpar {
+ callback {redrawoscil();}
+ tooltip {Oscillator's spectrum adjust parameter} xywh {700 318 20 20} maximum 127 step 1
+ code0 {o->init("sapar");}
+ class Fl_Osc_Dial
+ }
}
- }
- Fl_Group {} {
- xywh {665 340 65 65} box UP_FRAME
- } {
- Fl_Counter harmonicshiftcounter {
- label {Harmonic Shift}
- callback {oscil->Pharmonicshift=(int)o->value();
+ Fl_Group {} {
+ xywh {670 345 65 65} box UP_FRAME
+ } {
+ Fl_Counter harmonicshiftcounter {
+ label {Harmonic Shift}
+ callback {//oscil->Pharmonicshift=(int)o->value();
redrawoscil();}
- xywh {670 365 55 15} type Simple labelsize 10 align 129 minimum -64 maximum 64 step 1 textfont 1 textsize 10
- }
- Fl_Check_Button harmonicshiftpre {
- label preH
- callback {oscil->Pharmonicshiftfirst=(int)o->value();
+ xywh {675 370 55 15} type Simple labelsize 10 align 129 minimum -64 maximum 64 step 1 textfont 1 textsize 10
+ }
+ Fl_Check_Button harmonicshiftpre {
+ label preH
+ callback {//oscil->Pharmonicshiftfirst=(int)o->value();
redrawoscil();}
- tooltip {Apply the harmonic shift before the waveshaping and filtering} xywh {690 385 34 15} down_box DOWN_BOX labelsize 10 align 24
- }
- Fl_Button {} {
- label R
- callback {oscil->Pharmonicshift=0;
+ tooltip {Apply the harmonic shift before the waveshaping and filtering} xywh {695 390 34 15} down_box DOWN_BOX labelsize 10 align 24
+ }
+ Fl_Button {} {
+ label R
+ callback {//oscil->Pharmonicshift=0;
harmonicshiftcounter->value(0);
redrawoscil();}
- xywh {670 385 20 15} box THIN_UP_BOX labelfont 1 labelsize 10
- }
- }
- Fl_Group {} {open
- xywh {665 410 65 90} box UP_FRAME
- } {
- Fl_Choice adhrtype {
- label {Adpt.Harm.}
- callback {oscil->Padaptiveharmonics=(int) o->value();
-redrawoscil();}
- tooltip {The type of the addaptive harmonics} xywh {670 425 55 15} down_box BORDER_BOX labelsize 10 align 129 when 6 textsize 10
- } {
- MenuItem {} {
- label OFF
- xywh {80 80 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label ON
- xywh {90 90 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label Square
- xywh {100 100 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label 2xSub
- xywh {110 110 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label 2xAdd
- xywh {120 120 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label 3xSub
- xywh {120 120 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label 3xAdd
- xywh {130 130 100 20} labelfont 1 labelsize 10
+ xywh {675 390 20 15} box THIN_UP_BOX labelfont 1 labelsize 10
}
- MenuItem {} {
- label 4xSub
- xywh {130 130 100 20} labelfont 1 labelsize 10
- }
- MenuItem {} {
- label 4xAdd
- xywh {140 140 100 20} labelfont 1 labelsize 10
- }
- }
- Fl_Dial adhrpow {
- label pow
- callback {oscil->Padaptiveharmonicspower=(int)o->value();
-redrawoscil();}
- tooltip {Adaptive harmonics power} xywh {700 460 25 25} labelsize 10 maximum 200 step 1
- class WidgetPDial
}
- Fl_Dial adhrbf {
- label baseF
- callback {oscil->Padaptiveharmonicsbasefreq=(int)o->value();
+ Fl_Group {} {
+ xywh {670 415 65 90} box UP_FRAME
+ } {
+ Fl_Choice adhrtype {
+ label {Adpt.Harm.}
+ callback {//oscil->Padaptiveharmonics=(int) o->value();
redrawoscil();}
- tooltip {Adaptive harmonics base frequency} xywh {670 460 25 25} labelsize 10 maximum 255 step 1
- class WidgetPDial
- }
- Fl_Slider adhrpar {
- callback {oscil->Padaptiveharmonicspar=(int)o->value();
+ tooltip {The type of the addaptive harmonics} xywh {675 430 55 15} down_box BORDER_BOX labelsize 10 align 129 when 3 textsize 10
+ code0 {o->init("adaptiveharmonics");}
+ class Fl_Osc_Choice
+ } {
+ MenuItem {} {
+ label OFF
+ xywh {85 85 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label ON
+ xywh {95 95 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Square
+ xywh {105 105 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label 2xSub
+ xywh {115 115 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label 2xAdd
+ xywh {125 125 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label 3xSub
+ xywh {125 125 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label 3xAdd
+ xywh {135 135 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label 4xSub
+ xywh {135 135 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label 4xAdd
+ xywh {145 145 100 20} labelfont 1 labelsize 10
+ }
+ }
+ Fl_Dial adhrpow {
+ label pow
+ callback {redrawoscil();}
+ tooltip {Adaptive harmonics power} xywh {705 465 25 25} labelsize 10 maximum 200 step 1
+ code0 {o->init("adaptiveharmonicspower");}
+ class Fl_Osc_Dial
+ }
+ Fl_Dial adhrbf {
+ label baseF
+ callback {redrawoscil();}
+ tooltip {Adaptive harmonics base frequency} xywh {675 465 25 25} labelsize 10 maximum 255 step 1
+ code0 {o->init("adaptiveharmoicsbasefreq");}
+ class Fl_Osc_Dial
+ }
+ Fl_Slider adhrpar {
+ callback {//oscil->Padaptiveharmonicspar=(int)o->value();
redrawoscil();}
- xywh {670 445 55 10} type {Horz Knob} box NO_BOX maximum 100 step 1 value 50
+ xywh {675 450 55 10} type {Horz Knob} box NO_BOX maximum 100 step 1 value 50
+ }
}
- }
- Fl_Group {} {
- xywh {443 308 150 30} box UP_FRAME
- } {
- Fl_Choice modtype {
- label {Mod.}
- callback {oscil->Pmodulation=(int) o->value();
+ Fl_Group {} {
+ xywh {445 313 150 30} box UP_FRAME
+ } {
+ Fl_Choice modtype {
+ label {Mod.}
+ callback {//oscil->Pmodulation=(int) o->value();
redrawoscil();}
- tooltip modulation xywh {476 315 50 15} down_box BORDER_BOX labelsize 10 textsize 10
- } {
- MenuItem {} {
- label None
- xywh {60 60 100 20} labelfont 1 labelsize 10
+ tooltip modulation xywh {475 320 50 15} down_box BORDER_BOX labelsize 10 when 1 textsize 10
+ code0 {o->init("modtype");}
+ class Fl_Osc_Choice
+ } {
+ MenuItem {} {
+ label None
+ xywh {65 65 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Rev
+ xywh {75 75 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Sine
+ xywh {85 85 100 20} labelfont 1 labelsize 10
+ }
+ MenuItem {} {
+ label Pow
+ xywh {95 95 100 20} labelfont 1 labelsize 10
+ }
}
- MenuItem {} {
- label Rev
- xywh {70 70 100 20} labelfont 1 labelsize 10
+ Fl_Dial modpar1 {
+ callback {redrawoscil();}
+ tooltip {Oscillator's modulation parameter 1} xywh {535 320 15 15} maximum 127 step 1
+ code0 {o->init("modulationpar1");}
+ class Fl_Osc_Dial
}
- MenuItem {} {
- label Sine
- xywh {80 80 100 20} labelfont 1 labelsize 10
+ Fl_Dial modpar2 {
+ callback {redrawoscil();}
+ tooltip {Oscillator's modulation parameter 2} xywh {555 320 15 15} maximum 127 step 1
+ code0 {o->init("modulationpar2");}
+ class Fl_Osc_Dial
}
- MenuItem {} {
- label Pow
- xywh {90 90 100 20} labelfont 1 labelsize 10
+ Fl_Dial modpar3 {
+ callback {redrawoscil();}
+ tooltip {Oscillator's modulation parameter 3} xywh {575 320 15 15} maximum 127 step 1
+ code0 {o->init("modulationpar3");}
+ class Fl_Osc_Dial
}
}
- Fl_Dial modpar1 {
- callback {oscil->Pmodulationpar1=(int)o->value();
-
-redrawoscil();}
- tooltip {Oscillator's modulation parameter 1} xywh {534 315 15 15} maximum 127 step 1
- class WidgetPDial
- }
- Fl_Dial modpar2 {
- callback {oscil->Pmodulationpar2=(int)o->value();
-
-redrawoscil();}
- tooltip {Oscillator's modulation parameter 2} xywh {554 315 15 15} maximum 127 step 1
- class WidgetPDial
- }
- Fl_Dial modpar3 {
- callback {oscil->Pmodulationpar3=(int)o->value();
-redrawoscil();}
- tooltip {Oscillator's modulation parameter 3} xywh {574 315 15 15} maximum 127 step 1
- class WidgetPDial
- }
- }
- Fl_Button {} {
- label Sine
- callback {if (!fl_choice("Convert to SINE?","No","Yes",NULL)) return;
+ Fl_Button {} {
+ label Sine
+ callback {if (!fl_choice("Convert to SINE?","No","Yes",NULL)) return;
-pthread_mutex_lock(&master->mutex);
- oscil->convert2sine();
-pthread_mutex_unlock(&master->mutex);
+osc->requestValue(loc+"convert2sine");
redrawoscil();
refresh();}
- xywh {670 525 55 15} box THIN_UP_BOX labelfont 1 labelsize 11
- }
- Fl_Button {} {
- label C
- callback {presetsui->copy(oscil);}
- xywh {670 545 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
- }
- Fl_Button {} {
- label P
- callback {presetsui->paste(oscil,this);}
- xywh {700 545 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
- }
- Fl_Scroll _this_has_to_be_the_last {
- xywh {5 340 660 250} type HORIZONTAL box FLAT_BOX
- } {
- Fl_Pack harmonics {open
- xywh {10 345 650 225} type HORIZONTAL
- code0 {for (int i=0;i<MAX_AD_HARMONICS;i++){h[i]=new Oscilharmonic(0,0,20,o->h(),"");h[i]->init(oscil,i,oscildisplaygroup,oldosc,cbwidget,applybutton,master);}}
- } {}
+ xywh {675 530 55 15} box THIN_UP_BOX labelfont 1 labelsize 11
+ }
+ Fl_Button {} {
+ label C
+ callback {//presetsui->copy(oscil);
+//TODO FIXME}
+ xywh {675 550 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
+ }
+ Fl_Button {} {
+ label P
+ callback {//presetsui->paste(oscil,this);
+//TODO FIXME}
+ xywh {705 550 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
+ }
+ Fl_Scroll _this_has_to_be_the_last {
+ xywh {10 345 660 250} type HORIZONTAL box FLAT_BOX
+ } {
+ Fl_Pack harmonics {open
+ xywh {15 350 650 225} type HORIZONTAL
+ code0 {for (int i=0;i<MAX_AD_HARMONICS;i++){h[i]=new Oscilharmonic(0,0,20,o->h(),"");h[i]->init(i,oscildisplaygroup,loc,osc);}}
+ } {}
+ }
}
}
}
- Function {OscilEditor(OscilGen *oscil_,Fl_Widget *oldosc_,Fl_Widget *cbwidget_,Fl_Widget *cbapplywidget_,Master *master_)} {} {
- code {oscil=oscil_;
-oldosc=oldosc_;
-cbwidget=cbwidget_;
-cbapplywidget=cbapplywidget_;
-master=master_;
+ Function {OscilEditor(bool adnotep_, std::string loc_, Fl_Osc_Interface *osc_)} {open
+ } {
+ code { assert(osc_);
+assert(!loc_.empty());
+
+initialized = false;
+
+adnotep = adnotep_;
+osc = osc_;
+loc = loc_;
+
+oscilo = NULL;
+oscilo_base = NULL;
+oscils = NULL;
+oscils_base = NULL;
make_window();
+initialized = true;
refresh();
osceditUI->show();} {}
}
- Function {~OscilEditor()} {} {
+ Function {~OscilEditor()} {open
+ } {
code {osceditUI->hide();
-//for (int i=0;i<MAX_AD_HARMONICS;i++) delete (h[i]);
-delete (osceditUI);} {}
+for (int i=0; i<MAX_AD_HARMONICS; ++i)
+ delete h[i];
+
+delete oscilo;
+delete oscilo_base;
+delete oscils;
+delete oscils_base;
+delete osceditUI;} {}
}
Function {refresh()} {} {
- code {magtype->value(oscil->Phmagtype);
-rndslider->value(oscil->Prand-64);
+ code {magtype->update();
+ ////rndslider->update();
-hrndtype->value(oscil->Pamprandtype);
-hrnddial->value(oscil->Pamprandpower);
+ ////hrndtype->update();
+ ////hrnddial->update();
-bftype->value(oscil->Pcurrentbasefunc);
-bfparval->value(oscil->Pbasefuncpar-64);
-bfslider->value(oscil->Pbasefuncpar-64);
+ ////bftype->update();
+ ////bfparval->update();
+ ////bfslider->update();
-bfmodtype->value(oscil->Pbasefuncmodulation);
-bfmodpar1->value(oscil->Pbasefuncmodulationpar1);
-bfmodpar2->value(oscil->Pbasefuncmodulationpar2);
-bfmodpar3->value(oscil->Pbasefuncmodulationpar3);
+ ////bfmodtype->update();
+ ////bfmodpar1->update();
+ ////bfmodpar2->update();
+ ////bfmodpar3->update();
-wshbutton->value(oscil->Pwaveshapingfunction);
-wsparval->value(oscil->Pwaveshaping-64);
-wshpar->value(oscil->Pwaveshaping-64);
+ ////wshbutton->update();
+ ////wsparval->update();
+ ////wshpar->update();
-fltbutton->value(oscil->Pfiltertype);
-filtervalue1->value(oscil->Pfilterpar1);
-filtervalue2->value(oscil->Pfilterpar2);
-filterpref->value(oscil->Pfilterbeforews);
+ ////fltbutton->update();
+ ////filtervalue1->update();
+ ////filtervalue2->update();
+ ////filterpref->update();
-modtype->value(oscil->Pmodulation);
-modpar1->value(oscil->Pmodulationpar1);
-modpar2->value(oscil->Pmodulationpar2);
-modpar3->value(oscil->Pmodulationpar3);
+ ////modtype->update();
+ ////modpar1->update();
+ ////modpar2->update();
+ ////modpar3->update();
-sabutton->value(oscil->Psatype);
-sadjpar->value(oscil->Psapar);
+ ////sabutton->update();
+ ////sadjpar->update();
-harmonicshiftcounter->value(oscil->Pharmonicshift);
-harmonicshiftpre->value(oscil->Pharmonicshiftfirst);
+ ////harmonicshiftcounter->update();
+ ////harmonicshiftpre->update();
-adhrtype->value(oscil->Padaptiveharmonics);
-adhrbf->value(oscil->Padaptiveharmonicsbasefreq);
-adhrpow->value(oscil->Padaptiveharmonicspower);
-adhrtype->value(oscil->Padaptiveharmonicspar);
+ ////adhrtype->update();
+ ////adhrbf->update();
+ ////adhrpow->update();
+ ////adhrtype->update();
-for (int i=0;i<MAX_AD_HARMONICS;i++) h[i]->refresh();
+ for (int i=0;i<MAX_AD_HARMONICS;i++) h[i]->refresh();
-pthread_mutex_lock(&master->mutex);
- oscil->prepare();
-pthread_mutex_unlock(&master->mutex);
+ osc->requestValue(loc+"prepare");
-basefuncdisplaygroup->redraw();
+ basefuncdisplaygroup->redraw();
redrawoscil();} {}
}
- Function {redrawoscil()} {} {
- code {oscildisplaygroup->redraw();
-oldosc->redraw();
-if (cbwidget!=NULL) {
- cbwidget->do_callback();
- applybutton->color(FL_RED);
- applybutton->redraw();
-};} {}
+ Function {redrawoscil()} {open
+ } {
+ code {
+ if(!initialized) //Must have been called during initialization
+ return;
+ //get data from backend
+osc->requestValue(loc+"prepare");
+oscilo->update();
+oscils->update();
+oscilo_base->update();
+oscils_base->update();
+
+//oscildisplaygroup->redraw();
+//basefuncdisplaygroup->redraw();} {}
+ }
+ decl {Oscilharmonic *h[MAX_AD_HARMONICS];} {private local
+ }
+ decl {std::string loc;} {private local
+ }
+ decl {Fl_Osc_Interface *osc;} {private local
+ }
+ decl {Fl_Oscilloscope *oscilo, *oscilo_base;} {private local
+ }
+ decl {Fl_OscilSpectrum *oscils, *oscils_base;} {private local
+ }
+ decl {bool adnotep;} {private local
+ }
+ decl {bool initialized;} {private local
}
- decl {OscilGen *oscil;} {}
- decl {Fl_Widget *oldosc,*cbwidget,*cbapplywidget;} {}
- decl {Oscilharmonic *h[MAX_AD_HARMONICS];} {}
- decl {Master *master;} {}
}
diff --git a/src/UI/PADnoteUI.fl b/src/UI/PADnoteUI.fl
@@ -1,278 +1,130 @@
# data file for the Fltk User Interface Designer (fluid)
-version 1.0110
+version 1.0302
header_name {.h}
code_name {.cc}
-decl {\#include "../Params/PADnoteParameters.h"} {public
+decl {\#include "../Params/PADnoteParameters.h"} {public local
}
-decl {\#include "../Misc/Util.h"} {public
+decl {\#include "../Misc/Util.h"} {public local
}
-decl {\#include "../Misc/Master.h"} {public
+decl {\#include "../Misc/Master.h"} {public local
}
-decl {\#include "ResonanceUI.h"} {public
+decl {\#include "../Misc/MiddleWare.h"} {public local
}
-decl {\#include <FL/Fl_Box.H>} {public
+decl {\#include "ResonanceUI.h"} {public local
}
-decl {\#include <FL/Fl_Group.H>} {public
+decl {\#include <FL/Fl_Box.H>} {public local
}
-decl {\#include <FL/Fl_File_Chooser.H>} {public
+decl {\#include <FL/Fl_Group.H>} {public local
}
-decl {\#include <math.h>} {}
-
-decl {\#include <stdio.h>} {}
-
-decl {\#include <stdlib.h>} {}
-
-decl {\#include <string.h>} {}
-
-decl {\#include "WidgetPDial.h"} {public
+decl {\#include <FL/Fl_File_Chooser.H>} {public local
}
-decl {\#include "EnvelopeUI.h"} {public
+decl {\#include <math.h>} {private local
}
-decl {\#include "LFOUI.h"} {public
+decl {\#include <stdio.h>} {private local
}
-decl {\#include "FilterUI.h"} {public
+decl {\#include <stdlib.h>} {private local
}
-decl {\#include "OscilGenUI.h"} {public
+decl {\#include <string.h>} {private local
}
-decl {\#include "PresetsUI.h"} {public
+decl {\#include <string>} {public local
}
-class PADnoteHarmonicProfile {: {public Fl_Box}
-} {
- Function {PADnoteHarmonicProfile(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} {
- code {pars=NULL;} {}
- }
- Function {init(PADnoteParameters *pars,Master *master_)} {} {
- code {master=master_;
-this->pars=pars;} {}
- }
- Function {draw()} {} {
- code {int ox=x(),oy=y(),lx=w(),ly=h();
-if (!visible()) return;
-float smps[lx];
-
-float realbw=pars->getprofile(smps,lx);
-bool active=active_r();
-
-//draw the equivalent bandwidth
-if (active) fl_color(220,220,220);
- else fl_color(160,165,165);
-fl_line_style(FL_DASH);
-int rbw=(int)(realbw*(lx-1.0)/2.0);
-fl_begin_line();
-for (int i=lx/2-rbw;i<(lx/2+rbw);i++) { fl_vertex(ox+i,oy); }
-fl_end_line();
-
-fl_line_style(FL_DASH);
-if (active) fl_color(200,200,200);
- else fl_color(160,160,160);
-for (int i=1;i<10;i++){
- int kx=(int)(lx/10.0*i);
- fl_line( ox + kx, oy, ox + kx, oy + ly - 1 );
-};
-for (int i=1;i<5;i++){
- int ky=(int)(ly/5.0*i);
- fl_line(ox,oy+ly-ky,ox+lx,oy+ly-ky-1);
-};
-
-
-fl_color(120,120,120);
-fl_line_style(FL_DASH);
-fl_line(ox+lx/2,oy,ox+lx/2,oy+ly);
-
-//draw the graph
-fl_line_style(FL_SOLID);
- if (active) fl_color(180,210,240);
- else fl_color(150,150,155);
-
-fl_color( fl_color_add_alpha( fl_color(), 127 ) );
-
-fl_begin_polygon();
-fl_vertex( ox, oy + h() );
-for (int i=0;i<lx;i++){
- int val=(int) ((ly-2)*smps[i]);
-
-// fl_vertex(ox+i,oy+ly-1);
- fl_vertex(ox+i,oy+ly-1-val);
-
- // if (active) fl_color(0,0,100);
- // else fl_color(150,150,150);
-
-// if (i>0)
-// {
-// fl_vertex(ox+i-1,oy+ly-2-old);
-// fl_vertex(ox+i,oy+ly-2-val);
-// }
-};
-fl_vertex( ox + w(), oy + h() );
-fl_end_polygon();
-
-
-fl_line_style(FL_DASH);
-if (active) fl_color(0,100,220);
- else fl_color(150,160,170);
-fl_line(ox+lx/2-rbw,oy,ox+lx/2-rbw,oy+ly-1);
-fl_line(ox+lx/2+rbw,oy,ox+lx/2+rbw,oy+ly-1);
-
-fl_line_style(0);} {}
- }
- decl {Master *master;} {}
- decl {PADnoteParameters *pars;} {public
- }
+decl {\#include "Fl_Osc_Slider.H"} {public local
}
-class PADnoteOvertonePosition {: {public Fl_Box}
-} {
- Function {PADnoteOvertonePosition(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} {
- code {pars=NULL;} {}
- }
- Function {init(PADnoteParameters *pars,Master *master_)} {} {
- code {master=master_;
-this->pars=pars;} {}
- }
- Function {draw()} {} {
- code {if (!visible()) return;
-const int maxdb=60;
-
-int ox=x(),oy=y(),lx=w(),ly=h();
-const int maxharmonic=64;
-
-
-for (int i=1;i<maxharmonic;i++){
- fl_color(100,100,100);
- fl_line_style(FL_DOT);
- if (i%5==0) fl_line_style(0);
- if (i%10==0) fl_color(120,120,120);
- int kx=(int)(lx/(float)maxharmonic*i);
- fl_line(ox+kx,oy,ox+kx,oy+ly);
-};
-
-
-
-int n=synth->oscilsize/2;
-float spc[n];
-for (int i=0;i<n;i++) spc[i]=0.0;
-
-pthread_mutex_lock(&master->mutex);
-pars->oscilgen->getspectrum(n,spc,0);
-pthread_mutex_unlock(&master->mutex);
-
-
-//normalize
-float max=0;
-for (int i=0;i<n;i++){
- float x=fabs(spc[i]);
- if (max<x) max=x;
-}
-if (max<0.000001) max=1.0;
-max=max*1.05;
-
-float spectrum[lx];
-for (int i=0;i<lx;i++) spectrum[i]=0;
-
+decl {\#include "Fl_Osc_VSlider.H"} {public local
+}
-for (int i=1;i<n;i++){
- float nhr=pars->getNhr(i);
- int kx=(int)(lx/(float)maxharmonic*nhr);
- if ((kx<0)||(kx>lx)) continue;
+decl {\#include "EnvelopeUI.h"} {public local
+}
- spectrum[kx]=spc[i-1]/max+1e-9;
+decl {\#include "LFOUI.h"} {public local
+}
-};
+decl {\#include "FilterUI.h"} {public local
+}
-fl_color(180,0,0);
-fl_line_style(0);
+decl {\#include "OscilGenUI.h"} {public local
+}
-if (pars->Pmode==2){
- int old=0;
- for (int i=1;i<lx;i++){
- if ((spectrum[i]>1e-10)||(i==(lx-1))){
- int delta=i-old;
- float val1=spectrum[old];
- float val2=spectrum[i];
+decl {\#include "Fl_PADnoteOvertonePosition.h"} {public local
+}
- float idelta=1.0/delta;
- for (int j=0;j<delta;j++){
- float x=idelta*j;
- spectrum[old+j]=val1*(1.0-x)+val2*x;
- };
- old=i;
- };
-
- };
-};
+decl {\#include "Fl_PADnoteHarmonicProfile.h"} {public local
+}
-for (int i=0;i<lx;i++){
- float x=spectrum[i];
- if (x>dB2rap(-maxdb)) x=rap2dB(x)/maxdb+1;
- else continue;
- int yy=(int)(x*ly);
- fl_line(ox+i,oy+ly-1-yy,ox+i,oy+ly-1);
-
-};} {}
- }
- decl {Master *master;} {}
- decl {PADnoteParameters *pars;} {public
- }
+decl {\#include "PresetsUI.h"} {public local
}
class PADnoteUI {open : {public PresetsUI_}
} {
- Function {PADnoteUI(PADnoteParameters *parameters,Master *master_)} {open
+ Function {PADnoteUI(std::string location_, Fl_Osc_Interface *osc_)} {open
} {
- code {pars=parameters;
-master=master_;
+ code {assert(osc_);
+assert(!location_.empty());
+
+location=location_;
oscui=NULL;
-resui=new ResonanceUI(pars->resonance);
-make_window();} {}
+osc_i = osc_;
+resui=new ResonanceUI(osc_i, location+"resonance/");
+initialized = false;
+make_window();
+initialized = true;} {selected
+ }
}
Function {make_window()} {open
} {
Fl_Window padnotewindow {
label {PAD synth Parameters} open
- xywh {288 386 535 435} type Double visible
+ xywh {52 324 535 435} type Double hide
+ class Fl_Osc_Window
} {
+
+ Fl_Box dummy {
+ code0 {padnotewindow->osc = osc_i; padnotewindow->base = location;}
+ code1 {puts("dummy setup done...");}
+ }
Fl_Tabs {} {
callback {if (o->value()!=harmonicstructuregroup) applybutton->hide();
else applybutton->show();} open
xywh {0 0 535 395} box UP_FRAME
} {
Fl_Group harmonicstructuregroup {
- label {Harmonic Structure} open selected
+ label {Harmonic Structure} open
xywh {0 20 535 375} box UP_FRAME
+ class Fl_Osc_Group
} {
- Fl_Group bwprofilegroup {
+ Fl_Group bwprofilegroup {open
xywh {5 30 90 260} box UP_FRAME
- code0 {if (pars->Pmode!=0) o->deactivate();}
+ class Fl_Osc_Group
} {
Fl_Dial hpbasepar1 {
label Width
- callback {pars->Php.base.par1=(int) o->value();
-hprofile->redraw();
+ callback {if(hpui) hpui->update();
cbwidget->do_callback();}
xywh {20 75 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->Php.base.par1);}
- class WidgetPDial
+ code2 {o->init("Php.base.par1");}
+ class Fl_Osc_Dial
}
Fl_Choice hpbasetype {
label {Base Type}
- callback {pars->Php.base.type=o->value();
-hprofile->redraw();
-cbwidget->do_callback();}
+ callback {if(initialized) {hprofile->redraw();
+cbwidget->do_callback();}}
xywh {15 45 75 15} down_box BORDER_BOX labelsize 10 align 5 textsize 10
- code0 {o->value(pars->Php.base.type);}
+ code0 {o->init("Php.base.type");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label Gauss
@@ -289,41 +141,38 @@ cbwidget->do_callback();}
}
Fl_Dial hpfreqmult {
label FreqMlt
- callback {pars->Php.freqmult=(int) o->value();
-hprofile->redraw();
+ callback {hpui->update();
cbwidget->do_callback();}
xywh {55 75 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->Php.freqmult);}
- class WidgetPDial
+ code0 {o->init("Php.freqmult");}
+ class Fl_Osc_Dial
}
Fl_Dial hpmpar1 {
label Str
- callback {pars->Php.modulator.par1=(int) o->value();
-hprofile->redraw();
+ callback {hpui->update();
cbwidget->do_callback();}
xywh {15 115 20 20} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->Php.modulator.par1);}
- class WidgetPDial
+ code0 {o->init("Php.modulator.par1");}
+ class Fl_Osc_Dial
}
Fl_Dial hpmfreq {
label SFreq
- callback {pars->Php.modulator.freq=(int) o->value();
-hprofile->redraw();
+ callback {hpui->update();
cbwidget->do_callback();}
xywh {40 115 20 20} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->Php.modulator.freq);}
- class WidgetPDial
+ code0 {o->init("Php.modulator.freq");}
+ class Fl_Osc_Dial
}
Fl_Group {} {
xywh {10 160 80 105} box BORDER_BOX
} {
Fl_Choice hpamptype {
label AmpMultiplier
- callback {pars->Php.amp.type=o->value();
-hprofile->redraw();
-cbwidget->do_callback();}
+ callback {if(initialized) {hprofile->redraw();
+cbwidget->do_callback();}}
xywh {15 175 70 15} down_box BORDER_BOX labelsize 10 align 5 textsize 10
- code0 {o->value(pars->Php.amp.type);}
+ code0 {o->init("Php.amp.type");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label OFF
@@ -344,11 +193,11 @@ cbwidget->do_callback();}
}
Fl_Choice hpampmode {
label AmpMode
- callback {pars->Php.amp.mode=o->value();
-hprofile->redraw();
-cbwidget->do_callback();}
+ callback {if(initialized) {hpui->update();
+cbwidget->do_callback();}}
xywh {15 205 70 15} down_box BORDER_BOX labelsize 10 align 5 textsize 10
- code0 {o->value(pars->Php.amp.mode);}
+ code0 {o->init("Php.amp.mode");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label Sum
@@ -369,37 +218,37 @@ cbwidget->do_callback();}
}
Fl_Dial hpamppar1 {
label Par1
- callback {pars->Php.amp.par1=(int) o->value();
-hprofile->redraw();
+ callback {hpui->update();
cbwidget->do_callback();}
xywh {15 235 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->Php.amp.par1);}
- class WidgetPDial
+ code0 {o->init("Php.amp.par1");}
+ class Fl_Osc_Dial
}
Fl_Dial hpamppar2 {
label Par2
- callback {pars->Php.amp.par2=(int) o->value();
-hprofile->redraw();
+ callback {hpui->update();
cbwidget->do_callback();}
xywh {55 235 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->Php.amp.par2);}
- class WidgetPDial
+ code0 {o->init("Php.amp.par2");}
+ class Fl_Osc_Dial
}
}
Fl_Check_Button hpautoscale {
label autoscale
- callback {pars->Php.autoscale=(int) o->value();
-hprofile->redraw();
-cbwidget->do_callback();}
+ callback {
+ if(initialized) {
+ hprofile->redraw();
+ cbwidget->do_callback();}}
xywh {10 270 60 15} down_box DOWN_BOX labelsize 10
- code0 {o->value(pars->Php.autoscale);}
+ code0 {o->init("Php.autoscale");}
+ class Fl_Osc_Check
}
Fl_Choice hponehalf {
- callback {pars->Php.onehalf=o->value();
-hprofile->redraw();
-cbwidget->do_callback();}
+ callback {if(initialized) {hprofile->redraw();
+cbwidget->do_callback();}}
xywh {10 143 80 15} down_box BORDER_BOX labelsize 10 align 5 textsize 10
- code0 {o->value(pars->Php.onehalf);}
+ code0 {o->init("Php.onehalf");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label Full
@@ -416,28 +265,28 @@ cbwidget->do_callback();}
}
Fl_Dial hpwidth {
label Size
- callback {pars->Php.width=(int) o->value();
-hprofile->redraw();
+ callback {hpui->update();
cbwidget->do_callback();}
xywh {65 115 20 20} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->Php.width);}
- class WidgetPDial
+ code0 {o->init("Php.width");}
+ class Fl_Osc_Dial
}
}
- Fl_Group {} {
+ Fl_Group oscilgroup {open
xywh {100 155 270 135} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179 align 6
- code0 {osc=new Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");}
- code1 {osc->init(pars->oscilgen,master);}
+ code0 {oscilgroup->base = location; oscilgroup->ext="oscil/"; oscilgroup->osc = osc_i;}
+ code1 {osc=new Fl_Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");osc->init(false);}
+ class Fl_Osc_Group
} {}
Fl_Button {} {
label Change
callback {if (oscui!=NULL) delete (oscui);
-oscui=new OscilEditor(pars->oscilgen,osc,cbwidget,applybutton,master);}
+oscui=new OscilEditor(false, location+"oscil/",osc_i);}
xywh {375 270 60 20} box THIN_UP_BOX labelfont 1 labelsize 11
}
Fl_Box cbwidget {
label {Harmonic Content}
- callback {overtonepos->redraw();
+ callback {opui->update();
applybutton->color(FL_RED);
applybutton->redraw();}
xywh {125 135 205 20} align 16
@@ -451,29 +300,27 @@ resui->setcbwidget(cbwidget,applybutton);}
}
Fl_Dial bwdial {
label BandWidth
- callback {bwcents->value(pars->setPbandwidth((int) o->value()));
-cbwidget->do_callback();}
+ callback {o->oscWrite("bandwidthvalue");cbwidget->do_callback();}
xywh {15 295 35 35} box ROUND_UP_BOX labelsize 10 maximum 1000 step 1
- code0 {o->value(pars->Pbandwidth);}
- code1 {if (pars->Pmode!=0) o->deactivate();}
- class WidgetPDial
+ code0 {o->init("Pbandwidth");}
+ class Fl_Osc_Dial
}
Fl_Value_Output bwcents {
label cents
xywh {55 305 55 15} labelsize 10 align 6 maximum 10000 step 0.1
- code0 {o->value(pars->setPbandwidth(pars->Pbandwidth));}
- code1 {if (pars->Pmode!=0) o->deactivate();}
+ code0 {o->init("bandwidthvalue");}
+ class Fl_Osc_Output
}
- Fl_Group {} {
+ Fl_Group {} {open
xywh {315 295 215 45} box UP_FRAME
} {
Fl_Choice hrpostype {
label OvertonesPosition
- callback {pars->Phrpos.type=o->value();
-overtonepos->redraw();
-cbwidget->do_callback();}
+ callback {if(initialized) {opui->update();
+cbwidget->do_callback();}}
xywh {325 310 80 20} down_box BORDER_BOX labelsize 10 align 5 textsize 11
- code0 {o->value(pars->Phrpos.type);}
+ code0 {o->init("Phrpos.type");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label Harmonic
@@ -510,39 +357,36 @@ cbwidget->do_callback();}
}
Fl_Dial hrpospar1 {
label Par1
- callback {pars->Phrpos.par1=(int) o->value();
-overtonepos->redraw();
+ callback {opui->update();
+ hpui->update();
cbwidget->do_callback();}
- xywh {425 310 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 255 step 1
- code0 {o->value(pars->Phrpos.par1);}
- class WidgetPDial
+ xywh {425 310 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
+ code0 {o->init("Phrpos.par1");}
+ class Fl_Osc_Dial
}
Fl_Dial hrpospar2 {
label Par2
- callback {pars->Phrpos.par2=(int) o->value();
-overtonepos->redraw();
+ callback {opui->update();
cbwidget->do_callback();}
- xywh {460 310 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 255 step 1
- code0 {o->value(pars->Phrpos.par2);}
- class WidgetPDial
+ xywh {460 310 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
+ code0 {o->init("Phrpos.par2");}
+ class Fl_Osc_Dial
}
Fl_Dial hrpospar3 {
label ForceH
- callback {pars->Phrpos.par3=(int) o->value();
-overtonepos->redraw();
+ callback {opui->update();
cbwidget->do_callback();}
- xywh {495 310 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 255 step 1
- code0 {o->value(pars->Phrpos.par3);}
- class WidgetPDial
+ xywh {495 310 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
+ code0 {o->init("Phrpos.par3");}
+ class Fl_Osc_Dial
}
}
Fl_Choice bwscale {
label {Bandwidth Scale}
- callback {pars->Pbwscale=(int) o->value();
-cbwidget->do_callback();}
+ callback {if(initialized) {cbwidget->do_callback();}}
xywh {120 305 80 20} down_box BORDER_BOX labelsize 10 align 5 textsize 11
- code0 {o->value(pars->Pbwscale);}
- code1 {if (pars->Pmode!=0) o->deactivate();}
+ code0 {o->init("Pbwscale");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label Normal
@@ -579,15 +423,15 @@ cbwidget->do_callback();}
}
Fl_Group overtonepos {
xywh {5 345 525 45} box FLAT_BOX color 51 selection_color 218 labelcolor 63
- code0 {PADnoteOvertonePosition *opui=new PADnoteOvertonePosition(o->x(),o->y(),o->w(),o->h(),"");}
- code1 {opui->init(pars,master);}
+ code0 {opui=new PADnoteOvertonePosition(o->x(),o->y(),o->w(),o->h(),"");}
+ code1 {opui->init();}
} {}
Fl_Choice qsamplesize {
label {Sample Size}
- callback {pars->Pquality.samplesize=(int) o->value();
-cbwidget->do_callback();}
+ callback {if(initialized) {cbwidget->do_callback();}}
xywh {375 190 115 20} down_box BORDER_BOX labelsize 10 align 5 textsize 11
- code0 {o->value(pars->Pquality.samplesize);}
+ code0 {o->init("Pquality.samplesize");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label {16k (Tiny)}
@@ -620,10 +464,10 @@ cbwidget->do_callback();}
}
Fl_Choice qsmpoct {
label {smp/oct}
- callback {pars->Pquality.smpoct=(int) o->value();
-cbwidget->do_callback();}
+ callback {if(initialized) cbwidget->do_callback();}
xywh {430 155 45 20} down_box BORDER_BOX labelsize 11 align 5 textsize 11
- code0 {o->value(pars->Pquality.smpoct);}
+ code0 {o->init("Pquality.smpoct");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label {0.5}
@@ -656,10 +500,10 @@ cbwidget->do_callback();}
}
Fl_Choice qoct {
label {no.oct}
- callback {pars->Pquality.oct=(int) o->value();
-cbwidget->do_callback();}
+ callback {if(initialized) cbwidget->do_callback();}
xywh {480 155 45 20} down_box BORDER_BOX labelsize 11 align 5 textsize 11
- code0 {o->value(pars->Pquality.oct);}
+ code0 {o->init("Pquality.oct");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label 1
@@ -696,10 +540,10 @@ cbwidget->do_callback();}
}
Fl_Choice qbasenote {
label base
- callback {pars->Pquality.basenote=(int) o->value();
-cbwidget->do_callback();}
+ callback {if(initialized) cbwidget->do_callback();}
xywh {375 155 50 20} down_box BORDER_BOX labelsize 11 align 5 textsize 11
- code0 {o->value(pars->Pquality.basenote);}
+ code0 {o->init("Pquality.basenote");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label {C-2}
@@ -740,9 +584,8 @@ cbwidget->do_callback();}
}
Fl_Group hprofile {
xywh {100 45 430 90} box FLAT_BOX color 51 selection_color 218 labelcolor 63
- code0 {PADnoteHarmonicProfile *hpui=new PADnoteHarmonicProfile(o->x(),o->y(),o->w(),o->h(),"");}
- code1 {hpui->init(pars,master);}
- code2 {if (pars->Pmode!=0) { o->deactivate(); o->color(48);};}
+ code0 {hpui=new PADnoteHarmonicProfile(o->x(),o->y(),o->w(),o->h(),"");}
+ code1 {hpui->init();}
} {}
Fl_Box {} {
label {Profile of One Harmonic (Frequency Distribution)}
@@ -750,9 +593,8 @@ cbwidget->do_callback();}
}
Fl_Choice spectrummode {
label {Spectrum Mode}
- callback {pars->Pmode=(int) o->value();
-
-if (pars->Pmode==0){
+ callback {
+if (o->value()==0){
bwprofilegroup->activate();
bwdial->activate();
bwcents->activate();
@@ -768,9 +610,11 @@ if (pars->Pmode==0){
bwscale->deactivate();
};
+hpui->update();
cbwidget->do_callback();}
xywh {220 305 90 20} down_box BORDER_BOX labelfont 1 labelsize 10 align 5 textsize 11
- code0 {o->value(pars->Pmode);}
+ code0 {o->init("Pmode");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label Bandwidth
@@ -791,173 +635,156 @@ cbwidget->do_callback();}
xywh {0 20 535 375} box UP_FRAME hide
} {
Fl_Group {} {
- label FREQUENCY
+ label FREQUENCY open
xywh {5 275 525 115} box UP_FRAME labeltype EMBOSSED_LABEL labelfont 1 labelsize 13 align 17
} {
Fl_Group freqenv {
label {PADSynth - Frequency Envelope} open
xywh {10 315 205 70} box FLAT_BOX color 51 align 144
- code0 {o->init(pars->FreqEnvelope);}
+ code0 {o->init(ENV_ASR, osc_i, location, "FreqEnvelope/");}
class EnvelopeUI
} {}
Fl_Counter octave {
label Octave
- callback {int k=(int) o->value();
-if (k<0) k+=16;
-pars->PCoarseDetune = k*1024+
- pars->PCoarseDetune%1024;}
tooltip Octave xywh {470 295 45 15} type Simple labelsize 10 align 1 minimum -8 maximum 7 step 1 textfont 1 textsize 11
- code0 {int k=pars->PCoarseDetune/1024;}
- code1 {if (k>=8) k-=16;}
- code2 {o->value(k);}
+ code0 {o->init("octave");}
+ class Fl_Osc_Counter
}
Fl_Counter coarsedet {
label {Coarse det.}
- callback {int k=(int) o->value();
-if (k<0) k+=1024;
-pars->PCoarseDetune = k+
- (pars->PCoarseDetune/1024)*1024;}
tooltip {Coarse Detune} xywh {455 365 70 20} type Simple labelsize 10 align 5 minimum -64 maximum 63 step 1 textfont 1 textsize 11
- code0 {int k=pars->PCoarseDetune%1024;}
- code1 {if (k>=512) k-=1024;}
- code2 {o->value(k);}
+ code0 {o->init("coarsedetune");}
code3 {o->lstep(10);}
+ class Fl_Osc_Counter
}
Fl_Group freqlfo {
label {Frequency LFO } open
xywh {215 315 230 70} box FLAT_BOX color 47 align 144
- code0 {o->init(pars->FreqLfo);}
+ code0 {o->init(osc_i, location, "FreqLfo/");}
class LFOUI
} {}
Fl_Slider detune {
- callback {pars->PDetune=(int)o->value()+8192;
-detunevalueoutput->do_callback();}
+ callback {o->oscWrite("detunevalue");}
tooltip {Fine Detune (cents)} xywh {60 295 295 15} type {Horz Knob} box NO_BOX minimum -8192 maximum 8191 step 1
- code0 {o->value(pars->PDetune-8192);}
+ code0 {o->init("PDetune", 'i');}
+ class Fl_Osc_Slider
}
Fl_Value_Output detunevalueoutput {
label Detune
- callback {o->value(getdetune(pars->PDetuneType,0,pars->PDetune));}
xywh {12 295 45 15} labelsize 10 align 5 minimum -5000 maximum 5000 step 0.01 textfont 1 textsize 10
- code0 {o->value(getdetune(pars->PDetuneType,0,pars->PDetune));}
+ code0 {o->init("detunevalue");}
+ class Fl_Osc_Output
}
Fl_Choice detunetype {
label {Detune Type}
- callback {pars->PDetuneType=(int) o->value()+1;
-detunevalueoutput->do_callback();} open
+ callback {o->oscWrite("detunevalue");} open
xywh {450 330 75 20} down_box BORDER_BOX labelsize 10 align 5 textfont 1 textsize 10
code0 {o->add("L35cents");o->add("L10cents");o->add("E100cents");o->add("E1200cents");}
- code1 {o->value(pars->PDetuneType-1);}
+ code1 {o->init("PDetuneType",1);}
+ class Fl_Osc_Choice
} {}
Fl_Check_Button hz440 {
label 440Hz
- callback {int x=(int) o->value();
-pars->Pfixedfreq=x;
-if (x==0) fixedfreqetdial->deactivate();
+ callback {if (o->value()==0) fixedfreqetdial->deactivate();
else fixedfreqetdial->activate();}
tooltip {set the base frequency to 440Hz} xywh {365 295 50 15} down_box DOWN_BOX labelfont 1 labelsize 10
- code0 {o->value(pars->Pfixedfreq);}
+ code0 {o->init("Pfixedfreq");}
+ class Fl_Osc_Check
}
Fl_Dial fixedfreqetdial {
label {Eq.T.}
- callback {pars->PfixedfreqET=(int) o->value();}
tooltip {How the frequency varies acording to the keyboard (leftmost for fixed frequency)} xywh {420 295 15 15} box ROUND_UP_BOX labelsize 10 align 8 maximum 127 step 1
- code0 {o->value(pars->PfixedfreqET);}
- code1 {if (pars->Pfixedfreq==0) o->deactivate();}
- class WidgetPDial
+ code0 {o->init("PfixedfreqET");}
+ class Fl_Osc_Dial
}
}
Fl_Group {} {
- label AMPLITUDE
+ label AMPLITUDE open
xywh {5 25 240 250} box UP_FRAME labeltype EMBOSSED_LABEL labelfont 1 labelsize 13 align 17
} {
Fl_Value_Slider volume {
label Vol
- callback {pars->PVolume=(int)o->value();}
tooltip Volume xywh {10 50 160 15} type {Horz Knob} box NO_BOX labelsize 11 align 8 maximum 127 step 1
- code0 {o->value(pars->PVolume);}
+ code0 {o->init("PVolume", 'c');}
+ class Fl_Osc_VSlider
}
Fl_Value_Slider vsns {
label {V.Sns}
- callback {pars->PAmpVelocityScaleFunction=(int) o->value();}
tooltip {Velocity Sensing Function (rightmost to disable)} xywh {10 70 160 15} type {Horz Knob} box NO_BOX labelsize 11 align 8 maximum 127 step 1
- code0 {o->value(pars->PAmpVelocityScaleFunction);}
+ code0 {o->init("PAmpVelocityScaleFunction");}
+ class Fl_Osc_VSlider
}
Fl_Dial pan {
label Pan
- callback {pars->PPanning=(int) o->value();}
tooltip {Panning (leftmost is Random)} xywh {210 45 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(pars->PPanning);}
- class WidgetPDial
+ code0 {o->init("PPanning");}
+ class Fl_Osc_Dial
}
Fl_Dial pstr {
label {P.Str.}
- callback {pars->PPunchStrength=(int) o->value();}
tooltip {Punch Strength} xywh {125 247 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->PPunchStrength);}
- class WidgetPDial
+ code0 {o->init("PPunchStrength");}
+ class Fl_Osc_Dial
}
Fl_Dial pt {
label {P.t.}
- callback {pars->PPunchTime=(int) o->value();}
tooltip {Punch Time (duration)} xywh {155 247 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->PPunchTime);}
- class WidgetPDial
+ code0 {o->init("PPunchTime");}
+ class Fl_Osc_Dial
}
Fl_Dial pstc {
label {P.Stc.}
- callback {pars->PPunchStretch=(int) o->value();}
tooltip {Punch Stretch} xywh {185 247 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->PPunchStretch);}
- class WidgetPDial
+ code0 {o->init("PPunchStretch");}
+ class Fl_Osc_Dial
}
Fl_Dial pvel {
label {P.Vel.}
- callback {pars->PPunchVelocitySensing=(int) o->value();}
tooltip {Punch Velocity Sensing} xywh {215 247 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->PPunchVelocitySensing);}
- class WidgetPDial
+ code0 {o->init("PPunchVelocitySensing");}
+ class Fl_Osc_Dial
}
Fl_Group ampenv {
label {PADSynth - Amplitude Envelope} open
xywh {10 95 205 70} box FLAT_BOX color 51 align 144
- code0 {o->init(pars->AmpEnvelope);}
+ code0 {o->init(ENV_ADSR, osc_i, location, "AmpEnvelope/");}
class EnvelopeUI
} {}
Fl_Group amplfo {
label {Amplitude LFO } open
xywh {10 165 230 70} box FLAT_BOX color 47 align 144
- code0 {o->init(pars->AmpLfo);}
+ code0 {o->init(osc_i, location, "AmpLfo/");}
class LFOUI
} {}
Fl_Check_Button stereo {
label Stereo
- callback {pars->PStereo=(int) o->value();
-hprofile->redraw();}
+ callback {hprofile->redraw();}
xywh {15 245 70 25} down_box DOWN_BOX
- code0 {o->value(pars->PStereo);}
+ code0 {o->init("PStereo");}
+ class Fl_Osc_Check
}
}
Fl_Group {} {
- label FILTER
+ label FILTER open
xywh {245 25 285 250} box UP_FRAME labeltype EMBOSSED_LABEL labelfont 1 labelsize 13 align 17
} {
Fl_Group filterenv {
label {PADSynth - Filter Envelope} open
xywh {250 130 275 70} box FLAT_BOX color 51 align 144
- code0 {o->init(pars->FilterEnvelope);}
+ code0 {o->init(ENV_ADSR_FILTER, osc_i, location, "FilterEnvelope/");}
class EnvelopeUI
} {}
Fl_Group filterlfo {
label {Filter LFO } open
xywh {250 200 230 70} box FLAT_BOX color 47 align 144
- code0 {o->init(pars->FilterLfo);}
+ code0 {o->init(osc_i, location, "FilterLfo/");}
class LFOUI
} {}
Fl_Group filterui {
label {PADsynth - Filter} open
xywh {250 55 275 75} box FLAT_BOX color 50 align 144
- code0 {o->init(pars->GlobalFilter,&pars->PFilterVelocityScale,&pars->PFilterVelocityScaleFunction);}
+ code0 {o->init(location + "PFilter",
+ osc_i, location, "GlobalFilter/");}
class FilterUI
} {}
}
@@ -965,7 +792,8 @@ hprofile->redraw();}
}
Fl_Button applybutton {
label {Apply Changes}
- callback {pars->applyparameters(true);
+ callback {osc_i->requestValue(location+"prepare");
+//MiddleWare::preparePadSynth(location.c_str(), pars);
o->color(FL_GRAY);
if (oscui!=NULL) {
oscui->applybutton->color(FL_GRAY);
@@ -985,12 +813,12 @@ if (resui!=NULL) {
}
Fl_Button {} {
label C
- callback {presetsui->copy(pars);}
+ callback {/*presetsui->copy(pars);*/}
xywh {65 400 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
}
Fl_Button {} {
label P
- callback {presetsui->paste(pars,this);}
+ callback {/*presetsui->paste(pars,this);*/}
xywh {95 400 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
}
Fl_Button {} {
@@ -999,41 +827,15 @@ if (resui!=NULL) {
filename=fl_file_chooser("Export samples:","(*.wav)",NULL,0);
if (filename==NULL) return;
fl_filename_setext(filename,"");
-
-
-
-pars->export2wav(filename);}
+o->oscWrite("export2wav", "s", filename);}
tooltip {export samples as wav file} xywh {5 400 55 30} box THIN_UP_BOX color 51 labelsize 11 align 128
+ class Fl_Osc_Button
}
}
}
- Function {refresh()} {} {
- code {volume->value(pars->PVolume);
-vsns->value(pars->PAmpVelocityScaleFunction);
-pan->value(pars->PPanning);
-
-stereo->value(pars->PStereo);
-
-
-pstr->value(pars->PPunchStrength);
-pt->value(pars->PPunchTime);
-pstc->value(pars->PPunchStretch);
-pvel->value(pars->PPunchVelocitySensing);
-
-detunevalueoutput->value(getdetune(pars->PDetuneType,0,pars->PDetune));
-detune->value(pars->PDetune-8192);
-
-int k=pars->PCoarseDetune/1024;if (k>=8) k-=16;
-octave->value(k);
-
-detunetype->value(pars->PDetuneType-1);
-k=pars->PCoarseDetune%1024;if (k>=512) k-=1024;
-coarsedet->value(k);
-
-hz440->value(pars->Pfixedfreq);
-fixedfreqetdial->value(pars->PfixedfreqET);
-
-amplfo->refresh();
+ Function {refresh()} {open
+ } {
+ code {amplfo->refresh();
freqlfo->refresh();
filterlfo->refresh();
@@ -1046,25 +848,9 @@ filterui->refresh();
/* harmonic structure parametrs */
resui->refresh();
-if (oscui!=NULL) oscui->refresh();
-
-hpbasetype->value(pars->Php.base.type);
-hpbasepar1->value(pars->Php.base.par1);
-hpfreqmult->value(pars->Php.freqmult);
-
-hpmpar1->value(pars->Php.modulator.par1);
-hpmfreq->value(pars->Php.modulator.freq);
-hpwidth->value(pars->Php.width);
-
-hponehalf->value(pars->Php.onehalf);
-hpamptype->value(pars->Php.amp.type);
-hpampmode->value(pars->Php.amp.mode);
-hpamppar1->value(pars->Php.amp.par1);
-hpamppar2->value(pars->Php.amp.par2);
-hpautoscale->value(pars->Php.autoscale);
+if (oscui) oscui->refresh();
-bwdial->value(pars->Pbandwidth);
-if (pars->Pmode==0){
+if (spectrummode->value()==0){
bwprofilegroup->activate();
bwdial->activate();
bwcents->activate();
@@ -1080,23 +866,11 @@ if (pars->Pmode==0){
bwscale->activate();
};
-spectrummode->value(pars->Pmode);
-
-qbasenote->value(pars->Pquality.basenote);
-qsmpoct->value(pars->Pquality.smpoct);
-qoct->value(pars->Pquality.oct);
-qsamplesize->value(pars->Pquality.samplesize);
-
-hrpostype->value(pars->Phrpos.type);
-hrpospar1->value(pars->Phrpos.par1);
-hrpospar2->value(pars->Phrpos.par2);
-hrpospar3->value(pars->Phrpos.par3);
-
hprofile->redraw();
-overtonepos->redraw();
+opui->update();
osc->redraw();
-pars->applyparameters(true);
+//MiddleWare::preparePadSynth(location.c_str(), pars);
applybutton->color(FL_GRAY);
applybutton->parent()->redraw();} {}
}
@@ -1105,16 +879,22 @@ applybutton->parent()->redraw();} {}
delete(resui);
padnotewindow->hide();
-delete(padnotewindow);} {}
+delete padnotewindow;} {}
+ }
+ decl {OscilEditor *oscui;} {public local
+ }
+ decl {bool initialized;}{private local
+ }
+ decl {Fl_Oscilloscope *osc;} {public local
}
- decl {PADnoteParameters *pars;} {public
+ decl {ResonanceUI *resui;} {public local
}
- decl {Master *master;} {public
+ decl {std::string location;} {private local
}
- decl {OscilEditor *oscui;} {public
+ decl {Fl_Osc_Interface *osc_i;} {private local
}
- decl {Oscilloscope *osc;} {public
+ decl {PADnoteHarmonicProfile *hpui;} {private local
}
- decl {ResonanceUI *resui;} {public
+ decl {PADnoteOvertonePosition *opui;} {private local
}
}
diff --git a/src/UI/PartNameButton.cpp b/src/UI/PartNameButton.cpp
@@ -0,0 +1,12 @@
+#include "PartNameButton.h"
+
+PartNameButton::PartNameButton(int X, int Y, int W, int H, const char *label)
+ :Fl_Button(X,Y,W,H,label), Fl_Osc_Widget(this)
+{
+}
+
+void PartNameButton::OSC_value(const char *label_)
+{
+ the_string = label_;
+ label(the_string.c_str());
+}
diff --git a/src/UI/PartNameButton.h b/src/UI/PartNameButton.h
@@ -0,0 +1,16 @@
+#pragma once
+#include <FL/Fl_Button.H>
+#include "Fl_Osc_Widget.H"
+#include <string>
+
+class PartNameButton:public Fl_Button, public Fl_Osc_Widget
+{
+ public:
+ PartNameButton(int X, int Y, int W, int H, const char *label=NULL);
+
+ virtual ~PartNameButton(void){};
+ virtual void OSC_value(const char *);
+ std::string the_string;
+
+ //virtual void rebase(std::string) override;
+};
diff --git a/src/UI/PartUI.fl b/src/UI/PartUI.fl
@@ -1,45 +1,56 @@
# data file for the Fltk User Interface Designer (fluid)
-version 1.0110
+version 1.0302
header_name {.h}
code_name {.cc}
-decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {}
+decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {private local
+}
+
+decl {//License: GNU GPL version 2 or later} {private local
+}
+
+decl {\#include <stdlib.h>} {public local
+}
-decl {//License: GNU GPL version 2 or later} {}
+decl {\#include <stdio.h>} {public local
+}
+
+decl {\#include <string.h>} {public local
+}
-decl {\#include <stdlib.h>} {public
+decl {\#include <string>} {public local
}
-decl {\#include <stdio.h>} {public
+decl {\#include "Fl_Osc_Dial.H"} {public local
}
-decl {\#include <string.h>} {public
+decl {\#include "Fl_Osc_Input.H"} {public local
}
-decl {\#include "WidgetPDial.h"} {public
+decl {\#include "PartNameButton.h"} {public local
}
-decl {\#include "EffUI.h"} {public
+decl {\#include "EffUI.h"} {public local
}
-decl {\#include "BankUI.h"} {public
+decl {\#include "BankUI.h"} {public local
}
-decl {\#include "ADnoteUI.h"} {public
+decl {\#include "ADnoteUI.h"} {public local
}
-decl {\#include "SUBnoteUI.h"} {public
+decl {\#include "SUBnoteUI.h"} {public local
}
-decl {\#include "PADnoteUI.h"} {public
+decl {\#include "PADnoteUI.h"} {public local
}
-decl {\#include "../Misc/Config.h"} {public
+decl {\#include "../Misc/Config.h"} {public local
}
-decl {\#include "../Misc/Master.h"} {public
+decl {\#include "../Misc/Master.h"} {public local
}
-decl {\#include "../Misc/Part.h"} {public
+decl {\#include "../Misc/Part.h"} {public local
}
class PartSysEffSend {open : {public Fl_Group}
@@ -47,29 +58,26 @@ class PartSysEffSend {open : {public Fl_Group}
Function {make_window()} {open private
} {
Fl_Window syseffsend {
- private xywh {589 129 100 100} type Double box NO_BOX
+ private xywh {604 244 100 100} type Double box NO_BOX
class Fl_Group visible
} {
Fl_Dial {} {
label 01
- callback {master->setPsysefxvol(npart,neff,(int) o->value());}
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->value(master->Psysefxvol[neff][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 WidgetPDial
+ class Fl_Osc_Dial
}
}
}
Function {PartSysEffSend(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
- code {master=NULL;
-neff=0;
+ code {neff=0;
npart=0;} {}
}
- Function {init(Master *master_,int npart_,int neff_)} {} {
+ Function {init(int npart_,int neff_)} {} {
code {npart=npart_;
neff=neff_;
-master=master_;
make_window();
syseffsend->show();
end();} {}
@@ -78,41 +86,40 @@ end();} {}
code {syseffsend->hide();
//delete(syseffsend);} {}
}
- decl {Master *master;} {}
- decl {int neff;} {}
- decl {int npart;} {}
+ decl {int neff;} {private local
+ }
+ decl {int npart;} {private local
+ }
}
-class PartKitItem {open : {public Fl_Group}
+class PartKitItem {open : {public Fl_Osc_Group}
} {
Function {make_window()} {open private
} {
Fl_Window partkititem {
- private xywh {473 406 670 100} type Double box NO_BOX
- class Fl_Group visible
+ private xywh {488 521 670 100} type Double box NO_BOX
+ class Fl_Osc_Group visible
} {
Fl_Group partkititemgroup {
private xywh {55 0 605 20}
- code0 {if (part->kit[n].Penabled==0) o->deactivate();}
+ class Fl_Osc_Group
} {
Fl_Counter minkcounter {
- callback {part->kit[n].Pminkey=(int)o->value();}
xywh {225 0 55 15} type Simple minimum 0 maximum 128 step 1
- code0 {o->value(part->kit[n].Pminkey);}
+ code0 {o->init("Pminkey");}
+ class Fl_Osc_Counter
}
Fl_Button {} {
label m
- callback {if (part->lastnote>=0) minkcounter->value(part->lastnote);
-minkcounter->do_callback();
-maxkcounter->do_callback();}
+ callback {o->oscWrite("grabMinKey");}
tooltip {set the minimum key to the last pressed key} xywh {285 3 15 12} box THIN_UP_BOX labelsize 10
+ class Fl_Osc_Button
}
Fl_Button {} {
label M
- callback {if (part->lastnote>=0) maxkcounter->value(part->lastnote);
-maxkcounter->do_callback();
-minkcounter->do_callback();}
+ callback {o->oscWrite("grabMaxKey");}
tooltip {set the maximum key to the last pressed key} xywh {315 3 15 12} box THIN_UP_BOX labelsize 10
+ class Fl_Osc_Button
}
Fl_Button {} {
label R
@@ -126,174 +133,137 @@ maxkcounter->do_callback();}
label edit
callback {partui->showparameters(n,0);}
xywh {420 0 40 15} box THIN_UP_BOX labelsize 11
- code0 {if (part->kit[n].Padenabled==0) o->deactivate();}
code1 {if (n==0) o->hide();}
}
Fl_Button subeditbutton {
label edit
callback {partui->showparameters(n,1);}
xywh {490 0 40 15} box THIN_UP_BOX labelsize 11
- code0 {if (part->kit[n].Psubenabled==0) o->deactivate();}
code1 {if (n==0) o->hide();}
}
Fl_Check_Button mutedcheck {
- callback {part->kit[n].Pmuted=(int)o->value();}
private xywh {60 0 20 15} down_box DOWN_BOX labelfont 1 labelsize 11 align 4
- code0 {o->value(part->kit[n].Pmuted);}
+ code0 {o->init("Pmuted");}
+ class Fl_Osc_Check
}
Fl_Counter maxkcounter {
- callback {part->kit[n].Pmaxkey=(int)o->value();}
xywh {335 0 55 15} type Simple minimum 0 maximum 128 step 1
- code0 {o->value(part->kit[n].Pmaxkey);}
+ code0 {o->init("Pmaxkey");}
+ class Fl_Osc_Counter
}
- Fl_Button labelbutton {
+ Fl_Input labelbutton {
label {Bass Drum}
- callback {const char *tmp=fl_input("Kit item name:",(const char *)part->kit[n].Pname);
-if (tmp!=NULL) snprintf((char *)part->kit[n].Pname,PART_MAX_NAME_LEN,"%s",tmp);}
- xywh {90 0 130 15} box THIN_DOWN_BOX down_box FLAT_BOX labelfont 1 labelsize 10 align 20
- code0 {o->label((char *)part->kit[n].Pname);}
+ xywh {90 0 130 15} box THIN_DOWN_BOX labelfont 1 labelsize 10 align 20
+ code0 {o->init("Pname");}
+ class Fl_Osc_Input
}
Fl_Check_Button adcheck {
- callback {part->kit[n].Padenabled=(int)o->value();
-if (part->kit[n].Padenabled!=0) adeditbutton->activate();
+ callback {if (o->value()!=0) adeditbutton->activate();
else adeditbutton->deactivate();}
private xywh {400 0 20 15} down_box DOWN_BOX labelfont 1 labelsize 11 align 4
- code0 {o->value(part->kit[n].Padenabled);}
+ code0 {o->init("Padenabled");}
code1 {if (n==0) o->hide();}
+ class Fl_Osc_Check
}
Fl_Check_Button subcheck {
- callback {part->kit[n].Psubenabled=(int)o->value();
-if (part->kit[n].Psubenabled!=0) subeditbutton->activate();
+ callback {if(o->value()!=0) subeditbutton->activate();
else subeditbutton->deactivate();}
private xywh {470 0 20 15} down_box DOWN_BOX labelfont 1 labelsize 11 align 4
- code0 {o->value(part->kit[n].Psubenabled);}
+ code0 {o->init("Psubenabled");}
code1 {if (n==0) o->hide();}
+ class Fl_Osc_Check
}
Fl_Choice sendtoeffect {
- callback {if (o->value()!=0) part->kit[n].Psendtoparteffect=(int)o->value()-1;
- else part->kit[n].Psendtoparteffect=127;} open
xywh {615 0 45 15} down_box BORDER_BOX labelsize 10 align 5 textfont 1 textsize 10
code0 {o->add("OFF");char nrstr[10]; for(int i=0;i<NUM_PART_EFX;i++){sprintf(nrstr,"FX%d",i+1);o->add(nrstr);};}
- code1 {o->value(part->kit[n].Psendtoparteffect+1);if (part->kit[n].Psendtoparteffect==127) o->value(0);}
+ code1 {o->init("Psendtoparteffect");//TODO check semantics}
+ class Fl_Osc_Choice
} {}
Fl_Button padeditbutton {
label edit
callback {partui->showparameters(n,2);}
xywh {560 0 40 15} box THIN_UP_BOX labelsize 11
- code0 {if (part->kit[n].Ppadenabled==0) o->deactivate();}
code1 {if (n==0) o->hide();}
}
Fl_Check_Button padcheck {
- callback {part->kit[n].Ppadenabled=(int)o->value();
-if (part->kit[n].Ppadenabled!=0) padeditbutton->activate();
+ callback {if (o->value()!=0) padeditbutton->activate();
else padeditbutton->deactivate();}
private xywh {540 0 20 15} down_box DOWN_BOX labelfont 1 labelsize 11 align 4
- code0 {o->value(part->kit[n].Ppadenabled);}
+ code0 {o->init("Ppadenabled");}
code1 {if (n==0) o->hide();}
+ class Fl_Osc_Check
}
}
Fl_Check_Button enabledcheck {
label 01
callback {int answer=1;
-if (o->value()==0) answer=fl_choice("Delete the item?","No","Yes",NULL);
-if (answer!=0){
-pthread_mutex_lock(&master->mutex);
- part->setkititemstatus(n,(int) o->value());
-pthread_mutex_unlock(&master->mutex);
+ //TODO special case
+if (o->value()==0 && !o->is_osc)
+ answer=fl_choice("Delete the item?","No","Yes",NULL);
+if(!answer)
+ o->value(true);
if (o->value()==0) partkititemgroup->deactivate();
else partkititemgroup->activate();
o->redraw();
-partui->showparameters(n,-1);//use to delete the ui, if it is not to item 0
-} else o->value(1);}
+partui->showparameters(n,-1);//use to delete the ui, if it is not to item 0}
private xywh {30 0 20 15} down_box DOWN_BOX labeltype EMBOSSED_LABEL labelfont 1 labelsize 13 align 4
code0 {snprintf(label,10,"%d",n+1);o->label(label);}
- code1 {o->value(part->kit[n].Penabled);}
+ code1 {o->init("Penabled");}
code2 {if (n==0) o->deactivate();}
+ class Fl_Osc_Check
}
}
}
- Function {PartKitItem(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
- code {n=0;
-part=NULL;} {}
+ Function {PartKitItem(int x,int y, int w, int h, const char *label=0):Fl_Osc_Group(x,y,w,h,label)} {} {
+ code {n=0;} {}
}
Function {refresh()} {} {
- code {enabledcheck->value(part->kit[n].Penabled);
-if (part->kit[n].Penabled==0) partkititemgroup->deactivate();
-else partkititemgroup->activate();
-
-mutedcheck->value(part->kit[n].Pmuted);
-labelbutton->label((char *)part->kit[n].Pname);
-minkcounter->value(part->kit[n].Pminkey);
-maxkcounter->value(part->kit[n].Pmaxkey);
-adcheck->value(part->kit[n].Padenabled);
-adcheck->do_callback();
-subcheck->value(part->kit[n].Psubenabled);
-subcheck->do_callback();
-
-sendtoeffect->value(part->kit[n].Psendtoparteffect+1);
-if (part->kit[n].Psendtoparteffect==127) sendtoeffect->value(0);
-
-this->redraw();} {
- callback {int answer=1;
-if (o->value()==0) answer=fl_choice("Delete the item?","No","Yes",NULL);
-if (answer!=0){
-pthread_mutex_lock(&master->mutex);
- part->setkititemstatus(n,(int) o->value());
-pthread_mutex_unlock(&master->mutex);
-
-if (o->value()==0) partkititemgroup->deactivate();
-else partkititemgroup->activate();
-o->redraw();
-partui->showparameters(n,-1);//use to delete the ui, if it is not to item 0
-} else o->value(1);}
- }
+ code {this->redraw();} {}
}
- Function {init(Part *part_,int n_,Master *master_,class PartUI *partui_)} {} {
- code {part=part_;
-n=n_;
+ Function {init(int n_,class PartUI *partui_)} {} {
+ code {n=n_;
+ ext = "kit"+to_s(n)+"/";
partui=partui_;
-master=master_;
make_window();
//partkititem->show();
end();} {}
}
Function {~PartKitItem()} {} {
- code {partkititem->hide();
-//delete(partkititem);} {}
+ code {} {}
+ }
+ decl {int n;} {private local
+ }
+ decl {char label[10];} {private local
+ }
+ decl {class PartUI *partui;} {private local
}
- decl {Part *part;} {}
- decl {int n;} {}
- decl {Master *master;} {}
- decl {char label[10];} {}
- decl {class PartUI *partui;} {}
}
-class PartUI {open : {public Fl_Group}
+class PartUI {open : {public Fl_Osc_Group}
} {
Function {make_window()} {open private
} {
- Fl_Window partgroup {open
- private xywh {688 264 385 180} type Double box NO_BOX
+ Fl_Window partgroup {
+ private xywh {703 379 385 180} type Double box NO_BOX
class Fl_Group visible
} {
Fl_Group partgroupui {open
xywh {0 0 385 180}
- code0 {if (part->Penabled==0) o->deactivate();}
+ class Fl_Osc_Group
} {
Fl_Dial {} {
label Pan
- callback {part->setPpanning((int) o->value());}
xywh {50 40 25 25} box ROUND_UP_BOX labelsize 11 maximum 127 step 1
- code0 {o->value(part->Ppanning);}
- class WidgetPDial
+ code0 {o->init("Ppanning");}
+ class Fl_Osc_Dial
}
Fl_Counter {} {
label KeyShift
- callback {part->Pkeyshift=(int) o->value()+64;}
xywh {195 45 90 20} labelsize 11 align 1 minimum -64 maximum 64 step 1
code0 {o->lstep(12);}
- code1 {o->value(part->Pkeyshift-64);}
+ code1 {o->init("Pkeyshift");}
+ class Fl_Osc_Counter
}
Fl_Scroll {} {open
xywh {166 91 125 49} box UP_BOX labelfont 1 labelsize 10 align 21
@@ -301,21 +271,25 @@ class PartUI {open : {public Fl_Group}
Fl_Pack {} {open
xywh {171 96 115 35} type HORIZONTAL
code0 {o->spacing(5);}
- code1 {for (int i=0;i<NUM_SYS_EFX;i++){psyef[i]=new PartSysEffSend(0,0,25,35,"");psyef[i]->init(master,npart,i);}}
+ code1 {for (int i=0;i<NUM_SYS_EFX;i++){psyef[i]=new PartSysEffSend(0,0,25,35,"");psyef[i]->init(npart,i);}}
} {}
}
Fl_Button {} {
label {Grand Piano}
callback {int event=Fl::event_button();
if (event==FL_RIGHT_MOUSE){
- const char *tmp=fl_input("Instrument name:",(const char *)part->Pname);
- if (tmp!=NULL) snprintf((char *)part->Pname,PART_MAX_NAME_LEN,"%s",tmp);
+ fprintf(stderr, "Unimplemented...\\n");
+ /*const char *tmp=fl_input("Instrument name:",(const char *)part->Pname);*/
+ /*if (tmp!=NULL) snprintf((char *)part->Pname,PART_MAX_NAME_LEN,"%s",tmp);*/
} else {
if (event==FL_LEFT_MOUSE) bankui->show();
else instrumenteditwindow->show();
};}
- tooltip {left mousebutton - to choose/save/.. from/to bank or right mousebutton to change the name or middle button to change the instrument information} xywh {195 5 185 20} box UP_FRAME down_box DOWN_FRAME labelfont 1 labelsize 11 align 84
- code0 {o->label((char *)part->Pname);}
+ tooltip {left mousebutton - to choose/save/.. from/to bank or right mousebutton to change the name or middle button to change the instrument information}
+ xywh {195 5 185 20} box UP_FRAME down_box DOWN_FRAME labelfont 1 labelsize 11 align 84
+ code0 {/*o->label((char *)part->Pname);*/}
+ code1 {o->ext = "Pname";o->oscRegister("Pname");}
+ class PartNameButton
}
Fl_Box {} {
label {To Sys.Efx.}
@@ -323,47 +297,43 @@ if (event==FL_RIGHT_MOUSE){
}
Fl_Check_Button {} {
label NoteOn
- callback {part->Pnoteon=(int) o->value();}
tooltip {set if the part receives NoteOn messages} xywh {10 155 65 20} down_box DOWN_BOX labelfont 1 labelsize 11
- code0 {o->value(part->Pnoteon);}
+ code0 {o->init("Pnoteon");}
+ class Fl_Osc_Check
}
Fl_Counter minkcounter {
label {Min.k}
- callback {part->Pminkey=(int) o->value();
-if (part->Pminkey>part->Pmaxkey) o->textcolor(FL_RED);
+ callback {if (minkcounter->value() > maxkcounter->value()) o->textcolor(FL_RED);
else o->textcolor(FL_BLACK);}
tooltip {Minimum key (that the part receives NoteOn messages)} xywh {295 125 40 15} type Simple labelfont 1 labelsize 10 minimum 0 maximum 127 step 1 textsize 10
- code0 {o->value(part->Pminkey);}
+ code0 {o->init("Pminkey");}
+ class Fl_Osc_Counter
}
Fl_Counter maxkcounter {
label {Max.k}
- callback {part->Pmaxkey=(int) o->value();
-
-if (part->Pminkey>part->Pmaxkey) o->textcolor(FL_RED);
+ callback {if (minkcounter->value() > maxkcounter->value()) o->textcolor(FL_RED);
else o->textcolor(FL_BLACK);}
tooltip {Maximum key (that the part receives NoteOn messages)} xywh {340 125 40 15} type Simple labelfont 1 labelsize 10 minimum 0 maximum 127 step 1 textsize 10
- code0 {o->value(part->Pmaxkey);}
+ code0 {o->init("Pmaxkey");}
+ class Fl_Osc_Counter
}
Fl_Dial {} {
label Volume
- callback {part->setPvolume((int) o->value());}
tooltip {Part Volume} xywh {10 35 30 30} box ROUND_UP_BOX labelsize 11 maximum 127 step 1
- code0 {o->value(part->Pvolume);}
- class WidgetPDial
+ code0 {o->init("Pvolume");}
+ class Fl_Osc_Dial
}
Fl_Dial {} {
label {Vel.Ofs.}
- callback {part->Pveloffs=(int) o->value();}
tooltip {Velocity Offset} xywh {135 40 25 25} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(part->Pveloffs);}
- class WidgetPDial
+ code0 {o->init("Pveloffs");}
+ class Fl_Osc_Dial
}
Fl_Dial {} {
label {Vel.Sns.}
- callback {part->Pvelsns=(int) o->value();}
tooltip {Velocity Sensing Function} xywh {95 40 25 25} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(part->Pvelsns);}
- class WidgetPDial
+ code0 {o->init("Pvelsns");}
+ class Fl_Osc_Dial
}
Fl_Button {} {
label Controllers
@@ -372,9 +342,9 @@ if (part->Pminkey>part->Pmaxkey) o->textcolor(FL_RED);
}
Fl_Check_Button {} {
label Portamento
- callback {part->ctl.portamento.portamento=(int) o->value();}
tooltip {Enable/Disable the portamento} xywh {95 155 88 20} down_box DOWN_BOX labelfont 1 labelsize 11
- code0 {o->value(part->ctl.portamento.portamento);}
+ code0 {o->init("ctl/portamento.portamento");}
+ class Fl_Osc_Check
}
Fl_Button {} {
label {Edit instrument}
@@ -383,146 +353,134 @@ if (part->Pminkey>part->Pmaxkey) o->textcolor(FL_RED);
}
Fl_Button {} {
label m
- callback {if (part->lastnote>=0) minkcounter->value(part->lastnote);
-minkcounter->do_callback();
-maxkcounter->do_callback();}
+ callback {o->oscWrite("captureMin");
+ o->oscWrite("Pminkey");
+ o->oscWrite("Pmaxkey");}
tooltip {set the minimum key to the last pressed key} xywh {315 155 15 12} box THIN_UP_BOX labelsize 10
+ class Fl_Osc_Button
}
Fl_Button {} {
label M
- callback {if (part->lastnote>=0) maxkcounter->value(part->lastnote);
-maxkcounter->do_callback();
-minkcounter->do_callback();}
+ callback {o->oscWrite("captureMax");
+ o->oscWrite("Pminkey");
+ o->oscWrite("Pmaxkey");}
tooltip {set the maximum key to the last pressed key} xywh {345 155 15 12} box THIN_UP_BOX labelsize 10
+ class Fl_Osc_Button
}
Fl_Button {} {
label R
- callback {minkcounter->value(0);
-minkcounter->do_callback();
-maxkcounter->value(127);
-maxkcounter->do_callback();}
+ callback {o->oscWrite("Pminkey", "c", 0);
+ o->oscWrite("Pmaxkey", "c", 127);}
tooltip {reset the minimum key to 0 and maximum key to 127} xywh {330 155 15 12} box THIN_UP_BOX labelfont 1 labelsize 10
+ class Fl_Osc_Button
}
Fl_Choice {} {
label {MIDI Chn.Rcv.}
- callback {part->Prcvchn=(int) o->value();} open
tooltip {receive from Midi channel} xywh {310 45 70 20} down_box BORDER_BOX labelsize 10 align 5 textfont 1 textsize 10
code0 {char nrstr[10]; for(int i=0;i<NUM_MIDI_CHANNELS;i++){sprintf(nrstr,"Chn%d",i+1);if (i!=9) o->add(nrstr); else o->add("Drms10");};}
- code1 {o->value(part->Prcvchn);}
+ code1 {o->init("Prcvchn");}
+ class Fl_Osc_Choice
} {}
Fl_Choice keylimitlist {
label KLmt
- callback {int val=0;
+ callback {//TODO special case
+ int val=0;
val=atoi(o->text());
-part->setkeylimit(val);} open
+osc->write("/setkeylimit", "i", val);} open
tooltip {Key Limit} xywh {215 155 50 20} down_box BORDER_BOX labelsize 10 align 8 textfont 1 textsize 10
} {}
Fl_Choice {} {
label {Mode :}
- callback {if ((int) o->value()==0){ /* Poly (implies no legato) */
- part->Ppolymode=1;
- part->Plegatomode=0;
-} else {
- if ((int) o->value()==1){ /* Mono (implies no legato) */
- part->Ppolymode=0;
- part->Plegatomode=0;
- } else {
- if ((int) o->value()==2){ /* Legato (implies mono) */
- part->Ppolymode=0;
- part->Plegatomode=1;
- };
- };
-};} open
tooltip {Poly, Mono or Legato mode} xywh {80 130 64 18} down_box BORDER_BOX labelfont 1 labelsize 11 textfont 1 textsize 10
code0 {o->add("Poly"); o->add("Mono"); o->add("Legato");}
- code1 {if (part->Ppolymode!=0) o->value(0); else o->value(1);}
- code2 {if (part->Ppolymode==0 && part->Plegatomode!=0) o->value(2);}
+ code1 {o->init("polyType");}
+ class Fl_Osc_Choice
} {}
}
- Fl_Check_Button {} {
+ Fl_Check_Button partenablebutton {
label Enabled
- callback {pthread_mutex_lock(&master->mutex);
-master->partonoff(npart,(int) o->value());
-pthread_mutex_unlock(&master->mutex);
-if (part->Penabled==0) partgroupui->deactivate();
+ callback {if (o->value()==0) partgroupui->deactivate();
else partgroupui->activate();}
xywh {90 5 75 20} down_box DOWN_BOX labelfont 1 labelsize 11
- code0 {o->value(part->Penabled);}
+ code0 {o->init("Penabled");}
+ class Fl_Osc_Check
}
}
Fl_Window ctlwindow {
- label Controllers open
- private xywh {777 261 500 130} type Double box NO_BOX visible
+ label Controllers
+ private xywh {777 376 500 130} type Double box NO_BOX
+ class Fl_Osc_Window visible
} {
+ Fl_Box {} {
+ xywh {0 0 0 0}
+ code0 {ctlwindow->osc = osc;}
+ code1 {ctlwindow->base = "/part"+to_s(npart)+"/ctl/";}
+ }
Fl_Check_Button {} {
label Expr
- callback {part->ctl.expression.receive=(int) o->value();}
tooltip {Expression enable} xywh {155 55 45 20} box THIN_UP_BOX down_box DOWN_BOX labelsize 10
- code0 {o->value(part->ctl.expression.receive);}
+ code0 {o->init("expression.receive");}
+ class Fl_Osc_Check
}
Fl_Dial {} {
label PanDpth
- callback {part->ctl.panning.depth=(int) o->value();}
tooltip {Panning Depth} xywh {10 55 30 30} labelsize 10 maximum 127 step 1
- code0 {o->value(part->ctl.panning.depth);}
- class WidgetPDial
+ code0 {o->init("panning.depth");}
+ class Fl_Osc_Dial
}
Fl_Dial {} {
label FltCut
- callback {part->ctl.filtercutoff.depth=(int) o->value();}
tooltip {Filter Cutoff depth} xywh {90 55 30 30} labelsize 10 maximum 127 step 1
- code0 {o->value(part->ctl.filtercutoff.depth);}
- class WidgetPDial
+ code0 {o->init("filtercutoff.depth");}
+ class Fl_Osc_Dial
}
Fl_Dial {} {
label FltQ
- callback {part->ctl.filterq.depth=(int) o->value();}
tooltip {Filter Q depth} xywh {50 55 30 30} labelsize 10 maximum 127 step 1
- code0 {o->value(part->ctl.filterq.depth);}
- class WidgetPDial
+ code0 {o->init("filterq.depth");}
+ class Fl_Osc_Dial
}
Fl_Dial {} {
label BwDpth
- callback {part->ctl.bandwidth.depth=(int) o->value();}
tooltip {BandWidth depth} xywh {125 10 30 30} labelsize 10 maximum 127 step 1
- code0 {o->value(part->ctl.bandwidth.depth);}
- class WidgetPDial
+ code0 {o->init("bandwidth.depth");}
+ class Fl_Osc_Dial
}
Fl_Dial {} {
label ModWh
- callback {part->ctl.modwheel.depth=(int) o->value();}
tooltip {Modulation Wheel depth} xywh {50 10 30 30} labelsize 10 maximum 127 step 1
- code0 {o->value(part->ctl.modwheel.depth);}
- class WidgetPDial
+ code0 {o->init("modwheel.depth");}
+ class Fl_Osc_Dial
}
Fl_Counter {} {
label {PWheelB.Rng (cents)}
- callback {part->ctl.pitchwheel.bendrange=(int) o->value();}
tooltip {Pitch Wheel Bend Range (cents)} xywh {165 15 110 20} labelsize 10 align 1 minimum -6400 maximum 6400 step 1
- code0 {o->value(part->ctl.pitchwheel.bendrange);}
+ code0 {o->init("pitchwheel.bendrange", 'i');}
code1 {o->lstep(100);}
+ class Fl_Osc_Counter
}
Fl_Check_Button {} {
label FMamp
- callback {part->ctl.fmamp.receive=(int) o->value();}
tooltip {FM amplitude enable} xywh {205 55 60 20} box THIN_UP_BOX down_box DOWN_BOX labelsize 10
- code0 {o->value(part->ctl.fmamp.receive);}
+ code0 {o->init("fmamp.receive");}
+ class Fl_Osc_Check
}
Fl_Check_Button {} {
label Vol
- callback {part->ctl.volume.receive=(int) o->value();}
tooltip {Volume enable} xywh {155 80 45 20} box THIN_UP_BOX down_box DOWN_BOX labelsize 10
- code0 {o->value(part->ctl.volume.receive);}
+ code0 {o->init("volume.receive");}
+ class Fl_Osc_Check
}
Fl_Check_Button {} {
label Sustain
- callback {part->ctl.sustain.receive=(int) o->value();
-if (part->ctl.sustain.receive==0) {
- part->RelaseSustainedKeys();
- part->ctl.setsustain(0);
-};}
+ callback {//TODO
+ /*if (ctl.sustain.receive==0) {
+ RelaseSustainedKeys();
+ ctl.setsustain(0);
+ };*/}
tooltip {Sustain pedal enable} xywh {205 80 60 20} box THIN_UP_BOX down_box DOWN_BOX labelsize 10
- code0 {o->value(part->ctl.sustain.receive);}
+ code0 {o->init("sustain.receive");}
+ class Fl_Osc_Check
}
Fl_Button {} {
label Close
@@ -531,37 +489,38 @@ if (part->ctl.sustain.receive==0) {
}
Fl_Button {} {
label {Reset all controllers}
- callback {part->SetController(C_resetallcontrollers,0);}
+ callback {o->oscWrite("defaults");//part->SetController(C_resetallcontrollers,0);}
xywh {5 107 210 20} box THIN_UP_BOX
+ class Fl_Osc_Button
}
Fl_Group {} {
- label Portamento
+ label Portamento open
xywh {280 15 160 90} box UP_FRAME labelsize 10
+ class Fl_Osc_Group
} {
Fl_Check_Button {} {
label Rcv
- callback {part->ctl.portamento.receive=(int) o->value();}
tooltip {Receive Portamento Controllers} xywh {285 20 40 20} box THIN_UP_BOX down_box DOWN_BOX labelsize 10
- code0 {o->value(part->ctl.portamento.receive);}
+ code0 {o->init("portamento.receive");}
+ class Fl_Osc_Check
}
Fl_Dial {} {
label time
- callback {part->ctl.portamento.time=(int) o->value();}
tooltip {Portamento time} xywh {285 60 25 25} labelsize 10 maximum 127 step 1
- code0 {o->value(part->ctl.portamento.time);}
- class WidgetPDial
+ code0 {o->init("portamento.time");}
+ class Fl_Osc_Dial
}
Fl_Counter {} {
label thresh
- callback {part->ctl.portamento.pitchthresh=(int) o->value();}
tooltip {Minimum or max. difference of the notes in order to do the portamento (x 100 cents)} xywh {340 20 50 20} type Simple labelsize 10 minimum 0 maximum 127 step 1
- code0 {o->value(part->ctl.portamento.pitchthresh);}
+ code0 {o->init("portamento.pitchthresh");}
+ class Fl_Osc_Counter
}
Fl_Check_Button {} {
label {th.type}
- callback {part->ctl.portamento.pitchthreshtype=(int) o->value();}
tooltip {Threshold type (min/max)} xywh {365 70 15 15} down_box DOWN_BOX labelsize 10 align 2
- code0 {o->value(part->ctl.portamento.pitchthreshtype);}
+ code0 {o->init("portamento.pitchthreshtype");}
+ class Fl_Osc_Check
}
Fl_Box {} {
label {x100 cnt.}
@@ -569,83 +528,82 @@ if (part->ctl.sustain.receive==0) {
}
Fl_Dial {} {
label {t.dn/up}
- callback {int x=(int) o->value();
-
-part->ctl.portamento.updowntimestretch=x;}
tooltip {Portamento time stretch (up/down)} xywh {315 60 25 25} labelsize 10 maximum 127 step 1
- code0 {o->value(part->ctl.portamento.updowntimestretch);}
- class WidgetPDial
+ code0 {o->init("portamento.updowntimestretch");}
+ class Fl_Osc_Dial
}
Fl_Dial propta {
label {Prp.Rate}
- callback {part->ctl.portamento.propRate=(int) o->value();}
tooltip {Distance required to double change from nonpropotinal portamento time} xywh {405 20 25 25} labelsize 9 maximum 127 step 1
- code0 {o->value(part->ctl.portamento.propRate);}
- class WidgetPDial
+ code0 {o->init("portamento.propRate");}
+ class Fl_Osc_Dial
}
Fl_Dial proptb {
label {Prp.Dpth}
- callback {part->ctl.portamento.propDepth=(int) o->value();}
tooltip {The difference from nonproportinal portamento} xywh {405 60 25 25} labelsize 9 maximum 127 step 1
- code0 {o->value(part->ctl.portamento.propDepth);}
- class WidgetPDial
+ code0 {o->init("portamento.propDepth");}
+ class Fl_Osc_Dial
}
Fl_Check_Button {} {
label {Proprt.}
- callback {part->ctl.portamento.proportional=(int) o->value();
-if(o->value()){propta->activate();proptb->activate();}
+ callback {if(o->value()){propta->activate();proptb->activate();}
else {propta->deactivate();proptb->deactivate();}}
tooltip {Enable Proportinal Portamento (over fixed Portamento)} xywh {285 40 50 15} box THIN_UP_BOX down_box DOWN_BOX labelsize 9
- code0 {o->value(part->ctl.portamento.proportional);}
- code1 {if(o->value()){propta->activate();proptb->activate();}}
- code2 {else {propta->deactivate();proptb->deactivate();}}
+ code0 {o->init("portamento.proportional");}
+ class Fl_Osc_Check
}
}
Fl_Group {} {
label Resonance
xywh {445 15 50 90} box UP_FRAME labelsize 10
+ class Fl_Osc_Group
} {
Fl_Dial {} {
label BWdpth
- callback {part->ctl.resonancebandwidth.depth=(int) o->value();}
tooltip {BandWidth controller depth} xywh {455 60 25 25} labelsize 10 maximum 127 step 1
- code0 {o->value(part->ctl.resonancebandwidth.depth);}
- class WidgetPDial
+ code0 {o->init("resonancebandwidth.depth");}
+ class Fl_Osc_Dial
}
Fl_Dial {} {
label CFdpth
- callback {part->ctl.resonancecenter.depth=(int) o->value();}
tooltip {Center Frequency controller Depth} xywh {455 20 25 25} labelsize 10 maximum 127 step 1
- code0 {o->value(part->ctl.resonancecenter.depth);}
- class WidgetPDial
+ code0 {o->init("resonancecenter.depth");}
+ class Fl_Osc_Dial
}
}
Fl_Check_Button {} {
label {Exp MWh}
- callback {part->ctl.modwheel.exponential=(int) o->value();}
tooltip {Exponential modulation wheel} xywh {10 15 40 25} down_box DOWN_BOX labelsize 10 align 148
- code0 {o->value(part->ctl.modwheel.exponential);}
+ code0 {o->init("modwheel.exponential");}
+ class Fl_Osc_Check
}
Fl_Check_Button {} {
label {Exp BW}
- callback {part->ctl.bandwidth.exponential=(int) o->value();}
tooltip {Exponential BandWidth Controller} xywh {85 15 35 25} down_box DOWN_BOX labelsize 10 align 148
- code0 {o->value(part->ctl.bandwidth.exponential);}
+ code0 {o->init("bandwidth.exponential");}
+ class Fl_Osc_Check
}
}
Fl_Window partfx {
- label {Part's Insert Effects} selected
- private xywh {554 660 390 145} type Double box NO_BOX visible
+ label {Part's Insert Effects}
+ private xywh {569 775 390 145} type Double box NO_BOX
+ class Fl_Osc_Window visible
} {
+ Fl_Box {} {
+ xywh {0 0 0 0}
+ code0 {partfx->osc = osc;}
+ code1 {partfx->base = part_path;}
+ }
Fl_Counter inseffnocounter {
label {FX No.}
callback {ninseff=(int) o->value()-1;
-insefftype->value(part->partefx[ninseff]->geteffect());
+ insefftype->oscMove("partefx"+to_s(ninseff)+"/efftype");
+ inseffectuigroup->reext("partefx"+to_s(ninseff)+"/");
+/*insefftype->value(part->partefx[ninseff]->geteffect());*/
//insefftype->do_callback();
-inseffectui->refresh(part->partefx[ninseff]);
-int x=part->Pefxroute[ninseff];
+inseffectui->refresh();
+int x=127;/*part->Pefxroute[ninseff];*/
if (x==127) x=1;
-bypasseff->value(part->Pefxbypass[ninseff]);
sendtochoice->value(x);}
xywh {5 110 80 20} type Simple labelfont 1 align 6 minimum 1 maximum 127 step 1 textfont 1
@@ -654,12 +612,11 @@ sendtochoice->value(x);}
}
Fl_Choice insefftype {
label EffType
- callback {pthread_mutex_lock(part->mutex);
-part->partefx[ninseff]->changeeffect((int) o->value());
-pthread_mutex_unlock(part->mutex);
-inseffectui->refresh(part->partefx[ninseff]);}
+ callback {inseffectui->efftype = o->value();
+inseffectui->refresh();}
xywh {155 110 70 15} down_box BORDER_BOX labelsize 10 align 6
- code0 {o->value(part->partefx[ninseff]->geteffect());}
+ code0 {o->init(("partefx"+to_s(ninseff)+"/efftype").c_str());}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label {No Effect}
@@ -700,10 +657,15 @@ inseffectui->refresh(part->partefx[ninseff]);}
}
Fl_Group inseffectuigroup {
xywh {5 5 380 100} box FLAT_BOX color 48
+ class Fl_Osc_Group
} {
+ Fl_Box {} {
+ xywh {0 0 0 0}
+ code0 {inseffectuigroup->ext = "partefx0/";}
+ }
Fl_Group inseffectui {
xywh {5 5 380 95}
- code0 {o->init(part->partefx[ninseff]);}
+ code0 {o->init(true);}
class EffUI
} {}
}
@@ -714,13 +676,14 @@ inseffectui->refresh(part->partefx[ninseff]);}
}
Fl_Choice sendtochoice {
label {Send To.}
- callback {int x=(int) o->value();
+ callback {/*int x=(int) o->value();
part->Pefxroute[ninseff]=x;
if (x==2) part->partefx[ninseff]->setdryonly(true);
- else part->partefx[ninseff]->setdryonly(false);}
+ else part->partefx[ninseff]->setdryonly(false);*/}
xywh {235 110 80 15} down_box BORDER_BOX labelsize 10 align 6
- code0 {int x=part->Pefxroute[ninseff]; if (x==127) x=1;}
- code1 {o->value(x);}
+ code0 {/*int x=part->Pefxroute[ninseff]; if (x==127) x=1;*/}
+ code1 {o->init(("Pefxroute"+to_s(ninseff)).c_str());}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label {Next Effect}
@@ -737,27 +700,31 @@ if (x==2) part->partefx[ninseff]->setdryonly(true);
}
Fl_Check_Button bypasseff {
label bypass
- callback {part->Pefxbypass[ninseff]=(((int)o->value())!=0);}
tooltip {if the effect is not used (is bypassed)} xywh {90 110 60 15} down_box DOWN_BOX labelsize 11
- code0 {int x=part->Pefxbypass[ninseff];o->value(x);}
+ code0 {o->init("Pefxbypass"+to_s(ninseff));}
+ class Fl_Osc_Check
}
Fl_Button {} {
label C
- callback {presetsui->copy(part->partefx[ninseff]);}
+ callback {/*presetsui->copy(part->partefx[ninseff]);*/}
xywh {90 127 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
}
Fl_Button {} {
label P
- callback {pthread_mutex_lock(&master->mutex);
-presetsui->paste(part->partefx[ninseff],inseffectui);
-pthread_mutex_unlock(&master->mutex);}
+ callback {/*presetsui->paste(part->partefx[ninseff],inseffectui);*/}
xywh {120 127 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
}
}
Fl_Window instrumentkitlist {
- label {Instrument Kit} open
- xywh {586 566 670 370} type Double box NO_BOX visible
+ label {Instrument Kit}
+ xywh {601 611 670 370} type Double box NO_BOX
+ class Fl_Osc_Window visible
} {
+ Fl_Box {} {
+ xywh {0 0 0 0}
+ code0 {instrumentkitlist->osc = osc;}
+ code1 {instrumentkitlist->base = "/part"+to_s(npart)+"/";}
+ }
Fl_Button {} {
label {Close Window}
callback {instrumentkitlist->hide();}
@@ -765,11 +732,10 @@ pthread_mutex_unlock(&master->mutex);}
}
Fl_Scroll kitlist {open
xywh {0 15 670 330} type VERTICAL box UP_FRAME
- code0 {if (part->Pkitmode==0) o->deactivate();}
} {
Fl_Pack {} {
xywh {0 20 670 320}
- code0 {for (int i=0;i<NUM_KIT_ITEMS;i++){partkititem[i]=new PartKitItem(0,0,670,20,"");partkititem[i]->init(part,i,master,this);}}
+ code0 {for (int i=0;i<NUM_KIT_ITEMS;i++){partkititem[i]=new PartKitItem(0,0,670,20);partkititem[i]->init(i,this);}}
} {}
}
Fl_Box {} {
@@ -798,14 +764,10 @@ pthread_mutex_unlock(&master->mutex);}
}
Fl_Choice {} {
label Mode
- callback {part->Pkitmode=(int) o->value();
-if (part->Pkitmode==0) {
- kitlist->deactivate();
- } else {
- kitlist->activate();
-};}
+ callback {if (o->value()==0) { kitlist->deactivate(); } else { kitlist->activate(); };}
xywh {35 350 70 15} down_box BORDER_BOX labelsize 11 textfont 1 textsize 11
- code0 {o->value(part->Pkitmode);}
+ code0 {o->init("Pkitmode");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label OFF
@@ -822,9 +784,9 @@ if (part->Pkitmode==0) {
}
Fl_Check_Button {} {
label {Drum mode}
- callback {part->Pdrummode=(int) o->value();}
xywh {285 350 70 15} down_box DOWN_BOX labelsize 10
- code0 {o->value(part->Pdrummode);}
+ code0 {o->init("Pdrummode");}
+ class Fl_Osc_Check
}
Fl_Box {} {
label {FX.r.}
@@ -837,11 +799,22 @@ if (part->Pkitmode==0) {
}
Fl_Window instrumenteditwindow {
label {Instrument Edit} open
- xywh {247 621 395 360} type Double box NO_BOX visible
+ xywh {262 621 395 360} type Double box NO_BOX
+ class Fl_Osc_Window visible
} {
- Fl_Group {} {
+ Fl_Box {} {
+ xywh {0 0 0 0}
+ code0 {instrumenteditwindow->osc = osc;}
+ code1 {instrumenteditwindow->base = "/part"+to_s(npart)+"/";}
+ }
+ Fl_Group editgroup {
xywh {0 220 395 110} box UP_FRAME
+ class Fl_Osc_Group
} {
+ Fl_Box {} {
+ xywh {0 0 0 0}
+ code0 {editgroup->ext = "kit0/";}
+ }
Fl_Group {} {
label PADsynth
xywh {205 245 100 80} box ENGRAVED_FRAME labelfont 1
@@ -850,16 +823,14 @@ if (part->Pkitmode==0) {
label Edit
callback {showparameters(0,2);}
xywh {215 280 80 35} color 51 selection_color 51 labelfont 1 labelsize 13 align 128
- code0 {if (part->kit[0].Ppadenabled==0) o->deactivate();}
}
Fl_Check_Button padsynenabledcheck {
label Enabled
- callback {int x=(int) o->value();
-part->kit[0].Ppadenabled=x;
-if (x==0) padeditbutton->deactivate();
- else padeditbutton->activate();}
+ callback {if (o->value()==0) padeditbutton->deactivate();
+ else padeditbutton->activate();}
tooltip {enable/disable PADsynth} xywh {215 255 80 20} box UP_BOX down_box DOWN_BOX color 51 selection_color 0 labelfont 1 labelsize 11
- code1 {o->value(part->kit[0].Ppadenabled);}
+ code1 {o->init("Ppadenabled");}
+ class Fl_Osc_Check
}
}
Fl_Group {} {
@@ -868,18 +839,16 @@ if (x==0) padeditbutton->deactivate();
} {
Fl_Check_Button adsynenabledcheck {
label Enabled
- callback {int x=(int) o->value();
-part->kit[0].Padenabled=x;
-if (x==0) adeditbutton->deactivate();
+ callback {if (o->value()==0) adeditbutton->deactivate();
else adeditbutton->activate();}
tooltip {enable/disable ADsynth} xywh {15 255 80 20} box UP_BOX down_box DOWN_BOX color 51 selection_color 0 labelfont 1 labelsize 11
- code1 {o->value(part->kit[0].Padenabled);}
+ code1 {o->init("Padenabled");}
+ class Fl_Osc_Check
}
Fl_Button adeditbutton {
label Edit
callback {showparameters(0,0);}
xywh {15 281 80 34} color 51 selection_color 51 labelfont 1 labelsize 13 align 128
- code0 {if (part->kit[0].Padenabled==0) o->deactivate();}
}
}
Fl_Group {} {
@@ -888,18 +857,16 @@ if (x==0) adeditbutton->deactivate();
} {
Fl_Check_Button subsynenabledcheck {
label Enabled
- callback {int x=(int) o->value();
-part->kit[0].Psubenabled=x;
-if (x==0) subeditbutton->deactivate();
+ callback {if (o->value()==0) subeditbutton->deactivate();
else subeditbutton->activate();}
tooltip {enable/disable SUBsynth} xywh {115 255 80 20} box UP_BOX down_box DOWN_BOX color 51 selection_color 0 labelfont 1 labelsize 11
- code1 {o->value(part->kit[0].Psubenabled);}
+ code1 {o->init("Psubenabled");}
+ class Fl_Osc_Check
}
Fl_Button subeditbutton {
label Edit
callback {showparameters(0,1);}
xywh {115 280 80 35} color 51 selection_color 51 labelfont 1 labelsize 13 align 128
- code0 {if (part->kit[0].Psubenabled==0) o->deactivate();}
}
}
Fl_Button {} {
@@ -918,23 +885,23 @@ if (x==0) subeditbutton->deactivate();
} {
Fl_Input {} {
label {Author and Copyright}
- callback {snprintf((char *)part->info.Pauthor,MAX_INFO_TEXT_SIZE,"%s",o->value());}
xywh {5 60 385 50} type Multiline color 124 labelsize 10 align 5
code0 {o->maximum_size(MAX_INFO_TEXT_SIZE);}
- code1 {o->value((char *) &part->info.Pauthor);}
+ code1 {o->init("info.Pauthor");}
+ class Fl_Osc_Input
}
Fl_Input {} {
label Comments
- callback {snprintf((char *)part->info.Pcomments,MAX_INFO_TEXT_SIZE,"%s",o->value());}
xywh {5 125 385 90} type Multiline color 124 labelsize 11 align 5
code0 {o->maximum_size(MAX_INFO_TEXT_SIZE);}
- code1 {o->value((char *) &part->info.Pcomments);}
+ code1 {o->init("info.Pcomments");}
+ class Fl_Osc_Input
}
Fl_Choice {} {
label {Type:}
- callback {part->info.Ptype=o->value();}
xywh {5 25 155 20} down_box BORDER_BOX labelfont 1 labelsize 11 align 5 textsize 10
- code0 {o->value(part->info.Ptype);}
+ code0 {o->init("info.Ptype");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label {--------------------------}
@@ -1013,19 +980,26 @@ if (x==0) subeditbutton->deactivate();
}
}
}
- Function {PartUI(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
- code {part=NULL;
-adnoteui=NULL;
+ Function {PartUI(int x,int y, int w, int h, const char *label=0):Fl_Osc_Group(x,y,w,h,label)} {open
+ } {
+ code {adnoteui=NULL;
subnoteui=NULL;
padnoteui=NULL;
lastkititem=-1;} {}
}
- Function {init(Part *part_,Master *master_,int npart_,BankUI *bankui_)} {} {
- code {bankui=bankui_;
-part=part_;
+ Function {init(std::string part_path_, int npart_,BankUI *bankui_, std::string loc_, Fl_Osc_Interface *osc_)} {open
+ } {
+ code {assert(osc_);
+assert(!loc_.empty());
+
+bankui=bankui_;
+part_path = part_path_;
+base = part_path;
+osc = osc;
npart=npart_;
-master=master_;
ninseff=0;
+osc=osc_;
+loc=loc_;
make_window();
\#ifdef NTK_GUI
@@ -1050,7 +1024,7 @@ while (klimits[k]!=0){
sprintf(tmp,"%d",klimits[k]);
keylimitlist->add(tmp);
if (val==-1){
- if (klimits[k]>part->Pkeylimit) val=k;
+ /*if (klimits[k]>part->Pkeylimit) val=k;*/
};
k++;
};
@@ -1058,43 +1032,47 @@ while (klimits[k]!=0){
if (val==-1) val=k;
keylimitlist->value(val);} {}
}
- Function {showparameters(int kititem,int engine)} {} {
- code {if (engine==-1){//this is used if I want to clear the engine from the part
- if (kititem==lastkititem) kititem=-1;
- else kititem=lastkititem;
-};
+ Function {showparameters(int kititem,int engine)} {open
+ } {
+ code {
+if (engine==-1){//this is used if I want to clear the engine from the part
+ //if (kititem==lastkititem) kititem=-1;
+ //else kititem=lastkititem;
+ delete adnoteui;
+ delete subnoteui;
+ delete padnoteui;
+ adnoteui=NULL;subnoteui=NULL;padnoteui=NULL;
+ return;
+}
if (kititem!=lastkititem){
- if (adnoteui!=NULL) delete (adnoteui);
- if (subnoteui!=NULL) delete (subnoteui);
- if (padnoteui!=NULL) delete (padnoteui);
+ delete adnoteui;
+ delete subnoteui;
+ delete padnoteui;
adnoteui=NULL;subnoteui=NULL;padnoteui=NULL;
lastkititem=kititem;
- if (kititem>=NUM_KIT_ITEMS) return;//bad kit item
- if (kititem<0) return;
+ if(kititem>=NUM_KIT_ITEMS) return;//bad kit item
+ if(kititem<0) return;
+}
- if (part->kit[kititem].adpars!=NULL)
- adnoteui=new ADnoteUI(part->kit[kititem].adpars,master);
+if(!adnoteui && adsynenabledcheck->value())
+ adnoteui=new ADnoteUI(loc+"kit"+to_s(kititem)+"/adpars/", osc);
- if (part->kit[kititem].subpars!=NULL)
- subnoteui=new SUBnoteUI(part->kit[kititem].subpars);
+if(!subnoteui && subsynenabledcheck->value())
+ subnoteui=new SUBnoteUI(osc, loc+"kit"+to_s(kititem)+"/subpars/");
- if (part->kit[kititem].padpars!=NULL)
- padnoteui=new PADnoteUI(part->kit[kititem].padpars,master);
+if(!padnoteui && padsynenabledcheck->value())
+ padnoteui=new PADnoteUI(loc+"kit"+to_s(kititem)+"/padpars/", osc);
-};
-
-
-
-if ((engine==0)&&(adnoteui!=NULL)) adnoteui->ADnoteGlobalParameters->show();
-if ((engine==1)&&(subnoteui!=NULL)) subnoteui->SUBparameters->show();
-if ((engine==2)&&(adnoteui!=NULL)) padnoteui->padnotewindow->show();} {}
+if (engine==0&&adnoteui) adnoteui->ADnoteGlobalParameters->show();
+if (engine==1&&subnoteui) subnoteui->SUBparameters->show();
+if (engine==2&&padnoteui) padnoteui->padnotewindow->show();} {}
}
Function {~PartUI()} {} {
- code {if (adnoteui!=NULL) delete (adnoteui);
-if (subnoteui!=NULL) delete (subnoteui);
-if (padnoteui!=NULL) delete (padnoteui);
+ code {delete adnoteui;
+delete subnoteui;
+delete padnoteui;
partgroup->hide();
//delete(partgroup);
@@ -1111,15 +1089,41 @@ delete(instrumentkitlist);
instrumenteditwindow->hide();
delete(instrumenteditwindow);} {}
}
- decl {Part *part;} {}
- decl {Master *master;} {}
- decl {BankUI *bankui;} {}
- decl {ADnoteUI *adnoteui;} {}
- decl {SUBnoteUI *subnoteui;} {}
- decl {PADnoteUI *padnoteui;} {}
- decl {PartSysEffSend *psyef[NUM_SYS_EFX];} {}
- decl {int npart;} {}
- decl {int ninseff;} {}
- decl {int lastkititem;} {}
- decl {PartKitItem *partkititem[NUM_KIT_ITEMS];} {}
+ decl {BankUI *bankui;} {private local
+ }
+ decl {ADnoteUI *adnoteui;} {private local
+ }
+ decl {SUBnoteUI *subnoteui;} {private local
+ }
+ decl {PADnoteUI *padnoteui;} {private local
+ }
+ decl {PartSysEffSend *psyef[NUM_SYS_EFX];} {private local
+ }
+ decl {int npart;} {private local
+ }
+ decl {int ninseff;} {private local
+ }
+ decl {int lastkititem;} {private local
+ }
+ decl {PartKitItem *partkititem[NUM_KIT_ITEMS];} {private local
+ }
+ decl {std::string part_path;} {private local
+ }
+ decl {std::string loc;} {private local
+ }
+ decl {Fl_Osc_Interface *osc;} {private local
+ }
+ Function {rebase(std::string new_loc)} {open
+ } {
+ code {
+ loc = new_loc;
+ partgroupui->rebase(new_loc);
+ctlwindow->rebase(new_loc+"ctl/");
+partfx->rebase(new_loc);
+instrumentkitlist->rebase(new_loc);
+instrumenteditwindow->rebase(new_loc);
+partenablebutton->rebase(new_loc);
+} {selected
+ }
+ }
}
diff --git a/src/UI/ResonanceUI.fl b/src/UI/ResonanceUI.fl
@@ -1,219 +1,78 @@
# data file for the Fltk User Interface Designer (fluid)
-version 1.0110
+version 1.0302
header_name {.h}
code_name {.cc}
-decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {}
-
-decl {//License: GNU GPL version 2 or later} {}
-
-decl {\#include <FL/Fl_Box.H>} {public
+decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {private local
}
-decl {\#include <FL/fl_draw.H>} {public
+decl {//License: GNU GPL version 2 or later} {private local
}
-decl {\#include <FL/Fl_Value_Output.H>} {public
+decl {\#include <FL/Fl_Box.H>} {public local
}
-decl {\#include <math.h>} {}
-
-decl {\#include <stdio.h>} {}
-
-decl {\#include <stdlib.h>} {}
-
-decl {\#include <string.h>} {}
-
-decl {\#include "../Synth/Resonance.h"} {public
+decl {\#include <FL/fl_draw.H>} {public local
}
-decl {\#include "WidgetPDial.h"} {public
+decl {\#include <FL/Fl_Value_Output.H>} {public local
}
-decl {\#include "PresetsUI.h"} {public
+decl {\#include <math.h>} {private local
}
-class ResonanceGraph {open : {public Fl_Box}
-} {
- Function {ResonanceGraph(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} {
- code {respar=NULL;
-cbwidget=NULL;
-applybutton=NULL;} {}
- }
- Function {init(Resonance *respar_,Fl_Value_Output *khzvalue_,Fl_Value_Output *dbvalue_)} {} {
- code {respar=respar_;
-khzvalue=khzvalue_;
-dbvalue=dbvalue_;
-oldx=-1;
-khzval=-1;} {}
- }
- Function {draw_freq_line(float freq,int type)} {open
- } {
- code {float freqx=respar->getfreqpos(freq);
-switch(type){
- case 0:fl_line_style(FL_SOLID);break;
- case 1:fl_line_style(FL_DOT);break;
- case 2:fl_line_style(FL_DASH);break;
-};
-
-
-if ((freqx>0.0)&&(freqx<1.0))
- fl_line(x()+(int) (freqx*w()),y(),
- x()+(int) (freqx*w()),y()+h());} {}
- }
- Function {draw()} {open
- } {
- code {int ox=x(),oy=y(),lx=w(),ly=h(),i,ix,iy,oiy;
-float freqx;
-
-fl_color(FL_DARK1);
-fl_rectf(ox,oy,lx,ly);
-
-
-//draw the lines
-fl_color(FL_GRAY);
-
-fl_line_style(FL_SOLID);
-fl_line(ox+2,oy+ly/2,ox+lx-2,oy+ly/2);
-
-freqx=respar->getfreqpos(1000.0);
-if ((freqx>0.0)&&(freqx<1.0))
- fl_line(ox+(int) (freqx*lx),oy,
- ox+(int) (freqx*lx),oy+ly);
-
-for (i=1;i<10;i++){
- if(i==1){
- draw_freq_line(i*100.0,0);
- draw_freq_line(i*1000.0,0);
- }else
- if (i==5){
- draw_freq_line(i*100.0,2);
- draw_freq_line(i*1000.0,2);
- }else{
- draw_freq_line(i*100.0,1);
- draw_freq_line(i*1000.0,1);
- };
-};
-
-draw_freq_line(10000.0,0);
-draw_freq_line(20000.0,1);
+decl {\#include <stdio.h>} {private local
+}
-fl_line_style(FL_DOT);
-int GY=10;if (ly<GY*3) GY=-1;
-for (i=1;i<GY;i++){
- int tmp=(int)(ly/(float)GY*i);
- fl_line(ox+2,oy+tmp,ox+lx-2,oy+tmp);
-};
+decl {\#include <stdlib.h>} {private local
+}
+decl {\#include <string.h>} {private local
+}
+decl {\#include "Fl_Osc_Dial.H"} {public local
+}
-//draw the data
-fl_color(FL_RED);
-fl_line_style(FL_SOLID,2);
-fl_begin_line();
-oiy=(int)(respar->Prespoints[0]/128.0*ly);
-for (i=1;i<N_RES_POINTS;i++){
- ix=(int)(i*1.0/N_RES_POINTS*lx);
- iy=(respar->Prespoints[i]/128.0*ly);
- fl_vertex(ox+ix,oy+ly-oiy);
- oiy=iy;
-};
-fl_end_line();
-fl_line_style(FL_SOLID,0);} {selected
- }
- }
- Function {handle(int event)} {return_type int
- } {
- code {int x_=Fl::event_x()-x();
-int y_=Fl::event_y()-y();
-if ( (x_>=0)&&(x_<w()) && (y_>=0)&&(y_<h())){
- khzvalue->value(respar->getfreqx(x_*1.0/w())/1000.0);
- dbvalue->value((1.0-y_*2.0/h())*respar->PmaxdB);
-};
+decl {\#include "Fl_Osc_Pane.H"} {selected public local
+}
-if ((event==FL_PUSH)||(event==FL_DRAG)){
- int leftbutton=1;
- if (Fl::event_button()==FL_RIGHT_MOUSE) leftbutton=0;
- if (x_<0) x_=0;if (y_<0) y_=0;
- if (x_>=w()) x_=w();if (y_>=h()-1) y_=h()-1;
+decl {\#include "Fl_Osc_Button.H"} {public local
+}
- if ((oldx<0)||(oldx==x_)){
- int sn=(int)(x_*1.0/w()*N_RES_POINTS);
- int sp=127-(int)(y_*1.0/h()*127);
- if (leftbutton!=0) respar->setpoint(sn,sp);
- else respar->setpoint(sn,64);
- } else {
- int x1=oldx;
- int x2=x_;
- int y1=oldy;
- int y2=y_;
- if (oldx>x_){
- x1=x_;y1=y_;
- x2=oldx;y2=oldy;
- };
- for (int i=0;i<x2-x1;i++){
- int sn=(int)((i+x1)*1.0/w()*N_RES_POINTS);
- float yy=(y2-y1)*1.0/(x2-x1)*i;
- int sp=127-(int)((y1+yy)/h()*127);
- if (leftbutton!=0) respar->setpoint(sn,sp);
- else respar->setpoint(sn,64);
- };
- };
+decl {\#include "Fl_Osc_Check.H"} {public local
+}
- oldx=x_;oldy=y_;
- redraw();
-};
+decl {\#include "Fl_Osc_Roller.H"} {public local
+}
-if (event==FL_RELEASE) {
- oldx=-1;
- if (cbwidget!=NULL) {
- cbwidget->do_callback();
- if (applybutton!=NULL) {
- applybutton->color(FL_RED);
- applybutton->redraw();
+decl {\#include "Fl_Osc_Output.H"} {public local
+}
- };
- };
-};
+decl {\#include "Fl_Resonance_Graph.H"} {public local
+}
-return(1);} {}
- }
- Function {setcbwidget(Fl_Widget *cbwidget,Fl_Widget *applybutton)} {} {
- code {this->cbwidget=cbwidget;
-this->applybutton=applybutton;} {}
- }
- decl {Fl_Value_Output *khzvalue;} {}
- decl {Fl_Value_Output *dbvalue;} {}
- decl {Resonance *respar;} {}
- decl {int oldx,oldy;} {}
- decl {float khzval;} {public
- }
- decl {Fl_Widget *cbwidget,*applybutton;} {}
+decl {\#include "PresetsUI.h"} {public local
}
class ResonanceUI {open : PresetsUI_
} {
- Function {make_window()} {open
+ Function {make_window(Fl_Osc_Interface *osc, std::string loc)} {open
} {
Fl_Window resonancewindow {
label Resonance open
- xywh {120 70 780 305} type Double hide
+ xywh {123 93 780 305} type Double
+ class Fl_Osc_Window visible
} {
Fl_Value_Output khzvalue {
label kHz
xywh {415 264 45 18} labelsize 12 align 8 minimum 0.001 maximum 48 step 0.01 textfont 1 textsize 12
code0 {//this widget must be before the calling widgets}
+ code1 {resonancewindow->init(osc,loc);}
}
Fl_Value_Output dbvalue {
label dB
xywh {415 282 45 18} labelsize 12 align 8 minimum -150 maximum 150 step 0.1 textfont 1 textsize 12
code0 {//this widget must be before the calling widgets}
}
- Fl_Group {} {
- xywh {6 5 768 256} box BORDER_BOX
- code0 {rg=new ResonanceGraph(o->x(),o->y(),o->w(),o->h(),"");}
- code1 {rg->init(respar,khzvalue,dbvalue);}
- code2 {rg->show();}
- } {}
Fl_Button {} {
label Close
callback {resonancewindow->hide();}
@@ -221,37 +80,35 @@ class ResonanceUI {open : PresetsUI_
}
Fl_Button {} {
label Zero
- callback {for (int i=0;i<N_RES_POINTS;i++)
- respar->setpoint(i,64);
-resonancewindow->redraw();
-redrawPADnoteApply();}
+ callback {
+ o->oscWrite("zero");
+ redrawPADnoteApply();}
tooltip {Clear the resonance function} xywh {491 264 66 15} box THIN_UP_BOX labelfont 1 labelsize 12
+ class Fl_Osc_Button
}
Fl_Button {} {
label Smooth
- callback {respar->smooth();
-resonancewindow->redraw();
+ callback {o->oscWrite("smooth");
redrawPADnoteApply();}
tooltip {Smooth the resonance function} xywh {491 282 66 18} box THIN_UP_BOX labelfont 1 labelsize 12
+ class Fl_Osc_Button
}
Fl_Check_Button enabled {
label Enable
- callback {respar->Penabled=(int) o->value();
-redrawPADnoteApply();}
xywh {6 270 78 27} box THIN_UP_BOX down_box DOWN_BOX
- code0 {o->value(respar->Penabled);}
+ code0 {o->init("Penabled");}
+ class Fl_Osc_Check
}
Fl_Roller maxdb {
callback {maxdbvo->value(o->value());
-respar->PmaxdB=(int) 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
}
Fl_Value_Output maxdbvo {
label {Max.}
- callback {o->value(respar->PmaxdB);}
tooltip {The Maximum amplitude (dB)} xywh {126 264 24 18} labelsize 12 minimum 1 maximum 127 step 1 value 30 textfont 1 textsize 12
- code0 {o->value(respar->PmaxdB);}
}
Fl_Box {} {
label dB
@@ -259,82 +116,79 @@ redrawPADnoteApply();}
}
Fl_Value_Output centerfreqvo {
label {C.f.}
- callback {o->value(respar->getcenterfreq()/1000.0);}
+ callback {o->value(o->newvalue()/1000.0);}
tooltip {Center Frequency (kHz)} xywh {210 264 33 18} labelsize 12 when 3 minimum 1 maximum 10 step 0.01 value 1 textfont 1 textsize 12
- code0 {o->value(respar->getcenterfreq()/1000.0);}
+ code0 {o->init("centerfreq");}
+ class Fl_Osc_Output
}
Fl_Value_Output octavesfreqvo {
label {Oct.}
- callback {o->value(respar->getoctavesfreq());}
+ callback {o->value(o->newvalue());}
tooltip {No. of octaves} xywh {210 282 33 18} labelsize 12 when 3 minimum 1 maximum 127 step 1 value 30 textfont 1 textsize 12
- code0 {o->value(respar->getoctavesfreq());}
+ code0 {o->init("octavesfreq");}
+ class Fl_Osc_Output
}
Fl_Button {} {
label RND2
- callback {respar->randomize(1);
-resonancewindow->redraw();
+ callback {o->oscWrite("randomize", "i", 1);
redrawPADnoteApply();}
tooltip {Randomize the resonance function} xywh {566 276 42 12} box THIN_UP_BOX labelfont 1 labelsize 10
+ class Fl_Osc_Button
}
Fl_Button {} {
label RND1
- callback {respar->randomize(0);
-resonancewindow->redraw();
+ callback {o->oscWrite("randomize", "i", 0);
redrawPADnoteApply();}
tooltip {Randomize the resonance function} xywh {566 264 42 12} box THIN_UP_BOX labelfont 1 labelsize 10
+ class Fl_Osc_Button
}
Fl_Button {} {
label RND3
- callback {respar->randomize(2);
-resonancewindow->redraw();
+ callback {o->oscWrite("randomize", "i", 2);
redrawPADnoteApply();}
tooltip {Randomize the resonance function} xywh {566 288 42 12} box THIN_UP_BOX labelfont 1 labelsize 10
+ class Fl_Osc_Button
}
Fl_Check_Button p1st {
label {P.1st}
- callback {respar->Pprotectthefundamental=(int) o->value();
-redrawPADnoteApply();}
tooltip {Protect the fundamental frequency (do not damp the first harmonic)} xywh {365 285 45 15} down_box DOWN_BOX labelsize 10
- code0 {o->value(respar->Pprotectthefundamental);}
+ code0 {o->init("Pprotectthefundamental");}
+ class Fl_Osc_Check
}
Fl_Button {} {
label InterpP
callback {int type;
-if (Fl::event_button()==FL_LEFT_MOUSE) type=0;
+ if (Fl::event_button()==FL_LEFT_MOUSE) type=0;
else type=1;
-respar->interpolatepeaks(type);
-resonancewindow->redraw();
-redrawPADnoteApply();}
+ o->oscWrite("interpolatepeaks", "i", type);
+ redrawPADnoteApply();}
tooltip {Interpolate the peaks} xywh {365 265 46 15} box THIN_UP_BOX labelfont 1 labelsize 10
+ class Fl_Osc_Button
}
Fl_Dial centerfreq {
label {C.f.}
- callback {respar->Pcenterfreq=(int)o->value();
-centerfreqvo->do_callback();
-rg->redraw();
+ callback {centerfreqvo->do_callback();
redrawPADnoteApply();}
xywh {245 265 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(respar->Pcenterfreq);}
- class WidgetPDial
+ code0 {o->init("Pcenterfreq");}
+ class Fl_Osc_Dial
}
Fl_Dial octavesfreq {
label {Oct.}
- callback {respar->Poctavesfreq=(int)o->value();
-octavesfreqvo->do_callback();
-rg->redraw();
+ callback {octavesfreqvo->do_callback();
redrawPADnoteApply();}
xywh {280 265 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(respar->Poctavesfreq);}
- class WidgetPDial
+ code0 {o->init("Poctavesfreq");}
+ class Fl_Osc_Dial
}
Fl_Button {} {
label C
- callback {presetsui->copy(respar);}
+ callback {/*presetsui->copy(respar);*/}
xywh {625 275 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
}
Fl_Button {} {
label P
- callback {presetsui->paste(respar,this);}
+ callback {/*presetsui->paste(respar,this);*/}
xywh {655 275 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
}
Fl_Button applybutton {
@@ -348,20 +202,31 @@ if (cbapplywidget!=NULL) {
};}
xywh {690 265 85 15} box THIN_UP_BOX labelfont 1 labelsize 11
}
+ Fl_Box rg {
+ xywh {6 5 768 256} box BORDER_BOX
+ class Fl_Resonance_Graph
+ }
}
}
- Function {ResonanceUI(Resonance *respar_)} {} {
- code {respar=respar_;
+ Function {ResonanceUI(Fl_Osc_Interface *osc, std::string loc)} {open
+ } {
+ code {
+assert(osc);
cbwidget=NULL;
cbapplywidget=NULL;
-make_window();
+make_window(osc, loc);
+rg->init(khzvalue,dbvalue);
applybutton->hide();} {}
}
Function {~ResonanceUI()} {} {
- code {resonancewindow->hide();} {}
+ code {resonancewindow->hide();
+ delete resonancewindow;
+ } {}
}
Function {redrawPADnoteApply()} {} {
- code {if (cbwidget!=NULL) {
+ code {
+ rg->update();
+ if (cbwidget!=NULL) {
cbwidget->do_callback();
applybutton->color(FL_RED);
applybutton->redraw();
@@ -375,24 +240,22 @@ applybutton->show();} {}
}
Function {refresh()} {} {
code {redrawPADnoteApply();
-
-enabled->value(respar->Penabled);
-
-maxdb->value(respar->PmaxdB);
-maxdbvo->value(respar->PmaxdB);
-
-centerfreqvo->value(respar->getcenterfreq()/1000.0);
-octavesfreqvo->value(respar->getoctavesfreq());
-
-centerfreq->value(respar->Pcenterfreq);
-octavesfreq->value(respar->Poctavesfreq);
-
-p1st->value(respar->Pprotectthefundamental);
-
-rg->redraw();} {}
+//TODO fix me when controls are relocatable
+//enabled->value(respar->Penabled);
+
+//maxdb->value(respar->PmaxdB);
+//maxdbvo->value(respar->PmaxdB);
+//
+//centerfreqvo->value(respar->getcenterfreq()/1000.0);
+//octavesfreqvo->value(respar->getoctavesfreq());
+//
+//centerfreq->value(respar->Pcenterfreq);
+//octavesfreq->value(respar->Poctavesfreq);
+//
+//p1st->value(respar->Pprotectthefundamental);
+
+rg->update();} {}
}
- decl {Resonance *respar;} {public
+ decl {Fl_Widget *cbwidget,*cbapplywidget;} {private local
}
- decl {ResonanceGraph *rg;} {}
- decl {Fl_Widget *cbwidget,*cbapplywidget;} {}
}
diff --git a/src/UI/SUBnoteUI.fl b/src/UI/SUBnoteUI.fl
@@ -1,67 +1,119 @@
# data file for the Fltk User Interface Designer (fluid)
-version 1.0110
+version 1.0302
header_name {.h}
code_name {.cc}
-decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {}
+decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {private local
+}
-decl {//License: GNU GPL version 2 or later} {}
+decl {//License: GNU GPL version 2 or later} {private local
+}
-decl {\#include <stdlib.h>} {public
+decl {\#include <stdlib.h>} {public local
}
-decl {\#include <stdio.h>} {public
+decl {\#include <stdio.h>} {public local
}
-decl {\#include <string.h>} {public
+decl {\#include <string.h>} {public local
}
-decl {\#include "../globals.h"} {public
+decl {\#include "../globals.h"} {public local
}
-decl {\#include "WidgetPDial.h"} {public
+decl {\#include "Fl_Osc_VSlider.H"} {public local
+}
+
+decl {\#include "Fl_Osc_Dial.H"} {public local
+}
+
+decl {\#include "EnvelopeUI.h"} {public local
}
-decl {\#include "EnvelopeUI.h"} {public
+decl {\#include "FilterUI.h"} {public local
}
-decl {\#include "FilterUI.h"} {public
+decl {\#include "../Misc/Util.h"} {public local
}
-decl {\#include "../Misc/Util.h"} {public
+decl {\#include "../Params/SUBnoteParameters.h"} {public local
}
-decl {\#include "../Params/SUBnoteParameters.h"} {public
+decl {\#include "PresetsUI.h"} {public local
}
-decl {\#include "PresetsUI.h"} {public
+class PPSlider {: {public Fl_Slider, public Fl_Osc_Widget}
+} {
+ 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
+ } {
+ 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();
+
+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 {} {}
+ }
+ Function {update()} {return_type void
+ } {
+ code {} {}
+ }
+ Function {OSC_value(char c)} {open return_type void
+ } {
+ code {value(127-c);} {}
+ }
+ decl {bool bw;} {public local
+ }
}
-class SUBnoteharmonic {: {public Fl_Group}
+class SUBnoteharmonic {: {public Fl_Osc_Group}
} {
Function {make_window()} {private
} {
Fl_Window harmonic {
- xywh {1257 22 90 305} type Double hide
- class Fl_Group
+ xywh {329 403 90 305} type Double hide
+ class Fl_Osc_Group
} {
Fl_Slider mag {
- callback {int x=0;
+ 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);
-pars->Phmag[n]=x;
-if (pars->Phmag[n]==0) o->selection_color(0);
+ o->osc->writeValue(o->loc + "Phmag" + to_s(n), (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
- code0 {o->value(127-pars->Phmag[n]);}
- code1 {if (pars->Phmag[n]==0) o->selection_color(0);}
+ class PPSlider
}
Fl_Slider bw {
callback {int x=64;
if (Fl::event_button1() || Fl::event() == FL_MOUSEWHEEL) x=127-(int)o->value();
else o->value(x);
-pars->Phrelbw[n]=x;}
+ o->osc->writeValue(o->loc+"Phrelbw"+to_s(n), (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
- code0 {o->value(127-pars->Phrelbw[n]);}
+ class PPSlider
}
Fl_Box {} {
xywh {10 219 5 5} box FLAT_BOX color 45
@@ -79,28 +131,33 @@ pars->Phrelbw[n]=x;}
}
}
}
- Function {SUBnoteharmonic(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
+ Function {SUBnoteharmonic(int x,int y, int w, int h, const char *label=0):Fl_Osc_Group(x,y,w,h,label)} {} {
code {n=0;} {}
}
- Function {init(SUBnoteParameters *pars_,int n_)} {} {
- code {pars=pars_;
-n=n_;
+ Function {init(int n_)} {} {
+ code {n=n_;
make_window();
harmonic->show();
+
+osc->createLink(base+"Phmag"+to_s(n), mag);
+osc->createLink(base+"Phrelbw"+to_s(n), bw);
+osc->requestValue(base+"Phmag"+to_s(n));
+osc->requestValue(base+"Phrelbw"+to_s(n));
+
end();} {}
}
Function {refresh()} {} {
- code {mag->value(127-pars->Phmag[n]);
-if (pars->Phmag[n]==0) mag->selection_color(0);
-bw->value(127-pars->Phrelbw[n]);} {}
+ code {
+osc->requestValue(base+"Phmag"+to_s(n));
+osc->requestValue(base+"Phrelbw"+to_s(n));} {}
}
Function {~SUBnoteharmonic()} {} {
code {harmonic->hide();
hide();
//delete(harmonic);} {}
}
- decl {SUBnoteParameters *pars;} {}
- decl {int n;} {}
+ decl {int n;} {private local
+ }
}
class SUBnoteUI {open : {public PresetsUI_}
@@ -109,15 +166,20 @@ class SUBnoteUI {open : {public PresetsUI_}
} {
Fl_Window SUBparameters {
label {SUBsynth Parameters} open
- xywh {213 147 735 470} type Double visible
+ xywh {542 512 735 470} type Double
+ class Fl_Osc_Window visible
} {
+ Fl_Box {} {
+ xywh {0 0 0 0} box FLAT_BOX color 45
+ code0 {SUBparameters->osc = osc; SUBparameters->base = loc;}
+ }
Fl_Scroll {} {
label scroll open
xywh {5 140 434 325} type HORIZONTAL box FLAT_BOX labeltype NO_LABEL
} {
- Fl_Pack harmonics {
- xywh {5 145 430 325} type HORIZONTAL
- code0 {for (int i=0;i<MAX_SUB_HARMONICS;i++){h[i]=new SUBnoteharmonic(0,0,15,o->h(),"");h[i]->init(pars,i);}}
+ Fl_Pack harmonics {open
+ xywh {5 145 425 325} type HORIZONTAL
+ code0 {for (int i=0;i<MAX_SUB_HARMONICS;i++){h[i]=new SUBnoteharmonic(0,0,15,o->h(),"");h[i]->init(i);}}
} {}
}
Fl_Button {} {
@@ -131,27 +193,26 @@ class SUBnoteUI {open : {public PresetsUI_}
} {
Fl_Value_Slider vol {
label Vol
- callback {pars->PVolume=(int)o->value();}
tooltip Volume xywh {10 25 140 15} type {Horz Knob} box NO_BOX labelsize 11 align 8 maximum 127 step 1
- code0 {o->value(pars->PVolume);}
+ code0 {o->init("PVolume");}
+ class Fl_Osc_VSlider
}
Fl_Value_Slider vsns {
label {V.Sns}
- callback {pars->PAmpVelocityScaleFunction=(int) o->value();}
tooltip {Velocity Sensing Function (rightmost to disable)} xywh {10 45 140 15} type {Horz Knob} box NO_BOX labelsize 11 align 8 maximum 127 step 1
- code0 {o->value(pars->PAmpVelocityScaleFunction);}
+ code0 {o->init("PAmpVelocityScaleFunction");}
+ class Fl_Osc_VSlider
}
Fl_Dial pan {
label Pan
- callback {pars->PPanning=(int) o->value();}
tooltip {Panning (leftmost is Random)} xywh {185 20 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
- code0 {o->value(pars->PPanning);}
- class WidgetPDial
+ code0 {o->init("PPanning");}
+ class Fl_Osc_Dial
}
Fl_Group ampenv {
label {SUBsynth - Amplitude Envelope} open
xywh {10 65 205 70} box FLAT_BOX color 51 align 144
- code0 {o->init(pars->AmpEnvelope);}
+ code0 {o->init(ENV_ADSR, osc, loc, "AmpEnvelope/");}
class EnvelopeUI
} {}
}
@@ -160,15 +221,15 @@ class SUBnoteUI {open : {public PresetsUI_}
} {
Fl_Counter filterstages {
label {Filter Stages}
- callback {pars->Pnumstages=(int) o->value();}
tooltip {How many times the noise is filtered} xywh {515 421 45 15} type Simple labelfont 1 labelsize 10 align 1 minimum 1 maximum 5 step 1 textsize 10
- code0 {o->value(pars->Pnumstages);}
+ code0 {o->init("Pnumstages");}
+ class Fl_Osc_Counter
}
Fl_Choice magtype {
label {Mag.Type}
- callback {pars->Phmagtype=(int) o->value();}
xywh {585 421 65 15} down_box BORDER_BOX labelfont 1 labelsize 10 align 1 textsize 11
- code0 {o->value(pars->Phmagtype);}
+ code0 {o->init("Phmagtype");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label Linear
@@ -193,9 +254,9 @@ class SUBnoteUI {open : {public PresetsUI_}
}
Fl_Choice start {
label Start
- callback {pars->Pstart=(int) o->value();} open
- xywh {670 421 50 15} down_box BORDER_BOX labelfont 1 labelsize 10 align 1 textsize 11
- code0 {o->value(pars->Pstart);}
+ xywh {670 412 50 15} down_box BORDER_BOX labelfont 1 labelsize 10 align 1 textsize 11
+ code0 {o->init("Pstart");}
+ class Fl_Osc_Choice
} {
MenuItem {} {
label Zero
@@ -218,168 +279,154 @@ class SUBnoteUI {open : {public PresetsUI_}
Fl_Group freqenvelopegroup {
label {SUBsynth - Frequency Envelope} open
xywh {445 75 205 70} box FLAT_BOX color 51 align 144
- code0 {o->init(pars->FreqEnvelope);}
- code1 {if (pars->PFreqEnvelopeEnabled==0) o->deactivate();}
+ code0 {o->init(ENV_ASR, osc, loc, "FreqEnvelope/");}
class EnvelopeUI
} {}
Fl_Check_Button freqee {
label Enabled
- callback {pars->PFreqEnvelopeEnabled=o->value();
-if (o->value()==0) freqenvelopegroup->deactivate();
- else freqenvelopegroup->activate();
+ callback { if (o->value()==0) freqenvelopegroup->deactivate();
+ else freqenvelopegroup->activate();
o->show();
freqsettingsui->redraw();}
xywh {445 77 55 15} down_box DOWN_BOX labelfont 1 labelsize 10
- code0 {o->value(pars->PFreqEnvelopeEnabled);}
+ code0 {o->init("PFreqEnvelopeEnabled");}
+ class Fl_Osc_Check
}
Fl_Counter octave {
label Octave
- callback {int k=(int) o->value();
-if (k<0) k+=16;
-pars->PCoarseDetune = k*1024+
- pars->PCoarseDetune%1024;}
tooltip Octave xywh {670 58 45 15} type Simple labelsize 10 align 1 minimum -8 maximum 7 step 1 textfont 1 textsize 11
- code0 {int k=pars->PCoarseDetune/1024;if (k>=8) k-=16;}
- code2 {o->value(k);}
+ code0 {o->init("octave");}
+ class Fl_Osc_Counter
}
Fl_Counter coarsedet {
label {Coarse Det.}
- callback {int k=(int) o->value();
-if (k<0) k+=1024;
-pars->PCoarseDetune = k+
- (pars->PCoarseDetune/1024)*1024;}
tooltip {Coarse Detune} xywh {655 125 60 20} labelsize 10 align 1 minimum -64 maximum 63 step 1 textfont 1 textsize 11
- code0 {int k=pars->PCoarseDetune%1024;if (k>=512) k-=1024;}
- code2 {o->value(k);}
+ code0 {o->init("coarsedetune");}
code3 {o->lstep(10);}
+ class Fl_Osc_Counter
}
Fl_Slider detune {
- callback {pars->PDetune=(int)o->value()+8192;
-detunevalueoutput->do_callback();}
+ callback {o->oscWrite("detunevalue");}
tooltip {Fine Detune (cents)} xywh {495 27 230 15} type {Horz Knob} box NO_BOX minimum -8192 maximum 8191 step 1
- code0 {o->value(pars->PDetune-8192);}
+ code0 {o->init("PDetune",'i');}
+ class Fl_Osc_Slider
}
Fl_Value_Output detunevalueoutput {
label Detune
- callback {o->value(getdetune(pars->PDetuneType,0,pars->PDetune));}
xywh {448 27 45 15} labelsize 10 align 5 minimum -5000 maximum 5000 step 0.01 textfont 1 textsize 10
- code0 {o->value(getdetune(pars->PDetuneType,0,pars->PDetune));}
+ code0 {o->init("detunevalue");}
+ class Fl_Osc_Output
}
Fl_Check_Button hz440 {
label 440Hz
- callback {int x=(int) o->value();
-pars->Pfixedfreq=x;
-if (x==0) fixedfreqetdial->deactivate();
+ callback {if (o->value()==0) fixedfreqetdial->deactivate();
else fixedfreqetdial->activate();}
tooltip {set the base frequency to 440Hz} xywh {555 53 50 15} down_box DOWN_BOX labelfont 1 labelsize 10
- code0 {o->value(pars->Pfixedfreq);}
+ code0 {o->init("Pfixedfreq");}
+ class Fl_Osc_Check
}
Fl_Dial fixedfreqetdial {
label {Eq.T.}
- callback {pars->PfixedfreqET=(int) o->value();}
tooltip {How the frequency varies acording to the keyboard (leftmost for fixed frequency)} xywh {610 53 15 15} box ROUND_UP_BOX labelsize 10 align 8 maximum 127 step 1
- code0 {o->value(pars->PfixedfreqET);}
- code1 {if (pars->Pfixedfreq==0) o->deactivate();}
- class WidgetPDial
+ code0 {o->init("PfixedfreqET");}
+ class Fl_Osc_Dial
}
Fl_Choice detunetype {
label {Detune Type}
- callback {pars->PDetuneType=(int) o->value()+1;
-detunevalueoutput->do_callback();} open
+ callback {o->oscWrite("detunevalue");} open
xywh {655 94 70 15} down_box BORDER_BOX labelsize 10 align 5 textfont 1 textsize 10
code0 {o->add("L35cents");o->add("L10cents");o->add("E100cents");o->add("E1200cents");}
- code1 {o->value(pars->PDetuneType-1);}
+ code1 {o->init("PDetuneType",1);}
+ class Fl_Osc_Choice
} {}
}
Fl_Check_Button stereo {
label Stereo
- callback {pars->Pstereo=(int) o->value();}
xywh {440 406 55 35} box THIN_UP_BOX down_box DOWN_BOX labelsize 10
- code0 {o->value(pars->Pstereo);}
+ code0 {o->init("Pstereo");}
+ class Fl_Osc_Check
}
Fl_Button {} {
label Clear
- callback {for (int i=0;i<MAX_SUB_HARMONICS;i++){
+ callback {
+ o->oscWrite("clear");
+ for (int i=0;i<MAX_SUB_HARMONICS;i++){
h[i]->mag->value(127);
- pars->Phmag[i]=0;
h[i]->bw->value(64);
- pars->Phrelbw[i]=64;
};
-pars->Phmag[0]=127;
h[0]->mag->value(0);
SUBparameters->redraw();}
tooltip {Clear the harmonics} xywh {445 446 70 20} box THIN_UP_BOX labelfont 1 labelsize 11
+ class Fl_Osc_Button
}
Fl_Group bandwidthsettingsui {
label BANDWIDTH
xywh {220 5 220 135} box UP_FRAME labeltype EMBOSSED_LABEL labelfont 1 align 17
} {
Fl_Group bandwidthenvelopegroup {
- label {SUBsynth - BandWidth Envelope} open
+ label {SUBsynth - BandWidth Envelope} open selected
xywh {225 65 205 70} box FLAT_BOX color 51 align 144
- code0 {o->init(pars->BandWidthEnvelope);}
- code1 {if (pars->PBandWidthEnvelopeEnabled==0) o->deactivate();}
+ code0 {o->init(ENV_ADSR_BW, osc, loc, "BandWidthEnvelope/");}
class EnvelopeUI
} {}
Fl_Check_Button bwee {
label Enabled
- callback {pars->PBandWidthEnvelopeEnabled=o->value();
-if (o->value()==0) bandwidthenvelopegroup->deactivate();
+ callback {if (o->value()==0) bandwidthenvelopegroup->deactivate();
else bandwidthenvelopegroup->activate();
o->show();
bandwidthsettingsui->redraw();}
xywh {225 67 55 15} down_box DOWN_BOX labelfont 1 labelsize 10
- code0 {o->value(pars->PBandWidthEnvelopeEnabled);}
+ code0 {o->init("PBandWidthEnvelopeEnabled");}
+ class Fl_Osc_Check
}
Fl_Value_Slider bandwidth {
label {Band Width}
- callback {pars->Pbandwidth=(int) o->value();}
xywh {225 40 115 15} type {Horz Knob} box NO_BOX labelsize 10 align 1 maximum 127 step 1
- code0 {o->value(pars->Pbandwidth);}
+ code0 {o->init("Pbandwidth");}
+ class Fl_Osc_VSlider
}
Fl_Value_Slider bwidthscale {
label {B.Width Scale}
- callback {pars->Pbwscale=(int) o->value()+64;}
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->value(pars->Pbwscale-64);}
+ code0 {o->init("Pbwscale");}
+ class Fl_Osc_Slider
}
}
Fl_Group globalfiltergroup {
label FILTER
- xywh {440 221 290 185} box UP_FRAME labeltype EMBOSSED_LABEL labelfont 1 align 17
- code0 {if (pars->PGlobalFilterEnabled==0) o->deactivate();}
+ xywh {440 221 290 185} box UP_FRAME labeltype EMBOSSED_LABEL labelfont 1 labelsize 13 align 17
} {
Fl_Group filterenv {
label {SUBsynth - Filter Envelope} open
xywh {445 331 275 70} box FLAT_BOX color 51 align 144
- code0 {o->init(pars->GlobalFilterEnvelope);}
+ code0 {o->init(ENV_ADSR_FILTER, osc, loc, "GlobalFilterEnvelope/");}
class EnvelopeUI
} {}
Fl_Group filterui {
label {SUBsynthl - Filter} open
xywh {445 246 275 75} box FLAT_BOX color 50 align 144
- code0 {o->init(pars->GlobalFilter,&pars->PGlobalFilterVelocityScale,&pars->PGlobalFilterVelocityScaleFunction);}
+ code0 {o->init(loc + "PGlobalFilter" , osc, loc, "GlobalFilter/");}
class FilterUI
} {}
}
Fl_Check_Button filtere {
label Enabled
- callback {pars->PGlobalFilterEnabled=o->value();
-if (o->value()==0) globalfiltergroup->deactivate();
+ callback {if (o->value()==0) globalfiltergroup->deactivate();
else globalfiltergroup->activate();
o->show();
globalfiltergroup->redraw();}
xywh {445 226 85 20} down_box DOWN_BOX labelfont 1 labelsize 11
- code0 {o->value(pars->PGlobalFilterEnabled);}
+ code0 {o->init("PGlobalFilterEnabled");}
+ class Fl_Osc_Check
}
Fl_Button {} {
label C
- callback {presetsui->copy(pars);}
+ callback {/*presetsui->copy(pars);*/}
xywh {540 451 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
}
Fl_Button {} {
label P
- callback {presetsui->paste(pars,this);}
+ callback {/*presetsui->paste(pars,this);*/}
xywh {570 451 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
}
Fl_Group {} {
@@ -388,8 +435,8 @@ globalfiltergroup->redraw();}
} {
Fl_Choice spreadtype {
label OvertonesPosition
- callback {pars->POvertoneSpread.type = (int)o->value();
-pars->updateFrequencyMultipliers();} open
+ callback {/*pars->POvertoneSpread.type = (int)o->value();
+pars->updateFrequencyMultipliers();*/} open
xywh {450 190 80 20} down_box BORDER_BOX labelsize 10 align 5 textsize 10
code0 {o->value(pars->POvertoneSpread.type);}
} {
@@ -428,90 +475,51 @@ pars->updateFrequencyMultipliers();} open
}
Fl_Dial spreadpar1 {
label Par1
- callback {pars->POvertoneSpread.par1 = o->value();
-pars->updateFrequencyMultipliers();}
+ callback {/*pars->POvertoneSpread.par1 = o->value();
+pars->updateFrequencyMultipliers();*/}
xywh {548 173 30 30} box ROUND_UP_BOX labelsize 10 maximum 255 step 1
- code0 {o->value(pars->POvertoneSpread.par1);}
+ code0 {/*o->value(pars->POvertoneSpread.par1);*/}
class WidgetPDial
}
Fl_Dial spreadpar2 {
label Par2
- callback {pars->POvertoneSpread.par2 = o->value();
-pars->updateFrequencyMultipliers();}
+ callback {/*pars->POvertoneSpread.par2 = o->value();
+pars->updateFrequencyMultipliers();*/}
xywh {583 173 30 30} box ROUND_UP_BOX labelsize 10 maximum 255 step 1
- code0 {o->value(pars->POvertoneSpread.par2);}
+ code0 {/*o->value(pars->POvertoneSpread.par2);*/}
class WidgetPDial
}
Fl_Dial spreadpar3 {
label ForceH
- callback {pars->POvertoneSpread.par3 = o->value();
-pars->updateFrequencyMultipliers();}
+ callback {/*pars->POvertoneSpread.par3 = o->value();
+pars->updateFrequencyMultipliers();*/}
xywh {618 173 30 30} box ROUND_UP_BOX labelsize 10 maximum 255 step 1
- code0 {o->value(pars->POvertoneSpread.par3);}
+ code0 {/*o->value(pars->POvertoneSpread.par3);*/}
class WidgetPDial
}
}
}
}
Function {refresh()} {} {
- code {for (int i=0;i<MAX_SUB_HARMONICS;i++) h[i]->refresh();
-vol->value(pars->PVolume);
-vsns->value(pars->PAmpVelocityScaleFunction);
-pan->value(pars->PPanning);
-
-
-bandwidth->value(pars->Pbandwidth);
-bwidthscale->value(pars->Pbwscale-64);
-bwee->value(pars->PBandWidthEnvelopeEnabled);
-if (pars->PBandWidthEnvelopeEnabled==0) bandwidthenvelopegroup->deactivate();
- else bandwidthenvelopegroup->activate();
-bwee->show();
-bandwidthsettingsui->redraw();
-
-detunevalueoutput->value(getdetune(pars->PDetuneType,0,pars->PDetune));
-spreadtype->value(pars->POvertoneSpread.type);
-spreadpar1->value(pars->POvertoneSpread.par1);
-spreadpar2->value(pars->POvertoneSpread.par2);
-spreadpar3->value(pars->POvertoneSpread.par3);
+ code {
+//bwee->show();
+//bandwidthsettingsui->redraw();
-freqee->value(pars->PFreqEnvelopeEnabled);
-if (pars->PFreqEnvelopeEnabled==0) freqenvelopegroup->deactivate();
- else freqenvelopegroup->activate();
-freqee->show();
-freqsettingsui->redraw();
+//freqee->show();
+//freqsettingsui->redraw();
-detune->value(pars->PDetune-8192);
-hz440->value(pars->Pfixedfreq);
-
-fixedfreqetdial->value(pars->PfixedfreqET);
-
-int k=pars->PCoarseDetune/1024;if (k>=8) k-=16;
-octave->value(k);
-
-detunetype->value(pars->PDetuneType-1);
-
-k=pars->PCoarseDetune%1024;if (k>=512) k-=1024;
-coarsedet->value(k);
-
-filtere->value(pars->PGlobalFilterEnabled);
-if (pars->PGlobalFilterEnabled==0) globalfiltergroup->deactivate();
- else globalfiltergroup->activate();
-filtere->show();
+//filtere->show();
globalfiltergroup->redraw();
-stereo->value(pars->Pstereo);
-filterstages->value(pars->Pnumstages);
-magtype->value(pars->Phmagtype);
-start->value(pars->Pstart);
-
ampenv->refresh();
bandwidthenvelopegroup->refresh();
freqenvelopegroup->refresh();
filterui->refresh();
filterenv->refresh();} {}
}
- Function {SUBnoteUI(SUBnoteParameters *parameters)} {} {
- code {pars=parameters;
+ Function {SUBnoteUI(Fl_Osc_Interface *osc_, std::string loc_)} {} {
+ code {osc = osc_;
+ loc = loc_;
make_window();} {}
}
Function {~SUBnoteUI()} {} {
@@ -519,6 +527,10 @@ make_window();} {}
SUBparameters->hide();
delete(SUBparameters);} {}
}
- decl {SUBnoteParameters *pars;} {}
- decl {SUBnoteharmonic *h[MAX_SUB_HARMONICS];} {}
+ decl {Fl_Osc_Interface *osc;} {private local
+ }
+ decl {std::string loc;} {private local
+ }
+ decl {SUBnoteharmonic *h[MAX_SUB_HARMONICS];} {private local
+ }
}
diff --git a/src/UI/VirKeyboard.fl b/src/UI/VirKeyboard.fl
@@ -1,68 +1,81 @@
# data file for the Fltk User Interface Designer (fluid)
-version 1.0110
+version 1.0302
header_name {.h}
code_name {.cc}
-decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {}
-
-decl {//License: GNU GPL version 2 or later} {}
+decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {private local
+}
-decl {\#include <stdlib.h>} {public
+decl {//License: GNU GPL version 2 or later} {private local
}
-decl {\#include <FL/fl_draw.H>} {public
+decl {\#include <stdlib.h>} {public local
}
-decl {\#include <FL/Fl_Box.H>} {public
+decl {\#include <FL/fl_draw.H>} {public local
}
-decl {\#include "../globals.h"} {public
+decl {\#include <FL/Fl_Box.H>} {public local
}
-decl {\#include "../Misc/Master.h"} {public
+decl {\#include "../globals.h"} {public local
}
-decl {\#include "../Misc/Util.h"} {public
+decl {\#include "../Misc/Util.h"} {public local
}
-decl {\#include "WidgetPDial.h"} {public
+decl {\#include "WidgetPDial.h"} {public local
}
-decl {\#include "common.H"} {public
+decl {\#include "common.H"} {public local
}
decl {\#ifdef NTK_GUI
\#include "FL/Fl_Shared_Image.H"
- \#endif} {public
+ \#endif} {public local
}
-decl {const int keyspos[12]={0,-1,1,-2,2,3,-4,4,-5,5,-6,6};} {}
+decl {const int keyspos[12]={0,-1,1,-2,2,3,-4,4,-5,5,-6,6};} {private local
+}
-decl {const int keysoct1qwerty[]={'q','2','w','3','e','r','5','t','6','y','7','u','i','9','o','0','p','[','=',']','\\\\',FL_Enter,0};} {}
+decl {const int keysoct1qwerty[]={'q','2','w','3','e','r','5','t','6','y','7','u','i','9','o','0','p','[','=',']','\\\\',FL_Enter,0};} {private local
+}
-decl {const int keysoct2qwerty[]={'z','s','x','d','c','v','g','b','h','n','j','m',',','l','.',';','/',0};} {}
+decl {const int keysoct2qwerty[]={'z','s','x','d','c','v','g','b','h','n','j','m',',','l','.',';','/',0};} {private local
+}
-decl {const int keysoct1dw[]={'\\'','2',',','3','.','p','5','y','6','f','7','g','c','9','r','0','l','/',']','=','\\\\',FL_Enter,0};} {}
+decl {const int keysoct1dw[]={'\\'','2',',','3','.','p','5','y','6','f','7','g','c','9','r','0','l','/',']','=','\\\\',FL_Enter,0};} {private local
+}
-decl {const int keysoct2dw[]={';','o','q','e','j','k','i','x','d','b','h','m','w','n','v','s','z',0};} {}
+decl {const int keysoct2dw[]={';','o','q','e','j','k','i','x','d','b','h','m','w','n','v','s','z',0};} {private local
+}
-decl {const int keysoct1qwertz[]={'q','2','w','3','e','r','5','t','6','z','7','u','i','9','o','0','p',252,'\\'','+','\\\\',FL_Enter,0};} {}
+decl {const int keysoct1qwertz[]={'q','2','w','3','e','r','5','t','6','z','7','u','i','9','o','0','p',252,'\\'','+','\\\\',FL_Enter,0};} {private local
+}
-decl {const int keysoct2qwertz[]={'y','s','x','d','c','v','g','b','h','n','j','m',',','l','.',246,'-',0};} {}
+decl {const int keysoct2qwertz[]={'y','s','x','d','c','v','g','b','h','n','j','m',',','l','.',246,'-',0};} {private local
+}
-decl {const int keysoct1az[]={'a',233,'z','\\"','e','r','(','t','-','y',232,'u','i',231,'o',224,'p',65106,'=','$',0};} {}
+decl {const int keysoct1az[]={'a',233,'z','\\"','e','r','(','t','-','y',232,'u','i',231,'o',224,'p',65106,'=','$',0};} {private local
+}
-decl {const int keysoct2az[]={'w','s','x','d','c','v','g','b','h','n','j',',',';','l',':','m','!',0};} {}
+decl {const int keysoct2az[]={'w','s','x','d','c','v','g','b','h','n','j',',',';','l',':','m','!',0};} {private local
+}
-class VirKeys {: {public Fl_Box}
+class VirKeys {open : {public Fl_Box}
} {
- decl {static const int N_OCT=6;} {}
- decl {static const int SIZE_WHITE=14;} {}
- decl {static const int SIZE_BLACK=8;} {}
+ decl {static const int N_OCT=6;} {private local
+ }
+ decl {static const int SIZE_WHITE=14;} {private local
+ }
+ decl {static const int SIZE_BLACK=8;} {private local
+ }
Function {VirKeys(int x,int y, int w, int h, const char *label=0):Fl_Box(x,y,w,h,label)} {} {
- code {master=NULL;} {}
+ code {} {}
}
- Function {init(Master *master_)} {} {
- code {master=master_;
+ Function {init(Fl_Osc_Interface *osc_, std::string loc_)} {open
+ } {
+ code {osc=osc_;
+loc=loc_;
for (int i=0;i<N_OCT*12+1;i++) pressed[i]=0;
midich=0;
midivel=100;
@@ -70,7 +83,8 @@ midioct=2;
keyoct1=3;
keyoct2=2;
-rndvelocity=0;} {}
+rndvelocity=0;} {selected
+ }
}
Function {draw()} {} {
code {int ox=x(),oy=y(),lx=w(),ly=h()-1,i;
@@ -266,9 +280,7 @@ if (rndvelocity!=0){
vel=midivel*(127.0-rndvelocity)/127.0+RND*rndvelocity;
};
-pthread_mutex_lock(&master->mutex);
-master->noteOn(midich,nk+midioct*12,(int)vel);
-pthread_mutex_unlock(&master->mutex);} {}
+osc->write(loc+"noteOn", "ccc", midich,nk+midioct*12,(int)vel);} {}
}
Function {relasekey(int nk,int type)} {} {
code {if ((nk<0)||(nk>=N_OCT*12)) return;
@@ -280,22 +292,24 @@ pressed[nk]=0;
damage(1);
-pthread_mutex_lock(&master->mutex);
-master->noteOff(midich,nk+12*midioct);
-pthread_mutex_unlock(&master->mutex);} {}
+osc->write(loc+"noteOff", "cc", midich,nk+12*midioct);} {}
}
Function {relaseallkeys(int type)} {} {
code {for (int i=0;i<N_OCT*12;i++) relasekey(i,type);} {}
}
- decl {Master *master;} {}
- decl {int pressed[N_OCT*12+1];} {}
- decl {unsigned char midich;} {public
+ decl {int pressed[N_OCT*12+1];} {private local
+ }
+ decl {unsigned char midich;} {public local
+ }
+ decl {unsigned char midivel;} {public local
}
- decl {unsigned char midivel;} {public
+ decl {char midioct,keyoct1,keyoct2;} {public local
}
- decl {char midioct,keyoct1,keyoct2;} {public
+ decl {unsigned char rndvelocity;} {public local
}
- decl {unsigned char rndvelocity;} {public
+ decl {Fl_Osc_Interface *osc;} {private local
+ }
+ decl {std::string loc;} {private local
}
}
@@ -307,12 +321,12 @@ class VirKeyboard {open
label {Virtual Keyboard - ZynAddSubFX}
callback {relaseallkeys();
virkeyboardwindow->hide();} open
- xywh {100 597 650 130} type Double visible
+ xywh {103 620 650 130} type Double visible
} {
Fl_Box virkeys {
label Keyboard
xywh {10 10 590 80} box FLAT_BOX color 17
- code0 {o->init(master);}
+ code0 {o->init(osc,loc);}
class VirKeys
}
Fl_Counter {} {
@@ -334,7 +348,7 @@ virkeys->take_focus();}
Fl_Value_Slider {} {
label Vel
callback {virkeys->midivel=(int) o->value();
-virkeys->take_focus();} selected
+virkeys->take_focus();}
tooltip Velocity xywh {95 105 100 15} type {Horz Knob} box NO_BOX labelsize 10 align 5 minimum 1 maximum 127 step 1
code0 {o->value(virkeys->midivel);}
}
@@ -356,9 +370,7 @@ virkeyboardwindow->hide();}
label Cval
callback {int ctl=midictl;
-pthread_mutex_lock(&master->mutex);
-master->setController(virkeys->midich,ctl,(int) o->value());
-pthread_mutex_unlock(&master->mutex);
+osc->write("setController", "ccc", virkeys->midich,ctl,(int) o->value());
virkeys->take_focus();}
tooltip {Controller value} xywh {605 10 15 115} type {Vert Fill} box ENGRAVED_BOX selection_color 229 labelsize 8 align 5 minimum 127 maximum 0 step 1 value 64 textsize 7
}
@@ -438,9 +450,7 @@ virkeys->take_focus();}
}
Fl_Roller pitchwheelroller {
label Pwh
- callback {pthread_mutex_lock(&master->mutex);
-master->setController(virkeys->midich,C_pitchwheel,-(int) o->value());
-pthread_mutex_unlock(&master->mutex);
+ callback {osc->write("setController", "ccc", virkeys->midich,C_pitchwheel,-(int) o->value());
virkeys->take_focus();}
tooltip {Pitch Wheel} xywh {625 10 20 95} labelsize 8 align 1 when 3 minimum -8192 maximum 8192 step 64
}
@@ -468,20 +478,29 @@ virkeys->take_focus();} open
} {}
}
}
- Function {VirKeyboard(Master *master_)} {} {
- code {master=master_;
+ Function {VirKeyboard(Fl_Osc_Interface *osc_, std::string loc_)} {open
+ } {
+ code {osc=osc_;
+loc=loc_;
midictl=75;
make_window();} {}
}
- Function {~VirKeyboard()} {} {
+ Function {~VirKeyboard()} {open
+ } {
code {delete virkeyboardwindow;} {}
}
- Function {show()} {} {
+ Function {show()} {open
+ } {
code {virkeyboardwindow->show();} {}
}
- Function {relaseallkeys()} {} {
+ Function {relaseallkeys()} {open
+ } {
code {virkeys->relaseallkeys(0);} {}
}
- decl {Master *master;} {}
- decl {int midictl;} {}
+ decl {int midictl;} {private local
+ }
+ decl {Fl_Osc_Interface *osc;} {private local
+ }
+ decl {std::string loc;} {private local
+ }
}
diff --git a/src/UI/VuMasterMeter.h b/src/UI/VuMasterMeter.h
@@ -0,0 +1,134 @@
+#include "VuMeter.h"
+#include "Fl_Osc_Interface.h"
+#define MIN_DB (-48)
+
+class VuMasterMeter: public VuMeter
+{
+ public:
+ VuMasterMeter(int x,int y, int w, int h, const char *label=0)
+ :VuMeter(x,y,w,h,label),
+ olddbl(0.0f),olddbr(0.0f),
+ oldrmsdbl(0.0f),oldrmsdbr(0.0f),
+ dbl(0.0f),dbr(0.0f),rmsdbl(0.0f),rmsdbr(0.0f),maxdbl(0.0f),maxdbr(0.0f),
+ clipped(0),osc(NULL)
+ {}
+
+ void init(Fl_Osc_Interface *_osc)
+ {
+ osc = _osc;
+ }
+
+ int handle(int event)
+ {
+ switch(event){
+ case FL_SHOW:
+ Fl::add_timeout(1.0/18.0,tick,osc);
+ break;
+ case FL_HIDE:
+ Fl::remove_timeout(tick,osc);
+ break;
+ case FL_PUSH:
+ osc->requestValue("/reset-vu");
+ break;
+ }
+
+ return 1;
+ }
+
+ static void tick(void *v)
+ {
+ Fl::repeat_timeout(1.0/18.0,tick,v);//18 fps
+ Fl_Osc_Interface *osc = (Fl_Osc_Interface*)v;
+ osc->requestValue("/get-vu");
+ }
+
+ void draw(void)
+ {
+ const int X = x(), Y = y(), W = w(), H = h();
+
+#define VULENX (W-35)
+#define VULENY (H/2-3)
+
+ const int idbl = dbl*VULENX;
+ const int idbr = dbr*VULENX;
+ const int irmsdbl = rmsdbl*VULENX;
+ const int irmsdbr = rmsdbr*VULENX;
+
+ //draw the vu-meter lines
+ //dB
+ fl_rectf(X,Y,idbr,VULENY,0,200,255);
+ fl_rectf(X,Y+H/2,idbl,VULENY,0,200,255);
+ //black
+ fl_rectf(X+idbr,Y,VULENX-idbr,VULENY,0,0,0);
+ fl_rectf(X+idbl,Y+H/2,VULENX-idbl,VULENY,0,0,0);
+
+ //draw the scales
+ const float tmp=VULENX*1.0/MIN_DB;
+ for (int i=1;i<1-MIN_DB;i++){
+ const int tx=VULENX+(int) (tmp*i);
+ fl_rectf(X+tx,Y,1,VULENY+H/2,0,160,200);
+ if (i%5==0) fl_rectf(X+tx,Y,1,VULENY+H/2,0,230,240);
+ if (i%10==0) fl_rectf(X+tx-1,Y,2,VULENY+H/2,0,225,255);
+ }
+
+ //rms
+ if (irmsdbr>2) fl_rectf(X+irmsdbr-1,Y,3,VULENY,255,255,0);
+ if (irmsdbl>2) fl_rectf(X+irmsdbl-1,Y+H/2,3,VULENY,255,255,0);
+
+
+ //draw the red box if clipping has occured
+ if (clipped==0) fl_rectf(X+VULENX+2,Y+1,W-VULENX-3,H-4,0,0,10);
+ else fl_rectf(X+VULENX+2,Y+1,W-VULENX-3,H-4,250,10,10);
+
+ //draw the maxdB
+ fl_font(FL_HELVETICA|FL_BOLD,10);
+ fl_color(255,255,255);
+
+ char tmpstr[10];
+ if(maxdbl>MIN_DB-20){
+ snprintf((char *)&tmpstr,10,"%ddB",(int)maxdbr);
+ fl_draw(tmpstr,X+VULENX+1,Y+1,W-VULENX-1,VULENY,FL_ALIGN_RIGHT,NULL,0);
+ }
+ if(maxdbr>MIN_DB-20){
+ snprintf((char *)&tmpstr,10,"%ddB",(int)maxdbl);
+ fl_draw(tmpstr,X+VULENX+1,Y+H/2+1,W-VULENX-1,VULENY,FL_ALIGN_RIGHT,NULL,0);
+ }
+ }
+
+ void update(vuData *d)
+ {
+ //Update properties
+ dbl = limit((MIN_DB-rap2dB(d->outpeakl))/MIN_DB);
+ dbr = limit((MIN_DB-rap2dB(d->outpeakr))/MIN_DB);
+ rmsdbl = limit((MIN_DB-rap2dB(d->rmspeakl))/MIN_DB);
+ rmsdbr = limit((MIN_DB-rap2dB(d->rmspeakr))/MIN_DB);
+ maxdbl = rap2dB(d->maxoutpeakl);
+ maxdbr = rap2dB(d->maxoutpeakr);
+ clipped = d->clipped;
+
+ //interpolate
+ dbl = 0.4 * dbl + 0.6 * olddbl;
+ dbr = 0.4 * dbr + 0.6 * olddbr;
+
+ rmsdbl = 0.4 * rmsdbl + 0.6 * oldrmsdbl;
+ rmsdbr = 0.4 * rmsdbr + 0.6 * oldrmsdbr;
+
+ //only update when values appear to be different
+ if(olddbl == dbl && olddbr == dbr)
+ return;
+
+ olddbl = dbl;
+ olddbr = dbr;
+ oldrmsdbl = rmsdbl;
+ oldrmsdbr = rmsdbr;
+
+ damage(FL_DAMAGE_USER1);
+ }
+ private:
+ float olddbl,olddbr;
+ float oldrmsdbl,oldrmsdbr;
+ float dbl,dbr,rmsdbl,rmsdbr,maxdbl,maxdbr;
+ int clipped;
+
+ Fl_Osc_Interface *osc;
+};
diff --git a/src/UI/VuMeter.h b/src/UI/VuMeter.h
@@ -0,0 +1,23 @@
+#ifndef VU_METER_H
+#define VU_METER_H
+#include <FL/Fl_Box.H>
+
+class VuMeter: public Fl_Box
+{
+ public:
+
+ VuMeter(int x,int y, int w, int h, const char *label=0)
+ :Fl_Box(x,y,w,h,label)
+ {}
+
+ protected:
+ float limit(float x)
+ {
+ if(x<0.0)
+ x=0.0;
+ else if(x>1.0)
+ x=1.0;
+ return x;
+ }
+};
+#endif
diff --git a/src/UI/VuPartMeter.h b/src/UI/VuPartMeter.h
@@ -0,0 +1,53 @@
+#include "VuMeter.h"
+#define MIN_DB (-48)
+
+class VuPartMeter: public VuMeter
+{
+ public:
+ VuPartMeter(int x,int y, int w, int h, const char *label=0)
+ :VuMeter(x,y,w,h,label), db(0.0f)
+ {}
+
+ void draw(void)
+ {
+ const int X = x(), Y = y(), W = w(), H = h();
+
+ //XXX perhaps re-enable this later on
+ //if (!active_r()){
+ // int fakedb=master->fakepeakpart[npart];
+ // fl_rectf(X,Y,W,H,140,140,140);
+ // if (fakedb>0){
+ // fakedb=(int)(fakedb/255.0*H)+4;
+ // fl_rectf(X+2,Y+H-fakedb,W-4,fakedb,0,0,0);
+ // }
+ // return;
+ //}
+
+ //draw the vu lines
+ const int idb = db*(H-2);
+
+ fl_rectf(X,Y+H-idb,W,idb,0,200,255);
+ fl_rectf(X,Y,W,H-idb,0,0,0);
+
+ //draw the scales
+ const float tmp=H*1.0/MIN_DB;
+ for (int i = 1; i < 1 - MIN_DB; i++) {
+ const int ty = H+(int) (tmp*i);
+ if(i%5 == 0) fl_rectf(X, Y+H-ty, W, 1,0, 160, 200);
+ if(i%10 == 0) fl_rectf(X, Y+H-ty, W, 1,0, 230, 240);
+ }
+ }
+
+ void update(float x)
+ {
+ const float _db = limit((MIN_DB-rap2dB(x))/MIN_DB);
+
+ if(db != _db) {
+ db = _db;
+ damage(FL_DAMAGE_USER1);
+ }
+ }
+
+ private:
+ float db;
+};
diff --git a/src/UI/common.H b/src/UI/common.H
@@ -17,6 +17,7 @@
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*******************************************************************************/
+#include "Fl_Osc_Interface.h"
class Fl_Widget;
extern void set_module_parameters ( Fl_Widget * );
diff --git a/src/globals.h b/src/globals.h
@@ -26,6 +26,10 @@
#define GLOBALS_H
#include <stdint.h>
+//Forward declarations
+namespace rtosc{struct Ports; class ThreadLink;};
+extern rtosc::ThreadLink *bToU;
+extern rtosc::ThreadLink *uToB;
/**
* The number of harmonics of additive synth
diff --git a/src/main.cpp b/src/main.cpp
@@ -20,11 +20,9 @@
*/
-#include <FL/Fl.H>
-
-#include "UI/common.H"
#include <iostream>
+#include <map>
#include <cmath>
#include <cctype>
#include <algorithm>
@@ -35,6 +33,11 @@
#include <getopt.h>
+#include <lo/lo.h>
+#include <rtosc/ports.h>
+#include <rtosc/thread-link.h>
+#include "Params/PADnoteParameters.h"
+
#include "DSP/FFTwrapper.h"
#include "Misc/Master.h"
#include "Misc/Part.h"
@@ -42,34 +45,19 @@
#include "Misc/Dump.h"
extern Dump dump;
-
//Nio System
#include "Nio/Nio.h"
-#ifndef DISABLE_GUI
-#ifdef QT_GUI
-
-#include <QApplication>
-#include "masterui.h"
-QApplication *app;
-
-#elif defined FLTK_GUI
-#include "UI/MasterUI.h"
-#elif defined NTK_GUI
-#include "UI/MasterUI.h"
-#include <FL/Fl_Shared_Image.H>
-#include <FL/Fl_Tiled_Image.H>
-#include <FL/Fl_Dial.H>
-#include <FL/Fl_Tooltip.H>
-#endif // FLTK_GUI
+//GUI System
+#include "UI/Connection.h"
+GUI::ui_handle_t gui;
-MasterUI *ui;
-
-#endif //DISABLE_GUI
+//Glue Layer
+#include "Misc/MiddleWare.h"
+MiddleWare *middleware;
using namespace std;
-pthread_t thr4;
Master *master;
SYNTH_T *synth;
int swaplr = 0; //1 for left-right swapping
@@ -91,36 +79,16 @@ char *instance_name = 0;
void exitprogram();
+extern int main_thread;
+
//cleanup on signaled exit
void sigterm_exit(int /*sig*/)
{
+ if(Pexitprogram)
+ exit(1);
Pexitprogram = 1;
}
-
-#ifndef DISABLE_GUI
-
-#ifdef NTK_GUI
-static Fl_Tiled_Image *module_backdrop;
-#endif
-
-void
-set_module_parameters ( Fl_Widget *o )
-{
-#ifdef NTK_GUI
- o->box( FL_DOWN_FRAME );
- o->align( o->align() | FL_ALIGN_IMAGE_BACKDROP );
- o->color( FL_BLACK );
- o->image( module_backdrop );
- o->labeltype( FL_SHADOW_LABEL );
-#else
- o->box( FL_PLASTIC_UP_BOX );
- o->color( FL_CYAN );
- o->labeltype( FL_EMBOSSED_LABEL );
-#endif
-}
-#endif
-
/*
* Program initialisation
*/
@@ -135,11 +103,13 @@ void initprogram(void)
cerr << "ADsynth Oscil.Size = \t" << synth->oscilsize << " samples" << endl;
- master = &Master::getInstance();
+ middleware = new MiddleWare();
+ master = middleware->spawnMaster();
master->swaplr = swaplr;
signal(SIGINT, sigterm_exit);
signal(SIGTERM, sigterm_exit);
+ Nio::init(master);
}
/*
@@ -147,15 +117,10 @@ void initprogram(void)
*/
void exitprogram()
{
- //ensure that everything has stopped with the mutex wait
- pthread_mutex_lock(&master->mutex);
- pthread_mutex_unlock(&master->mutex);
-
Nio::stop();
-#ifndef DISABLE_GUI
- delete ui;
-#endif
+ GUI::destroyUi(gui);
+ delete middleware;
#if LASH
if(lash)
delete lash;
@@ -167,17 +132,17 @@ void exitprogram()
delete [] denormalkillbuf;
FFT_cleanup();
- Master::deleteInstance();
}
int main(int argc, char *argv[])
{
+ main_thread = (long int)syscall(224);
synth = new SYNTH_T;
config.init();
dump.startnow();
int noui = 0;
cerr
- << "\nZynAddSubFX - Copyright (c) 2002-2011 Nasca Octavian Paul and others"
+ << "\nZynAddSubFX - Copyright (c) 2002-2013 Nasca Octavian Paul and others"
<< endl;
cerr
<< " Copyright (c) 2009-2014 Mark McCurry [active maintainer]"
@@ -437,49 +402,18 @@ int main(int argc, char *argv[])
}
-#ifndef DISABLE_GUI
-
-#ifdef NTK_GUI
- fl_register_images();
-
- Fl_Tooltip::textcolor(0x0);
-
- Fl_Dial::default_style(Fl_Dial::PIXMAP_DIAL);
-
- if(Fl_Shared_Image *img = Fl_Shared_Image::get(PIXMAP_PATH "/knob.png"))
- Fl_Dial::default_image(img);
- else
- Fl_Dial::default_image(Fl_Shared_Image::get(SOURCE_DIR "/../pixmaps/knob.png"));
-
- if(Fl_Shared_Image *img = Fl_Shared_Image::get(PIXMAP_PATH "/window_backdrop.png"))
- Fl::scheme_bg(new Fl_Tiled_Image(img));
- else
- Fl::scheme_bg(new Fl_Tiled_Image(Fl_Shared_Image::get(SOURCE_DIR "/../pixmaps/window_backdrop.png")));
-
- if(Fl_Shared_Image *img = Fl_Shared_Image::get(PIXMAP_PATH "/module_backdrop.png"))
- module_backdrop = new Fl_Tiled_Image(img);
- else
- module_backdrop = new Fl_Tiled_Image(Fl_Shared_Image::get(SOURCE_DIR "/../pixmaps/module_backdrop.png"));
-
- Fl::background( 50, 50, 50 );
- Fl::background2( 70, 70, 70 );
- Fl::foreground( 255,255,255 );
-#endif
+ gui = GUI::createUi(middleware->spawnUiApi(), &Pexitprogram);
+ middleware->setUiCallback(GUI::raiseUi, gui);
+ middleware->setIdleCallback([](){GUI::tickUi(gui);});
- ui = new MasterUI(master, &Pexitprogram);
-
- if ( !noui)
+ if(!noui)
{
- ui->showUI();
-
+ GUI::raiseUi(gui, "/show", "T");
if(!ioGood)
- fl_alert(
- "Default IO did not initialize.\nDefaulting to NULL backend.");
+ GUI::raiseUi(gui, "/alert", "s",
+ "Default IO did not initialize.\nDefaulting to NULL backend.");
}
-#endif
-
-#ifndef DISABLE_GUI
#if USE_NSM
char *nsm_url = getenv("NSM_URL");
@@ -494,7 +428,6 @@ int main(int argc, char *argv[])
}
}
#endif
-#endif
#if USE_NSM
if(!nsm)
@@ -502,17 +435,11 @@ int main(int argc, char *argv[])
{
#if LASH
lash = new LASHClient(&argc, &argv);
-#ifndef DISABLE_GUI
- ui->sm_indicator1->value(1);
- ui->sm_indicator2->value(1);
- ui->sm_indicator1->tooltip("LASH");
- ui->sm_indicator2->tooltip("LASH");
-#endif
+ GUI::raiseUi(gui, "/session-type", "s", "LASH");
#endif
}
while(Pexitprogram == 0) {
-#ifndef DISABLE_GUI
#if USE_NSM
if(nsm) {
nsm->check();
@@ -524,11 +451,11 @@ int main(int argc, char *argv[])
string filename;
switch(lash->checkevents(filename)) {
case LASHClient::Save:
- ui->do_save_master(filename.c_str());
+ GUI::raiseUi(gui, "/save-master", "s", filename.c_str());
lash->confirmevent(LASHClient::Save);
break;
case LASHClient::Restore:
- ui->do_load_master(filename.c_str());
+ GUI::raiseUi(gui, "/load-master", "s", filename.c_str());
lash->confirmevent(LASHClient::Restore);
break;
case LASHClient::Quit:
@@ -542,11 +469,8 @@ int main(int argc, char *argv[])
#if USE_NSM
done:
#endif
-
- Fl::wait(0.02f);
-#else
- usleep(100000);
-#endif
+ GUI::tickUi(gui);
+ middleware->tick();
}
exitprogram();