diff --git a/.gitignore b/.gitignore
index ec15721..e840d19 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@ src/*.o
luppp
*.zip
+*.orig
build/*
buildTest/*
diff --git a/src/audiobuffer.cxx b/src/audiobuffer.cxx
index 06a99da..cb4f8e6 100644
--- a/src/audiobuffer.cxx
+++ b/src/audiobuffer.cxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -22,95 +22,94 @@
AudioBuffer::AudioBuffer()
{
- ID = privateID++;
- init();
+ ID = privateID++;
+ init();
}
AudioBuffer::AudioBuffer(unsigned long size)
{
- // FIXME recorded buffers don't get an ID, using garbage IDs
- /// no ID assigned: it *takes* the one from the previous buffer!
- init();
- buffer.resize(size);
+ // FIXME recorded buffers don't get an ID, using garbage IDs
+ /// no ID assigned: it *takes* the one from the previous buffer!
+ init();
+ buffer.resize(size);
}
-
+
void AudioBuffer::init()
{
- numBeats = 0;
- audioFrames = 0;
- memset( name, 0, sizeof(char)*20 );
- //sprintf( name, "%i", ID );
+ numBeats = 0;
+ audioFrames = 0;
+ memset( name, 0, sizeof(char)*20 );
+ //sprintf( name, "%i", ID );
}
/// this function is used for "resizing" an exisiting buffer, and should
/// not be called for any other reason.
void AudioBuffer::setID(int id)
{
- ID = id;
+ ID = id;
}
int AudioBuffer::getID()
{
- return ID;
+ return ID;
}
void AudioBuffer::setName(const char* n)
{
- memcpy( name, n, sizeof(char)* 19 );
-
- if ( strlen(n) > 19 )
- {
+ memcpy( name, n, sizeof(char)* 19 );
+
+ if ( strlen(n) > 19 ) {
#ifdef DEBUG_BUFFER
- cout << "AudioBuffer setName too long, truncating." << endl;
+ cout << "AudioBuffer setName too long, truncating." << endl;
#endif
- return;
- }
-
+ return;
+ }
+
}
char* AudioBuffer::getName()
{
- return name;
+ return name;
}
int AudioBuffer::getBeats()
{
- return numBeats;
+ return numBeats;
}
void AudioBuffer::setBeats(int b)
{
#ifdef DEBUG_BUFFER
- cout << "AudioBuffer now has " << b << " beats\n" << endl;
+ cout << "AudioBuffer now has " << b << " beats\n" << endl;
#endif
- numBeats = b;
+ numBeats = b;
}
void AudioBuffer::setAudioFrames(long af)
{
- audioFrames = af;
+ audioFrames = af;
#ifdef DEBUG_BUFFER
- cout << "AudioBuffer " << ID << " has " << audioFrames << " audioFrames\n" << endl;
+ cout << "AudioBuffer " << ID << " has " << audioFrames << " audioFrames\n" << endl;
#endif
}
long AudioBuffer::getAudioFrames()
{
- return audioFrames;
+ return audioFrames;
}
std::vector& AudioBuffer::getData()
{
- return buffer;
+ return buffer;
}
void AudioBuffer::nonRtSetSample(std::vector& sample)
{
- buffer.swap(sample);
+ buffer.swap(sample);
}
void AudioBuffer::nonRtResize(unsigned long size)
{
- buffer.resize(size);
+ buffer.resize(size);
}
/*
diff --git a/src/audiobuffer.hxx b/src/audiobuffer.hxx
index 2db923e..ff49fd6 100644
--- a/src/audiobuffer.hxx
+++ b/src/audiobuffer.hxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -30,49 +30,49 @@ using namespace std;
/// AudioBuffer stores float samples in a big vector.
class AudioBuffer
{
- public:
- AudioBuffer();
- AudioBuffer(unsigned long size);
-
- void init();
-
- /// this function is used for "resizing" an exisiting buffer, and should
- /// not be called for any other reason.
- void setID(int id);
-
- int getID();
- void setName(const char* n);
-
- char* getName();
- int getBeats();
-
- void setBeats(int b);
-
- void setAudioFrames(long af);
-
- long getAudioFrames();
-
- std::vector& getData();
-
- void nonRtSetSample(std::vector& sample);
-
- void nonRtResize(unsigned long size);
-
- //friend ostream& operator<<(ostream& o, const AudioBuffer& a);
-
- protected:
- static int privateID;
- int ID;
-
- int numBeats;
-
- /// holds the number of samples that are usable audio, as opposed to
- /// buffer.size(), which also has non-used space at the end.
- long audioFrames;
-
- char name[20];
-
- std::vector buffer;
+public:
+ AudioBuffer();
+ AudioBuffer(unsigned long size);
+
+ void init();
+
+ /// this function is used for "resizing" an exisiting buffer, and should
+ /// not be called for any other reason.
+ void setID(int id);
+
+ int getID();
+ void setName(const char* n);
+
+ char* getName();
+ int getBeats();
+
+ void setBeats(int b);
+
+ void setAudioFrames(long af);
+
+ long getAudioFrames();
+
+ std::vector& getData();
+
+ void nonRtSetSample(std::vector& sample);
+
+ void nonRtResize(unsigned long size);
+
+ //friend ostream& operator<<(ostream& o, const AudioBuffer& a);
+
+protected:
+ static int privateID;
+ int ID;
+
+ int numBeats;
+
+ /// holds the number of samples that are usable audio, as opposed to
+ /// buffer.size(), which also has non-used space at the end.
+ long audioFrames;
+
+ char name[20];
+
+ std::vector buffer;
};
#endif
diff --git a/src/audioprocessor.hxx b/src/audioprocessor.hxx
index 8bbd71f..520cbbf 100644
--- a/src/audioprocessor.hxx
+++ b/src/audioprocessor.hxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -25,25 +25,28 @@
class AudioProcessor
{
- public:
- AudioProcessor(){}
-
- /// copies the track output to master buffer, sidechain & post-side buffer
- virtual void process(unsigned int nframes, Buffers* buffers){printf("AudioProcessor::process() not derived\n");}
-
- /// set main mix, 0-1
- virtual void setMaster(float value){}
-
- /// set sidechain mix, 0-1
- virtual void setSidechain(float value){}
-
- /// set post sidechain mix, 0-1
- virtual void setPostSidechain(float value){}
-
- /// set reverb mix, 0-1
- virtual void setReverb(float value){}
-
- virtual ~AudioProcessor(){};
+public:
+ AudioProcessor() {}
+
+ /// copies the track output to master buffer, sidechain & post-side buffer
+ virtual void process(unsigned int nframes, Buffers* buffers)
+ {
+ printf("AudioProcessor::process() not derived\n");
+ }
+
+ /// set main mix, 0-1
+ virtual void setMaster(float value) {}
+
+ /// set sidechain mix, 0-1
+ virtual void setSidechain(float value) {}
+
+ /// set post sidechain mix, 0-1
+ virtual void setPostSidechain(float value) {}
+
+ /// set reverb mix, 0-1
+ virtual void setReverb(float value) {}
+
+ virtual ~AudioProcessor() {};
};
#endif // LUPPP_AUDIO_PROCESSOR_H
diff --git a/src/avtk/avtk_background.h b/src/avtk/avtk_background.h
index 9997e66..6fc07c0 100644
--- a/src/avtk/avtk_background.h
+++ b/src/avtk/avtk_background.h
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -32,134 +32,129 @@ namespace Avtk
// FIXME: Refactor to .hxx .cxx
class Background : public Fl_Widget
{
- public:
- Background(int _x, int _y, int _w, int _h, const char *_label = 0):
- Fl_Widget(_x, _y, _w, _h, _label)
- {
- x = _x;
- y = _y;
- w = _w;
- h = _h;
-
- label = strdup(_label);
-
- highlight = false;
- }
- bool highlight;
- int x, y, w, h;
- const char* label;
-
- void setLabel(const char* l)
- {
- if( label )
- free( (char*) label);
-
- label = strdup( l );
- redraw();
- }
- const char* getLabel()
- {
- return label;
- }
-
- void draw()
- {
- if (damage() & FL_DAMAGE_ALL)
- {
- cairo_t *cr = Fl::cairo_cc();
-
- cairo_save( cr );
-
- cairo_set_line_width(cr, 1.5);
-
-
- // fill background
- cairo_rectangle( cr, x, y, w, h);
- cairo_set_source_rgba( cr, 28 / 255.f, 28 / 255.f , 28 / 255.f , 1 );
- cairo_fill( cr );
-
- // draw header
- // backing
- cairo_rectangle(cr, x, y, w, 20);
- cairo_set_source_rgb( cr, 28 / 255.f, 28 / 255.f , 28 / 255.f );
- cairo_fill( cr );
-
- // text
- cairo_move_to( cr, x + 10, y + 14 );
- cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 );
- cairo_set_font_size( cr, 10 );
- cairo_show_text( cr, label );
-
- // lower stripe
- cairo_move_to( cr, x , y + 20 );
- cairo_line_to( cr, x + w, y + 20 );
- cairo_stroke( cr );
-
-
- // stroke rim
- cairo_rectangle(cr, x, y, w, h);
- cairo_set_source_rgba( cr, 66 / 255.f, 66 / 255.f , 66 / 255.f , 1 );
- cairo_stroke( cr );
-
-
- cairo_restore( cr );
- }
- }
-
- void resize(int X, int Y, int W, int H)
- {
- Fl_Widget::resize(X,Y,W,H);
- x = X;
- y = Y;
- w = W;
- h = H;
- redraw();
- }
-
- int handle(int event)
- {
- switch(event)
- {
- case FL_PUSH:
- if ( Fl::event_state(FL_BUTTON3) && Fl::event_y() < y + 20 )
- {
- const char* name = fl_input( "Track name: ", "" );
- if ( name )
- {
- free( (char*) label );
- label = strdup( name );
- redraw();
- }
- return 1;
- }
-
- redraw();
- return 1;
- case FL_DRAG: {
- int t = Fl::event_inside(this);
- if (t != highlight) {
- redraw();
- }
- }
- return 1;
- case FL_RELEASE:
- if (highlight) {
- highlight = 0;
- redraw();
- do_callback();
- }
- return 1;
- case FL_SHORTCUT:
- if ( test_shortcut() )
- {
- do_callback();
- return 1;
- }
- return 0;
- default:
- return Fl_Widget::handle(event);
- }
- }
+public:
+ Background(int _x, int _y, int _w, int _h, const char *_label = 0):
+ Fl_Widget(_x, _y, _w, _h, _label)
+ {
+ x = _x;
+ y = _y;
+ w = _w;
+ h = _h;
+
+ label = strdup(_label);
+
+ highlight = false;
+ }
+ bool highlight;
+ int x, y, w, h;
+ const char* label;
+
+ void setLabel(const char* l)
+ {
+ if( label )
+ free( (char*) label);
+
+ label = strdup( l );
+ redraw();
+ }
+ const char* getLabel()
+ {
+ return label;
+ }
+
+ void draw()
+ {
+ if (damage() & FL_DAMAGE_ALL) {
+ cairo_t *cr = Fl::cairo_cc();
+
+ cairo_save( cr );
+
+ cairo_set_line_width(cr, 1.5);
+
+
+ // fill background
+ cairo_rectangle( cr, x, y, w, h);
+ cairo_set_source_rgba( cr, 28 / 255.f, 28 / 255.f , 28 / 255.f , 1 );
+ cairo_fill( cr );
+
+ // draw header
+ // backing
+ cairo_rectangle(cr, x, y, w, 20);
+ cairo_set_source_rgb( cr, 28 / 255.f, 28 / 255.f , 28 / 255.f );
+ cairo_fill( cr );
+
+ // text
+ cairo_move_to( cr, x + 10, y + 14 );
+ cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 );
+ cairo_set_font_size( cr, 10 );
+ cairo_show_text( cr, label );
+
+ // lower stripe
+ cairo_move_to( cr, x , y + 20 );
+ cairo_line_to( cr, x + w, y + 20 );
+ cairo_stroke( cr );
+
+
+ // stroke rim
+ cairo_rectangle(cr, x, y, w, h);
+ cairo_set_source_rgba( cr, 66 / 255.f, 66 / 255.f , 66 / 255.f , 1 );
+ cairo_stroke( cr );
+
+
+ cairo_restore( cr );
+ }
+ }
+
+ void resize(int X, int Y, int W, int H)
+ {
+ Fl_Widget::resize(X,Y,W,H);
+ x = X;
+ y = Y;
+ w = W;
+ h = H;
+ redraw();
+ }
+
+ int handle(int event)
+ {
+ switch(event) {
+ case FL_PUSH:
+ if ( Fl::event_state(FL_BUTTON3) && Fl::event_y() < y + 20 ) {
+ const char* name = fl_input( "Track name: ", "" );
+ if ( name ) {
+ free( (char*) label );
+ label = strdup( name );
+ redraw();
+ }
+ return 1;
+ }
+
+ redraw();
+ return 1;
+ case FL_DRAG: {
+ int t = Fl::event_inside(this);
+ if (t != highlight) {
+ redraw();
+ }
+ }
+ return 1;
+ case FL_RELEASE:
+ if (highlight) {
+ highlight = 0;
+ redraw();
+ do_callback();
+ }
+ return 1;
+ case FL_SHORTCUT:
+ if ( test_shortcut() ) {
+ do_callback();
+ return 1;
+ }
+ return 0;
+ default:
+ return Fl_Widget::handle(event);
+ }
+ }
};
} // Avtk
diff --git a/src/avtk/avtk_box.h b/src/avtk/avtk_box.h
index 4efe59f..f36525b 100644
--- a/src/avtk/avtk_box.h
+++ b/src/avtk/avtk_box.h
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -28,84 +28,83 @@ namespace Avtk
// FIXME: Refactor to .hxx .cxx
class Box : public Fl_Widget
{
- public:
- Box(int _x, int _y, int _w, int _h, const char *_label = 0):
- Fl_Widget(_x, _y, _w, _h, _label)
- {
- x = _x;
- y = _y;
- w = _w;
- h = _h;
-
- r = g = b = 0;
-
- label = strdup(_label);
-
- highlight = false;
- }
- bool highlight;
- int x, y, w, h;
- const char* label;
-
- int r,g,b;
-
- void setLabel(const char* l)
- {
- if( label )
- free( (char*) label);
-
- label = strdup( l );
- redraw();
- }
- const char* getLabel()
- {
- return label;
- }
-
- void setColor( int red, int green, int blue )
- {
- r = red;
- g = green;
- b = blue;
-
- redraw();
- }
-
- void draw()
- {
- if (damage() & FL_DAMAGE_ALL)
- {
- cairo_t *cr = Fl::cairo_cc();
-
- cairo_save( cr );
-
- cairo_set_line_width(cr, 1.5);
-
- // fill background
- cairo_rectangle( cr, x, y, w, h);
- cairo_set_source_rgba( cr, r, g, b, 1 );
- cairo_fill( cr );
-
- /*
- // stroke rim
- cairo_rectangle(cr, x, y, w, h);
- cairo_set_source_rgba( cr, 66 / 255.f, 66 / 255.f , 66 / 255.f , 1 );
- cairo_stroke( cr );
- */
-
- cairo_restore( cr );
- }
- }
-
- void resize(int X, int Y, int W, int H)
- {
- Fl_Widget::resize(X,Y,W,H);
- x = X;
- y = Y;
- w = W;
- h = H;
- redraw();
- }
+public:
+ Box(int _x, int _y, int _w, int _h, const char *_label = 0):
+ Fl_Widget(_x, _y, _w, _h, _label)
+ {
+ x = _x;
+ y = _y;
+ w = _w;
+ h = _h;
+
+ r = g = b = 0;
+
+ label = strdup(_label);
+
+ highlight = false;
+ }
+ bool highlight;
+ int x, y, w, h;
+ const char* label;
+
+ int r,g,b;
+
+ void setLabel(const char* l)
+ {
+ if( label )
+ free( (char*) label);
+
+ label = strdup( l );
+ redraw();
+ }
+ const char* getLabel()
+ {
+ return label;
+ }
+
+ void setColor( int red, int green, int blue )
+ {
+ r = red;
+ g = green;
+ b = blue;
+
+ redraw();
+ }
+
+ void draw()
+ {
+ if (damage() & FL_DAMAGE_ALL) {
+ cairo_t *cr = Fl::cairo_cc();
+
+ cairo_save( cr );
+
+ cairo_set_line_width(cr, 1.5);
+
+ // fill background
+ cairo_rectangle( cr, x, y, w, h);
+ cairo_set_source_rgba( cr, r, g, b, 1 );
+ cairo_fill( cr );
+
+ /*
+ // stroke rim
+ cairo_rectangle(cr, x, y, w, h);
+ cairo_set_source_rgba( cr, 66 / 255.f, 66 / 255.f , 66 / 255.f , 1 );
+ cairo_stroke( cr );
+ */
+
+ cairo_restore( cr );
+ }
+ }
+
+ void resize(int X, int Y, int W, int H)
+ {
+ Fl_Widget::resize(X,Y,W,H);
+ x = X;
+ y = Y;
+ w = W;
+ h = H;
+ redraw();
+ }
};
} // Avtk
diff --git a/src/avtk/avtk_button.h b/src/avtk/avtk_button.h
index a77030a..3fe7996 100644
--- a/src/avtk/avtk_button.h
+++ b/src/avtk/avtk_button.h
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -27,174 +27,170 @@ namespace Avtk
class Button : public Fl_Button
{
- public:
- Button(int _x, int _y, int _w, int _h, const char *_label):
- Fl_Button(_x, _y, _w, _h, _label)
- {
- x = _x;
- y = _y;
- w = _w;
- h = _h;
-
- labelMe = _label;
- setLabel( labelMe );
-
- _r = 1.0;
- _g = 0.48;
- _b = 0.0;
-
- _bgr = 0.11;
- _bgg = 0.11;
- _bgb = 0.11;
-
- highlight = false;
- mouseOver = false;
-
- greyedOut = false;
- }
-
- void setGreyOut( bool g )
- {
- greyedOut = g;
- }
-
- bool greyedOut;
-
- bool mouseOver;
- bool highlight;
- int x, y, w, h;
- const char* labelMe;
-
- void setLabel( const char* l)
- {
- labelMe = l;
- label( labelMe );
- redraw();
- }
-
- float _r, _g, _b; // foreground colour
- float _bgr, _bgg, _bgb; // background colour
- float _outr, _outg, _outb; // outline colour
-
- void setColor(float r, float g, float b)
- {
- _r = r;
- _g = g;
- _b = b;
- }
-
- void setBgColor(float r, float g, float b)
- {
- _bgr = r;
- _bgg = g;
- _bgb = b;
- }
-
- void setHighlight(bool b)
- {
- highlight = b; redraw();
- }
-
- void draw()
- {
- if (damage() & FL_DAMAGE_ALL)
- {
- cairo_t *cr = Fl::cairo_cc();
-
- cairo_save( cr );
-
- cairo_rectangle( cr, x+1, y+1, w-2, h-2 );
- if ( !greyedOut )
- cairo_set_source_rgb( cr, _bgr, _bgg, _bgb );
- else
- {
- float grey = (_bgr + _bgg + _bgb) / 3;
- cairo_set_source_rgb( cr, grey, grey, grey );
- }
- cairo_fill_preserve(cr);
-
- cairo_set_line_width(cr, 1.3);
- cairo_rectangle( cr, x+1, y+1, w-2, h-2 );
-
- if ( highlight && !greyedOut )
- {
- cairo_set_source_rgba(cr, _r, _g, _b, 0.4);
- cairo_fill_preserve(cr);
- }
-
- float alpha = 0.6;
- if (mouseOver)
- alpha = 1;
-
- if ( !greyedOut )
- cairo_set_source_rgba(cr, _r, _g, _b, alpha);
- else
- {
- float grey = (_r + _g + _b) / 3;
- cairo_set_source_rgb( cr, grey, grey, grey );
- }
-
- if ( highlight && !greyedOut )
- cairo_set_line_width(cr, 2.2);
- cairo_stroke(cr);
-
- cairo_restore( cr );
-
- draw_label();
- }
- }
-
- void resize(int X, int Y, int W, int H)
- {
- Fl_Widget::resize(X,Y,W,H);
- x = X;
- y = Y;
- w = W;
- h = H;
- redraw();
- }
-
- int handle(int event)
- {
- switch(event) {
- case FL_PUSH:
- highlight = 1;
- redraw();
- return 1;
- case FL_DRAG: {
- int t = Fl::event_inside(this);
- if (t != highlight) {
- highlight = t;
- redraw();
- }
- }
- return 1;
- case FL_ENTER:
- mouseOver = true;
- redraw();
- return 1;
- case FL_LEAVE:
- mouseOver = false;
- redraw();
- return 1;
- case FL_RELEASE:
- if (highlight) {
- highlight = 0;
- redraw();
- do_callback();
- }
- return 1;
- case FL_SHORTCUT:
- if ( test_shortcut() )
- {
- do_callback();
- return 1;
- }
- return 0;
- default:
- return Fl_Widget::handle(event);
- }
- }
+public:
+ Button(int _x, int _y, int _w, int _h, const char *_label):
+ Fl_Button(_x, _y, _w, _h, _label)
+ {
+ x = _x;
+ y = _y;
+ w = _w;
+ h = _h;
+
+ labelMe = _label;
+ setLabel( labelMe );
+
+ _r = 1.0;
+ _g = 0.48;
+ _b = 0.0;
+
+ _bgr = 0.11;
+ _bgg = 0.11;
+ _bgb = 0.11;
+
+ highlight = false;
+ mouseOver = false;
+
+ greyedOut = false;
+ }
+
+ void setGreyOut( bool g )
+ {
+ greyedOut = g;
+ }
+
+ bool greyedOut;
+
+ bool mouseOver;
+ bool highlight;
+ int x, y, w, h;
+ const char* labelMe;
+
+ void setLabel( const char* l)
+ {
+ labelMe = l;
+ label( labelMe );
+ redraw();
+ }
+
+ float _r, _g, _b; // foreground colour
+ float _bgr, _bgg, _bgb; // background colour
+ float _outr, _outg, _outb; // outline colour
+
+ void setColor(float r, float g, float b)
+ {
+ _r = r;
+ _g = g;
+ _b = b;
+ }
+
+ void setBgColor(float r, float g, float b)
+ {
+ _bgr = r;
+ _bgg = g;
+ _bgb = b;
+ }
+
+ void setHighlight(bool b)
+ {
+ highlight = b;
+ redraw();
+ }
+
+ void draw()
+ {
+ if (damage() & FL_DAMAGE_ALL) {
+ cairo_t *cr = Fl::cairo_cc();
+
+ cairo_save( cr );
+
+ cairo_rectangle( cr, x+1, y+1, w-2, h-2 );
+ if ( !greyedOut )
+ cairo_set_source_rgb( cr, _bgr, _bgg, _bgb );
+ else {
+ float grey = (_bgr + _bgg + _bgb) / 3;
+ cairo_set_source_rgb( cr, grey, grey, grey );
+ }
+ cairo_fill_preserve(cr);
+
+ cairo_set_line_width(cr, 1.3);
+ cairo_rectangle( cr, x+1, y+1, w-2, h-2 );
+
+ if ( highlight && !greyedOut ) {
+ cairo_set_source_rgba(cr, _r, _g, _b, 0.4);
+ cairo_fill_preserve(cr);
+ }
+
+ float alpha = 0.6;
+ if (mouseOver)
+ alpha = 1;
+
+ if ( !greyedOut )
+ cairo_set_source_rgba(cr, _r, _g, _b, alpha);
+ else {
+ float grey = (_r + _g + _b) / 3;
+ cairo_set_source_rgb( cr, grey, grey, grey );
+ }
+
+ if ( highlight && !greyedOut )
+ cairo_set_line_width(cr, 2.2);
+ cairo_stroke(cr);
+
+ cairo_restore( cr );
+
+ draw_label();
+ }
+ }
+
+ void resize(int X, int Y, int W, int H)
+ {
+ Fl_Widget::resize(X,Y,W,H);
+ x = X;
+ y = Y;
+ w = W;
+ h = H;
+ redraw();
+ }
+
+ int handle(int event)
+ {
+ switch(event) {
+ case FL_PUSH:
+ highlight = 1;
+ redraw();
+ return 1;
+ case FL_DRAG: {
+ int t = Fl::event_inside(this);
+ if (t != highlight) {
+ highlight = t;
+ redraw();
+ }
+ }
+ return 1;
+ case FL_ENTER:
+ mouseOver = true;
+ redraw();
+ return 1;
+ case FL_LEAVE:
+ mouseOver = false;
+ redraw();
+ return 1;
+ case FL_RELEASE:
+ if (highlight) {
+ highlight = 0;
+ redraw();
+ do_callback();
+ }
+ return 1;
+ case FL_SHORTCUT:
+ if ( test_shortcut() ) {
+ do_callback();
+ return 1;
+ }
+ return 0;
+ default:
+ return Fl_Widget::handle(event);
+ }
+ }
};
} // Avtk
diff --git a/src/avtk/avtk_dial.h b/src/avtk/avtk_dial.h
index 72fa357..7f9e310 100644
--- a/src/avtk/avtk_dial.h
+++ b/src/avtk/avtk_dial.h
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -29,174 +29,168 @@ namespace Avtk
class Dial : public Fl_Slider
{
- public:
- Dial(int _x, int _y, int _w, int _h, const char* _lab=0):
- Fl_Slider(_x, _y, _w, _h, _lab)
- {
- x = _x;
- y = _y;
- w = _w;
- h = _h;
-
- drawLabel = true;
-
- mouseClickedY = 0;
- mouseClicked = false;
-
- highlight = false;
- _label = strdup( _lab );
- }
-
- ~Dial()
- {
- if( _label )
- free( _label );
- }
-
- bool highlight;
- int x, y, w, h;
- char* _label;
-
- float radius;
- float lineWidth;
-
- int mouseClickedY;
- bool mouseClicked;
-
- bool drawLabel;
-
- void setLabel( const char* newLabel )
- {
- if( _label )
- free( _label );
-
- _label = strdup( newLabel );
-
- label( _label );
- redraw();
- }
-
- void draw()
- {
- if (damage() & FL_DAMAGE_ALL)
- {
- if ( drawLabel )
- {
- draw_label();
- }
-
- // * 0.9 for line width to remain inside redraw area
- if ( w > h )
- radius = (h / 2.f)*0.9;
- else
- radius = (w / 2.f)*0.9;
-
- lineWidth = 1.4 + radius / 12.f;
-
- cairo_t *cr = Fl::cairo_cc();
-
- cairo_save( cr );
-
- cairo_rectangle( cr, x, y, w, h );
- cairo_set_source_rgba(cr, 1.1, 0.1, 0.1, 0 );
- cairo_fill(cr);
-
- cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND);
- cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
-
- cairo_set_line_width(cr, lineWidth-0.2);
- cairo_move_to( cr, x+w/2,y+h/2);
- cairo_line_to( cr, x+w/2,y+h/2);
- cairo_set_source_rgba(cr, 0.1, 0.1, 0.1, 0 );
- cairo_stroke(cr);
-
- cairo_arc(cr, x+w/2,y+h/2, radius, 2.46, 0.75 );
- cairo_set_source_rgb(cr, 0.1, 0.1, 0.1 );
- cairo_stroke(cr);
-
- float angle = 2.46 + ( 4.54 * value() );
- cairo_set_line_width(cr, lineWidth);
- cairo_arc(cr, x+w/2,y+h/2, radius, 2.46, angle );
- cairo_line_to(cr, x+w/2,y+h/2);
- cairo_set_source_rgba(cr, 1.0, 0.48, 0, 0.8);
- cairo_stroke(cr);
-
- cairo_restore( cr );
- }
- }
-
- void resize(int X, int Y, int W, int H)
- {
- Fl_Slider::resize(X,Y,W,H);
- x = X;
- y = Y;
- w = W;
- h = H;
- redraw();
- }
-
- int handle(int event)
- {
- //cout << "handle event type = " << event << " value = " << value() << endl;
-
- //Fl_Slider::handle( event );
-
- switch(event) {
- case FL_PUSH:
- highlight = 1;
- redraw();
- return 1;
- case FL_DRAG:
- {
- if ( Fl::event_state(FL_BUTTON1) )
- {
- if ( mouseClicked == false ) // catch the "click" event
- {
- mouseClickedY = Fl::event_y();
- mouseClicked = true;
- }
-
- float deltaY = mouseClickedY - Fl::event_y();
-
- float val = value();
- val += deltaY / 100.f;
-
- if ( val > 1.0 ) val = 1.0;
- if ( val < 0.0 ) val = 0.0;
-
- set_value( val );
-
- mouseClickedY = Fl::event_y();
- redraw();
- do_callback(); // makes FLTK call "extra" code entered in FLUID
- }
- }
- return 1;
- case FL_MOUSEWHEEL:
- {
- float val = value() - Fl::event_dy() * 0.1;
- //printf("dial scroll event: %f\n", val);
- if ( val > 1.0 ) val = 1.0;
- if ( val < 0.0 ) val = 0.0;
- set_value( val );
- redraw();
- do_callback();
- return 1;
- }
- break;
- case FL_RELEASE:
- if (highlight) {
- highlight = 0;
- redraw();
- // never do anything after a callback, as the callback
- // may delete the widget!
- }
- mouseClicked = false;
- return 1;
- default:
- return Fl_Widget::handle(event);
- }
- }
+public:
+ Dial(int _x, int _y, int _w, int _h, const char* _lab=0):
+ Fl_Slider(_x, _y, _w, _h, _lab)
+ {
+ x = _x;
+ y = _y;
+ w = _w;
+ h = _h;
+
+ drawLabel = true;
+
+ mouseClickedY = 0;
+ mouseClicked = false;
+
+ highlight = false;
+ _label = strdup( _lab );
+ }
+
+ ~Dial()
+ {
+ if( _label )
+ free( _label );
+ }
+
+ bool highlight;
+ int x, y, w, h;
+ char* _label;
+
+ float radius;
+ float lineWidth;
+
+ int mouseClickedY;
+ bool mouseClicked;
+
+ bool drawLabel;
+
+ void setLabel( const char* newLabel )
+ {
+ if( _label )
+ free( _label );
+
+ _label = strdup( newLabel );
+
+ label( _label );
+ redraw();
+ }
+
+ void draw()
+ {
+ if (damage() & FL_DAMAGE_ALL) {
+ if ( drawLabel ) {
+ draw_label();
+ }
+
+ // * 0.9 for line width to remain inside redraw area
+ if ( w > h )
+ radius = (h / 2.f)*0.9;
+ else
+ radius = (w / 2.f)*0.9;
+
+ lineWidth = 1.4 + radius / 12.f;
+
+ cairo_t *cr = Fl::cairo_cc();
+
+ cairo_save( cr );
+
+ cairo_rectangle( cr, x, y, w, h );
+ cairo_set_source_rgba(cr, 1.1, 0.1, 0.1, 0 );
+ cairo_fill(cr);
+
+ cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND);
+ cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
+
+ cairo_set_line_width(cr, lineWidth-0.2);
+ cairo_move_to( cr, x+w/2,y+h/2);
+ cairo_line_to( cr, x+w/2,y+h/2);
+ cairo_set_source_rgba(cr, 0.1, 0.1, 0.1, 0 );
+ cairo_stroke(cr);
+
+ cairo_arc(cr, x+w/2,y+h/2, radius, 2.46, 0.75 );
+ cairo_set_source_rgb(cr, 0.1, 0.1, 0.1 );
+ cairo_stroke(cr);
+
+ float angle = 2.46 + ( 4.54 * value() );
+ cairo_set_line_width(cr, lineWidth);
+ cairo_arc(cr, x+w/2,y+h/2, radius, 2.46, angle );
+ cairo_line_to(cr, x+w/2,y+h/2);
+ cairo_set_source_rgba(cr, 1.0, 0.48, 0, 0.8);
+ cairo_stroke(cr);
+
+ cairo_restore( cr );
+ }
+ }
+
+ void resize(int X, int Y, int W, int H)
+ {
+ Fl_Slider::resize(X,Y,W,H);
+ x = X;
+ y = Y;
+ w = W;
+ h = H;
+ redraw();
+ }
+
+ int handle(int event)
+ {
+ //cout << "handle event type = " << event << " value = " << value() << endl;
+
+ //Fl_Slider::handle( event );
+
+ switch(event) {
+ case FL_PUSH:
+ highlight = 1;
+ redraw();
+ return 1;
+ case FL_DRAG: {
+ if ( Fl::event_state(FL_BUTTON1) ) {
+ if ( mouseClicked == false ) { // catch the "click" event
+ mouseClickedY = Fl::event_y();
+ mouseClicked = true;
+ }
+
+ float deltaY = mouseClickedY - Fl::event_y();
+
+ float val = value();
+ val += deltaY / 100.f;
+
+ if ( val > 1.0 ) val = 1.0;
+ if ( val < 0.0 ) val = 0.0;
+
+ set_value( val );
+
+ mouseClickedY = Fl::event_y();
+ redraw();
+ do_callback(); // makes FLTK call "extra" code entered in FLUID
+ }
+ }
+ return 1;
+ case FL_MOUSEWHEEL: {
+ float val = value() - Fl::event_dy() * 0.1;
+ //printf("dial scroll event: %f\n", val);
+ if ( val > 1.0 ) val = 1.0;
+ if ( val < 0.0 ) val = 0.0;
+ set_value( val );
+ redraw();
+ do_callback();
+ return 1;
+ }
+ break;
+ case FL_RELEASE:
+ if (highlight) {
+ highlight = 0;
+ redraw();
+ // never do anything after a callback, as the callback
+ // may delete the widget!
+ }
+ mouseClicked = false;
+ return 1;
+ default:
+ return Fl_Widget::handle(event);
+ }
+ }
};
} // Avtk
diff --git a/src/avtk/avtk_image.h b/src/avtk/avtk_image.h
index c73b398..09fe8c0 100644
--- a/src/avtk/avtk_image.h
+++ b/src/avtk/avtk_image.h
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -38,78 +38,74 @@ namespace Avtk
class Image : public Fl_Widget
{
- public:
- Image(int _x, int _y, int _w, int _h, const char *_label=0 ):
- Fl_Widget(_x, _y, _w, _h, _label)
- {
- x = _x;
- y = _y;
- w = _w;
- h = _h;
-
- label = _label;
-
- bits = -1;
- imageDataPtr = 0;
-
- stickToRight = false;
- }
-
- // used to keep images on the right hand side of the window
- bool stickToRight;
-
- void setPixbuf(const unsigned char* data, int b )
- {
- bits = b;
- imageDataPtr = data;
- }
-
- int x, y, w, h;
- const char* label;
-
- int bits;
- const unsigned char* imageDataPtr;
-
- void draw()
- {
- if ( damage() & FL_DAMAGE_ALL && imageDataPtr != 0 )
- {
- fl_draw_image((const uchar*)imageDataPtr, x, y, w, h, bits, w*bits);
- }
- }
-
- void resize(int X, int Y, int W, int H)
- {
- if ( stickToRight )
- {
- x = gui->getWindowWidth() - w;
- }
-
- redraw();
- }
-
- int handle(int event)
- {
- switch(event)
- {
- case FL_PUSH:
- do_callback();
- return 1;
- case FL_DRAG:
- return 1;
- case FL_RELEASE:
- return 1;
- case FL_SHORTCUT:
- if ( test_shortcut() )
- {
- do_callback();
- return 1;
- }
- return 0;
- default:
- return Fl_Widget::handle(event);
- }
- }
+public:
+ Image(int _x, int _y, int _w, int _h, const char *_label=0 ):
+ Fl_Widget(_x, _y, _w, _h, _label)
+ {
+ x = _x;
+ y = _y;
+ w = _w;
+ h = _h;
+
+ label = _label;
+
+ bits = -1;
+ imageDataPtr = 0;
+
+ stickToRight = false;
+ }
+
+ // used to keep images on the right hand side of the window
+ bool stickToRight;
+
+ void setPixbuf(const unsigned char* data, int b )
+ {
+ bits = b;
+ imageDataPtr = data;
+ }
+
+ int x, y, w, h;
+ const char* label;
+
+ int bits;
+ const unsigned char* imageDataPtr;
+
+ void draw()
+ {
+ if ( damage() & FL_DAMAGE_ALL && imageDataPtr != 0 ) {
+ fl_draw_image((const uchar*)imageDataPtr, x, y, w, h, bits, w*bits);
+ }
+ }
+
+ void resize(int X, int Y, int W, int H)
+ {
+ if ( stickToRight ) {
+ x = gui->getWindowWidth() - w;
+ }
+
+ redraw();
+ }
+
+ int handle(int event)
+ {
+ switch(event) {
+ case FL_PUSH:
+ do_callback();
+ return 1;
+ case FL_DRAG:
+ return 1;
+ case FL_RELEASE:
+ return 1;
+ case FL_SHORTCUT:
+ if ( test_shortcut() ) {
+ do_callback();
+ return 1;
+ }
+ return 0;
+ default:
+ return Fl_Widget::handle(event);
+ }
+ }
};
} // Avtk
diff --git a/src/avtk/avtk_light_button.h b/src/avtk/avtk_light_button.h
index df91400..441a1ca 100644
--- a/src/avtk/avtk_light_button.h
+++ b/src/avtk/avtk_light_button.h
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -27,152 +27,144 @@ namespace Avtk
class LightButton : public Fl_Button
{
- public:
- LightButton(int _x, int _y, int _w, int _h, const char *_label):
- Fl_Button(_x, _y, _w, _h, _label)
- {
- x = _x;
- y = _y;
- w = _w;
- h = _h;
-
- _r = 1.0;
- _g = 0.48;
- _b = 0.0;
-
- _bgr = 0.11;
- _bgg = 0.11;
- _bgb = 0.11;
-
- _outr = _r;
- _outg = _g;
- _outb = _b;
-
- label = _label;
-
- _highlight = false;
- mouseOver = false;
- }
-
- bool mouseOver;
- bool _highlight;
- int x, y, w, h;
- const char* label;
- float _r, _g, _b; // foreground colour
- float _bgr, _bgg, _bgb; // background colour
- float _outr, _outg, _outb; // outline colour
-
- void setColor(float r, float g, float b)
- {
- _r = r;
- _g = g;
- _b = b;
- }
-
- void setBgColor(float r, float g, float b)
- {
- _bgr = r;
- _bgg = g;
- _bgb = b;
- }
-
- void draw()
- {
- if (damage() & FL_DAMAGE_ALL)
- {
- if ( value() )
- {
- _highlight = true;
- }
- else
- {
- _highlight = false;
- }
-
- cairo_t *cr = Fl::cairo_cc();
-
- cairo_save( cr );
-
- cairo_rectangle( cr, x+1, y+1, w-2, h-2 );
- cairo_set_source_rgba( cr, _bgr, _bgg, _bgb, 0.4 );
- cairo_fill_preserve(cr);
-
- cairo_set_line_width(cr, 1.5);
- cairo_rectangle( cr, x+1, y+1, w-2, h-2 );
-
- if ( _highlight )
- {
- cairo_set_source_rgba(cr, _r, _g, _b, 0.4);
- cairo_fill_preserve(cr);
- }
-
- float alpha = 0.7;
- if (mouseOver)
- alpha = 1;
- cairo_set_source_rgba(cr, _r, _g, _b, alpha);
- cairo_stroke(cr);
-
- cairo_restore( cr );
-
- draw_label();
- }
- }
-
- void resize(int X, int Y, int W, int H)
- {
- Fl_Widget::resize(X,Y,W,H);
- x = X;
- y = Y;
- w = W;
- h = H;
- redraw();
- }
-
-
-
- int handle(int event)
- {
- switch(event) {
- case FL_ACTIVATE:
- {
- }
- case FL_DEACTIVATE:
- {
- }
- return 1;
- case FL_PUSH:
-
- do_callback();
- return 1;
- case FL_DRAG: {
- int t = Fl::event_inside(this);
- if (t != _highlight) {
- _highlight = t;
- redraw();
- }
- }
- return 1;
- case FL_ENTER:
- mouseOver = true;
- redraw();
- return 1;
- case FL_LEAVE:
- mouseOver = false;
- redraw();
- return 1;
- case FL_RELEASE:
- return 1;
- case FL_SHORTCUT:
- if ( test_shortcut() )
- {
- do_callback();
- return 1;
- }
- return 0;
- default:
- return Fl_Widget::handle(event);
- }
- }
+public:
+ LightButton(int _x, int _y, int _w, int _h, const char *_label):
+ Fl_Button(_x, _y, _w, _h, _label)
+ {
+ x = _x;
+ y = _y;
+ w = _w;
+ h = _h;
+
+ _r = 1.0;
+ _g = 0.48;
+ _b = 0.0;
+
+ _bgr = 0.11;
+ _bgg = 0.11;
+ _bgb = 0.11;
+
+ _outr = _r;
+ _outg = _g;
+ _outb = _b;
+
+ label = _label;
+
+ _highlight = false;
+ mouseOver = false;
+ }
+
+ bool mouseOver;
+ bool _highlight;
+ int x, y, w, h;
+ const char* label;
+ float _r, _g, _b; // foreground colour
+ float _bgr, _bgg, _bgb; // background colour
+ float _outr, _outg, _outb; // outline colour
+
+ void setColor(float r, float g, float b)
+ {
+ _r = r;
+ _g = g;
+ _b = b;
+ }
+
+ void setBgColor(float r, float g, float b)
+ {
+ _bgr = r;
+ _bgg = g;
+ _bgb = b;
+ }
+
+ void draw()
+ {
+ if (damage() & FL_DAMAGE_ALL) {
+ if ( value() ) {
+ _highlight = true;
+ } else {
+ _highlight = false;
+ }
+
+ cairo_t *cr = Fl::cairo_cc();
+
+ cairo_save( cr );
+
+ cairo_rectangle( cr, x+1, y+1, w-2, h-2 );
+ cairo_set_source_rgba( cr, _bgr, _bgg, _bgb, 0.4 );
+ cairo_fill_preserve(cr);
+
+ cairo_set_line_width(cr, 1.5);
+ cairo_rectangle( cr, x+1, y+1, w-2, h-2 );
+
+ if ( _highlight ) {
+ cairo_set_source_rgba(cr, _r, _g, _b, 0.4);
+ cairo_fill_preserve(cr);
+ }
+
+ float alpha = 0.7;
+ if (mouseOver)
+ alpha = 1;
+ cairo_set_source_rgba(cr, _r, _g, _b, alpha);
+ cairo_stroke(cr);
+
+ cairo_restore( cr );
+
+ draw_label();
+ }
+ }
+
+ void resize(int X, int Y, int W, int H)
+ {
+ Fl_Widget::resize(X,Y,W,H);
+ x = X;
+ y = Y;
+ w = W;
+ h = H;
+ redraw();
+ }
+
+
+
+ int handle(int event)
+ {
+ switch(event) {
+ case FL_ACTIVATE: {
+ }
+ case FL_DEACTIVATE: {
+ }
+ return 1;
+ case FL_PUSH:
+
+ do_callback();
+ return 1;
+ case FL_DRAG: {
+ int t = Fl::event_inside(this);
+ if (t != _highlight) {
+ _highlight = t;
+ redraw();
+ }
+ }
+ return 1;
+ case FL_ENTER:
+ mouseOver = true;
+ redraw();
+ return 1;
+ case FL_LEAVE:
+ mouseOver = false;
+ redraw();
+ return 1;
+ case FL_RELEASE:
+ return 1;
+ case FL_SHORTCUT:
+ if ( test_shortcut() ) {
+ do_callback();
+ return 1;
+ }
+ return 0;
+ default:
+ return Fl_Widget::handle(event);
+ }
+ }
};
} // Avtk
diff --git a/src/avtk/avtk_radial_status.h b/src/avtk/avtk_radial_status.h
index 8e5c32e..29227e9 100644
--- a/src/avtk/avtk_radial_status.h
+++ b/src/avtk/avtk_radial_status.h
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -27,173 +27,172 @@ namespace Avtk
class RadialStatus : public Fl_Slider
{
- public:
- RadialStatus(int _x, int _y, int _w, int _h, const char *_label = 0):
- Fl_Slider(_x, _y, _w, _h, _label)
- {
- x = _x;
- y = _y;
- w = _w;
- h = _h;
-
- label = _label;
-
- previousAngle = -1;
-
- _r = 1.0;
- _g = 0.48;
- _b = 0.0;
-
- _bgr = 0.11;
- _bgg = 0.11;
- _bgb = 0.11;
-
- highlight = false;
- mouseOver = false;
-
- _recording = false;
- }
-
- bool _recording;
- void recording(bool r){_recording = r; redraw();}
-
- bool mouseOver;
- bool highlight;
- int x, y, w, h;
- const char* label;
-
- int previousAngle;
-
- float _r, _g, _b; // foreground colour
- float _bgr, _bgg, _bgb; // background colour
- float _outr, _outg, _outb; // outline colour
-
- void setColor(float r, float g, float b)
- {
- _r = r;
- _g = g;
- _b = b;
- }
-
- void setBgColor(float r, float g, float b)
- {
- _bgr = r;
- _bgg = g;
- _bgb = b;
- }
-
- void draw()
- {
- // check that its a new "segment" to redraw
- int newAngle = (value() * 16);
-
- if (damage() & FL_DAMAGE_ALL &&
- previousAngle != newAngle )
- {
- cairo_t *cr = Fl::cairo_cc();
-
- cairo_save( cr );
-
- int xc = (w) / 2.f;
- int yc = (h) / 2.f;
-
- int radius = xc > yc ? yc : xc;
- radius -= 10;
-
- float angle = newAngle / 16.f;
-
- cairo_set_line_cap ( cr, CAIRO_LINE_CAP_ROUND );
- //cairo_move_to( cr, x + xc, y + yc );
- cairo_arc( cr, x + xc, y + yc, radius, -(3.1415/2), angle * 6.28 - (3.1415/2) );
- cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.5 );
- cairo_set_line_width(cr, 12);
- cairo_stroke_preserve(cr);
-
- cairo_set_source_rgba (cr, 1.0, 0.48, 0.0, 1 );
- cairo_set_line_width(cr, 8.2);
- cairo_stroke(cr);
-
-
- // recording?
- if ( _recording )
- {
- cairo_set_source_rgba(cr,1.0,0.0,0.0, 0.8);
- cairo_arc(cr, x + xc, y + yc, radius-4, 0, 2 * 3.1415);
- cairo_fill_preserve(cr);
- cairo_set_source_rgba(cr,0.0,0.0,0.0, 0.8);
- cairo_set_line_width(cr, 2.2);
- cairo_stroke(cr);
-
- // color of internal dot depending on rec state
- cairo_set_source_rgba(cr,0.0,0.0,0.0, 1);
- }
- else
- {
- cairo_set_source_rgba(cr,0.3,0.3,0.3, 1);
- }
-
- // inside circle
- cairo_arc(cr, x + xc, y + yc, 10, 0, 2 * 3.1415);
- cairo_set_line_width(cr, 4.2);
- cairo_fill(cr);
-
- cairo_restore( cr );
-
- draw_label();
- }
- }
-
- void resize(int X, int Y, int W, int H)
- {
- Fl_Widget::resize(X,Y,W,H);
- x = X;
- y = Y;
- w = W;
- h = H;
- redraw();
- }
-
- int handle(int event)
- {
- switch(event) {
- case FL_PUSH:
- highlight = 1;
- redraw();
- return 1;
- case FL_DRAG: {
- int t = Fl::event_inside(this);
- if (t != highlight) {
- highlight = t;
- redraw();
- }
- }
- return 1;
- case FL_ENTER:
- mouseOver = true;
- redraw();
- return 1;
- case FL_LEAVE:
- mouseOver = false;
- redraw();
- return 1;
- case FL_RELEASE:
- if (highlight) {
- highlight = 0;
- redraw();
- do_callback();
- }
- return 1;
- case FL_SHORTCUT:
- if ( test_shortcut() )
- {
- do_callback();
- return 1;
- }
- return 0;
- default:
- return Fl_Widget::handle(event);
- }
- }
+public:
+ RadialStatus(int _x, int _y, int _w, int _h, const char *_label = 0):
+ Fl_Slider(_x, _y, _w, _h, _label)
+ {
+ x = _x;
+ y = _y;
+ w = _w;
+ h = _h;
+
+ label = _label;
+
+ previousAngle = -1;
+
+ _r = 1.0;
+ _g = 0.48;
+ _b = 0.0;
+
+ _bgr = 0.11;
+ _bgg = 0.11;
+ _bgb = 0.11;
+
+ highlight = false;
+ mouseOver = false;
+
+ _recording = false;
+ }
+
+ bool _recording;
+ void recording(bool r)
+ {
+ _recording = r;
+ redraw();
+ }
+
+ bool mouseOver;
+ bool highlight;
+ int x, y, w, h;
+ const char* label;
+
+ int previousAngle;
+
+ float _r, _g, _b; // foreground colour
+ float _bgr, _bgg, _bgb; // background colour
+ float _outr, _outg, _outb; // outline colour
+
+ void setColor(float r, float g, float b)
+ {
+ _r = r;
+ _g = g;
+ _b = b;
+ }
+
+ void setBgColor(float r, float g, float b)
+ {
+ _bgr = r;
+ _bgg = g;
+ _bgb = b;
+ }
+
+ void draw()
+ {
+ // check that its a new "segment" to redraw
+ int newAngle = (value() * 16);
+
+ if (damage() & FL_DAMAGE_ALL &&
+ previousAngle != newAngle ) {
+ cairo_t *cr = Fl::cairo_cc();
+
+ cairo_save( cr );
+
+ int xc = (w) / 2.f;
+ int yc = (h) / 2.f;
+
+ int radius = xc > yc ? yc : xc;
+ radius -= 10;
+
+ float angle = newAngle / 16.f;
+
+ cairo_set_line_cap ( cr, CAIRO_LINE_CAP_ROUND );
+ //cairo_move_to( cr, x + xc, y + yc );
+ cairo_arc( cr, x + xc, y + yc, radius, -(3.1415/2), angle * 6.28 - (3.1415/2) );
+ cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.5 );
+ cairo_set_line_width(cr, 12);
+ cairo_stroke_preserve(cr);
+
+ cairo_set_source_rgba (cr, 1.0, 0.48, 0.0, 1 );
+ cairo_set_line_width(cr, 8.2);
+ cairo_stroke(cr);
+
+
+ // recording?
+ if ( _recording ) {
+ cairo_set_source_rgba(cr,1.0,0.0,0.0, 0.8);
+ cairo_arc(cr, x + xc, y + yc, radius-4, 0, 2 * 3.1415);
+ cairo_fill_preserve(cr);
+ cairo_set_source_rgba(cr,0.0,0.0,0.0, 0.8);
+ cairo_set_line_width(cr, 2.2);
+ cairo_stroke(cr);
+
+ // color of internal dot depending on rec state
+ cairo_set_source_rgba(cr,0.0,0.0,0.0, 1);
+ } else {
+ cairo_set_source_rgba(cr,0.3,0.3,0.3, 1);
+ }
+
+ // inside circle
+ cairo_arc(cr, x + xc, y + yc, 10, 0, 2 * 3.1415);
+ cairo_set_line_width(cr, 4.2);
+ cairo_fill(cr);
+
+ cairo_restore( cr );
+
+ draw_label();
+ }
+ }
+
+ void resize(int X, int Y, int W, int H)
+ {
+ Fl_Widget::resize(X,Y,W,H);
+ x = X;
+ y = Y;
+ w = W;
+ h = H;
+ redraw();
+ }
+
+ int handle(int event)
+ {
+ switch(event) {
+ case FL_PUSH:
+ highlight = 1;
+ redraw();
+ return 1;
+ case FL_DRAG: {
+ int t = Fl::event_inside(this);
+ if (t != highlight) {
+ highlight = t;
+ redraw();
+ }
+ }
+ return 1;
+ case FL_ENTER:
+ mouseOver = true;
+ redraw();
+ return 1;
+ case FL_LEAVE:
+ mouseOver = false;
+ redraw();
+ return 1;
+ case FL_RELEASE:
+ if (highlight) {
+ highlight = 0;
+ redraw();
+ do_callback();
+ }
+ return 1;
+ case FL_SHORTCUT:
+ if ( test_shortcut() ) {
+ do_callback();
+ return 1;
+ }
+ return 0;
+ default:
+ return Fl_Widget::handle(event);
+ }
+ }
};
} // Avtk
diff --git a/src/avtk/avtk_reverb.h b/src/avtk/avtk_reverb.h
index a94af0f..a3a05d3 100644
--- a/src/avtk/avtk_reverb.h
+++ b/src/avtk/avtk_reverb.h
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -27,190 +27,212 @@ namespace Avtk
class Reverb : public Fl_Slider
{
- public:
- Reverb(int _x, int _y, int _w, int _h, const char *_label =0):
- Fl_Slider(_x, _y, _w, _h, _label)
- {
- x = _x;
- y = _y;
- w = _w;
- h = _h;
-
- amp = 0.5;
- s = 0.5;
- damp= 0.5;
-
- active = false;
-
- label = _label;
-
- highlight = false;
- mouseOver = false;
- }
-
- void size(float v) { s = v; redraw(); }
- void wet(float v) { amp = v; redraw(); }
- void damping(float v){damp = v; redraw();}
-
- float size(){return s;}
- float wet (){return amp;}
- float damping(){return damp;}
-
- bool getActive(){return active;}
- void setActive(bool a){active = a; redraw();}
-
- float s;
- float amp;
- float damp;
-
- bool active;
-
- bool mouseOver;
- bool highlight;
- int x, y, w, h;
- const char* label;
-
- void draw()
- {
- if (damage() & FL_DAMAGE_ALL)
- {
- cairo_t *cr = Fl::cairo_cc();
-
- cairo_save( cr );
-
- // graph
- cairo_rectangle( cr, x, y, w, h );
- cairo_set_source_rgb( cr,28 / 255.f, 28 / 255.f , 28 / 255.f );
- cairo_fill(cr);
-
-
- // set up dashed lines, 1 px off, 1 px on
- double dashes[1];
- dashes[0] = 2.0;
-
- cairo_set_dash ( cr, dashes, 1, 0.0);
-
- // loop over each 2nd line, drawing dots
- cairo_set_line_width(cr, 1.0);
- cairo_set_source_rgb(cr, 0.4,0.4,0.4);
- for ( int i = 0; i < 4; i++ )
- {
- cairo_move_to( cr, x + ((w / 4.f)*i), y );
- cairo_line_to( cr, x + ((w / 4.f)*i), y + h );
- }
- for ( int i = 0; i < 4; i++ )
- {
- cairo_move_to( cr, x , y + ((h / 4.f)*i) );
- cairo_line_to( cr, x + w, y + ((h / 4.f)*i) );
- }
- cairo_set_source_rgba( cr, 66 / 255.f, 66 / 255.f , 66 / 255.f , 0.5 );
- cairo_stroke(cr);
- cairo_set_dash ( cr, dashes, 0, 0.0);
-
- // draw "damping" control
- cairo_move_to( cr, x+w*0.1 , y + h*0.85 - (h*0.7*amp));
- cairo_line_to( cr, x+w*0.1 + (w-20)*damp, y + h*0.85 - (h*0.7*amp));
- cairo_set_source_rgba(cr, 1.0, 0.48, 0, 1);
- cairo_set_line_join( cr, CAIRO_LINE_JOIN_ROUND);
- cairo_set_line_cap ( cr, CAIRO_LINE_CAP_ROUND);
- cairo_set_line_width(cr, 1.9);
- cairo_stroke( cr );
-
- // draw reverb triangle
- cairo_move_to( cr, x , y + h*0.99 );
- cairo_line_to( cr, x + w*0.1, y + h*0.85 - (h*0.7*amp));
- cairo_line_to( cr, x + w*0.3+w*0.7*s, y + (h*0.99));
-
- // stroke
- cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 0.21 );
- cairo_fill_preserve(cr);
- cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 );
- cairo_set_line_width(cr, 1.2);
- cairo_stroke( cr );
-
- // stroke rim
- cairo_rectangle(cr, x, y, w, h);
- //cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 );
- cairo_set_source_rgba( cr, 126 / 255.f, 126 / 255.f , 126 / 255.f , 0.8 );
- cairo_set_line_width(cr, 0.9);
- cairo_stroke( cr );
-
- if ( !active )
- {
- // big grey X
- cairo_set_line_width(cr, 12.0);
- cairo_set_source_rgba(cr, 0.0,0.0,0.0, 1.0);
-
- cairo_move_to( cr, x + (3 * w / 4.f), y + ( h / 4.f ) );
- cairo_line_to( cr, x + (w / 4.f), y + ( 3 *h / 4.f ) );
-
- cairo_move_to( cr, x + (w / 4.f), y + ( h / 4.f ) );
- cairo_line_to( cr, x + (3 * w / 4.f), y + ( 3 *h / 4.f ) );
- cairo_set_line_cap ( cr, CAIRO_LINE_CAP_BUTT);
- cairo_stroke( cr );
- }
-
- cairo_restore( cr );
-
- draw_label();
- }
- }
-
- void resize(int X, int Y, int W, int H)
- {
- Fl_Widget::resize(X,Y,W,H);
- x = X;
- y = Y;
- w = W;
- h = H;
- redraw();
- }
-
- int handle(int event)
- {
- switch(event) {
- case FL_PUSH:
- highlight = 1;
- if ( Fl::event_button() == FL_RIGHT_MOUSE )
- {
- active = !active;
- redraw();
- do_callback();
- }
- return 1;
- case FL_DRAG: {
- int t = Fl::event_inside(this);
- if (t != highlight) {
- highlight = t;
- redraw();
- }
- }
- return 1;
- case FL_ENTER:
- mouseOver = true;
- redraw();
- return 1;
- case FL_LEAVE:
- mouseOver = false;
- redraw();
- return 1;
- case FL_RELEASE:
- if (highlight) {
- highlight = 0;
- redraw();
- }
- return 1;
- case FL_SHORTCUT:
- if ( test_shortcut() )
- {
- do_callback();
- return 1;
- }
- return 0;
- default:
- return Fl_Widget::handle(event);
- }
- }
+public:
+ Reverb(int _x, int _y, int _w, int _h, const char *_label =0):
+ Fl_Slider(_x, _y, _w, _h, _label)
+ {
+ x = _x;
+ y = _y;
+ w = _w;
+ h = _h;
+
+ amp = 0.5;
+ s = 0.5;
+ damp= 0.5;
+
+ active = false;
+
+ label = _label;
+
+ highlight = false;
+ mouseOver = false;
+ }
+
+ void size(float v)
+ {
+ s = v;
+ redraw();
+ }
+ void wet(float v)
+ {
+ amp = v;
+ redraw();
+ }
+ void damping(float v)
+ {
+ damp = v;
+ redraw();
+ }
+
+ float size()
+ {
+ return s;
+ }
+ float wet ()
+ {
+ return amp;
+ }
+ float damping()
+ {
+ return damp;
+ }
+
+ bool getActive()
+ {
+ return active;
+ }
+ void setActive(bool a)
+ {
+ active = a;
+ redraw();
+ }
+
+ float s;
+ float amp;
+ float damp;
+
+ bool active;
+
+ bool mouseOver;
+ bool highlight;
+ int x, y, w, h;
+ const char* label;
+
+ void draw()
+ {
+ if (damage() & FL_DAMAGE_ALL) {
+ cairo_t *cr = Fl::cairo_cc();
+
+ cairo_save( cr );
+
+ // graph
+ cairo_rectangle( cr, x, y, w, h );
+ cairo_set_source_rgb( cr,28 / 255.f, 28 / 255.f , 28 / 255.f );
+ cairo_fill(cr);
+
+
+ // set up dashed lines, 1 px off, 1 px on
+ double dashes[1];
+ dashes[0] = 2.0;
+
+ cairo_set_dash ( cr, dashes, 1, 0.0);
+
+ // loop over each 2nd line, drawing dots
+ cairo_set_line_width(cr, 1.0);
+ cairo_set_source_rgb(cr, 0.4,0.4,0.4);
+ for ( int i = 0; i < 4; i++ ) {
+ cairo_move_to( cr, x + ((w / 4.f)*i), y );
+ cairo_line_to( cr, x + ((w / 4.f)*i), y + h );
+ }
+ for ( int i = 0; i < 4; i++ ) {
+ cairo_move_to( cr, x , y + ((h / 4.f)*i) );
+ cairo_line_to( cr, x + w, y + ((h / 4.f)*i) );
+ }
+ cairo_set_source_rgba( cr, 66 / 255.f, 66 / 255.f , 66 / 255.f , 0.5 );
+ cairo_stroke(cr);
+ cairo_set_dash ( cr, dashes, 0, 0.0);
+
+ // draw "damping" control
+ cairo_move_to( cr, x+w*0.1 , y + h*0.85 - (h*0.7*amp));
+ cairo_line_to( cr, x+w*0.1 + (w-20)*damp, y + h*0.85 - (h*0.7*amp));
+ cairo_set_source_rgba(cr, 1.0, 0.48, 0, 1);
+ cairo_set_line_join( cr, CAIRO_LINE_JOIN_ROUND);
+ cairo_set_line_cap ( cr, CAIRO_LINE_CAP_ROUND);
+ cairo_set_line_width(cr, 1.9);
+ cairo_stroke( cr );
+
+ // draw reverb triangle
+ cairo_move_to( cr, x , y + h*0.99 );
+ cairo_line_to( cr, x + w*0.1, y + h*0.85 - (h*0.7*amp));
+ cairo_line_to( cr, x + w*0.3+w*0.7*s, y + (h*0.99));
+
+ // stroke
+ cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 0.21 );
+ cairo_fill_preserve(cr);
+ cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 );
+ cairo_set_line_width(cr, 1.2);
+ cairo_stroke( cr );
+
+ // stroke rim
+ cairo_rectangle(cr, x, y, w, h);
+ //cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 );
+ cairo_set_source_rgba( cr, 126 / 255.f, 126 / 255.f , 126 / 255.f , 0.8 );
+ cairo_set_line_width(cr, 0.9);
+ cairo_stroke( cr );
+
+ if ( !active ) {
+ // big grey X
+ cairo_set_line_width(cr, 12.0);
+ cairo_set_source_rgba(cr, 0.0,0.0,0.0, 1.0);
+
+ cairo_move_to( cr, x + (3 * w / 4.f), y + ( h / 4.f ) );
+ cairo_line_to( cr, x + (w / 4.f), y + ( 3 *h / 4.f ) );
+
+ cairo_move_to( cr, x + (w / 4.f), y + ( h / 4.f ) );
+ cairo_line_to( cr, x + (3 * w / 4.f), y + ( 3 *h / 4.f ) );
+ cairo_set_line_cap ( cr, CAIRO_LINE_CAP_BUTT);
+ cairo_stroke( cr );
+ }
+
+ cairo_restore( cr );
+
+ draw_label();
+ }
+ }
+
+ void resize(int X, int Y, int W, int H)
+ {
+ Fl_Widget::resize(X,Y,W,H);
+ x = X;
+ y = Y;
+ w = W;
+ h = H;
+ redraw();
+ }
+
+ int handle(int event)
+ {
+ switch(event) {
+ case FL_PUSH:
+ highlight = 1;
+ if ( Fl::event_button() == FL_RIGHT_MOUSE ) {
+ active = !active;
+ redraw();
+ do_callback();
+ }
+ return 1;
+ case FL_DRAG: {
+ int t = Fl::event_inside(this);
+ if (t != highlight) {
+ highlight = t;
+ redraw();
+ }
+ }
+ return 1;
+ case FL_ENTER:
+ mouseOver = true;
+ redraw();
+ return 1;
+ case FL_LEAVE:
+ mouseOver = false;
+ redraw();
+ return 1;
+ case FL_RELEASE:
+ if (highlight) {
+ highlight = 0;
+ redraw();
+ }
+ return 1;
+ case FL_SHORTCUT:
+ if ( test_shortcut() ) {
+ do_callback();
+ return 1;
+ }
+ return 0;
+ default:
+ return Fl_Widget::handle(event);
+ }
+ }
};
} // Avtk
diff --git a/src/avtk/avtk_sidechain_gain.h b/src/avtk/avtk_sidechain_gain.h
index 5c11d95..b141230 100644
--- a/src/avtk/avtk_sidechain_gain.h
+++ b/src/avtk/avtk_sidechain_gain.h
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -29,185 +29,198 @@
namespace Avtk
{
-
+
class SidechainGain : public Fl_Slider
{
- public:
- SidechainGain(int _x, int _y, int _w, int _h, const char *_label = 0):
- Fl_Slider(_x, _y, _w, _h, _label)
- {
- x = _x;
- y = _y;
- w = _w;
- h = _h;
-
- label = _label;
-
- mouseClickedX = 0;
- mouseClickedY = 0;
- mouseClicked = false;
-
- active = true;
- highlight = false;
-
- _threshold = 1.0;
- _target = 1.f;
- _reduce = 1.f;
- _release = 0.5;
-
- _sidechainAmp = 0;
- }
-
- void threshold(float t) {_threshold = t; redraw();}
- void reduce (float r) {_reduce = r; redraw();}
- void release (float r) {_release = r; redraw();}
-
- /// sets the sidechain amplitude
- void sidechain(float s) {_sidechainAmp = s; redraw();}
-
- bool active;
- bool highlight;
- int x, y, w, h;
- const char* label;
-
- int mouseClickedX;
- int mouseClickedY;
- bool mouseClicked;
- bool mouseRightClicked;
-
- float _threshold;
- float _target;
- float _reduce;
- float _release;
-
- float _sidechainAmp;
-
- void set_active(bool a)
- {
- active = a;
- redraw();
- }
-
- void draw()
- {
- if (damage() & FL_DAMAGE_ALL)
- {
- cairo_t *cr = Fl::cairo_cc();
-
- cairo_save( cr );
-
- cairo_set_line_width(cr, 1.5);
-
-
- // fill background
- cairo_rectangle( cr, x, y, w, h);
- cairo_set_source_rgb( cr, 28 / 255.f, 28 / 255.f , 28 / 255.f );
- cairo_fill_preserve( cr );
- cairo_clip( cr );
-
-
- // set up dashed lines, 1 px off, 1 px on
- double dashes[1];
- dashes[0] = 2.0;
-
- cairo_set_dash ( cr, dashes, 1, 0.0);
- cairo_set_line_width( cr, 1.0);
-
- // loop over each 2nd line, drawing dots
- cairo_set_line_width(cr, 1.0);
- cairo_set_source_rgb(cr, 0.4,0.4,0.4);
- for ( int i = 0; i < 4; i++ )
- {
- cairo_move_to( cr, x + ((w / 4.f)*i), y );
- cairo_line_to( cr, x + ((w / 4.f)*i), y + h );
- }
- for ( int i = 0; i < 4; i++ )
- {
- cairo_move_to( cr, x , y + ((h / 4.f)*i) );
- cairo_line_to( cr, x + w, y + ((h / 4.f)*i) );
- }
-
- cairo_set_source_rgba( cr, 66 / 255.f, 66 / 255.f , 66 / 255.f , 0.5 );
- cairo_stroke(cr);
- cairo_set_dash ( cr, dashes, 0, 0.0);
-
-
- // draw threshold / ducked line
- cairo_move_to( cr, x + w * 0.750 - (w * 0.5 * (1-_threshold)), y );
-
- cairo_line_to( cr, x + w * 0.750 - (w * 0.5 * (1-_threshold)) + _sidechainAmp* _reduce*( w * 0.5 ), y + h / 2 );
-
- cairo_line_to( cr, x + w * 0.750 - (w * 0.5 * (1-_threshold)), y + h );
-
- cairo_line_to( cr, x + w , y + h );
- cairo_line_to( cr, x + w , y );
- cairo_close_path( cr );
- cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 0.21 );
- cairo_fill_preserve( cr );
- cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 );
- cairo_stroke( cr );
-
- // _sidechainAmp => arrow
- cairo_move_to( cr, x + w * 0.00 * _sidechainAmp, y + h * 0.4 - (h*0.1*_sidechainAmp) );
- cairo_line_to( cr, x + w * 0.65 * _sidechainAmp, y + h * 0.4 );
- cairo_line_to( cr, x + w * 0.1 + w * 0.65 * _sidechainAmp, y + h * 0.5 );
- cairo_line_to( cr, x + w * 0.65 * _sidechainAmp, y + h * 0.6 );
- cairo_line_to( cr, x + w * 0.00 * _sidechainAmp, y + h * 0.6 + (h*0.1*_sidechainAmp) );
- cairo_close_path( cr );
- cairo_set_source_rgba( cr, 1.0, 0.48, 0.f , 0.21 );
- cairo_fill_preserve( cr );
- cairo_set_source_rgba( cr, 1.0, 0.48, 0.f , 1 );
- cairo_stroke( cr );
-
-
- // _release horizontal line
- cairo_move_to( cr, x , y + h * 0.25 + h/2 * _release );
- cairo_line_to( cr, x + w, y + h * 0.25 + h/2 * _release );
- cairo_set_source_rgba( cr, 1.0, 0.0, 0.f , 1 );
- cairo_stroke( cr );
-
- // stroke outline
- cairo_rectangle(cr, x, y, w, h);
- cairo_set_source_rgba( cr, 126 / 255.f, 126 / 255.f , 126 / 255.f , 0.8 );
- cairo_set_line_width(cr, 1.9);
- cairo_stroke( cr );
-
- if ( !active )
- {
- // big grey X
- cairo_set_line_width(cr, 20.0);
- cairo_set_source_rgba(cr, 0.4,0.4,0.4, 0.7);
-
- cairo_move_to( cr, x + (3 * w / 4.f), y + ( h / 4.f ) );
- cairo_line_to( cr, x + (w / 4.f), y + ( 3 *h / 4.f ) );
-
- cairo_move_to( cr, x + (w / 4.f), y + ( h / 4.f ) );
- cairo_line_to( cr, x + (3 * w / 4.f), y + ( 3 *h / 4.f ) );
- cairo_set_line_cap ( cr, CAIRO_LINE_CAP_BUTT);
- cairo_stroke( cr );
- }
-
- cairo_restore( cr );
- }
- }
-
- void resize(int X, int Y, int W, int H)
- {
- Fl_Widget::resize(X,Y,W,H);
- x = X;
- y = Y;
- w = W;
- h = H;
- redraw();
- }
-
- int handle(int event)
- { //TODO needed?
-
- return 0;
- }
-
- private:
+public:
+ SidechainGain(int _x, int _y, int _w, int _h, const char *_label = 0):
+ Fl_Slider(_x, _y, _w, _h, _label)
+ {
+ x = _x;
+ y = _y;
+ w = _w;
+ h = _h;
+
+ label = _label;
+
+ mouseClickedX = 0;
+ mouseClickedY = 0;
+ mouseClicked = false;
+
+ active = true;
+ highlight = false;
+
+ _threshold = 1.0;
+ _target = 1.f;
+ _reduce = 1.f;
+ _release = 0.5;
+
+ _sidechainAmp = 0;
+ }
+
+ void threshold(float t)
+ {
+ _threshold = t;
+ redraw();
+ }
+ void reduce (float r)
+ {
+ _reduce = r;
+ redraw();
+ }
+ void release (float r)
+ {
+ _release = r;
+ redraw();
+ }
+
+ /// sets the sidechain amplitude
+ void sidechain(float s)
+ {
+ _sidechainAmp = s;
+ redraw();
+ }
+
+ bool active;
+ bool highlight;
+ int x, y, w, h;
+ const char* label;
+
+ int mouseClickedX;
+ int mouseClickedY;
+ bool mouseClicked;
+ bool mouseRightClicked;
+
+ float _threshold;
+ float _target;
+ float _reduce;
+ float _release;
+
+ float _sidechainAmp;
+
+ void set_active(bool a)
+ {
+ active = a;
+ redraw();
+ }
+
+ void draw()
+ {
+ if (damage() & FL_DAMAGE_ALL) {
+ cairo_t *cr = Fl::cairo_cc();
+
+ cairo_save( cr );
+
+ cairo_set_line_width(cr, 1.5);
+
+
+ // fill background
+ cairo_rectangle( cr, x, y, w, h);
+ cairo_set_source_rgb( cr, 28 / 255.f, 28 / 255.f , 28 / 255.f );
+ cairo_fill_preserve( cr );
+ cairo_clip( cr );
+
+
+ // set up dashed lines, 1 px off, 1 px on
+ double dashes[1];
+ dashes[0] = 2.0;
+
+ cairo_set_dash ( cr, dashes, 1, 0.0);
+ cairo_set_line_width( cr, 1.0);
+
+ // loop over each 2nd line, drawing dots
+ cairo_set_line_width(cr, 1.0);
+ cairo_set_source_rgb(cr, 0.4,0.4,0.4);
+ for ( int i = 0; i < 4; i++ ) {
+ cairo_move_to( cr, x + ((w / 4.f)*i), y );
+ cairo_line_to( cr, x + ((w / 4.f)*i), y + h );
+ }
+ for ( int i = 0; i < 4; i++ ) {
+ cairo_move_to( cr, x , y + ((h / 4.f)*i) );
+ cairo_line_to( cr, x + w, y + ((h / 4.f)*i) );
+ }
+
+ cairo_set_source_rgba( cr, 66 / 255.f, 66 / 255.f , 66 / 255.f , 0.5 );
+ cairo_stroke(cr);
+ cairo_set_dash ( cr, dashes, 0, 0.0);
+
+
+ // draw threshold / ducked line
+ cairo_move_to( cr, x + w * 0.750 - (w * 0.5 * (1-_threshold)), y );
+
+ cairo_line_to( cr, x + w * 0.750 - (w * 0.5 * (1-_threshold)) + _sidechainAmp* _reduce*( w * 0.5 ), y + h / 2 );
+
+ cairo_line_to( cr, x + w * 0.750 - (w * 0.5 * (1-_threshold)), y + h );
+
+ cairo_line_to( cr, x + w , y + h );
+ cairo_line_to( cr, x + w , y );
+ cairo_close_path( cr );
+ cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 0.21 );
+ cairo_fill_preserve( cr );
+ cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 );
+ cairo_stroke( cr );
+
+ // _sidechainAmp => arrow
+ cairo_move_to( cr, x + w * 0.00 * _sidechainAmp, y + h * 0.4 - (h*0.1*_sidechainAmp) );
+ cairo_line_to( cr, x + w * 0.65 * _sidechainAmp, y + h * 0.4 );
+ cairo_line_to( cr, x + w * 0.1 + w * 0.65 * _sidechainAmp, y + h * 0.5 );
+ cairo_line_to( cr, x + w * 0.65 * _sidechainAmp, y + h * 0.6 );
+ cairo_line_to( cr, x + w * 0.00 * _sidechainAmp, y + h * 0.6 + (h*0.1*_sidechainAmp) );
+ cairo_close_path( cr );
+ cairo_set_source_rgba( cr, 1.0, 0.48, 0.f , 0.21 );
+ cairo_fill_preserve( cr );
+ cairo_set_source_rgba( cr, 1.0, 0.48, 0.f , 1 );
+ cairo_stroke( cr );
+
+
+ // _release horizontal line
+ cairo_move_to( cr, x , y + h * 0.25 + h/2 * _release );
+ cairo_line_to( cr, x + w, y + h * 0.25 + h/2 * _release );
+ cairo_set_source_rgba( cr, 1.0, 0.0, 0.f , 1 );
+ cairo_stroke( cr );
+
+ // stroke outline
+ cairo_rectangle(cr, x, y, w, h);
+ cairo_set_source_rgba( cr, 126 / 255.f, 126 / 255.f , 126 / 255.f , 0.8 );
+ cairo_set_line_width(cr, 1.9);
+ cairo_stroke( cr );
+
+ if ( !active ) {
+ // big grey X
+ cairo_set_line_width(cr, 20.0);
+ cairo_set_source_rgba(cr, 0.4,0.4,0.4, 0.7);
+
+ cairo_move_to( cr, x + (3 * w / 4.f), y + ( h / 4.f ) );
+ cairo_line_to( cr, x + (w / 4.f), y + ( 3 *h / 4.f ) );
+
+ cairo_move_to( cr, x + (w / 4.f), y + ( h / 4.f ) );
+ cairo_line_to( cr, x + (3 * w / 4.f), y + ( 3 *h / 4.f ) );
+ cairo_set_line_cap ( cr, CAIRO_LINE_CAP_BUTT);
+ cairo_stroke( cr );
+ }
+
+ cairo_restore( cr );
+ }
+ }
+
+ void resize(int X, int Y, int W, int H)
+ {
+ Fl_Widget::resize(X,Y,W,H);
+ x = X;
+ y = Y;
+ w = W;
+ h = H;
+ redraw();
+ }
+
+ int handle(int event)
+ {
+ //TODO needed?
+
+ return 0;
+ }
+
+private:
};
} // Avtk
diff --git a/src/avtk/avtk_unit.h b/src/avtk/avtk_unit.h
index 21dc1d3..9bc4bb7 100644
--- a/src/avtk/avtk_unit.h
+++ b/src/avtk/avtk_unit.h
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -29,171 +29,166 @@ namespace Avtk
class UnitState
{
- public:
- enum State {
- UNIT_EMPTY = 0,
- UNIT_LOADED,
- UNIT_QUEUED,
- UNIT_PLAYING,
- UNIT_RECORDING,
- UNIT_STOPPING,
- };
- UnitState()
- {
- state = UNIT_EMPTY;
- name = "Clip";
- }
- UnitState(std::string n)
- {
- state = UNIT_EMPTY;
- name = n;
- }
-
- State state;
- std::string name;
+public:
+ enum State {
+ UNIT_EMPTY = 0,
+ UNIT_LOADED,
+ UNIT_QUEUED,
+ UNIT_PLAYING,
+ UNIT_RECORDING,
+ UNIT_STOPPING,
+ };
+ UnitState()
+ {
+ state = UNIT_EMPTY;
+ name = "Clip";
+ }
+ UnitState(std::string n)
+ {
+ state = UNIT_EMPTY;
+ name = n;
+ }
+
+ State state;
+ std::string name;
};
class Unit : public Fl_Button
{
- public:
- Unit(int _x, int _y, int _w, int _h, const char *_label):
- Fl_Button(_x, _y, _w, _h, _label)
- {
- x = _x;
- y = _y;
- w = _w;
- h = _h;
-
- label = _label;
-
- highlight = false;
- mouseOver = false;
-
- clips[0].state = UnitState::UNIT_EMPTY;
- clips[1].state = UnitState::UNIT_LOADED;
- clips[2].state = UnitState::UNIT_QUEUED;
- clips[3].state = UnitState::UNIT_PLAYING;
- clips[4].state = UnitState::UNIT_RECORDING;
- clips[5].state = UnitState::UNIT_STOPPING;
- }
-
- static const int numClips = 10;
- UnitState clips[numClips];
-
- bool mouseOver;
- bool highlight;
- int x, y, w, h;
- const char* label;
-
- void draw()
- {
- if (damage() & FL_DAMAGE_ALL)
- {
- if ( value() )
- {
- highlight = true;
- }
- else
- {
- highlight = false;
- }
-
- cairo_t *cr = Fl::cairo_cc();
-
- cairo_save( cr );
-
- cairo_rectangle( cr, x+2, y + 2, w - 2, h - 2 );
- cairo_set_source_rgba(cr, 66 / 255.f, 66 / 255.f , 66 / 255.f, 0.4);
- cairo_fill(cr);
-
- //cairo_rectangle( cr, x+1, drawY, clipHeight - 2, clipHeight - 2 );
- /*
- cairo_rectangle( cr, x+1, drawY, clipWidth, clipHeight - 2 );
-
- float alpha = 0.7;
- if (mouseOver) { alpha = 1; }
- cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, alpha);
- cairo_set_line_width( cr, 1.4);
- cairo_move_to( cr, x+clipHeight-1, drawY );
- cairo_line_to( cr, x+clipHeight-1, drawY + clipHeight - 2);
- cairo_stroke(cr);
-
- // clip name
- cairo_move_to( cr, x+clipHeight-1+ 10, drawY + 15 );
- cairo_set_source_rgba( cr, 255 / 255.f, 255 / 255.f , 255 / 255.f , 1 );
- cairo_set_font_size( cr, 10 );
- cairo_show_text( cr, label );
- */
-
- // outline
- float alpha = 0.7;
- if (mouseOver) { alpha = 1; }
- cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, alpha);
- cairo_rectangle( cr, x+2, y + 2, w - 2, h - 2 );
- cairo_set_line_width( cr, 1.4);
- cairo_stroke( cr );
-
- cairo_restore( cr );
-
- draw_label();
- }
- }
-
- void resize(int X, int Y, int W, int H)
- {
- Fl_Widget::resize(X,Y,W,H);
- x = X;
- y = Y;
- w = W;
- h = H;
- redraw();
- }
-
-
-
- int handle(int event)
- {
- switch(event) {
- case FL_ACTIVATE:
- {
- }
- case FL_DEACTIVATE:
- {
- }
- return 1;
- case FL_PUSH:
- highlight = 1;
- do_callback();
- return 1;
- case FL_DRAG: {
- int t = Fl::event_inside(this);
- if (t != highlight) {
- highlight = t;
- redraw();
- }
- }
- return 1;
- case FL_ENTER:
- mouseOver = true;
- redraw();
- return 1;
- case FL_LEAVE:
- mouseOver = false;
- redraw();
- return 1;
- case FL_RELEASE:
- return 1;
- case FL_SHORTCUT:
- if ( test_shortcut() )
- {
- do_callback();
- return 1;
- }
- return 0;
- default:
- return Fl_Widget::handle(event);
- }
- }
+public:
+ Unit(int _x, int _y, int _w, int _h, const char *_label):
+ Fl_Button(_x, _y, _w, _h, _label)
+ {
+ x = _x;
+ y = _y;
+ w = _w;
+ h = _h;
+
+ label = _label;
+
+ highlight = false;
+ mouseOver = false;
+
+ clips[0].state = UnitState::UNIT_EMPTY;
+ clips[1].state = UnitState::UNIT_LOADED;
+ clips[2].state = UnitState::UNIT_QUEUED;
+ clips[3].state = UnitState::UNIT_PLAYING;
+ clips[4].state = UnitState::UNIT_RECORDING;
+ clips[5].state = UnitState::UNIT_STOPPING;
+ }
+
+ static const int numClips = 10;
+ UnitState clips[numClips];
+
+ bool mouseOver;
+ bool highlight;
+ int x, y, w, h;
+ const char* label;
+
+ void draw()
+ {
+ if (damage() & FL_DAMAGE_ALL) {
+ if ( value() ) {
+ highlight = true;
+ } else {
+ highlight = false;
+ }
+
+ cairo_t *cr = Fl::cairo_cc();
+
+ cairo_save( cr );
+
+ cairo_rectangle( cr, x+2, y + 2, w - 2, h - 2 );
+ cairo_set_source_rgba(cr, 66 / 255.f, 66 / 255.f , 66 / 255.f, 0.4);
+ cairo_fill(cr);
+
+ //cairo_rectangle( cr, x+1, drawY, clipHeight - 2, clipHeight - 2 );
+ /*
+ cairo_rectangle( cr, x+1, drawY, clipWidth, clipHeight - 2 );
+
+ float alpha = 0.7;
+ if (mouseOver) { alpha = 1; }
+ cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, alpha);
+ cairo_set_line_width( cr, 1.4);
+ cairo_move_to( cr, x+clipHeight-1, drawY );
+ cairo_line_to( cr, x+clipHeight-1, drawY + clipHeight - 2);
+ cairo_stroke(cr);
+
+ // clip name
+ cairo_move_to( cr, x+clipHeight-1+ 10, drawY + 15 );
+ cairo_set_source_rgba( cr, 255 / 255.f, 255 / 255.f , 255 / 255.f , 1 );
+ cairo_set_font_size( cr, 10 );
+ cairo_show_text( cr, label );
+ */
+
+ // outline
+ float alpha = 0.7;
+ if (mouseOver) {
+ alpha = 1;
+ }
+ cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, alpha);
+ cairo_rectangle( cr, x+2, y + 2, w - 2, h - 2 );
+ cairo_set_line_width( cr, 1.4);
+ cairo_stroke( cr );
+
+ cairo_restore( cr );
+
+ draw_label();
+ }
+ }
+
+ void resize(int X, int Y, int W, int H)
+ {
+ Fl_Widget::resize(X,Y,W,H);
+ x = X;
+ y = Y;
+ w = W;
+ h = H;
+ redraw();
+ }
+
+
+
+ int handle(int event)
+ {
+ switch(event) {
+ case FL_ACTIVATE: {
+ }
+ case FL_DEACTIVATE: {
+ }
+ return 1;
+ case FL_PUSH:
+ highlight = 1;
+ do_callback();
+ return 1;
+ case FL_DRAG: {
+ int t = Fl::event_inside(this);
+ if (t != highlight) {
+ highlight = t;
+ redraw();
+ }
+ }
+ return 1;
+ case FL_ENTER:
+ mouseOver = true;
+ redraw();
+ return 1;
+ case FL_LEAVE:
+ mouseOver = false;
+ redraw();
+ return 1;
+ case FL_RELEASE:
+ return 1;
+ case FL_SHORTCUT:
+ if ( test_shortcut() ) {
+ do_callback();
+ return 1;
+ }
+ return 0;
+ default:
+ return Fl_Widget::handle(event);
+ }
+ }
};
} // Avtk
diff --git a/src/avtk/bindings.cxx b/src/avtk/bindings.cxx
index 3835849..3800886 100644
--- a/src/avtk/bindings.cxx
+++ b/src/avtk/bindings.cxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -27,132 +27,130 @@ namespace Avtk
{
Bindings::Bindings( int _x, int _y, int _w, int _h, const char *_label ) :
- Fl_Button(_x, _y, _w, _h, _label)
+ Fl_Button(_x, _y, _w, _h, _label)
{
- x = _x;
- y = _y;
- w = _w;
- h = _h;
-
- label = _label;
-
- bindYPx = 25;
-
- highlight = false;
- mouseOver = false;
+ x = _x;
+ y = _y;
+ w = _w;
+ h = _h;
+
+ label = _label;
+
+ bindYPx = 25;
+
+ highlight = false;
+ mouseOver = false;
}
void Bindings::draw()
{
- if (damage() & FL_DAMAGE_ALL)
- {
- cairo_t *cr = Fl::cairo_cc();
- cairo_save( cr );
-
- cairo_set_source_rgba( cr, 255 / 255.f, 255 / 255.f , 255 / 255.f , 1 );
- cairo_set_font_size( cr, 11 );
- cairo_move_to( cr, x + 7, y+15 );
- cairo_show_text( cr, "Action:" );
-
- cairo_move_to( cr, x + 140, y+15 );
- cairo_show_text( cr, "T:" );
- cairo_move_to( cr, x + 160, y+15 );
- cairo_show_text( cr, "S:" );
-
-
- cairo_move_to( cr, x + 200, y+15 );
- cairo_show_text( cr, "B1:" );
- cairo_move_to( cr, x + 230, y+15 );
- cairo_show_text( cr, "B2:" );
-
-
- int drawY = y + bindYPx;
- for(unsigned int i = 0; i < binds.size(); i++) // draw each binding
- {
- cairo_rectangle( cr, x+2, drawY, 179, 23 );
- cairo_set_source_rgba(cr, 0 / 255.f, 0 / 255.f , 0 / 255.f, 0.4);
- cairo_fill(cr);
-
- // action
- cairo_move_to( cr, x + 7, drawY+15 );
- cairo_set_source_rgba( cr, 255 / 255.f, 255 / 255.f , 255 / 255.f , 1 );
- cairo_set_font_size( cr, 11 );
- const char* action = Event::getPrettyName( binds.at(i)->action );
- if ( action )
- cairo_show_text( cr, action );
-
- // track
- cairo_move_to( cr, x + 140, drawY+15 );
- {
- std::stringstream s;
- s << binds.at(i)->track;
- cairo_show_text( cr, s.str().c_str() );
- }
- // scene
- cairo_move_to( cr, x + 150, drawY+15 );
- {
- std::stringstream s;
- s << binds.at(i)->scene;
- cairo_show_text( cr, s.str().c_str() );
- }
-
- // status
- cairo_move_to( cr, x + 165, drawY+15 );
- {
- std::stringstream s;
- s << binds.at(i)->status;
- cairo_show_text( cr, s.str().c_str() );
- }
- // data
- cairo_move_to( cr, x + 175, drawY+15 );
- {
- std::stringstream s;
- s << binds.at(i)->data;
- cairo_show_text( cr, s.str().c_str() );
- }
- // move to next line
- drawY += bindYPx;
- }
-
- //printf("done drawing\n");
-
- cairo_restore( cr );
- }
+ if (damage() & FL_DAMAGE_ALL) {
+ cairo_t *cr = Fl::cairo_cc();
+ cairo_save( cr );
+
+ cairo_set_source_rgba( cr, 255 / 255.f, 255 / 255.f , 255 / 255.f , 1 );
+ cairo_set_font_size( cr, 11 );
+ cairo_move_to( cr, x + 7, y+15 );
+ cairo_show_text( cr, "Action:" );
+
+ cairo_move_to( cr, x + 140, y+15 );
+ cairo_show_text( cr, "T:" );
+ cairo_move_to( cr, x + 160, y+15 );
+ cairo_show_text( cr, "S:" );
+
+
+ cairo_move_to( cr, x + 200, y+15 );
+ cairo_show_text( cr, "B1:" );
+ cairo_move_to( cr, x + 230, y+15 );
+ cairo_show_text( cr, "B2:" );
+
+
+ int drawY = y + bindYPx;
+ for(unsigned int i = 0; i < binds.size(); i++) { // draw each binding
+ cairo_rectangle( cr, x+2, drawY, 179, 23 );
+ cairo_set_source_rgba(cr, 0 / 255.f, 0 / 255.f , 0 / 255.f, 0.4);
+ cairo_fill(cr);
+
+ // action
+ cairo_move_to( cr, x + 7, drawY+15 );
+ cairo_set_source_rgba( cr, 255 / 255.f, 255 / 255.f , 255 / 255.f , 1 );
+ cairo_set_font_size( cr, 11 );
+ const char* action = Event::getPrettyName( binds.at(i)->action );
+ if ( action )
+ cairo_show_text( cr, action );
+
+ // track
+ cairo_move_to( cr, x + 140, drawY+15 );
+ {
+ std::stringstream s;
+ s << binds.at(i)->track;
+ cairo_show_text( cr, s.str().c_str() );
+ }
+ // scene
+ cairo_move_to( cr, x + 150, drawY+15 );
+ {
+ std::stringstream s;
+ s << binds.at(i)->scene;
+ cairo_show_text( cr, s.str().c_str() );
+ }
+
+ // status
+ cairo_move_to( cr, x + 165, drawY+15 );
+ {
+ std::stringstream s;
+ s << binds.at(i)->status;
+ cairo_show_text( cr, s.str().c_str() );
+ }
+ // data
+ cairo_move_to( cr, x + 175, drawY+15 );
+ {
+ std::stringstream s;
+ s << binds.at(i)->data;
+ cairo_show_text( cr, s.str().c_str() );
+ }
+ // move to next line
+ drawY += bindYPx;
+ }
+
+ //printf("done drawing\n");
+
+ cairo_restore( cr );
+ }
}
void Bindings::add( Binding* b )
{
- // FIXME: Refactor to use copy-constructor?
- Binding* tmp = new Binding();
- tmp->action = b->action;
- tmp->status = b->status;
- tmp->data = b->data;
-
- tmp->active = b->active;
- tmp->track = b->track;
- tmp->scene = b->scene;
- tmp->send = b->send;
-
- binds.push_back( tmp );
-
- /*
- int height = binds.size() * bindYPx;
- printf("resize to %i, %i, %i, %i\n", x, y, w, height );
- resize( x, y, w, height );
- */
-
- redraw();
+ // FIXME: Refactor to use copy-constructor?
+ Binding* tmp = new Binding();
+ tmp->action = b->action;
+ tmp->status = b->status;
+ tmp->data = b->data;
+
+ tmp->active = b->active;
+ tmp->track = b->track;
+ tmp->scene = b->scene;
+ tmp->send = b->send;
+
+ binds.push_back( tmp );
+
+ /*
+ int height = binds.size() * bindYPx;
+ printf("resize to %i, %i, %i, %i\n", x, y, w, height );
+ resize( x, y, w, height );
+ */
+
+ redraw();
}
void Bindings::resize(int X, int Y, int W, int H)
{
- Fl_Widget::resize(X,Y,W,H);
- x = X;
- y = Y;
- w = W;
- h = H;
- redraw();
+ Fl_Widget::resize(X,Y,W,H);
+ x = X;
+ y = Y;
+ w = W;
+ h = H;
+ redraw();
}
} // namespace Avtk
diff --git a/src/avtk/bindings.h b/src/avtk/bindings.h
index 246f7de..bc82a79 100644
--- a/src/avtk/bindings.h
+++ b/src/avtk/bindings.h
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -31,23 +31,23 @@ namespace Avtk
class Bindings : public Fl_Button
{
- public:
- Bindings( int _x, int _y, int _w, int _h, const char *_label = 0 );
-
- bool mouseOver;
- bool highlight;
- int x, y, w, h;
- const char* label;
-
- void add( Binding* b );
-
- void draw();
- //int handle(int event);
- void resize(int X, int Y, int W, int H);
-
- int bindYPx;
- std::vector binds;
-
+public:
+ Bindings( int _x, int _y, int _w, int _h, const char *_label = 0 );
+
+ bool mouseOver;
+ bool highlight;
+ int x, y, w, h;
+ const char* label;
+
+ void add( Binding* b );
+
+ void draw();
+ //int handle(int event);
+ void resize(int X, int Y, int W, int H);
+
+ int bindYPx;
+ std::vector binds;
+
};
}
diff --git a/src/avtk/clipselector.cxx b/src/avtk/clipselector.cxx
index b6690b9..738e81a 100644
--- a/src/avtk/clipselector.cxx
+++ b/src/avtk/clipselector.cxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -32,38 +32,36 @@ namespace Avtk
ClipSelector::ClipSelector( int _x, int _y, int _w, int _h,
const char *_label, bool master ) :
- Fl_Button(_x, _y, _w, _h, _label)
+ Fl_Button(_x, _y, _w, _h, _label)
{
- x = _x;
- y = _y;
- w = _w;
- h = _h;
-
- special = -1;
-
- label = _label;
- _master = master;
-
- if ( _master )
- {
- for(int i = 0; i < 10; i++ )
- {
- stringstream s;
- s << "Scene " << i + 1;
- clips[i].setName( s.str() );
- }
-
- }
-
- highlight = false;
- mouseOver = false;
+ x = _x;
+ y = _y;
+ w = _w;
+ h = _h;
+
+ special = -1;
+
+ label = _label;
+ _master = master;
+
+ if ( _master ) {
+ for(int i = 0; i < 10; i++ ) {
+ stringstream s;
+ s << "Scene " << i + 1;
+ clips[i].setName( s.str() );
+ }
+
+ }
+
+ highlight = false;
+ mouseOver = false;
}
void ClipSelector::setID( int id )
{
- ID = id;
+ ID = id;
}
@@ -71,366 +69,320 @@ void ClipSelector::setID( int id )
void ClipSelector::setState( int clipNum, GridLogic::State s )
{
#ifdef DEBUG_CLIP
- //cout << "ClipSelector::setState() t = " << ID << " clipNum = " << clipNum << " state = " << s << endl;
+ //cout << "ClipSelector::setState() t = " << ID << " clipNum = " << clipNum << " state = " << s << endl;
#endif
- clips[clipNum].setState( s );
- if ( s == GridLogic::STATE_EMPTY )
- {
- clips[clipNum].setName("");
- }
-
- redraw();
+ clips[clipNum].setState( s );
+ if ( s == GridLogic::STATE_EMPTY ) {
+ clips[clipNum].setName("");
+ }
+
+ redraw();
}
std::string ClipSelector::clipName(int clip)
{
- return clips[clip].getName();
+ return clips[clip].getName();
}
void ClipSelector::clipName(int clip, std::string name)
{
- clips[clip].setName( name );
- redraw();
+ clips[clip].setName( name );
+ redraw();
}
void ClipSelector::setSpecial(int scene)
{
- if ( special == -1 && scene == -1 )
- {
- // no change
- return;
- }
-
- special = scene;
- redraw();
+ if ( special == -1 && scene == -1 ) {
+ // no change
+ return;
+ }
+
+ special = scene;
+ redraw();
}
void ClipSelector::draw()
{
- if (damage() & FL_DAMAGE_ALL)
- {
- if ( value() )
- {
- highlight = true;
- }
- else
- {
- highlight = false;
- }
-
- cairo_t *cr = Fl::cairo_cc();
-
- cairo_save( cr );
-
- int clipWidth = w - 2;
- int clipHeight = (h / numClips);
-
- // text height adjustment based on clip size
- // small 22, 13
- // start 29, 17
- //printf("clipHeight %i\n", clipHeight);
- int textHeight = 13 + ((clipHeight - 22) * 0.66 );
-
-
-
- int xOff = x+clipHeight/2;
-
- int drawY = y + 1;
- for( int i = 0; i < numClips; i++) // draw each clip
- {
- int yOff = drawY+ clipHeight/2 -1;
-
- cairo_rectangle( cr, x+2, drawY, clipWidth-1, clipHeight - 4 );
- cairo_set_source_rgba(cr, 66 / 255.f, 66 / 255.f , 66 / 255.f, 0.4);
- cairo_fill(cr);
-
- cairo_rectangle( cr, x+2, drawY, clipHeight-4, clipHeight - 4 );
-
- if ( clips[i].getState() == GridLogic::STATE_RECORDING )
- {
- cairo_set_source_rgba(cr, 1.f, 0 / 255.f , 0 / 255.f, 1.f);
- cairo_fill(cr);
- //cairo_arc( cr, x+14, drawY+13, 4.3, 0, 6.29 );
- cairo_arc( cr, xOff, yOff, 4.3, 0, 6.29 );
- cairo_set_source_rgba(cr, 0, 0, 0, 1.f);
- cairo_fill(cr);
- }
- else if ( clips[i].getState() == GridLogic::STATE_PLAYING )
- {
- cairo_set_source_rgba(cr, 0.0, 1.0, 0, 1.f );
- cairo_fill(cr);
- cairo_move_to( cr, xOff-4, yOff-5 );
- cairo_line_to( cr, xOff+5, yOff );
- cairo_line_to( cr, xOff-4, yOff+5 );
- cairo_close_path(cr);
- cairo_set_source_rgba(cr, 0, 0, 0, 1.f);
- cairo_fill(cr);
- }
- else if ( clips[i].getState() == GridLogic::STATE_PLAY_QUEUED )
- {
- cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 );
- cairo_fill(cr);
- cairo_move_to( cr, xOff-4, yOff-5 );
- cairo_line_to( cr, xOff+5, yOff );
- cairo_line_to( cr, xOff-4, yOff +5 );
- cairo_close_path(cr);
- cairo_set_source_rgba(cr, 0, 0, 0, 1.f);
- cairo_fill(cr);
- }
- else if ( clips[i].getState() == GridLogic::STATE_STOP_QUEUED )
- {
- cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 );
- cairo_fill(cr);
- cairo_arc( cr, xOff, yOff, 4.3, 0, 6.29 );
- cairo_set_source_rgba(cr, 0, 0, 0, 1.f);
- cairo_set_line_width(cr, 2.2f);
- cairo_stroke(cr);
- }
- else if ( clips[i].getState() == GridLogic::STATE_RECORD_QUEUED )
- {
- cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 );
- cairo_fill(cr);
- cairo_arc( cr, xOff, yOff, 4.3, 0, 6.29 );
- cairo_set_source_rgba(cr, 0, 0, 0, 1.f);
- cairo_fill(cr);
- }
- else if ( clips[i].getState() == GridLogic::STATE_STOPPED )
- {
- cairo_set_source_rgba(cr, 1.0, 0.6, 0, 1.f);
- cairo_fill(cr);
- cairo_arc( cr, xOff, yOff, 4.3, 0, 6.29 );
- cairo_set_source_rgba(cr, 0, 0, 0, 1.f);
- cairo_set_line_width(cr, 2.2f);
- cairo_stroke(cr);
- }
- else
- {
- cairo_set_source_rgba(cr, 66 / 255.f, 66 / 255.f , 66 / 255.f, 1.f);
- cairo_fill(cr);
- }
-
- cairo_rectangle( cr, x+2, drawY, clipWidth -1, clipHeight - 3 );
-
- float alpha = 1;
- cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, alpha);
- cairo_set_line_width( cr, 1.3);
- cairo_move_to( cr, x+clipHeight-1, drawY );
- cairo_line_to( cr, x+clipHeight-1, drawY + clipHeight - 2);
- cairo_stroke(cr);
-
- // clip name
- cairo_move_to( cr, x + clipHeight + 5, drawY + textHeight );
- cairo_set_source_rgba( cr, 255 / 255.f, 255 / 255.f , 255 / 255.f , 0.9 );
- cairo_set_font_size( cr, 11 );
-
- std::string tmp = clips[i].getName().substr(0,8);
-
- cairo_show_text( cr, tmp.c_str() );
-
- // special indicator?
- if ( i == special )
- {
- cairo_rectangle( cr, x+2, drawY, clipWidth -1, clipHeight - 3 );
- cairo_set_source_rgba(cr, 0.0, 153 / 255.f, 1.0, alpha);
- cairo_stroke( cr );
- }
-
- drawY += clipHeight;
-
- }
-
- cairo_restore( cr );
-
- //draw_label();
- }
+ if (damage() & FL_DAMAGE_ALL) {
+ if ( value() ) {
+ highlight = true;
+ } else {
+ highlight = false;
+ }
+
+ cairo_t *cr = Fl::cairo_cc();
+
+ cairo_save( cr );
+
+ int clipWidth = w - 2;
+ int clipHeight = (h / numClips);
+
+ // text height adjustment based on clip size
+ // small 22, 13
+ // start 29, 17
+ //printf("clipHeight %i\n", clipHeight);
+ int textHeight = 13 + ((clipHeight - 22) * 0.66 );
+
+
+
+ int xOff = x+clipHeight/2;
+
+ int drawY = y + 1;
+ for( int i = 0; i < numClips; i++) { // draw each clip
+ int yOff = drawY+ clipHeight/2 -1;
+
+ cairo_rectangle( cr, x+2, drawY, clipWidth-1, clipHeight - 4 );
+ cairo_set_source_rgba(cr, 66 / 255.f, 66 / 255.f , 66 / 255.f, 0.4);
+ cairo_fill(cr);
+
+ cairo_rectangle( cr, x+2, drawY, clipHeight-4, clipHeight - 4 );
+
+ if ( clips[i].getState() == GridLogic::STATE_RECORDING ) {
+ cairo_set_source_rgba(cr, 1.f, 0 / 255.f , 0 / 255.f, 1.f);
+ cairo_fill(cr);
+ //cairo_arc( cr, x+14, drawY+13, 4.3, 0, 6.29 );
+ cairo_arc( cr, xOff, yOff, 4.3, 0, 6.29 );
+ cairo_set_source_rgba(cr, 0, 0, 0, 1.f);
+ cairo_fill(cr);
+ } else if ( clips[i].getState() == GridLogic::STATE_PLAYING ) {
+ cairo_set_source_rgba(cr, 0.0, 1.0, 0, 1.f );
+ cairo_fill(cr);
+ cairo_move_to( cr, xOff-4, yOff-5 );
+ cairo_line_to( cr, xOff+5, yOff );
+ cairo_line_to( cr, xOff-4, yOff+5 );
+ cairo_close_path(cr);
+ cairo_set_source_rgba(cr, 0, 0, 0, 1.f);
+ cairo_fill(cr);
+ } else if ( clips[i].getState() == GridLogic::STATE_PLAY_QUEUED ) {
+ cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 );
+ cairo_fill(cr);
+ cairo_move_to( cr, xOff-4, yOff-5 );
+ cairo_line_to( cr, xOff+5, yOff );
+ cairo_line_to( cr, xOff-4, yOff +5 );
+ cairo_close_path(cr);
+ cairo_set_source_rgba(cr, 0, 0, 0, 1.f);
+ cairo_fill(cr);
+ } else if ( clips[i].getState() == GridLogic::STATE_STOP_QUEUED ) {
+ cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 );
+ cairo_fill(cr);
+ cairo_arc( cr, xOff, yOff, 4.3, 0, 6.29 );
+ cairo_set_source_rgba(cr, 0, 0, 0, 1.f);
+ cairo_set_line_width(cr, 2.2f);
+ cairo_stroke(cr);
+ } else if ( clips[i].getState() == GridLogic::STATE_RECORD_QUEUED ) {
+ cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 );
+ cairo_fill(cr);
+ cairo_arc( cr, xOff, yOff, 4.3, 0, 6.29 );
+ cairo_set_source_rgba(cr, 0, 0, 0, 1.f);
+ cairo_fill(cr);
+ } else if ( clips[i].getState() == GridLogic::STATE_STOPPED ) {
+ cairo_set_source_rgba(cr, 1.0, 0.6, 0, 1.f);
+ cairo_fill(cr);
+ cairo_arc( cr, xOff, yOff, 4.3, 0, 6.29 );
+ cairo_set_source_rgba(cr, 0, 0, 0, 1.f);
+ cairo_set_line_width(cr, 2.2f);
+ cairo_stroke(cr);
+ } else {
+ cairo_set_source_rgba(cr, 66 / 255.f, 66 / 255.f , 66 / 255.f, 1.f);
+ cairo_fill(cr);
+ }
+
+ cairo_rectangle( cr, x+2, drawY, clipWidth -1, clipHeight - 3 );
+
+ float alpha = 1;
+ cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, alpha);
+ cairo_set_line_width( cr, 1.3);
+ cairo_move_to( cr, x+clipHeight-1, drawY );
+ cairo_line_to( cr, x+clipHeight-1, drawY + clipHeight - 2);
+ cairo_stroke(cr);
+
+ // clip name
+ cairo_move_to( cr, x + clipHeight + 5, drawY + textHeight );
+ cairo_set_source_rgba( cr, 255 / 255.f, 255 / 255.f , 255 / 255.f , 0.9 );
+ cairo_set_font_size( cr, 11 );
+
+ std::string tmp = clips[i].getName().substr(0,8);
+
+ cairo_show_text( cr, tmp.c_str() );
+
+ // special indicator?
+ if ( i == special ) {
+ cairo_rectangle( cr, x+2, drawY, clipWidth -1, clipHeight - 3 );
+ cairo_set_source_rgba(cr, 0.0, 153 / 255.f, 1.0, alpha);
+ cairo_stroke( cr );
+ }
+
+ drawY += clipHeight;
+
+ }
+
+ cairo_restore( cr );
+
+ //draw_label();
+ }
}
void ClipSelector::resize(int X, int Y, int W, int H)
{
- Fl_Widget::resize(X,Y,W,H);
- x = X;
- y = Y;
- w = W;
- h = H;
- redraw();
+ Fl_Widget::resize(X,Y,W,H);
+ x = X;
+ y = Y;
+ w = W;
+ h = H;
+ redraw();
}
int ClipSelector::handle(int event)
{
- switch(event) {
- case FL_ACTIVATE:
- {
- }
- case FL_DEACTIVATE:
- {
- }
- return 1;
- case FL_PUSH:
- highlight = 1;
- {
- // calculate the clicked clip number
- int clipHeight = (h / numClips);
- int clipNum = ( (Fl::event_y() ) - y ) / clipHeight;
- if (clipNum >= numClips)
- clipNum = numClips -1; // fix for clicking the lowest pixel
-
- // handle right clicks: popup menu
- if ( Fl::event_state(FL_BUTTON3) )
- {
- if ( _master )
- {
- // ask new name for clip, then
- const char* name = fl_input( "Scene name: ", clips[clipNum].getName().c_str() );
- if ( name )
- clips[clipNum].setName( name );
-
- redraw();
- return 1;
- }
-
-
- Fl_Menu_Item rclick_menu[] =
- {
- { "Load" },
- { "Save" },
- { "Special"},
- { "Beats", 0, 0, 0, FL_SUBMENU | FL_MENU_DIVIDER },
- {"1 "},
- {"2"},
- {"4"},
- {"8"},
- {"16"},
- {"32"},
- {"64"},
- {0},
- //{ "Record" },
- { "Use as tempo" },
- { "Rename", 0, 0, 0, FL_MENU_DIVIDER},
- { "Clear" },
- { 0 }
- };
- Fl_Menu_Item *m = (Fl_Menu_Item*) rclick_menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, 0);
- if ( !m )
- {
- return 0;
- }
- else if ( strcmp(m->label(), "Load") == 0 )
- {
- gui->selectLoadSample( ID, clipNum );
- }
- else if ( strcmp(m->label(), "Save") == 0 )
- {
- //gui->saveBufferPath = "/tmp/test.wav";
- char* tmp = gui->selectSavePath();
- if(tmp && strlen(tmp)) {
- if( access( tmp, F_OK ) != -1 ) {
- int overwrite = fl_choice("Overwrite file?","Cancel","Overwrite",0);
- if (!overwrite) {
- return 0;
- }
- }
- gui->saveBufferPath = tmp;
- free(tmp);
- gui->selectSaveSample( ID, clipNum );
- }
- }
- else if ( strcmp(m->label(), "1 ") == 0 ) {
- EventLooperLoopLength e = EventLooperLoopLength(ID, clipNum ,1);
- writeToDspRingbuffer( &e );
- } else if ( strcmp(m->label(), "2") == 0 ) {
- EventLooperLoopLength e = EventLooperLoopLength(ID, clipNum ,2);
- writeToDspRingbuffer( &e );
- } else if ( strcmp(m->label(), "4") == 0 ) {
- EventLooperLoopLength e = EventLooperLoopLength(ID, clipNum ,4);
- writeToDspRingbuffer( &e );
- } else if ( strcmp(m->label(), "8") == 0 ) {
- EventLooperLoopLength e = EventLooperLoopLength(ID, clipNum ,8);
- writeToDspRingbuffer( &e );
- } else if ( strcmp(m->label(), "16") == 0 ) {
- EventLooperLoopLength e = EventLooperLoopLength(ID, clipNum ,16);
- writeToDspRingbuffer( &e );
- } else if ( strcmp(m->label(), "32") == 0 ) {
- EventLooperLoopLength e = EventLooperLoopLength(ID, clipNum ,32);
- writeToDspRingbuffer( &e );
- } else if ( strcmp(m->label(), "64") == 0 ) {
- EventLooperLoopLength e = EventLooperLoopLength(ID, clipNum ,64);
- writeToDspRingbuffer( &e );
- }
- else if ( strcmp(m->label(), "Use as tempo") == 0 )
- {
- EventLooperUseAsTempo e (ID, clipNum);
- writeToDspRingbuffer( &e );
- }
- else if ( strcmp(m->label(), "Special") == 0 )
- {
- //printf("special selected %i, %i\n", ID, clipNum );
- EventGridSelectNewChosen e( ID, clipNum);
- writeToDspRingbuffer( &e );
- }
- else if ( strcmp(m->label(), "Rename") == 0 )
- {
- const char* name = fl_input( "Clip name: ", clips[clipNum].getName().c_str() );
- if ( name )
- clips[clipNum].setName( name );
- }
- else if ( strcmp(m->label(), "Clear") == 0 )
- {
- // for a clip to become 0
- EventGridState e( ID, clipNum, GridLogic::STATE_EMPTY );
- writeToDspRingbuffer( &e );
- }
- }
- else
- {
- if ( _master )
- {
- EventGridLaunchScene e( clipNum );
- writeToDspRingbuffer( &e );
- redraw();
- return 1;
- }
-
- // write "pressed" event for this track,scene
- EventGridEvent e( ID, clipNum, true );
- writeToDspRingbuffer( &e );
- }
- }
- redraw();
- do_callback();
- return 1;
- case FL_DRAG:
- {
- int t = Fl::event_inside(this);
- if (t != highlight)
- {
- highlight = t;
- redraw();
- }
- }
- return 1;
- case FL_ENTER:
- mouseOver = true;
-
- redraw();
- return 1;
- case FL_LEAVE:
- mouseOver = false;
- redraw();
- return 1;
- case FL_RELEASE:
- return 1;
- case FL_SHORTCUT:
- if ( test_shortcut() )
- {
- do_callback();
- return 1;
- }
- return 0;
- default:
- return Fl_Widget::handle(event);
- }
+ switch(event) {
+ case FL_ACTIVATE: {
+ }
+ case FL_DEACTIVATE: {
+ }
+ return 1;
+ case FL_PUSH:
+ highlight = 1;
+ {
+ // calculate the clicked clip number
+ int clipHeight = (h / numClips);
+ int clipNum = ( (Fl::event_y() ) - y ) / clipHeight;
+ if (clipNum >= numClips)
+ clipNum = numClips -1; // fix for clicking the lowest pixel
+
+ // handle right clicks: popup menu
+ if ( Fl::event_state(FL_BUTTON3) ) {
+ if ( _master ) {
+ // ask new name for clip, then
+ const char* name = fl_input( "Scene name: ", clips[clipNum].getName().c_str() );
+ if ( name )
+ clips[clipNum].setName( name );
+
+ redraw();
+ return 1;
+ }
+
+
+ Fl_Menu_Item rclick_menu[] = {
+ { "Load" },
+ { "Save" },
+ { "Special"},
+ { "Beats", 0, 0, 0, FL_SUBMENU | FL_MENU_DIVIDER },
+ {"1 "},
+ {"2"},
+ {"4"},
+ {"8"},
+ {"16"},
+ {"32"},
+ {"64"},
+ {0},
+ //{ "Record" },
+ { "Use as tempo" },
+ { "Rename", 0, 0, 0, FL_MENU_DIVIDER},
+ { "Clear" },
+ { 0 }
+ };
+ Fl_Menu_Item *m = (Fl_Menu_Item*) rclick_menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, 0);
+ if ( !m ) {
+ return 0;
+ } else if ( strcmp(m->label(), "Load") == 0 ) {
+ gui->selectLoadSample( ID, clipNum );
+ } else if ( strcmp(m->label(), "Save") == 0 ) {
+ //gui->saveBufferPath = "/tmp/test.wav";
+ char* tmp = gui->selectSavePath();
+ if(tmp && strlen(tmp)) {
+ if( access( tmp, F_OK ) != -1 ) {
+ int overwrite = fl_choice("Overwrite file?","Cancel","Overwrite",0);
+ if (!overwrite) {
+ return 0;
+ }
+ }
+ gui->saveBufferPath = tmp;
+ free(tmp);
+ gui->selectSaveSample( ID, clipNum );
+ }
+ } else if ( strcmp(m->label(), "1 ") == 0 ) {
+ EventLooperLoopLength e = EventLooperLoopLength(ID, clipNum ,1);
+ writeToDspRingbuffer( &e );
+ } else if ( strcmp(m->label(), "2") == 0 ) {
+ EventLooperLoopLength e = EventLooperLoopLength(ID, clipNum ,2);
+ writeToDspRingbuffer( &e );
+ } else if ( strcmp(m->label(), "4") == 0 ) {
+ EventLooperLoopLength e = EventLooperLoopLength(ID, clipNum ,4);
+ writeToDspRingbuffer( &e );
+ } else if ( strcmp(m->label(), "8") == 0 ) {
+ EventLooperLoopLength e = EventLooperLoopLength(ID, clipNum ,8);
+ writeToDspRingbuffer( &e );
+ } else if ( strcmp(m->label(), "16") == 0 ) {
+ EventLooperLoopLength e = EventLooperLoopLength(ID, clipNum ,16);
+ writeToDspRingbuffer( &e );
+ } else if ( strcmp(m->label(), "32") == 0 ) {
+ EventLooperLoopLength e = EventLooperLoopLength(ID, clipNum ,32);
+ writeToDspRingbuffer( &e );
+ } else if ( strcmp(m->label(), "64") == 0 ) {
+ EventLooperLoopLength e = EventLooperLoopLength(ID, clipNum ,64);
+ writeToDspRingbuffer( &e );
+ } else if ( strcmp(m->label(), "Use as tempo") == 0 ) {
+ EventLooperUseAsTempo e (ID, clipNum);
+ writeToDspRingbuffer( &e );
+ } else if ( strcmp(m->label(), "Special") == 0 ) {
+ //printf("special selected %i, %i\n", ID, clipNum );
+ EventGridSelectNewChosen e( ID, clipNum);
+ writeToDspRingbuffer( &e );
+ } else if ( strcmp(m->label(), "Rename") == 0 ) {
+ const char* name = fl_input( "Clip name: ", clips[clipNum].getName().c_str() );
+ if ( name )
+ clips[clipNum].setName( name );
+ } else if ( strcmp(m->label(), "Clear") == 0 ) {
+ // for a clip to become 0
+ EventGridState e( ID, clipNum, GridLogic::STATE_EMPTY );
+ writeToDspRingbuffer( &e );
+ }
+ } else {
+ if ( _master ) {
+ EventGridLaunchScene e( clipNum );
+ writeToDspRingbuffer( &e );
+ redraw();
+ return 1;
+ }
+
+ // write "pressed" event for this track,scene
+ EventGridEvent e( ID, clipNum, true );
+ writeToDspRingbuffer( &e );
+ }
+ }
+ redraw();
+ do_callback();
+ return 1;
+ case FL_DRAG: {
+ int t = Fl::event_inside(this);
+ if (t != highlight) {
+ highlight = t;
+ redraw();
+ }
+ }
+ return 1;
+ case FL_ENTER:
+ mouseOver = true;
+
+ redraw();
+ return 1;
+ case FL_LEAVE:
+ mouseOver = false;
+ redraw();
+ return 1;
+ case FL_RELEASE:
+ return 1;
+ case FL_SHORTCUT:
+ if ( test_shortcut() ) {
+ do_callback();
+ return 1;
+ }
+ return 0;
+ default:
+ return Fl_Widget::handle(event);
+ }
}
} // Avtk
diff --git a/src/avtk/clipselector.hxx b/src/avtk/clipselector.hxx
index 282e5a9..1b688f2 100644
--- a/src/avtk/clipselector.hxx
+++ b/src/avtk/clipselector.hxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -38,73 +38,73 @@ namespace Avtk
class ClipState
{
- public:
- ClipState() :
- state(GridLogic::STATE_EMPTY),
- name("")
- {}
-
- void setName(std::string n)
- {
- name = n;
- }
-
- void setState(GridLogic::State s)
- {
- state = s;
- }
-
- std::string getName()
- {
- return name;
- }
-
- GridLogic::State getState()
- {
- return state;
- }
-
- private:
- GridLogic::State state;
- std::string name;
+public:
+ ClipState() :
+ state(GridLogic::STATE_EMPTY),
+ name("")
+ {}
+
+ void setName(std::string n)
+ {
+ name = n;
+ }
+
+ void setState(GridLogic::State s)
+ {
+ state = s;
+ }
+
+ std::string getName()
+ {
+ return name;
+ }
+
+ GridLogic::State getState()
+ {
+ return state;
+ }
+
+private:
+ GridLogic::State state;
+ std::string name;
};
class ClipSelector : public Fl_Button
{
- public:
- ClipSelector( int _x, int _y, int _w, int _h,
- const char *_label, bool master = false);
-
- int ID;
-
- // FIXME: NSCENES?
- static const int numClips = 10;
- ClipState clips[numClips];
-
- /// indicates if a clip is the "special" clip
- void setSpecial(int scene);
- int special;
-
- bool _master;
- bool mouseOver;
- bool highlight;
- int x, y, w, h;
- const char* label;
-
- void setID( int id );
-
- /** converts the Looper::State into the UI represnted ClipSelector state.
- * It puts some of the data into clips[], and stores unique state into the class.
- **/
- void setState( int clipNum, GridLogic::State s );
-
- void clipName(int clip, std::string name);
- std::string clipName(int clip);
-
- void draw();
- int handle(int event);
-
- void resize(int X, int Y, int W, int H);
+public:
+ ClipSelector( int _x, int _y, int _w, int _h,
+ const char *_label, bool master = false);
+
+ int ID;
+
+ // FIXME: NSCENES?
+ static const int numClips = 10;
+ ClipState clips[numClips];
+
+ /// indicates if a clip is the "special" clip
+ void setSpecial(int scene);
+ int special;
+
+ bool _master;
+ bool mouseOver;
+ bool highlight;
+ int x, y, w, h;
+ const char* label;
+
+ void setID( int id );
+
+ /** converts the Looper::State into the UI represnted ClipSelector state.
+ * It puts some of the data into clips[], and stores unique state into the class.
+ **/
+ void setState( int clipNum, GridLogic::State s );
+
+ void clipName(int clip, std::string name);
+ std::string clipName(int clip);
+
+ void draw();
+ int handle(int event);
+
+ void resize(int X, int Y, int W, int H);
};
} // Avtk
diff --git a/src/avtk/volume.cxx b/src/avtk/volume.cxx
index 4b9a340..9a3deda 100644
--- a/src/avtk/volume.cxx
+++ b/src/avtk/volume.cxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -21,218 +21,206 @@
using namespace Avtk;
Volume::Volume(int _x, int _y, int _w, int _h, const char *_label ):
- Fl_Slider(_x, _y, _w, _h, _label)
+ Fl_Slider(_x, _y, _w, _h, _label)
{
- x = _x;
- y = _y;
- w = _w;
- h = _h;
-
- label = _label;
-
- mouseClickedX = 0;
- mouseClickedY = 0;
- mouseClicked = false;
-
- active = true;
- highlight = false;
-
- ampL = 0;
- ampR = 0;
- compress = 0;
- value( 0.78f );
+ x = _x;
+ y = _y;
+ w = _w;
+ h = _h;
- orientationHorizontal = false;
+ label = _label;
+
+ mouseClickedX = 0;
+ mouseClickedY = 0;
+ mouseClicked = false;
+
+ active = true;
+ highlight = false;
+
+ ampL = 0;
+ ampR = 0;
+ compress = 0;
+ value( 0.78f );
+
+ orientationHorizontal = false;
}
void Volume::fader( float f )
{
- // redraw on larger value change
- //if ( fabsf( value() - f ) > 0.025 )
- value( f );
+ // redraw on larger value change
+ //if ( fabsf( value() - f ) > 0.025 )
+ value( f );
}
void Volume::amplitude (float aL, float aR)
{
- if ( aL < 0.1 ) aL = 0.f;
- if ( aR < 0.1 ) aR = 0.f;
-
- // only redraw if changed more than X amount
- if ( fabsf(ampL - aL) > 0.025 ||
- fabsf(ampR - aR) > 0.025 )
- {
- ampL = aL;
- ampR = aR;
- redraw();
- }
+ if ( aL < 0.1 ) aL = 0.f;
+ if ( aR < 0.1 ) aR = 0.f;
+
+ // only redraw if changed more than X amount
+ if ( fabsf(ampL - aL) > 0.025 ||
+ fabsf(ampR - aR) > 0.025 ) {
+ ampL = aL;
+ ampR = aR;
+ redraw();
+ }
}
void Volume::compression(float c)
{
- compress = c;
- redraw();
+ compress = c;
+ redraw();
}
void Volume::setOrientationHorizontal()
{
- orientationHorizontal = true;
- redraw();
+ orientationHorizontal = true;
+ redraw();
}
void Volume::set_active(bool a)
{
- active = a;
- redraw();
+ active = a;
+ redraw();
}
void Volume::draw()
{
- if (damage() & FL_DAMAGE_ALL)
- {
- cairo_t *cr = Fl::cairo_cc();
-
- cairo_save( cr );
-
- cairo_set_line_width(cr, 1.5);
-
- // fill background
- cairo_rectangle( cr, x, y, w, h);
- cairo_set_source_rgba(cr, 66 / 255.f, 66 / 255.f , 66 / 255.f, 0.4);
- //cairo_set_source_rgb( cr, 28 / 255.f, 28 / 255.f , 28 / 255.f );
- cairo_fill( cr );
-
- //cairo_set_dash ( cr, dashes, 1, 0.0);
- cairo_set_line_width( cr, 1.0);
-
- // loop over each 2nd line, drawing dots
- cairo_set_line_width(cr, 1.0);
- cairo_set_source_rgb(cr, 0.4,0.4,0.4);
- for ( int i = 0; i < 2; i++ )
- {
- cairo_move_to( cr, x + ((w / 2.f)*i), y );
- cairo_line_to( cr, x + ((w / 2.f)*i), y + h );
- }
- for ( int i = 0; i < 4; i++ )
- {
- cairo_move_to( cr, x , y + ((h / 4.f)*i) );
- cairo_line_to( cr, x + w, y + ((h / 4.f)*i) );
- }
-
- cairo_set_source_rgba( cr, 66 / 255.f, 66 / 255.f , 66 / 255.f , 0.5 );
- cairo_stroke(cr);
- //cairo_set_dash ( cr, dashes, 0, 0.0);
-
-
- // audio level
- if ( orientationHorizontal )
- {
- cairo_rectangle(cr, x, y+h*0.15, w * ampL, 9.9 );
- cairo_rectangle(cr, x, y+h*0.56, w * ampR, 9.9 );
- }
- else
- {
- cairo_rectangle(cr, x+w*0.15, y+h*(1-ampL), 9.9, h - h*(1-ampL) );
- cairo_rectangle(cr, x+w*0.56, y+h*(1-ampR), 9.9, h - h*(1-ampR) );
- }
- cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 0.21 );
- cairo_fill_preserve( cr );
- cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 );
- cairo_stroke(cr);
-
- // fader
- if ( orientationHorizontal )
- cairo_rectangle(cr, x+2+(w-24)*(value()), y+5, 20, h-10);
- else
- cairo_rectangle(cr, x+5, y+2+(h-24)*(1-value()), w-10, 20);
-
- cairo_set_source_rgba( cr, 1.0f, 0.48, 0.f, 1);
- cairo_set_line_width(cr, 1.9);
- cairo_stroke( cr );
-
- // stroke outline
- cairo_rectangle(cr, x, y, w, h);
- cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
- cairo_set_line_width(cr, 1.9);
- cairo_stroke( cr );
-
- cairo_restore( cr );
- }
+ if (damage() & FL_DAMAGE_ALL) {
+ cairo_t *cr = Fl::cairo_cc();
+
+ cairo_save( cr );
+
+ cairo_set_line_width(cr, 1.5);
+
+ // fill background
+ cairo_rectangle( cr, x, y, w, h);
+ cairo_set_source_rgba(cr, 66 / 255.f, 66 / 255.f , 66 / 255.f, 0.4);
+ //cairo_set_source_rgb( cr, 28 / 255.f, 28 / 255.f , 28 / 255.f );
+ cairo_fill( cr );
+
+ //cairo_set_dash ( cr, dashes, 1, 0.0);
+ cairo_set_line_width( cr, 1.0);
+
+ // loop over each 2nd line, drawing dots
+ cairo_set_line_width(cr, 1.0);
+ cairo_set_source_rgb(cr, 0.4,0.4,0.4);
+ for ( int i = 0; i < 2; i++ ) {
+ cairo_move_to( cr, x + ((w / 2.f)*i), y );
+ cairo_line_to( cr, x + ((w / 2.f)*i), y + h );
+ }
+ for ( int i = 0; i < 4; i++ ) {
+ cairo_move_to( cr, x , y + ((h / 4.f)*i) );
+ cairo_line_to( cr, x + w, y + ((h / 4.f)*i) );
+ }
+
+ cairo_set_source_rgba( cr, 66 / 255.f, 66 / 255.f , 66 / 255.f , 0.5 );
+ cairo_stroke(cr);
+ //cairo_set_dash ( cr, dashes, 0, 0.0);
+
+
+ // audio level
+ if ( orientationHorizontal ) {
+ cairo_rectangle(cr, x, y+h*0.15, w * ampL, 9.9 );
+ cairo_rectangle(cr, x, y+h*0.56, w * ampR, 9.9 );
+ } else {
+ cairo_rectangle(cr, x+w*0.15, y+h*(1-ampL), 9.9, h - h*(1-ampL) );
+ cairo_rectangle(cr, x+w*0.56, y+h*(1-ampR), 9.9, h - h*(1-ampR) );
+ }
+ cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 0.21 );
+ cairo_fill_preserve( cr );
+ cairo_set_source_rgba( cr, 0 / 255.f, 153 / 255.f , 255 / 255.f , 1 );
+ cairo_stroke(cr);
+
+ // fader
+ if ( orientationHorizontal )
+ cairo_rectangle(cr, x+2+(w-24)*(value()), y+5, 20, h-10);
+ else
+ cairo_rectangle(cr, x+5, y+2+(h-24)*(1-value()), w-10, 20);
+
+ cairo_set_source_rgba( cr, 1.0f, 0.48, 0.f, 1);
+ cairo_set_line_width(cr, 1.9);
+ cairo_stroke( cr );
+
+ // stroke outline
+ cairo_rectangle(cr, x, y, w, h);
+ cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
+ cairo_set_line_width(cr, 1.9);
+ cairo_stroke( cr );
+
+ cairo_restore( cr );
+ }
}
void Volume::resize(int X, int Y, int W, int H)
{
- Fl_Widget::resize(X,Y,W,H);
- x = X;
- y = Y;
- w = W;
- h = H;
- redraw();
+ Fl_Widget::resize(X,Y,W,H);
+ x = X;
+ y = Y;
+ w = W;
+ h = H;
+ redraw();
}
int Volume::handle(int event)
{
- switch(event)
- {
- case FL_PUSH:
- highlight = 0;
- redraw();
- return 1;
- case FL_DRAG:
- {
- if ( Fl::event_state(FL_BUTTON1) )
- {
- if ( mouseClicked == false ) // catch the "click" event
- {
- mouseClickedX = Fl::event_x();
- mouseClickedY = Fl::event_y();
- mouseClicked = true;
- }
-
- float delta = (mouseClickedY - Fl::event_y() ) / float(h);
- // handle the x / y swap, and the inverting of direction (mouseX / Y relative)
- if ( orientationHorizontal )
- delta = ( Fl::event_x() - mouseClickedX ) / float(w);
-
- float valY = value();
- valY += delta;
-
- if ( valY > 1.0 ) valY = 1.0;
- if ( valY < 0.0 ) valY = 0.0;
-
- set_value( valY );
-
- mouseClickedX = Fl::event_x();
- mouseClickedY = Fl::event_y();
- redraw();
- do_callback();
- }
- }
- return 1;
- case FL_ENTER:
- return 1;
- case FL_MOUSEWHEEL:
- //printf("no scroll on faders\n");
- return 1;
- case FL_RELEASE:
- if (highlight) {
- highlight = 0;
- redraw();
- do_callback();
- }
- mouseClicked = false;
- return 1;
- case FL_SHORTCUT:
- if ( test_shortcut() )
- {
- do_callback();
- return 1;
- }
- return 0;
- default:
- return Fl_Widget::handle(event);
- }
+ switch(event) {
+ case FL_PUSH:
+ highlight = 0;
+ redraw();
+ return 1;
+ case FL_DRAG: {
+ if ( Fl::event_state(FL_BUTTON1) ) {
+ if ( mouseClicked == false ) { // catch the "click" event
+ mouseClickedX = Fl::event_x();
+ mouseClickedY = Fl::event_y();
+ mouseClicked = true;
+ }
+
+ float delta = (mouseClickedY - Fl::event_y() ) / float(h);
+ // handle the x / y swap, and the inverting of direction (mouseX / Y relative)
+ if ( orientationHorizontal )
+ delta = ( Fl::event_x() - mouseClickedX ) / float(w);
+
+ float valY = value();
+ valY += delta;
+
+ if ( valY > 1.0 ) valY = 1.0;
+ if ( valY < 0.0 ) valY = 0.0;
+
+ set_value( valY );
+
+ mouseClickedX = Fl::event_x();
+ mouseClickedY = Fl::event_y();
+ redraw();
+ do_callback();
+ }
+ }
+ return 1;
+ case FL_ENTER:
+ return 1;
+ case FL_MOUSEWHEEL:
+ //printf("no scroll on faders\n");
+ return 1;
+ case FL_RELEASE:
+ if (highlight) {
+ highlight = 0;
+ redraw();
+ do_callback();
+ }
+ mouseClicked = false;
+ return 1;
+ case FL_SHORTCUT:
+ if ( test_shortcut() ) {
+ do_callback();
+ return 1;
+ }
+ return 0;
+ default:
+ return Fl_Widget::handle(event);
+ }
}
diff --git a/src/avtk/volume.hxx b/src/avtk/volume.hxx
index fc00493..ae592d0 100644
--- a/src/avtk/volume.hxx
+++ b/src/avtk/volume.hxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -28,39 +28,39 @@
namespace Avtk
{
- class Volume : public Fl_Slider
- {
- public:
- Volume(int _x, int _y, int _w, int _h, const char *_label = 0);
-
- void set_active(bool a);
- void setOrientationHorizontal();
-
- void fader( float f );
- void compression(float c);
- void amplitude (float aL, float aR);
-
- void draw();
- int handle(int event);
-
- void resize(int X, int Y, int W, int H);
-
-
- private:
- bool active;
- bool highlight;
- bool orientationHorizontal;
-
- int x, y, w, h;
- const char* label;
-
- int mouseClickedX;
- int mouseClickedY;
- bool mouseClicked;
-
- float ampL, ampR;
- float compress;
- };
+class Volume : public Fl_Slider
+{
+public:
+ Volume(int _x, int _y, int _w, int _h, const char *_label = 0);
+
+ void set_active(bool a);
+ void setOrientationHorizontal();
+
+ void fader( float f );
+ void compression(float c);
+ void amplitude (float aL, float aR);
+
+ void draw();
+ int handle(int event);
+
+ void resize(int X, int Y, int W, int H);
+
+
+private:
+ bool active;
+ bool highlight;
+ bool orientationHorizontal;
+
+ int x, y, w, h;
+ const char* label;
+
+ int mouseClickedX;
+ int mouseClickedY;
+ bool mouseClicked;
+
+ float ampL, ampR;
+ float compress;
+};
} // Avtk
#endif // AVTK_VOLUME_H
diff --git a/src/avtk/waveform.h b/src/avtk/waveform.h
index d0810fd..32cca90 100644
--- a/src/avtk/waveform.h
+++ b/src/avtk/waveform.h
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -33,276 +33,259 @@ namespace Avtk
class Waveform : public Fl_Widget
{
- public:
- Waveform(int _x, int _y, int _w, int _h, const char *_label=0 ):
- Fl_Widget(_x, _y, _w, _h, _label)
- {
- x = _x;
- y = _y;
- w = _w;
- h = _h;
-
- label = _label;
-
- highlight = false;
- newWaveform = false;
-
- waveformCr = 0;
- waveformSurf = 0;
-
-
- data = (float*)malloc( sizeof(float) * w );
-
- srand (time(NULL));
-
- for (int i = 0; i < _w; i++)
- {
- data[i] = rand() / RAND_MAX / 0.75;
- }
-
- newWaveform = true;
-
- strokeRim = true;
- }
-
- bool strokeRim;
- bool highlight;
- int x, y, w, h;
- const char* label;
-
- cairo_t* waveformCr;
- cairo_surface_t* waveformSurf;
-
- bool newWaveform;
-
- long dataSize;
- float* data;
-
- void setData( float* d, long size )
- {
- //cout << "AvtkWaveform: setDataPtr = " << data << endl;
- dataSize = size;
- data = d;
- newWaveform = true;
-
-
- damage(FL_DAMAGE_ALL);
- }
-
- void draw()
- {
- if (damage() & FL_DAMAGE_ALL)
- {
- cairo_t *cr = Fl::cairo_cc();
- cairo_save(cr);
-
- // clear the surface
- cairo_rectangle(cr, x, y, w, h);
- cairo_set_source_rgb (cr, 0.1,0.1,0.1);
- cairo_fill( cr );
-
- if ( newWaveform )
- {
- if ( !waveformCr )
- {
- // create the waveform surface and context
- //cout << "waveform draw() creating new objects" << endl;
- waveformSurf= cairo_image_surface_create ( CAIRO_FORMAT_ARGB32, w, h);
- waveformCr = cairo_create ( waveformSurf );
- //cout << "waveform draw() creating objects done" << endl;
- }
-
- // clear the surface
- cairo_rectangle(waveformCr, 0, 0, w, h);
- cairo_set_source_rgb (waveformCr, 0.1,0.1,0.1);
- cairo_fill( waveformCr );
-
- // set up dashed lines, 1 px off, 1 px on
- double dashes[1];
- dashes[0] = 2.0;
-
- cairo_set_dash ( waveformCr, dashes, 1, 0.0);
- cairo_set_line_width( waveformCr, 1.0);
-
- // loop over each 2nd line, drawing dots
- cairo_set_line_width(waveformCr, 1.0);
- cairo_set_source_rgb(waveformCr, 0.4,0.4,0.4);
- for ( int i = 1; i < 4; i++ )
- {
- cairo_move_to( waveformCr, ((w / 4.f)*i), 0);
- cairo_line_to( waveformCr, ((w / 4.f)*i), h );
- }
- for ( int i = 1; i < 4; i++ )
- {
- cairo_move_to( waveformCr, 0, ((h / 4.f)*i) );
- cairo_line_to( waveformCr, w, ((h / 4.f)*i) );
- }
-
- cairo_set_source_rgba( waveformCr, 66 / 255.f, 66 / 255.f , 66 / 255.f , 0.5 );
- cairo_stroke(waveformCr);
- cairo_set_dash ( waveformCr, dashes, 0, 0.0);
-
-
- if ( !data )
- {
- // draw X
- cairo_move_to( cr, 0 , 0 );
- cairo_line_to( cr, 0 + w, 0 + h );
- cairo_move_to( cr, 0 , 0 + h );
- cairo_line_to( cr, 0 + w, 0 );
- cairo_set_source_rgb ( cr, 0.2,0.2,0.2);
- cairo_stroke(cr);
-
- // draw text
- cairo_move_to( cr, 0 + (w/2.f) - 65, 0 + (h/2.f) + 10 );
- cairo_set_source_rgb ( cr, 0.6,0.6,0.6);
- cairo_set_font_size( cr, 20 );
- cairo_show_text( cr, "No data loaded" );
- }
- else
- {
- // don't draw every sample
- int sampleCountForDrawing = -1;
-
- float currentTop = 0.f;
- float previousTop = 0.f;
- float currentSample = 0.f;
-
- // find how many samples per pixel
- int samplesPerPix = int(dataSize / float(w));
- //cout << "width = " << w << " sampsPerPx " << samplesPerPix << endl;
-
- // loop over each pixel value we need
- for( int p = 0; p < w; p++ )
- {
- float averageMax = 0.f;
- float averageMin = 0.f;
-
- // calc value for this pixel
- for( int i = 0; i < samplesPerPix; i++ )
- {
- float tmp = data[i + (p * samplesPerPix)];
- if ( tmp < 0 )
- {
- averageMin -= tmp;
- }
- else
- {
- averageMax += tmp;
- }
- }
-
- // - 0.1 to keep in bounds of square
- averageMin = (averageMin / samplesPerPix);
- averageMax = (averageMax / samplesPerPix);
-
- // don't use to the *very* top of the widget, only 0.8 (top & bottom)
- float dH = h * 0.4;
-
- // emulate log shape
- float tmpMin = log( 0.1 + (averageMin*4.9) );
- float tmpMax = log( 0.1 + (averageMax*4.9) );
-
- // logMin range == -2.3 -> 1.6: add 2.3, then / 3.9
- float logMin = -((tmpMin + 2.3) / 3.9);
- float logMax = ((tmpMax + 2.3) / 3.9);
-
- //printf("input %f, output %f\n", averageMin, logMin );
-
- // draw lines
- cairo_move_to( waveformCr, p, h * 0.5 + (logMin * dH ) );
- cairo_line_to( waveformCr, p, h * 0.5 + (logMax * dH ) );
- }
-
- // stroke the waveform
- cairo_set_source_rgb( waveformCr, 1.0,1.0,1.0);
- cairo_stroke( waveformCr );
-
- newWaveform = false;
- }
- }
-
- cairo_set_source_surface(cr, waveformSurf, x, y);
- cairo_rectangle( cr, x, y, w, h);
- cairo_paint(cr);
-
- if ( strokeRim )
- {
- // stroke rim
- cairo_set_line_width(cr, 1);
- cairo_rectangle(cr, x, y, w, h);
- cairo_set_source_rgba( cr, 100 / 255.f, 100 / 255.f , 100 / 255.f , 1 );
- cairo_stroke( cr );
- }
-
- //cout << "waveform draw() done" << endl;
-
- cairo_restore(cr);
- }
- }
-
- void resize(int X, int Y, int W, int H)
- {
- Fl_Widget::resize(X,Y,W,H);
-
- // take the smaller value
- long newSize = W > w ? W : w;
- printf("Waveform new size %li, from %i\n", newSize, w );
-
- x = X;
- y = Y;
- w = W;
- h = H;
-
- // FIXME: needs to be resampled, not clipped at end
- // delete old data, and resize it
- float* newData = (float*)malloc( sizeof(float) * w );
-
- memcpy( newData, data, newSize );
- free ( data );
- data = newData;
-
- newWaveform = true;
-
-
- redraw();
- }
-
- int handle(int event)
- {
- return 0;
-
- switch(event)
- {
- case FL_PUSH:
- highlight = 0;
- redraw();
- return 1;
- case FL_DRAG: {
- int t = Fl::event_inside(this);
- if (t != highlight) {
- redraw();
- }
- }
- return 1;
- case FL_RELEASE:
- if (highlight) {
- highlight = 0;
- redraw();
- do_callback();
- }
- return 1;
- case FL_SHORTCUT:
- if ( test_shortcut() )
- {
- do_callback();
- return 1;
- }
- return 0;
- default:
- return Fl_Widget::handle(event);
- }
- }
+public:
+ Waveform(int _x, int _y, int _w, int _h, const char *_label=0 ):
+ Fl_Widget(_x, _y, _w, _h, _label)
+ {
+ x = _x;
+ y = _y;
+ w = _w;
+ h = _h;
+
+ label = _label;
+
+ highlight = false;
+ newWaveform = false;
+
+ waveformCr = 0;
+ waveformSurf = 0;
+
+
+ data = (float*)malloc( sizeof(float) * w );
+
+ srand (time(NULL));
+
+ for (int i = 0; i < _w; i++) {
+ data[i] = rand() / RAND_MAX / 0.75;
+ }
+
+ newWaveform = true;
+
+ strokeRim = true;
+ }
+
+ bool strokeRim;
+ bool highlight;
+ int x, y, w, h;
+ const char* label;
+
+ cairo_t* waveformCr;
+ cairo_surface_t* waveformSurf;
+
+ bool newWaveform;
+
+ long dataSize;
+ float* data;
+
+ void setData( float* d, long size )
+ {
+ //cout << "AvtkWaveform: setDataPtr = " << data << endl;
+ dataSize = size;
+ data = d;
+ newWaveform = true;
+
+
+ damage(FL_DAMAGE_ALL);
+ }
+
+ void draw()
+ {
+ if (damage() & FL_DAMAGE_ALL) {
+ cairo_t *cr = Fl::cairo_cc();
+ cairo_save(cr);
+
+ // clear the surface
+ cairo_rectangle(cr, x, y, w, h);
+ cairo_set_source_rgb (cr, 0.1,0.1,0.1);
+ cairo_fill( cr );
+
+ if ( newWaveform ) {
+ if ( !waveformCr ) {
+ // create the waveform surface and context
+ //cout << "waveform draw() creating new objects" << endl;
+ waveformSurf= cairo_image_surface_create ( CAIRO_FORMAT_ARGB32, w, h);
+ waveformCr = cairo_create ( waveformSurf );
+ //cout << "waveform draw() creating objects done" << endl;
+ }
+
+ // clear the surface
+ cairo_rectangle(waveformCr, 0, 0, w, h);
+ cairo_set_source_rgb (waveformCr, 0.1,0.1,0.1);
+ cairo_fill( waveformCr );
+
+ // set up dashed lines, 1 px off, 1 px on
+ double dashes[1];
+ dashes[0] = 2.0;
+
+ cairo_set_dash ( waveformCr, dashes, 1, 0.0);
+ cairo_set_line_width( waveformCr, 1.0);
+
+ // loop over each 2nd line, drawing dots
+ cairo_set_line_width(waveformCr, 1.0);
+ cairo_set_source_rgb(waveformCr, 0.4,0.4,0.4);
+ for ( int i = 1; i < 4; i++ ) {
+ cairo_move_to( waveformCr, ((w / 4.f)*i), 0);
+ cairo_line_to( waveformCr, ((w / 4.f)*i), h );
+ }
+ for ( int i = 1; i < 4; i++ ) {
+ cairo_move_to( waveformCr, 0, ((h / 4.f)*i) );
+ cairo_line_to( waveformCr, w, ((h / 4.f)*i) );
+ }
+
+ cairo_set_source_rgba( waveformCr, 66 / 255.f, 66 / 255.f , 66 / 255.f , 0.5 );
+ cairo_stroke(waveformCr);
+ cairo_set_dash ( waveformCr, dashes, 0, 0.0);
+
+
+ if ( !data ) {
+ // draw X
+ cairo_move_to( cr, 0 , 0 );
+ cairo_line_to( cr, 0 + w, 0 + h );
+ cairo_move_to( cr, 0 , 0 + h );
+ cairo_line_to( cr, 0 + w, 0 );
+ cairo_set_source_rgb ( cr, 0.2,0.2,0.2);
+ cairo_stroke(cr);
+
+ // draw text
+ cairo_move_to( cr, 0 + (w/2.f) - 65, 0 + (h/2.f) + 10 );
+ cairo_set_source_rgb ( cr, 0.6,0.6,0.6);
+ cairo_set_font_size( cr, 20 );
+ cairo_show_text( cr, "No data loaded" );
+ } else {
+ // don't draw every sample
+ int sampleCountForDrawing = -1;
+
+ float currentTop = 0.f;
+ float previousTop = 0.f;
+ float currentSample = 0.f;
+
+ // find how many samples per pixel
+ int samplesPerPix = int(dataSize / float(w));
+ //cout << "width = " << w << " sampsPerPx " << samplesPerPix << endl;
+
+ // loop over each pixel value we need
+ for( int p = 0; p < w; p++ ) {
+ float averageMax = 0.f;
+ float averageMin = 0.f;
+
+ // calc value for this pixel
+ for( int i = 0; i < samplesPerPix; i++ ) {
+ float tmp = data[i + (p * samplesPerPix)];
+ if ( tmp < 0 ) {
+ averageMin -= tmp;
+ } else {
+ averageMax += tmp;
+ }
+ }
+
+ // - 0.1 to keep in bounds of square
+ averageMin = (averageMin / samplesPerPix);
+ averageMax = (averageMax / samplesPerPix);
+
+ // don't use to the *very* top of the widget, only 0.8 (top & bottom)
+ float dH = h * 0.4;
+
+ // emulate log shape
+ float tmpMin = log( 0.1 + (averageMin*4.9) );
+ float tmpMax = log( 0.1 + (averageMax*4.9) );
+
+ // logMin range == -2.3 -> 1.6: add 2.3, then / 3.9
+ float logMin = -((tmpMin + 2.3) / 3.9);
+ float logMax = ((tmpMax + 2.3) / 3.9);
+
+ //printf("input %f, output %f\n", averageMin, logMin );
+
+ // draw lines
+ cairo_move_to( waveformCr, p, h * 0.5 + (logMin * dH ) );
+ cairo_line_to( waveformCr, p, h * 0.5 + (logMax * dH ) );
+ }
+
+ // stroke the waveform
+ cairo_set_source_rgb( waveformCr, 1.0,1.0,1.0);
+ cairo_stroke( waveformCr );
+
+ newWaveform = false;
+ }
+ }
+
+ cairo_set_source_surface(cr, waveformSurf, x, y);
+ cairo_rectangle( cr, x, y, w, h);
+ cairo_paint(cr);
+
+ if ( strokeRim ) {
+ // stroke rim
+ cairo_set_line_width(cr, 1);
+ cairo_rectangle(cr, x, y, w, h);
+ cairo_set_source_rgba( cr, 100 / 255.f, 100 / 255.f , 100 / 255.f , 1 );
+ cairo_stroke( cr );
+ }
+
+ //cout << "waveform draw() done" << endl;
+
+ cairo_restore(cr);
+ }
+ }
+
+ void resize(int X, int Y, int W, int H)
+ {
+ Fl_Widget::resize(X,Y,W,H);
+
+ // take the smaller value
+ long newSize = W > w ? W : w;
+ printf("Waveform new size %li, from %i\n", newSize, w );
+
+ x = X;
+ y = Y;
+ w = W;
+ h = H;
+
+ // FIXME: needs to be resampled, not clipped at end
+ // delete old data, and resize it
+ float* newData = (float*)malloc( sizeof(float) * w );
+
+ memcpy( newData, data, newSize );
+ free ( data );
+ data = newData;
+
+ newWaveform = true;
+
+
+ redraw();
+ }
+
+ int handle(int event)
+ {
+ return 0;
+
+ switch(event) {
+ case FL_PUSH:
+ highlight = 0;
+ redraw();
+ return 1;
+ case FL_DRAG: {
+ int t = Fl::event_inside(this);
+ if (t != highlight) {
+ redraw();
+ }
+ }
+ return 1;
+ case FL_RELEASE:
+ if (highlight) {
+ highlight = 0;
+ redraw();
+ do_callback();
+ }
+ return 1;
+ case FL_SHORTCUT:
+ if ( test_shortcut() ) {
+ do_callback();
+ return 1;
+ }
+ return 0;
+ default:
+ return Fl_Widget::handle(event);
+ }
+ }
};
} // Avtk
diff --git a/src/buffers.hxx b/src/buffers.hxx
index 0469263..1e2342e 100644
--- a/src/buffers.hxx
+++ b/src/buffers.hxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -24,91 +24,91 @@
class Buffers
{
- public:
-
- enum BUFFER {
- // AUDIO
- MASTER_INPUT = 0,
-
- MASTER_OUT_L,
- MASTER_OUT_R,
-
- JACK_SEND_OUT,
- JACK_MASTER_OUT_L,
- JACK_MASTER_OUT_R,
- JACK_SIDECHAIN_KEY,
- JACK_SIDECHAIN_SIGNAL,
-
- SEND,
- SIDECHAIN_KEY,
- SIDECHAIN_SIGNAL,
-
- MASTER_RETURN_L,
- MASTER_RETURN_R,
-
- HEADPHONES_OUT,
-
- // MIDI
- MASTER_MIDI_INPUT,
-
- // track buffers: they are the "working" buffers per track:
- // the end result is mixed into the master output, while each
- // stage along the way the amplitude etc can be analysed
- TRACK_0,
- TRACK_1,
- TRACK_2,
- TRACK_3,
- TRACK_4,
- TRACK_5,
- TRACK_6,
- TRACK_7,
- //Per track sends/returns
- SEND_TRACK_0,
- SEND_TRACK_1,
- SEND_TRACK_2,
- SEND_TRACK_3,
- SEND_TRACK_4,
- SEND_TRACK_5,
- SEND_TRACK_6,
- SEND_TRACK_7,
- RETURN_TRACK_0,
- RETURN_TRACK_1,
- RETURN_TRACK_2,
- RETURN_TRACK_3,
- RETURN_TRACK_4,
- RETURN_TRACK_5,
- RETURN_TRACK_6,
- RETURN_TRACK_7,
+public:
- JACK_TRACK_0,
- JACK_TRACK_1,
- JACK_TRACK_2,
- JACK_TRACK_3,
- JACK_TRACK_4,
- JACK_TRACK_5,
- JACK_TRACK_6,
- JACK_TRACK_7,
+ enum BUFFER {
+ // AUDIO
+ MASTER_INPUT = 0,
+
+ MASTER_OUT_L,
+ MASTER_OUT_R,
+
+ JACK_SEND_OUT,
+ JACK_MASTER_OUT_L,
+ JACK_MASTER_OUT_R,
+ JACK_SIDECHAIN_KEY,
+ JACK_SIDECHAIN_SIGNAL,
+
+ SEND,
+ SIDECHAIN_KEY,
+ SIDECHAIN_SIGNAL,
+
+ MASTER_RETURN_L,
+ MASTER_RETURN_R,
+
+ HEADPHONES_OUT,
+
+ // MIDI
+ MASTER_MIDI_INPUT,
+
+ // track buffers: they are the "working" buffers per track:
+ // the end result is mixed into the master output, while each
+ // stage along the way the amplitude etc can be analysed
+ TRACK_0,
+ TRACK_1,
+ TRACK_2,
+ TRACK_3,
+ TRACK_4,
+ TRACK_5,
+ TRACK_6,
+ TRACK_7,
+ //Per track sends/returns
+ SEND_TRACK_0,
+ SEND_TRACK_1,
+ SEND_TRACK_2,
+ SEND_TRACK_3,
+ SEND_TRACK_4,
+ SEND_TRACK_5,
+ SEND_TRACK_6,
+ SEND_TRACK_7,
+ RETURN_TRACK_0,
+ RETURN_TRACK_1,
+ RETURN_TRACK_2,
+ RETURN_TRACK_3,
+ RETURN_TRACK_4,
+ RETURN_TRACK_5,
+ RETURN_TRACK_6,
+ RETURN_TRACK_7,
+
+ JACK_TRACK_0,
+ JACK_TRACK_1,
+ JACK_TRACK_2,
+ JACK_TRACK_3,
+ JACK_TRACK_4,
+ JACK_TRACK_5,
+ JACK_TRACK_6,
+ JACK_TRACK_7,
+
+
+ BUFFER_COUNT,
+ };
+
+ Buffers()
+ {
+ memset( audio, 0, sizeof(float*)*BUFFER_COUNT);
+ memset( midi , 0, sizeof(void *)*BUFFER_COUNT);
+ }
+ float* audio[BUFFER_COUNT];
+ void* midi [BUFFER_COUNT];
+
+ // Jack details
+ jack_nframes_t nframes;
+ jack_nframes_t samplerate;
+
+ jack_nframes_t transportFrame;
+ jack_position_t* transportPosition;
+ jack_transport_state_t* transportState;
-
- BUFFER_COUNT,
- };
-
- Buffers()
- {
- memset( audio, 0, sizeof(float*)*BUFFER_COUNT);
- memset( midi , 0, sizeof(void *)*BUFFER_COUNT);
- }
- float* audio[BUFFER_COUNT];
- void* midi [BUFFER_COUNT];
-
- // Jack details
- jack_nframes_t nframes;
- jack_nframes_t samplerate;
-
- jack_nframes_t transportFrame;
- jack_position_t* transportPosition;
- jack_transport_state_t* transportState;
-
};
#endif // LUPPP_BUFFERS_H
diff --git a/src/config.hxx b/src/config.hxx
index 6469cc4..bc035ab 100644
--- a/src/config.hxx
+++ b/src/config.hxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
diff --git a/src/controller/binding.hxx b/src/controller/binding.hxx
index 286a22c..19958c5 100644
--- a/src/controller/binding.hxx
+++ b/src/controller/binding.hxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -27,32 +27,35 @@ typedef int LupppAction;
class Binding
{
- public:
- Binding() : status(0), data(0), action(0), active(-1),
- track(-2),scene(-1),send(-1) { ID = privateID++; }
-
- int ID;
-
- unsigned char status;
- unsigned char data;
-
- /// the action this binding relates to: this is an integer based on the
- /// event.hxx enumeration of event types
- LupppAction action;
-
- /// arguments to the event: track number, scene number etc
- int active;
- int track;
- int scene;
- int send;
-
- /// maps from Gridlogic::State to MIDI output value from binding
- std::map clipStateMap;
-
- private:
- /// static int counter to allow deleting this specific instance
- static int privateID;
-
+public:
+ Binding() : status(0), data(0), action(0), active(-1),
+ track(-2),scene(-1),send(-1)
+ {
+ ID = privateID++;
+ }
+
+ int ID;
+
+ unsigned char status;
+ unsigned char data;
+
+ /// the action this binding relates to: this is an integer based on the
+ /// event.hxx enumeration of event types
+ LupppAction action;
+
+ /// arguments to the event: track number, scene number etc
+ int active;
+ int track;
+ int scene;
+ int send;
+
+ /// maps from Gridlogic::State to MIDI output value from binding
+ std::map clipStateMap;
+
+private:
+ /// static int counter to allow deleting this specific instance
+ static int privateID;
+
};
#endif
diff --git a/src/controller/controller.cxx b/src/controller/controller.cxx
index a25e5b9..66f9730 100644
--- a/src/controller/controller.cxx
+++ b/src/controller/controller.cxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -29,7 +29,7 @@ int Controller::privateID = 0;
Controller::Controller()
{
- ID = privateID++;
+ ID = privateID++;
}
void Controller::reset()
@@ -38,5 +38,5 @@ void Controller::reset()
int Controller::getID()
{
- return ID;
+ return ID;
}
diff --git a/src/controller/controller.hxx b/src/controller/controller.hxx
index cb6b36e..21f1217 100644
--- a/src/controller/controller.hxx
+++ b/src/controller/controller.hxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -31,66 +31,72 @@
**/
class Controller
{
- public:
- /// used to report the controller status
- enum STATUS {
- CONTROLLER_ERROR = 0,
- CONTROLLER_OK,
- };
-
- /// creates the controller instance: this is called in the non-RT thread
- Controller();
-
- /// controllers have a unique ID
- int getID();
-
- /// allows instance to register MIDI observer type functionality
- virtual int registerComponents(){return 0;}
-
- virtual ~Controller(){};
-
- /// get the status of the controller
- virtual STATUS status(){return CONTROLLER_OK;}
-
- /// name string to show in UI
- virtual std::string getName() = 0;
-
- /// master
- virtual void masterInputVol(float f){}
- virtual void masterInputTo(int to,float f){}
- virtual void masterInputToActive(int to,float f){}
- virtual void masterVolume(float f){}
- virtual void masterReturnVolume(float f){}
- virtual void metronomeEnable(bool b){}
-
- /// FX
- virtual void trackSend(int t, int send, float v){}
- virtual void trackSendActive(int t, int send, bool a){}
+public:
+ /// used to report the controller status
+ enum STATUS {
+ CONTROLLER_ERROR = 0,
+ CONTROLLER_OK,
+ };
- virtual void trackJackSend(int t, float v){}
- virtual void trackJackSendActivate(int t, bool a){}
-
- /// Time
- virtual void bpm(int bpm){}
- virtual void tapTempo(bool b){}
-
- /// Special
- virtual void specialScene(int t, int scene){}
-
- /// track functionality
- virtual void mute(int t, bool b){}
- virtual void volume(int t, float f){}
- virtual void progress(int t, int s, float f){}
- virtual void recordArm(int t, bool r){}
- virtual void setSceneState(int track, int scene, GridLogic::State s){}
- virtual void launchScene( int scene ){}
-
- /// reset controller
- virtual void reset();
-
- private:
- static int privateID;
- int ID;
+ /// creates the controller instance: this is called in the non-RT thread
+ Controller();
+
+ /// controllers have a unique ID
+ int getID();
+
+ /// allows instance to register MIDI observer type functionality
+ virtual int registerComponents()
+ {
+ return 0;
+ }
+
+ virtual ~Controller() {};
+
+ /// get the status of the controller
+ virtual STATUS status()
+ {
+ return CONTROLLER_OK;
+ }
+
+ /// name string to show in UI
+ virtual std::string getName() = 0;
+
+ /// master
+ virtual void masterInputVol(float f) {}
+ virtual void masterInputTo(int to,float f) {}
+ virtual void masterInputToActive(int to,float f) {}
+ virtual void masterVolume(float f) {}
+ virtual void masterReturnVolume(float f) {}
+ virtual void metronomeEnable(bool b) {}
+
+ /// FX
+ virtual void trackSend(int t, int send, float v) {}
+ virtual void trackSendActive(int t, int send, bool a) {}
+
+ virtual void trackJackSend(int t, float v) {}
+ virtual void trackJackSendActivate(int t, bool a) {}
+
+ /// Time
+ virtual void bpm(int bpm) {}
+ virtual void tapTempo(bool b) {}
+
+ /// Special
+ virtual void specialScene(int t, int scene) {}
+
+ /// track functionality
+ virtual void mute(int t, bool b) {}
+ virtual void volume(int t, float f) {}
+ virtual void progress(int t, int s, float f) {}
+ virtual void recordArm(int t, bool r) {}
+ virtual void setSceneState(int track, int scene, GridLogic::State s) {}
+ virtual void launchScene( int scene ) {}
+
+ /// reset controller
+ virtual void reset();
+
+private:
+ static int privateID;
+ int ID;
};
#endif // LUPPP_CONTROLLER_H
diff --git a/src/controller/genericmidi.cxx b/src/controller/genericmidi.cxx
index def9146..9033643 100644
--- a/src/controller/genericmidi.cxx
+++ b/src/controller/genericmidi.cxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -35,178 +35,162 @@ extern Jack* jack;
int Binding::privateID = 0;
GenericMIDI::GenericMIDI(int waste, std::string n) :
- Controller(),
- MidiIO()
+ Controller(),
+ MidiIO()
{
- LUPPP_NOTE("Adding GenericMIDI %s", n.c_str() );
- name = n;
- registerMidiPorts( name );
- stat = CONTROLLER_OK;
-
- setFootswitchToNextScene( 0 );
+ LUPPP_NOTE("Adding GenericMIDI %s", n.c_str() );
+ name = n;
+ registerMidiPorts( name );
+ stat = CONTROLLER_OK;
+
+ setFootswitchToNextScene( 0 );
}
void GenericMIDI::setFootswitchToNextScene(int v)
{
- LUPPP_NOTE("Set Footswitch to %i", v );
- if ( v == 0 )
- {
- footswitchNextScene = false;
- footswitchPrevScene = false;
- }
- else if ( v > 0 )
- {
- footswitchNextScene = true;
- footswitchPrevScene = false;
- }
- else
- {
- footswitchNextScene = false;
- footswitchPrevScene = true;
- }
+ LUPPP_NOTE("Set Footswitch to %i", v );
+ if ( v == 0 ) {
+ footswitchNextScene = false;
+ footswitchPrevScene = false;
+ } else if ( v > 0 ) {
+ footswitchNextScene = true;
+ footswitchPrevScene = false;
+ } else {
+ footswitchNextScene = false;
+ footswitchPrevScene = true;
+ }
}
void GenericMIDI::setName(std::string n)
{
- name = n;
+ name = n;
}
GenericMIDI::GenericMIDI(std::string file) :
- Controller(),
- MidiIO()
+ Controller(),
+ MidiIO()
{
- // default name for each controller
- name = "generic";
-
- // load the JSON config file
- int result = loadController( file );
-
- if ( result == LUPPP_RETURN_OK )
- {
- LUPPP_NOTE("GenericMIDI registering ports: %s", name.c_str() );
- registerMidiPorts( name );
- stat = CONTROLLER_OK;
- }
- else
- {
- LUPPP_ERROR("Error in loading controller map!" );
- stat = CONTROLLER_ERROR;
- }
+ // default name for each controller
+ name = "generic";
+
+ // load the JSON config file
+ int result = loadController( file );
+
+ if ( result == LUPPP_RETURN_OK ) {
+ LUPPP_NOTE("GenericMIDI registering ports: %s", name.c_str() );
+ registerMidiPorts( name );
+ stat = CONTROLLER_OK;
+ } else {
+ LUPPP_ERROR("Error in loading controller map!" );
+ stat = CONTROLLER_ERROR;
+ }
}
const std::vector& GenericMIDI::getMidiToAction()
{
- return midiToAction;
+ return midiToAction;
}
Controller::STATUS GenericMIDI::status()
{
- return stat;
+ return stat;
}
int GenericMIDI::registerComponents()
{
- // makes JACK add this controller to the midiObservers list:
- // note the static_cast<>() is *needed* here for multiple-inheritance
- MidiIO* m = static_cast(this);
-
- jack->registerMidiIO( m );
-
- return LUPPP_RETURN_OK;
+ // makes JACK add this controller to the midiObservers list:
+ // note the static_cast<>() is *needed* here for multiple-inheritance
+ MidiIO* m = static_cast(this);
+
+ jack->registerMidiIO( m );
+
+ return LUPPP_RETURN_OK;
}
std::string GenericMIDI::getName()
{
- return name;
+ return name;
}
std::string GenericMIDI::getAuthor()
{
- return author;
+ return author;
}
std::string GenericMIDI::getEmail()
{
- return email;
+ return email;
}
void GenericMIDI::volume(int t, float f)
{
-
+
}
void GenericMIDI::recordArm(int t, bool enabled)
{
- for(unsigned int i = 0; i < actionToMidi.size(); i++)
- {
- Binding* b = actionToMidi.at(i);
-
- if ( b->action == TRACK_RECORD_ARM && b->track == t )
- {
- unsigned char data[3];
- data[0] = b->status;
- data[1] = b->data;
- data[2] = enabled ? 127 : 0;
- writeMidi( data );
- return;
- }
- }
+ for(unsigned int i = 0; i < actionToMidi.size(); i++) {
+ Binding* b = actionToMidi.at(i);
+
+ if ( b->action == TRACK_RECORD_ARM && b->track == t ) {
+ unsigned char data[3];
+ data[0] = b->status;
+ data[1] = b->data;
+ data[2] = enabled ? 127 : 0;
+ writeMidi( data );
+ return;
+ }
+ }
}
void GenericMIDI::metronomeEnable(bool enabled)
{
- for(unsigned int i = 0; i < actionToMidi.size(); i++)
- {
- Binding* b = actionToMidi.at(i);
-
- if ( b->action == METRONOME_ACTIVE )
- {
- unsigned char data[3];
- data[0] = b->status;
- data[1] = b->data;
- data[2] = enabled ? 127 : 0;
- writeMidi( data );
- return;
- }
- }
+ for(unsigned int i = 0; i < actionToMidi.size(); i++) {
+ Binding* b = actionToMidi.at(i);
+
+ if ( b->action == METRONOME_ACTIVE ) {
+ unsigned char data[3];
+ data[0] = b->status;
+ data[1] = b->data;
+ data[2] = enabled ? 127 : 0;
+ writeMidi( data );
+ return;
+ }
+ }
}
void GenericMIDI::trackSend(int t, int send, float v)
{
-
- for(unsigned int i = 0; i < actionToMidi.size(); i++)
- {
- Binding* b = actionToMidi.at(i);
-
- if ( b->action == TRACK_SEND && b->track == t && b->send == send )
- {
- unsigned char data[3];
- data[0] = b->status;
- data[1] = b->data;
- data[2] = v * 127;
- writeMidi( data );
- return;
- }
- }
+
+ for(unsigned int i = 0; i < actionToMidi.size(); i++) {
+ Binding* b = actionToMidi.at(i);
+
+ if ( b->action == TRACK_SEND && b->track == t && b->send == send ) {
+ unsigned char data[3];
+ data[0] = b->status;
+ data[1] = b->data;
+ data[2] = v * 127;
+ writeMidi( data );
+ return;
+ }
+ }
}
void GenericMIDI::trackSendActive(int t, int send, bool a)
{
- for(unsigned int i = 0; i < actionToMidi.size(); i++)
- {
- Binding* b = actionToMidi.at(i);
-
- if ( b->action == TRACK_SEND_ACTIVE && b->track == t && b->send == send )
- {
- unsigned char data[3];
- data[0] = b->status;
- data[1] = b->data;
- data[2] = a ? 127 : 0;
- writeMidi( data );
- return;
- }
- }
+ for(unsigned int i = 0; i < actionToMidi.size(); i++) {
+ Binding* b = actionToMidi.at(i);
+
+ if ( b->action == TRACK_SEND_ACTIVE && b->track == t && b->send == send ) {
+ unsigned char data[3];
+ data[0] = b->status;
+ data[1] = b->data;
+ data[2] = a ? 127 : 0;
+ writeMidi( data );
+ return;
+ }
+ }
}
void GenericMIDI::trackJackSend(int t, float v)
@@ -222,13 +206,13 @@ void GenericMIDI::trackJackSendActivate(int t, bool a)
/*
void GenericMIDI::progress(int t, int s, float f)
{
-
+
unsigned char data[3];
data[0] = 176;
data[1] = 48; // record enable LED
data[2] = 127 * f;
jack->midiObserverWriteMIDI( _port, &data[0] );
-
+
}
void GenericMIDI::trackSend(int t, int send, float v)
@@ -238,9 +222,9 @@ void GenericMIDI::trackSend(int t, int send, float v)
// master track
return;
}
-
+
unsigned char data[3];
-
+
if ( send == SEND_KEY )
{
data[0] = 144 + t;
@@ -259,14 +243,14 @@ void GenericMIDI::trackSend(int t, int send, float v)
data[1] = 17;
data[2] = 127 * v;
}
-
+
jack->midiObserverWriteMIDI( _port, &data[0] );
}
void GenericMIDI::launchScene( int s )
{
unsigned char data[3];
-
+
for(int i = 0; i < 5; i++ )
{
data[0] = 128;
@@ -274,7 +258,7 @@ void GenericMIDI::launchScene( int s )
data[2] = 0;
jack->midiObserverWriteMIDI( _port, &data[0] );
}
-
+
data[0] = 144;
data[1] = 82 + s;
data[2] = 127;
@@ -283,13 +267,13 @@ void GenericMIDI::launchScene( int s )
void GenericMIDI::mute(int t, bool b)
{
-
+
}
void GenericMIDI::volume(int t, float f)
{
-
+
}
void GenericMIDI::noteOn( int track, int note, int vel )
@@ -306,8 +290,8 @@ void GenericMIDI::noteOn( int track, int note, int vel )
jack->getGridLogic()->pressed( track, note - 53 );
return;
}
-
-
+
+
switch( note )
{
case 48: { // record
@@ -316,35 +300,35 @@ void GenericMIDI::noteOn( int track, int note, int vel )
case 49: { // solo / cue
jack->getLogic()->trackSend(track, SEND_KEY, 1);
} break;
-
+
case 82: // Master Scene Clips
- case 83:
- case 84:
- case 85:
+ case 83:
+ case 84:
+ case 85:
case 86: {
jack->getGridLogic()->launchScene(note - 82);
} break;
-
+
case 98: { // Shift
shiftPressed = true;
break; }
-
+
case 99: { // tap tempo
jack->getLogic()->tapTempo();
jack->getControllerUpdater()->tapTempo( true );
- } break;
+ } break;
case 100: { // nudge +
-
- } break;
+
+ } break;
case 101: { // nudge -
-
- } break;
-
+
+ } break;
+
default:
break;
}
-
-
+
+
}
void GenericMIDI::noteOff( int track, int note, int vel )
@@ -354,7 +338,7 @@ void GenericMIDI::noteOff( int track, int note, int vel )
{
jack->getGridLogic()->released( track, note - 53 );
}
-
+
switch( note )
{
case 48: { // record
@@ -363,12 +347,12 @@ void GenericMIDI::noteOff( int track, int note, int vel )
case 49: { // solo / cue
jack->getLogic()->trackSend(track, SEND_KEY, 0);
}
-
+
case 99: { // tap tempo
EventTimeTempoTap e(false);
writeToGuiRingbuffer( &e );
- } break;
-
+ } break;
+
case 82: // scene launch
case 83:
case 84:
@@ -377,7 +361,7 @@ void GenericMIDI::noteOff( int track, int note, int vel )
int s = jack->getGridLogic()->getLaunchedScene();
launchScene( s );
} break ;
-
+
case 98: { // Shift
shiftPressed = false;
break; }
@@ -397,12 +381,12 @@ void GenericMIDI::ccChange( int track, int cc, float value )
case 14: { // master
jack->getLogic()->trackVolume( -1, value );
break; }
-
+
/// X-Fader
case 15: {
jack->getTimeManager()->setBpm( 60 + value * 180 );
break; }
-
+
/// Device Control
case 16: {
//jack->getLogic()->trackSend( track, SEND_KEY, value );
@@ -413,8 +397,8 @@ void GenericMIDI::ccChange( int track, int cc, float value )
case 18: {
jack->getLogic()->trackSend( track, SEND_POSTFADER, value );
break; }
-
-
+
+
case 64: { // FootSwitch 1
if ( value > 0.5 )
{
@@ -427,7 +411,7 @@ void GenericMIDI::ccChange( int track, int cc, float value )
jack->getGridLogic()->released( footpedalTrack, footpedalScene );
} break; }
case 67: { // FootSwitch 2
-
+
break; }
}
}
@@ -437,7 +421,7 @@ void GenericMIDI::ccChange( int track, int cc, float value )
{
if ( cc == 16 ) // master device control select
{
-
+
}
}
}
@@ -447,512 +431,466 @@ void GenericMIDI::ccChange( int track, int cc, float value )
void GenericMIDI::midi(unsigned char* midi)
{
- int status = midi[0];
- int data = midi[1];
- float value = midi[2] / 127.f;
-
-
- // create new MIDI binding?
- if ( jack->bindingEventRecordEnable )
- {
- //LUPPP_NOTE("making binding from: %i %i %f", status, data, value );
- setupBinding( jack->bindingEventType, status, data,
- jack->bindingTrack,
- jack->bindingScene,
- jack->bindingSend,
- jack->bindingActive );
-
- // reset jack state, so bindings defaults are setup after each creation
- jack->resetMidiBindingState();
-
- // binding is now created, so disable GUI binding enable button
- EventControllerBindingEnable e( getID(), false );
- writeToGuiRingbuffer( &e );
-
- // update GUI of new binding
- EventControllerBindingMade e2( getID(), (void*)midiToAction.back() );
- writeToGuiRingbuffer( &e2 );
- }
-
- if ( status == 0x90 && data == 0x64 ) // nudge +
- {
- // footpedal to scene++
- setFootswitchToNextScene( 1 );
- }
- else if ( status == 0x90 && data == 0x65 ) // nudge
- {
- // footpedal to scene--
- setFootswitchToNextScene( -1 );
- }
- else if ( status == 0x90 && data == 0x60 ) // > on bank select: clear scene
- {
- // footpedal to special clip
- setFootswitchToNextScene( 0 );
- }
-
- // iterate over bindings, execute binding action if matches
- for(unsigned int i = 0; i < midiToAction.size(); i++)
- {
- Binding* b = midiToAction.at(i);
-
- if ( b->status == status && b->data == data )
- {
- //LUPPP_NOTE("Executing action %s, send %i value %f, b->active %i", Event::getPrettyName(b->action), b->send, value, int(b->active) );
-
- switch( b->action )
- {
- case Event::TRACK_VOLUME: jack->getLogic()->trackVolume( b->track, value ); break;
- case Event::TRACK_SEND: jack->getLogic()->trackSend( b->track, b->send, value ); break;
- case Event::TRACK_SEND_ACTIVE: jack->getLogic()->trackSendActive( b->track, b->send, b->active ); break;
- case Event::TRACK_RECORD_ARM: jack->getLogic()->trackRecordArm( b->track, b->active ); break;
- case Event::TRACK_JACKSEND: jack->getLogic()->trackJackSend(b->track,value); break;
- case Event::TRACK_JACKSEND_ACTIVATE: jack->getLogic()->trackJackSendActivate(b->track,b->active); break;
- case Event::GRID_EVENT:
- if ( b->active )
- jack->getGridLogic()->pressed( b->track, b->scene );
- else
- jack->getGridLogic()->released( b->track, b->scene );
- break;
-
- case Event::GRID_SELECT_CLIP_EVENT:
- // hack to do scene ++ / -- with footswitch
- if ( footswitchNextScene && value > 0.5 ) // avoid note offs
- {
- cout << "footswitch next scene *now*" << endl;
- jack->getGridLogic()->launchScene( jack->getGridLogic()->getCurrentScene() + 1 );
- }
- else if ( footswitchPrevScene && value > 0.5 )
- {
- cout << "footswitch prev scene *now*" << endl;
- jack->getGridLogic()->launchScene( jack->getGridLogic()->getCurrentScene() - 1 );
- }
- else
- {
- cout << "footswitch special clip action now" << endl;
- jack->getGridLogic()->selectedTrackSceneEvent( value );
- }
- break;
- case Event::GRID_SELECT_CLIP_ENABLE:
- jack->getGridLogic()->setSelectTrackScene( b->active );
- break;
- case Event::GRID_LAUNCH_SCENE:
- jack->getGridLogic()->launchScene( b->scene );
- break;
-
- case Event::MASTER_RETURN:
- jack->getLogic()->masterReturn( RETURN_MAIN, value );
- break;
- case Event::MASTER_INPUT_VOL:
- jack->getLogic()->masterInputVol( value );
- break;
- case Event::MASTER_INPUT_TO:
- //LUPPP_NOTE("GenMidi event INPUT_TO %i", b->send );
- jack->getLogic()->masterInputTo( b->send, value );
- break;
- case Event::MASTER_INPUT_TO_ACTIVE:
- //LUPPP_NOTE("GenMidi event INPUT_TO_ACTIVE %i", b->send );
- jack->getLogic()->masterInputToActive( b->send, b->active );
- break;
-
- case Event::TIME_TEMPO_TAP:
- jack->getLogic()->tapTempo();
- break;
- case Event::TIME_BPM:
- // FIXME: quick-fix for "ZeroOne" type value -> BPM range
- jack->getLogic()->setBpm( value * 160 + 60 );
- break;
- case Event::METRONOME_ACTIVE:
- jack->getLogic()->metronomeEnable( b->active );
- break;
-
- case Event::MASTER_VOL: jack->getLogic()->trackVolume( -1 , value ); break;
- }
- }
-
-
- }
-
+ int status = midi[0];
+ int data = midi[1];
+ float value = midi[2] / 127.f;
+
+
+ // create new MIDI binding?
+ if ( jack->bindingEventRecordEnable ) {
+ //LUPPP_NOTE("making binding from: %i %i %f", status, data, value );
+ setupBinding( jack->bindingEventType, status, data,
+ jack->bindingTrack,
+ jack->bindingScene,
+ jack->bindingSend,
+ jack->bindingActive );
+
+ // reset jack state, so bindings defaults are setup after each creation
+ jack->resetMidiBindingState();
+
+ // binding is now created, so disable GUI binding enable button
+ EventControllerBindingEnable e( getID(), false );
+ writeToGuiRingbuffer( &e );
+
+ // update GUI of new binding
+ EventControllerBindingMade e2( getID(), (void*)midiToAction.back() );
+ writeToGuiRingbuffer( &e2 );
+ }
+
+ if ( status == 0x90 && data == 0x64 ) { // nudge +
+ // footpedal to scene++
+ setFootswitchToNextScene( 1 );
+ } else if ( status == 0x90 && data == 0x65 ) { // nudge
+ // footpedal to scene--
+ setFootswitchToNextScene( -1 );
+ } else if ( status == 0x90 && data == 0x60 ) { // > on bank select: clear scene
+ // footpedal to special clip
+ setFootswitchToNextScene( 0 );
+ }
+
+ // iterate over bindings, execute binding action if matches
+ for(unsigned int i = 0; i < midiToAction.size(); i++) {
+ Binding* b = midiToAction.at(i);
+
+ if ( b->status == status && b->data == data ) {
+ //LUPPP_NOTE("Executing action %s, send %i value %f, b->active %i", Event::getPrettyName(b->action), b->send, value, int(b->active) );
+
+ switch( b->action ) {
+ case Event::TRACK_VOLUME:
+ jack->getLogic()->trackVolume( b->track, value );
+ break;
+ case Event::TRACK_SEND:
+ jack->getLogic()->trackSend( b->track, b->send, value );
+ break;
+ case Event::TRACK_SEND_ACTIVE:
+ jack->getLogic()->trackSendActive( b->track, b->send, b->active );
+ break;
+ case Event::TRACK_RECORD_ARM:
+ jack->getLogic()->trackRecordArm( b->track, b->active );
+ break;
+ case Event::TRACK_JACKSEND:
+ jack->getLogic()->trackJackSend(b->track,value);
+ break;
+ case Event::TRACK_JACKSEND_ACTIVATE:
+ jack->getLogic()->trackJackSendActivate(b->track,b->active);
+ break;
+ case Event::GRID_EVENT:
+ if ( b->active )
+ jack->getGridLogic()->pressed( b->track, b->scene );
+ else
+ jack->getGridLogic()->released( b->track, b->scene );
+ break;
+
+ case Event::GRID_SELECT_CLIP_EVENT:
+ // hack to do scene ++ / -- with footswitch
+ if ( footswitchNextScene && value > 0.5 ) { // avoid note offs
+ cout << "footswitch next scene *now*" << endl;
+ jack->getGridLogic()->launchScene( jack->getGridLogic()->getCurrentScene() + 1 );
+ } else if ( footswitchPrevScene && value > 0.5 ) {
+ cout << "footswitch prev scene *now*" << endl;
+ jack->getGridLogic()->launchScene( jack->getGridLogic()->getCurrentScene() - 1 );
+ } else {
+ cout << "footswitch special clip action now" << endl;
+ jack->getGridLogic()->selectedTrackSceneEvent( value );
+ }
+ break;
+ case Event::GRID_SELECT_CLIP_ENABLE:
+ jack->getGridLogic()->setSelectTrackScene( b->active );
+ break;
+ case Event::GRID_LAUNCH_SCENE:
+ jack->getGridLogic()->launchScene( b->scene );
+ break;
+
+ case Event::MASTER_RETURN:
+ jack->getLogic()->masterReturn( RETURN_MAIN, value );
+ break;
+ case Event::MASTER_INPUT_VOL:
+ jack->getLogic()->masterInputVol( value );
+ break;
+ case Event::MASTER_INPUT_TO:
+ //LUPPP_NOTE("GenMidi event INPUT_TO %i", b->send );
+ jack->getLogic()->masterInputTo( b->send, value );
+ break;
+ case Event::MASTER_INPUT_TO_ACTIVE:
+ //LUPPP_NOTE("GenMidi event INPUT_TO_ACTIVE %i", b->send );
+ jack->getLogic()->masterInputToActive( b->send, b->active );
+ break;
+
+ case Event::TIME_TEMPO_TAP:
+ jack->getLogic()->tapTempo();
+ break;
+ case Event::TIME_BPM:
+ // FIXME: quick-fix for "ZeroOne" type value -> BPM range
+ jack->getLogic()->setBpm( value * 160 + 60 );
+ break;
+ case Event::METRONOME_ACTIVE:
+ jack->getLogic()->metronomeEnable( b->active );
+ break;
+
+ case Event::MASTER_VOL:
+ jack->getLogic()->trackVolume( -1 , value );
+ break;
+ }
+ }
+
+
+ }
+
}
void GenericMIDI::setSceneState(int t, int scene, GridLogic::State s)
{
- for(unsigned int i = 0; i < actionToMidi.size(); i++)
- {
- Binding* b = actionToMidi.at(i);
-
- if ( b->action == GRID_STATE && b->track == t && b->scene == scene )
- {
- for( map::iterator it = b->clipStateMap.begin(); it != b->clipStateMap.end(); ++it)
- {
- // check if its the right clip state
- if ( it->first == int(s) )
- {
- unsigned char data[3];
- data[0] = b->status;
- data[1] = b->data;
- data[2] = it->second;
-
- //LUPPP_NOTE("GenericMIDI::sceneState() writing event %i, %i, %i", data[0],data[1],data[2] );
- writeMidi( data );
- }
- }
- }
- }
+ for(unsigned int i = 0; i < actionToMidi.size(); i++) {
+ Binding* b = actionToMidi.at(i);
+
+ if ( b->action == GRID_STATE && b->track == t && b->scene == scene ) {
+ for( map::iterator it = b->clipStateMap.begin(); it != b->clipStateMap.end(); ++it) {
+ // check if its the right clip state
+ if ( it->first == int(s) ) {
+ unsigned char data[3];
+ data[0] = b->status;
+ data[1] = b->data;
+ data[2] = it->second;
+
+ //LUPPP_NOTE("GenericMIDI::sceneState() writing event %i, %i, %i", data[0],data[1],data[2] );
+ writeMidi( data );
+ }
+ }
+ }
+ }
}
void GenericMIDI::reset()
-{//TODO needed?
- /*
- unsigned char data[3];
- // setup "volume" style rotary display
- for(int i = 0; i < NTRACKS; i++)
- {
- data[0] = 176 + i;
- data[1] = 0x19;
- data[2] = 2;
- jack->midiObserverWriteMIDI( _port, &data[0] );
- }
- */
+{
+ //TODO needed?
+ /*
+ unsigned char data[3];
+ // setup "volume" style rotary display
+ for(int i = 0; i < NTRACKS; i++)
+ {
+ data[0] = 176 + i;
+ data[1] = 0x19;
+ data[2] = 2;
+ jack->midiObserverWriteMIDI( _port, &data[0] );
+ }
+ */
}
void GenericMIDI::launchScene( int scene )
{
- for(unsigned int i = 0; i < actionToMidi.size(); i++)
- {
- Binding* b = actionToMidi.at(i);
-
- if ( b->action == GRID_LAUNCH_SCENE )
- {
- for( int i = 0; i < 5; i++ )
- {
- if ( i != scene )
- {
- unsigned char data[3];
- data[0] = b->status;
- data[1] = b->data + i;
- data[2] = 0;
- writeMidi( data );
- }
- }
- unsigned char data[3];
- data[0] = b->status;
- data[1] = b->data + scene;
- data[2] = 127;
- //LUPPP_NOTE("this = %i GenericMIDI::launchScene()", this );
- writeMidi( data );
-
- return;
- }
- }
-
+ for(unsigned int i = 0; i < actionToMidi.size(); i++) {
+ Binding* b = actionToMidi.at(i);
+
+ if ( b->action == GRID_LAUNCH_SCENE ) {
+ for( int i = 0; i < 5; i++ ) {
+ if ( i != scene ) {
+ unsigned char data[3];
+ data[0] = b->status;
+ data[1] = b->data + i;
+ data[2] = 0;
+ writeMidi( data );
+ }
+ }
+ unsigned char data[3];
+ data[0] = b->status;
+ data[1] = b->data + scene;
+ data[2] = 127;
+ //LUPPP_NOTE("this = %i GenericMIDI::launchScene()", this );
+ writeMidi( data );
+
+ return;
+ }
+ }
+
}
int GenericMIDI::loadController( std::string file )
{
-
- /// open and read whole file
+
+ /// open and read whole file
#ifdef DEBUG_CONTROLLER
- LUPPP_NOTE("%s%s","Loading controller : ", file.c_str() );
+ LUPPP_NOTE("%s%s","Loading controller : ", file.c_str() );
#endif
- std::ifstream sampleFile( file.c_str(), std::ios_base::in|std::ios_base::ate);
- long file_length = sampleFile.tellg();
- if ( file_length > 0 )
- {
- sampleFile.seekg(0, std::ios_base::beg);
- sampleFile.clear();
- char *sampleString = new char[file_length];
- sampleFile.read(sampleString, file_length);
-
- cJSON* controllerJson = cJSON_Parse( sampleString );
- if (!controllerJson) {
- std::string error = cJSON_GetErrorPtr();
-
- std::istringstream ss( error );
-
- std::string line;
- std::getline( ss, line );
- LUPPP_ERROR("%s %s","Error in JSON *before*: ", line.c_str() );
-
- for(int i = 0; i < 5; i++)
- {
- std::getline( ss, line );
- LUPPP_ERROR("%s %s","Error in JSON : ", line.c_str() );
- }
- return LUPPP_RETURN_ERROR;
- }
-
- cJSON* nameJson = cJSON_GetObjectItem( controllerJson, "name" );
- if ( nameJson )
- {
- name = nameJson->valuestring;
- LUPPP_NOTE("Device %s", name.c_str() );
- }
- else
- {
- LUPPP_NOTE("Has no name field");
- }
-
- cJSON* authorJson = cJSON_GetObjectItem( controllerJson, "author" );
- if ( authorJson )
- {
- author = authorJson->valuestring;
- LUPPP_NOTE("Author %s", author.c_str() );
- }
- else
- {
- LUPPP_NOTE("Has no author field");
- }
-
- cJSON* linkJson = cJSON_GetObjectItem( controllerJson, "link" );
- if ( linkJson )
- {
- email = linkJson->valuestring;
- LUPPP_NOTE("Link %s", email.c_str() );
- }
- else
- {
- LUPPP_NOTE("Has no link field");
- }
-
-
- int nInputBindings = 0;
- cJSON* inputBindings = cJSON_GetObjectItem( controllerJson, "inputBindings");
- if ( inputBindings )
- {
- int nBindings = cJSON_GetArraySize( inputBindings );
- for(int i = 0; i < nBindings; i++ )
- {
- cJSON* bindingJson = cJSON_GetArrayItem( inputBindings, i );
- Binding* tmp = setupBinding( bindingJson );
- if ( tmp )
- midiToAction.push_back( tmp );
-
- nInputBindings++;
- }
- }
- else
- {
- LUPPP_WARN("No input bindings array in .ctlr map." );
- nInputBindings++; // hack to avoid 2 prints
- }
-
- if ( nInputBindings == 0 )
- {
- LUPPP_NOTE("Zero input bindings present in .ctlr map.");
- }
-
-
- int nOutputBindings = 0;
- cJSON* outputBindings = cJSON_GetObjectItem( controllerJson, "outputBindings");
- if ( outputBindings )
- {
- int nBindings = cJSON_GetArraySize( outputBindings );
- for(int i = 0; i < nBindings; i++ )
- {
- cJSON* bindingJson = cJSON_GetArrayItem( outputBindings, i );
- Binding* tmp = setupBinding( bindingJson );
- if ( tmp )
- actionToMidi.push_back( tmp );
-
- nOutputBindings++;
- //LUPPP_NOTE("Binding from %s to %i %i", actionJ->valuestring, statusJson->valueint, dataJson->valueint );
- }
- }
- else
- {
- LUPPP_NOTE("No output bindings array in .ctlr map." );
- nOutputBindings++; // hack to avoid 2 prints
- }
- if ( nOutputBindings == 0 )
- {
- LUPPP_NOTE("Zero output bindings present in .ctlr map." );
- }
-
-
- cJSON_Delete( controllerJson );
- delete[] sampleString;
- }
- else
- {
- LUPPP_WARN("%s %s","No controller file found at ", file.c_str() );
- return LUPPP_RETURN_WARNING;
- }
-
-
- LUPPP_NOTE("Controller loading complete." );
-
- return LUPPP_RETURN_OK;
+ std::ifstream sampleFile( file.c_str(), std::ios_base::in|std::ios_base::ate);
+ long file_length = sampleFile.tellg();
+ if ( file_length > 0 ) {
+ sampleFile.seekg(0, std::ios_base::beg);
+ sampleFile.clear();
+ char *sampleString = new char[file_length];
+ sampleFile.read(sampleString, file_length);
+
+ cJSON* controllerJson = cJSON_Parse( sampleString );
+ if (!controllerJson) {
+ std::string error = cJSON_GetErrorPtr();
+
+ std::istringstream ss( error );
+
+ std::string line;
+ std::getline( ss, line );
+ LUPPP_ERROR("%s %s","Error in JSON *before*: ", line.c_str() );
+
+ for(int i = 0; i < 5; i++) {
+ std::getline( ss, line );
+ LUPPP_ERROR("%s %s","Error in JSON : ", line.c_str() );
+ }
+ return LUPPP_RETURN_ERROR;
+ }
+
+ cJSON* nameJson = cJSON_GetObjectItem( controllerJson, "name" );
+ if ( nameJson ) {
+ name = nameJson->valuestring;
+ LUPPP_NOTE("Device %s", name.c_str() );
+ } else {
+ LUPPP_NOTE("Has no name field");
+ }
+
+ cJSON* authorJson = cJSON_GetObjectItem( controllerJson, "author" );
+ if ( authorJson ) {
+ author = authorJson->valuestring;
+ LUPPP_NOTE("Author %s", author.c_str() );
+ } else {
+ LUPPP_NOTE("Has no author field");
+ }
+
+ cJSON* linkJson = cJSON_GetObjectItem( controllerJson, "link" );
+ if ( linkJson ) {
+ email = linkJson->valuestring;
+ LUPPP_NOTE("Link %s", email.c_str() );
+ } else {
+ LUPPP_NOTE("Has no link field");
+ }
+
+
+ int nInputBindings = 0;
+ cJSON* inputBindings = cJSON_GetObjectItem( controllerJson, "inputBindings");
+ if ( inputBindings ) {
+ int nBindings = cJSON_GetArraySize( inputBindings );
+ for(int i = 0; i < nBindings; i++ ) {
+ cJSON* bindingJson = cJSON_GetArrayItem( inputBindings, i );
+ Binding* tmp = setupBinding( bindingJson );
+ if ( tmp )
+ midiToAction.push_back( tmp );
+
+ nInputBindings++;
+ }
+ } else {
+ LUPPP_WARN("No input bindings array in .ctlr map." );
+ nInputBindings++; // hack to avoid 2 prints
+ }
+
+ if ( nInputBindings == 0 ) {
+ LUPPP_NOTE("Zero input bindings present in .ctlr map.");
+ }
+
+
+ int nOutputBindings = 0;
+ cJSON* outputBindings = cJSON_GetObjectItem( controllerJson, "outputBindings");
+ if ( outputBindings ) {
+ int nBindings = cJSON_GetArraySize( outputBindings );
+ for(int i = 0; i < nBindings; i++ ) {
+ cJSON* bindingJson = cJSON_GetArrayItem( outputBindings, i );
+ Binding* tmp = setupBinding( bindingJson );
+ if ( tmp )
+ actionToMidi.push_back( tmp );
+
+ nOutputBindings++;
+ //LUPPP_NOTE("Binding from %s to %i %i", actionJ->valuestring, statusJson->valueint, dataJson->valueint );
+ }
+ } else {
+ LUPPP_NOTE("No output bindings array in .ctlr map." );
+ nOutputBindings++; // hack to avoid 2 prints
+ }
+ if ( nOutputBindings == 0 ) {
+ LUPPP_NOTE("Zero output bindings present in .ctlr map." );
+ }
+
+
+ cJSON_Delete( controllerJson );
+ delete[] sampleString;
+ } else {
+ LUPPP_WARN("%s %s","No controller file found at ", file.c_str() );
+ return LUPPP_RETURN_WARNING;
+ }
+
+
+ LUPPP_NOTE("Controller loading complete." );
+
+ return LUPPP_RETURN_OK;
}
void GenericMIDI::removeBinding( int bindingID )
{
- for(unsigned int i = 0; i < midiToAction.size(); i++)
- {
- if ( midiToAction.at(i)->ID == bindingID )
- {
- //LUPPP_NOTE("MIDI binding REMOVED with bindingID %i\n", bindingID );
- Binding* tmp = midiToAction.at(i);
- midiToAction.erase( midiToAction.begin()+i );
-
- if ( tmp )
- {
- delete tmp;
- }
- return;
- }
- }
+ for(unsigned int i = 0; i < midiToAction.size(); i++) {
+ if ( midiToAction.at(i)->ID == bindingID ) {
+ //LUPPP_NOTE("MIDI binding REMOVED with bindingID %i\n", bindingID );
+ Binding* tmp = midiToAction.at(i);
+ midiToAction.erase( midiToAction.begin()+i );
+
+ if ( tmp ) {
+ delete tmp;
+ }
+ return;
+ }
+ }
}
void GenericMIDI::setupBinding( LupppAction eventType, int midiStatus, int midiData, int track, int scene, int send, int active )
{
- LUPPP_NOTE("MIDI binding, track %d, send %d from eventType %d to %d, %d", track, send, eventType, midiStatus, midiData );
-
- // FIXME: NON-RT Have stack of Bindings() available, or push in GUI thread?
- Binding* tmp = new Binding();
-
- tmp->action = eventType;
- tmp->status = midiStatus;
- tmp->data = midiData;
- tmp->track = track;
- tmp->scene = scene;
- tmp->send = send;
- tmp->active = active;
-
- // FIXME: Could allocate memory! Issue? Shouldn't be binding during performance?
- midiToAction.push_back( tmp );
+ LUPPP_NOTE("MIDI binding, track %d, send %d from eventType %d to %d, %d", track, send, eventType, midiStatus, midiData );
+
+ // FIXME: NON-RT Have stack of Bindings() available, or push in GUI thread?
+ Binding* tmp = new Binding();
+
+ tmp->action = eventType;
+ tmp->status = midiStatus;
+ tmp->data = midiData;
+ tmp->track = track;
+ tmp->scene = scene;
+ tmp->send = send;
+ tmp->active = active;
+
+ // FIXME: Could allocate memory! Issue? Shouldn't be binding during performance?
+ midiToAction.push_back( tmp );
}
Binding* GenericMIDI::setupBinding( cJSON* binding )
{
- // include Event::getPrettyName, and avoid Event::TRACK_VOLUME etc each time
- using namespace Event;
-
- // create binding, then fill in data as from JSON.
- Binding* tmp = new Binding();
-
-
- cJSON* actionJson = cJSON_GetObjectItem( binding, "action" );
- if ( !actionJson )
- {
- LUPPP_WARN("Binding doesn't have action field: fix .ctlr file");
- return 0;
- }
-
- cJSON* statusJson = cJSON_GetObjectItem( binding, "status" );
- cJSON* dataJson = cJSON_GetObjectItem( binding, "data" );
- if ( !statusJson || !dataJson )
- {
- LUPPP_WARN("Binding w Action:%s doesn't have status / data field: fix .ctlr file", actionJson->valuestring);
- return 0;
- }
-
- tmp->status = statusJson->valueint;
- tmp->data = dataJson->valueint;
-
- // gets the Action type from the JSON string
- cJSON* activeJson = cJSON_GetObjectItem( binding, "active" );
- if ( activeJson )
- {
- tmp->active = activeJson->valueint;
- }
-
- // gets the active bool from the JSON
- tmp->action = Event::getTypeFromName( actionJson->valuestring );
-
- // check what our send value should be:
- cJSON* sendJson = cJSON_GetObjectItem( binding, "send" );
- if ( sendJson )
- {
- tmp->send = sendJson->valueint;
- }
-
- if ( strcmp( actionJson->valuestring, "grid:clip_state" ) == 0 )
- {
- tmp->action = Event::GRID_STATE;
-
- // read "state", to bind multiple values depending on clip state
-
- cJSON* stateBindings = cJSON_GetObjectItem( binding, "state");
- if ( stateBindings )
- {
- cJSON* empty = cJSON_GetObjectItem( stateBindings, "empty");
- cJSON* stopped = cJSON_GetObjectItem( stateBindings, "stopped");
- cJSON* playing = cJSON_GetObjectItem( stateBindings, "playing");
- cJSON* recording = cJSON_GetObjectItem( stateBindings, "recording");
- cJSON* qPlaying = cJSON_GetObjectItem( stateBindings, "queuePlaying");
- cJSON* qStopped = cJSON_GetObjectItem( stateBindings, "queueStopped");
- cJSON* qRecording = cJSON_GetObjectItem( stateBindings, "queueRecording");
-
- // keep a map of GridLogic::STATE to the MIDI byte 3 output from .ctlr file
- if ( empty )
- tmp->clipStateMap.insert( std::pair( GridLogic::STATE_EMPTY, empty->valueint ) );
- if ( stopped )
- tmp->clipStateMap.insert( std::pair( GridLogic::STATE_STOPPED, stopped->valueint ) );
- if ( playing )
- tmp->clipStateMap.insert( std::pair( GridLogic::STATE_PLAYING, playing->valueint ) );
- if ( recording )
- tmp->clipStateMap.insert( std::pair( GridLogic::STATE_RECORDING, recording->valueint ) );
-
- if ( qPlaying )
- tmp->clipStateMap.insert( std::pair( GridLogic::STATE_PLAY_QUEUED, qPlaying->valueint ) );
- if ( qStopped )
- tmp->clipStateMap.insert( std::pair( GridLogic::STATE_STOP_QUEUED, qStopped->valueint ) );
- if ( qRecording )
- tmp->clipStateMap.insert( std::pair( GridLogic::STATE_RECORD_QUEUED, qRecording->valueint ) );
- }
- /* // Extreme debugging
- for( map::iterator it = tmp->clipStateMap.begin(); it != tmp->clipStateMap.end(); ++it)
- {
- std::co ut << it->first << " " << it->second << "\n";
- }
- */
- }
-
- else if ( strcmp( actionJson->valuestring, "grid:launch_scene" ) == 0 ) {
- tmp->action = Event::GRID_LAUNCH_SCENE;
- }
- else if ( strcmp( actionJson->valuestring, "grid:special_clip_event" ) == 0 ) {
- tmp->action = Event::GRID_SELECT_CLIP_EVENT;
- }
- else if ( strcmp( actionJson->valuestring, "grid:select_clip_enable" ) == 0 ) {
- tmp->action = Event::GRID_SELECT_CLIP_ENABLE;
- }
- else if ( strcmp( actionJson->valuestring, "master:volume" ) == 0 ) {
- tmp->action = Event::MASTER_VOL;
- }
- else if ( strcmp( actionJson->valuestring, "metronome:active" ) == 0 ) {
- tmp->action = Event::METRONOME_ACTIVE;
- LUPPP_NOTE("binding metro active event, tmp->active == %i", tmp->active );
- }
-
- // check for valid event: otherwise pass
- if ( tmp->action != Event::EVENT_NULL )
- {
- //LUPPP_NOTE("Binding from %i %i %s", statusJson->valueint, dataJson->valueint, actionJson->valuestring);
-
- cJSON* track = cJSON_GetObjectItem( binding, "track" );
- cJSON* scene = cJSON_GetObjectItem( binding, "scene" );
- cJSON* activeJson = cJSON_GetObjectItem( binding, "active" );
-
- if ( track )
- tmp->track = track->valueint;
- if ( scene )
- tmp->scene = scene->valueint;
- if ( activeJson )
- tmp->active = activeJson->valueint;
-
- return tmp;
- }
- else
- {
- LUPPP_WARN("Binding action not recognized: %s", actionJson->valuestring );
- }
-
- return 0;
-
+ // include Event::getPrettyName, and avoid Event::TRACK_VOLUME etc each time
+ using namespace Event;
+
+ // create binding, then fill in data as from JSON.
+ Binding* tmp = new Binding();
+
+
+ cJSON* actionJson = cJSON_GetObjectItem( binding, "action" );
+ if ( !actionJson ) {
+ LUPPP_WARN("Binding doesn't have action field: fix .ctlr file");
+ return 0;
+ }
+
+ cJSON* statusJson = cJSON_GetObjectItem( binding, "status" );
+ cJSON* dataJson = cJSON_GetObjectItem( binding, "data" );
+ if ( !statusJson || !dataJson ) {
+ LUPPP_WARN("Binding w Action:%s doesn't have status / data field: fix .ctlr file", actionJson->valuestring);
+ return 0;
+ }
+
+ tmp->status = statusJson->valueint;
+ tmp->data = dataJson->valueint;
+
+ // gets the Action type from the JSON string
+ cJSON* activeJson = cJSON_GetObjectItem( binding, "active" );
+ if ( activeJson ) {
+ tmp->active = activeJson->valueint;
+ }
+
+ // gets the active bool from the JSON
+ tmp->action = Event::getTypeFromName( actionJson->valuestring );
+
+ // check what our send value should be:
+ cJSON* sendJson = cJSON_GetObjectItem( binding, "send" );
+ if ( sendJson ) {
+ tmp->send = sendJson->valueint;
+ }
+
+ if ( strcmp( actionJson->valuestring, "grid:clip_state" ) == 0 ) {
+ tmp->action = Event::GRID_STATE;
+
+ // read "state", to bind multiple values depending on clip state
+
+ cJSON* stateBindings = cJSON_GetObjectItem( binding, "state");
+ if ( stateBindings ) {
+ cJSON* empty = cJSON_GetObjectItem( stateBindings, "empty");
+ cJSON* stopped = cJSON_GetObjectItem( stateBindings, "stopped");
+ cJSON* playing = cJSON_GetObjectItem( stateBindings, "playing");
+ cJSON* recording = cJSON_GetObjectItem( stateBindings, "recording");
+ cJSON* qPlaying = cJSON_GetObjectItem( stateBindings, "queuePlaying");
+ cJSON* qStopped = cJSON_GetObjectItem( stateBindings, "queueStopped");
+ cJSON* qRecording = cJSON_GetObjectItem( stateBindings, "queueRecording");
+
+ // keep a map of GridLogic::STATE to the MIDI byte 3 output from .ctlr file
+ if ( empty )
+ tmp->clipStateMap.insert( std::pair( GridLogic::STATE_EMPTY, empty->valueint ) );
+ if ( stopped )
+ tmp->clipStateMap.insert( std::pair( GridLogic::STATE_STOPPED, stopped->valueint ) );
+ if ( playing )
+ tmp->clipStateMap.insert( std::pair( GridLogic::STATE_PLAYING, playing->valueint ) );
+ if ( recording )
+ tmp->clipStateMap.insert( std::pair( GridLogic::STATE_RECORDING, recording->valueint ) );
+
+ if ( qPlaying )
+ tmp->clipStateMap.insert( std::pair( GridLogic::STATE_PLAY_QUEUED, qPlaying->valueint ) );
+ if ( qStopped )
+ tmp->clipStateMap.insert( std::pair( GridLogic::STATE_STOP_QUEUED, qStopped->valueint ) );
+ if ( qRecording )
+ tmp->clipStateMap.insert( std::pair( GridLogic::STATE_RECORD_QUEUED, qRecording->valueint ) );
+ }
+ /* // Extreme debugging
+ for( map::iterator it = tmp->clipStateMap.begin(); it != tmp->clipStateMap.end(); ++it)
+ {
+ std::co ut << it->first << " " << it->second << "\n";
+ }
+ */
+ }
+
+ else if ( strcmp( actionJson->valuestring, "grid:launch_scene" ) == 0 ) {
+ tmp->action = Event::GRID_LAUNCH_SCENE;
+ } else if ( strcmp( actionJson->valuestring, "grid:special_clip_event" ) == 0 ) {
+ tmp->action = Event::GRID_SELECT_CLIP_EVENT;
+ } else if ( strcmp( actionJson->valuestring, "grid:select_clip_enable" ) == 0 ) {
+ tmp->action = Event::GRID_SELECT_CLIP_ENABLE;
+ } else if ( strcmp( actionJson->valuestring, "master:volume" ) == 0 ) {
+ tmp->action = Event::MASTER_VOL;
+ } else if ( strcmp( actionJson->valuestring, "metronome:active" ) == 0 ) {
+ tmp->action = Event::METRONOME_ACTIVE;
+ LUPPP_NOTE("binding metro active event, tmp->active == %i", tmp->active );
+ }
+
+ // check for valid event: otherwise pass
+ if ( tmp->action != Event::EVENT_NULL ) {
+ //LUPPP_NOTE("Binding from %i %i %s", statusJson->valueint, dataJson->valueint, actionJson->valuestring);
+
+ cJSON* track = cJSON_GetObjectItem( binding, "track" );
+ cJSON* scene = cJSON_GetObjectItem( binding, "scene" );
+ cJSON* activeJson = cJSON_GetObjectItem( binding, "active" );
+
+ if ( track )
+ tmp->track = track->valueint;
+ if ( scene )
+ tmp->scene = scene->valueint;
+ if ( activeJson )
+ tmp->active = activeJson->valueint;
+
+ return tmp;
+ } else {
+ LUPPP_WARN("Binding action not recognized: %s", actionJson->valuestring );
+ }
+
+ return 0;
+
}
diff --git a/src/controller/genericmidi.hxx b/src/controller/genericmidi.hxx
index f5841b4..9b7f0a7 100644
--- a/src/controller/genericmidi.hxx
+++ b/src/controller/genericmidi.hxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -36,96 +36,96 @@
**/
class GenericMIDI : public Controller, public MidiIO
{
- public:
- /// Creates a blank GenericMIDI instance, which can be bound dynamically
- GenericMIDI(int waste = 0, std::string name = "generic");
-
- /// Attempts to load a .ctlr file, pointed to by the string
- GenericMIDI(std::string file);
-
- int registerComponents();
-
- Controller::STATUS status();
-
- void setName(std::string );
- std::string getName();
- std::string getAuthor();
- std::string getEmail();
-
- /// track actions
- //void mute(int t, bool b);
-
- void metronomeEnable(bool b);
-
- void launchScene( int scene );
-
- void volume(int t, float f);
-
-
- void recordArm(int t, bool b);
- void setSceneState(int track, int clip, GridLogic::State s);
-
- /*
- void progress(int t, int s, float f);
- void launchScene( int scene );
-
- /// track FX
- void trackSend(int t, int send, float v);
- */
-
- void trackSend(int t, int send, float v);
- void trackSendActive(int t, int send, bool a);
+public:
+ /// Creates a blank GenericMIDI instance, which can be bound dynamically
+ GenericMIDI(int waste = 0, std::string name = "generic");
- virtual void trackJackSend(int t, float v);
- virtual void trackJackSendActivate(int t, bool a);
-
- /// footswitch -> scene launch controls
- void setFootswitchToNextScene(int v);
- bool footswitchNextScene;
- bool footswitchPrevScene;
-
-
- void reset();
-
- void midi(unsigned char* data);
-
- void process(int nframes);
-
- const std::vector& getMidiToAction();
-
- // for adding bindings from MIDI / GUI event pair
- void setupBinding( LupppAction eventType, int midiStatus, int midiData, int track, int scene, int send, int active );
- void removeBinding( int bindingID );
-
- private:
- STATUS stat;
-
- std::string name;
- std::string author;
- std::string email;
-
- /// contains midi binding instances
- std::vector midiToAction;
- std::vector actionToMidi;
-
- int loadController(std::string controllerFile);
-
- /// creates a binding from a cJSON inputBindings / outputBindings object
- Binding* setupBinding( cJSON* bindings );
-
-
- /// for "sampling" a clip in the grid, and applying events to it:
- /// footpedal for example
- bool shiftPressed;
- int footpedalTrack;
- int footpedalScene;
-
- /*
- /// for handling events
- void ccChange( int track, int cc, float value );
- void noteOff( int track, int note, int vel );
- void noteOn( int track, int note, int vel );
- */
+ /// Attempts to load a .ctlr file, pointed to by the string
+ GenericMIDI(std::string file);
+
+ int registerComponents();
+
+ Controller::STATUS status();
+
+ void setName(std::string );
+ std::string getName();
+ std::string getAuthor();
+ std::string getEmail();
+
+ /// track actions
+ //void mute(int t, bool b);
+
+ void metronomeEnable(bool b);
+
+ void launchScene( int scene );
+
+ void volume(int t, float f);
+
+
+ void recordArm(int t, bool b);
+ void setSceneState(int track, int clip, GridLogic::State s);
+
+ /*
+ void progress(int t, int s, float f);
+ void launchScene( int scene );
+
+ /// track FX
+ void trackSend(int t, int send, float v);
+ */
+
+ void trackSend(int t, int send, float v);
+ void trackSendActive(int t, int send, bool a);
+
+ virtual void trackJackSend(int t, float v);
+ virtual void trackJackSendActivate(int t, bool a);
+
+ /// footswitch -> scene launch controls
+ void setFootswitchToNextScene(int v);
+ bool footswitchNextScene;
+ bool footswitchPrevScene;
+
+
+ void reset();
+
+ void midi(unsigned char* data);
+
+ void process(int nframes);
+
+ const std::vector& getMidiToAction();
+
+ // for adding bindings from MIDI / GUI event pair
+ void setupBinding( LupppAction eventType, int midiStatus, int midiData, int track, int scene, int send, int active );
+ void removeBinding( int bindingID );
+
+private:
+ STATUS stat;
+
+ std::string name;
+ std::string author;
+ std::string email;
+
+ /// contains midi binding instances
+ std::vector midiToAction;
+ std::vector actionToMidi;
+
+ int loadController(std::string controllerFile);
+
+ /// creates a binding from a cJSON inputBindings / outputBindings object
+ Binding* setupBinding( cJSON* bindings );
+
+
+ /// for "sampling" a clip in the grid, and applying events to it:
+ /// footpedal for example
+ bool shiftPressed;
+ int footpedalTrack;
+ int footpedalScene;
+
+ /*
+ /// for handling events
+ void ccChange( int track, int cc, float value );
+ void noteOff( int track, int note, int vel );
+ void noteOn( int track, int note, int vel );
+ */
};
#endif // LUPPP_GENERIC_MIDI_H
diff --git a/src/controller/guicontroller.cxx b/src/controller/guicontroller.cxx
index bc7a5c3..2a91f22 100644
--- a/src/controller/guicontroller.cxx
+++ b/src/controller/guicontroller.cxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -30,120 +30,120 @@
extern Jack* jack;
LupppGUI::LupppGUI() :
- Controller()
+ Controller()
{
}
void LupppGUI::masterInputVol(float f)
{
- EventMasterInputVol e( f );
- writeToGuiRingbuffer( &e );
+ EventMasterInputVol e( f );
+ writeToGuiRingbuffer( &e );
}
void LupppGUI::masterInputTo(int to,float f)
{
- EventMasterInputTo e( (Event::INPUT_TO)to, f );
- writeToGuiRingbuffer( &e );
+ EventMasterInputTo e( (Event::INPUT_TO)to, f );
+ writeToGuiRingbuffer( &e );
}
void LupppGUI::masterInputToActive(int to,float f)
{
- EventMasterInputToActive e( (Event::INPUT_TO)to, f );
- writeToGuiRingbuffer( &e );
+ EventMasterInputToActive e( (Event::INPUT_TO)to, f );
+ writeToGuiRingbuffer( &e );
}
void LupppGUI::masterVolume(float f)
{
- EventMasterVol e( f );
- writeToGuiRingbuffer( &e );
+ EventMasterVol e( f );
+ writeToGuiRingbuffer( &e );
}
void LupppGUI::masterReturnVolume(float f)
{
- printf(" return %f ", f );
- EventMasterReturn e( RETURN_MAIN, f );
- writeToGuiRingbuffer( &e );
+ printf(" return %f ", f );
+ EventMasterReturn e( RETURN_MAIN, f );
+ writeToGuiRingbuffer( &e );
}
void LupppGUI::metronomeEnable(bool r)
{
- EventMetronomeActive e( r );
- writeToGuiRingbuffer( &e );
+ EventMetronomeActive e( r );
+ writeToGuiRingbuffer( &e );
}
void LupppGUI::recordArm(int t, bool r)
{
- EventTrackRecordArm e( t, r );
- writeToGuiRingbuffer( &e );
+ EventTrackRecordArm e( t, r );
+ writeToGuiRingbuffer( &e );
}
void LupppGUI::trackSend(int t, int send, float r)
{
- EventTrackSend e( t, static_cast(send), r );
- writeToGuiRingbuffer( &e );
+ EventTrackSend e( t, static_cast(send), r );
+ writeToGuiRingbuffer( &e );
}
void LupppGUI::specialScene(int t, int s)
{
- EventGridSelectNewChosen e( t, s );
- writeToGuiRingbuffer( &e );
+ EventGridSelectNewChosen e( t, s );
+ writeToGuiRingbuffer( &e );
}
void LupppGUI::trackSendActive(int t, int send, bool a)
{
- EventTrackSendActive e( t, static_cast(send), a );
- writeToGuiRingbuffer( &e );
+ EventTrackSendActive e( t, static_cast(send), a );
+ writeToGuiRingbuffer( &e );
}
void LupppGUI::trackJackSend(int t, float v)
{
- EventTrackJackSend e(t,v);
- writeToGuiRingbuffer(&e);
+ EventTrackJackSend e(t,v);
+ writeToGuiRingbuffer(&e);
}
void LupppGUI::trackJackSendActivate(int t, bool a)
{
- EventTrackJackSendActivate e(t,a);
- writeToGuiRingbuffer(&e);
+ EventTrackJackSendActivate e(t,a);
+ writeToGuiRingbuffer(&e);
}
void LupppGUI::setSceneState(int t, int clip, GridLogic::State s)
{
- EventGridState e( t, clip, s );
- writeToGuiRingbuffer( &e );
+ EventGridState e( t, clip, s );
+ writeToGuiRingbuffer( &e );
}
void LupppGUI::launchScene( int scene )
{
- EventGridLaunchScene e( scene );
- writeToGuiRingbuffer( &e );
+ EventGridLaunchScene e( scene );
+ writeToGuiRingbuffer( &e );
}
void LupppGUI::mute(int t, bool b)
{
-
+
}
void LupppGUI::tapTempo( bool b )
{
- EventTimeTempoTap e(b);
- writeToGuiRingbuffer( &e );
+ EventTimeTempoTap e(b);
+ writeToGuiRingbuffer( &e );
}
void LupppGUI::bpm(int bpm)
{
- EventTimeBPM e(bpm);
- writeToGuiRingbuffer( &e );
+ EventTimeBPM e(bpm);
+ writeToGuiRingbuffer( &e );
}
void LupppGUI::volume(int t, float f)
{
- EventTrackVol e( t, f );
- writeToGuiRingbuffer( &e );
+ EventTrackVol e( t, f );
+ writeToGuiRingbuffer( &e );
}
void LupppGUI::progress(int t, int s, float f)
{
- EventLooperProgress e( t, f );
- writeToGuiRingbuffer( &e );
+ EventLooperProgress e( t, f );
+ writeToGuiRingbuffer( &e );
}
diff --git a/src/controller/guicontroller.hxx b/src/controller/guicontroller.hxx
index f346b50..b4cc766 100644
--- a/src/controller/guicontroller.hxx
+++ b/src/controller/guicontroller.hxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -26,37 +26,40 @@
class LupppGUI : public Controller
{
- public:
- LupppGUI();
-
- std::string getName(){return "Luppp GUI";}
-
- void masterVolume(float f);
- void masterReturnVolume(float f);
- void masterInputVol(float v);
- void masterInputTo(int to,float f);
- void masterInputToActive(int to,float f);
-
- void metronomeEnable(bool b);
-
- void trackSend(int t, int send, float r);
- void trackSendActive(int t, int send, bool a);
+public:
+ LupppGUI();
+
+ std::string getName()
+ {
+ return "Luppp GUI";
+ }
+
+ void masterVolume(float f);
+ void masterReturnVolume(float f);
+ void masterInputVol(float v);
+ void masterInputTo(int to,float f);
+ void masterInputToActive(int to,float f);
+
+ void metronomeEnable(bool b);
+
+ void trackSend(int t, int send, float r);
+ void trackSendActive(int t, int send, bool a);
+
+ virtual void trackJackSend(int t, float v);
+ virtual void trackJackSendActivate(int t, bool a);
+
+ void bpm(int bpm);
+ void tapTempo( bool b );
+
+ void specialScene(int t, int scene);
+
+ void mute(int t, bool b);
+ void volume(int t, float f);
+ void progress(int t, int s, float p);
+ void recordArm(int t, bool b);
+ void launchScene( int scene );
+ void setSceneState(int track, int clip, GridLogic::State s);
- virtual void trackJackSend(int t, float v);
- virtual void trackJackSendActivate(int t, bool a);
-
- void bpm(int bpm);
- void tapTempo( bool b );
-
- void specialScene(int t, int scene);
-
- void mute(int t, bool b);
- void volume(int t, float f);
- void progress(int t, int s, float p);
- void recordArm(int t, bool b);
- void launchScene( int scene );
- void setSceneState(int track, int clip, GridLogic::State s);
-
};
#endif // LUPPP_CONTROLLER_GUI_H
diff --git a/src/controller/nonseq.cxx b/src/controller/nonseq.cxx
index 7bb6060..33d0de3 100644
--- a/src/controller/nonseq.cxx
+++ b/src/controller/nonseq.cxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -26,56 +26,56 @@
#include "../looperclip.hxx"
NonSeq::NonSeq() :
- Controller(),
- MidiIO()
+ Controller(),
+ MidiIO()
{
- std::string name = "non-seq";
- registerMidiPorts( name );
+ std::string name = "non-seq";
+ registerMidiPorts( name );
}
void NonSeq::launchScene( int scene )
{
- unsigned char data[3];
- data[0] = 176;
- data[1] = 20;
- data[2] = scene;
-
- //LUPPP_NOTE("NonSeq::launchScene() %i, %i, %i\n", data[0],data[1],data[2] );
- writeMidi( data );
+ unsigned char data[3];
+ data[0] = 176;
+ data[1] = 20;
+ data[2] = scene;
+
+ //LUPPP_NOTE("NonSeq::launchScene() %i, %i, %i\n", data[0],data[1],data[2] );
+ writeMidi( data );
}
std::string NonSeq::getName()
{
- return "non-seq";
+ return "non-seq";
}
void NonSeq::setSceneState(int track, int scene, GridLogic::State s)
{
- unsigned char data[3];
- data[0] = 176;
- data[1] = 22; // off
-
- // check *actual* value of playing: *NOT* GridState::s, because it could be queued
- // for something else, but we want the *actual* here, not "queued". This is a unique
- // use case because were trying to control non-seq as if it were part of Luppp.
- if( jack->getLooper( track )->getClip( scene )->playing() )
- data[1] = 21;
-
- data[2] = track;
-
- //LUPPP_NOTE("NonSeq::setSceneState() %i, %i, %i\n", data[0],data[1],data[2] );
- writeMidi( data );
+ unsigned char data[3];
+ data[0] = 176;
+ data[1] = 22; // off
+
+ // check *actual* value of playing: *NOT* GridState::s, because it could be queued
+ // for something else, but we want the *actual* here, not "queued". This is a unique
+ // use case because were trying to control non-seq as if it were part of Luppp.
+ if( jack->getLooper( track )->getClip( scene )->playing() )
+ data[1] = 21;
+
+ data[2] = track;
+
+ //LUPPP_NOTE("NonSeq::setSceneState() %i, %i, %i\n", data[0],data[1],data[2] );
+ writeMidi( data );
}
int NonSeq::registerComponents()
{
- // makes JACK add this controller to the midiObservers list:
- // note the static_cast<>() is *needed* here for multiple-inheritance
- MidiIO* m = static_cast(this);
-
- jack->registerMidiIO( m );
-
- return LUPPP_RETURN_OK;
+ // makes JACK add this controller to the midiObservers list:
+ // note the static_cast<>() is *needed* here for multiple-inheritance
+ MidiIO* m = static_cast(this);
+
+ jack->registerMidiIO( m );
+
+ return LUPPP_RETURN_OK;
}
diff --git a/src/controller/nonseq.hxx b/src/controller/nonseq.hxx
index 6bcc3a4..fb20666 100644
--- a/src/controller/nonseq.hxx
+++ b/src/controller/nonseq.hxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -29,17 +29,17 @@
**/
class NonSeq : public Controller, public MidiIO
{
- public:
- NonSeq();
- ~NonSeq(){};
-
- std::string getName();
-
- int registerComponents();
-
- void launchScene( int scene );
-
- void setSceneState(int track, int scene, GridLogic::State s);
+public:
+ NonSeq();
+ ~NonSeq() {};
+
+ std::string getName();
+
+ int registerComponents();
+
+ void launchScene( int scene );
+
+ void setSceneState(int track, int scene, GridLogic::State s);
};
#endif // LUPPP_NON_SEQ_H
diff --git a/src/controllerupdater.cxx b/src/controllerupdater.cxx
index 546dcb5..12a7240 100644
--- a/src/controllerupdater.cxx
+++ b/src/controllerupdater.cxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -22,167 +22,162 @@
ControllerUpdater::ControllerUpdater()
{
- // CAREFUL size of controllers: otherwise malloc() called
- c.reserve( CONTROLLERS_PREALLOC );
+ // CAREFUL size of controllers: otherwise malloc() called
+ c.reserve( CONTROLLERS_PREALLOC );
}
void ControllerUpdater::registerController( Controller* controller )
{
- if (!controller)
- {
- LUPPP_ERROR("Register Controller passed NULL controller!");
- return;
- }
-
- //LUPPP_NOTE("Registering controller %s", controller->getName().c_str() );
-
- // store the controller instance
- c.push_back( controller );
-
- // and tell it to register itself (MidiObserver / AudioObserver etc)
- controller->registerComponents();
+ if (!controller) {
+ LUPPP_ERROR("Register Controller passed NULL controller!");
+ return;
+ }
+
+ //LUPPP_NOTE("Registering controller %s", controller->getName().c_str() );
+
+ // store the controller instance
+ c.push_back( controller );
+
+ // and tell it to register itself (MidiObserver / AudioObserver etc)
+ controller->registerComponents();
}
void ControllerUpdater::removeController( int id )
{
- for( unsigned int i = 0; i < c.size(); i++)
- {
- if ( c.at(i)->getID() == id )
- {
- // keep pointer: otherwise we mem-leak
- Controller* removed = c.at( i );
-
- cout << "Removing item " << i << " with name " << removed->getName() << endl;
-
- // remove the instance at
- c.erase( c.begin() + i );
-
- // send it for de-allocation
- EventControllerInstance e( removed );
- writeToGuiRingbuffer( &e );
- }
- }
-
+ for( unsigned int i = 0; i < c.size(); i++) {
+ if ( c.at(i)->getID() == id ) {
+ // keep pointer: otherwise we mem-leak
+ Controller* removed = c.at( i );
+
+ cout << "Removing item " << i << " with name " << removed->getName() << endl;
+
+ // remove the instance at
+ c.erase( c.begin() + i );
+
+ // send it for de-allocation
+ EventControllerInstance e( removed );
+ writeToGuiRingbuffer( &e );
+ }
+ }
+
}
Controller* ControllerUpdater::getController(int id)
{
- // search controllers for ID, if found return a pointer to it
- for( unsigned int i = 0; i < c.size(); i++)
- {
- if ( c.at(i)->getID() == id )
- {
- LUPPP_NOTE("getController target ID: %i, found ID: %i, returning %s", id, i, c.at(i)->getName().c_str() );
- return c.at(i);
- }
- }
- return 0;
+ // search controllers for ID, if found return a pointer to it
+ for( unsigned int i = 0; i < c.size(); i++) {
+ if ( c.at(i)->getID() == id ) {
+ LUPPP_NOTE("getController target ID: %i, found ID: %i, returning %s", id, i, c.at(i)->getName().c_str() );
+ return c.at(i);
+ }
+ }
+ return 0;
}
void ControllerUpdater::reset()
{
- for(unsigned int i = 0; i < c.size(); i++)
- c.at(i)->reset();
+ for(unsigned int i = 0; i < c.size(); i++)
+ c.at(i)->reset();
}
void ControllerUpdater::mute(int t, bool b)
{
- for(unsigned int i = 0; i < c.size(); i++)
- c.at(i)->mute(t,b);
+ for(unsigned int i = 0; i < c.size(); i++)
+ c.at(i)->mute(t,b);
}
void ControllerUpdater::masterVolume(float v)
{
- for(unsigned int i = 0; i < c.size(); i++)
- c.at(i)->masterVolume(v);
+ for(unsigned int i = 0; i < c.size(); i++)
+ c.at(i)->masterVolume(v);
}
void ControllerUpdater::masterReturnVolume(float v)
{
- for(unsigned int i = 0; i < c.size(); i++)
- c.at(i)->masterReturnVolume( v );
+ for(unsigned int i = 0; i < c.size(); i++)
+ c.at(i)->masterReturnVolume( v );
}
void ControllerUpdater::setTrackSceneProgress(int t, int s, float p)
{
- for(unsigned int i = 0; i < c.size(); i++)
- c.at(i)->progress(t,s,p);
+ for(unsigned int i = 0; i < c.size(); i++)
+ c.at(i)->progress(t,s,p);
}
void ControllerUpdater::setTrackSendActive(int t, int send, bool v)
{
- for(unsigned int i = 0; i < c.size(); i++)
- c.at(i)->trackSendActive(t, send, v);
+ for(unsigned int i = 0; i < c.size(); i++)
+ c.at(i)->trackSendActive(t, send, v);
}
void ControllerUpdater::setTrackSend(int t, int send, float v)
{
- for(unsigned int i = 0; i < c.size(); i++)
- c.at(i)->trackSend(t, send, v);
+ for(unsigned int i = 0; i < c.size(); i++)
+ c.at(i)->trackSend(t, send, v);
}
void ControllerUpdater::setTrackJackSendActive(int t, bool v)
{
- for(unsigned int i = 0; i < c.size(); i++)
- c.at(i)->trackJackSendActivate(t, v);
+ for(unsigned int i = 0; i < c.size(); i++)
+ c.at(i)->trackJackSendActivate(t, v);
}
void ControllerUpdater::setTrackJackSend(int t, float v)
{
- for(unsigned int i = 0; i < c.size(); i++)
- c.at(i)->trackJackSend(t, v);
+ for(unsigned int i = 0; i < c.size(); i++)
+ c.at(i)->trackJackSend(t, v);
}
void ControllerUpdater::specialScene(int t, int scene)
{
- for(unsigned int i = 0; i < c.size(); i++)
- c.at(i)->specialScene(t, scene);
+ for(unsigned int i = 0; i < c.size(); i++)
+ c.at(i)->specialScene(t, scene);
}
void ControllerUpdater::masterInputToActive(int to, bool v)
{
- for(unsigned int i = 0; i < c.size(); i++)
- c.at(i)->masterInputToActive( to, v);
+ for(unsigned int i = 0; i < c.size(); i++)
+ c.at(i)->masterInputToActive( to, v);
}
void ControllerUpdater::masterInputTo( int to, float v )
{
- for(unsigned int i = 0; i < c.size(); i++)
- c.at(i)->masterInputTo( to, v);
+ for(unsigned int i = 0; i < c.size(); i++)
+ c.at(i)->masterInputTo( to, v);
}
void ControllerUpdater::masterInputVol( float v )
{
- for(unsigned int i = 0; i < c.size(); i++)
- c.at(i)->masterInputVol( v );
+ for(unsigned int i = 0; i < c.size(); i++)
+ c.at(i)->masterInputVol( v );
}
void ControllerUpdater::launchScene( int scene )
{
- for(unsigned int i = 0; i < c.size(); i++)
- c.at(i)->launchScene(scene);
+ for(unsigned int i = 0; i < c.size(); i++)
+ c.at(i)->launchScene(scene);
}
void ControllerUpdater::setSceneState(int t, int clip, GridLogic::State s)
{
- for(unsigned int i = 0; i < c.size(); i++)
- c.at(i)->setSceneState(t,clip,s);
+ for(unsigned int i = 0; i < c.size(); i++)
+ c.at(i)->setSceneState(t,clip,s);
}
void ControllerUpdater::recordArm(int t, bool r)
{
- for(unsigned int i = 0; i < c.size(); i++)
- c.at(i)->recordArm(t,r);
+ for(unsigned int i = 0; i < c.size(); i++)
+ c.at(i)->recordArm(t,r);
}
void ControllerUpdater::volume(int t, float v)
{
- for(unsigned int i = 0; i < c.size(); i++) c.at(i)->volume(t,v);
+ for(unsigned int i = 0; i < c.size(); i++) c.at(i)->volume(t,v);
}
void ControllerUpdater::tapTempo(bool b)
{
- for(unsigned int i = 0; i < c.size(); i++) c.at(i)->tapTempo(b);
+ for(unsigned int i = 0; i < c.size(); i++) c.at(i)->tapTempo(b);
}
void ControllerUpdater::metronomeEnable(bool b)
{
- for(unsigned int i = 0; i < c.size(); i++) c.at(i)->metronomeEnable(b);
+ for(unsigned int i = 0; i < c.size(); i++) c.at(i)->metronomeEnable(b);
}
diff --git a/src/controllerupdater.hxx b/src/controllerupdater.hxx
index 216cb54..c46a050 100644
--- a/src/controllerupdater.hxx
+++ b/src/controllerupdater.hxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -33,60 +33,60 @@ using namespace std;
* Updates each registered controller when a certain event occurs. All output
* devices (MIDI controllers, GUI, OSC-UI's etc) are registered in order to
* stay up-to-date.
- *
+ *
* This class does no scheduling, it passes the events to the Controllers
* immidiatly.
- *
+ *
* The Logic class is the opposite of this: it takes input and Luppp processes
* it, pushing the relevant updates in state through ControllerUpdater to each
* registered device.
**/
class ControllerUpdater
{
- public:
- ControllerUpdater();
-
- /// add a Controller* to Controllers that recieve updates
- void registerController( Controller* controller );
-
- /// removes a controller by ID
- void removeController( int controllerID );
-
- /// returns a Controller* from ID
- Controller* getController(int id);
-
- void reset();
- void mute(int t, bool b);
-
- void masterVolume(float v);
- void masterReturnVolume(float v);
- void masterInputToActive(int to, bool v);
- void masterInputTo( int inputTo, float vol );
- void masterInputVol( float vol );
-
- void setTrackSceneProgress(int t, int s, float p);
- void setTrackSendActive(int t, int send, bool v);
- void setTrackSend(int t, int send, float v);
+public:
+ ControllerUpdater();
- void setTrackJackSendActive(int t, bool v);
- void setTrackJackSend(int t, float v);
-
- void specialScene(int t, int scene);
-
- void launchScene( int scene );
-
- void setSceneState(int t, int clip, GridLogic::State s);
-
- void recordArm(int t, bool r);
-
- void volume(int t, float v);
-
- void tapTempo(bool b);
-
- void metronomeEnable(bool b);
-
- private:
- std::vector c;
+ /// add a Controller* to Controllers that recieve updates
+ void registerController( Controller* controller );
+
+ /// removes a controller by ID
+ void removeController( int controllerID );
+
+ /// returns a Controller* from ID
+ Controller* getController(int id);
+
+ void reset();
+ void mute(int t, bool b);
+
+ void masterVolume(float v);
+ void masterReturnVolume(float v);
+ void masterInputToActive(int to, bool v);
+ void masterInputTo( int inputTo, float vol );
+ void masterInputVol( float vol );
+
+ void setTrackSceneProgress(int t, int s, float p);
+ void setTrackSendActive(int t, int send, bool v);
+ void setTrackSend(int t, int send, float v);
+
+ void setTrackJackSendActive(int t, bool v);
+ void setTrackJackSend(int t, float v);
+
+ void specialScene(int t, int scene);
+
+ void launchScene( int scene );
+
+ void setSceneState(int t, int clip, GridLogic::State s);
+
+ void recordArm(int t, bool r);
+
+ void volume(int t, float v);
+
+ void tapTempo(bool b);
+
+ void metronomeEnable(bool b);
+
+private:
+ std::vector c;
};
#endif // LUPPP_CONTROLLER_UPDATER_H
diff --git a/src/debug.cxx b/src/debug.cxx
index a816a91..7e01396 100644
--- a/src/debug.cxx
+++ b/src/debug.cxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -24,34 +24,26 @@
void luppp_debug( int warnLevel, const char* name, const char* file, const char* func, int line,
const char* format, ... )
{
- if ( warnLevel == DEBUG_LEVEL_ERROR )
- {
- printf( "[\033[1;31m%s\033[0m] %s:%i: ", name, func, line );
- }
- else if ( warnLevel == DEBUG_LEVEL_WARN )
- {
- printf( "[\033[1;33m%s\033[0m] %s:%i: ", name, func, line );
- }
- else if ( warnLevel == DEBUG_LEVEL_TEST )
- {
+ if ( warnLevel == DEBUG_LEVEL_ERROR ) {
+ printf( "[\033[1;31m%s\033[0m] %s:%i: ", name, func, line );
+ } else if ( warnLevel == DEBUG_LEVEL_WARN ) {
+ printf( "[\033[1;33m%s\033[0m] %s:%i: ", name, func, line );
+ } else if ( warnLevel == DEBUG_LEVEL_TEST ) {
#ifdef BUILD_TESTS
- printf( "[\033[1;33m%s\033[0m] %s:%i: ", name, func, line );
+ printf( "[\033[1;33m%s\033[0m] %s:%i: ", name, func, line );
#endif
- }
- else // NOTE
- {
- printf( "[\033[1;32m%s\033[0m] %s:%i: ", name, func, line );
- }
- printf( "\033[0m" );
-
- if ( format )
- {
- va_list args;
- va_start( args, format );
- vfprintf( stdout, format, args );
- va_end( args );
- }
- printf( "\n" );
-
+ } else { // NOTE
+ printf( "[\033[1;32m%s\033[0m] %s:%i: ", name, func, line );
+ }
+ printf( "\033[0m" );
+
+ if ( format ) {
+ va_list args;
+ va_start( args, format );
+ vfprintf( stdout, format, args );
+ va_end( args );
+ }
+ printf( "\n" );
+
}
diff --git a/src/debug.hxx b/src/debug.hxx
index 1dbc079..c30525b 100644
--- a/src/debug.hxx
+++ b/src/debug.hxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -29,10 +29,10 @@ LUPPP_KILL( "%s", "MessageHere" );
*/
enum DEBUG_LEVEL {
- DEBUG_LEVEL_NOTE = 0,
- DEBUG_LEVEL_WARN,
- DEBUG_LEVEL_ERROR,
- DEBUG_LEVEL_TEST
+ DEBUG_LEVEL_NOTE = 0,
+ DEBUG_LEVEL_WARN,
+ DEBUG_LEVEL_ERROR,
+ DEBUG_LEVEL_TEST
};
void luppp_debug( int warnLevel, const char* name, const char* file, const char* func, int line,
diff --git a/src/denormals.hxx b/src/denormals.hxx
index 7b6eed5..833c954 100644
--- a/src/denormals.hxx
+++ b/src/denormals.hxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -29,23 +29,23 @@
#include
inline void AVOIDDENORMALS()
{
- //LUPPP_NOTE("Denormals: FZ DAZ using SSE3");
- _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
- _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
+ //LUPPP_NOTE("Denormals: FZ DAZ using SSE3");
+ _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
+ _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
}
#else
#include
inline void AVOIDDENORMALS()
{
- //LUPPP_NOTE("Denormals: FZ");
- _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
+ //LUPPP_NOTE("Denormals: FZ");
+ _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
}
#endif //__SSE3__
#else
inline void AVOIDDENORMALS()
{
- LUPPP_NOTE( "Denormals: Warning! No protection" );
+ LUPPP_NOTE( "Denormals: Warning! No protection" );
}
#endif //__SSE__
diff --git a/src/diskreader.cxx b/src/diskreader.cxx
index 68f4de4..fba02d9 100644
--- a/src/diskreader.cxx
+++ b/src/diskreader.cxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -43,650 +43,593 @@ using namespace std;
DiskReader::DiskReader()
{
- resampleQuality = 1;
-
- // FIXME: could use a config item of sample location?
- lastLoadedSamplePath = getenv("HOME");
+ resampleQuality = 1;
+
+ // FIXME: could use a config item of sample location?
+ lastLoadedSamplePath = getenv("HOME");
}
int DiskReader::loadPreferences()
{
- stringstream s;
- s << getenv("HOME") << "/.config/openAV/luppp/luppp.prfs";
- std::ifstream sampleFile( s.str().c_str(), std::ios_base::in|std::ios_base::ate);
-
- long file_length = sampleFile.tellg();
- if ( file_length > 0 )
- {
- sampleFile.seekg(0, std::ios_base::beg);
- sampleFile.clear();
- char *sampleString = new char[file_length];
- sampleFile.read(sampleString, file_length);
-
- cJSON* preferencesJson = cJSON_Parse( sampleString );
- if (!preferencesJson)
- {
- LUPPP_WARN("Preferences JSON not valid");
- return LUPPP_RETURN_ERROR;
- }
-
-
- cJSON* resample = cJSON_GetObjectItem( preferencesJson, "resampleQuality" );
- if ( resample )
- {
- resampleQuality = resample->valueint;
- if ( resampleQuality == 0 )
- {
- LUPPP_NOTE("Using Linear resampling, may reduce quality. Check .config/openAV/luppp/luppp.prfs");
- }
- }
- cJSON* ctlrs = cJSON_GetObjectItem( preferencesJson, "defaultControllers" );
- if ( ctlrs )
- {
- //cout << ".ctlr HAS items." << endl;
- int nCtlrs = cJSON_GetArraySize( ctlrs );
- for(int i = 0; i < nCtlrs; i++ )
- {
- cJSON* ctlr = cJSON_GetArrayItem( ctlrs, i );
- if( ctlr )
- {
- LUPPP_NOTE("Loading controller %s", ctlr->valuestring);
- stringstream s;
- s << getenv("HOME") << "/.config/openAV/luppp/controllers/" << ctlr->valuestring;
- gui->addMidiControllerToSetup( s.str() );
- }
- }
- }
- else
- {
- LUPPP_NOTE("No default controllers active.");
- }
+ stringstream s;
+ s << getenv("HOME") << "/.config/openAV/luppp/luppp.prfs";
+ std::ifstream sampleFile( s.str().c_str(), std::ios_base::in|std::ios_base::ate);
+
+ long file_length = sampleFile.tellg();
+ if ( file_length > 0 ) {
+ sampleFile.seekg(0, std::ios_base::beg);
+ sampleFile.clear();
+ char *sampleString = new char[file_length];
+ sampleFile.read(sampleString, file_length);
+
+ cJSON* preferencesJson = cJSON_Parse( sampleString );
+ if (!preferencesJson) {
+ LUPPP_WARN("Preferences JSON not valid");
+ return LUPPP_RETURN_ERROR;
+ }
- cJSON* projDir=cJSON_GetObjectItem(preferencesJson,"saveDirectory");
- string dir=getenv("HOME");
- if(projDir)
- {
- stringstream s;
- s<valuestring;
- dir=s.str();
- }
- gui->setProjectsDir(dir);
+ cJSON* resample = cJSON_GetObjectItem( preferencesJson, "resampleQuality" );
+ if ( resample ) {
+ resampleQuality = resample->valueint;
+ if ( resampleQuality == 0 ) {
+ LUPPP_NOTE("Using Linear resampling, may reduce quality. Check .config/openAV/luppp/luppp.prfs");
+ }
+ }
+ cJSON* ctlrs = cJSON_GetObjectItem( preferencesJson, "defaultControllers" );
+ if ( ctlrs ) {
+ //cout << ".ctlr HAS items." << endl;
+ int nCtlrs = cJSON_GetArraySize( ctlrs );
+ for(int i = 0; i < nCtlrs; i++ ) {
+ cJSON* ctlr = cJSON_GetArrayItem( ctlrs, i );
+ if( ctlr ) {
+ LUPPP_NOTE("Loading controller %s", ctlr->valuestring);
+ stringstream s;
+ s << getenv("HOME") << "/.config/openAV/luppp/controllers/" << ctlr->valuestring;
+ gui->addMidiControllerToSetup( s.str() );
+ }
+ }
+ } else {
+ LUPPP_NOTE("No default controllers active.");
+ }
- //Enable per track send and resturn jack ports?
- cJSON* jackPerTrackOutput=cJSON_GetObjectItem(preferencesJson,"enablePerTrackOutput");
- if(jackPerTrackOutput)
- {
- gui->enablePerTrackOutput=jackPerTrackOutput->valueint;
- if(gui->enablePerTrackOutput)
- LUPPP_NOTE("Enabling per track output ports");
- }
- //Metronome on by default?
- cJSON* metronomeActive=cJSON_GetObjectItem(preferencesJson,"metronomeActiveByDefault");
- if(metronomeActive)
- {
- EventMetronomeActive e = EventMetronomeActive( metronomeActive->valueint);
- writeToDspRingbuffer( &e );
- }
+ cJSON* projDir=cJSON_GetObjectItem(preferencesJson,"saveDirectory");
+ string dir=getenv("HOME");
+ if(projDir) {
+ stringstream s;
+ s<valuestring;
+ dir=s.str();
+ }
+ gui->setProjectsDir(dir);
- //Metronome default volume
- cJSON* metronomeVol=cJSON_GetObjectItem(preferencesJson,"metronomeDefaultVolume");
- if(metronomeVol)
- {
- float vol=metronomeVol->valueint/100.0f;
- EventMetronomeVolume e(vol);
- writeToDspRingbuffer(&e);
- }
-
-
- cJSON_Delete( preferencesJson );
- delete[] sampleString;
- }
- else
- {
- // empty file / file no exists:
- LUPPP_WARN("Preferences, file doesn't exist: ~/.config/openAV/luppp/luppp.prefs");
-
- // so write default file
- gui->getDiskWriter()->writeDefaultConfigToUserHome();
-
- return LUPPP_RETURN_OK;
- }
-
- return LUPPP_RETURN_OK;
+ //Enable per track send and resturn jack ports?
+ cJSON* jackPerTrackOutput=cJSON_GetObjectItem(preferencesJson,"enablePerTrackOutput");
+ if(jackPerTrackOutput) {
+ gui->enablePerTrackOutput=jackPerTrackOutput->valueint;
+ if(gui->enablePerTrackOutput)
+ LUPPP_NOTE("Enabling per track output ports");
+ }
+
+ //Metronome on by default?
+ cJSON* metronomeActive=cJSON_GetObjectItem(preferencesJson,"metronomeActiveByDefault");
+ if(metronomeActive) {
+ EventMetronomeActive e = EventMetronomeActive( metronomeActive->valueint);
+ writeToDspRingbuffer( &e );
+ }
+
+ //Metronome default volume
+ cJSON* metronomeVol=cJSON_GetObjectItem(preferencesJson,"metronomeDefaultVolume");
+ if(metronomeVol) {
+ float vol=metronomeVol->valueint/100.0f;
+ EventMetronomeVolume e(vol);
+ writeToDspRingbuffer(&e);
+ }
+
+
+ cJSON_Delete( preferencesJson );
+ delete[] sampleString;
+ } else {
+ // empty file / file no exists:
+ LUPPP_WARN("Preferences, file doesn't exist: ~/.config/openAV/luppp/luppp.prefs");
+
+ // so write default file
+ gui->getDiskWriter()->writeDefaultConfigToUserHome();
+
+ return LUPPP_RETURN_OK;
+ }
+
+ return LUPPP_RETURN_OK;
}
int DiskReader::showAudioEditor(AudioBuffer* ab)
{
- while ( ab->getBeats() == 0 )
- {
- // FIXME: Cancel = no load sample?
- gui->getAudioEditor()->show( ab, true );
-
- while ( gui->getAudioEditor()->shown() ) Fl::wait();
-
- // handle "cancel" return
- if ( ab->getBeats() == -1 )
- {
- return LUPPP_RETURN_ERROR;
- }
- }
-
- return LUPPP_RETURN_OK;
+ while ( ab->getBeats() == 0 ) {
+ // FIXME: Cancel = no load sample?
+ gui->getAudioEditor()->show( ab, true );
+
+ while ( gui->getAudioEditor()->shown() ) Fl::wait();
+
+ // handle "cancel" return
+ if ( ab->getBeats() == -1 ) {
+ return LUPPP_RETURN_ERROR;
+ }
+ }
+
+ return LUPPP_RETURN_OK;
}
int DiskReader::loadSample( int track, int scene, string path )
{
- /// load the sample
- SndfileHandle infile( path, SFM_READ );
- std::vector buf( infile.frames() * infile.channels() );
- infile.read( (float*)&buf[0] , infile.frames() * infile.channels() );
-
- if ( infile.error() )
- {
- LUPPP_ERROR("File %s, Error %s", path.c_str(), infile.strError() );
- return LUPPP_RETURN_ERROR;
- }
-
- LUPPP_NOTE("Loading file with %i chnls, frames %i,buffer size %i", infile.channels(), infile.frames(), buf.size() );
-
- /// kick stereo channel?
- int chnls = infile.channels();
- if ( chnls > 1 )
- {
- // we're gonna kick all samples that are *not* channel 1
- std::vector tmp( buf.size() / chnls );
-
- LUPPP_NOTE("Non mono file: %i chnls found, old size %i, new size %i ", infile.channels(), buf.size(), tmp.size() );
-
- for(size_t i = 0; i < tmp.size(); i++ )
- {
- tmp.at(i) = buf.at( i * chnls );
- }
-
- // swap the buffers
- buf.swap( tmp );
- }
-
- /// resample?
- if ( infile.samplerate() != gui->samplerate )
- {
- LUPPP_NOTE("%s%i%s%i", "Resampling from ", infile.samplerate(), " to ", gui->samplerate);
-
- float resampleRatio = float(gui->samplerate) / infile.samplerate();
- std::vector resampled( infile.frames() * resampleRatio );
-
- SRC_DATA data;
- data.data_in = &buf[0];
- data.data_out = &resampled[0];
-
- data.input_frames = infile.frames();
- data.output_frames = infile.frames() * resampleRatio;
-
- data.end_of_input = 0;
- data.src_ratio = resampleRatio;
-
- int q = SRC_SINC_FASTEST;
-
- switch( resampleQuality )
- {
- case 0: q = SRC_LINEAR; break;
- case 1: q = SRC_SINC_FASTEST; break;
- case 2: q = SRC_SINC_BEST_QUALITY; break;
- }
-
-
- // resample quality taken from config file,
- int ret = src_simple ( &data, q, 1 );
- if ( ret == 0 )
- LUPPP_NOTE("%s%i%s%i", "Resampling finished, from ", data.input_frames_used, " to ", data.output_frames_gen );
- else
- LUPPP_ERROR("%s%i%s%i", "Resampling finished, from ", data.input_frames_used, " to ", data.output_frames_gen );
-
- /// exchange buffers, so buf contains the resampled audio
- buf.swap( resampled );
- }
-
-
- /// create buffer, and set the data
- AudioBuffer* ab = new AudioBuffer();
- ab->setAudioFrames( buf.size() );
- ab->nonRtSetSample( buf );
-
- //cout << "DiskReader::loadSample() " << path << endl;
-
- bool loadableBuffer = false;
-
- // retrieve sample metadata from sample.cfg using filename as key
- char* tmp = strdup( path.c_str() );
- char* baseName = basename( tmp );
- //cout << "tmp " << tmp << " baseName " << baseName << endl;
- ab->setName( baseName );
-
- if ( infile.frames() > 0 )
- {
- char* basePath = strdup( path.c_str() );
- stringstream base;
- base << dirname( basePath ) << "/audio.cfg";
-
- free( basePath );
-
- /// open audio.cfg, reading whole file
+ /// load the sample
+ SndfileHandle infile( path, SFM_READ );
+ std::vector buf( infile.frames() * infile.channels() );
+ infile.read( (float*)&buf[0] , infile.frames() * infile.channels() );
+
+ if ( infile.error() ) {
+ LUPPP_ERROR("File %s, Error %s", path.c_str(), infile.strError() );
+ return LUPPP_RETURN_ERROR;
+ }
+
+ LUPPP_NOTE("Loading file with %i chnls, frames %i,buffer size %i", infile.channels(), infile.frames(), buf.size() );
+
+ /// kick stereo channel?
+ int chnls = infile.channels();
+ if ( chnls > 1 ) {
+ // we're gonna kick all samples that are *not* channel 1
+ std::vector tmp( buf.size() / chnls );
+
+ LUPPP_NOTE("Non mono file: %i chnls found, old size %i, new size %i ", infile.channels(), buf.size(), tmp.size() );
+
+ for(size_t i = 0; i < tmp.size(); i++ ) {
+ tmp.at(i) = buf.at( i * chnls );
+ }
+
+ // swap the buffers
+ buf.swap( tmp );
+ }
+
+ /// resample?
+ if ( infile.samplerate() != gui->samplerate ) {
+ LUPPP_NOTE("%s%i%s%i", "Resampling from ", infile.samplerate(), " to ", gui->samplerate);
+
+ float resampleRatio = float(gui->samplerate) / infile.samplerate();
+ std::vector resampled( infile.frames() * resampleRatio );
+
+ SRC_DATA data;
+ data.data_in = &buf[0];
+ data.data_out = &resampled[0];
+
+ data.input_frames = infile.frames();
+ data.output_frames = infile.frames() * resampleRatio;
+
+ data.end_of_input = 0;
+ data.src_ratio = resampleRatio;
+
+ int q = SRC_SINC_FASTEST;
+
+ switch( resampleQuality ) {
+ case 0:
+ q = SRC_LINEAR;
+ break;
+ case 1:
+ q = SRC_SINC_FASTEST;
+ break;
+ case 2:
+ q = SRC_SINC_BEST_QUALITY;
+ break;
+ }
+
+
+ // resample quality taken from config file,
+ int ret = src_simple ( &data, q, 1 );
+ if ( ret == 0 )
+ LUPPP_NOTE("%s%i%s%i", "Resampling finished, from ", data.input_frames_used, " to ", data.output_frames_gen );
+ else
+ LUPPP_ERROR("%s%i%s%i", "Resampling finished, from ", data.input_frames_used, " to ", data.output_frames_gen );
+
+ /// exchange buffers, so buf contains the resampled audio
+ buf.swap( resampled );
+ }
+
+
+ /// create buffer, and set the data
+ AudioBuffer* ab = new AudioBuffer();
+ ab->setAudioFrames( buf.size() );
+ ab->nonRtSetSample( buf );
+
+ //cout << "DiskReader::loadSample() " << path << endl;
+
+ bool loadableBuffer = false;
+
+ // retrieve sample metadata from sample.cfg using filename as key
+ char* tmp = strdup( path.c_str() );
+ char* baseName = basename( tmp );
+ //cout << "tmp " << tmp << " baseName " << baseName << endl;
+ ab->setName( baseName );
+
+ if ( infile.frames() > 0 ) {
+ char* basePath = strdup( path.c_str() );
+ stringstream base;
+ base << dirname( basePath ) << "/audio.cfg";
+
+ free( basePath );
+
+ /// open audio.cfg, reading whole file
#ifdef DEBUG_STATE
- cout << "loading sample metadata file " << base.str().c_str() << endl;
+ cout << "loading sample metadata file " << base.str().c_str() << endl;
#endif
- std::ifstream sampleFile( base.str().c_str(), std::ios_base::in|std::ios_base::ate);
- long file_length = sampleFile.tellg();
- if ( file_length > 0 )
- {
- sampleFile.seekg(0, std::ios_base::beg);
- sampleFile.clear();
- char *sampleString = new char[file_length];
- sampleFile.read(sampleString, file_length);
-
- //cout << "Sample file:" << endl << sampleString << endl;
- //cout << "Sample file (parsed):" << endl << cJSON_Parse( sampleString ) << endl;
-
- cJSON* audioJson = cJSON_Parse( sampleString );
- if (!audioJson) {
- LUPPP_ERROR("%s %s","Error in Sample JSON before: ", cJSON_GetErrorPtr() );
- return LUPPP_RETURN_ERROR;
- }
-
- cJSON* sample = cJSON_GetObjectItem( audioJson, baseName );
- if ( sample )
- {
- cJSON* beats = cJSON_GetObjectItem( sample, "beats" );
- cJSON* name = cJSON_GetObjectItem( sample, "name" );
- //cout << "Clip @ " << track << " " << scene << " gets " << beats->valuedouble << " beats."<< endl;
- if ( beats )
- {
- loadableBuffer = true;
- ab->setBeats( beats->valuedouble );
- }
-
- if ( name )
- {
- ab->setName( name->valuestring );
- }
- }
-
- // if we don't find the beats from audio.cfg, show dialog
- if ( loadableBuffer == false )
- {
- LUPPP_NOTE("Warning: audio.cfg has no entry for beats.");
- int ret = showAudioEditor( ab );
-
- if ( ret == LUPPP_RETURN_OK )
- {
- // flag that we can load this sample OK
- loadableBuffer = true;
- }
- else
- {
- delete ab;
- }
- }
-
- cJSON_Delete( audioJson );
- delete[] sampleString;
- free ( tmp );
- }
- else
- {
- // this means there's no audio.cfg file found for the sample: show the user
- // the file, and ask what the intended beat number is, and load the AudioBuffer
- LUPPP_WARN("%s %s","Empty or no audio.cfg found at ",base.str().c_str() );
- int error = showAudioEditor( ab );
- if ( error == LUPPP_RETURN_ERROR )
- {
- LUPPP_WARN("cancel clicked, deleting audiobuffer" );
- delete ab;
- }
- else
- {
- std::string name = path;
- int i = name.find_last_of('/') + 1;
- std::string sub = name.substr( i );
- ab->setName( sub.c_str() );
-
- LUPPP_NOTE("AudioBuffer %s set %i beats", ab->getName(), ab->getBeats() );
-
- loadableBuffer = true;
- }
- }
-
- if ( loadableBuffer )
- {
- std::string n = ab->getName();
-
- // write audioBuffer to DSP
- EventLooperLoad e = EventLooperLoad( track, scene, ab );
- writeToDspRingbuffer( &e );
-
- // now write audiobuffer name to GUI on track, scene
- gui->getTrack( track )->getClipSelector()->clipName( scene, n );
-
- char* tmp = strdup( path.c_str() );
- lastLoadedSamplePath = dirname( tmp );
- free(tmp);
- }
- else
- {
- LUPPP_NOTE("AudioBuffer not loaded, missing beats info and dialog was Canceled" );
- }
- }
-
- return LUPPP_RETURN_OK;
-
+ std::ifstream sampleFile( base.str().c_str(), std::ios_base::in|std::ios_base::ate);
+ long file_length = sampleFile.tellg();
+ if ( file_length > 0 ) {
+ sampleFile.seekg(0, std::ios_base::beg);
+ sampleFile.clear();
+ char *sampleString = new char[file_length];
+ sampleFile.read(sampleString, file_length);
+
+ //cout << "Sample file:" << endl << sampleString << endl;
+ //cout << "Sample file (parsed):" << endl << cJSON_Parse( sampleString ) << endl;
+
+ cJSON* audioJson = cJSON_Parse( sampleString );
+ if (!audioJson) {
+ LUPPP_ERROR("%s %s","Error in Sample JSON before: ", cJSON_GetErrorPtr() );
+ return LUPPP_RETURN_ERROR;
+ }
+
+ cJSON* sample = cJSON_GetObjectItem( audioJson, baseName );
+ if ( sample ) {
+ cJSON* beats = cJSON_GetObjectItem( sample, "beats" );
+ cJSON* name = cJSON_GetObjectItem( sample, "name" );
+ //cout << "Clip @ " << track << " " << scene << " gets " << beats->valuedouble << " beats."<< endl;
+ if ( beats ) {
+ loadableBuffer = true;
+ ab->setBeats( beats->valuedouble );
+ }
+
+ if ( name ) {
+ ab->setName( name->valuestring );
+ }
+ }
+
+ // if we don't find the beats from audio.cfg, show dialog
+ if ( loadableBuffer == false ) {
+ LUPPP_NOTE("Warning: audio.cfg has no entry for beats.");
+ int ret = showAudioEditor( ab );
+
+ if ( ret == LUPPP_RETURN_OK ) {
+ // flag that we can load this sample OK
+ loadableBuffer = true;
+ } else {
+ delete ab;
+ }
+ }
+
+ cJSON_Delete( audioJson );
+ delete[] sampleString;
+ free ( tmp );
+ } else {
+ // this means there's no audio.cfg file found for the sample: show the user
+ // the file, and ask what the intended beat number is, and load the AudioBuffer
+ LUPPP_WARN("%s %s","Empty or no audio.cfg found at ",base.str().c_str() );
+ int error = showAudioEditor( ab );
+ if ( error == LUPPP_RETURN_ERROR ) {
+ LUPPP_WARN("cancel clicked, deleting audiobuffer" );
+ delete ab;
+ } else {
+ std::string name = path;
+ int i = name.find_last_of('/') + 1;
+ std::string sub = name.substr( i );
+ ab->setName( sub.c_str() );
+
+ LUPPP_NOTE("AudioBuffer %s set %i beats", ab->getName(), ab->getBeats() );
+
+ loadableBuffer = true;
+ }
+ }
+
+ if ( loadableBuffer ) {
+ std::string n = ab->getName();
+
+ // write audioBuffer to DSP
+ EventLooperLoad e = EventLooperLoad( track, scene, ab );
+ writeToDspRingbuffer( &e );
+
+ // now write audiobuffer name to GUI on track, scene
+ gui->getTrack( track )->getClipSelector()->clipName( scene, n );
+
+ char* tmp = strdup( path.c_str() );
+ lastLoadedSamplePath = dirname( tmp );
+ free(tmp);
+ } else {
+ LUPPP_NOTE("AudioBuffer not loaded, missing beats info and dialog was Canceled" );
+ }
+ }
+
+ return LUPPP_RETURN_OK;
+
}
std::string DiskReader::getLastLoadedSamplePath()
{
- return lastLoadedSamplePath;
+ return lastLoadedSamplePath;
}
int DiskReader::readSession( std::string path )
{
- cout << "DiskReader::readSession() " << path << endl;
- sessionPath = path;
-
- stringstream s;
- s << path << "/session.luppp";
-
- stringstream samplePath;
- samplePath << path << "/audio/audio.cfg";
-
- cout << "session path: " << s.str() << endl;
- cout << "audio path: " << samplePath.str() << endl;
-
- // open session, read all
- std::ifstream file( s.str().c_str(), std::ios_base::in|std::ios_base::ate);
- long file_length = file.tellg();
- if ( file_length < 0 )
- {
- // empty file / file no exists:
- LUPPP_ERROR("no session file exists!");
- return LUPPP_RETURN_ERROR;
- }
-
- file.seekg(0, std::ios_base::beg);
- file.clear();
- char *sessionString = new char[file_length];
- file.read(sessionString, file_length);
-
- // create cJSON nodes from strings
- sessionJson = cJSON_Parse( sessionString );
- if (!sessionJson) {
- LUPPP_ERROR("%s %s", "Error in Session JSON before: ", cJSON_GetErrorPtr() );
- return LUPPP_RETURN_ERROR;
- }
-
-
- int tr = readTracks();
-
- int mr = readMaster();
-
- if( tr == mr ){};
-
- // cleanup
- cJSON_Delete( sessionJson );
- delete[] sessionString;
-
- return LUPPP_RETURN_OK;
+ cout << "DiskReader::readSession() " << path << endl;
+ sessionPath = path;
+
+ stringstream s;
+ s << path << "/session.luppp";
+
+ stringstream samplePath;
+ samplePath << path << "/audio/audio.cfg";
+
+ cout << "session path: " << s.str() << endl;
+ cout << "audio path: " << samplePath.str() << endl;
+
+ // open session, read all
+ std::ifstream file( s.str().c_str(), std::ios_base::in|std::ios_base::ate);
+ long file_length = file.tellg();
+ if ( file_length < 0 ) {
+ // empty file / file no exists:
+ LUPPP_ERROR("no session file exists!");
+ return LUPPP_RETURN_ERROR;
+ }
+
+ file.seekg(0, std::ios_base::beg);
+ file.clear();
+ char *sessionString = new char[file_length];
+ file.read(sessionString, file_length);
+
+ // create cJSON nodes from strings
+ sessionJson = cJSON_Parse( sessionString );
+ if (!sessionJson) {
+ LUPPP_ERROR("%s %s", "Error in Session JSON before: ", cJSON_GetErrorPtr() );
+ return LUPPP_RETURN_ERROR;
+ }
+
+
+ int tr = readTracks();
+
+ int mr = readMaster();
+
+ if( tr == mr ) {};
+
+ // cleanup
+ cJSON_Delete( sessionJson );
+ delete[] sessionString;
+
+ return LUPPP_RETURN_OK;
}
int DiskReader::readMaster()
{
- cJSON* master = cJSON_GetObjectItem( sessionJson, "master");
- if ( master )
- {
- // bpm
- {
- cJSON* bpm = cJSON_GetObjectItem( master, "bpm");
- if ( bpm ) {
- LUPPP_NOTE("%s %i","Session: BPM ",bpm->valueint);
- EventTimeBPM e( bpm->valuedouble );
- writeToDspRingbuffer( &e );
- }
- }
- // fader
- {
- cJSON* fader = cJSON_GetObjectItem( master, "fader");
- if ( fader ) {
- EventTrackVol e( -1, fader->valuedouble );
- writeToDspRingbuffer( &e );
- }
- }
- // input volume
- {
- cJSON* cjson = cJSON_GetObjectItem( master, "inputVolume");
- if ( cjson ) {
- EventMasterInputVol e( cjson->valuedouble );
- writeToDspRingbuffer( &e ); }
- }
- // input to send
- {
- cJSON* cjson = cJSON_GetObjectItem( master, "inputToSndVol");
- if ( cjson ) {
- EventMasterInputTo e( INPUT_TO_SEND, cjson->valuedouble );
- writeToDspRingbuffer( &e ); }
- }
- // input to key
- {
- cJSON* cjson = cJSON_GetObjectItem( master, "inputToXSide");
- if ( cjson ) {
- EventMasterInputTo e( INPUT_TO_XSIDE, cjson->valuedouble );
- writeToDspRingbuffer( &e ); }
- }
- // input to mix
- {
- cJSON* cjson = cJSON_GetObjectItem( master, "inputToMixVol");
- if ( cjson ) {
- EventMasterInputTo e( INPUT_TO_MIX, cjson->valuedouble );
- writeToDspRingbuffer( &e ); }
- }
-
- // input to send active
- {
- cJSON* cjson = cJSON_GetObjectItem( master, "inputToSndActive");
- if ( cjson ) {
- EventMasterInputTo e( INPUT_TO_SEND, cjson->valuedouble );
- writeToDspRingbuffer( &e ); }
- }
- // input to key active
- {
- cJSON* cjson = cJSON_GetObjectItem( master, "inputToKeyActive");
- if ( cjson ) {
- EventMasterInputTo e( INPUT_TO_SIDE_KEY, cjson->valuedouble );
- writeToDspRingbuffer( &e ); }
- }
- // input to mix active
- {
- cJSON* cjson = cJSON_GetObjectItem( master, "inputToMixActive");
- if ( cjson ) {
- EventMasterInputTo e( INPUT_TO_MIX, cjson->valuedouble );
- writeToDspRingbuffer( &e ); }
- }
-
- // reverb
- {
- cJSON* reverb = cJSON_GetObjectItem( master, "reverb");
- if ( reverb )
- {
- cJSON* active = cJSON_GetObjectItem( reverb, "active");
- cJSON* size = cJSON_GetObjectItem( reverb, "size");
- cJSON* wet = cJSON_GetObjectItem( reverb, "wet");
- cJSON* damping = cJSON_GetObjectItem( reverb, "damping");
-
- if ( active && size && wet && damping )
- {
- EventFxReverb e( active->valuedouble, size->valuedouble,
- wet->valuedouble, damping->valuedouble );
- writeToDspRingbuffer( &e );
- }
- }
- else
- {
+ cJSON* master = cJSON_GetObjectItem( sessionJson, "master");
+ if ( master ) {
+ // bpm
+ {
+ cJSON* bpm = cJSON_GetObjectItem( master, "bpm");
+ if ( bpm ) {
+ LUPPP_NOTE("%s %i","Session: BPM ",bpm->valueint);
+ EventTimeBPM e( bpm->valuedouble );
+ writeToDspRingbuffer( &e );
+ }
+ }
+ // fader
+ {
+ cJSON* fader = cJSON_GetObjectItem( master, "fader");
+ if ( fader ) {
+ EventTrackVol e( -1, fader->valuedouble );
+ writeToDspRingbuffer( &e );
+ }
+ }
+ // input volume
+ {
+ cJSON* cjson = cJSON_GetObjectItem( master, "inputVolume");
+ if ( cjson ) {
+ EventMasterInputVol e( cjson->valuedouble );
+ writeToDspRingbuffer( &e );
+ }
+ }
+ // input to send
+ {
+ cJSON* cjson = cJSON_GetObjectItem( master, "inputToSndVol");
+ if ( cjson ) {
+ EventMasterInputTo e( INPUT_TO_SEND, cjson->valuedouble );
+ writeToDspRingbuffer( &e );
+ }
+ }
+ // input to key
+ {
+ cJSON* cjson = cJSON_GetObjectItem( master, "inputToXSide");
+ if ( cjson ) {
+ EventMasterInputTo e( INPUT_TO_XSIDE, cjson->valuedouble );
+ writeToDspRingbuffer( &e );
+ }
+ }
+ // input to mix
+ {
+ cJSON* cjson = cJSON_GetObjectItem( master, "inputToMixVol");
+ if ( cjson ) {
+ EventMasterInputTo e( INPUT_TO_MIX, cjson->valuedouble );
+ writeToDspRingbuffer( &e );
+ }
+ }
+
+ // input to send active
+ {
+ cJSON* cjson = cJSON_GetObjectItem( master, "inputToSndActive");
+ if ( cjson ) {
+ EventMasterInputTo e( INPUT_TO_SEND, cjson->valuedouble );
+ writeToDspRingbuffer( &e );
+ }
+ }
+ // input to key active
+ {
+ cJSON* cjson = cJSON_GetObjectItem( master, "inputToKeyActive");
+ if ( cjson ) {
+ EventMasterInputTo e( INPUT_TO_SIDE_KEY, cjson->valuedouble );
+ writeToDspRingbuffer( &e );
+ }
+ }
+ // input to mix active
+ {
+ cJSON* cjson = cJSON_GetObjectItem( master, "inputToMixActive");
+ if ( cjson ) {
+ EventMasterInputTo e( INPUT_TO_MIX, cjson->valuedouble );
+ writeToDspRingbuffer( &e );
+ }
+ }
+
+ // reverb
+ {
+ cJSON* reverb = cJSON_GetObjectItem( master, "reverb");
+ if ( reverb ) {
+ cJSON* active = cJSON_GetObjectItem( reverb, "active");
+ cJSON* size = cJSON_GetObjectItem( reverb, "size");
+ cJSON* wet = cJSON_GetObjectItem( reverb, "wet");
+ cJSON* damping = cJSON_GetObjectItem( reverb, "damping");
+
+ if ( active && size && wet && damping ) {
+ EventFxReverb e( active->valuedouble, size->valuedouble,
+ wet->valuedouble, damping->valuedouble );
+ writeToDspRingbuffer( &e );
+ }
+ } else {
#ifdef DEBUG_STATE
- cout << "Session has no reverb element" << endl;
+ cout << "Session has no reverb element" << endl;
#endif
- }
- }
- // TODO add samplerate to session JSON
-
- // sceneNames
- {
- cJSON* names = cJSON_GetObjectItem( master, "sceneNames");
- if ( names )
- {
- GMasterTrack* master = gui->getMasterTrack();
- Avtk::ClipSelector* clipSelector = master->getClipSelector();
- int nscenes = cJSON_GetArraySize( names );
- for(int s = 0; s < nscenes; s++ )
- {
- cJSON* name = cJSON_GetArrayItem( names, s );
- clipSelector->clipName( s, name->valuestring );
- }
- clipSelector->redraw();
- }
- }
-
- }
- else
- {
- LUPPP_ERROR("%s", "Error getting master from JSON" );
- return LUPPP_RETURN_ERROR;
- }
-
- return LUPPP_RETURN_OK;
+ }
+ }
+ // TODO add samplerate to session JSON
+
+ // sceneNames
+ {
+ cJSON* names = cJSON_GetObjectItem( master, "sceneNames");
+ if ( names ) {
+ GMasterTrack* master = gui->getMasterTrack();
+ Avtk::ClipSelector* clipSelector = master->getClipSelector();
+ int nscenes = cJSON_GetArraySize( names );
+ for(int s = 0; s < nscenes; s++ ) {
+ cJSON* name = cJSON_GetArrayItem( names, s );
+ clipSelector->clipName( s, name->valuestring );
+ }
+ clipSelector->redraw();
+ }
+ }
+
+ } else {
+ LUPPP_ERROR("%s", "Error getting master from JSON" );
+ return LUPPP_RETURN_ERROR;
+ }
+
+ return LUPPP_RETURN_OK;
}
int DiskReader::readScenes(int t, cJSON* track)
{
- cJSON* clips = cJSON_GetObjectItem( track, "clips");
- if ( clips )
- {
-
- int nClips = cJSON_GetArraySize( clips );
- for(int s = 0; s < nClips; s++ )
- {
- // get metadata for Clip
- cJSON* clip = cJSON_GetArrayItem( clips, s );
-
- if ( strcmp(clip->valuestring, "") != 0 )
- {
- stringstream sampleFilePath;
- sampleFilePath << sessionPath << "/audio/" << clip->valuestring;
+ cJSON* clips = cJSON_GetObjectItem( track, "clips");
+ if ( clips ) {
+
+ int nClips = cJSON_GetArraySize( clips );
+ for(int s = 0; s < nClips; s++ ) {
+ // get metadata for Clip
+ cJSON* clip = cJSON_GetArrayItem( clips, s );
+
+ if ( strcmp(clip->valuestring, "") != 0 ) {
+ stringstream sampleFilePath;
+ sampleFilePath << sessionPath << "/audio/" << clip->valuestring;
#ifdef DEBUG_STATE
- LUPPP_NOTE << "clip t " << t << " s " << s << " path " << sampleFilePath.str() << endl;
+ LUPPP_NOTE << "clip t " << t << " s " << s << " path " << sampleFilePath.str() << endl;
#endif
- // load it, checking for sample.cfg, and using metadata if there
- loadSample( t, s, sampleFilePath.str() );
- }
-
- // FIXME: check GUI ringbuffer after each sample: with resampling it can
- // take quite some time, and the ->GUI ringbuffer can fill up
- handleGuiEvents();
-
- } // nClips loop
- }
-
- return LUPPP_RETURN_OK;
+ // load it, checking for sample.cfg, and using metadata if there
+ loadSample( t, s, sampleFilePath.str() );
+ }
+
+ // FIXME: check GUI ringbuffer after each sample: with resampling it can
+ // take quite some time, and the ->GUI ringbuffer can fill up
+ handleGuiEvents();
+
+ } // nClips loop
+ }
+
+ return LUPPP_RETURN_OK;
}
int DiskReader::readTracks()
{
- cJSON* tracks = cJSON_GetObjectItem( sessionJson, "tracks");
- if ( tracks )
- {
- int nTracks = cJSON_GetArraySize( tracks );
- for(int t = 0; t < nTracks; t++ )
- {
- cJSON* track = cJSON_GetArrayItem( tracks, t );
-
- if( !track )
- {
- LUPPP_WARN("Track %i has no name track saved.", t);
- }
- else
- {
- readScenes( t, track );
-
- // name
- {
- cJSON* name = cJSON_GetObjectItem( track, "name");
- if( !name )
- {
- LUPPP_WARN("Track %i has no name data saved.", t);
- }
- else
- {
- gui->getTrack(t)->bg.setLabel( name->valuestring );
- }
- }
- // fader
- {
- cJSON* fader = cJSON_GetObjectItem( track, "fader");
- if( !fader )
- {
- LUPPP_WARN("Track %i has no fader data saved.", t);
- }
- else
- {
- EventTrackVol e( t, fader->valuedouble );
- writeToDspRingbuffer( &e );
- }
- }
- // sends
- {
- cJSON* send = cJSON_GetObjectItem( track, "sendAmount");
- cJSON* sendActive = cJSON_GetObjectItem( track, "sendActive");
-
- cJSON* xside = cJSON_GetObjectItem( track, "xsideAmount");
- cJSON* keyActive = cJSON_GetObjectItem( track, "keyActive");
-
- if( !send || !sendActive || !xside || !keyActive )
- {
- LUPPP_WARN("Track %i has no send data saved.", t);
- }
- else
- {
- EventTrackSendActive e1( t, SEND_POSTFADER, sendActive->valueint );
- EventTrackSendActive e2( t, SEND_KEY , keyActive ->valueint );
-
- EventTrackSend e3( t, SEND_XSIDE , xside->valuedouble );
- EventTrackSend e4( t, SEND_POSTFADER , send->valuedouble );
-
-
- writeToDspRingbuffer( &e1 );
- writeToDspRingbuffer( &e2 );
- writeToDspRingbuffer( &e3 );
- }
+ cJSON* tracks = cJSON_GetObjectItem( sessionJson, "tracks");
+ if ( tracks ) {
+ int nTracks = cJSON_GetArraySize( tracks );
+ for(int t = 0; t < nTracks; t++ ) {
+ cJSON* track = cJSON_GetArrayItem( tracks, t );
- cJSON* jacksend = cJSON_GetObjectItem( track, "jacksendAmount");
- cJSON* jacksendActive = cJSON_GetObjectItem( track, "jacksendActive");
- if(jacksend)
- {
- EventTrackJackSend ev(t,jacksend->valuedouble);
- writeToDspRingbuffer(&ev);
- }
- if(jacksendActive)
- {
- EventTrackJackSendActivate ev(t,jacksendActive->valueint);
- writeToDspRingbuffer(&ev);
- }
- }
- }// if track
- } // nTracks loop
- }
- else
- {
- LUPPP_ERROR("%s", "Error getting clip" );
- return LUPPP_RETURN_ERROR;
- }
- return LUPPP_RETURN_OK;
+ if( !track ) {
+ LUPPP_WARN("Track %i has no name track saved.", t);
+ } else {
+ readScenes( t, track );
+
+ // name
+ {
+ cJSON* name = cJSON_GetObjectItem( track, "name");
+ if( !name ) {
+ LUPPP_WARN("Track %i has no name data saved.", t);
+ } else {
+ gui->getTrack(t)->bg.setLabel( name->valuestring );
+ }
+ }
+ // fader
+ {
+ cJSON* fader = cJSON_GetObjectItem( track, "fader");
+ if( !fader ) {
+ LUPPP_WARN("Track %i has no fader data saved.", t);
+ } else {
+ EventTrackVol e( t, fader->valuedouble );
+ writeToDspRingbuffer( &e );
+ }
+ }
+ // sends
+ {
+ cJSON* send = cJSON_GetObjectItem( track, "sendAmount");
+ cJSON* sendActive = cJSON_GetObjectItem( track, "sendActive");
+
+ cJSON* xside = cJSON_GetObjectItem( track, "xsideAmount");
+ cJSON* keyActive = cJSON_GetObjectItem( track, "keyActive");
+
+ if( !send || !sendActive || !xside || !keyActive ) {
+ LUPPP_WARN("Track %i has no send data saved.", t);
+ } else {
+ EventTrackSendActive e1( t, SEND_POSTFADER, sendActive->valueint );
+ EventTrackSendActive e2( t, SEND_KEY , keyActive ->valueint );
+
+ EventTrackSend e3( t, SEND_XSIDE , xside->valuedouble );
+ EventTrackSend e4( t, SEND_POSTFADER , send->valuedouble );
+
+
+ writeToDspRingbuffer( &e1 );
+ writeToDspRingbuffer( &e2 );
+ writeToDspRingbuffer( &e3 );
+ }
+
+ cJSON* jacksend = cJSON_GetObjectItem( track, "jacksendAmount");
+ cJSON* jacksendActive = cJSON_GetObjectItem( track, "jacksendActive");
+ if(jacksend) {
+ EventTrackJackSend ev(t,jacksend->valuedouble);
+ writeToDspRingbuffer(&ev);
+ }
+ if(jacksendActive) {
+ EventTrackJackSendActivate ev(t,jacksendActive->valueint);
+ writeToDspRingbuffer(&ev);
+ }
+ }
+ }// if track
+ } // nTracks loop
+ } else {
+ LUPPP_ERROR("%s", "Error getting clip" );
+ return LUPPP_RETURN_ERROR;
+ }
+ return LUPPP_RETURN_OK;
}
diff --git a/src/diskreader.hxx b/src/diskreader.hxx
index 62ba60f..46b17ac 100644
--- a/src/diskreader.hxx
+++ b/src/diskreader.hxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -28,51 +28,51 @@ class AudioBuffer;
/** DiskReader
* This class reads a previously saved session from disk, restoring Luppp's
* internal state to that of when the save took place.
- *
- * The directory is the main point of loading. The user selects
+ *
+ * The directory is the main point of loading. The user selects
* that directory to load the session from. .luppp is the name of
* the session file: it contains all info about the session: Volumes, loaded
* samples etc.
- *
+ *
* Samples are read from the directory /samples, in which there is a
* sample.cfg file, which can be parsed to get sample metadata.
**/
class DiskReader
{
- public:
- DiskReader();
-
- /// loads default settings for Luppp: controller instances etc
- int loadPreferences();
-
- /// loads a sample into a new AudioBuffer, returning the buffer
- int loadSample( int track, int scene, std::string path );
- std::string getLastLoadedSamplePath();
-
- /// reads a session from disk, parsing and restoring state
- int readSession( std::string path );
-
+public:
+ DiskReader();
+
+ /// loads default settings for Luppp: controller instances etc
+ int loadPreferences();
+
+ /// loads a sample into a new AudioBuffer, returning the buffer
+ int loadSample( int track, int scene, std::string path );
+ std::string getLastLoadedSamplePath();
+
+ /// reads a session from disk, parsing and restoring state
+ int readSession( std::string path );
+
#ifdef BUILD_TESTS
- int runTests();
+ int runTests();
#endif
-
- private:
- cJSON* sessionJson;
-
- std::string sessionName;
- std::string sessionPath;
-
- // convinience functions
- int readTracks();
- int readMaster();
- int readScenes(int t, cJSON* track);
-
- // ui show editor
- int showAudioEditor(AudioBuffer* );
-
- // sample load dialog
- int resampleQuality;
- std::string lastLoadedSamplePath;
+
+private:
+ cJSON* sessionJson;
+
+ std::string sessionName;
+ std::string sessionPath;
+
+ // convinience functions
+ int readTracks();
+ int readMaster();
+ int readScenes(int t, cJSON* track);
+
+ // ui show editor
+ int showAudioEditor(AudioBuffer* );
+
+ // sample load dialog
+ int resampleQuality;
+ std::string lastLoadedSamplePath;
};
#endif // LUPPP_DISK_READER_H
diff --git a/src/diskwriter.cxx b/src/diskwriter.cxx
index 7b3e58b..f70a53e 100644
--- a/src/diskwriter.cxx
+++ b/src/diskwriter.cxx
@@ -1,17 +1,17 @@
/*
* Author: Harry van Haaren 2013
* harryhaaren@gmail.com
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
@@ -43,498 +43,451 @@ using namespace std;
DiskWriter::DiskWriter()
{
- sessionJson = cJSON_CreateObject();
- audioJson = cJSON_CreateObject();
-
- // setup default controller name / author etc
- controllerInfo[CONTROLLER_NAME] = "no name";
- controllerInfo[CONTROLLER_AUTHOR] = "no author";
- controllerInfo[CONTROLLER_LINK] = "no link";
-
- sessionDir = getenv("HOME");
- sessionName = "session";
- foldersCreated = false;
-
- // create .config/openAV/luppp/ directory
- stringstream dotConfig;
- dotConfig << getenv("HOME") << "/.config/openAV/";
- int dotConfigDir = mkdir( dotConfig.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
- if ( errno == EEXIST )
- {
- //LUPPP_NOTE("dotConfigDir exists");
- }
- else if ( dotConfigDir )
- {
- LUPPP_WARN("Error creating dotConfigDir: %s", strerror(errno));
- }
- else
- {
- LUPPP_NOTE("Creating .config/openAV/ directory");
- }
-
- stringstream dotConfigLuppp;
- dotConfigLuppp << getenv("HOME") << "/.config/openAV/luppp";
- int dotConfigLupppDir = mkdir( dotConfigLuppp.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
- if ( errno == EEXIST )
- {
- //LUPPP_NOTE("dotConfigLupppDir exists");
- }
- else if ( dotConfigLupppDir )
- {
- LUPPP_WARN("Error creating dotConfigLupppDir: %s", strerror(errno));
- }
- else
- {
- LUPPP_NOTE("Creating .config/openAV/luppp directory");
- }
-
- stringstream dotConfigCtlr;
- dotConfigCtlr << getenv("HOME") << "/.config/openAV/luppp/controllers/";
- int dotConfigCtlrDir = mkdir( dotConfigCtlr.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
- if ( errno == EEXIST )
- {
- //LUPPP_NOTE("dotConfigCtlrDir exists");
- }
- else if ( dotConfigCtlrDir )
- {
- LUPPP_WARN("Error creating dotConfigCtlrDir: %s", strerror(errno));
- }
- else
- {
- LUPPP_NOTE("Creating .config/openAV/luppp directory");
- }
+ sessionJson = cJSON_CreateObject();
+ audioJson = cJSON_CreateObject();
+
+ // setup default controller name / author etc
+ controllerInfo[CONTROLLER_NAME] = "no name";
+ controllerInfo[CONTROLLER_AUTHOR] = "no author";
+ controllerInfo[CONTROLLER_LINK] = "no link";
+
+ sessionDir = getenv("HOME");
+ sessionName = "session";
+ foldersCreated = false;
+
+ // create .config/openAV/luppp/ directory
+ stringstream dotConfig;
+ dotConfig << getenv("HOME") << "/.config/openAV/";
+ int dotConfigDir = mkdir( dotConfig.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
+ if ( errno == EEXIST ) {
+ //LUPPP_NOTE("dotConfigDir exists");
+ } else if ( dotConfigDir ) {
+ LUPPP_WARN("Error creating dotConfigDir: %s", strerror(errno));
+ } else {
+ LUPPP_NOTE("Creating .config/openAV/ directory");
+ }
+
+ stringstream dotConfigLuppp;
+ dotConfigLuppp << getenv("HOME") << "/.config/openAV/luppp";
+ int dotConfigLupppDir = mkdir( dotConfigLuppp.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
+ if ( errno == EEXIST ) {
+ //LUPPP_NOTE("dotConfigLupppDir exists");
+ } else if ( dotConfigLupppDir ) {
+ LUPPP_WARN("Error creating dotConfigLupppDir: %s", strerror(errno));
+ } else {
+ LUPPP_NOTE("Creating .config/openAV/luppp directory");
+ }
+
+ stringstream dotConfigCtlr;
+ dotConfigCtlr << getenv("HOME") << "/.config/openAV/luppp/controllers/";
+ int dotConfigCtlrDir = mkdir( dotConfigCtlr.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
+ if ( errno == EEXIST ) {
+ //LUPPP_NOTE("dotConfigCtlrDir exists");
+ } else if ( dotConfigCtlrDir ) {
+ LUPPP_WARN("Error creating dotConfigCtlrDir: %s", strerror(errno));
+ } else {
+ LUPPP_NOTE("Creating .config/openAV/luppp directory");
+ }
};
void DiskWriter::initialize(std::string path, std::string name )
{
- sessionName = name;
- sessionPath = path;
-
- // write session.luppp JSON node to /.luppp
- stringstream sessionDirStream;
-
- sessionDirStream << path;
-
- if ( !gui->getNsm() )
- sessionDirStream << "/" << sessionName << ".luppp";
-
- sessionDir = sessionDirStream.str();
-
- LUPPP_NOTE( "Creating session dir %s", sessionDir.c_str() );
-
- int sessionDirError = mkdir( sessionDir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
- if ( sessionDirError )
- {
- // handle by using different filename?
- LUPPP_WARN("Error creating session directory. Does the path: %s exist?",path.c_str());
- }
-
- stringstream audioDirStream;
- audioDirStream << sessionDir << "/audio";
- audioDir = audioDirStream.str();
- LUPPP_NOTE("Creating audio dir %s", audioDir.c_str() );
-
- int audioDirError = mkdir( audioDir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
- if ( audioDirError )
- {
- LUPPP_WARN("Error creating sample directory");
- }
-
- foldersCreated = true;
+ sessionName = name;
+ sessionPath = path;
+
+ // write session.luppp JSON node to /.luppp
+ stringstream sessionDirStream;
+
+ sessionDirStream << path;
+
+ if ( !gui->getNsm() )
+ sessionDirStream << "/" << sessionName << ".luppp";
+
+ sessionDir = sessionDirStream.str();
+
+ LUPPP_NOTE( "Creating session dir %s", sessionDir.c_str() );
+
+ int sessionDirError = mkdir( sessionDir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
+ if ( sessionDirError ) {
+ // handle by using different filename?
+ LUPPP_WARN("Error creating session directory. Does the path: %s exist?",path.c_str());
+ }
+
+ stringstream audioDirStream;
+ audioDirStream << sessionDir << "/audio";
+ audioDir = audioDirStream.str();
+ LUPPP_NOTE("Creating audio dir %s", audioDir.c_str() );
+
+ int audioDirError = mkdir( audioDir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
+ if ( audioDirError ) {
+ LUPPP_WARN("Error creating sample directory");
+ }
+
+ foldersCreated = true;
}
std::string DiskWriter::getLastSaveName()
{
- return sessionName;
+ return sessionName;
}
std::string DiskWriter::getLastSavePath()
{
- return sessionPath;
+ return sessionPath;
}
void DiskWriter::writeControllerInfo( CONTROLLER_INFO c, std::string s )
{
- controllerInfo[c] = s;
+ controllerInfo[c] = s;
}
int DiskWriter::writeControllerFile( Controller* c )
{
- if ( c )
- {
- LUPPP_NOTE("DiskWriter Controller* id: %i", c->getID() );
- }
- else
- {
- LUPPP_ERROR("DiskWriter Controller* passed NULL" );
- return LUPPP_RETURN_ERROR;
- }
-
- // check if controller of ID is actually a GenericMIDI controller
- GenericMIDI* g = dynamic_cast( c );
-
- if ( g )
- {
- LUPPP_NOTE("Creating JSON for .ctlr file...");
-
- cJSON* controllerJson = cJSON_CreateObject();
-
- cJSON_AddItemToObject( controllerJson, "name",
- cJSON_CreateString( controllerInfo[CONTROLLER_NAME].c_str() ) );
- cJSON_AddItemToObject( controllerJson, "author",
- cJSON_CreateString( controllerInfo[CONTROLLER_AUTHOR].c_str() ) );
- cJSON_AddItemToObject( controllerJson, "link",
- cJSON_CreateString( controllerInfo[CONTROLLER_LINK].c_str() ) );
-
- // input bindings
- std::vector b = g->getMidiToAction();
-
- cJSON* inputBindings = cJSON_CreateArray();
- cJSON_AddItemToObject(controllerJson, "inputBindings", inputBindings );
- for(unsigned int i = 0; i < b.size(); i++ )
- {
- // create binding
- cJSON* binding = cJSON_CreateObject();
- cJSON_AddItemToArray( inputBindings, binding );
-
- // add metadata to binding
- const char* actionName = Event::getPrettyName( b.at(i)->action );
-
- if ( actionName )
- {
- cJSON_AddItemToObject( binding, "action", cJSON_CreateString( actionName ) );
-
- cJSON_AddNumberToObject( binding, "status", b.at(i)->status );
- cJSON_AddNumberToObject( binding, "data" , b.at(i)->data );
-
- // only add JSON elements if they're not the "invalid" defaults
- if ( b.at(i)->track != -2 )
- cJSON_AddNumberToObject( binding, "track" , b.at(i)->track );
- if ( b.at(i)->scene != -1 )
- cJSON_AddNumberToObject( binding, "scene" , b.at(i)->scene );
- if ( b.at(i)->send != -1 )
- cJSON_AddNumberToObject( binding, "send" , b.at(i)->send );
- if ( b.at(i)->active!= -1 )
- cJSON_AddNumberToObject( binding, "active", b.at(i)->active );
-
- LUPPP_NOTE("Creating Binding: action %i == %s!", b.at(i)->action, actionName );
- }
- else
- {
- LUPPP_WARN("Binding action %i has no prettyName!", b.at(i)->action );
- }
- }
-
-
- //std::vector b = g->getMidiToAction();
- /*
- cJSON* outputBindings = cJSON_CreateArray();
- cJSON_AddItemToObject(controllerJson, "outputBindings", outputBindings );
-
- for(unsigned int i = 0; i < b.size(); i++ )
- {
- // create binding
- cJSON* binding = cJSON_CreateObject();
- cJSON_AddItemToArray( outputBindings, binding );
-
- // add metadata to binding
- // FIXME: get action string from Event class: need to move function from GenericMIDI to there
- cJSON_AddItemToObject( binding, "action", cJSON_CreateString( "gridlogic:launchscene" ) );
-
- cJSON_AddNumberToObject( binding, "status", b.at(i)->status );
- cJSON_AddNumberToObject( binding, "data" , b.at(i)->data );
-
- cJSON_AddNumberToObject( binding, "track" , b.at(i)->track );
- cJSON_AddNumberToObject( binding, "scene" , b.at(i)->scene );
- cJSON_AddNumberToObject( binding, "send" , b.at(i)->send );
- cJSON_AddNumberToObject( binding, "active", b.at(i)->active );
- }
- */
-
-
- // write the sample JSON node to /sample.cfg
- stringstream controllerCfgPath;
- controllerCfgPath << getenv("HOME") << "/.config/openAV/luppp/controllers/" << g->getName() << ".ctlr";
-
- ifstream infile( controllerCfgPath.str().c_str() );
- if ( infile.good() )
- {
- // file exists: ask user overwrite or rename?
- //LUPPP_WARN("Controller filename exists: prompting user to overwrite y/n?");
- int action = fl_choice("Controller exists, action?", "Cancel", "Rename", "Overwrite");
- if ( action == 0 )
- {
- // return OK, as user has chosen to cancel writing the file
- return LUPPP_RETURN_OK;
- }
- else if ( action == 1 )
- {
- // rename here
- const char* name = fl_input("New name for .ctlr file:");
- if ( name )
- {
- // clear the filename
- controllerCfgPath.str( "" );
- controllerCfgPath << getenv("HOME") << "/.config/openAV/luppp/controllers/" << name << ".ctlr";
- LUPPP_NOTE( "New .ctlr filename %s", controllerCfgPath.str().c_str() );
- }
- else
- {
- LUPPP_NOTE("No name entered for .ctlr file, canceling!");
- return LUPPP_RETURN_ERROR;
- }
- }
- else
- {
- // just overwrite the file, no action
- }
-
-
- }
-
- LUPPP_NOTE("Writing %s.ctlr file to disk", g->getName().c_str() );
-
- ofstream controllerCfgFile;
- controllerCfgFile.open ( controllerCfgPath.str().c_str() );
- controllerCfgFile << cJSON_Print( controllerJson );
- controllerCfgFile.close();
- }
- else
- {
- LUPPP_WARN("Invalid Controller pointer: cannot write %s as is not a GenericMIDI controller!", c->getName().c_str() );
- return LUPPP_RETURN_ERROR;
- }
-
- return LUPPP_RETURN_OK;
+ if ( c ) {
+ LUPPP_NOTE("DiskWriter Controller* id: %i", c->getID() );
+ } else {
+ LUPPP_ERROR("DiskWriter Controller* passed NULL" );
+ return LUPPP_RETURN_ERROR;
+ }
+
+ // check if controller of ID is actually a GenericMIDI controller
+ GenericMIDI* g = dynamic_cast( c );
+
+ if ( g ) {
+ LUPPP_NOTE("Creating JSON for .ctlr file...");
+
+ cJSON* controllerJson = cJSON_CreateObject();
+
+ cJSON_AddItemToObject( controllerJson, "name",
+ cJSON_CreateString( controllerInfo[CONTROLLER_NAME].c_str() ) );
+ cJSON_AddItemToObject( controllerJson, "author",
+ cJSON_CreateString( controllerInfo[CONTROLLER_AUTHOR].c_str() ) );
+ cJSON_AddItemToObject( controllerJson, "link",
+ cJSON_CreateString( controllerInfo[CONTROLLER_LINK].c_str() ) );
+
+ // input bindings
+ std::vector b = g->getMidiToAction();
+
+ cJSON* inputBindings = cJSON_CreateArray();
+ cJSON_AddItemToObject(controllerJson, "inputBindings", inputBindings );
+ for(unsigned int i = 0; i < b.size(); i++ ) {
+ // create binding
+ cJSON* binding = cJSON_CreateObject();
+ cJSON_AddItemToArray( inputBindings, binding );
+
+ // add metadata to binding
+ const char* actionName = Event::getPrettyName( b.at(i)->action );
+
+ if ( actionName ) {
+ cJSON_AddItemToObject( binding, "action", cJSON_CreateString( actionName ) );
+
+ cJSON_AddNumberToObject( binding, "status", b.at(i)->status );
+ cJSON_AddNumberToObject( binding, "data" , b.at(i)->data );
+
+ // only add JSON elements if they're not the "invalid" defaults
+ if ( b.at(i)->track != -2 )
+ cJSON_AddNumberToObject( binding, "track" , b.at(i)->track );
+ if ( b.at(i)->scene != -1 )
+ cJSON_AddNumberToObject( binding, "scene" , b.at(i)->scene );
+ if ( b.at(i)->send != -1 )
+ cJSON_AddNumberToObject( binding, "send" , b.at(i)->send );
+ if ( b.at(i)->active!= -1 )
+ cJSON_AddNumberToObject( binding, "active", b.at(i)->active );
+
+ LUPPP_NOTE("Creating Binding: action %i == %s!", b.at(i)->action, actionName );
+ } else {
+ LUPPP_WARN("Binding action %i has no prettyName!", b.at(i)->action );
+ }
+ }
+
+
+ //std::vector b = g->getMidiToAction();
+ /*
+ cJSON* outputBindings = cJSON_CreateArray();
+ cJSON_AddItemToObject(controllerJson, "outputBindings", outputBindings );
+
+ for(unsigned int i = 0; i < b.size(); i++ )
+ {
+ // create binding
+ cJSON* binding = cJSON_CreateObject();
+ cJSON_AddItemToArray( outputBindings, binding );
+
+ // add metadata to binding
+ // FIXME: get action string from Event class: need to move function from GenericMIDI to there
+ cJSON_AddItemToObject( binding, "action", cJSON_CreateString( "gridlogic:launchscene" ) );
+
+ cJSON_AddNumberToObject( binding, "status", b.at(i)->status );
+ cJSON_AddNumberToObject( binding, "data" , b.at(i)->data );
+
+ cJSON_AddNumberToObject( binding, "track" , b.at(i)->track );
+ cJSON_AddNumberToObject( binding, "scene" , b.at(i)->scene );
+ cJSON_AddNumberToObject( binding, "send" , b.at(i)->send );
+ cJSON_AddNumberToObject( binding, "active", b.at(i)->active );
+ }
+ */
+
+
+ // write the sample JSON node to /sample.cfg
+ stringstream controllerCfgPath;
+ controllerCfgPath << getenv("HOME") << "/.config/openAV/luppp/controllers/" << g->getName() << ".ctlr";
+
+ ifstream infile( controllerCfgPath.str().c_str() );
+ if ( infile.good() ) {
+ // file exists: ask user overwrite or rename?
+ //LUPPP_WARN("Controller filename exists: prompting user to overwrite y/n?");
+ int action = fl_choice("Controller exists, action?", "Cancel", "Rename", "Overwrite");
+ if ( action == 0 ) {
+ // return OK, as user has chosen to cancel writing the file
+ return LUPPP_RETURN_OK;
+ } else if ( action == 1 ) {
+ // rename here
+ const char* name = fl_input("New name for .ctlr file:");
+ if ( name ) {
+ // clear the filename
+ controllerCfgPath.str( "" );
+ controllerCfgPath << getenv("HOME") << "/.config/openAV/luppp/controllers/" << name << ".ctlr";
+ LUPPP_NOTE( "New .ctlr filename %s", controllerCfgPath.str().c_str() );
+ } else {
+ LUPPP_NOTE("No name entered for .ctlr file, canceling!");
+ return LUPPP_RETURN_ERROR;
+ }
+ } else {
+ // just overwrite the file, no action
+ }
+
+
+ }
+
+ LUPPP_NOTE("Writing %s.ctlr file to disk", g->getName().c_str() );
+
+ ofstream controllerCfgFile;
+ controllerCfgFile.open ( controllerCfgPath.str().c_str() );
+ controllerCfgFile << cJSON_Print( controllerJson );
+ controllerCfgFile.close();
+ } else {
+ LUPPP_WARN("Invalid Controller pointer: cannot write %s as is not a GenericMIDI controller!", c->getName().c_str() );
+ return LUPPP_RETURN_ERROR;
+ }
+
+ return LUPPP_RETURN_OK;
}
int DiskWriter::writeAudioBuffer(int track, int scene, AudioBuffer* ab,
- const char *gui_path)
+ const char *gui_path)
{
- stringstream path;
- if ( gui_path && strlen(gui_path) ) {
- printf("saving single buffer to %s\n", gui_path);
- path << gui_path;
- }
- else if ( foldersCreated )
- {
- stringstream filename;
- filename << "t_" << track << "_s_" << scene << ".wav";
-
- // store the clip in clipData, we will write the session JSON for it in writeSession
- clipData.push_back( ClipData( track, scene, filename.str() ) );
-
- // add the AudioBuffer metadata to the sample JSON node
- cJSON* sampleClip = cJSON_CreateObject();
- cJSON_AddItemToObject(audioJson, filename.str().c_str(), sampleClip );
- cJSON_AddNumberToObject(sampleClip,"beats", ab->getBeats() );
-
- // get pretty name from GUI
- std::string clipName = gui->getTrack(track)->getClipSelector()->clipName( scene );
- cJSON_AddItemToObject ( sampleClip, "name", cJSON_CreateString( clipName.c_str() ));
-
- // write the AudioBuffer contents to /audio/ as .wav
- // or alternatively t_