mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-05 09:01:39 -05:00
-Updated UI, GOptions, Controller reading etc
This commit is contained in:
parent
9bd37a666e
commit
b30297f01a
8 changed files with 91 additions and 45 deletions
|
@ -39,7 +39,8 @@ class Button : public Fl_Button
|
|||
w = _w;
|
||||
h = _h;
|
||||
|
||||
label = _label;
|
||||
labelMe = _label;
|
||||
setLabel( labelMe );
|
||||
|
||||
_r = 1.0;
|
||||
_g = 0.48;
|
||||
|
@ -56,11 +57,12 @@ class Button : public Fl_Button
|
|||
bool mouseOver;
|
||||
bool highlight;
|
||||
int x, y, w, h;
|
||||
const char* label;
|
||||
const char* labelMe;
|
||||
|
||||
void setLabel( const char* l)
|
||||
{
|
||||
label = l;
|
||||
labelMe = l;
|
||||
label( labelMe );
|
||||
redraw();
|
||||
}
|
||||
|
||||
|
|
|
@ -623,15 +623,15 @@ int GenericMIDI::loadController( std::string file )
|
|||
LUPPP_NOTE("Has no author field");
|
||||
}
|
||||
|
||||
cJSON* linkJson = cJSON_GetObjectItem( controllerJson, "email" );
|
||||
cJSON* linkJson = cJSON_GetObjectItem( controllerJson, "link" );
|
||||
if ( linkJson )
|
||||
{
|
||||
email = linkJson->valuestring;
|
||||
LUPPP_NOTE("Email %s", email.c_str() );
|
||||
LUPPP_NOTE("Link %s", email.c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
LUPPP_NOTE("Has no email field");
|
||||
LUPPP_NOTE("Has no link field");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -29,6 +29,11 @@ DiskWriter::DiskWriter()
|
|||
sessionJson = cJSON_CreateObject();
|
||||
audioJson = cJSON_CreateObject();
|
||||
|
||||
// setup default controller name / author etc
|
||||
controllerInfo[CONTROLLER_NAME] = "no name";
|
||||
controllerInfo[CONTROLLER_AUTHOR] = "no author";
|
||||
controllerInfo[CONTROLLER_LINK] = "no link";
|
||||
|
||||
sessionDir = getenv("HOME");
|
||||
sessionName = "lupppSession";
|
||||
foldersCreated = false;
|
||||
|
@ -131,10 +136,12 @@ std::string DiskWriter::getLastSavePath()
|
|||
return sessionPath;
|
||||
}
|
||||
|
||||
int DiskWriter::writeControllerFile(std::string name ,
|
||||
std::string author,
|
||||
std::string email,
|
||||
Controller* c )
|
||||
void DiskWriter::writeControllerInfo( CONTROLLER_INFO c, std::string s )
|
||||
{
|
||||
controllerInfo[c] = s;
|
||||
}
|
||||
|
||||
int DiskWriter::writeControllerFile( Controller* c )
|
||||
{
|
||||
if ( c )
|
||||
{
|
||||
|
@ -155,9 +162,12 @@ int DiskWriter::writeControllerFile(std::string name ,
|
|||
|
||||
cJSON* controllerJson = cJSON_CreateObject();
|
||||
|
||||
cJSON_AddItemToObject( controllerJson, "name", cJSON_CreateString( name.c_str() ));
|
||||
cJSON_AddItemToObject( controllerJson, "author", cJSON_CreateString( author.c_str() ));
|
||||
cJSON_AddItemToObject( controllerJson, "email", cJSON_CreateString( email.c_str() ));
|
||||
cJSON_AddItemToObject( controllerJson, "name",
|
||||
cJSON_CreateString( controllerInfo[CONTROLLER_NAME].c_str() ) );
|
||||
cJSON_AddItemToObject( controllerJson, "author",
|
||||
cJSON_CreateString( controllerInfo[CONTROLLER_AUTHOR].c_str() ) );
|
||||
cJSON_AddItemToObject( controllerJson, "link",
|
||||
cJSON_CreateString( controllerInfo[CONTROLLER_LINK].c_str() ) );
|
||||
|
||||
// input bindings
|
||||
std::vector<Binding*> b = g->getMidiToAction();
|
||||
|
|
|
@ -10,6 +10,14 @@
|
|||
class AudioBuffer;
|
||||
class Controller;
|
||||
|
||||
enum CONTROLLER_INFO
|
||||
{
|
||||
CONTROLLER_NAME,
|
||||
CONTROLLER_AUTHOR,
|
||||
CONTROLLER_LINK,
|
||||
CONTROLLER_INFO_SIZE,
|
||||
};
|
||||
|
||||
/// To hold data about loaded clips until we write the JSON out
|
||||
class ClipData
|
||||
{
|
||||
|
@ -43,11 +51,10 @@ class DiskWriter
|
|||
std::string getLastSaveName();
|
||||
std::string getLastSavePath();
|
||||
|
||||
/// sets a piece of info to be written to the controller
|
||||
void writeControllerInfo( CONTROLLER_INFO c, std::string s );
|
||||
/// writes a controller definition .ctlr JSON file from a GenericMIDI instance
|
||||
int writeControllerFile( std::string name ,
|
||||
std::string author,
|
||||
std::string link ,
|
||||
Controller* );
|
||||
int writeControllerFile( Controller* c );
|
||||
|
||||
|
||||
#ifdef BUILD_TESTS
|
||||
|
@ -68,6 +75,8 @@ class DiskWriter
|
|||
|
||||
// convienice functions for code separation
|
||||
void writeMaster();
|
||||
|
||||
std::string controllerInfo[CONTROLLER_INFO_SIZE];
|
||||
};
|
||||
|
||||
#endif // LUPPP_DISK_WRITER_H
|
||||
|
|
|
@ -330,7 +330,7 @@ void handleGuiEvents()
|
|||
EventControllerInstanceGetToWrite ev;
|
||||
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventControllerInstanceGetToWrite) );
|
||||
// write the contents of the GenericMIDI controller to .ctlr file
|
||||
gui->getDiskWriter()->writeControllerFile("name","author","link", (Controller*)ev.controller );
|
||||
gui->getDiskWriter()->writeControllerFile( (Controller*)ev.controller );
|
||||
} break; }
|
||||
|
||||
case Event::CONTROLLER_INSTANCE: {
|
||||
|
|
|
@ -32,7 +32,7 @@ static void addControllerUiDsp(OptionsWindow* self, GenericMIDI* c)
|
|||
|
||||
// tell the ControllerUI to add the bindings from this Controller*
|
||||
self->controllers.back()->setAuthor( c->getAuthor() );
|
||||
self->controllers.back()->setEmail( c->getEmail() );
|
||||
self->controllers.back()->setLink( c->getEmail() );
|
||||
self->controllers.back()->addBindings( c );
|
||||
|
||||
self->tabs->redraw();
|
||||
|
@ -42,6 +42,26 @@ static void addControllerUiDsp(OptionsWindow* self, GenericMIDI* c)
|
|||
writeToDspRingbuffer( &e );
|
||||
}
|
||||
|
||||
static void updateAuthorCB(Fl_Widget* w, void* data)
|
||||
{
|
||||
ControllerUI* c = (ControllerUI*)data;
|
||||
const char* s = fl_input( "Author: ", "" );
|
||||
if ( s )
|
||||
{
|
||||
c->setAuthor( s );
|
||||
}
|
||||
}
|
||||
|
||||
static void updateLinkCB(Fl_Widget* w, void* data)
|
||||
{
|
||||
ControllerUI* c = (ControllerUI*)data;
|
||||
const char* s = fl_input( "Link: ", "" );
|
||||
if ( s )
|
||||
{
|
||||
c->setLink( s );
|
||||
}
|
||||
}
|
||||
|
||||
static void writeBindEnable(Fl_Widget* w, void* data)
|
||||
{
|
||||
OptionsWindow* o = (OptionsWindow*) data;
|
||||
|
@ -146,13 +166,16 @@ static void selectLoadController(Fl_Widget* w, void* data)
|
|||
|
||||
static void writeControllerFile(Fl_Widget* w, void* data)
|
||||
{
|
||||
// a pointer to the controllerID int is passed as data
|
||||
ControllerUI* c = (ControllerUI*)data;
|
||||
|
||||
LUPPP_NOTE("Writing controller %li, %s ID %i .ctlr to disk", c, c->name.c_str(), c->controllerID );
|
||||
|
||||
// FIXME: Controller ID hardcoded
|
||||
EventControllerInstanceGetToWrite e( 2 );
|
||||
// Set the Controller details in diskWriter, so it write it pretty
|
||||
gui->getDiskWriter()->writeControllerInfo( CONTROLLER_NAME , c->name );
|
||||
gui->getDiskWriter()->writeControllerInfo( CONTROLLER_AUTHOR, c->getAuthor());
|
||||
gui->getDiskWriter()->writeControllerInfo( CONTROLLER_LINK , c->getLink() );
|
||||
|
||||
EventControllerInstanceGetToWrite e( c->controllerID );
|
||||
writeToDspRingbuffer( &e );
|
||||
}
|
||||
|
||||
|
@ -183,19 +206,25 @@ ControllerUI::ControllerUI(int x, int y, int w, int h, std::string n, int ID)
|
|||
widget = new Fl_Group( x, y, w, h, name.c_str());
|
||||
{
|
||||
// author / link
|
||||
authorLabel = new Fl_Box( x, y + 0, 200, 30, "Author: -" );
|
||||
emailLabel = new Fl_Box( x + w/2, y + 0, 200, 30, "Email: -" );
|
||||
authorLabel = new Avtk::Button( x + 5, y + 0, 190, 25, "Author?" );
|
||||
linkLabel = new Avtk::Button( x + 7+ w/2, y + 0, 190, 25, "Link?" );
|
||||
|
||||
authorLabel->label("Author?");
|
||||
authorLabel->label("Link?");
|
||||
|
||||
authorLabel->callback( updateAuthorCB, this );
|
||||
linkLabel->callback( updateLinkCB, this );
|
||||
|
||||
// binding / target
|
||||
targetLabelStat = new Fl_Box(x + 100,y + 25, 75, 25,"Target: ");
|
||||
targetLabel = new Fl_Box(x + 140,y + 25, 200, 25,"");
|
||||
bindEnable = new Avtk::LightButton(x + 5, y + 25, 100, 25, "Bind Enable");
|
||||
targetLabelStat = new Fl_Box(x + 100,y + 27, 75, 25,"Target: ");
|
||||
targetLabel = new Fl_Box(x + 140,y + 27, 200, 25,"");
|
||||
bindEnable = new Avtk::LightButton(x + 5, y + 27, 100, 25, "Bind Enable");
|
||||
|
||||
writeControllerBtn = new Avtk::Button( x + 5, y + h - 27, 100, 25, "Save" );
|
||||
//ctlrButton = new Avtk::Button(x + 110, y + 275, 100, 25, "Load");
|
||||
removeController = new Avtk::Button(x + 110, y + h - 27, 100, 25, "Remove");
|
||||
|
||||
scroll = new Fl_Scroll( x + 5, y + 75, 395, 270 );
|
||||
scroll = new Fl_Scroll( x + 5, y + 77, 395, 270 );
|
||||
{
|
||||
bindingsPack = new Fl_Pack( x + 5, y + 75, 340, 10);
|
||||
bindingsPack->end();
|
||||
|
@ -238,20 +267,16 @@ void ControllerUI::setTarget( const char* n )
|
|||
|
||||
void ControllerUI::setAuthor(std::string a)
|
||||
{
|
||||
stringstream s;
|
||||
s << "Author: " << a;
|
||||
author = s.str();
|
||||
author = a;
|
||||
authorLabel->label( author.c_str() );
|
||||
authorLabel->redraw();
|
||||
}
|
||||
|
||||
void ControllerUI::setEmail(std::string e)
|
||||
void ControllerUI::setLink(std::string e)
|
||||
{
|
||||
stringstream s;
|
||||
s << "Email: " << e;
|
||||
email = s.str();
|
||||
emailLabel->label( email.c_str() );
|
||||
emailLabel->redraw();
|
||||
link = e;
|
||||
linkLabel->label( link.c_str() );
|
||||
linkLabel->redraw();
|
||||
}
|
||||
|
||||
void ControllerUI::setBindEnable( bool b )
|
||||
|
|
|
@ -31,7 +31,9 @@ class ControllerUI
|
|||
~ControllerUI();
|
||||
|
||||
void setAuthor(std::string author);
|
||||
void setEmail (std::string email );
|
||||
void setLink (std::string link );
|
||||
std::string getAuthor(){return author;}
|
||||
std::string getLink(){return link;}
|
||||
|
||||
void setTarget(const char* n);
|
||||
void setBindEnable( bool b );
|
||||
|
@ -57,10 +59,10 @@ class ControllerUI
|
|||
// bindings
|
||||
std::string target;
|
||||
std::string author;
|
||||
std::string email;
|
||||
std::string link;
|
||||
|
||||
Fl_Box* authorLabel;
|
||||
Fl_Box* emailLabel;
|
||||
Avtk::Button* authorLabel;
|
||||
Avtk::Button* linkLabel;
|
||||
|
||||
std::vector<int> bindingID;
|
||||
|
||||
|
|
|
@ -55,8 +55,6 @@ void TimeManager::setBpmZeroOne(float b)
|
|||
void TimeManager::setFpb(float f)
|
||||
{
|
||||
fpb = f;
|
||||
//LUPPP_NOTE("%s %f","setFpb()", fpb);
|
||||
|
||||
int bpm = ( samplerate * 60) / f;
|
||||
|
||||
char buffer [50];
|
||||
|
@ -175,13 +173,13 @@ void TimeManager::process(Buffers* buffers)
|
|||
int remaining = buffers->nframes - beatFrameCountdown;
|
||||
if ( remaining > 0 )
|
||||
{
|
||||
|
||||
/*
|
||||
char buffer [50];
|
||||
sprintf (buffer, "remaining %i", remaining );
|
||||
EventGuiPrint e2( buffer );
|
||||
writeToGuiRingbuffer( &e2 );
|
||||
*/
|
||||
|
||||
printf("remaining %i\n", remaining );
|
||||
jack->processFrames( remaining );
|
||||
}
|
||||
// write new beat to UI (bar info currently not used)
|
||||
|
|
Loading…
Add table
Reference in a new issue