-Updated GTrack: renameable and extra buttons, GMasterTrack BPM dial

main
Harry van Haaren 2013-09-10 23:09:45 +01:00
parent 499fc93ffe
commit 63680a3ffb
7 changed files with 73 additions and 40 deletions

View File

@ -52,6 +52,16 @@ class Background : public Fl_Widget
int x, y, w, h;
const char* label;
void setLabel(const char* l)
{
free( (char*) label);
label = strdup( l );
}
const char* getLabel()
{
return label;
}
void draw()
{
if (damage() & FL_DAMAGE_ALL)

View File

@ -84,8 +84,7 @@ void DiskWriter::writeMaster()
GMasterTrack* master = gui->getMasterTrack();
cJSON_AddNumberToObject( masterTrack, "fader", master->getVolume()->value() );
cJSON_AddNumberToObject( masterTrack, "bpm", gui->getMasterTrack()->bpm );
cJSON_AddNumberToObject( masterTrack, "bpm", gui->getMasterTrack()->getBpm() );
// scene names
Avtk::ClipSelector* clipSelector = master->getClipSelector();
@ -108,9 +107,6 @@ void DiskWriter::writeMaster()
cJSON_AddNumberToObject( reverb, "damping", rev->damping() );
*/
//cJSON_AddNumberToObject( reverb, "wet", rev->wet() );
//cJSON_AddNumberToObject( reverb, "damping", rev->damping() );
}
void DiskWriter::writeSession( std::string path, std::string sessionName )
@ -122,11 +118,10 @@ void DiskWriter::writeSession( std::string path, std::string sessionName )
cJSON_AddNumberToObject( session, "version_minor", 0 );
cJSON_AddNumberToObject( session, "version_patch", 0 );
writeMaster();
// add JSON "tracks" array
cJSON* trackArray = cJSON_CreateArray();
cJSON_AddItemToObject(session, "tracks", trackArray );
@ -168,13 +163,11 @@ void DiskWriter::writeSession( std::string path, std::string sessionName )
}
}
}
}
}
// write session.luppp JSON node to <path>/<sessionName>.luppp
stringstream sessionDir;
sessionDir << getenv("HOME") << "/" << sessionName;
@ -192,13 +185,11 @@ void DiskWriter::writeSession( std::string path, std::string sessionName )
sessionLuppp << sessionDir.str() << "/session.luppp";
//cout << "Session dir: " << sessionDir.str() << "\n" << "Sample dir : " << sampleDir.str() << endl;
ofstream sessionFile;
sessionFile.open ( sessionLuppp.str().c_str() );
sessionFile << cJSON_Print( session );
sessionFile.close();
// write the sample JSON node to <path>/samples/sample.cfg
stringstream sampleConfig;
sampleConfig << sampleDir.str() << "/sample.cfg";

View File

@ -100,7 +100,7 @@ void handleGuiEvents()
if ( availableRead >= sizeof(EventTimeBPM) ) {
EventTimeBPM ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventTimeBPM) );
gui->getMasterTrack()->bpm = ev.bpm;
gui->getMasterTrack()->setBpm( ev.bpm );
} break; }

View File

