astyle: global restyle of codebase (fixes #153)

This to bring common fomatting to the whole project,
including submissions. To format a file to this style:

astyle --style=linux -t8 <file>

Future patches / pull-requests should be in this format.
This commit is contained in:
Harry van Haaren 2016-12-27 12:47:19 +00:00
parent 0020d9a672
commit 01f71ec5e4
93 changed files with 11792 additions and 11466 deletions

1
.gitignore vendored
View file

@ -5,6 +5,7 @@ src/*.o
luppp
*.zip
*.orig
build/*
buildTest/*

View file

@ -58,8 +58,7 @@ void AudioBuffer::setName(const char* n)
{
memcpy( name, n, sizeof(char)* 19 );
if ( strlen(n) > 19 )
{
if ( strlen(n) > 19 ) {
#ifdef DEBUG_BUFFER
cout << "AudioBuffer setName too long, truncating." << endl;
#endif

View file

@ -30,7 +30,7 @@ using namespace std;
/// AudioBuffer stores float samples in a big vector.
class AudioBuffer
{
public:
public:
AudioBuffer();
AudioBuffer(unsigned long size);
@ -60,7 +60,7 @@ class AudioBuffer
//friend ostream& operator<<(ostream& o, const AudioBuffer& a);
protected:
protected:
static int privateID;
int ID;

View file

@ -25,25 +25,28 @@
class AudioProcessor
{
public:
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");}
virtual void process(unsigned int nframes, Buffers* buffers)
{
printf("AudioProcessor::process() not derived\n");
}
/// set main mix, 0-1
virtual void setMaster(float value){}
virtual void setMaster(float value) {}
/// set sidechain mix, 0-1
virtual void setSidechain(float value){}
virtual void setSidechain(float value) {}
/// set post sidechain mix, 0-1
virtual void setPostSidechain(float value){}
virtual void setPostSidechain(float value) {}
/// set reverb mix, 0-1
virtual void setReverb(float value){}
virtual void setReverb(float value) {}
virtual ~AudioProcessor(){};
virtual ~AudioProcessor() {};
};
#endif // LUPPP_AUDIO_PROCESSOR_H

View file

@ -32,7 +32,7 @@ namespace Avtk
// FIXME: Refactor to .hxx .cxx
class Background : public Fl_Widget
{
public:
public:
Background(int _x, int _y, int _w, int _h, const char *_label = 0):
Fl_Widget(_x, _y, _w, _h, _label)
{
@ -64,8 +64,7 @@ class Background : public Fl_Widget
void draw()
{
if (damage() & FL_DAMAGE_ALL)
{
if (damage() & FL_DAMAGE_ALL) {
cairo_t *cr = Fl::cairo_cc();
cairo_save( cr );
@ -118,14 +117,11 @@ class Background : public Fl_Widget
int handle(int event)
{
switch(event)
{
switch(event) {
case FL_PUSH:
if ( Fl::event_state(FL_BUTTON3) && Fl::event_y() < y + 20 )
{
if ( Fl::event_state(FL_BUTTON3) && Fl::event_y() < y + 20 ) {
const char* name = fl_input( "Track name: ", "" );
if ( name )
{
if ( name ) {
free( (char*) label );
label = strdup( name );
redraw();
@ -150,8 +146,7 @@ class Background : public Fl_Widget
}
return 1;
case FL_SHORTCUT:
if ( test_shortcut() )
{
if ( test_shortcut() ) {
do_callback();
return 1;
}

View file

@ -28,7 +28,7 @@ namespace Avtk
// FIXME: Refactor to .hxx .cxx
class Box : public Fl_Widget
{
public:
public:
Box(int _x, int _y, int _w, int _h, const char *_label = 0):
Fl_Widget(_x, _y, _w, _h, _label)
{
@ -73,8 +73,7 @@ class Box : public Fl_Widget
void draw()
{
if (damage() & FL_DAMAGE_ALL)
{
if (damage() & FL_DAMAGE_ALL) {
cairo_t *cr = Fl::cairo_cc();
cairo_save( cr );

View file

@ -27,7 +27,7 @@ namespace Avtk
class Button : public Fl_Button
{
public:
public:
Button(int _x, int _y, int _w, int _h, const char *_label):
Fl_Button(_x, _y, _w, _h, _label)
{
@ -92,13 +92,13 @@ class Button : public Fl_Button
void setHighlight(bool b)
{
highlight = b; redraw();
highlight = b;
redraw();
}
void draw()
{
if (damage() & FL_DAMAGE_ALL)
{
if (damage() & FL_DAMAGE_ALL) {
cairo_t *cr = Fl::cairo_cc();
cairo_save( cr );
@ -106,8 +106,7 @@ class Button : public Fl_Button
cairo_rectangle( cr, x+1, y+1, w-2, h-2 );
if ( !greyedOut )
cairo_set_source_rgb( cr, _bgr, _bgg, _bgb );
else
{
else {
float grey = (_bgr + _bgg + _bgb) / 3;
cairo_set_source_rgb( cr, grey, grey, grey );
}
@ -116,8 +115,7 @@ class Button : public Fl_Button
cairo_set_line_width(cr, 1.3);
cairo_rectangle( cr, x+1, y+1, w-2, h-2 );
if ( highlight && !greyedOut )
{
if ( highlight && !greyedOut ) {
cairo_set_source_rgba(cr, _r, _g, _b, 0.4);
cairo_fill_preserve(cr);
}
@ -128,8 +126,7 @@ class Button : public Fl_Button
if ( !greyedOut )
cairo_set_source_rgba(cr, _r, _g, _b, alpha);
else
{
else {
float grey = (_r + _g + _b) / 3;
cairo_set_source_rgb( cr, grey, grey, grey );
}
@ -185,8 +182,7 @@ class Button : public Fl_Button
}
return 1;
case FL_SHORTCUT:
if ( test_shortcut() )
{
if ( test_shortcut() ) {
do_callback();
return 1;
}

View file

@ -29,7 +29,7 @@ namespace Avtk
class Dial : public Fl_Slider
{
public:
public:
Dial(int _x, int _y, int _w, int _h, const char* _lab=0):
Fl_Slider(_x, _y, _w, _h, _lab)
{
@ -78,10 +78,8 @@ class Dial : public Fl_Slider
void draw()
{
if (damage() & FL_DAMAGE_ALL)
{
if ( drawLabel )
{
if (damage() & FL_DAMAGE_ALL) {
if ( drawLabel ) {
draw_label();
}
@ -146,12 +144,9 @@ class Dial : public Fl_Slider
highlight = 1;
redraw();
return 1;
case FL_DRAG:
{
if ( Fl::event_state(FL_BUTTON1) )
{
if ( mouseClicked == false ) // catch the "click" event
{
case FL_DRAG: {
if ( Fl::event_state(FL_BUTTON1) ) {
if ( mouseClicked == false ) { // catch the "click" event
mouseClickedY = Fl::event_y();
mouseClicked = true;
}
@ -172,8 +167,7 @@ class Dial : public Fl_Slider
}
}
return 1;
case FL_MOUSEWHEEL:
{
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;

View file

@ -38,7 +38,7 @@ namespace Avtk
class Image : public Fl_Widget
{
public:
public:
Image(int _x, int _y, int _w, int _h, const char *_label=0 ):
Fl_Widget(_x, _y, _w, _h, _label)
{
@ -72,16 +72,14 @@ class Image : public Fl_Widget
void draw()
{
if ( damage() & FL_DAMAGE_ALL && imageDataPtr != 0 )
{
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 )
{
if ( stickToRight ) {
x = gui->getWindowWidth() - w;
}
@ -90,8 +88,7 @@ class Image : public Fl_Widget
int handle(int event)
{
switch(event)
{
switch(event) {
case FL_PUSH:
do_callback();
return 1;
@ -100,8 +97,7 @@ class Image : public Fl_Widget
case FL_RELEASE:
return 1;
case FL_SHORTCUT:
if ( test_shortcut() )
{
if ( test_shortcut() ) {
do_callback();
return 1;
}

View file

@ -27,7 +27,7 @@ namespace Avtk
class LightButton : public Fl_Button
{
public:
public:
LightButton(int _x, int _y, int _w, int _h, const char *_label):
Fl_Button(_x, _y, _w, _h, _label)
{
@ -78,14 +78,10 @@ class LightButton : public Fl_Button
void draw()
{
if (damage() & FL_DAMAGE_ALL)
{
if ( value() )
{
if (damage() & FL_DAMAGE_ALL) {
if ( value() ) {
_highlight = true;
}
else
{
} else {
_highlight = false;
}
@ -100,8 +96,7 @@ class LightButton : public Fl_Button
cairo_set_line_width(cr, 1.5);
cairo_rectangle( cr, x+1, y+1, w-2, h-2 );
if ( _highlight )
{
if ( _highlight ) {
cairo_set_source_rgba(cr, _r, _g, _b, 0.4);
cairo_fill_preserve(cr);
}
@ -133,11 +128,9 @@ class LightButton : public Fl_Button
int handle(int event)
{
switch(event) {
case FL_ACTIVATE:
{
case FL_ACTIVATE: {
}
case FL_DEACTIVATE:
{
case FL_DEACTIVATE: {
}
return 1;
case FL_PUSH:
@ -163,8 +156,7 @@ class LightButton : public Fl_Button
case FL_RELEASE:
return 1;
case FL_SHORTCUT:
if ( test_shortcut() )
{
if ( test_shortcut() ) {
do_callback();
return 1;
}

View file

@ -27,7 +27,7 @@ namespace Avtk
class RadialStatus : public Fl_Slider
{
public:
public:
RadialStatus(int _x, int _y, int _w, int _h, const char *_label = 0):
Fl_Slider(_x, _y, _w, _h, _label)
{
@ -55,7 +55,11 @@ class RadialStatus : public Fl_Slider
}
bool _recording;
void recording(bool r){_recording = r; redraw();}
void recording(bool r)
{
_recording = r;
redraw();
}
bool mouseOver;
bool highlight;
@ -88,8 +92,7 @@ class RadialStatus : public Fl_Slider
int newAngle = (value() * 16);
if (damage() & FL_DAMAGE_ALL &&
previousAngle != newAngle )
{
previousAngle != newAngle ) {
cairo_t *cr = Fl::cairo_cc();
cairo_save( cr );
@ -115,8 +118,7 @@ class RadialStatus : public Fl_Slider
// recording?
if ( _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);
@ -126,9 +128,7 @@ class RadialStatus : public Fl_Slider
// color of internal dot depending on rec state
cairo_set_source_rgba(cr,0.0,0.0,0.0, 1);
}
else
{
} else {
cairo_set_source_rgba(cr,0.3,0.3,0.3, 1);
}
@ -184,8 +184,7 @@ class RadialStatus : public Fl_Slider
}
return 1;
case FL_SHORTCUT:
if ( test_shortcut() )
{
if ( test_shortcut() ) {
do_callback();
return 1;
}

View file

@ -27,7 +27,7 @@ namespace Avtk
class Reverb : public Fl_Slider
{
public:
public:
Reverb(int _x, int _y, int _w, int _h, const char *_label =0):
Fl_Slider(_x, _y, _w, _h, _label)
{
@ -48,16 +48,44 @@ class Reverb : public Fl_Slider
mouseOver = false;
}
void size(float v) { s = v; redraw(); }
void wet(float v) { amp = v; redraw(); }
void damping(float v){damp = v; redraw();}
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;}
float size()
{
return s;
}
float wet ()
{
return amp;
}
float damping()
{
return damp;
}
bool getActive(){return active;}
void setActive(bool a){active = a; redraw();}
bool getActive()
{
return active;
}
void setActive(bool a)
{
active = a;
redraw();
}
float s;
float amp;
@ -72,8 +100,7 @@ class Reverb : public Fl_Slider
void draw()
{
if (damage() & FL_DAMAGE_ALL)
{
if (damage() & FL_DAMAGE_ALL) {
cairo_t *cr = Fl::cairo_cc();
cairo_save( cr );
@ -93,13 +120,11 @@ class Reverb : public Fl_Slider
// 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++ )
{
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++ )
{
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) );
}
@ -135,8 +160,7 @@ class Reverb : public Fl_Slider
cairo_set_line_width(cr, 0.9);
cairo_stroke( cr );
if ( !active )
{
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);
@ -171,8 +195,7 @@ class Reverb : public Fl_Slider
switch(event) {
case FL_PUSH:
highlight = 1;
if ( Fl::event_button() == FL_RIGHT_MOUSE )
{
if ( Fl::event_button() == FL_RIGHT_MOUSE ) {
active = !active;
redraw();
do_callback();
@ -201,8 +224,7 @@ class Reverb : public Fl_Slider
}
return 1;
case FL_SHORTCUT:
if ( test_shortcut() )
{
if ( test_shortcut() ) {
do_callback();
return 1;
}

View file

@ -32,7 +32,7 @@ namespace Avtk
class SidechainGain : public Fl_Slider
{
public:
public:
SidechainGain(int _x, int _y, int _w, int _h, const char *_label = 0):
Fl_Slider(_x, _y, _w, _h, _label)
{
@ -58,12 +58,28 @@ class SidechainGain : public Fl_Slider
_sidechainAmp = 0;
}
void threshold(float t) {_threshold = t; redraw();}
void reduce (float r) {_reduce = r; redraw();}
void release (float r) {_release = r; redraw();}
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();}
void sidechain(float s)
{
_sidechainAmp = s;
redraw();
}
bool active;
bool highlight;
@ -90,8 +106,7 @@ class SidechainGain : public Fl_Slider
void draw()
{
if (damage() & FL_DAMAGE_ALL)
{
if (damage() & FL_DAMAGE_ALL) {
cairo_t *cr = Fl::cairo_cc();
cairo_save( cr );
@ -116,13 +131,11 @@ class SidechainGain : public Fl_Slider
// 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++ )
{
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++ )
{
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) );
}
@ -172,8 +185,7 @@ class SidechainGain : public Fl_Slider
cairo_set_line_width(cr, 1.9);
cairo_stroke( cr );
if ( !active )
{
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);
@ -202,12 +214,13 @@ class SidechainGain : public Fl_Slider
}
int handle(int event)
{ //TODO needed?
{
//TODO needed?
return 0;
}
private:
private:
};
} // Avtk

View file

@ -29,7 +29,7 @@ namespace Avtk
class UnitState
{
public:
public:
enum State {
UNIT_EMPTY = 0,
UNIT_LOADED,
@ -55,7 +55,7 @@ class UnitState
class Unit : public Fl_Button
{
public:
public:
Unit(int _x, int _y, int _w, int _h, const char *_label):
Fl_Button(_x, _y, _w, _h, _label)
{
@ -87,14 +87,10 @@ class Unit : public Fl_Button
void draw()
{
if (damage() & FL_DAMAGE_ALL)
{
if ( value() )
{
if (damage() & FL_DAMAGE_ALL) {
if ( value() ) {
highlight = true;
}
else
{
} else {
highlight = false;
}
@ -127,7 +123,9 @@ class Unit : public Fl_Button
// outline
float alpha = 0.7;
if (mouseOver) { alpha = 1; }
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);
@ -154,11 +152,9 @@ class Unit : public Fl_Button
int handle(int event)
{
switch(event) {
case FL_ACTIVATE:
{
case FL_ACTIVATE: {
}
case FL_DEACTIVATE:
{
case FL_DEACTIVATE: {
}
return 1;
case FL_PUSH:
@ -184,8 +180,7 @@ class Unit : public Fl_Button
case FL_RELEASE:
return 1;
case FL_SHORTCUT:
if ( test_shortcut() )
{
if ( test_shortcut() ) {
do_callback();
return 1;
}

View file

@ -45,8 +45,7 @@ Bindings::Bindings( int _x, int _y, int _w, int _h, const char *_label ) :
void Bindings::draw()
{
if (damage() & FL_DAMAGE_ALL)
{
if (damage() & FL_DAMAGE_ALL) {
cairo_t *cr = Fl::cairo_cc();
cairo_save( cr );
@ -68,8 +67,7 @@ void Bindings::draw()
int drawY = y + bindYPx;
for(unsigned int i = 0; i < binds.size(); i++) // draw each binding
{
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);

View file

@ -31,7 +31,7 @@ namespace Avtk
class Bindings : public Fl_Button
{
public:
public:
Bindings( int _x, int _y, int _w, int _h, const char *_label = 0 );
bool mouseOver;

View file

@ -44,10 +44,8 @@ ClipSelector::ClipSelector( int _x, int _y, int _w, int _h,
label = _label;
_master = master;
if ( _master )
{
for(int i = 0; i < 10; i++ )
{
if ( _master ) {
for(int i = 0; i < 10; i++ ) {
stringstream s;
s << "Scene " << i + 1;
clips[i].setName( s.str() );
@ -74,8 +72,7 @@ void ClipSelector::setState( int clipNum, GridLogic::State s )
//cout << "ClipSelector::setState() t = " << ID << " clipNum = " << clipNum << " state = " << s << endl;
#endif
clips[clipNum].setState( s );
if ( s == GridLogic::STATE_EMPTY )
{
if ( s == GridLogic::STATE_EMPTY ) {
clips[clipNum].setName("");
}
@ -95,8 +92,7 @@ void ClipSelector::clipName(int clip, std::string name)
void ClipSelector::setSpecial(int scene)
{
if ( special == -1 && scene == -1 )
{
if ( special == -1 && scene == -1 ) {
// no change
return;
}
@ -107,14 +103,10 @@ void ClipSelector::setSpecial(int scene)
void ClipSelector::draw()
{
if (damage() & FL_DAMAGE_ALL)
{
if ( value() )
{
if (damage() & FL_DAMAGE_ALL) {
if ( value() ) {
highlight = true;
}
else
{
} else {
highlight = false;
}
@ -136,8 +128,7 @@ void ClipSelector::draw()
int xOff = x+clipHeight/2;
int drawY = y + 1;
for( int i = 0; i < numClips; i++) // draw each clip
{
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 );
@ -146,17 +137,14 @@ void ClipSelector::draw()
cairo_rectangle( cr, x+2, drawY, clipHeight-4, clipHeight - 4 );
if ( clips[i].getState() == GridLogic::STATE_RECORDING )
{
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 )
{
} 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 );
@ -165,9 +153,7 @@ void ClipSelector::draw()
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 )
{
} 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 );
@ -176,35 +162,27 @@ void ClipSelector::draw()
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 )
{
} 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 )
{
} 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 )
{
} 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
{
} else {
cairo_set_source_rgba(cr, 66 / 255.f, 66 / 255.f , 66 / 255.f, 1.f);
cairo_fill(cr);
}
@ -228,8 +206,7 @@ void ClipSelector::draw()
cairo_show_text( cr, tmp.c_str() );
// special indicator?
if ( i == special )
{
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 );
@ -260,11 +237,9 @@ void ClipSelector::resize(int X, int Y, int W, int H)
int ClipSelector::handle(int event)
{
switch(event) {
case FL_ACTIVATE:
{
case FL_ACTIVATE: {
}
case FL_DEACTIVATE:
{
case FL_DEACTIVATE: {
}
return 1;
case FL_PUSH:
@ -277,10 +252,8 @@ int ClipSelector::handle(int event)
clipNum = numClips -1; // fix for clicking the lowest pixel
// handle right clicks: popup menu
if ( Fl::event_state(FL_BUTTON3) )
{
if ( _master )
{
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 )
@ -291,8 +264,7 @@ int ClipSelector::handle(int event)
}
Fl_Menu_Item rclick_menu[] =
{
Fl_Menu_Item rclick_menu[] = {
{ "Load" },
{ "Save" },
{ "Special"},
@ -312,16 +284,11 @@ int ClipSelector::handle(int event)
{ 0 }
};
Fl_Menu_Item *m = (Fl_Menu_Item*) rclick_menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, 0);
if ( !m )
{
if ( !m ) {
return 0;
}
else if ( strcmp(m->label(), "Load") == 0 )
{
} else if ( strcmp(m->label(), "Load") == 0 ) {
gui->selectLoadSample( ID, clipNum );
}
else if ( strcmp(m->label(), "Save") == 0 )
{
} else if ( strcmp(m->label(), "Save") == 0 ) {
//gui->saveBufferPath = "/tmp/test.wav";
char* tmp = gui->selectSavePath();
if(tmp && strlen(tmp)) {
@ -335,8 +302,7 @@ int ClipSelector::handle(int event)
free(tmp);
gui->selectSaveSample( ID, clipNum );
}
}
else if ( strcmp(m->label(), "1 ") == 0 ) {
} else if ( strcmp(m->label(), "1 ") == 0 ) {
EventLooperLoopLength e = EventLooperLoopLength(ID, clipNum ,1);
writeToDspRingbuffer( &e );
} else if ( strcmp(m->label(), "2") == 0 ) {
@ -357,35 +323,24 @@ int ClipSelector::handle(int event)
} else if ( strcmp(m->label(), "64") == 0 ) {
EventLooperLoopLength e = EventLooperLoopLength(ID, clipNum ,64);
writeToDspRingbuffer( &e );
}
else if ( strcmp(m->label(), "Use as tempo") == 0 )
{
} else if ( strcmp(m->label(), "Use as tempo") == 0 ) {
EventLooperUseAsTempo e (ID, clipNum);
writeToDspRingbuffer( &e );
}
else if ( strcmp(m->label(), "Special") == 0 )
{
} 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 )
{
} 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 )
{
} 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 )
{
} else {
if ( _master ) {
EventGridLaunchScene e( clipNum );
writeToDspRingbuffer( &e );
redraw();
@ -400,11 +355,9 @@ int ClipSelector::handle(int event)
redraw();
do_callback();
return 1;
case FL_DRAG:
{
case FL_DRAG: {
int t = Fl::event_inside(this);
if (t != highlight)
{
if (t != highlight) {
highlight = t;
redraw();
}
@ -422,8 +375,7 @@ int ClipSelector::handle(int event)
case FL_RELEASE:
return 1;
case FL_SHORTCUT:
if ( test_shortcut() )
{
if ( test_shortcut() ) {
do_callback();
return 1;
}

View file

@ -38,7 +38,7 @@ namespace Avtk
class ClipState
{
public:
public:
ClipState() :
state(GridLogic::STATE_EMPTY),
name("")
@ -64,14 +64,14 @@ class ClipState
return state;
}
private:
private:
GridLogic::State state;
std::string name;
};
class ClipSelector : public Fl_Button
{
public:
public:
ClipSelector( int _x, int _y, int _w, int _h,
const char *_label, bool master = false);

View file

@ -61,8 +61,7 @@ void Volume::amplitude (float aL, float aR)
// only redraw if changed more than X amount
if ( fabsf(ampL - aL) > 0.025 ||
fabsf(ampR - aR) > 0.025 )
{
fabsf(ampR - aR) > 0.025 ) {
ampL = aL;
ampR = aR;
redraw();
@ -91,8 +90,7 @@ void Volume::set_active(bool a)
void Volume::draw()
{
if (damage() & FL_DAMAGE_ALL)
{
if (damage() & FL_DAMAGE_ALL) {
cairo_t *cr = Fl::cairo_cc();
cairo_save( cr );
@ -111,13 +109,11 @@ void Volume::draw()
// 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++ )
{
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++ )
{
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) );
}
@ -128,13 +124,10 @@ void Volume::draw()
// audio level
if ( orientationHorizontal )
{
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
{
} 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) );
}
@ -175,18 +168,14 @@ void Volume::resize(int X, int Y, int W, int H)
int Volume::handle(int event)
{
switch(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
{
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;
@ -226,8 +215,7 @@ int Volume::handle(int event)
mouseClicked = false;
return 1;
case FL_SHORTCUT:
if ( test_shortcut() )
{
if ( test_shortcut() ) {
do_callback();
return 1;
}

View file

@ -28,9 +28,9 @@
namespace Avtk
{
class Volume : public Fl_Slider
{
public:
class Volume : public Fl_Slider
{
public:
Volume(int _x, int _y, int _w, int _h, const char *_label = 0);
void set_active(bool a);
@ -46,7 +46,7 @@ namespace Avtk
void resize(int X, int Y, int W, int H);
private:
private:
bool active;
bool highlight;
bool orientationHorizontal;
@ -60,7 +60,7 @@ namespace Avtk
float ampL, ampR;
float compress;
};
};
} // Avtk
#endif // AVTK_VOLUME_H

View file

@ -33,7 +33,7 @@ namespace Avtk
class Waveform : public Fl_Widget
{
public:
public:
Waveform(int _x, int _y, int _w, int _h, const char *_label=0 ):
Fl_Widget(_x, _y, _w, _h, _label)
{
@ -55,8 +55,7 @@ class Waveform : public Fl_Widget
srand (time(NULL));
for (int i = 0; i < _w; i++)
{
for (int i = 0; i < _w; i++) {
data[i] = rand() / RAND_MAX / 0.75;
}
@ -91,8 +90,7 @@ class Waveform : public Fl_Widget
void draw()
{
if (damage() & FL_DAMAGE_ALL)
{
if (damage() & FL_DAMAGE_ALL) {
cairo_t *cr = Fl::cairo_cc();
cairo_save(cr);
@ -101,10 +99,8 @@ class Waveform : public Fl_Widget
cairo_set_source_rgb (cr, 0.1,0.1,0.1);
cairo_fill( cr );
if ( newWaveform )
{
if ( !waveformCr )
{
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);
@ -127,13 +123,11 @@ class Waveform : public Fl_Widget
// 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++ )
{
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++ )
{
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) );
}
@ -143,8 +137,7 @@ class Waveform : public Fl_Widget
cairo_set_dash ( waveformCr, dashes, 0, 0.0);
if ( !data )
{
if ( !data ) {
// draw X
cairo_move_to( cr, 0 , 0 );
cairo_line_to( cr, 0 + w, 0 + h );
@ -158,9 +151,7 @@ class Waveform : public Fl_Widget
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
{
} else {
// don't draw every sample
int sampleCountForDrawing = -1;
@ -173,21 +164,16 @@ class Waveform : public Fl_Widget
//cout << "width = " << w << " sampsPerPx " << samplesPerPix << endl;
// loop over each pixel value we need
for( int p = 0; p < w; p++ )
{
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++ )
{
for( int i = 0; i < samplesPerPix; i++ ) {
float tmp = data[i + (p * samplesPerPix)];
if ( tmp < 0 )
{
if ( tmp < 0 ) {
averageMin -= tmp;
}
else
{
} else {
averageMax += tmp;
}
}
@ -226,8 +212,7 @@ class Waveform : public Fl_Widget
cairo_rectangle( cr, x, y, w, h);
cairo_paint(cr);
if ( strokeRim )
{
if ( strokeRim ) {
// stroke rim
cairo_set_line_width(cr, 1);
cairo_rectangle(cr, x, y, w, h);
@ -272,8 +257,7 @@ class Waveform : public Fl_Widget
{
return 0;
switch(event)
{
switch(event) {
case FL_PUSH:
highlight = 0;
redraw();
@ -293,8 +277,7 @@ class Waveform : public Fl_Widget
}
return 1;
case FL_SHORTCUT:
if ( test_shortcut() )
{
if ( test_shortcut() ) {
do_callback();
return 1;
}

View file

@ -24,7 +24,7 @@
class Buffers
{
public:
public:
enum BUFFER {
// AUDIO

View file

@ -27,9 +27,12 @@ typedef int LupppAction;
class Binding
{
public:
public:
Binding() : status(0), data(0), action(0), active(-1),
track(-2),scene(-1),send(-1) { ID = privateID++; }
track(-2),scene(-1),send(-1)
{
ID = privateID++;
}
int ID;
@ -49,7 +52,7 @@ class Binding
/// maps from Gridlogic::State to MIDI output value from binding
std::map<int,int> clipStateMap;
private:
private:
/// static int counter to allow deleting this specific instance
static int privateID;

View file

@ -31,7 +31,7 @@
**/
class Controller
{
public:
public:
/// used to report the controller status
enum STATUS {
CONTROLLER_ERROR = 0,
@ -45,50 +45,56 @@ class Controller
int getID();
/// allows instance to register MIDI observer type functionality
virtual int registerComponents(){return 0;}
virtual int registerComponents()
{
return 0;
}
virtual ~Controller(){};
virtual ~Controller() {};
/// get the status of the controller
virtual STATUS status(){return CONTROLLER_OK;}
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){}
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 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){}
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){}
virtual void bpm(int bpm) {}
virtual void tapTempo(bool b) {}
/// Special
virtual void specialScene(int t, int scene){}
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 ){}
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:
private:
static int privateID;
int ID;
};

