2013-09-10 22:51:05 +02:00
|
|
|
|
|
|
|
#include "gmastertrack.hxx"
|
|
|
|
|
2013-09-14 04:57:58 +02:00
|
|
|
static void gmastertrack_tempoDial_callback(Fl_Widget *w, void *data)
|
|
|
|
{
|
|
|
|
Avtk::Dial* b = (Avtk::Dial*)w;
|
2013-12-01 20:01:58 +01:00
|
|
|
float bpm = b->value() * 160.f + 60;
|
2013-09-14 04:57:58 +02:00
|
|
|
EventTimeBPM e = EventTimeBPM( bpm );
|
|
|
|
writeToDspRingbuffer( &e );
|
|
|
|
}
|
|
|
|
|
2013-09-20 11:29:05 +02:00
|
|
|
static void gmastertrack_volume_callback(Fl_Widget *w, void *data)
|
|
|
|
{
|
|
|
|
Avtk::Volume* b = (Avtk::Volume*)w;
|
|
|
|
float v = b->value();
|
|
|
|
EventMasterVol e( v );
|
|
|
|
writeToDspRingbuffer( &e );
|
|
|
|
}
|
|
|
|
|
2013-09-20 14:11:47 +02:00
|
|
|
static void gmastertrack_inputVolume_callback(Fl_Widget *w, void *data)
|
|
|
|
{
|
|
|
|
Avtk::Volume* b = (Avtk::Volume*)w;
|
|
|
|
float v = b->value();
|
|
|
|
EventMasterInputVol e( v );
|
|
|
|
writeToDspRingbuffer( &e );
|
|
|
|
}
|
|
|
|
|
2013-09-20 12:23:59 +02:00
|
|
|
static void gmastertrack_sidchainKeyButton_callback(Fl_Widget *w, void *data)
|
2013-09-18 10:53:15 +02:00
|
|
|
{
|
|
|
|
Avtk::LightButton* b = (Avtk::LightButton*)w;
|
|
|
|
b->value( !b->value() );
|
2013-09-20 16:38:23 +02:00
|
|
|
EventMasterInputToActive e( INPUT_TO_SIDE_KEY, b->value() );
|
|
|
|
writeToDspRingbuffer( &e );
|
2013-11-11 01:14:32 +01:00
|
|
|
//printf("Key button\n");
|
2013-09-18 10:53:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gmastertrack_mixButton_callback(Fl_Widget *w, void *data)
|
|
|
|
{
|
|
|
|
Avtk::LightButton* b = (Avtk::LightButton*)w;
|
|
|
|
b->value( !b->value() );
|
2013-09-20 16:38:23 +02:00
|
|
|
EventMasterInputToActive e( INPUT_TO_MIX, b->value() );
|
|
|
|
writeToDspRingbuffer( &e );
|
2013-11-11 01:14:32 +01:00
|
|
|
//printf("Mix button\n");
|
2013-09-18 10:53:15 +02:00
|
|
|
}
|
|
|
|
|
2013-09-20 13:40:50 +02:00
|
|
|
static void gmastertrack_sendButton_callback(Fl_Widget *w, void *data)
|
|
|
|
{
|
|
|
|
Avtk::LightButton* b = (Avtk::LightButton*)w;
|
|
|
|
b->value( !b->value() );
|
2013-09-20 16:38:23 +02:00
|
|
|
EventMasterInputToActive e( INPUT_TO_SEND, b->value() );
|
|
|
|
writeToDspRingbuffer( &e );
|
2013-11-11 01:14:32 +01:00
|
|
|
//printf("Send button\n");
|
2013-09-20 14:02:27 +02:00
|
|
|
|
2013-09-20 13:40:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gmastertrack_sendVol_callback(Fl_Widget *w, void *data)
|
|
|
|
{
|
|
|
|
Avtk::Dial* b = (Avtk::Dial*)w;
|
|
|
|
float v = b->value();
|
|
|
|
EventMasterInputTo e = EventMasterInputTo( INPUT_TO_SEND, v );
|
|
|
|
writeToDspRingbuffer( &e );
|
2013-11-11 01:14:32 +01:00
|
|
|
///printf("Send dial\n");
|
2013-09-20 14:02:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gmastertrack_xSideVol_callback(Fl_Widget *w, void *data)
|
|
|
|
{
|
|
|
|
Avtk::Dial* b = (Avtk::Dial*)w;
|
|
|
|
float v = b->value();
|
|
|
|
EventMasterInputTo e = EventMasterInputTo( INPUT_TO_XSIDE, v );
|
|
|
|
writeToDspRingbuffer( &e );
|
2013-11-11 01:14:32 +01:00
|
|
|
//printf("XSide dial\n");
|
2013-09-20 14:02:27 +02:00
|
|
|
}
|
|
|
|
|
2013-10-07 16:21:24 +02:00
|
|
|
/// return volume
|
|
|
|
static void gmastertrack_returnVol_callback(Fl_Widget *w, void *data)
|
|
|
|
{
|
|
|
|
Avtk::Dial* b = (Avtk::Dial*)w;
|
|
|
|
float v = b->value();
|
|
|
|
EventMasterReturn e( RETURN_MAIN, v );
|
|
|
|
writeToDspRingbuffer( &e );
|
2013-11-11 01:14:32 +01:00
|
|
|
//printf("Return dial\n");
|
2013-10-07 16:21:24 +02:00
|
|
|
}
|
|
|
|
|
2013-09-20 14:02:27 +02:00
|
|
|
static void gmastertrack_mixVol_callback(Fl_Widget *w, void *data)
|
|
|
|
{
|
|
|
|
Avtk::Dial* b = (Avtk::Dial*)w;
|
|
|
|
float v = b->value();
|
|
|
|
EventMasterInputTo e = EventMasterInputTo( INPUT_TO_MIX, v );
|
|
|
|
writeToDspRingbuffer( &e );
|
2013-11-11 01:14:32 +01:00
|
|
|
//printf("MIX dial\n");
|
2013-09-20 13:40:50 +02:00
|
|
|
}
|
|
|
|
|
2013-09-14 04:57:58 +02:00
|
|
|
static void gmastertrack_button_callback(Fl_Widget *w, void *data)
|
|
|
|
{
|
2013-09-10 22:51:05 +02:00
|
|
|
if ( strcmp( w->label(), "Metro" ) == 0 )
|
|
|
|
{
|
2013-09-18 10:53:15 +02:00
|
|
|
Avtk::LightButton* b = (Avtk::LightButton*)w;
|
2013-09-10 22:51:05 +02:00
|
|
|
b->value( !b->value() );
|
|
|
|
EventMetronomeActive e = EventMetronomeActive( b->value() );
|
|
|
|
writeToDspRingbuffer( &e );
|
|
|
|
}
|
|
|
|
else if ( strcmp( w->label(), "Tap" ) == 0 )
|
|
|
|
{
|
|
|
|
EventTimeTempoTap e;
|
|
|
|
writeToDspRingbuffer( &e );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-11-02 00:31:18 +01:00
|
|
|
LUPPP_WARN("Error: unknown command string");
|
2013-09-10 22:51:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GMasterTrack::GMasterTrack(int x, int y, int w, int h, const char* l ) :
|
|
|
|
Fl_Group(x, y, w, h),
|
|
|
|
title( strdup(l) ),
|
|
|
|
bg( x, y , w, h, title ),
|
|
|
|
|
2013-09-10 23:23:32 +02:00
|
|
|
// with "true" master flag: launches scenes instead of clips on tracks
|
2013-09-10 22:51:05 +02:00
|
|
|
clipSel(x + 5, y + 26 + 102, 140, 294,"", true),
|
|
|
|
|
|
|
|
source(x+5, y+26, 140, 100, ""),
|
|
|
|
volBox(x+5, y+422, 140, 172, ""),
|
|
|
|
|
2013-09-10 23:23:32 +02:00
|
|
|
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"),
|
2013-09-10 22:51:05 +02:00
|
|
|
|
2013-09-11 00:09:45 +02:00
|
|
|
tempoDial ( x + w * 2/4.f - 18, y + 426 + 41 * 2, 45, 36,"BPM"),
|
2013-09-11 02:32:58 +02:00
|
|
|
returnVol ( x + w * 2/4.f - 18, y + 426 + 41 * 3, 45, 36,"Return"),
|
2013-09-18 10:53:15 +02:00
|
|
|
|
2013-09-20 12:23:59 +02:00
|
|
|
inputVolume(x + 9,y + 26 + 4, w - 18, 30,""),
|
2013-09-18 10:53:15 +02:00
|
|
|
|
2013-09-20 12:23:59 +02:00
|
|
|
inputToSend (x + 10,y + 28 + 68, 40, 26,"Snd"),
|
|
|
|
inputToSendVol(x + w*0.2-15,y + 28 + 36, 30, 30,""),
|
|
|
|
|
|
|
|
inputToSidechainKey (x + w*0.5-20,y + 28 + 68, 40, 26,"Key"),
|
|
|
|
inputToSidechainSignalVol(x + w*0.5-15,y + 28 + 36, 30, 30,""),
|
|
|
|
|
|
|
|
inputToMix (x + w*0.8-20,y + 28 + 68, 40, 26,"Mix"),
|
|
|
|
inputToMixVol(x + w*0.8-15,y + 28 + 36, 30, 30,""),
|
2013-09-11 02:32:58 +02:00
|
|
|
|
2013-09-10 22:51:05 +02:00
|
|
|
volume(x+106, y +425, 36, 166, "")
|
|
|
|
{
|
|
|
|
ID = privateID++;
|
|
|
|
|
|
|
|
bar = 0;
|
|
|
|
|
2013-09-18 11:09:26 +02:00
|
|
|
inputVolume.value(0.5);
|
2013-09-10 22:51:05 +02:00
|
|
|
inputVolume.setOrientationHorizontal();
|
2013-09-10 23:23:32 +02:00
|
|
|
|
2013-09-20 14:11:47 +02:00
|
|
|
inputVolume.callback( gmastertrack_inputVolume_callback, 0 );
|
|
|
|
|
2013-09-10 22:51:05 +02:00
|
|
|
tapTempo.callback( gmastertrack_button_callback, &ID );
|
|
|
|
metronomeButton.callback( gmastertrack_button_callback, 0 );
|
2013-09-20 14:02:27 +02:00
|
|
|
|
2013-09-14 04:57:58 +02:00
|
|
|
tempoDial.callback( gmastertrack_tempoDial_callback, 0 );
|
2013-09-20 12:23:59 +02:00
|
|
|
|
2013-09-20 14:02:27 +02:00
|
|
|
inputToSend.setColor( 0, 1.0, 0 );
|
|
|
|
inputToSend.callback( gmastertrack_sendButton_callback, 0 );
|
|
|
|
inputToSendVol.callback( gmastertrack_sendVol_callback, 0 );
|
|
|
|
|
2013-09-20 12:23:59 +02:00
|
|
|
inputToSidechainKey.setColor( 0, 0.6, 1 );
|
|
|
|
inputToSidechainKey.callback( gmastertrack_sidchainKeyButton_callback, 0 );
|
|
|
|
inputToSidechainSignalVol.value( 0 );
|
2013-09-20 14:02:27 +02:00
|
|
|
inputToSidechainSignalVol.callback( gmastertrack_xSideVol_callback, 0 );
|
2013-09-14 04:57:58 +02:00
|
|
|
|
2013-09-20 14:02:27 +02:00
|
|
|
inputToMix.callback ( gmastertrack_mixButton_callback, 0 );
|
2013-09-20 12:23:59 +02:00
|
|
|
inputToMixVol.callback ( gmastertrack_mixVol_callback, 0 );
|
2013-09-18 11:09:26 +02:00
|
|
|
|
2013-09-20 13:40:50 +02:00
|
|
|
|
|
|
|
|
2013-09-11 00:09:45 +02:00
|
|
|
tempoDial.align( FL_ALIGN_CENTER );
|
2013-10-07 16:21:24 +02:00
|
|
|
|
|
|
|
returnVol.value( 1.f );
|
2013-09-11 02:32:58 +02:00
|
|
|
returnVol.align( FL_ALIGN_CENTER );
|
2013-10-07 16:21:24 +02:00
|
|
|
returnVol.callback( gmastertrack_returnVol_callback, 0 );
|
2013-09-10 22:51:05 +02:00
|
|
|
|
|
|
|
for(int i = 0; i < 4; i++)
|
|
|
|
{
|
2013-09-23 16:23:48 +02:00
|
|
|
beatLights[i] = new Avtk::LightButton( x + 11, y + 427 + 41 * i, 38, 38, "" );
|
2013-09-10 22:51:05 +02:00
|
|
|
}
|
2013-09-10 23:23:32 +02:00
|
|
|
beatLights[0]->setColor( 1.0, 0.0 , 0.0 );
|
|
|
|
beatLights[1]->setColor( 1.0, 0.48, 0.0 );
|
|
|
|
beatLights[2]->setColor( 1.0, 1.0 , 0.0 );
|
|
|
|
beatLights[3]->setColor( 0.0, 1.0 , 0.0 );
|
2013-09-10 22:51:05 +02:00
|
|
|
|
|
|
|
volume.amplitude( 0.0, 0.0 );
|
2013-09-20 11:29:05 +02:00
|
|
|
volume.callback( gmastertrack_volume_callback, 0 );
|
2013-09-10 22:51:05 +02:00
|
|
|
|
|
|
|
end(); // close the group
|
|
|
|
}
|
|
|
|
|
2013-09-11 00:09:45 +02:00
|
|
|
void GMasterTrack::setBpm( int b )
|
|
|
|
{
|
|
|
|
bpm = b;
|
2013-09-14 04:57:58 +02:00
|
|
|
tempoDial.value( ( bpm - 60 ) / 160.f );
|
2013-09-11 00:09:45 +02:00
|
|
|
}
|
|
|
|
|
2013-11-09 22:50:21 +01:00
|
|
|
void GMasterTrack::setInputVol(float f)
|
|
|
|
{
|
2013-11-11 01:14:32 +01:00
|
|
|
//LUPPP_NOTE(" gmtrck, inputVol %f", f );
|
2013-11-09 22:50:21 +01:00
|
|
|
inputVolume.value( f );
|
|
|
|
}
|
|
|
|
|
2013-11-21 15:11:06 +01:00
|
|
|
void GMasterTrack::setReturnVol(float f)
|
|
|
|
{
|
|
|
|
LUPPP_NOTE(" gmtrck, returnVol %f", f );
|
|
|
|
returnVol.value( f );
|
|
|
|
}
|
|
|
|
|
2013-11-09 22:50:21 +01:00
|
|
|
void GMasterTrack::setInputTo(int to, float f)
|
|
|
|
{
|
2013-11-11 01:14:32 +01:00
|
|
|
//LUPPP_NOTE(" gmtrck, inputTO %i, %f", to, f );
|
2013-11-09 22:50:21 +01:00
|
|
|
if ( to == Event::INPUT_TO_MIX )
|
|
|
|
inputToMixVol.value( f );
|
2013-11-09 23:11:45 +01:00
|
|
|
else if ( to == Event::INPUT_TO_SEND )
|
2013-11-09 22:50:21 +01:00
|
|
|
inputToSendVol.value( f );
|
|
|
|
else if ( to == Event::INPUT_TO_XSIDE )
|
|
|
|
inputToSidechainSignalVol.value( f );
|
|
|
|
}
|
|
|
|
|
|
|
|
void GMasterTrack::setInputToActive(int to, bool f)
|
|
|
|
{
|
2013-11-11 01:14:32 +01:00
|
|
|
//LUPPP_NOTE(" gmtrck, inputToActive %i, %i", to, int(f) );
|
2013-11-09 23:11:45 +01:00
|
|
|
|
2013-11-09 22:50:21 +01:00
|
|
|
if ( to == Event::INPUT_TO_MIX )
|
|
|
|
inputToMix.value( f );
|
2013-11-09 23:11:45 +01:00
|
|
|
else if ( to == Event::INPUT_TO_SEND )
|
2013-11-09 22:50:21 +01:00
|
|
|
inputToSend.value( f );
|
|
|
|
else if ( to == Event::INPUT_TO_SIDE_KEY )
|
|
|
|
inputToSidechainKey.value( f );
|
|
|
|
}
|
|
|
|
|
2013-10-09 01:15:31 +02:00
|
|
|
void GMasterTrack::metronomeEnable( bool b )
|
|
|
|
{
|
|
|
|
metronomeButton.value( b );
|
|
|
|
}
|
|
|
|
|
2013-09-11 00:09:45 +02:00
|
|
|
int GMasterTrack::getBpm()
|
|
|
|
{
|
|
|
|
return bpm;
|
|
|
|
}
|
|
|
|
|
2013-09-10 22:51:05 +02:00
|
|
|
void GMasterTrack::setTapTempo( bool b )
|
|
|
|
{
|
2013-09-11 00:09:45 +02:00
|
|
|
tapTempo.setHighlight( b );
|
2013-09-10 22:51:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GMasterTrack::setBarBeat(int b, int beat)
|
|
|
|
{
|
|
|
|
if ( beat % 4 == 0 )
|
|
|
|
{
|
|
|
|
bar = bar % 4 + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int num = (beat % 4) + 1;
|
|
|
|
|
|
|
|
// turn all off
|
2013-09-10 23:23:32 +02:00
|
|
|
for( int i = 0; i < 4; i++)
|
2013-09-10 22:51:05 +02:00
|
|
|
beatLights[i]->value( 0 );
|
|
|
|
|
|
|
|
// beat starts at 4
|
|
|
|
for( int i = 0; i < num; i++)
|
2013-09-10 23:23:32 +02:00
|
|
|
beatLights[3-i]->value( 1 );
|
2013-09-10 22:51:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Avtk::Volume* GMasterTrack::getInputVolume()
|
|
|
|
{
|
|
|
|
return &inputVolume;
|
|
|
|
}
|
|
|
|
Avtk::Volume* GMasterTrack::getVolume()
|
|
|
|
{
|
|
|
|
return &volume;
|
|
|
|
}
|
|
|
|
Avtk::ClipSelector* GMasterTrack::getClipSelector()
|
|
|
|
{
|
|
|
|
return &clipSel;
|
|
|
|
}
|
|
|
|
|
|
|
|
GMasterTrack::~GMasterTrack()
|
|
|
|
{
|
|
|
|
free(title);
|
|
|
|
}
|