@ -1,16 +1,6 @@
#include "gmastertrack.hxx"
/*
static void gmastertrack_reverb_cb(Fl_Widget *w, void *data)
{
int enable = ((Avtk::Reverb*)w)->getActive();
printf("reverb enable %i\n",enable);
EventFxReverb e = EventFxReverb( enable, 0.5, 0.5, 0.5 );
writeToDspRingbuffer( &e );
}
*/
static void gmastertrack_button_callback(Fl_Widget *w, void *data) {
if ( strcmp( w->label(), "Metro" ) == 0 )
{
@ -51,8 +41,8 @@ GMasterTrack::GMasterTrack(int x, int y, int w, int h, const char* l ) :
tapTempo ( x + w * 2/4.f - 18, y + 426 + 41 * 0, 44,38, "Tap"),
metronomeButton( x + w * 2/4.f - 18, y + 426 + 41 * 1, 44, 38,"Metro"),
tempoDial ( x + w * 2/4.f - 18, y + 426 + 41 * 2, 44, 38,"BPM"),
aboutButton ( x + w * 2/4.f - 18, y + 426 + 41 * 3, 44, 38,"About"),
tempoDial ( x + w * 2/4.f - 18, y + 426 + 41 * 2, 45, 36,"BPM"),
metroVol ( x + w * 2/4.f - 18, y + 426 + 41 * 3, 45, 36,"MtroVol"),
inputVolume(x + 9,y + 26 + 4, w - 18, 29,""),
volume(x+106, y +425, 36, 166, "")
@ -65,10 +55,9 @@ GMasterTrack::GMasterTrack(int x, int y, int w, int h, const char* l ) :
tapTempo.callback( gmastertrack_button_callback, &ID );
metronomeButton.callback( gmastertrack_button_callback, 0 );
//tapTempo.setBgColor( 0, 0, 0 );
//metronomeButton.setBgColor( 0, 0, 0 );
//metronomeButton.setColor( 0.4, 0.4, 0.4 );
//metronomeButton.setOutlineColor( 0.4, 0.4, 0.4 );
tempoDial.align( FL_ALIGN_CENTER );
metroVol.align( FL_ALIGN_CENTER );
for(int i = 0; i < 4; i++)
{
@ -92,9 +81,20 @@ GMasterTrack::GMasterTrack(int x, int y, int w, int h, const char* l ) :
end(); // close the group
}
void GMasterTrack::setBpm( int b )
{
bpm = b;
tempoDial.value( ( bpm - 60 ) / 140.f );
}
int GMasterTrack::getBpm()
{
return bpm;
}
void GMasterTrack::setTapTempo( bool b )
{
//tapTempo.setHighlight( b );
tapTempo.setHighlight( b );
}
void GMasterTrack::setBarBeat(int b, int beat)

View File

@ -30,25 +30,23 @@ class GMasterTrack : public Fl_Group
public:
GMasterTrack(int x, int y, int w, int h, const char* l = 0 );
int getBpm();
void setBpm( int bpm );
void setTapTempo( bool b );
void setBarBeat(int b, int beat);
// FIXME: refactor into time class?
int bpm;
Avtk::Volume* getInputVolume();
Avtk::Volume* getVolume();
Avtk::ClipSelector* getClipSelector();
~GMasterTrack();
private:
int ID;
char* title;
int bar;
char* title;
int bpm;
Avtk::Background bg;
@ -60,7 +58,7 @@ class GMasterTrack : public Fl_Group
Avtk::Button tapTempo;
Avtk::LightButton metronomeButton;
Avtk::Dial tempoDial;
Avtk::Button aboutButton;
Avtk::Dial metroVol;
Avtk::LightButton* beatLights[4];

View File

@ -20,9 +20,11 @@ GTrack::GTrack(int x, int y, int w, int h, const char* l ) :
volBox(x+5, y+422, 100, 172, ""),
volume(x+66, y +425, 36, 166, ""),
side(x+11, y +427 + 0, 50, 25, "Side"),
post(x+21, y +435 + 50, 30, 30, "Post"),
rev (x+21, y +440 +100, 30, 30, "Verb")
active (x+11, y +427 + 0, 50, 25, "Active"),
side (x+11, y +427 + 27, 50, 25, "Side"),
recEnable(x+11, y +427 + 54, 50, 25, "Rec"),
post (x+21, y +435 + 70, 30, 30, "Post"),
rev (x+21, y +440 +110, 30, 30, "Verb")
{
ID = privateID++;
@ -31,6 +33,9 @@ GTrack::GTrack(int x, int y, int w, int h, const char* l ) :
side.callback( gtrack_side_cb, this );
side.setColor( 0, 0.6, 1 );
active.setColor( 0, 1.0, 0.0 );
recEnable.setColor( 1, 0.0, 0.0 );
rev.callback( gtrack_reverb_cb, this );
post.callback( gtrack_post_cb, this );
@ -46,6 +51,31 @@ GTrack::GTrack(int x, int y, int w, int h, const char* l ) :
end(); // close the group
}
int GTrack::handle( int event )
{
// highjack right-click on track title for renaming
if ( event == FL_PUSH )
{
if ( Fl::event_y() < y() + 20 )
{
if ( Fl::event_state(FL_BUTTON3) )
{
const char* name = fl_input( "Track name: ", "" );
if ( name )
{
bg.setLabel( name );
redraw();
}
return 1;
}
}
}
else
{
return 0;
}
}
void gtrack_reverb_cb(Fl_Widget *w, void *data)
{

View File

@ -40,6 +40,8 @@ class GTrack : public Fl_Group
free(title);
}
int handle( int );
int ID;
char* title;
@ -54,6 +56,8 @@ class GTrack : public Fl_Group
Avtk::Volume volume;
Avtk::LightButton active;
Avtk::LightButton recEnable;
Avtk::LightButton side;
Avtk::Dial post;
Avtk::Dial rev;