View file

@ -50,18 +50,13 @@ GenericMIDI::GenericMIDI(int waste, std::string n) :
void GenericMIDI::setFootswitchToNextScene(int v)
{
LUPPP_NOTE("Set Footswitch to %i", v );
if ( v == 0 )
{
if ( v == 0 ) {
footswitchNextScene = false;
footswitchPrevScene = false;
}
else if ( v > 0 )
{
} else if ( v > 0 ) {
footswitchNextScene = true;
footswitchPrevScene = false;
}
else
{
} else {
footswitchNextScene = false;
footswitchPrevScene = true;
}
@ -82,14 +77,11 @@ GenericMIDI::GenericMIDI(std::string file) :
// load the JSON config file
int result = loadController( file );
if ( result == LUPPP_RETURN_OK )
{
if ( result == LUPPP_RETURN_OK ) {
LUPPP_NOTE("GenericMIDI registering ports: %s", name.c_str() );
registerMidiPorts( name );
stat = CONTROLLER_OK;
}
else
{
} else {
LUPPP_ERROR("Error in loading controller map!" );
stat = CONTROLLER_ERROR;
}
@ -138,12 +130,10 @@ void GenericMIDI::volume(int t, float f)
void GenericMIDI::recordArm(int t, bool enabled)
{
for(unsigned int i = 0; i < actionToMidi.size(); i++)
{
for(unsigned int i = 0; i < actionToMidi.size(); i++) {
Binding* b = actionToMidi.at(i);
if ( b->action == TRACK_RECORD_ARM && b->track == t )
{
if ( b->action == TRACK_RECORD_ARM && b->track == t ) {
unsigned char data[3];
data[0] = b->status;
data[1] = b->data;
@ -156,12 +146,10 @@ void GenericMIDI::recordArm(int t, bool enabled)
void GenericMIDI::metronomeEnable(bool enabled)
{
for(unsigned int i = 0; i < actionToMidi.size(); i++)
{
for(unsigned int i = 0; i < actionToMidi.size(); i++) {
Binding* b = actionToMidi.at(i);
if ( b->action == METRONOME_ACTIVE )
{
if ( b->action == METRONOME_ACTIVE ) {
unsigned char data[3];
data[0] = b->status;
data[1] = b->data;
@ -175,12 +163,10 @@ void GenericMIDI::metronomeEnable(bool enabled)
void GenericMIDI::trackSend(int t, int send, float v)
{
for(unsigned int i = 0; i < actionToMidi.size(); i++)
{
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 )
{
if ( b->action == TRACK_SEND && b->track == t && b->send == send ) {
unsigned char data[3];
data[0] = b->status;
data[1] = b->data;
@ -193,12 +179,10 @@ void GenericMIDI::trackSend(int t, int send, float v)
void GenericMIDI::trackSendActive(int t, int send, bool a)
{
for(unsigned int i = 0; i < actionToMidi.size(); i++)
{
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 )
{
if ( b->action == TRACK_SEND_ACTIVE && b->track == t && b->send == send ) {
unsigned char data[3];
data[0] = b->status;
data[1] = b->data;
@ -453,8 +437,7 @@ void GenericMIDI::midi(unsigned char* midi)
// create new MIDI binding?
if ( jack->bindingEventRecordEnable )
{
if ( jack->bindingEventRecordEnable ) {
//LUPPP_NOTE("making binding from: %i %i %f", status, data, value );
setupBinding( jack->bindingEventType, status, data,
jack->bindingTrack,
@ -474,39 +457,43 @@ void GenericMIDI::midi(unsigned char* midi)
writeToGuiRingbuffer( &e2 );
}
if ( status == 0x90 && data == 0x64 ) // nudge +
{
if ( status == 0x90 && data == 0x64 ) { // nudge +
// footpedal to scene++
setFootswitchToNextScene( 1 );
}
else if ( status == 0x90 && data == 0x65 ) // nudge
{
} else if ( status == 0x90 && data == 0x65 ) { // nudge
// footpedal to scene--
setFootswitchToNextScene( -1 );
}
else if ( status == 0x90 && data == 0x60 ) // > on bank select: clear scene
{
} 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++)
{
for(unsigned int i = 0; i < midiToAction.size(); i++) {
Binding* b = midiToAction.at(i);
if ( b->status == status && b->data == data )
{
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;
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 );
@ -516,18 +503,13 @@ void GenericMIDI::midi(unsigned char* midi)
case Event::GRID_SELECT_CLIP_EVENT:
// hack to do scene ++ / -- with footswitch
if ( footswitchNextScene && value > 0.5 ) // avoid note offs
{
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 )
{
} else if ( footswitchPrevScene && value > 0.5 ) {
cout << "footswitch prev scene *now*" << endl;
jack->getGridLogic()->launchScene( jack->getGridLogic()->getCurrentScene() - 1 );
}
else
{
} else {
cout << "footswitch special clip action now" << endl;
jack->getGridLogic()->selectedTrackSceneEvent( value );
}
@ -565,7 +547,9 @@ void GenericMIDI::midi(unsigned char* midi)
jack->getLogic()->metronomeEnable( b->active );
break;
case Event::MASTER_VOL: jack->getLogic()->trackVolume( -1 , value ); break;
case Event::MASTER_VOL:
jack->getLogic()->trackVolume( -1 , value );
break;
}
}
@ -576,17 +560,13 @@ void GenericMIDI::midi(unsigned char* midi)
void GenericMIDI::setSceneState(int t, int scene, GridLogic::State s)
{
for(unsigned int i = 0; i < actionToMidi.size(); i++)
{
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<int,int>::iterator it = b->clipStateMap.begin(); it != b->clipStateMap.end(); ++it)
{
if ( b->action == GRID_STATE && b->track == t && b->scene == scene ) {
for( map<int,int>::iterator it = b->clipStateMap.begin(); it != b->clipStateMap.end(); ++it) {
// check if its the right clip state
if ( it->first == int(s) )
{
if ( it->first == int(s) ) {
unsigned char data[3];
data[0] = b->status;
data[1] = b->data;
@ -602,7 +582,8 @@ void GenericMIDI::setSceneState(int t, int scene, GridLogic::State s)
void GenericMIDI::reset()
{//TODO needed?
{
//TODO needed?
/*
unsigned char data[3];
// setup "volume" style rotary display
@ -618,16 +599,12 @@ void GenericMIDI::reset()
void GenericMIDI::launchScene( int scene )
{
for(unsigned int i = 0; i < actionToMidi.size(); i++)
{
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 )
{
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;
@ -658,8 +635,7 @@ int GenericMIDI::loadController( std::string file )
#endif
std::ifstream sampleFile( file.c_str(), std::ios_base::in|std::ios_base::ate);
long file_length = sampleFile.tellg();
if ( file_length > 0 )
{
if ( file_length > 0 ) {
sampleFile.seekg(0, std::ios_base::beg);
sampleFile.clear();
char *sampleString = new char[file_length];
@ -675,8 +651,7 @@ int GenericMIDI::loadController( std::string file )
std::getline( ss, line );
LUPPP_ERROR("%s %s","Error in JSON *before*: ", line.c_str() );
for(int i = 0; i < 5; i++)
{
for(int i = 0; i < 5; i++) {
std::getline( ss, line );
LUPPP_ERROR("%s %s","Error in JSON : ", line.c_str() );
}
@ -684,46 +659,35 @@ int GenericMIDI::loadController( std::string file )
}
cJSON* nameJson = cJSON_GetObjectItem( controllerJson, "name" );
if ( nameJson )
{
if ( nameJson ) {
name = nameJson->valuestring;
LUPPP_NOTE("Device %s", name.c_str() );
}
else
{
} else {
LUPPP_NOTE("Has no name field");
}
cJSON* authorJson = cJSON_GetObjectItem( controllerJson, "author" );
if ( authorJson )
{
if ( authorJson ) {
author = authorJson->valuestring;
LUPPP_NOTE("Author %s", author.c_str() );
}
else
{
} else {
LUPPP_NOTE("Has no author field");
}
cJSON* linkJson = cJSON_GetObjectItem( controllerJson, "link" );
if ( linkJson )
{
if ( linkJson ) {
email = linkJson->valuestring;
LUPPP_NOTE("Link %s", email.c_str() );
}
else
{
} else {
LUPPP_NOTE("Has no link field");
}
int nInputBindings = 0;
cJSON* inputBindings = cJSON_GetObjectItem( controllerJson, "inputBindings");
if ( inputBindings )
{
if ( inputBindings ) {
int nBindings = cJSON_GetArraySize( inputBindings );
for(int i = 0; i < nBindings; i++ )
{
for(int i = 0; i < nBindings; i++ ) {
cJSON* bindingJson = cJSON_GetArrayItem( inputBindings, i );
Binding* tmp = setupBinding( bindingJson );
if ( tmp )
@ -731,26 +695,21 @@ int GenericMIDI::loadController( std::string file )
nInputBindings++;
}
}
else
{
} else {
LUPPP_WARN("No input bindings array in .ctlr map." );
nInputBindings++; // hack to avoid 2 prints
}
if ( nInputBindings == 0 )
{
if ( nInputBindings == 0 ) {
LUPPP_NOTE("Zero input bindings present in .ctlr map.");
}
int nOutputBindings = 0;
cJSON* outputBindings = cJSON_GetObjectItem( controllerJson, "outputBindings");
if ( outputBindings )
{
if ( outputBindings ) {
int nBindings = cJSON_GetArraySize( outputBindings );
for(int i = 0; i < nBindings; i++ )
{
for(int i = 0; i < nBindings; i++ ) {
cJSON* bindingJson = cJSON_GetArrayItem( outputBindings, i );
Binding* tmp = setupBinding( bindingJson );
if ( tmp )
@ -759,23 +718,18 @@ int GenericMIDI::loadController( std::string file )
nOutputBindings++;
//LUPPP_NOTE("Binding from %s to %i %i", actionJ->valuestring, statusJson->valueint, dataJson->valueint );
}
}
else
{
} else {
LUPPP_NOTE("No output bindings array in .ctlr map." );
nOutputBindings++; // hack to avoid 2 prints
}
if ( nOutputBindings == 0 )
{
if ( nOutputBindings == 0 ) {
LUPPP_NOTE("Zero output bindings present in .ctlr map." );
}
cJSON_Delete( controllerJson );
delete[] sampleString;
}
else
{
} else {
LUPPP_WARN("%s %s","No controller file found at ", file.c_str() );
return LUPPP_RETURN_WARNING;
}
@ -788,16 +742,13 @@ int GenericMIDI::loadController( std::string file )
void GenericMIDI::removeBinding( int bindingID )
{
for(unsigned int i = 0; i < midiToAction.size(); i++)
{
if ( midiToAction.at(i)->ID == 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 )
{
if ( tmp ) {
delete tmp;
}
return;
@ -835,16 +786,14 @@ Binding* GenericMIDI::setupBinding( cJSON* binding )
cJSON* actionJson = cJSON_GetObjectItem( binding, "action" );
if ( !actionJson )
{
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 )
{
if ( !statusJson || !dataJson ) {
LUPPP_WARN("Binding w Action:%s doesn't have status / data field: fix .ctlr file", actionJson->valuestring);
return 0;
}
@ -854,8 +803,7 @@ Binding* GenericMIDI::setupBinding( cJSON* binding )
// gets the Action type from the JSON string
cJSON* activeJson = cJSON_GetObjectItem( binding, "active" );
if ( activeJson )
{
if ( activeJson ) {
tmp->active = activeJson->valueint;
}
@ -864,20 +812,17 @@ Binding* GenericMIDI::setupBinding( cJSON* binding )
// check what our send value should be:
cJSON* sendJson = cJSON_GetObjectItem( binding, "send" );
if ( sendJson )
{
if ( sendJson ) {
tmp->send = sendJson->valueint;
}
if ( strcmp( actionJson->valuestring, "grid:clip_state" ) == 0 )
{
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 )
{
if ( stateBindings ) {
cJSON* empty = cJSON_GetObjectItem( stateBindings, "empty");
cJSON* stopped = cJSON_GetObjectItem( stateBindings, "stopped");
cJSON* playing = cJSON_GetObjectItem( stateBindings, "playing");
@ -913,24 +858,19 @@ Binding* GenericMIDI::setupBinding( cJSON* binding )
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 ) {
} 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 ) {
} 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 ) {
} else if ( strcmp( actionJson->valuestring, "master:volume" ) == 0 ) {
tmp->action = Event::MASTER_VOL;
}
else if ( strcmp( actionJson->valuestring, "metronome:active" ) == 0 ) {
} 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 )
{
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" );
@ -945,9 +885,7 @@ Binding* GenericMIDI::setupBinding( cJSON* binding )
tmp->active = activeJson->valueint;
return tmp;
}
else
{
} else {
LUPPP_WARN("Binding action not recognized: %s", actionJson->valuestring );
}

View file

@ -36,7 +36,7 @@
**/
class GenericMIDI : public Controller, public MidiIO
{
public:
public:
/// Creates a blank GenericMIDI instance, which can be bound dynamically
GenericMIDI(int waste = 0, std::string name = "generic");
@ -97,7 +97,7 @@ class GenericMIDI : public Controller, public MidiIO
void setupBinding( LupppAction eventType, int midiStatus, int midiData, int track, int scene, int send, int active );
void removeBinding( int bindingID );
private:
private:
STATUS stat;
std::string name;

View file

@ -26,10 +26,13 @@
class LupppGUI : public Controller
{
public:
public:
LupppGUI();
std::string getName(){return "Luppp GUI";}
std::string getName()
{
return "Luppp GUI";
}
void masterVolume(float f);
void masterReturnVolume(float f);

View file

@ -29,9 +29,9 @@
**/
class NonSeq : public Controller, public MidiIO
{
public:
public:
NonSeq();
~NonSeq(){};
~NonSeq() {};
std::string getName();

View file

@ -28,8 +28,7 @@ ControllerUpdater::ControllerUpdater()
void ControllerUpdater::registerController( Controller* controller )
{
if (!controller)
{
if (!controller) {
LUPPP_ERROR("Register Controller passed NULL controller!");
return;
}
@ -45,10 +44,8 @@ void ControllerUpdater::registerController( Controller* controller )
void ControllerUpdater::removeController( int id )
{
for( unsigned int i = 0; i < c.size(); i++)
{
if ( c.at(i)->getID() == 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 );
@ -68,10 +65,8 @@ void ControllerUpdater::removeController( int id )
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 )
{
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);
}

View file

@ -43,7 +43,7 @@ using namespace std;
**/
class ControllerUpdater
{
public:
public:
ControllerUpdater();
/// add a Controller* to Controllers that recieve updates
@ -85,7 +85,7 @@ class ControllerUpdater
void metronomeEnable(bool b);
private:
private:
std::vector<Controller*> c;
};

View file

@ -24,28 +24,20 @@
void luppp_debug( int warnLevel, const char* name, const char* file, const char* func, int line,
const char* format, ... )
{
if ( warnLevel == DEBUG_LEVEL_ERROR )
{
if ( warnLevel == DEBUG_LEVEL_ERROR ) {
printf( "[\033[1;31m%s\033[0m] %s:%i: ", name, func, line );
}
else if ( warnLevel == DEBUG_LEVEL_WARN )
{
} else if ( warnLevel == DEBUG_LEVEL_WARN ) {
printf( "[\033[1;33m%s\033[0m] %s:%i: ", name, func, line );
}
else if ( warnLevel == DEBUG_LEVEL_TEST )
{
} else if ( warnLevel == DEBUG_LEVEL_TEST ) {
#ifdef BUILD_TESTS
printf( "[\033[1;33m%s\033[0m] %s:%i: ", name, func, line );
#endif
}
else // NOTE
{
} else { // NOTE
printf( "[\033[1;32m%s\033[0m] %s:%i: ", name, func, line );
}
printf( "\033[0m" );
if ( format )
{
if ( format ) {
va_list args;
va_start( args, format );
vfprintf( stdout, format, args );

View file

@ -56,57 +56,47 @@ int DiskReader::loadPreferences()
std::ifstream sampleFile( s.str().c_str(), std::ios_base::in|std::ios_base::ate);
long file_length = sampleFile.tellg();
if ( file_length > 0 )
{
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)
{
if (!preferencesJson) {
LUPPP_WARN("Preferences JSON not valid");
return LUPPP_RETURN_ERROR;
}
cJSON* resample = cJSON_GetObjectItem( preferencesJson, "resampleQuality" );
if ( resample )
{
if ( resample ) {
resampleQuality = resample->valueint;
if ( resampleQuality == 0 )
{
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 )
{
if ( ctlrs ) {
//cout << ".ctlr HAS items." << endl;
int nCtlrs = cJSON_GetArraySize( ctlrs );
for(int i = 0; i < nCtlrs; i++ )
{
for(int i = 0; i < nCtlrs; i++ ) {
cJSON* ctlr = cJSON_GetArrayItem( ctlrs, i );
if( ctlr )
{
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
{
} else {
LUPPP_NOTE("No default controllers active.");
}
cJSON* projDir=cJSON_GetObjectItem(preferencesJson,"saveDirectory");
string dir=getenv("HOME");
if(projDir)
{
if(projDir) {
stringstream s;
s<<dir<<"/"<<projDir->valuestring;
dir=s.str();
@ -115,8 +105,7 @@ int DiskReader::loadPreferences()
//Enable per track send and resturn jack ports?
cJSON* jackPerTrackOutput=cJSON_GetObjectItem(preferencesJson,"enablePerTrackOutput");
if(jackPerTrackOutput)
{
if(jackPerTrackOutput) {
gui->enablePerTrackOutput=jackPerTrackOutput->valueint;
if(gui->enablePerTrackOutput)
LUPPP_NOTE("Enabling per track output ports");
@ -124,16 +113,14 @@ int DiskReader::loadPreferences()
//Metronome on by default?
cJSON* metronomeActive=cJSON_GetObjectItem(preferencesJson,"metronomeActiveByDefault");
if(metronomeActive)
{
if(metronomeActive) {
EventMetronomeActive e = EventMetronomeActive( metronomeActive->valueint);
writeToDspRingbuffer( &e );
}
//Metronome default volume
cJSON* metronomeVol=cJSON_GetObjectItem(preferencesJson,"metronomeDefaultVolume");
if(metronomeVol)
{
if(metronomeVol) {
float vol=metronomeVol->valueint/100.0f;
EventMetronomeVolume e(vol);
writeToDspRingbuffer(&e);
@ -142,9 +129,7 @@ int DiskReader::loadPreferences()
cJSON_Delete( preferencesJson );
delete[] sampleString;
}
else
{
} else {
// empty file / file no exists:
LUPPP_WARN("Preferences, file doesn't exist: ~/.config/openAV/luppp/luppp.prefs");
@ -159,16 +144,14 @@ int DiskReader::loadPreferences()
int DiskReader::showAudioEditor(AudioBuffer* ab)
{
while ( ab->getBeats() == 0 )
{
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 )
{
if ( ab->getBeats() == -1 ) {
return LUPPP_RETURN_ERROR;
}
}
@ -184,8 +167,7 @@ int DiskReader::loadSample( int track, int scene, string path )
std::vector<float> buf( infile.frames() * infile.channels() );
infile.read( (float*)&buf[0] , infile.frames() * infile.channels() );
if ( infile.error() )
{
if ( infile.error() ) {
LUPPP_ERROR("File %s, Error %s", path.c_str(), infile.strError() );
return LUPPP_RETURN_ERROR;
}
@ -194,15 +176,13 @@ int DiskReader::loadSample( int track, int scene, string path )
/// kick stereo channel?
int chnls = infile.channels();
if ( chnls > 1 )
{
if ( chnls > 1 ) {
// we're gonna kick all samples that are *not* channel 1
std::vector<float> 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++ )
{
for(size_t i = 0; i < tmp.size(); i++ ) {
tmp.at(i) = buf.at( i * chnls );
}
@ -211,8 +191,7 @@ int DiskReader::loadSample( int track, int scene, string path )
}
/// resample?
if ( infile.samplerate() != gui->samplerate )
{
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();
@ -230,11 +209,16 @@ int DiskReader::loadSample( int track, int scene, string path )
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;
switch( resampleQuality ) {
case 0:
q = SRC_LINEAR;
break;
case 1:
q = SRC_SINC_FASTEST;
break;
case 2:
q = SRC_SINC_BEST_QUALITY;
break;
}
@ -265,8 +249,7 @@ int DiskReader::loadSample( int track, int scene, string path )
//cout << "tmp " << tmp << " baseName " << baseName << endl;
ab->setName( baseName );
if ( infile.frames() > 0 )
{
if ( infile.frames() > 0 ) {
char* basePath = strdup( path.c_str() );
stringstream base;
base << dirname( basePath ) << "/audio.cfg";
@ -279,8 +262,7 @@ int DiskReader::loadSample( int track, int scene, string path )
#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 )
{
if ( file_length > 0 ) {
sampleFile.seekg(0, std::ios_base::beg);
sampleFile.clear();
char *sampleString = new char[file_length];
@ -296,36 +278,29 @@ int DiskReader::loadSample( int track, int scene, string path )
}
cJSON* sample = cJSON_GetObjectItem( audioJson, baseName );
if ( sample )
{
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 )
{
if ( beats ) {
loadableBuffer = true;
ab->setBeats( beats->valuedouble );
}
if ( name )
{
if ( name ) {
ab->setName( name->valuestring );
}
}
// if we don't find the beats from audio.cfg, show dialog
if ( loadableBuffer == false )
{
if ( loadableBuffer == false ) {
LUPPP_NOTE("Warning: audio.cfg has no entry for beats.");
int ret = showAudioEditor( ab );
if ( ret == LUPPP_RETURN_OK )
{
if ( ret == LUPPP_RETURN_OK ) {
// flag that we can load this sample OK
loadableBuffer = true;
}
else
{
} else {
delete ab;
}
}
@ -333,20 +308,15 @@ int DiskReader::loadSample( int track, int scene, string path )
cJSON_Delete( audioJson );
delete[] sampleString;
free ( tmp );
}
else
{
} 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 )
{
if ( error == LUPPP_RETURN_ERROR ) {
LUPPP_WARN("cancel clicked, deleting audiobuffer" );
delete ab;
}
else
{
} else {
std::string name = path;
int i = name.find_last_of('/') + 1;
std::string sub = name.substr( i );
@ -358,8 +328,7 @@ int DiskReader::loadSample( int track, int scene, string path )
}
}
if ( loadableBuffer )
{
if ( loadableBuffer ) {
std::string n = ab->getName();
// write audioBuffer to DSP
@ -372,9 +341,7 @@ int DiskReader::loadSample( int track, int scene, string path )
char* tmp = strdup( path.c_str() );
lastLoadedSamplePath = dirname( tmp );
free(tmp);
}
else
{
} else {
LUPPP_NOTE("AudioBuffer not loaded, missing beats info and dialog was Canceled" );
}
}
@ -405,8 +372,7 @@ int DiskReader::readSession( std::string path )
// 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 )
{
if ( file_length < 0 ) {
// empty file / file no exists:
LUPPP_ERROR("no session file exists!");
return LUPPP_RETURN_ERROR;
@ -429,7 +395,7 @@ int DiskReader::readSession( std::string path )
int mr = readMaster();
if( tr == mr ){};
if( tr == mr ) {};
// cleanup
cJSON_Delete( sessionJson );
@ -441,8 +407,7 @@ int DiskReader::readSession( std::string path )
int DiskReader::readMaster()
{
cJSON* master = cJSON_GetObjectItem( sessionJson, "master");
if ( master )
{
if ( master ) {
// bpm
{
cJSON* bpm = cJSON_GetObjectItem( master, "bpm");
@ -465,28 +430,32 @@ int DiskReader::readMaster()
cJSON* cjson = cJSON_GetObjectItem( master, "inputVolume");
if ( cjson ) {
EventMasterInputVol e( cjson->valuedouble );
writeToDspRingbuffer( &e ); }
writeToDspRingbuffer( &e );
}
}
// input to send
{
cJSON* cjson = cJSON_GetObjectItem( master, "inputToSndVol");
if ( cjson ) {
EventMasterInputTo e( INPUT_TO_SEND, cjson->valuedouble );
writeToDspRingbuffer( &e ); }
writeToDspRingbuffer( &e );
}
}
// input to key
{
cJSON* cjson = cJSON_GetObjectItem( master, "inputToXSide");
if ( cjson ) {
EventMasterInputTo e( INPUT_TO_XSIDE, cjson->valuedouble );
writeToDspRingbuffer( &e ); }
writeToDspRingbuffer( &e );
}
}
// input to mix
{
cJSON* cjson = cJSON_GetObjectItem( master, "inputToMixVol");
if ( cjson ) {
EventMasterInputTo e( INPUT_TO_MIX, cjson->valuedouble );
writeToDspRingbuffer( &e ); }
writeToDspRingbuffer( &e );
}
}
// input to send active
@ -494,42 +463,41 @@ int DiskReader::readMaster()
cJSON* cjson = cJSON_GetObjectItem( master, "inputToSndActive");
if ( cjson ) {
EventMasterInputTo e( INPUT_TO_SEND, cjson->valuedouble );
writeToDspRingbuffer( &e ); }
writeToDspRingbuffer( &e );
}
}
// input to key active
{
cJSON* cjson = cJSON_GetObjectItem( master, "inputToKeyActive");
if ( cjson ) {
EventMasterInputTo e( INPUT_TO_SIDE_KEY, cjson->valuedouble );
writeToDspRingbuffer( &e ); }
writeToDspRingbuffer( &e );
}
}
// input to mix active
{
cJSON* cjson = cJSON_GetObjectItem( master, "inputToMixActive");
if ( cjson ) {
EventMasterInputTo e( INPUT_TO_MIX, cjson->valuedouble );
writeToDspRingbuffer( &e ); }
writeToDspRingbuffer( &e );
}
}
// reverb
{
cJSON* reverb = cJSON_GetObjectItem( master, "reverb");
if ( 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 )
{
if ( active && size && wet && damping ) {
EventFxReverb e( active->valuedouble, size->valuedouble,
wet->valuedouble, damping->valuedouble );
writeToDspRingbuffer( &e );
}
}
else
{
} else {
#ifdef DEBUG_STATE
cout << "Session has no reverb element" << endl;
#endif
@ -540,13 +508,11 @@ int DiskReader::readMaster()
// sceneNames
{
cJSON* names = cJSON_GetObjectItem( master, "sceneNames");
if ( names )
{
if ( names ) {
GMasterTrack* master = gui->getMasterTrack();
Avtk::ClipSelector* clipSelector = master->getClipSelector();
int nscenes = cJSON_GetArraySize( names );
for(int s = 0; s < nscenes; s++ )
{
for(int s = 0; s < nscenes; s++ ) {
cJSON* name = cJSON_GetArrayItem( names, s );
clipSelector->clipName( s, name->valuestring );
}
@ -554,9 +520,7 @@ int DiskReader::readMaster()
}
}
}
else
{
} else {
LUPPP_ERROR("%s", "Error getting master from JSON" );
return LUPPP_RETURN_ERROR;
}
@ -568,17 +532,14 @@ int DiskReader::readMaster()
int DiskReader::readScenes(int t, cJSON* track)
{
cJSON* clips = cJSON_GetObjectItem( track, "clips");
if ( clips )
{
if ( clips ) {
int nClips = cJSON_GetArraySize( clips );
for(int s = 0; s < nClips; s++ )
{
for(int s = 0; s < nClips; s++ ) {
// get metadata for Clip
cJSON* clip = cJSON_GetArrayItem( clips, s );
if ( strcmp(clip->valuestring, "") != 0 )
{
if ( strcmp(clip->valuestring, "") != 0 ) {
stringstream sampleFilePath;
sampleFilePath << sessionPath << "/audio/" << clip->valuestring;
#ifdef DEBUG_STATE
@ -601,42 +562,31 @@ int DiskReader::readScenes(int t, cJSON* track)
int DiskReader::readTracks()
{
cJSON* tracks = cJSON_GetObjectItem( sessionJson, "tracks");
if ( tracks )
{
if ( tracks ) {
int nTracks = cJSON_GetArraySize( tracks );
for(int t = 0; t < nTracks; t++ )
{
for(int t = 0; t < nTracks; t++ ) {
cJSON* track = cJSON_GetArrayItem( tracks, t );
if( !track )
{
if( !track ) {
LUPPP_WARN("Track %i has no name track saved.", t);
}
else
{
} else {
readScenes( t, track );
// name
{
cJSON* name = cJSON_GetObjectItem( track, "name");
if( !name )
{
if( !name ) {
LUPPP_WARN("Track %i has no name data saved.", t);
}
else
{
} else {
gui->getTrack(t)->bg.setLabel( name->valuestring );
}
}
// fader
{
cJSON* fader = cJSON_GetObjectItem( track, "fader");
if( !fader )
{
if( !fader ) {
LUPPP_WARN("Track %i has no fader data saved.", t);
}
else
{
} else {
EventTrackVol e( t, fader->valuedouble );
writeToDspRingbuffer( &e );
}
@ -649,12 +599,9 @@ int DiskReader::readTracks()
cJSON* xside = cJSON_GetObjectItem( track, "xsideAmount");
cJSON* keyActive = cJSON_GetObjectItem( track, "keyActive");
if( !send || !sendActive || !xside || !keyActive )
{
if( !send || !sendActive || !xside || !keyActive ) {
LUPPP_WARN("Track %i has no send data saved.", t);
}
else
{
} else {
EventTrackSendActive e1( t, SEND_POSTFADER, sendActive->valueint );
EventTrackSendActive e2( t, SEND_KEY , keyActive ->valueint );
@ -669,22 +616,18 @@ int DiskReader::readTracks()
cJSON* jacksend = cJSON_GetObjectItem( track, "jacksendAmount");
cJSON* jacksendActive = cJSON_GetObjectItem( track, "jacksendActive");
if(jacksend)
{
if(jacksend) {
EventTrackJackSend ev(t,jacksend->valuedouble);
writeToDspRingbuffer(&ev);
}
if(jacksendActive)
{
if(jacksendActive) {
EventTrackJackSendActivate ev(t,jacksendActive->valueint);
writeToDspRingbuffer(&ev);
}
}
}// if track
} // nTracks loop
}
else
{
} else {
LUPPP_ERROR("%s", "Error getting clip" );
return LUPPP_RETURN_ERROR;
}

View file

@ -39,7 +39,7 @@ class AudioBuffer;
**/
class DiskReader
{
public:
public:
DiskReader();
/// loads default settings for Luppp: controller instances etc
@ -56,7 +56,7 @@ class DiskReader
int runTests();
#endif
private:
private:
cJSON* sessionJson;
std::string sessionName;

View file

@ -59,48 +59,33 @@ DiskWriter::DiskWriter()
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 )
{
if ( errno == EEXIST ) {
//LUPPP_NOTE("dotConfigDir exists");
}
else if ( dotConfigDir )
{
} else if ( dotConfigDir ) {
LUPPP_WARN("Error creating dotConfigDir: %s", strerror(errno));
}
else
{
} 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 )
{
if ( errno == EEXIST ) {
//LUPPP_NOTE("dotConfigLupppDir exists");
}
else if ( dotConfigLupppDir )
{
} else if ( dotConfigLupppDir ) {
LUPPP_WARN("Error creating dotConfigLupppDir: %s", strerror(errno));
}
else
{
} 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 )
{
if ( errno == EEXIST ) {
//LUPPP_NOTE("dotConfigCtlrDir exists");
}
else if ( dotConfigCtlrDir )
{
} else if ( dotConfigCtlrDir ) {
LUPPP_WARN("Error creating dotConfigCtlrDir: %s", strerror(errno));
}
else
{
} else {
LUPPP_NOTE("Creating .config/openAV/luppp directory");
}
};
@ -123,8 +108,7 @@ void DiskWriter::initialize(std::string path, std::string name )
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 )
{
if ( sessionDirError ) {
// handle by using different filename?
LUPPP_WARN("Error creating session directory. Does the path: %s exist?",path.c_str());
}
@ -135,8 +119,7 @@ void DiskWriter::initialize(std::string path, std::string name )
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 )
{
if ( audioDirError ) {
LUPPP_WARN("Error creating sample directory");
}
@ -160,12 +143,9 @@ void DiskWriter::writeControllerInfo( CONTROLLER_INFO c, std::string s )
int DiskWriter::writeControllerFile( Controller* c )
{
if ( c )
{
if ( c ) {
LUPPP_NOTE("DiskWriter Controller* id: %i", c->getID() );
}
else
{
} else {
LUPPP_ERROR("DiskWriter Controller* passed NULL" );
return LUPPP_RETURN_ERROR;
}
@ -173,8 +153,7 @@ int DiskWriter::writeControllerFile( Controller* c )
// check if controller of ID is actually a GenericMIDI controller
GenericMIDI* g = dynamic_cast<GenericMIDI*>( c );
if ( g )
{
if ( g ) {
LUPPP_NOTE("Creating JSON for .ctlr file...");
cJSON* controllerJson = cJSON_CreateObject();
@ -191,8 +170,7 @@ int DiskWriter::writeControllerFile( Controller* c )
cJSON* inputBindings = cJSON_CreateArray();
cJSON_AddItemToObject(controllerJson, "inputBindings", inputBindings );
for(unsigned int i = 0; i < b.size(); i++ )
{
for(unsigned int i = 0; i < b.size(); i++ ) {
// create binding
cJSON* binding = cJSON_CreateObject();
cJSON_AddItemToArray( inputBindings, binding );
@ -200,8 +178,7 @@ int DiskWriter::writeControllerFile( Controller* c )
// add metadata to binding
const char* actionName = Event::getPrettyName( b.at(i)->action );
if ( actionName )
{
if ( actionName ) {
cJSON_AddItemToObject( binding, "action", cJSON_CreateString( actionName ) );
cJSON_AddNumberToObject( binding, "status", b.at(i)->status );
@ -218,9 +195,7 @@ int DiskWriter::writeControllerFile( Controller* c )
cJSON_AddNumberToObject( binding, "active", b.at(i)->active );
LUPPP_NOTE("Creating Binding: action %i == %s!", b.at(i)->action, actionName );
}
else
{
} else {
LUPPP_WARN("Binding action %i has no prettyName!", b.at(i)->action );
}
}
@ -257,35 +232,26 @@ int DiskWriter::writeControllerFile( Controller* c )
controllerCfgPath << getenv("HOME") << "/.config/openAV/luppp/controllers/" << g->getName() << ".ctlr";
ifstream infile( controllerCfgPath.str().c_str() );
if ( infile.good() )
{
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 )
{
if ( action == 0 ) {
// return OK, as user has chosen to cancel writing the file
return LUPPP_RETURN_OK;
}
else if ( action == 1 )
{
} else if ( action == 1 ) {
// rename here
const char* name = fl_input("New name for .ctlr file:");
if ( name )
{
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
{
} else {
LUPPP_NOTE("No name entered for .ctlr file, canceling!");
return LUPPP_RETURN_ERROR;
}
}
else
{
} else {
// just overwrite the file, no action
}
@ -298,9 +264,7 @@ int DiskWriter::writeControllerFile( Controller* c )
controllerCfgFile.open ( controllerCfgPath.str().c_str() );
controllerCfgFile << cJSON_Print( controllerJson );
controllerCfgFile.close();
}
else
{
} else {
LUPPP_WARN("Invalid Controller pointer: cannot write %s as is not a GenericMIDI controller!", c->getName().c_str() );
return LUPPP_RETURN_ERROR;
}
@ -315,9 +279,7 @@ int DiskWriter::writeAudioBuffer(int track, int scene, AudioBuffer* ab,
if ( gui_path && strlen(gui_path) ) {
printf("saving single buffer to %s\n", gui_path);
path << gui_path;
}
else if ( foldersCreated )
{
} else if ( foldersCreated ) {
stringstream filename;
filename << "t_" << track << "_s_" << scene << ".wav";
@ -337,9 +299,7 @@ int DiskWriter::writeAudioBuffer(int track, int scene, AudioBuffer* ab,
// or alternatively t_<track>_s_<scene>.wav
path << audioDir << "/" << filename.str();
}
else
{
} else {
LUPPP_WARN("%s", "Session folders not created yet, while trying to write audioBuffers.");
return LUPPP_RETURN_ERROR;
}
@ -351,8 +311,7 @@ int DiskWriter::writeAudioBuffer(int track, int scene, AudioBuffer* ab,
// calculate the length that needs saving using getBeats() * framesPerBeat
if ( ab->getAudioFrames() > 0 )
outfile.write( &ab->getData()[0], ab->getAudioFrames() );
else
{
else {
LUPPP_WARN("%s","Sample has zero samples");
}
@ -385,8 +344,7 @@ void DiskWriter::writeMaster()
Avtk::ClipSelector* clipSelector = master->getClipSelector();
cJSON* sceneNames = cJSON_CreateArray();
cJSON_AddItemToObject( masterTrack, "sceneNames", sceneNames );
for(int i = 0; i < NSCENES; i++)
{
for(int i = 0; i < NSCENES; i++) {
cJSON* sceneName = cJSON_CreateString( clipSelector->clipName(i).c_str() );
cJSON_AddItemToArray( sceneNames, sceneName );
}
@ -395,8 +353,7 @@ void DiskWriter::writeMaster()
int DiskWriter::writeSession()
{
if ( !foldersCreated )
{
if ( !foldersCreated ) {
LUPPP_WARN("%s", "Session folders not created yet, while trying to write session.");
return LUPPP_RETURN_ERROR;
}
@ -417,8 +374,7 @@ int DiskWriter::writeSession()
cJSON_AddItemToObject(sessionJson, "tracks", trackArray );
// write tracks into JSON tracks array
for(int t = 0; t < NTRACKS; t++)
{
for(int t = 0; t < NTRACKS; t++) {
cJSON* track = cJSON_CreateObject();
cJSON_AddItemToArray( trackArray, track );
@ -444,18 +400,15 @@ int DiskWriter::writeSession()
for(int s = 0; s < NSCENES; s++)
{
for(int s = 0; s < NSCENES; s++) {
// add empty string to array
cJSON* clip = cJSON_CreateString( "" );
cJSON_AddItemToArray( clips, clip );
// replace blank string if clip exists
for(unsigned int i = 0; i < clipData.size(); i++)
{
for(unsigned int i = 0; i < clipData.size(); i++) {
if ( clipData.at(i).track == t &&
clipData.at(i).scene == s )
{
clipData.at(i).scene == s ) {
cJSON* newClip = cJSON_CreateString( clipData.at(i).name.c_str() );
cJSON_ReplaceItemInArray( clips, s, newClip );
}

View file

@ -27,8 +27,7 @@
class AudioBuffer;
class Controller;
enum CONTROLLER_INFO
{
enum CONTROLLER_INFO {
CONTROLLER_NAME,
CONTROLLER_AUTHOR,
CONTROLLER_LINK,
@ -38,7 +37,7 @@ enum CONTROLLER_INFO
/// To hold data about loaded clips until we write the JSON out
class ClipData
{
public:
public:
ClipData(int tr, int sc, std::string na) :
track(tr), scene(sc), name(na) {}
int track;
@ -53,7 +52,7 @@ class ClipData
**/
class DiskWriter
{
public:
public:
DiskWriter();
/// sets up session write path etc
@ -82,7 +81,7 @@ class DiskWriter
int runTests();
#endif
private:
private:
cJSON* sessionJson;
cJSON* audioJson;

View file

@ -26,7 +26,7 @@
class DBMeter
{
public:
public:
DBMeter(int rate)
{
fSamplingFreq = rate;
@ -41,8 +41,14 @@ class DBMeter
fvbargraph1 = -96.f;
}
int getNumInputs() { return 2;}
int getNumOutputs(){ return 2;}
int getNumInputs()
{
return 2;
}
int getNumOutputs()
{
return 2;
}
// call these to get the current dB values
float getLeftDB()
@ -61,8 +67,7 @@ class DBMeter
void process(int count, float* inputL, float* inputR )
{
for (int i = 0; (i < count); i = (i + 1))
{
for (int i = 0; (i < count); i = (i + 1)) {
fRec0[0] = max((fRec0[1] - fConst0), min(10.f, (20.f * log10f(max(1.58489e-05f, fabsf(*inputL))))));
if ( fvbargraph0 < fRec0[0] )
fvbargraph0 = fRec0[0];
@ -76,7 +81,7 @@ class DBMeter
}
}
private:
private:
float fRec0[2];
float fRec1[2];
int fSamplingFreq;

View file

@ -24,22 +24,43 @@
#include <cmath>
#include <cstdlib>
template <int N> inline float faustpower(float x) { return powf(x,N); }
template <int N> inline double faustpower(double x) { return pow(x,N); }
template <int N> inline int faustpower(int x) { return faustpower<N/2>(x) * faustpower<N-N/2>(x); }
template <> inline int faustpower<0>(int x) { return 1; }
template <> inline int faustpower<1>(int x) { return x; }
template <int N> inline float faustpower(float x)
{
return powf(x,N);
}
template <int N> inline double faustpower(double x)
{
return pow(x,N);
}
template <int N> inline int faustpower(int x)
{
return faustpower<N/2>(x) * faustpower<N-N/2>(x);
}
template <> inline int faustpower<0>(int x)
{
return 1;
}
template <> inline int faustpower<1>(int x)
{
return x;
}
class Reverb // : Effect
{
public:
public:
Reverb(int sr)
{
init( sr );
}
int getNumInputs() { return 2; }
int getNumOutputs(){ return 2; }
int getNumInputs()
{
return 2;
}
int getNumOutputs()
{
return 2;
}
void damping(float d)
{
@ -228,14 +249,22 @@ class Reverb // : Effect
output1[i] = (input1[i] * (1-_dryWet)) + (reverb1 * _dryWet );
// post processing
fRec7[2] = fRec7[1]; fRec7[1] = fRec7[0];
fRec6[2] = fRec6[1]; fRec6[1] = fRec6[0];
fRec5[2] = fRec5[1]; fRec5[1] = fRec5[0];
fRec4[2] = fRec4[1]; fRec4[1] = fRec4[0];
fRec3[2] = fRec3[1]; fRec3[1] = fRec3[0];
fRec2[2] = fRec2[1]; fRec2[1] = fRec2[0];
fRec1[2] = fRec1[1]; fRec1[1] = fRec1[0];
fRec0[2] = fRec0[1]; fRec0[1] = fRec0[0];
fRec7[2] = fRec7[1];
fRec7[1] = fRec7[0];
fRec6[2] = fRec6[1];
fRec6[1] = fRec6[0];
fRec5[2] = fRec5[1];
fRec5[1] = fRec5[0];
fRec4[2] = fRec4[1];
fRec4[1] = fRec4[0];
fRec3[2] = fRec3[1];
fRec3[1] = fRec3[0];
fRec2[2] = fRec2[1];
fRec2[1] = fRec2[0];
fRec1[2] = fRec1[1];
fRec1[1] = fRec1[0];
fRec0[2] = fRec0[1];
fRec0[1] = fRec0[0];
fRec36[1] = fRec36[0];
fRec38[1] = fRec38[0];
fRec39[1] = fRec39[0];
@ -264,7 +293,7 @@ class Reverb // : Effect
}
}
private:
private:
float _dryWet;
float _rt60;
int iConst0;

View file

@ -58,8 +58,7 @@ void SidechainGain::process(unsigned int n_samples, float** inputs, float** outp
/// analyse sidechain input for peak
float sum = 0.f;
for( unsigned int i = 0; i < n_samples; i++ )
{
for( unsigned int i = 0; i < n_samples; i++ ) {
if ( *side > 0.000001 )
sum += *side++;
else
@ -69,17 +68,12 @@ void SidechainGain::process(unsigned int n_samples, float** inputs, float** outp
currentTarget = 0.f;
/// check for peak level (offset to avoid "always on" peak)
if ( sum / n_samples > threshold + 0.05 )
{
if ( sum / n_samples > threshold + 0.05 ) {
peakFrameCounter = peakCountDuration * releaseTime;
currentTarget = 1.f - reduction;
}
else if ( peakFrameCounter < 0 )
{
} else if ( peakFrameCounter < 0 ) {
currentTarget = 1.f;
}
else
{
} else {
currentTarget = 1.f - reduction;
}
@ -88,8 +82,7 @@ void SidechainGain::process(unsigned int n_samples, float** inputs, float** outp
peakFrameCounter -= n_samples;
for( unsigned int i = 0; i < n_samples; i++ )
{
for( unsigned int i = 0; i < n_samples; i++ ) {
/// smoothing algo is a lowpass, to de-zip the fades
/// x^^4 approximates linear volume increase for human ears
g1 += w * ( pow ( currentTarget, 4.f ) - g1 - a * g2 - 1e-20f);

View file

@ -25,17 +25,26 @@
class SidechainGain
{
public:
public:
SidechainGain(int rate);
~SidechainGain(){}
~SidechainGain() {}
void threshold(float t){controlThreshold = t;}
void reduction(float r){controlReduction = r;}
void time (float t){controlReleaseTime = t;}
void threshold(float t)
{
controlThreshold = t;
}
void reduction(float r)
{
controlReduction = r;
}
void time (float t)
{
controlReleaseTime = t;
}
void process(unsigned int n_samples, float** inputs, float** outputs);
private:
private:
/// audio buffers
float* audioInputL;
float* audioInputR;

View file

@ -42,11 +42,9 @@ const char* EventGridLaunchScene::prettyName = "grid:launch_scene";
EVENT_TYPE Event::getTypeFromName(const char* name)
{
for(int i = 0; i < EVENT_TYPE_FINAL; i++)
{
for(int i = 0; i < EVENT_TYPE_FINAL; i++) {
const char* tmp = getPrettyName(i);
if ( tmp )
{
if ( tmp ) {
if ( strcmp( name, tmp ) == 0 ) {
return (EVENT_TYPE)i;
}
@ -58,30 +56,64 @@ EVENT_TYPE Event::getTypeFromName(const char* name)
const char* Event::getPrettyName( int type )
{
switch ( type )
{
case MASTER_VOL:{ return EventMasterVol::prettyName; }
case MASTER_RETURN:{ return EventMasterReturn::prettyName; }
case MASTER_INPUT_VOL:{ return EventMasterInputVol::prettyName; }
case MASTER_INPUT_TO:{ return EventMasterInputTo::prettyName; }
case MASTER_INPUT_TO_ACTIVE:{ return EventMasterInputToActive::prettyName; }
switch ( type ) {
case MASTER_VOL: {
return EventMasterVol::prettyName;
}
case MASTER_RETURN: {
return EventMasterReturn::prettyName;
}
case MASTER_INPUT_VOL: {
return EventMasterInputVol::prettyName;
}
case MASTER_INPUT_TO: {
return EventMasterInputTo::prettyName;
}
case MASTER_INPUT_TO_ACTIVE: {
return EventMasterInputToActive::prettyName;
}
case TRACK_VOLUME:{ return EventTrackVol::prettyName; }
case TRACK_SEND:{ return EventTrackSend::prettyName; }
case TRACK_SEND_ACTIVE:{ return EventTrackSendActive::prettyName; }
case TRACK_JACKSEND:{ return EventTrackJackSend::prettyName; }
case TRACK_JACKSEND_ACTIVATE:{ return EventTrackJackSendActivate::prettyName; }
case TRACK_RECORD_ARM:{ return EventTrackRecordArm::prettyName; }
case TRACK_VOLUME: {
return EventTrackVol::prettyName;
}
case TRACK_SEND: {
return EventTrackSend::prettyName;
}
case TRACK_SEND_ACTIVE: {
return EventTrackSendActive::prettyName;
}
case TRACK_JACKSEND: {
return EventTrackJackSend::prettyName;
}
case TRACK_JACKSEND_ACTIVATE: {
return EventTrackJackSendActivate::prettyName;
}
case TRACK_RECORD_ARM: {
return EventTrackRecordArm::prettyName;
}
case TIME_BPM:{ return EventTimeBPM::prettyName; }
case TIME_TEMPO_TAP:{ return EventTimeTempoTap::prettyName; }
case TIME_BPM: {
return EventTimeBPM::prettyName;
}
case TIME_TEMPO_TAP: {
return EventTimeTempoTap::prettyName;
}
case GRID_EVENT:{ return EventGridEvent::prettyName; }
case GRID_LAUNCH_SCENE:{ return EventGridLaunchScene::prettyName; }
case GRID_EVENT: {
return EventGridEvent::prettyName;
}
case GRID_LAUNCH_SCENE: {
return EventGridLaunchScene::prettyName;
}
case METRONOME_ACTIVE:{ return EventMetronomeActive::prettyName; }
case METRONOME_VOLUME:{ return EventMetronomeVolume::prettyName; }
case METRONOME_ACTIVE: {
return EventMetronomeActive::prettyName;
}
case METRONOME_VOLUME: {
return EventMetronomeVolume::prettyName;
}
default: return 0;
default:
return 0;
}
}

File diff suppressed because it is too large Load diff

View file

@ -46,32 +46,27 @@ void handleDspEvents()
{
uint availableRead = jack_ringbuffer_read_space( rbToDsp );
while ( availableRead >= sizeof(EventBase) )
{
while ( availableRead >= sizeof(EventBase) ) {
jack_ringbuffer_peek( rbToDsp, (char*)processDspMem, sizeof(EventBase) );
EventBase* e = (EventBase*)processDspMem;
// recheck the size against the actual event size
if ( availableRead >= e->size() )
{
if ( availableRead >= e->size() ) {
// MIDI binding creation: sample the Event.
if( jack->bindingEventRecordEnable )
{
if( jack->bindingEventRecordEnable ) {
//printf("event %i\n", e->type() );
jack->bindingEventType = e->type();
const char* target = e->name();
if ( target )
{
if ( target ) {
EventControllerBindingTarget event( target );
writeToGuiRingbuffer( &event );
}
}
switch ( e->type() )
{
switch ( e->type() ) {
case Event::QUIT: {
if ( availableRead >= sizeof(EventQuit) ) {
EventQuit ev;
@ -80,7 +75,9 @@ void handleDspEvents()
// we want to *quit* *fast*: remaining events don't matter!
return;
} break; }
}
break;
}
// ======== TRANSPORT ==
@ -89,7 +86,9 @@ void handleDspEvents()
EventTransportState ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventTransportState) );
jack->getTimeManager()->setTransportState( ev.ts );
} break; }
}
break;
}
// ========= SAVE =====
case Event::STATE_SAVE: {
@ -97,13 +96,17 @@ void handleDspEvents()
EventStateSave ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventStateSave) );
jack->getState()->save();
} break; }
}
break;
}
case Event::STATE_RESET: {
if ( availableRead >= sizeof(EventStateReset) ) {
EventStateReset ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventStateReset) );
jack->getState()->reset();
} break; }
}
break;
}
case Event::STATE_SAVE_BUFFER: {
if ( availableRead >= sizeof(EventStateReset) ) {
EventStateSaveBuffer ev;
@ -117,7 +120,9 @@ void handleDspEvents()
e.ab = lc->getAudioBuffer();
e.no_dealloc = 1;
writeToGuiRingbuffer( &e );
} break; }
}
break;
}
// ========= MASTER ===
case Event::MASTER_VOL: {
@ -125,7 +130,9 @@ void handleDspEvents()
EventMasterVol ev(0);
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventMasterVol) );
jack->masterVolume( ev.vol );
} break; }
}
break;
}
case Event::MASTER_RETURN: {
if ( availableRead >= sizeof(EventMasterReturn) ) {
EventMasterReturn ev;
@ -133,20 +140,26 @@ void handleDspEvents()
if ( ev.ret == RETURN_MAIN ) {
jack->returnVolume( ev.vol );
}
} break; }
}
break;
}
case Event::MASTER_INPUT_VOL: {
if ( availableRead >= sizeof(EventMasterVol) ) {
EventMasterVol ev(0);
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventMasterVol) );
jack->getLogic()->masterInputVol( ev.vol );
} break; }
}
break;
}
case Event::MASTER_INPUT_TO: {
if ( availableRead >= sizeof(EventMasterInputTo) ) {
EventMasterInputTo ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventMasterInputTo) );
jack->bindingSend = ev.place;
jack->getLogic()->masterInputTo( ev.place, ev.value );
} break; }
}
break;
}
case Event::MASTER_INPUT_TO_ACTIVE: {
if ( availableRead >= sizeof(EventMasterInputToActive) ) {
EventMasterInputToActive ev;
@ -154,7 +167,9 @@ void handleDspEvents()
jack->bindingSend = ev.place;
jack->bindingActive = ev.active;
jack->getLogic()->masterInputToActive( ev.place, ev.active );
} break; }
}
break;
}
// ========= GRID =====
case Event::GRID_STATE: {
@ -162,13 +177,14 @@ void handleDspEvents()
EventGridState ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventGridState) );
// clear clips in Controllers
if ( ev.state == GridLogic::STATE_EMPTY )
{
if ( ev.state == GridLogic::STATE_EMPTY ) {
jack->getLooper( ev.track )->getClip( ev.scene )->init();
jack->getControllerUpdater()->setTrackSceneProgress(ev.track, ev.scene, 0 );
jack->getControllerUpdater()->setSceneState( ev.track, ev.scene, GridLogic::STATE_EMPTY );
}
} break; }
}
break;
}
case Event::GRID_EVENT: {
if ( availableRead >= sizeof(EventGridEvent) ) {
@ -180,31 +196,37 @@ void handleDspEvents()
jack->getGridLogic()->pressed( ev.track, ev.scene );
else
jack->getGridLogic()->released( ev.track, ev.scene );
} break; }
}
break;
}
case Event::GRID_LAUNCH_SCENE: {
EventGridLaunchScene ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventGridLaunchScene) );
jack->getGridLogic()->launchScene( ev.scene );
jack->bindingScene = ev.scene;
break; }
break;
}
case Event::GRID_SELECT_CLIP_ENABLE: {
EventGridSelectClipEnable ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventGridSelectClipEnable) );
jack->getGridLogic()->setSelectTrackScene( ev.enable );
break; }
break;
}
case Event::GRID_SELECT_CLIP_EVENT: {
EventGridSelectClipEvent ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventGridSelectClipEvent) );
jack->getGridLogic()->selectedTrackSceneEvent( ev.pressed );
break; }
break;
}
case Event::GRID_SELECT_NEW_CHOSEN: {
EventGridSelectNewChosen ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventGridSelectNewChosen) );
jack->getGridLogic()->specialScene( ev.track, ev.scene );
break; }
break;
}
case Event::LOOPER_LOAD: {
@ -212,32 +234,42 @@ void handleDspEvents()
EventLooperLoad ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventLooperLoad) );
jack->getGridLogic()->load( ev.track, ev.clip, (AudioBuffer*)ev.audioBuffer );
} break; }
}
break;
}
case Event::METRONOME_ACTIVE: {
if ( availableRead >= sizeof(EventMetronomeActive) ) {
EventMetronomeActive ev(false);
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventMetronomeActive) );
jack->getLogic()->metronomeEnable(ev.active);
} break; }
}
break;
}
case Event::METRONOME_VOLUME: {
if ( availableRead >= sizeof(EventMetronomeVolume) ) {
EventMetronomeVolume ev(false);
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventMetronomeVolume) );
LUPPP_NOTE("EventDSP: MetroVol %f", ev.vol );
jack->getMetronome()->setVolume(ev.vol);
} break; }
}
break;
}
case Event::LOOPER_STATE: {
if ( availableRead >= sizeof(EventLooperState) ) {
EventLooperState ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventLooperState) );
//jack->setLooperState( ev.track, ev.scene, ev.state );
} break; }
}
break;
}
case Event::LOOPER_LOOP_LENGTH: {
if ( availableRead >= sizeof(EventLooperLoopLength) ) {
EventLooperLoopLength ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventLooperLoopLength) );
jack->getLogic()->looperClipLenght( ev.track, ev.scene, ev.beats );
} break; }
}
break;
}
case Event::LOOPER_LOOP_USE_AS_TEMPO: {
@ -245,7 +277,9 @@ void handleDspEvents()
EventLooperUseAsTempo ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventLooperUseAsTempo) );
jack->getLogic()->looperUseAsTempo( ev.track, ev.scene );
} break; }
}
break;
}
@ -254,17 +288,22 @@ void handleDspEvents()
EventTimeBPM ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventTimeBPM) );
jack->getTimeManager()->setBpm(ev.bpm);
} break; }
}
break;
}
case Event::TIME_TEMPO_TAP: {
if ( availableRead >= sizeof(EventTimeTempoTap) ) {
EventTimeTempoTap ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventTimeTempoTap) );
jack->getTimeManager()->tap();
} break; }
}
break;
}
// ======== FX ===========
case Event::FX_REVERB: break;
case Event::FX_REVERB:
break;
/*{
if ( availableRead >= sizeof(EventFxReverb) ) {
EventFxReverb ev;
@ -279,7 +318,8 @@ void handleDspEvents()
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventTrackVol) );
jack->getLogic()->trackVolume( ev.track, ev.vol );
jack->bindingTrack = ev.track;
break; }
break;
}
}
case Event::TRACK_RECORD_ARM: {
@ -289,7 +329,8 @@ void handleDspEvents()
jack->getLogic()->trackRecordArm( ev.track, ev.recordArm );
jack->bindingTrack = ev.track;
jack->bindingActive = ev.recordArm;
break; }
break;
}
}
case Event::TRACK_SEND_ACTIVE: {
@ -300,7 +341,9 @@ void handleDspEvents()
jack->bindingTrack = ev.track;
jack->bindingSend = ev.send;
jack->bindingActive = ev.active;
} break; }
}
break;
}
case Event::TRACK_JACKSEND_ACTIVATE: {
if ( availableRead >= sizeof(EventTrackJackSendActivate) ) {
@ -310,7 +353,9 @@ void handleDspEvents()
jack->bindingTrack = ev.track;
jack->bindingActive = ev.active;
} break; }
}
break;
}
case Event::TRACK_JACKSEND: {
if ( availableRead >= sizeof(EventTrackJackSend) ) {
@ -318,7 +363,9 @@ void handleDspEvents()
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventTrackJackSend) );
jack->getLogic()->trackJackSend(ev.track,ev.value);
jack->bindingTrack = ev.track;
} break; }
}
break;
}
case Event::TRACK_SEND: {
if ( availableRead >= sizeof(EventTrackSend) ) {
@ -327,7 +374,9 @@ void handleDspEvents()
jack->getLogic()->trackSend( ev.track, ev.send, ev.value );
jack->bindingTrack = ev.track;
jack->bindingSend = ev.send;
} break; }
}
break;
}
// ========= LUPPP INTERNAL =====
@ -336,21 +385,27 @@ void handleDspEvents()
EventLooperClipRequestBuffer ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventLooperClipRequestBuffer) );
jack->getLooper( ev.track )->setRequestedBuffer( ev.scene, ev.ab );
} break; }
}
break;
}
case Event::REQUEST_SAVE_BUFFER: {
if ( availableRead >= sizeof(EventRequestSaveBuffer) ) {
EventRequestSaveBuffer ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventRequestSaveBuffer) );
jack->getLooper( ev.track )->getClip(ev.scene)->recieveSaveBuffer( ev.ab );
} break; }
}
break;
}
case Event::CONTROLLER_INSTANCE: {
if ( availableRead >= sizeof(EventControllerInstance) ) {
EventControllerInstance ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventControllerInstance) );
jack->getControllerUpdater()->registerController( static_cast<Controller*>(ev.controller) );
} break; }
}
break;
}
case Event::CONTROLLER_INSTANCE_REMOVE: {
if ( availableRead >= sizeof(EventControllerInstanceRemove) ) {
@ -358,14 +413,18 @@ void handleDspEvents()
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventControllerInstanceRemove) );
jack->getControllerUpdater()->removeController( ev.ID );
} break; }
}
break;
}
case Event::CONTROLLER_BINDING_ENABLE: {
if ( availableRead >= sizeof(EventControllerBindingEnable) ) {
EventControllerBindingEnable ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventControllerBindingEnable) );
jack->bindingEventRecordEnable = ev.enable;
} break; }
}
break;
}
case Event::CONTROLLER_BINDING_REMOVE: {
@ -376,16 +435,14 @@ void handleDspEvents()
Controller* c =jack->getControllerUpdater()->getController(ev.controllerID);
// dynamic cast to check for GenericMIDI controller
GenericMIDI* g = dynamic_cast<GenericMIDI*>(c);
if ( g )
{
if ( g ) {
// kick out BindingID
g->removeBinding( ev.bindingID );
}
else
{
} else {
// GUI print notify of error removing binding
}
} break; }
} break;
}
case Event::CONTROLLER_INSTANCE_GET_TO_WRITE: {
if ( availableRead >= sizeof(EventControllerInstanceGetToWrite) ) {
@ -400,18 +457,17 @@ void handleDspEvents()
EventControllerInstanceGetToWrite tmp( ev.ID, c );
writeToGuiRingbuffer( &tmp );
} break; }
}
break;
}
default:
{
default: {
cout << "DSP: Unkown message!! Will clog ringbuffer" << endl;
// just do nothing
break;
}
}
}
else
{
} else {
// next call will get the half-written event
return;
}
@ -423,12 +479,9 @@ void handleDspEvents()
void writeToDspRingbuffer(EventBase* e)
{
if ( jack_ringbuffer_write_space(rbToDsp) >= e->size() )
{
if ( jack_ringbuffer_write_space(rbToDsp) >= e->size() ) {
jack_ringbuffer_write( rbToDsp, (const char*)e, e->size() );
}
else
{
} else {
// non-RT context, printing is OK!
cout << "->DSP ringbuffer full!" << endl;
}

View file

@ -43,26 +43,25 @@ void handleGuiEvents()
{
uint availableRead = jack_ringbuffer_read_space( rbToGui );
while ( availableRead >= sizeof(EventBase) )
{
while ( availableRead >= sizeof(EventBase) ) {
jack_ringbuffer_peek( rbToGui, (char*)processGuiMem, sizeof(EventBase) );
EventBase* e = (EventBase*)processGuiMem;
// recheck the size against the actual event size
if ( availableRead >= e->size() )
{
if ( availableRead >= e->size() ) {
//cout << "reading event type " << e->type() << endl;
switch ( e->type() )
{
switch ( e->type() ) {
case Event::QUIT: {
if ( availableRead >= sizeof(EventQuit) ) {
EventQuit ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventQuit) );
LUPPP_NOTE("%s","GUI QUIT");
gui->quit();
} break; }
}
break;
}
case Event::SAMPLERATE: {
if ( availableRead >= sizeof(EventSamplerate) ) {
@ -70,7 +69,9 @@ void handleGuiEvents()
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventSamplerate) );
gui->samplerate = ev.samplerate;
//LUPPP_NOTE("Gui Samplerate: %i", gui->samplerate);
} break; }
}
break;
}
/// master
case Event::MASTER_INPUT_TO: {
@ -78,31 +79,41 @@ void handleGuiEvents()
EventMasterInputTo ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventMasterInputTo) );
gui->getMasterTrack()->setInputTo( (int)ev.place, ev.value );
} break; }
}
break;
}
case Event::MASTER_INPUT_TO_ACTIVE: {
if ( availableRead >= sizeof(EventMasterInputToActive) ) {
EventMasterInputToActive ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventMasterInputToActive) );
gui->getMasterTrack()->setInputToActive( (int)ev.place, ev.active );
} break; }
}
break;
}
case Event::MASTER_INPUT_VOL: {
if ( availableRead >= sizeof(EventMasterInputVol) ) {
EventMasterInputVol ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventMasterInputVol) );
gui->getMasterTrack()->setInputVol( ev.vol );
} break; }
}
break;
}
case Event::MASTER_RETURN: {
if ( availableRead >= sizeof(EventMasterReturn) ) {
EventMasterReturn ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventMasterReturn) );
gui->getMasterTrack()->setReturnVol( ev.vol );
} break; }
}
break;
}
case Event::MASTER_VOL: {
if ( availableRead >= sizeof(EventMasterVol) ) {
EventMasterVol ev(0);
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventMasterVol) );
gui->getMasterTrack()->getVolume()->fader( ev.vol );
} break; }
}
break;
}
case Event::METRONOME_ACTIVE: {
@ -110,20 +121,25 @@ void handleGuiEvents()
EventMetronomeActive ev(false);
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventMetronomeActive) );
gui->getMasterTrack()->metronomeEnable(ev.active);
} break; }
}
break;
}
case Event::LOOPER_STATE: {
if ( availableRead >= sizeof(EventLooperState) ) {
EventLooperState ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventLooperState) );
//gui->getTrack(ev.track)->getClipSelector()->setState(ev.scene, ev.state);
//jack->setLooperState( ev.track, ev.state );
} break; }
}
break;
}
case Event::LOOPER_LOOP_LENGTH: {
if ( availableRead >= sizeof(EventLooperLoopLength) ) {
//EventLooperLoopLength ev;
//jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventLooperLoopLength) );
//jack->setLooperLoopLength( ev.track, ev.scale );
} break; }
} break;
}
case Event::LOOPER_PROGRESS: {
if ( availableRead >= sizeof(EventLooperProgress) ) {
EventLooperProgress ev;
@ -134,7 +150,9 @@ void handleGuiEvents()
// ev.progress > 0.9 )
gui->getTrack(ev.track)->radial.value(ev.progress);
} break; }
}
break;
}
// FIXME: reset signal level to 0
@ -147,14 +165,19 @@ void handleGuiEvents()
} else if ( ev.track == -1 ) {
gui->getMasterTrack()->getVolume()->amplitude( ev.left, ev.right );
} else {
gui->getTrack(ev.track)->getVolume()->amplitude( ev.left, ev.right ); }
} break; }
gui->getTrack(ev.track)->getVolume()->amplitude( ev.left, ev.right );
}
}
break;
}
case Event::TRACK_VOLUME: {
if ( availableRead >= sizeof(EventTrackVol) ) {
EventTrackVol ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventTrackVol) );
gui->getTrack(ev.track)->getVolume()->fader( ev.vol );
} break; }
}
break;
}
case Event::TRACK_RECORD_ARM: {
@ -162,7 +185,8 @@ void handleGuiEvents()
EventTrackRecordArm ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventTrackRecordArm) );
gui->getTrack(ev.track)->setRecordActive( ev.recordArm );
break; }
break;
}
}
case Event::TIME_BPM: {
@ -170,7 +194,9 @@ void handleGuiEvents()
EventTimeBPM ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventTimeBPM) );
gui->getMasterTrack()->setBpm( ev.bpm );
} break; }
}
break;
}
case Event::STATE_SAVE_BUFFER: {
@ -185,14 +211,15 @@ void handleGuiEvents()
if(!ev.no_dealloc) {
gui->getDiskWriter()->writeAudioBuffer( ev.track, ev.scene, ev.ab );
delete ev.ab;
} else
{
} else {
gui->getDiskWriter()->writeAudioBuffer(ev.track, ev.scene, ev.ab,
gui->saveBufferPath.c_str());
gui->saveBufferPath = "";
}
} break; }
}
break;
}
case Event::STATE_SAVE_FINISH: {
if ( availableRead >= sizeof(EventStateSaveFinish) ) {
@ -202,7 +229,9 @@ void handleGuiEvents()
cout << "EventSaveFinish!" << endl;
#endif
gui->getDiskWriter()->writeSession();
} break; }
}
break;
}
case Event::GRID_STATE: {
@ -214,7 +243,9 @@ void handleGuiEvents()
gui->getTrack(ev.track)->getRadialStatus()->recording( true );
else
gui->getTrack(ev.track)->getRadialStatus()->recording( false );
} break; }
}
break;
}
case Event::GRID_LAUNCH_SCENE: {
if ( availableRead >= sizeof(EventGridLaunchScene) ) {
EventGridLaunchScene ev;
@ -222,20 +253,23 @@ void handleGuiEvents()
for(int i = 0; i < NSCENES; i++)
gui->getMasterTrack()->getClipSelector()->setState( i, GridLogic::STATE_EMPTY );
gui->getMasterTrack()->getClipSelector()->setState( ev.scene, GridLogic::STATE_PLAYING );
} break; }
}
break;
}
case Event::GRID_SELECT_NEW_CHOSEN: {
if ( availableRead >= sizeof(EventGridSelectNewChosen) ) {
EventGridSelectNewChosen ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventGridSelectNewChosen) );
//LUPPP_NOTE("New special, %i, %i", ev.track, ev.scene);
for(int i = 0; i < NTRACKS; i++)
{
for(int i = 0; i < NTRACKS; i++) {
gui->getTrack(i)->getClipSelector()->setSpecial( i == ev.track ? ev.scene : -1 );
}
gui->specialTrack = ev.track;
gui->specialScene = ev.scene;
} break; }
}
break;
}
case Event::TRACK_SEND: {
@ -243,48 +277,51 @@ void handleGuiEvents()
EventTrackSend ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventTrackSend) );
if ( ev.send == SEND_POSTFADER )
if ( ev.track < NTRACKS )
{
if ( ev.track < NTRACKS ) {
gui->getTrack(ev.track)->setSend(ev.value );
}
if ( ev.send == SEND_XSIDE )
if ( ev.track < NTRACKS )
{
if ( ev.track < NTRACKS ) {
gui->getTrack(ev.track)->setXSide( ev.value );
}
} break; }
}
break;
}
case Event::TRACK_JACKSEND: {
if ( availableRead >= sizeof(EventTrackJackSend) ) {
EventTrackJackSend ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventTrackJackSend) );
gui->getTrack(ev.track)->setJackSend(ev.value);
} break; }
}
break;
}
case Event::TRACK_JACKSEND_ACTIVATE: {
if ( availableRead >= sizeof(EventTrackJackSendActivate) ) {
EventTrackJackSendActivate ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventTrackJackSendActivate) );
gui->getTrack(ev.track)->setJackSendActivate(ev.active);
} break; }
}
break;
}
case Event::TRACK_SEND_ACTIVE: {
if ( availableRead >= sizeof(EventTrackSendActive) ) {
EventTrackSendActive ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventTrackSendActive) );
if ( ev.send == SEND_POSTFADER )
if ( ev.track < NTRACKS )
{
if ( ev.track < NTRACKS ) {
gui->getTrack(ev.track)->setSendActive(ev.active );
}
if ( ev.send == SEND_KEY )
{
if ( ev.track < NTRACKS )
{
if ( ev.send == SEND_KEY ) {
if ( ev.track < NTRACKS ) {
gui->getTrack(ev.track)->setKeyActive( ev.active );
}
}
} break; }
}
break;
}
case Event::GUI_PRINT: {
if ( availableRead >= sizeof(EventGuiPrint) ) {
@ -292,19 +329,25 @@ void handleGuiEvents()
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventGuiPrint) );
//cout << "DSP: " << ev.getMessage() << endl;
LUPPP_DSP("%s", ev.getMessage() );
} break; }
}
break;
}
case Event::TIME_BAR_BEAT: {
if ( availableRead >= sizeof(EventTimeBarBeat) ) {
EventTimeBarBeat ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventTimeBarBeat) );
gui->getMasterTrack()->setBarBeat( ev.bar, ev.beat);
} break; }
}
break;
}
case Event::TIME_TEMPO_TAP: {
if ( availableRead >= sizeof(EventTimeTempoTap) ) {
EventTimeTempoTap ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventTimeTempoTap) );
gui->getMasterTrack()->setTapTempo( ev.pressed );
} break; }
}
break;
}
case Event::LOOPER_REQUEST_BUFFER: {
@ -319,7 +362,9 @@ void handleGuiEvents()
#ifdef DEBUG_BUFFER
printf("new buffer going to track %i, scene %i\n",ev.track, ev.scene);
#endif
} break; }
}
break;
}
case Event::REQUEST_SAVE_BUFFER: {
if ( availableRead >= sizeof(EventRequestSaveBuffer) ) {
@ -331,24 +376,25 @@ void handleGuiEvents()
/// allocate a new AudioBuffer with ev.numElements, pass back to DSP
AudioBuffer* ab = new AudioBuffer(ev.bufferSize);
if ( ab )
{
if ( ab ) {
//LUPPP_NOTE("Save buffer sent with t %i, s %i, ab* %i", ev.track, ev.scene, ab );
EventRequestSaveBuffer returnEvent( ev.track, ev.scene, ab);
writeToDspRingbuffer( &returnEvent );
}
else
{
} else {
cout << "error allocating save buffer!" << endl;
}
} break; }
}
break;
}
case Event::DEALLOCATE_BUFFER: {
if ( availableRead >= sizeof(EventDeallocateBuffer) ) {
EventDeallocateBuffer ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventDeallocateBuffer) );
delete ev.ab;
} break; }
}
break;
}
case Event::CONTROLLER_BINDING_ENABLE: {
if ( availableRead >= sizeof(EventControllerBindingEnable) ) {
@ -359,14 +405,18 @@ void handleGuiEvents()
c->setBindEnable( ev.enable );
else
LUPPP_WARN("ControllerUI %i doesn't exist in the UI", ev.controllerID );
} break; }
}
break;
}
case Event::CONTROLLER_BINDING_TARGET: {
if ( availableRead >= sizeof(EventControllerBindingTarget) ) {
EventControllerBindingTarget ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventControllerBindingTarget) );
gui->getOptionsWindow()->setTarget( ev.target );
} break; }
}
break;
}
case Event::CONTROLLER_BINDING_MADE: {
if ( availableRead >= sizeof(EventControllerBindingMade) ) {
@ -377,7 +427,9 @@ void handleGuiEvents()
c->addBinding( (Binding*)ev.binding );
else
LUPPP_WARN("ControllerUI %i doesn't exist in the UI", ev.controllerID );
} break; }
}
break;
}
case Event::CONTROLLER_INSTANCE_GET_TO_WRITE: {
if ( availableRead >= sizeof(EventControllerInstanceGetToWrite) ) {
@ -385,7 +437,9 @@ void handleGuiEvents()
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventControllerInstanceGetToWrite) );
// write the contents of the GenericMIDI controller to .ctlr file
gui->getDiskWriter()->writeControllerFile( (Controller*)ev.controller );
} break; }
}
break;
}
case Event::CONTROLLER_INSTANCE: {
if ( availableRead >= sizeof(EventControllerInstance) ) {
@ -397,20 +451,19 @@ void handleGuiEvents()
// delete will call the destructor for the Controller: this should
// clean up ports etc, all from the GUI thread as appropriate
delete c;
} break; }
}
break;
}
default:
{
default: {
cout << "GUI: Unkown message!! Will clog ringbuffer" << endl;
// just do nothing
break;
}
}
}
else
{
} else {
// next call will get the half-written event
return;
}
@ -422,12 +475,9 @@ void handleGuiEvents()
void writeToGuiRingbuffer(EventBase* e)
{
if ( jack_ringbuffer_write_space(rbToGui) >= e->size() )
{
if ( jack_ringbuffer_write_space(rbToGui) >= e->size() ) {
jack_ringbuffer_write( rbToGui, (const char*)e, e->size() );
}
else
{
} else {
cout << "->GUI ringbuffer full!" << endl;
}
}

View file

@ -31,13 +31,34 @@ extern Gui* gui;
#include "avtk/avtk_button.h"
void oneCB (Fl_Widget*,void* data) { ((AudioEditor*)data)->setBeatsAndQuit( 1 ); }
void twoCB (Fl_Widget*,void* data) { ((AudioEditor*)data)->setBeatsAndQuit( 2 ); }
void fourCB (Fl_Widget*,void* data) { ((AudioEditor*)data)->setBeatsAndQuit( 4 ); }
void eightCB (Fl_Widget*,void* data) { ((AudioEditor*)data)->setBeatsAndQuit( 8 ); }
void sixteenCB (Fl_Widget*,void* data) { ((AudioEditor*)data)->setBeatsAndQuit( 16); }
void thirtyTwoCB(Fl_Widget*,void* data) { ((AudioEditor*)data)->setBeatsAndQuit( 32); }
void sixtyfourCB(Fl_Widget*,void* data) { ((AudioEditor*)data)->setBeatsAndQuit( 64); }
void oneCB (Fl_Widget*,void* data)
{
((AudioEditor*)data)->setBeatsAndQuit( 1 );
}
void twoCB (Fl_Widget*,void* data)
{
((AudioEditor*)data)->setBeatsAndQuit( 2 );
}
void fourCB (Fl_Widget*,void* data)
{
((AudioEditor*)data)->setBeatsAndQuit( 4 );
}
void eightCB (Fl_Widget*,void* data)
{
((AudioEditor*)data)->setBeatsAndQuit( 8 );
}
void sixteenCB (Fl_Widget*,void* data)
{
((AudioEditor*)data)->setBeatsAndQuit( 16);
}
void thirtyTwoCB(Fl_Widget*,void* data)
{
((AudioEditor*)data)->setBeatsAndQuit( 32);
}
void sixtyfourCB(Fl_Widget*,void* data)
{
((AudioEditor*)data)->setBeatsAndQuit( 64);
}
void cancelCB(Fl_Widget*,void* data)
{
@ -56,8 +77,7 @@ AudioEditor::AudioEditor()
"1","2","4","8","16","32","64"
};
for(int i = 0; i < 7; i++)
{
for(int i = 0; i < 7; i++) {
stringstream s;
s << i;
beatButtons[i] = new Avtk::Button(5 + i * 50, 160, 40,30, strdup(names[i]) );
@ -79,24 +99,20 @@ void AudioEditor::show( AudioBuffer* buf, bool modal )
{
ab = buf;
if ( !ab )
{
if ( !ab ) {
LUPPP_WARN("called with ab == 0");
}
else
{
} else {
std::vector<float>& tmp = ab->getData();
int size = tmp.size();
waveform->setData( &tmp[0], size );
const int beats[]={1,2,4,8,16,32,64};
const int beats[]= {1,2,4,8,16,32,64};
int iBeatOne = -1;
int iBeatTwo = -1;
// figure out BPM values from size
for( int i = 0; i < 7; i++ )
{
for( int i = 0; i < 7; i++ ) {
int beat = beats[i];
int fpb = size / beat;
@ -104,14 +120,11 @@ void AudioEditor::show( AudioBuffer* buf, bool modal )
int bpm = (gui->samplerate / fpb) * 60;
if ( bpm < 60 || bpm > 220 )
{
if ( bpm < 60 || bpm > 220 ) {
// disable option: not valid
beatButtons[i]->setGreyOut( true );
beatButtons[i]->setColor( 0.4, 0.4, 0.4 );
}
else
{
} else {
//printf("%i, fpb = %i, bpm= = %i\n", beat, fpb, bpm );
// enable option ( may be disabled previously! )
beatButtons[i]->setGreyOut( false );
@ -125,8 +138,7 @@ void AudioEditor::show( AudioBuffer* buf, bool modal )
}
// both valid: compare, and adjust color
if ( iBeatOne != -1 && iBeatTwo != -1 )
{
if ( iBeatOne != -1 && iBeatTwo != -1 ) {
int masterFpb = (gui->samplerate * 60) / gui->getMasterTrack()->getBpm();
int oneFpb = size / beats[iBeatOne];
int twoFpb = size / beats[iBeatTwo];
@ -137,29 +149,20 @@ void AudioEditor::show( AudioBuffer* buf, bool modal )
if ( oneDelta < 0 ) oneDelta = -oneDelta;
if ( twoDelta < 0 ) twoDelta = -twoDelta;
if ( oneDelta == twoDelta )
{
if ( oneDelta == twoDelta ) {
beatButtons[iBeatOne]->setColor( 0.0, 1.0, 0.0 );
beatButtons[iBeatTwo]->setColor( 0.0, 1.0, 0.0 );
}
else if ( oneDelta <= twoDelta )
{
} else if ( oneDelta <= twoDelta ) {
// one is the better match
beatButtons[iBeatOne]->setColor( 0.0, 1.0, 0.0 );
beatButtons[iBeatTwo]->setColor( 1.0, 0.0, 0.0 );
}
else
{
} else {
beatButtons[iBeatTwo]->setColor( 0.0, 1.0, 0.0 );
beatButtons[iBeatOne]->setColor( 1.0, 0.0, 0.0 );
}
}
else if( iBeatOne != -1 && iBeatTwo == -1) // only one valid
{
} else if( iBeatOne != -1 && iBeatTwo == -1) { // only one valid
beatButtons[iBeatOne]->setColor( 0.0, 1.0, 0.0 );
}
else
{
} else {
// no valid BPM range..?
}

View file

@ -24,14 +24,15 @@
#include <FL/Fl_Double_Window.H>
class AudioBuffer;
namespace Avtk {
namespace Avtk
{
class Waveform;
class Button;
}
class AudioEditor
{
public:
public:
AudioEditor();
~AudioEditor();
@ -47,7 +48,7 @@ class AudioEditor
//AudioBuffer* getAudioBuffer();
private:
private:
// GUI elements
Fl_Double_Window* window;
Avtk::Waveform* waveform;

View file

@ -24,8 +24,7 @@ static void gmastertrack_tempoDial_callback(Fl_Widget *w, void *data)
{
Avtk::Dial* b = (Avtk::Dial*)w;
float bpm = (int)(b->value() * 160.f + 60);
if(std::fabs(bpm-round(bpm)))
{
if(std::fabs(bpm-round(bpm))) {
LUPPP_WARN("%f",bpm);
}
EventTimeBPM e = EventTimeBPM( bpm );
@ -115,15 +114,12 @@ static void gmastertrack_mixVol_callback(Fl_Widget *w, void *data)
static void gmastertrack_transport_callback(Fl_Widget *w, void *data)
{
Avtk::LightButton* b = (Avtk::LightButton*)w;
if( b->value() )
{
if( b->value() ) {
EventTransportState e = EventTransportState( TRANSPORT_ROLLING );
writeToDspRingbuffer( &e );
w->label( "Stop" );
b->value( 0 );
}
else
{
} else {
EventTransportState e = EventTransportState( TRANSPORT_STOPPED );
writeToDspRingbuffer( &e );
w->label( "Play" );
@ -134,13 +130,10 @@ static void gmastertrack_transport_callback(Fl_Widget *w, void *data)
static void gmastertrack_button_callback(Fl_Widget *w, void *data)
{
if ( strcmp( w->label(), "Metro" ) == 0 )
{
if ( Fl::event_button() == FL_RIGHT_MOUSE )
{
if ( strcmp( w->label(), "Metro" ) == 0 ) {
if ( Fl::event_button() == FL_RIGHT_MOUSE ) {
// popup volume menu: 10 "steps of volume"
Fl_Menu_Item rclick_menu[] =
{
Fl_Menu_Item rclick_menu[] = {
{ "Vol 100%" },
{ "Vol 75%" },
{ "Vol 50%" },
@ -151,29 +144,22 @@ static void gmastertrack_button_callback(Fl_Widget *w, void *data)
Fl_Menu_Item *m = (Fl_Menu_Item*) rclick_menu->popup( Fl::event_x(), Fl::event_y(), 0, 0, 0);
float v = 0.f;
if ( !m )
{
if ( !m ) {
return;
}
else if ( strcmp(m->label(), "Vol 100%") == 0 ) {
} else if ( strcmp(m->label(), "Vol 100%") == 0 ) {
v = 1;
}
else if ( strcmp(m->label(), "Vol 75%") == 0 ) {
} else if ( strcmp(m->label(), "Vol 75%") == 0 ) {
v = 0.75;
}
else if ( strcmp(m->label(), "Vol 50%") == 0 ) {
} else if ( strcmp(m->label(), "Vol 50%") == 0 ) {
v = 0.5;
}
else
} else
v = 0.25;
LUPPP_NOTE("metro vol = %f", v );
EventMetronomeVolume e( v );
writeToDspRingbuffer( &e );
}
else
{
} else {
Avtk::LightButton* b = (Avtk::LightButton*)w;
b->value( !b->value() );
EventMetronomeActive e = EventMetronomeActive( b->value() );
@ -182,14 +168,10 @@ static void gmastertrack_button_callback(Fl_Widget *w, void *data)
}
else if ( strcmp( w->label(), "Tap" ) == 0 )
{
} else if ( strcmp( w->label(), "Tap" ) == 0 ) {
EventTimeTempoTap e;
writeToDspRingbuffer( &e );
}
else
{
} else {
LUPPP_WARN("Error: unknown command string");
}
}
@ -261,8 +243,7 @@ GMasterTrack::GMasterTrack(int x, int y, int w, int h, const char* l ) :
returnVol.align( FL_ALIGN_CENTER );
returnVol.callback( gmastertrack_returnVol_callback, 0 );
for(int i = 0; i < 4; i++)
{
for(int i = 0; i < 4; i++) {
beatLights[i] = new Avtk::LightButton( x + 10, y + 437 + 54 * i, 40, 42, "" );
}
beatLights[0]->setColor( 1.0, 0.0 , 0.0 );
@ -338,8 +319,7 @@ void GMasterTrack::setTapTempo( bool b )
void GMasterTrack::setBarBeat(int b, int beat)
{
// FIXME: hard coded 4/4 time here
if ( beat % 4 == 0 )
{
if ( beat % 4 == 0 ) {
bar = bar % 4 + 1;
}

View file

@ -45,7 +45,7 @@ using namespace std;
class GMasterTrack : public Fl_Group
{
public:
public:
GMasterTrack(int x, int y, int w, int h, const char* l = 0 );
int getBpm();
@ -74,7 +74,7 @@ class GMasterTrack : public Fl_Group
~GMasterTrack();
private:
private:
int ID;
char* title;

View file

@ -62,8 +62,7 @@ static void updateAuthorCB(Fl_Widget* w, void* data)
{
ControllerUI* c = (ControllerUI*)data;
const char* s = fl_input( "Author: ", "" );
if ( s )
{
if ( s ) {
c->setAuthor( s );
}
}
@ -124,22 +123,16 @@ static void addNewController(Fl_Widget* w, void* ud)
GenericMIDI* c = 0;
const char* name = fl_input( "Controller name: ", "" );
if ( name )
{
if ( name ) {
c = new GenericMIDI( 0, name);
}
else
{
} else {
return;
}
if ( c->status() == Controller::CONTROLLER_OK )
{
if ( c->status() == Controller::CONTROLLER_OK ) {
addControllerUiDsp( self, c );
}
else
{
} else {
LUPPP_ERROR("Controller initialization failed!");
}
}
@ -162,8 +155,10 @@ static void selectLoadController(Fl_Widget* w, void* data)
fnfc.directory( s.str().c_str() ); // default directory to use
// Show native chooser
switch ( fnfc.show() ) {
case -1: /*printf("ERROR: %s\n", fnfc.errmsg());*/ break; // ERROR
case 1: /*printf("CANCEL\n"); */ break; // CANCEL
case -1: /*printf("ERROR: %s\n", fnfc.errmsg());*/
break; // ERROR
case 1: /*printf("CANCEL\n"); */
break; // CANCEL
default:
//printf("Loading controller at %s\n", fnfc.filename());
path = fnfc.filename();
@ -176,12 +171,9 @@ static void selectLoadController(Fl_Widget* w, void* data)
//LUPPP_NOTE("%s","ADD Controller cb");
GenericMIDI* c = new GenericMIDI( path );
if ( c->status() == Controller::CONTROLLER_OK )
{
if ( c->status() == Controller::CONTROLLER_OK ) {
addControllerUiDsp( self, c );
}
else
{
} else {
LUPPP_ERROR("Controller initialization failed!");
}
}
@ -277,8 +269,7 @@ ControllerUI::ControllerUI(int x, int y, int w, int h, std::string n, int ID)
void OptionsWindow::setTarget(const char* n)
{
for(unsigned int i = 0; i < controllers.size(); i++ )
{
for(unsigned int i = 0; i < controllers.size(); i++ ) {
controllers.at(i)->setTarget( n );
}
}
@ -311,20 +302,16 @@ void ControllerUI::setBindEnable( bool b )
void ControllerUI::addBinding( Binding* b )
{
if ( b->action != EVENT_NULL )
{
if ( b->action != EVENT_NULL ) {
// add individual bindings as they're made
const char* tmp = Event::getPrettyName( b->action );
if ( !tmp )
{
if ( !tmp ) {
#ifdef DEBUG_MIDI
LUPPP_NOTE("new binding, action string returned NULL, action number %i ", b->action );
#endif
return;
}
}
else
{
} else {
LUPPP_WARN("new binding, action: == EVENT_NULL" );
return;
}
@ -362,8 +349,7 @@ void ControllerUI::addBinding( Binding* b )
if ( b->send == Event::SEND_KEY )
s << " Sidechain Key";
if ( b->active != -1)
{
if ( b->active != -1) {
if ( b->active == true )
s << " On";
if ( b->active == false )
@ -398,8 +384,7 @@ void ControllerUI::addBindings( GenericMIDI* c )
{
std::vector<Binding*> bindingVector= c->getMidiToAction();
for(unsigned int i = 0; i < bindingVector.size(); i++ )
{
for(unsigned int i = 0; i < bindingVector.size(); i++ ) {
addBinding( bindingVector.at(i) );
}
}
@ -468,10 +453,8 @@ void OptionsWindow::hide()
ControllerUI* OptionsWindow::getControllerUI(int id)
{
for(unsigned int i = 0; i < controllers.size(); i++ )
{
if ( controllers.at(i)->controllerID == id )
{
for(unsigned int i = 0; i < controllers.size(); i++ ) {
if ( controllers.at(i)->controllerID == id ) {
return controllers.at(i);
}
}

View file

@ -43,14 +43,20 @@ class OptionsWindow;
/// contains UI elements to represent one controller
class ControllerUI
{
public:
public:
ControllerUI( int x, int y, int w, int h, std::string name,int id);
~ControllerUI();
void setAuthor(std::string author);
void setLink (std::string link );
std::string getAuthor(){return author;}
std::string getLink(){return link;}
std::string getAuthor()
{
return author;
}
std::string getLink()
{
return link;
}
void setTarget(const char* n);
void setBindEnable( bool b );
@ -72,7 +78,7 @@ class ControllerUI
Fl_Scroll* scroll;
Fl_Pack* bindingsPack;
private:
private:
// bindings
std::string target;
std::string author;
@ -93,7 +99,7 @@ class ControllerUI
class OptionsWindow
{
public:
public:
OptionsWindow();
~OptionsWindow();
@ -111,7 +117,7 @@ class OptionsWindow
int runTests();
#endif
private:
private:
Fl_Double_Window* window;
Avtk::Button* newButton;
Avtk::Button* loadButton;

View file

@ -46,12 +46,9 @@ GridLogic::GridLogic()
void GridLogic::selectedTrackSceneEvent(bool p)
{
if ( p )
{
if ( p ) {
pressed( selectedTrack, selectedScene );
}
else
{
} else {
released( selectedTrack, selectedScene );
}
}
@ -93,25 +90,17 @@ void GridLogic::setSelectedScene(int s)
void GridLogic::launchScene( int scene )
{
for(unsigned int t = 0; t < NTRACKS; t++ )
{
for(int s = 0; s < NSCENES; s++ )
{
for(unsigned int t = 0; t < NTRACKS; t++ ) {
for(int s = 0; s < NSCENES; s++ ) {
LooperClip* lc = jack->getLooper( t )->getClip( s );
if ( s == scene )
{
if ( s == scene ) {
lc->queuePlay();
jack->getControllerUpdater()->setSceneState( t, s, lc->getState() );
}
else
{
if ( lc->playing() )
{
} else {
if ( lc->playing() ) {
lc->queueStop();
jack->getControllerUpdater()->setSceneState( t, s, lc->getState() );
}
else if ( lc->somethingQueued() )
{
} else if ( lc->somethingQueued() ) {
lc->neutralize();
jack->getControllerUpdater()->setSceneState( t, s, lc->getState() );
}
@ -141,8 +130,7 @@ void GridLogic::specialScene(int t, int s)
void GridLogic::pressed( int track, int scene )
{
if ( sampleTrackScene )
{
if ( sampleTrackScene ) {
specialScene( track, scene );
// don't act on grid press!
@ -159,25 +147,19 @@ void GridLogic::pressed( int track, int scene )
printf("GridLogic::pressed() before press state = %s\n", StateString[ int(scene) ] );
#endif
if ( to->recordArm() && !lc->recording() )
{
if ( to->recordArm() && !lc->recording() ) {
lc->queueRecord();
to->recordArm(false);
jack->getControllerUpdater()->recordArm( track, false );
}
else
{
} else {
if ( s == STATE_EMPTY )
lc->queueRecord();
if ( s == STATE_STOPPED )
{
if ( s == STATE_STOPPED ) {
// hack, stop all scenes, then launch proper one
for( int i = 0; i < NTRACKS; i++ )
{
for( int i = 0; i < NTRACKS; i++ ) {
LooperClip* ilc = jack->getLooper( track )->getClip( i );
if ( ilc->playing() )
{
if ( ilc->playing() ) {
ilc->queueStop();
}
}
@ -208,11 +190,9 @@ void GridLogic::pressed( int track, int scene )
// check state of new clip, if getQueuePlay() == true, queueStop() all other scenes
//if ( lc->getQueuePlay() )
{
for(int i = 0; i < NSCENES; i++)
{
for(int i = 0; i < NSCENES; i++) {
// exclude current scene
if ( i != scene )
{
if ( i != scene ) {
//LUPPP_NOTE("netralizing & qStop on scene %i due to press on %i", i, scene );
LooperClip* ilc = jack->getLooper( track )->getClip( i );
@ -249,10 +229,8 @@ void GridLogic::load(int track, int scene, AudioBuffer* ab)
void GridLogic::updateState()
{
//printf("GridLogic::updateState() stub" );
for(int t = 0; t < NTRACKS; t++)
{
for(int s = 0; s < NSCENES; s++)
{
for(int t = 0; t < NTRACKS; t++) {
for(int s = 0; s < NSCENES; s++) {
GridLogic::State st = jack->getLooper( t )->getClip( s )->getState();
EventGuiPrint e( GridLogic::StateString[st] );
writeToGuiRingbuffer( &e );
@ -269,16 +247,14 @@ void GridLogic::bar()
#endif
/// iterate over all clips, if they're set to QUEUED, set to the next state
for( int i = 0; i < NTRACKS*NSCENES; i++ )
{
for( int i = 0; i < NTRACKS*NSCENES; i++ ) {
int track = i / NSCENES;
int scene = i - track * NSCENES;
jack->getLooper( track )->getClip(scene)->bar();
#ifdef DEBUG_CLIP
GridLogic::State s = jack->getLooper( track )->getClip( scene )->getState();
if ( s != STATE_EMPTY )
{
if ( s != STATE_EMPTY ) {
//printf("%i, %i:after bar() state = %s\n", track, scene, StateString[ int(s) ] );
}
#endif

View file

@ -42,7 +42,7 @@ class AudioBuffer;
**/
class GridLogic : public TimeObserver
{
public:
public:
/// possible states of each square. Public so Controller subclasses can
/// determine the state of the square
enum State {
@ -56,7 +56,7 @@ class GridLogic : public TimeObserver
};
GridLogic();
~GridLogic(){};
~GridLogic() {};
/// button press / click event
void pressed( int track, int scene );
@ -66,7 +66,10 @@ class GridLogic : public TimeObserver
/// master controls, launches a horizontal scene with one event
void launchScene( int scene );
int getCurrentScene(){return sceneLaunch;}
int getCurrentScene()
{
return sceneLaunch;
}
int getLaunchedScene();
/// selected track functions
@ -97,7 +100,7 @@ class GridLogic : public TimeObserver
int runTests();
#endif
private:
private:
/// holds last scene launch
int sceneLaunch;

View file

@ -85,20 +85,50 @@ GTrack::GTrack(int x, int y, int w, int h, const char* l ) :
end(); // close the group
}
float GTrack::getSend(){return sendDial.value(); }
float GTrack::getXSide(){return xsideDial.value(); }
float GTrack::getSend()
{
return sendDial.value();
}
float GTrack::getXSide()
{
return xsideDial.value();
}
bool GTrack::getSendActive (){return sendActive.value(); }
bool GTrack::getKeyActive (){return keyActive.value(); }
bool GTrack::getRecordActive(){return recordActive.value(); }
bool GTrack::getSendActive ()
{
return sendActive.value();
}
bool GTrack::getKeyActive ()
{
return keyActive.value();
}
bool GTrack::getRecordActive()
{
return recordActive.value();
}
void GTrack::setSend(float s){ sendDial.value( s ); }
void GTrack::setXSide(float s){ xsideDial.value( s ); }
void GTrack::setSend(float s)
{
sendDial.value( s );
}
void GTrack::setXSide(float s)
{
xsideDial.value( s );
}
void GTrack::setSendActive(bool a){ sendActive.value( a ); }
void GTrack::setKeyActive(bool a){ keyActive.value( a ); }
void GTrack::setRecordActive(bool a){ recordActive.value( a ); }
void GTrack::setSendActive(bool a)
{
sendActive.value( a );
}
void GTrack::setKeyActive(bool a)
{
keyActive.value( a );
}
void GTrack::setRecordActive(bool a)
{
recordActive.value( a );
}
void GTrack::setJackSend(float s)
{
@ -134,13 +164,10 @@ void gtrack_key_cb(Fl_Widget *w, void *data)
GTrack* track = (GTrack*) data;
Avtk::LightButton* d = (Avtk::LightButton*)w;
bool b = d->value();
if ( b < 0.5 )
{
if ( b < 0.5 ) {
EventTrackSendActive e( track->ID, SEND_KEY, true );
writeToDspRingbuffer( &e );
}
else
{
} else {
EventTrackSendActive e( track->ID, SEND_KEY, false );
writeToDspRingbuffer( &e );
}
@ -171,13 +198,10 @@ void gtrack_send_cb(Fl_Widget *w, void *data)
Avtk::LightButton* d = (Avtk::LightButton*)w;
bool b = d->value();
d->value( !b );
if ( b < 0.5 )
{
if ( b < 0.5 ) {
EventTrackSendActive e( track->ID, SEND_POSTFADER, 1.0f );
writeToDspRingbuffer( &e );
}
else
{
} else {
EventTrackSendActive e( track->ID, SEND_POSTFADER, 0.0f );
writeToDspRingbuffer( &e );
}
@ -198,13 +222,10 @@ void gtrack_record_cb(Fl_Widget *w, void *data)
GTrack* track = (GTrack*) data;
Avtk::LightButton* d = (Avtk::LightButton*)w;
bool b = d->value();
if ( b < 0.5 )
{
if ( b < 0.5 ) {
EventTrackRecordArm e( track->ID, 1.0f );
writeToDspRingbuffer( &e );
}
else
{
} else {
EventTrackRecordArm e( track->ID, 0.0f );
writeToDspRingbuffer( &e );
}
@ -217,13 +238,10 @@ void gtrack_jacksendactivate_cb(Fl_Widget* w,void *data)
Avtk::LightButton* d = (Avtk::LightButton*)w;
bool b=d->value();
// d->value(!b);
if ( b < 0.5 )
{
if ( b < 0.5 ) {
EventTrackJackSendActivate e( track->ID, 1.0f );
writeToDspRingbuffer( &e );
}
else
{
} else {
EventTrackJackSendActivate e( track->ID, 0.0f );
writeToDspRingbuffer( &e );
}

View file

@ -45,11 +45,20 @@ using namespace std;
class GTrack : public Fl_Group
{
public:
public:
Avtk::Volume* getVolume(){return &volume;}
Avtk::RadialStatus* getRadialStatus(){return &radial;}
Avtk::ClipSelector* getClipSelector(){return &clipSel;}
Avtk::Volume* getVolume()
{
return &volume;
}
Avtk::RadialStatus* getRadialStatus()
{
return &radial;
}
Avtk::ClipSelector* getClipSelector()
{
return &clipSel;
}
GTrack(int x, int y, int w, int h, const char* l = 0 );

View file

@ -59,26 +59,20 @@ extern int signalHanlderInt;
static void signalChecker(void*)
{
if ( signalHanlderInt )
{
if ( signalHanlderInt ) {
// Luppp recieved either a SIGTERM or SIGINT: quit gracefully
gui->quit();
}
else
{
} else {
Fl::repeat_timeout( 0.1, (Fl_Timeout_Handler)&signalChecker, 0 );
}
}
void close_cb(Fl_Widget*o, void*)
{
if ( (Fl::event() == FL_KEYDOWN || Fl::event() == FL_SHORTCUT) && Fl::event_key() == FL_Escape)
{
if ( (Fl::event() == FL_KEYDOWN || Fl::event() == FL_SHORTCUT) && Fl::event_key() == FL_Escape) {
// on excape, as about quitting
gui->askQuit();
}
else
{
} else {
gui->quit();
}
}
@ -103,13 +97,11 @@ void option_controller_cb(Fl_Widget*,void* data)
static void gui_header_callback(Fl_Widget *w, void *data)
{
Gui* g = (Gui*)data;
if ( Fl::event_x() > 130 )
{
if ( Fl::event_x() > 130 ) {
return;
}
Fl_Menu_Item rclick_menu[] =
{
Fl_Menu_Item rclick_menu[] = {
{ "New Session" },
{ "Load Session" },
{ "Save Session ", 0, 0, 0, FL_MENU_DIVIDER},
@ -119,28 +111,21 @@ static void gui_header_callback(Fl_Widget *w, void *data)
};
// check for NSM running, deactivate new / save / load if yes
if ( gui->getNsm() )
{
if ( gui->getNsm() ) {
rclick_menu[1].deactivate();
rclick_menu[2].deactivate();
}
Fl_Menu_Item *m = (Fl_Menu_Item*) rclick_menu->popup( 10, 38, 0, 0, 0);
if ( !m )
{
if ( !m ) {
return;
}
else if ( strcmp(m->label(), "New Session") == 0 )
{
} else if ( strcmp(m->label(), "New Session") == 0 ) {
int yes = fl_choice("Start a new session?","Cancel","Yes",0);
if ( yes )
{
if ( yes ) {
gui->reset();
}
}
else if ( strcmp(m->label(), "Load Session") == 0 )
{
} else if ( strcmp(m->label(), "Load Session") == 0 ) {
std::string tmp;
{
@ -154,12 +139,15 @@ static void gui_header_callback(Fl_Widget *w, void *data)
// Block until user picks something.
// (The other way to do this is to use a callback())
//
while(chooser.shown())
{ Fl::wait(); }
while(chooser.shown()) {
Fl::wait();
}
// User hit cancel?
if ( chooser.value() == NULL )
{ fprintf(stderr, "(User hit 'Cancel')\n"); return; }
if ( chooser.value() == NULL ) {
fprintf(stderr, "(User hit 'Cancel')\n");
return;
}
// Print what the user picked
fprintf(stderr, "--------------------\n");
@ -189,24 +177,17 @@ static void gui_header_callback(Fl_Widget *w, void *data)
LUPPP_ERROR( "Error loading session" );
return;
}
else if ( strcmp(m->label(), "Save Session ") == 0 )
{
} else if ( strcmp(m->label(), "Save Session ") == 0 ) {
const char* name = fl_input( "Save session as", gui->getDiskWriter()->getLastSaveName().c_str() );
if ( name )
{
if ( name ) {
gui->getDiskWriter()->initialize( gui->getProjectsDir().c_str(), name );
LUPPP_NOTE("%s %s","Saving session as ", name );
EventStateSave e;
writeToDspRingbuffer( &e );
}
}
else if ( strcmp(m->label(), "Setup") == 0 )
{
} else if ( strcmp(m->label(), "Setup") == 0 ) {
g->getOptionsWindow()->show();
}
else if ( strcmp(m->label(), "Quit") == 0 )
{
} else if ( strcmp(m->label(), "Quit") == 0 ) {
g->askQuit();
}
}
@ -227,9 +208,14 @@ void Gui::selectLoadController(Fl_Widget* w, void*)
fnfc.directory( getenv("HOME") ); // default directory to use
// Show native chooser
switch ( fnfc.show() ) {
case -1: printf("ERROR: %s\n", fnfc.errmsg()); break; // ERROR
case 1: printf("CANCEL\n"); break; // CANCEL
default: printf("Loading controller at %s\n", fnfc.filename());
case -1:
printf("ERROR: %s\n", fnfc.errmsg());
break; // ERROR
case 1:
printf("CANCEL\n");
break; // CANCEL
default:
printf("Loading controller at %s\n", fnfc.filename());
path = fnfc.filename();
break;
}
@ -240,13 +226,10 @@ void Gui::selectLoadController(Fl_Widget* w, void*)
LUPPP_NOTE("%s","ADD Controller cb");
Controller* c = new GenericMIDI( path );
if ( c->status() == Controller::CONTROLLER_OK )
{
if ( c->status() == Controller::CONTROLLER_OK ) {
EventControllerInstance e(c);
writeToDspRingbuffer( &e );
}
else
{
} else {
LUPPP_ERROR("Controller initialization failed!");
}
@ -283,8 +266,10 @@ Gui::selectSavePath()
// Show native chooser
switch ( fnfc.show() ) {
case -1: /*printf("ERROR: %s\n", fnfc.errmsg()); */ break; // ERROR
case 1: /*(printf("CANCEL\n"); */ break; // CANCEL
case -1: /*printf("ERROR: %s\n", fnfc.errmsg()); */
break; // ERROR
case 1: /*(printf("CANCEL\n"); */
break; // CANCEL
default: /*printf("Loading directory: %s\n", fnfc.filename()); */
path = fnfc.filename();
break;
@ -311,8 +296,10 @@ void Gui::selectLoadSample( int track, int scene )
// Show native chooser
switch ( fnfc.show() ) {
case -1: /*printf("ERROR: %s\n", fnfc.errmsg()); */ break; // ERROR
case 1: /*(printf("CANCEL\n"); */ break; // CANCEL
case -1: /*printf("ERROR: %s\n", fnfc.errmsg()); */
break; // ERROR
case 1: /*(printf("CANCEL\n"); */
break; // CANCEL
default: /*printf("Loading directory: %s\n", fnfc.filename()); */
path = fnfc.filename();
break;
@ -454,8 +441,7 @@ Gui::Gui(const char* argZero) :
lupppGroup = new Fl_Group( 0, 0, 1110, 700, "Luppp");
{
int i = 0;
for (; i < NTRACKS; i++ )
{
for (; i < NTRACKS; i++ ) {
stringstream s;
s << "Track " << i+1;
tracks.push_back( new GTrack(8 + i * 118, 40, 110, 650, s.str().c_str() ) );
@ -480,38 +466,29 @@ Gui::Gui(const char* argZero) :
// read settings file using diskreader, and setup controllers etc
int prefs = diskReader->loadPreferences();
if ( prefs != LUPPP_RETURN_OK )
{
if ( prefs != LUPPP_RETURN_OK ) {
LUPPP_WARN("No preferences loaded, using defaults.");
}
else
{
} else {
LUPPP_NOTE("Loaded preferences");
}
// NSM stuff
nsm = 0;
const char *nsm_url = getenv( "NSM_URL" );
if ( nsm_url )
{
if ( nsm_url ) {
nsm = nsm_new();
nsm_set_open_callback( nsm, cb_nsm_open, this );
nsm_set_save_callback( nsm, cb_nsm_save, this );
if ( nsm_init( nsm, nsm_url ) == 0 )
{
if ( nsm_init( nsm, nsm_url ) == 0 ) {
nsm_send_announce( nsm, "Luppp", "", argZero );
LUPPP_NOTE("Announcing to NSM");
}
else
{
} else {
nsm_free( nsm );
nsm = 0;
}
}
else
{
} else {
LUPPP_NOTE("No session management in use");
}
}
@ -523,11 +500,9 @@ void Gui::addMidiControllerToSetup(std::string c)
void Gui::setupMidiControllers()
{
for(unsigned int i = 0; i < controllerVector.size(); i++)
{
for(unsigned int i = 0; i < controllerVector.size(); i++) {
GenericMIDI* c = new GenericMIDI( controllerVector.at(i).c_str() );
if ( c )
{
if ( c ) {
EventControllerInstance e(c);
writeToDspRingbuffer( &e );
}
@ -541,20 +516,17 @@ void Gui::reset()
writeToDspRingbuffer( &ev );
// clear UI state: track names / scene names
for(unsigned int i = 0; i < NTRACKS; i++)
{
for(unsigned int i = 0; i < NTRACKS; i++) {
stringstream s;
s << "Track " << i+1;
tracks.at(i)->bg.setLabel( s.str().c_str() );
for(unsigned int s = 0; s < NSCENES; s++)
{
for(unsigned int s = 0; s < NSCENES; s++) {
tracks.at(i)->getClipSelector()->clipName( s, "" );
}
}
for(unsigned int i = 0; i < NSCENES; i++)
{
for(unsigned int i = 0; i < NSCENES; i++) {
stringstream s;
s << "Scene " << i+1;
master->getClipSelector()->clipName( i, s.str() );
@ -599,8 +571,7 @@ int Gui::quit()
void Gui::askQuit()
{
int quit = fl_choice("Really Quit?","Cancel","Quit",0);
if ( quit ) // JUST QUIT
{
if ( quit ) { // JUST QUIT
gui->quit();
}
}
@ -608,99 +579,332 @@ void Gui::askQuit()
int Gui::keyboardHandler(int event)
{
switch( event )
{
switch( event ) {
case FL_SHORTCUT:
if ( strcmp( Fl::event_text(), "1" ) == 0 ) { EventGridEvent e( 0, 0, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "2" ) == 0 ) { EventGridEvent e( 1, 0, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "3" ) == 0 ) { EventGridEvent e( 2, 0, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "4" ) == 0 ) { EventGridEvent e( 3, 0, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "5" ) == 0 ) { EventGridEvent e( 4, 0, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "6" ) == 0 ) { EventGridEvent e( 5, 0, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "7" ) == 0 ) { EventGridEvent e( 6, 0, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "8" ) == 0 ) { EventGridEvent e( 7, 0, true ); writeToDspRingbuffer( &e ); return 1; }
if ( strcmp( Fl::event_text(), "1" ) == 0 ) {
EventGridEvent e( 0, 0, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "2" ) == 0 ) {
EventGridEvent e( 1, 0, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "3" ) == 0 ) {
EventGridEvent e( 2, 0, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "4" ) == 0 ) {
EventGridEvent e( 3, 0, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "5" ) == 0 ) {
EventGridEvent e( 4, 0, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "6" ) == 0 ) {
EventGridEvent e( 5, 0, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "7" ) == 0 ) {
EventGridEvent e( 6, 0, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "8" ) == 0 ) {
EventGridEvent e( 7, 0, true );
writeToDspRingbuffer( &e );
return 1;
}
else if( strcmp( Fl::event_text(), "!" ) == 0 ) { EventGridState e( 0, 0, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "@" ) == 0 ) { EventGridState e( 1, 0, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "\"" ) == 0 ) { EventGridState e( 1, 0, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; } // for UK/Ireland keyboards
else if( strcmp( Fl::event_text(), "#" ) == 0 ) { EventGridState e( 2, 0, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "£" ) == 0 ) { EventGridState e( 2, 0, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; } // for UK/Ireland keyboards
else if( strcmp( Fl::event_text(), "$" ) == 0 ) { EventGridState e( 3, 0, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "%" ) == 0 ) { EventGridState e( 4, 0, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "^" ) == 0 ) { EventGridState e( 5, 0, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "&" ) == 0 ) { EventGridState e( 6, 0, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "*" ) == 0 ) { EventGridState e( 7, 0, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "!" ) == 0 ) {
EventGridState e( 0, 0, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "@" ) == 0 ) {
EventGridState e( 1, 0, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "\"" ) == 0 ) {
EventGridState e( 1, 0, GridLogic::STATE_EMPTY ); // for UK/Ireland keyboards
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "#" ) == 0 ) {
EventGridState e( 2, 0, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "£" ) == 0 ) {
EventGridState e( 2, 0, GridLogic::STATE_EMPTY ); // for UK/Ireland keyboards
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "$" ) == 0 ) {
EventGridState e( 3, 0, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "%" ) == 0 ) {
EventGridState e( 4, 0, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "^" ) == 0 ) {
EventGridState e( 5, 0, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "&" ) == 0 ) {
EventGridState e( 6, 0, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "*" ) == 0 ) {
EventGridState e( 7, 0, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
}
else if( strcmp( Fl::event_text(), "q" ) == 0 ) { EventGridEvent e( 0, 1, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "w" ) == 0 ) { EventGridEvent e( 1, 1, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "e" ) == 0 ) { EventGridEvent e( 2, 1, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "r" ) == 0 ) { EventGridEvent e( 3, 1, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "t" ) == 0 ) { EventGridEvent e( 4, 1, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "y" ) == 0 ) { EventGridEvent e( 5, 1, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "u" ) == 0 ) { EventGridEvent e( 6, 1, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "i" ) == 0 ) { EventGridEvent e( 7, 1, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "q" ) == 0 ) {
EventGridEvent e( 0, 1, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "w" ) == 0 ) {
EventGridEvent e( 1, 1, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "e" ) == 0 ) {
EventGridEvent e( 2, 1, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "r" ) == 0 ) {
EventGridEvent e( 3, 1, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "t" ) == 0 ) {
EventGridEvent e( 4, 1, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "y" ) == 0 ) {
EventGridEvent e( 5, 1, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "u" ) == 0 ) {
EventGridEvent e( 6, 1, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "i" ) == 0 ) {
EventGridEvent e( 7, 1, true );
writeToDspRingbuffer( &e );
return 1;
}
else if( strcmp( Fl::event_text(), "Q" ) == 0 ) { EventGridState e( 0, 1, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "W" ) == 0 ) { EventGridState e( 1, 1, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "E" ) == 0 ) { EventGridState e( 2, 1, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "R" ) == 0 ) { EventGridState e( 3, 1, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "T" ) == 0 ) { EventGridState e( 4, 1, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "Y" ) == 0 ) { EventGridState e( 5, 1, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "U" ) == 0 ) { EventGridState e( 6, 1, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "I" ) == 0 ) { EventGridState e( 7, 1, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "Q" ) == 0 ) {
EventGridState e( 0, 1, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "W" ) == 0 ) {
EventGridState e( 1, 1, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "E" ) == 0 ) {
EventGridState e( 2, 1, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "R" ) == 0 ) {
EventGridState e( 3, 1, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "T" ) == 0 ) {
EventGridState e( 4, 1, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "Y" ) == 0 ) {
EventGridState e( 5, 1, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "U" ) == 0 ) {
EventGridState e( 6, 1, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "I" ) == 0 ) {
EventGridState e( 7, 1, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
}
else if( strcmp( Fl::event_text(), "a" ) == 0 ) { EventGridEvent e( 0, 2, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "s" ) == 0 ) { EventGridEvent e( 1, 2, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "d" ) == 0 ) { EventGridEvent e( 2, 2, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "f" ) == 0 ) { EventGridEvent e( 3, 2, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "g" ) == 0 ) { EventGridEvent e( 4, 2, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "h" ) == 0 ) { EventGridEvent e( 5, 2, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "j" ) == 0 ) { EventGridEvent e( 6, 2, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "k" ) == 0 ) { EventGridEvent e( 7, 2, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "a" ) == 0 ) {
EventGridEvent e( 0, 2, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "s" ) == 0 ) {
EventGridEvent e( 1, 2, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "d" ) == 0 ) {
EventGridEvent e( 2, 2, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "f" ) == 0 ) {
EventGridEvent e( 3, 2, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "g" ) == 0 ) {
EventGridEvent e( 4, 2, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "h" ) == 0 ) {
EventGridEvent e( 5, 2, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "j" ) == 0 ) {
EventGridEvent e( 6, 2, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "k" ) == 0 ) {
EventGridEvent e( 7, 2, true );
writeToDspRingbuffer( &e );
return 1;
}
else if( strcmp( Fl::event_text(), "A" ) == 0 ) { EventGridState e( 0, 2, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "S" ) == 0 ) { EventGridState e( 1, 2, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "D" ) == 0 ) { EventGridState e( 2, 2, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "F" ) == 0 ) { EventGridState e( 3, 2, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "G" ) == 0 ) { EventGridState e( 4, 2, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "H" ) == 0 ) { EventGridState e( 5, 2, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "J" ) == 0 ) { EventGridState e( 6, 2, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "K" ) == 0 ) { EventGridState e( 7, 2, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "A" ) == 0 ) {
EventGridState e( 0, 2, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "S" ) == 0 ) {
EventGridState e( 1, 2, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "D" ) == 0 ) {
EventGridState e( 2, 2, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "F" ) == 0 ) {
EventGridState e( 3, 2, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "G" ) == 0 ) {
EventGridState e( 4, 2, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "H" ) == 0 ) {
EventGridState e( 5, 2, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "J" ) == 0 ) {
EventGridState e( 6, 2, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "K" ) == 0 ) {
EventGridState e( 7, 2, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
}
else if( strcmp( Fl::event_text(), "z" ) == 0 ) { EventGridEvent e( 0, 3, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "x" ) == 0 ) { EventGridEvent e( 1, 3, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "c" ) == 0 ) { EventGridEvent e( 2, 3, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "v" ) == 0 ) { EventGridEvent e( 3, 3, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "b" ) == 0 ) { EventGridEvent e( 4, 3, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "n" ) == 0 ) { EventGridEvent e( 5, 3, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "m" ) == 0 ) { EventGridEvent e( 6, 3, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "," ) == 0 ) { EventGridEvent e( 7, 3, true ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "z" ) == 0 ) {
EventGridEvent e( 0, 3, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "x" ) == 0 ) {
EventGridEvent e( 1, 3, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "c" ) == 0 ) {
EventGridEvent e( 2, 3, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "v" ) == 0 ) {
EventGridEvent e( 3, 3, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "b" ) == 0 ) {
EventGridEvent e( 4, 3, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "n" ) == 0 ) {
EventGridEvent e( 5, 3, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "m" ) == 0 ) {
EventGridEvent e( 6, 3, true );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "," ) == 0 ) {
EventGridEvent e( 7, 3, true );
writeToDspRingbuffer( &e );
return 1;
}
else if( strcmp( Fl::event_text(), "Z" ) == 0 ) { EventGridState e( 0, 3, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "X" ) == 0 ) { EventGridState e( 1, 3, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "C" ) == 0 ) { EventGridState e( 2, 3, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "V" ) == 0 ) { EventGridState e( 3, 3, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "B" ) == 0 ) { EventGridState e( 4, 3, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "N" ) == 0 ) { EventGridState e( 5, 3, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "M" ) == 0 ) { EventGridState e( 6, 3, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "<" ) == 0 ) { EventGridState e( 7, 3, GridLogic::STATE_EMPTY ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "Z" ) == 0 ) {
EventGridState e( 0, 3, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "X" ) == 0 ) {
EventGridState e( 1, 3, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "C" ) == 0 ) {
EventGridState e( 2, 3, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "V" ) == 0 ) {
EventGridState e( 3, 3, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "B" ) == 0 ) {
EventGridState e( 4, 3, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "N" ) == 0 ) {
EventGridState e( 5, 3, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "M" ) == 0 ) {
EventGridState e( 6, 3, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "<" ) == 0 ) {
EventGridState e( 7, 3, GridLogic::STATE_EMPTY );
writeToDspRingbuffer( &e );
return 1;
}
else if( strcmp( Fl::event_text(), "9" ) == 0 ) { EventGridLaunchScene e( 0 ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "o" ) == 0 ) { EventGridLaunchScene e( 1 ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "l" ) == 0 ) { EventGridLaunchScene e( 2 ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "." ) == 0 ) { EventGridLaunchScene e( 3 ); writeToDspRingbuffer( &e ); return 1; }
else if( strcmp( Fl::event_text(), "9" ) == 0 ) {
EventGridLaunchScene e( 0 );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "o" ) == 0 ) {
EventGridLaunchScene e( 1 );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "l" ) == 0 ) {
EventGridLaunchScene e( 2 );
writeToDspRingbuffer( &e );
return 1;
} else if( strcmp( Fl::event_text(), "." ) == 0 ) {
EventGridLaunchScene e( 3 );
writeToDspRingbuffer( &e );
return 1;
}
else
{
else {
//printf("%s\n", Fl::event_text() ); return 1;
}
}
// keyboard arrows to special key mapping
if ( Fl::event_key( FL_Left ) ) { EventGridSelectNewChosen e( gui->specialTrack-1, gui->specialScene ); writeToDspRingbuffer( &e ); return 1; }
if ( Fl::event_key( FL_Right ) ) { EventGridSelectNewChosen e( gui->specialTrack+1, gui->specialScene ); writeToDspRingbuffer( &e ); return 1; }
if ( Fl::event_key( FL_Up ) ) { EventGridSelectNewChosen e( gui->specialTrack , gui->specialScene-1); writeToDspRingbuffer( &e ); return 1; }
if ( Fl::event_key( FL_Down ) ) { EventGridSelectNewChosen e( gui->specialTrack , gui->specialScene+1); writeToDspRingbuffer( &e ); return 1; }
if ( Fl::event_key( FL_Left ) ) {
EventGridSelectNewChosen e( gui->specialTrack-1, gui->specialScene );
writeToDspRingbuffer( &e );
return 1;
}
if ( Fl::event_key( FL_Right ) ) {
EventGridSelectNewChosen e( gui->specialTrack+1, gui->specialScene );
writeToDspRingbuffer( &e );
return 1;
}
if ( Fl::event_key( FL_Up ) ) {
EventGridSelectNewChosen e( gui->specialTrack , gui->specialScene-1);
writeToDspRingbuffer( &e );
return 1;
}
if ( Fl::event_key( FL_Down ) ) {
EventGridSelectNewChosen e( gui->specialTrack , gui->specialScene+1);
writeToDspRingbuffer( &e );
return 1;
}
return 0;
}
@ -716,8 +920,7 @@ Gui::~Gui()
delete master;
for(unsigned int i = 0; i < tracks.size(); i++)
{
for(unsigned int i = 0; i < tracks.size(); i++) {
delete tracks.at(i);
}

View file

@ -46,7 +46,7 @@ class AudioBuffer;
class Gui
{
public:
public:
Gui(const char* argZero);
~Gui();
@ -69,10 +69,19 @@ class Gui
void setupMidiControllers();
GTrack* getTrack(int id);
GMasterTrack* getMasterTrack(){return master;}
GMasterTrack* getMasterTrack()
{
return master;
}
DiskWriter* getDiskWriter(){return diskWriter;}
DiskReader* getDiskReader(){return diskReader;}
DiskWriter* getDiskWriter()
{
return diskWriter;
}
DiskReader* getDiskReader()
{
return diskReader;
}
/// used to load samples into the grid
void selectLoadSample( int track, int clip );
@ -88,9 +97,15 @@ class Gui
////Enable per track send and resturn jack ports
bool enablePerTrackOutput;
int getWindowWidth(){return window.w();}
int getWindowWidth()
{
return window.w();
}
nsm_client_t* getNsm(){return nsm;}
nsm_client_t* getNsm()
{
return nsm;
}
/// current special clip:
@ -104,7 +119,7 @@ class Gui
// save a particular sample to path
std::string saveBufferPath;
private:
private:
vector<std::string> controllerVector;
Fl_Double_Window window;

View file

@ -37,7 +37,7 @@ using namespace std;
class GUnitTrack : public Fl_Group
{
public:
public:
GUnitTrack(int x, int y, int w, int h, const char* l = 0 ) :
Fl_Group(x, y, w, h),
title( strdup(l) ),
@ -59,7 +59,7 @@ class GUnitTrack : public Fl_Group
}
private:
private:
char* title;
Avtk::Background bg;

View file

@ -53,15 +53,12 @@ extern Jack* jack;
void Jack::setup(std::string name)
{
if ( jack == 0 )
{
if ( jack == 0 ) {
jack = new Jack( name );
jack->activate();
return;
}
else
{
} else {
LUPPP_WARN("JACK instance already exists!");
}
}
@ -194,8 +191,7 @@ Jack::Jack( std::string name ) :
buffers.audio[Buffers::MASTER_OUT_L] = new float[ buffers.nframes ];
buffers.audio[Buffers::MASTER_OUT_R] = new float[ buffers.nframes ];
for(int i = 0; i < NTRACKS; i++)
{
for(int i = 0; i < NTRACKS; i++) {
/** Setup the tracks:
* The TrackOutput gets a pointer to the next AudioProcessor to call:
* This is either a JackSendReturn (providing send and return ports)
@ -215,8 +211,7 @@ Jack::Jack( std::string name ) :
timeManager->registerObserver( loopers.back() );
if(gui->enablePerTrackOutput)
{
if(gui->enablePerTrackOutput) {
char name[50];
sprintf(name,"track_%d\n",i);
trackJackOutputPorts[i]=jack_port_register( client,
@ -241,16 +236,14 @@ Jack::Jack( std::string name ) :
/// setup JACK callbacks
if ( jack_set_process_callback( client,
static_process,
static_cast<void*>(this)) )
{
static_cast<void*>(this)) ) {
LUPPP_ERROR("%s","Error setting process callback");
}
if ( jack_set_timebase_callback(client,
0, //0, 0 == must be master, 1 == conditional
(JackTimebaseCallback)static_timebase,
static_cast<void*>(this)) )
{
static_cast<void*>(this)) ) {
LUPPP_ERROR("%s","Error setting timebase callback");
}
@ -263,8 +256,7 @@ Jack::Jack( std::string name ) :
Controller* g = new LupppGUI();
controllerUpdater->registerController( g );
if ( !g )
{
if ( !g ) {
LUPPP_ERROR("%s","Error creating LupppGUI Controller instance");
}
@ -284,8 +276,7 @@ Jack::~Jack()
delete inputMeter;
delete masterMeter;
for(int i = 0; i < NTRACKS; i++)
{
for(int i = 0; i < NTRACKS; i++) {
delete [] buffers.audio[Buffers::TRACK_0+i];
delete [] buffers.audio[Buffers::SEND_TRACK_0+i];
delete [] buffers.audio[Buffers::RETURN_TRACK_0+i];
@ -320,8 +311,7 @@ TrackOutput* Jack::getTrackOutput(int t)
if ( t >= 0 && t < NTRACKS )
return trackOutputs.at(t);
#ifdef DEBUG_TRACKS
else
{
else {
printf( "Jack::getTrackOutput() returning 0x0: invalid track requested!\n" );
}
#endif
@ -334,8 +324,7 @@ JackSendReturn* Jack::getJackSendReturn(int t)
if ( t >= 0 && t < NTRACKS )
return tracksendreturns.at(t);
#ifdef DEBUG_TRACKS
else
{
else {
printf( "Jack::getTrackOutput() returning 0x0: invalid track requested!\n" );
}
#endif
@ -349,8 +338,7 @@ Looper* Jack::getLooper(int t)
if ( t >= 0 && t < NTRACKS )
return loopers.at(t);
#ifdef DEBUG_TRACKS
else
{
else {
printf( "Jack::getLooper() returning 0x0: invalid track requested!\n" );
}
#endif
@ -372,10 +360,8 @@ void Jack::unregisterMidiIO( MidiIO* mo )
LUPPP_NOTE("Jack::unregisterMidiIO()");
// unregister the observer
for(unsigned int i = 0; i < midiIO.size(); i++)
{
if ( midiIO.at(i) == mo )
{
for(unsigned int i = 0; i < midiIO.size(); i++) {
if ( midiIO.at(i) == mo ) {
cout << "removing mo at " << i << endl;
midiIO.erase( midiIO.begin() + i );
return;
@ -396,9 +382,8 @@ int Jack::process (jack_nframes_t nframes)
buffers.audio[Buffers::JACK_MASTER_OUT_R] = (float*)jack_port_get_buffer( masterOutputR , nframes );
buffers.audio[Buffers::JACK_SIDECHAIN_KEY] = (float*)jack_port_get_buffer(sidechainKeyOutput,nframes);
buffers.audio[Buffers::JACK_SIDECHAIN_SIGNAL]=(float*)jack_port_get_buffer(sidechainSignalOutput,nframes);
if(gui->enablePerTrackOutput)
{
for(int t=0;t<NTRACKS;t++)
if(gui->enablePerTrackOutput) {
for(int t=0; t<NTRACKS; t++)
buffers.audio[Buffers::JACK_TRACK_0+t] = (float*)jack_port_get_buffer( trackJackOutputPorts[t] , nframes );
}
@ -413,9 +398,8 @@ int Jack::process (jack_nframes_t nframes)
memset( buffers.audio[Buffers::SEND] , 0, sizeof(float) * nframes );
memset( buffers.audio[Buffers::SIDECHAIN_KEY] , 0, sizeof(float) * nframes );
memset( buffers.audio[Buffers::SIDECHAIN_SIGNAL] , 0, sizeof(float) * nframes );
if(gui->enablePerTrackOutput)
{
for(int t=0;t<NTRACKS;t++)
if(gui->enablePerTrackOutput) {
for(int t=0; t<NTRACKS; t++)
memset( buffers.audio[Buffers::JACK_TRACK_0+t] , 0, sizeof(float) * nframes );
}
@ -424,8 +408,7 @@ int Jack::process (jack_nframes_t nframes)
//buffers.midi [Buffers::MASTER_MIDI_INPUT] = (void*) jack_port_get_buffer( masterMidiInput, nframes );
/// init buffers for each MidiIO
for(unsigned int i = 0; i < midiIO.size(); i++ )
{
for(unsigned int i = 0; i < midiIO.size(); i++ ) {
midiIO.at(i)->initBuffers( nframes );
}
@ -464,8 +447,7 @@ int Jack::process (jack_nframes_t nframes)
void Jack::processFrames(int nframes)
{
if ( nframes < 0 )
{
if ( nframes < 0 ) {
LUPPP_WARN("Jack processFrames got nframes < 0");
return;
}
@ -479,14 +461,12 @@ void Jack::processFrames(int nframes)
*/
/// process each MidiIO registered MIDI port
for(unsigned int i = 0; i < midiIO.size(); i++ )
{
for(unsigned int i = 0; i < midiIO.size(); i++ ) {
midiIO.at(i)->process( nframes );
}
/// process each track, starting at output and working up signal path
for(unsigned int i = 0; i < NTRACKS; i++)
{
for(unsigned int i = 0; i < NTRACKS; i++) {
trackOutputs.at(i)->process( nframes, &buffers );
}
@ -494,8 +474,7 @@ void Jack::processFrames(int nframes)
metronome->process( nframes, &buffers );
/// mix input, reverb & post-sidechain in
for(unsigned int i = 0; i < nframes; i++)
{
for(unsigned int i = 0; i < nframes; i++) {
float input= buffers.audio[Buffers::MASTER_INPUT][i] * inputVol;
float L = buffers.audio[Buffers::MASTER_OUT_L][i];
@ -504,20 +483,17 @@ void Jack::processFrames(int nframes)
float returnR = buffers.audio[Buffers::MASTER_RETURN_R][i];
if ( inputToMixEnable )
{
if ( inputToMixEnable ) {
// if sending to mix, scale by volume *and* by XSide send
float tmp = input * inputToMixVol * (1-inputToXSideVol);
L += tmp;
R += tmp;
}
if ( inputToSendEnable )
{
if ( inputToSendEnable ) {
// post-mix-send amount: hence * inputToMixVol
buffers.audio[Buffers::SEND][i] += input * inputToSendVol * inputToMixVol;
}
if ( inputToKeyEnable )
{
if ( inputToKeyEnable ) {
buffers.audio[Buffers::SIDECHAIN_KEY][i] += input;
}
@ -542,8 +518,7 @@ void Jack::processFrames(int nframes)
inputMeter->process( nframes, buffers.audio[Buffers::MASTER_INPUT], buffers.audio[Buffers::MASTER_INPUT]);
masterMeter->process(nframes, buffers.audio[Buffers::JACK_MASTER_OUT_L], buffers.audio[Buffers::JACK_MASTER_OUT_R] );
if ( uiUpdateCounter > uiUpdateConstant )
{
if ( uiUpdateCounter > uiUpdateConstant ) {
// instead of scaling whole buffer, just scale output by vol
EventTrackSignalLevel e(-1, masterMeter->getLeftDB(), masterMeter->getRightDB() );
writeToGuiRingbuffer( &e );
@ -572,8 +547,7 @@ void Jack::processFrames(int nframes)
// JACK in multiple parts internally in Luppp: used for processing bar() / beat()
// if a full JACK nframes has been processed, this is extra work: its not that expensive
/// update buffers by nframes
if(lastnframes+nframes<buffers.nframes)
{
if(lastnframes+nframes<buffers.nframes) {
lastnframes=nframes;
buffers.audio[Buffers::MASTER_INPUT] = &buffers.audio[Buffers::MASTER_INPUT] [nframes];
buffers.audio[Buffers::MASTER_RETURN_L] = &buffers.audio[Buffers::MASTER_RETURN_L][nframes];
@ -585,15 +559,12 @@ void Jack::processFrames(int nframes)
buffers.audio[Buffers::JACK_MASTER_OUT_R] = &buffers.audio[Buffers::JACK_MASTER_OUT_R][nframes];
buffers.audio[Buffers::JACK_SIDECHAIN_KEY] = &buffers.audio[Buffers::JACK_SIDECHAIN_KEY][nframes];
buffers.audio[Buffers::JACK_SIDECHAIN_SIGNAL]=&buffers.audio[Buffers::JACK_SIDECHAIN_SIGNAL][nframes];
if(gui->enablePerTrackOutput)
{
for(int t=0;t<NTRACKS;t++)
{
if(gui->enablePerTrackOutput) {
for(int t=0; t<NTRACKS; t++) {
buffers.audio[Buffers::JACK_TRACK_0+t] = &buffers.audio[Buffers::JACK_TRACK_0+t][nframes];
}
}
}
else
} else
lastnframes=0;
return;
@ -606,8 +577,7 @@ void Jack::clearInternalBuffers(int nframes)
memset(buffers.audio[Buffers::SIDECHAIN_SIGNAL],0,sizeof(float)*nframes);
memset(buffers.audio[Buffers::MASTER_OUT_L],0,sizeof(float)*nframes);
memset(buffers.audio[Buffers::MASTER_OUT_R],0,sizeof(float)*nframes);
for(int i=0;i<NTRACKS;i++)
{
for(int i=0; i<NTRACKS; i++) {
memset(buffers.audio[Buffers::TRACK_0 + i],0,sizeof(float)*nframes);
memset(buffers.audio[Buffers::SEND_TRACK_0 + i],0,sizeof(float)*nframes);
@ -633,8 +603,7 @@ void Jack::inputVolume(float v)
void Jack::inputTo(INPUT_TO to, float v)
{
switch ( to )
{
switch ( to ) {
case INPUT_TO_MIX:
inputToMixVol = v;
break;
@ -651,8 +620,7 @@ void Jack::inputTo(INPUT_TO to, float v)
void Jack::inputToActive(INPUT_TO to, bool a)
{
switch ( to )
{
switch ( to ) {
case INPUT_TO_MIX:
inputToMixEnable = a;
break;

View file

@ -54,7 +54,7 @@ using namespace std;
**/
class Jack
{
public:
public:
Jack(std::string name);
~Jack();
@ -77,12 +77,30 @@ class Jack
Looper* getLooper(int t);
TrackOutput* getTrackOutput(int t);
State* getState(){return state;}
Logic* getLogic(){return logic;}
Metronome* getMetronome(){return metronome;}
GridLogic* getGridLogic(){return gridLogic;}
TimeManager* getTimeManager(){return timeManager;}
ControllerUpdater* getControllerUpdater(){return controllerUpdater;}
State* getState()
{
return state;
}
Logic* getLogic()
{
return logic;
}
Metronome* getMetronome()
{
return metronome;
}
GridLogic* getGridLogic()
{
return gridLogic;
}
TimeManager* getTimeManager()
{
return timeManager;
}
ControllerUpdater* getControllerUpdater()
{
return controllerUpdater;
}
void transportRolling(bool rolling);

View file

@ -30,13 +30,12 @@ void JackSendReturn::process(unsigned int nframes, Buffers *buffers)
m_previousProcessor->process(nframes,buffers);
float* send=(float*)jack_port_get_buffer(m_sendport,(jack_nframes_t)(buffers->nframes));
float* ret=(float*)jack_port_get_buffer(m_returnport,(jack_nframes_t)(buffers->nframes));
if(offset)
{
if(offset) {
send+=offset;
ret+=offset;
}
for(int i=0;i<nframes;i++)
for(int i=0; i<nframes; i++)
send[i]=m_sendvol*sendtrack[i];
// if(nframes!=buffers->nframes)
// {

View file

@ -73,95 +73,72 @@ void Logic::masterReturn( int returnNum, float value )
void Logic::trackVolume(int t, float v)
{
if ( t == -1 ) // master track
{
if ( t == -1 ) { // master track
jack->masterVolume(v);
jack->getControllerUpdater()->masterVolume( v );
}
else if ( t >= 0 && t < NTRACKS )
{
} else if ( t >= 0 && t < NTRACKS ) {
jack->getTrackOutput( t )->setMaster( v );
jack->getControllerUpdater()->volume( t, v );
}
else
{
} else {
LUPPP_WARN("invalid track number %i: check controller map has \"track\" field.", t );
}
}
void Logic::trackRecordArm(int t, bool v)
{
if ( t >= 0 && t < NTRACKS )
{
if ( t >= 0 && t < NTRACKS ) {
jack->getTrackOutput( t )->recordArm( v );
jack->getControllerUpdater()->recordArm( t, v );
}
else
{
} else {
LUPPP_WARN("invalid track number %i: check controller map has \"track\" field.", t );
}
}
void Logic::trackSendActive(int t, int s, bool v)
{
if ( t >= 0 && t < NTRACKS )
{
if ( t >= 0 && t < NTRACKS ) {
jack->getTrackOutput( t )->setSendActive( s, v );
jack->getControllerUpdater()->setTrackSendActive( t, s, v );
}
else
{
} else {
LUPPP_WARN("invalid track number %i: check controller map has \"track\" field.", t );
}
}
void Logic::trackSend(int t, int send, float v)
{
if ( t >= 0 && t < NTRACKS )
{
if ( t >= 0 && t < NTRACKS ) {
jack->getTrackOutput( t )->setSend( send, v );
jack->getControllerUpdater()->setTrackSend( t, send, v );
}
else
{
} else {
LUPPP_WARN("invalid track number %i: check controller map has \"track\" field.", t );
}
}
void Logic::trackJackSendActivate(int t, bool active)
{
if ( t >= 0 && t < NTRACKS )
{
if ( t >= 0 && t < NTRACKS ) {
jack->getJackSendReturn(t)->activate(active);
jack->getControllerUpdater()->setTrackJackSendActive( t, active );
}
else
{
} else {
LUPPP_WARN("invalid track number %i: check controller map has \"track\" field.", t );
}
}
void Logic::trackJackSend(int t, float vol)
{
if ( t >= 0 && t < NTRACKS )
{
if ( t >= 0 && t < NTRACKS ) {
jack->getJackSendReturn(t)->sendVolume(vol);
jack->getControllerUpdater()->setTrackJackSend( t, vol );
}
else
{
} else {
LUPPP_WARN("invalid track number %i: check controller map has \"track\" field.", t );
}
}
void Logic::looperClipLenght(int t, int s, int l)
{
if ( t >= 0 && t < NTRACKS )
{
if ( t >= 0 && t < NTRACKS ) {
jack->getLooper( t )->getClip( s )->setBeats(l);
}
else
{
} else {
LUPPP_WARN("invalid track number %i: check controller map has \"track\" field.", t );
}
}
@ -172,8 +149,7 @@ void Logic::looperUseAsTempo(int t, int s)
size_t clipBeats = jack->getLooper( t )->getClip( s )->getBeats();
size_t clipFrames = jack->getLooper( t )->getClip( s )->getBufferLenght();
if ( clipBeats > 0 )
{
if ( clipBeats > 0 ) {
size_t framesPerBeat = clipFrames / clipBeats;
jack->getTimeManager()->setFpb( framesPerBeat );
}

View file

@ -38,7 +38,7 @@
**/
class Logic
{
public:
public:
Logic();
void tapTempo();

View file

@ -42,8 +42,7 @@ Looper::Looper(int t) :
//tmpRecordBuffer = (float*)malloc( sizeof(float) * MAX_BUFFER_SIZE );
//memset( tmpRecordBuffer, 0, sizeof(float) * MAX_BUFFER_SIZE );
for(int i = 0; i < 10; i++ )
{
for(int i = 0; i < 10; i++ ) {
clips[i] = new LooperClip(track, i);
}
@ -72,7 +71,8 @@ LooperClip* Looper::getClip(int scene)
}
void Looper::beat()
{//TODO needed?
{
//TODO needed?
//FIXME: Need to keep looperClips in sync when there exists no int N
// such that playSpeed*N==1
// for(int i=0;i<NSCENES;i++)
@ -106,15 +106,12 @@ void Looper::process(unsigned int nframes, Buffers* buffers)
{
// process each clip individually: this allows for playback of one clip,
// while another clip records.
for ( int clip = 0; clip < NSCENES; clip++ )
{
for ( int clip = 0; clip < NSCENES; clip++ ) {
// handle state of clip, and do what needs doing:
// record into buffer, play from buffer, etc
if ( clips[clip]->recording() )
{
if ( clips[clip]->recording() ) {
if ( clips[clip]->recordSpaceAvailable() < LOOPER_SAMPLES_BEFORE_REQUEST &&
!clips[clip]->newBufferInTransit() )
{
!clips[clip]->newBufferInTransit() ) {
EventLooperClipRequestBuffer e( track, clip, clips[clip]->audioBufferSize() + LOOPER_SAMPLES_UPDATE_SIZE);
writeToGuiRingbuffer( &e );
clips[clip]->newBufferInTransit(true);
@ -123,23 +120,19 @@ void Looper::process(unsigned int nframes, Buffers* buffers)
// copy data from input buffer to recording buffer
float* input = buffers->audio[Buffers::MASTER_INPUT];
clips[clip]->record( nframes, input, 0 );
}
else if ( clips[clip]->playing() )
{
} else if ( clips[clip]->playing() ) {
// copy data into tmpBuffer, then pitch-stretch into track buffer
long targetFrames = clips[clip]->getBeats() * fpb;
long actualFrames = clips[clip]->getActualAudioLength();//getBufferLenght();
float playSpeed = 1.0;
if ( targetFrames != 0 && actualFrames != 0 )
{
if ( targetFrames != 0 && actualFrames != 0 ) {
playSpeed = float(actualFrames) / targetFrames;
}
float* out = buffers->audio[Buffers::SEND_TRACK_0 + track];
for(unsigned int i = 0; i < nframes; i++ )
{
for(unsigned int i = 0; i < nframes; i++ ) {
// REFACTOR into system that is better than per sample function calls
float tmp = clips[clip]->getSample(playSpeed);
@ -157,8 +150,7 @@ void Looper::process(unsigned int nframes, Buffers* buffers)
//printf("Looper %i playing(), speed = %f\n", track, playSpeed );
if ( uiUpdateCounter > uiUpdateConstant )
{
if ( uiUpdateCounter > uiUpdateConstant ) {
jack->getControllerUpdater()->setTrackSceneProgress(track, clip, clips[clip]->getProgress() );
uiUpdateCounter = 0;
}
@ -172,7 +164,7 @@ void Looper::process(unsigned int nframes, Buffers* buffers)
void Looper::resetTimeState()
{
for(int i=0;i<NSCENES;i++)
for(int i=0; i<NSCENES; i++)
clips[i]->setPlayHead(0.0);
}
@ -185,8 +177,7 @@ void Looper::pitchShift(int count, float* input, float* output)
float* input0 = &input[0];
//float* output0 = &output[0];
for (int i=0; i<count; i++)
{
for (int i=0; i<count; i++) {
float fTemp0 = (float)input0[i];
fVec0[IOTA&65535] = fTemp0;
fRec0[0] = fmodf((fRec0[1] + fSlow1),fSlow0);

View file

@ -37,7 +37,7 @@ using namespace std;
**/
class Looper : public AudioProcessor, public TimeObserver
{
public:
public:
Looper(int t);
/// *sets* the new audiobuffer, but the content gets copied to the new buffer.
@ -60,7 +60,7 @@ class Looper : public AudioProcessor, public TimeObserver
/// reset timestate implementation: rest all looperClips
virtual void resetTimeState();
private:
private:
const int track;
/// variables used to determing the current actions of the looper

View file

@ -52,8 +52,7 @@ void LooperClip::init()
_queueStop = false;
_queueRecord= false;
if ( _buffer )
{
if ( _buffer ) {
_buffer->init();
}
_newBufferInTransit = false;
@ -67,8 +66,7 @@ void LooperClip::init()
void LooperClip::save()
{
// ensure the buffer exists, and is saveable (not recording)
if ( _loaded && !_recording && !_queueRecord )
{
if ( _loaded && !_recording && !_queueRecord ) {
char buffer [50];
sprintf (buffer, "LC::save() track %i, scene %i", track,scene);
EventGuiPrint e( buffer );
@ -77,9 +75,7 @@ void LooperClip::save()
int frames = _buffer->getAudioFrames();
EventRequestSaveBuffer e2( track, scene, frames );
writeToGuiRingbuffer( &e2 );
}
else
{
} else {
// notify of "success" of save if there *is* no state to save
Stately::success();
}
@ -88,8 +84,7 @@ void LooperClip::save()
void LooperClip::reset()
{
// TODO make the LooperClip reset to initial state
if ( _loaded )
{
if ( _loaded ) {
char buffer [50];
sprintf (buffer, "LC::reset() track %i, scene %i", track,scene);
EventGuiPrint e( buffer );
@ -97,9 +92,7 @@ void LooperClip::reset()
// set "progress" to zero as there's no clip anymore
jack->getControllerUpdater()->setTrackSceneProgress(track, scene, 0 );
}
else
{
} else {
//SaveAble::done();
}
@ -117,8 +110,7 @@ void LooperClip::load( AudioBuffer* ab )
_queueStop = false;
_queueRecord= false;
if ( _buffer )
{
if ( _buffer ) {
EventDeallocateBuffer e( _buffer );
writeToGuiRingbuffer( &e );
}
@ -141,8 +133,7 @@ void LooperClip::load( AudioBuffer* ab )
void LooperClip::setRequestedBuffer( AudioBuffer* ab )
{
if ( _buffer )
{
if ( _buffer ) {
size_t size = _buffer->getData().size();
memcpy( &ab->getData().at(0), &_buffer->getData().at(0), sizeof(float)*size);
@ -162,8 +153,7 @@ void LooperClip::setRequestedBuffer( AudioBuffer* ab )
void LooperClip::recieveSaveBuffer( AudioBuffer* saveBuffer )
{
if ( saveBuffer->getData().size() >= _buffer->getData().at(0) )
{
if ( saveBuffer->getData().size() >= _buffer->getData().at(0) ) {
// copy current contents into save buffer,
size_t framesBySize = _buffer->getAudioFrames();
memcpy( &saveBuffer->getData().at(0), &_buffer->getData().at(0), sizeof(float)*framesBySize);
@ -176,9 +166,7 @@ void LooperClip::recieveSaveBuffer( AudioBuffer* saveBuffer )
writeToGuiRingbuffer( &e );
Stately::success();
}
else
{
} else {
char buffer [50];
sprintf (buffer, "LC:: %i, %i: can't save, buf too small",track, scene );
EventGuiPrint e( buffer );
@ -189,8 +177,7 @@ void LooperClip::recieveSaveBuffer( AudioBuffer* saveBuffer )
void LooperClip::setPlayHead(float ph)
{
if(!_recording&&_playing)
{
if(!_recording&&_playing) {
_playhead = ph;
jack->getControllerUpdater()->setTrackSceneProgress(track, scene, getProgress() );
}
@ -201,19 +188,14 @@ void LooperClip::setPlayHead(float ph)
void LooperClip::record(int count, float* L, float* R)
{
// write "count" samples into current buffer.
if ( _buffer )
{
if ( _buffer ) {
size_t size = _buffer->getData().size();
for(int i = 0; i < count; i++)
{
if ( _recordhead < size )
{
for(int i = 0; i < count; i++) {
if ( _recordhead < size ) {
_buffer->getData().at( _recordhead ) = *L++;
_recordhead++;
}
else
{
} else {
// break: this is *BAD*, audio data is lost but the buffer isn't here
// yet to hold new audio data so there's no option. This has not been
// encountered in actual usage, only during the development process.
@ -243,8 +225,7 @@ unsigned long LooperClip::recordSpaceAvailable()
size_t LooperClip::audioBufferSize()
{
if ( _buffer )
{
if ( _buffer ) {
return _buffer->getData().size();
}
return 0;
@ -252,8 +233,7 @@ size_t LooperClip::audioBufferSize()
void LooperClip::setBeats(int beats)
{
if ( _buffer )
{
if ( _buffer ) {
_buffer->setBeats( beats );
}
}
@ -287,20 +267,17 @@ void LooperClip::bar()
GridLogic::State s = GridLogic::STATE_EMPTY;
// first update the buffer, as time has passed
if ( _recording )
{
if ( _recording ) {
// FIXME: assumes 4 beats in a bar
_buffer->setBeats( _buffer->getBeats() + 4 );
_buffer->setAudioFrames( jack->getTimeManager()->getFpb() * _buffer->getBeats() );
}
if ( _playhead >= _recordhead )
{
if ( _playhead >= _recordhead ) {
_playhead = 0.f;
}
if ( _queuePlay && _loaded )
{
if ( _queuePlay && _loaded ) {
//LUPPP_NOTE("QPLay + loaded" );
_playing = true;
s = GridLogic::STATE_PLAYING;
@ -309,9 +286,7 @@ void LooperClip::bar()
change = true;
_playhead = 0;
}
else if ( _queueStop && _loaded )
{
} else if ( _queueStop && _loaded ) {
_playing = false;
s = GridLogic::STATE_STOPPED;
_recording = false;
@ -319,31 +294,25 @@ void LooperClip::bar()
change = true;
// set "progress" to zero, as we're stopped!
jack->getControllerUpdater()->setTrackSceneProgress(track, scene, 0 );
}
else if ( _queueRecord )
{
} else if ( _queueRecord ) {
_recording = true;
s = GridLogic::STATE_RECORDING;
_playing = false;
_queueRecord = false;
change = true;
if ( _buffer )
{
if ( _buffer ) {
_buffer->setBeats( 0 );
}
_recordhead = 0;
}
else if ( _queuePlay )
{
} else if ( _queuePlay ) {
// clip was queued, but there's nothing loaded
_queuePlay = false;
change = true;
}
if ( change )
{
if ( change ) {
jack->getControllerUpdater()->setSceneState(track, scene, s );
}
}
@ -357,8 +326,7 @@ void LooperClip::neutralize()
bool LooperClip::somethingQueued()
{
if ( _queuePlay || _queueStop || _queueRecord )
{
if ( _queuePlay || _queueStop || _queueRecord ) {
return true;
}
return false;
@ -374,8 +342,7 @@ void LooperClip::queuePlay(bool qP)
void LooperClip::queueStop()
{
// comment
if ( _loaded )
{
if ( _loaded ) {
_queueStop = true;
_queuePlay = false;
}
@ -445,12 +412,10 @@ bool LooperClip::newBufferInTransit()
float LooperClip::getSample(float playSpeed)
{
if ( _buffer && _buffer->getData().size() > 0 )
{
if ( _buffer && _buffer->getData().size() > 0 ) {
if ( _playhead >= _recordhead ||
_playhead >= _buffer->getData().size() ||
_playhead < 0 )
{
_playhead < 0 ) {
_playhead = 0;
EventGuiPrint e( "LooperClip resetting _playhead" );
@ -469,8 +434,7 @@ float LooperClip::getSample(float playSpeed)
float LooperClip::getProgress()
{
if ( _buffer && _playing )
{
if ( _buffer && _playing ) {
float p = float(_playhead) / _recordhead;
//printf("LooperClip progress %f\n", p );
return p;

View file

@ -46,7 +46,7 @@ class AudioBuffer;
**/
class LooperClip : public Stately
{
public:
public:
LooperClip(int track, int scene);
void init();
@ -83,7 +83,10 @@ class LooperClip : public Stately
long getActualAudioLength();
size_t audioBufferSize();
AudioBuffer* getAudioBuffer() {return _buffer;}
AudioBuffer* getAudioBuffer()
{
return _buffer;
}
/// set clip state
void queuePlay(bool=true);
@ -118,7 +121,7 @@ class LooperClip : public Stately
void setState( bool load, bool play, bool rec, bool qPlay, bool qStop, bool qRec );
#endif
private:
private:
int track, scene;
/** Luppp needs more than the current state of the clip to accuratly handle

View file

@ -63,15 +63,12 @@ int main(int argc, char** argv)
LUPPP_NOTE("Git: %s", GIT_VERSION );
bool runTests = false;
if ( runTests ){} // remove unused warning if not built with BUILD_TESTS
if ( runTests ) {} // remove unused warning if not built with BUILD_TESTS
for(int i = 0; i < argc; i++)
{
for(int i = 0; i < argc; i++) {
if ( strcmp(argv[i], "-test" ) == 0 ) {
runTests = true;
}
else if ( i != 0 ) // don't try load with the program name!
{
} else if ( i != 0 ) { // don't try load with the program name!
// assume filename, try load it
Fl::repeat_timeout( 1 / 30.f, &gui_static_loadSession_cb, argv[i] );
}
@ -92,8 +89,7 @@ int main(int argc, char** argv)
#ifdef BUILD_TESTS
LUPPP_NOTE("Built with BUILD_TESTS enabled");
if ( runTests )
{
if ( runTests ) {
// counts failures
int testResult = 0;
@ -124,13 +120,10 @@ int main(int argc, char** argv)
// Create a GUI, check for NSM integration
gui = new Gui( argv[0] );
if ( gui->getNsm() )
{
if ( gui->getNsm() ) {
// the NSM OSC Open message will trigger Jack initialization: necessary
// to use the right name to create the JACK client.
}
else
{
} else {
Jack::setup("Luppp");
jack->activate();
}

View file

@ -45,7 +45,7 @@ Metronome::Metronome() :
float scale = 2 * 3.1415 *880/jack->getSamplerate();
// And fill it up
for(int i=0;i < jack->getSamplerate();i++){
for(int i=0; i < jack->getSamplerate(); i++) {
beatSample[i]= sin(i*scale);
barSample [i]= sin(i*scale*2);
}
@ -103,15 +103,12 @@ void Metronome::process(int nframes, Buffers* buffers)
float* out = buffers->audio[Buffers::HEADPHONES_OUT];
float* sample = &beatSample[0];
if( playBar )
{
if( playBar ) {
sample = &barSample[0];
}
for(int i = 0; i < nframes; i++)
{
if ( playPoint < endPoint )
{
for(int i = 0; i < nframes; i++) {
if ( playPoint < endPoint ) {
out[i] += sample[playPoint] * vol;
playPoint++;
}

View file

@ -30,7 +30,7 @@ using namespace std;
class Metronome : public TimeObserver
{
public:
public:
Metronome();
~Metronome();
@ -44,7 +44,7 @@ class Metronome : public TimeObserver
void process(int nframes, Buffers* buffers);
private:
private:
int fpb;
bool playBar;
bool active;

View file

@ -47,12 +47,9 @@ void MidiIO::writeMidi( unsigned char* data )
void* portBuffer = jack_port_get_buffer( jackOutputPort, jack->getBuffersize() );
unsigned char* buffer = jack_midi_event_reserve( portBuffer, 0, 3);
if( buffer == 0 )
{
if( buffer == 0 ) {
return;
}
else
{
} else {
//memcpy( buffer, data, sizeof(unsigned char)*3 );
buffer[0] = data[0];
buffer[1] = data[1];
@ -63,8 +60,7 @@ void MidiIO::writeMidi( unsigned char* data )
int MidiIO::registerMidiPorts(std::string name)
{
if( !jack )
{
if( !jack ) {
LUPPP_ERROR("Attempted register of controller, JACK not instantiated yet!");
return LUPPP_RETURN_ERROR;
}
@ -87,14 +83,11 @@ int MidiIO::registerMidiPorts(std::string name)
JackPortIsOutput,
0 );
if ( jackInputPort && jackOutputPort )
{
if ( jackInputPort && jackOutputPort ) {
//LUPPP_NOTE("%i, %i", jackInputPort, jackOutputPort );
portsRegistered = true;
return LUPPP_RETURN_OK;
}
else
{
} else {
LUPPP_ERROR("Error registering JACK ports" );
return LUPPP_RETURN_ERROR;
}
@ -122,8 +115,7 @@ void MidiIO::process(int nframes)
jack_midi_event_t event;
int index = 0;
int event_count = (int) jack_midi_get_event_count( inputBuffer );
while ( index < event_count )
{
while ( index < event_count ) {
jack_midi_event_get(&event, inputBuffer, index);
midi( (unsigned char*) &event.buffer[0] );
//printf( "MIDI %i %i %i\n", int(event.buffer[0]), int(event.buffer[1]), int(event.buffer[2]) );

View file

@ -32,7 +32,7 @@ extern Jack* jack;
**/
class MidiIO
{
public:
public:
MidiIO();
virtual ~MidiIO();
@ -48,11 +48,11 @@ class MidiIO
/// called by the subclass to create MIDI ports
int registerMidiPorts(std::string name);
virtual void midi(unsigned char* /*data*/){};
virtual void midi(unsigned char* /*data*/) {};
void writeMidi( unsigned char* /*data*/ );
private:
private:
bool portsRegistered;
// there are jack_port_t* registered ports
jack_port_t* jackInputPort;

View file

@ -23,22 +23,22 @@
class TimeObserver
{
public:
public:
/// registers with TimeManager
TimeObserver();
virtual ~TimeObserver(){};
virtual ~TimeObserver() {};
virtual void setFpb(int fpb){};
virtual void setFpb(int fpb) {};
//Reset any internal set of this object regarding time. Don't reset/delete any buffers!!
//This is not to be confused with Stately::reset()
virtual void resetTimeState(){};
virtual void resetTimeState() {};
virtual void bar(){};
virtual void bar() {};
virtual void beat(){};
virtual void beat() {};
virtual void tapTempo(bool b){};
virtual void tapTempo(bool b) {};
};

View file

@ -39,16 +39,14 @@ void State::registerStately(Stately* s)
void State::save()
{
for( unsigned int i = 0; i < statelys.size(); i++)
{
for( unsigned int i = 0; i < statelys.size(); i++) {
statelys.at(i)->save();
}
}
void State::reset()
{
for( unsigned int i = 0; i < statelys.size(); i++)
{
for( unsigned int i = 0; i < statelys.size(); i++) {
statelys.at(i)->reset();
}

View file

@ -29,7 +29,7 @@
**/
class State
{
public:
public:
State();
/// called to initiate a save on all Statelys
@ -45,7 +45,7 @@ class State
int getNumStatelys();
private:
private:
std::vector<Stately*> statelys;
};

View file

@ -43,12 +43,10 @@ void Stately::save()
void Stately::checkCompletedSave()
{
if ( (saveSuccess + saveErrors) >= jack->getState()->getNumStatelys() )
{
if ( (saveSuccess + saveErrors) >= jack->getState()->getNumStatelys() ) {
jack->getState()->finish();
if ( saveErrors )
{
if ( saveErrors ) {
// send message to UI to be printed, noting # of clips unsaved due to errors
char buf[50];
sprintf( buf, "Saved with %i clips !saved due to errors", saveErrors);

View file

@ -31,7 +31,7 @@
**/
class Stately
{
public:
public:
Stately();
/// this function being called resets the state of the instance to blank
@ -48,7 +48,7 @@ class Stately
/// size mismatch in LooperClip for example.
static void error(const char* errorString);
private:
private:
/// holds the amount of successful / error-full saves. Used by success()
/// and error()
static int saveSuccess;

View file

@ -99,8 +99,7 @@ void TimeManager::setFpb(float f)
EventTimeBPM e2( bpm );
writeToGuiRingbuffer( &e2 );
for(uint i = 0; i < observers.size(); i++)
{
for(uint i = 0; i < observers.size(); i++) {
observers.at(i)->setFpb(fpb);
}
}
@ -119,18 +118,14 @@ void TimeManager::registerObserver(TimeObserver* o)
void TimeManager::tap()
{
// reset tap tempo to "first tap" if more than 5 secs elapsed since last tap
if ( tapTempo[0] < totalFrameCounter - samplerate * 5 )
{
if ( tapTempo[0] < totalFrameCounter - samplerate * 5 ) {
tapTempoPos = 0;
}
if ( tapTempoPos < 3 )
{
if ( tapTempoPos < 3 ) {
tapTempo[tapTempoPos] = totalFrameCounter;
tapTempoPos++;
}
else
{
} else {
// calculate frames per tap
int tapFpb1 = tapTempo[1] - tapTempo[0];
int tapFpb2 = tapTempo[2] - tapTempo[1];
@ -138,8 +133,7 @@ void TimeManager::tap()
int average = (tapFpb1 + tapFpb2 + tapFpb3) / 3;
if( average < 13000 )
{
if( average < 13000 ) {
char buffer [50];
sprintf (buffer, "TM, tap() average too slow! quitting");
EventGuiPrint e( buffer );
@ -171,13 +165,12 @@ void TimeManager::setTransportState( TRANSPORT_STATE s )
transportState = s;
if(transportState == TRANSPORT_STOPPED)
jack->transportRolling(false);
else
{
else {
jack->transportRolling(true);
barCounter = 0;
beatCounter = 0;
beatFrameCountdown = -1;
for(int i=0;i<observers.size();i++)
for(int i=0; i<observers.size(); i++)
observers[i]->resetTimeState();
}
}
@ -188,8 +181,7 @@ void TimeManager::process(Buffers* buffers)
//buffers->transportPosition->beats_per_bar = 4;
//buffers->transportPosition->beat_type = 4;
if ( transportState == TRANSPORT_STOPPED )
{
if ( transportState == TRANSPORT_STOPPED ) {
return;
}
@ -198,24 +190,20 @@ void TimeManager::process(Buffers* buffers)
if ( beatFrameCountdown < nframes )
{
if ( beatFrameCountdown < nframes ) {
//length of beat is not multiple of nframes, so need to process last frames of last beat *before* setting next beat
//then set new beat (get the queued actions: play, rec etc)
// then process first frames *after* new beat
int before=(beatCounter*fpb)%nframes;
int after=nframes-before;
if ( before < nframes && after <= nframes && before + after == nframes )
{
if ( before < nframes && after <= nframes && before + after == nframes ) {
char buffer [50];
// sprintf (buffer, "Timing OK: before %i, after %i, b+a %i", before, after, before+after );
// EventGuiPrint e2( buffer );
// writeToGuiRingbuffer( &e2 );
}
else
{
} else {
char buffer [50];
sprintf (buffer, "Timing Error: before: %i, after %i", before, after );
EventGuiPrint e2( buffer );
@ -228,16 +216,13 @@ void TimeManager::process(Buffers* buffers)
// handle beat:
// inform observers of new beat FIRST
for(uint i = 0; i < observers.size(); i++)
{
for(uint i = 0; i < observers.size(); i++) {
observers.at(i)->beat();
}
if ( beatCounter % 4 == 0 )
{
if ( beatCounter % 4 == 0 ) {
// inform observers of new bar SECOND
for(uint i = 0; i < observers.size(); i++)
{
for(uint i = 0; i < observers.size(); i++) {
observers.at(i)->bar();
}
barCounter++;
@ -258,9 +243,7 @@ void TimeManager::process(Buffers* buffers)
beatFrameCountdown = fpb-after;
beatCounter++;
}
else
{
} else {
jack->processFrames( nframes );
beatFrameCountdown -= nframes;
@ -270,8 +253,7 @@ void TimeManager::process(Buffers* buffers)
// write BPM / transport info to JACK
int bpm = ( samplerate * 60) / fpb;
if ( buffers->transportPosition )
{
if ( buffers->transportPosition ) {
buffers->transportPosition->valid = (jack_position_bits_t)(JackPositionBBT | JackTransportPosition);
buffers->transportPosition->bar = beatCounter / 4 + 1;// bars 1-based

View file

@ -32,7 +32,7 @@ using namespace std;
class TimeManager
{
public:
public:
TimeManager();
int getFpb();
@ -58,7 +58,7 @@ class TimeManager
/// TRANSPORT_STATE is defined in transport.hxx
void setTransportState( TRANSPORT_STATE s );
private:
private:
int samplerate;
/// the "state" of the transport: rolling or stopped

View file

@ -72,8 +72,7 @@ void TrackOutput::recordArm(bool r)
void TrackOutput::setSendActive( int send, bool a )
{
switch( send )
{
switch( send ) {
case SEND_POSTFADER:
_toPostfaderActive = a;
break;
@ -89,8 +88,7 @@ void TrackOutput::setSendActive( int send, bool a )
void TrackOutput::setSend( int send, float value )
{
switch( send )
{
switch( send ) {
case SEND_POSTFADER:
_toReverb = value;
break;
@ -119,8 +117,7 @@ void TrackOutput::process(unsigned int nframes, Buffers* buffers)
// run the meter
dbMeter->process( nframes, trackBuffer, trackBuffer );
if (uiUpdateCounter > uiUpdateConstant )
{
if (uiUpdateCounter > uiUpdateConstant ) {
float l = dbMeter->getLeftDB() * _toMasterLag;
float r = dbMeter->getRightDB() * _toMasterLag;
EventTrackSignalLevel e( track, l, r );
@ -141,8 +138,7 @@ void TrackOutput::process(unsigned int nframes, Buffers* buffers)
float* jackoutput = buffers->audio[Buffers::JACK_TRACK_0+track];
for(unsigned int i = 0; i < nframes; i++)
{
for(unsigned int i = 0; i < nframes; i++) {
// * master for "post-fader" sends
float tmp = trackBuffer[i];

View file

@ -35,7 +35,7 @@
**/
class TrackOutput : public AudioProcessor
{
public:
public:
TrackOutput(int t, AudioProcessor* ap);
/// set main mix, 0-1
@ -55,7 +55,7 @@ class TrackOutput : public AudioProcessor
~TrackOutput();
private:
private:
int track;
bool _recordArm;

View file

@ -19,8 +19,7 @@
#ifndef LUPPP_TRANSPORT_H
#define LUPPP_TRANSPORT_H
enum TRANSPORT_STATE
{
enum TRANSPORT_STATE {
TRANSPORT_STOPPED = 0,
TRANSPORT_ROLLING,
};