2013-04-20 13:20:46 +02:00
|
|
|
|
|
|
|
#ifndef LUPPP_G_TRACK_H
|
|
|
|
#define LUPPP_G_TRACK_H
|
|
|
|
|
2013-05-13 23:04:12 +02:00
|
|
|
#include <iostream>
|
|
|
|
|
2013-04-20 13:20:46 +02:00
|
|
|
#include <FL/Fl.H>
|
|
|
|
#include <FL/Fl_Group.H>
|
|
|
|
#include <FL/Fl_Slider.H>
|
2013-05-16 14:38:46 +02:00
|
|
|
#include <FL/Fl_Progress.H>
|
2013-05-20 00:57:12 +02:00
|
|
|
#include <FL/Fl_Native_File_Chooser.H>
|
2013-04-20 13:20:46 +02:00
|
|
|
|
2013-05-13 03:43:44 +02:00
|
|
|
#include "avtk/avtk_dial.h"
|
2013-04-20 13:20:46 +02:00
|
|
|
#include "avtk/avtk_button.h"
|
2013-05-13 03:43:44 +02:00
|
|
|
#include "avtk/avtk_background.h"
|
2013-04-20 13:20:46 +02:00
|
|
|
|
2013-05-13 23:04:12 +02:00
|
|
|
|
2013-05-20 00:57:12 +02:00
|
|
|
#include "worker.hxx"
|
|
|
|
#include "audiobuffer.hxx"
|
2013-05-13 23:04:12 +02:00
|
|
|
#include "eventhandler.hxx"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2013-05-20 00:57:12 +02:00
|
|
|
static string choose_file()
|
|
|
|
{
|
|
|
|
string path;
|
|
|
|
Fl_Native_File_Chooser fnfc;
|
|
|
|
fnfc.title("Pick a file");
|
|
|
|
fnfc.type(Fl_Native_File_Chooser::BROWSE_FILE);
|
|
|
|
//fnfc.filter("Wav\t*.wav");
|
|
|
|
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 directory: %s\n", fnfc.filename());
|
|
|
|
|
|
|
|
// update path and load it
|
|
|
|
path = fnfc.filename();
|
|
|
|
|
|
|
|
break; // FILE CHOSEN
|
|
|
|
}
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2013-05-16 00:27:31 +02:00
|
|
|
static void gtrack_button_callback(Fl_Widget *w, void *data) {
|
2013-05-16 18:45:46 +02:00
|
|
|
int track = 0;
|
|
|
|
if ( data )
|
|
|
|
track = *(int*)data;
|
2013-05-16 16:17:49 +02:00
|
|
|
//cout << "Button " << *(int*)data << " " << w->label() << " clicked" << endl;
|
2013-05-13 23:04:12 +02:00
|
|
|
|
|
|
|
if ( strcmp( w->label() , "Rec" ) == 0 )
|
|
|
|
{
|
2013-05-15 05:05:36 +02:00
|
|
|
EventLooperState e = EventLooperState(track,Looper::STATE_RECORD_QUEUED);
|
2013-05-13 23:04:12 +02:00
|
|
|
writeToDspRingbuffer( &e );
|
|
|
|
}
|
|
|
|
else if ( strcmp( w->label() , "Play" ) == 0 )
|
|
|
|
{
|
2013-05-15 05:05:36 +02:00
|
|
|
EventLooperState e = EventLooperState(track,Looper::STATE_PLAY_QUEUED);
|
2013-05-13 23:04:12 +02:00
|
|
|
writeToDspRingbuffer( &e );
|
|
|
|
}
|
2013-05-13 23:20:00 +02:00
|
|
|
else if ( strcmp( w->label() , "Stop" ) == 0 )
|
|
|
|
{
|
2013-05-15 05:05:36 +02:00
|
|
|
EventLooperState e = EventLooperState(track,Looper::STATE_STOP_QUEUED);
|
2013-05-13 23:20:00 +02:00
|
|
|
writeToDspRingbuffer( &e );
|
|
|
|
}
|
2013-05-16 02:38:11 +02:00
|
|
|
else if ( strcmp( w->label() , "+" ) == 0 )
|
|
|
|
{
|
|
|
|
EventLooperLoopLength e = EventLooperLoopLength(track, 2);
|
|
|
|
writeToDspRingbuffer( &e );
|
|
|
|
}
|
|
|
|
else if ( strcmp( w->label() , "-" ) == 0 )
|
|
|
|
{
|
|
|
|
EventLooperLoopLength e = EventLooperLoopLength(track, 0.5);
|
|
|
|
writeToDspRingbuffer( &e );
|
|
|
|
}
|
2013-05-20 00:57:12 +02:00
|
|
|
else if ( strcmp( w->label() , "Load" ) == 0 )
|
|
|
|
{
|
|
|
|
AudioBuffer* ab = Worker::loadSample( choose_file() );
|
|
|
|
EventLooperLoad e = EventLooperLoad( track, 0 , ab );
|
2013-05-20 02:08:10 +02:00
|
|
|
cout << "writing event ab ptr = " << ab << endl;
|
2013-05-20 00:57:12 +02:00
|
|
|
writeToDspRingbuffer( &e );
|
2013-05-20 02:08:10 +02:00
|
|
|
cout << "writing event done" << endl;
|
2013-05-20 00:57:12 +02:00
|
|
|
}
|
2013-05-16 18:16:18 +02:00
|
|
|
else if ( strcmp( w->label() , "Vol" ) == 0 )
|
|
|
|
{
|
2013-05-16 18:45:46 +02:00
|
|
|
|
2013-05-16 18:16:18 +02:00
|
|
|
}
|
2013-05-15 03:17:08 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
cout << __FILE__ << __LINE__ << " Error: unknown command string" << endl;
|
|
|
|
}
|
2013-05-13 23:04:12 +02:00
|
|
|
}
|
|
|
|
|
2013-04-20 13:20:46 +02:00
|
|
|
class GTrack : public Fl_Group
|
|
|
|
{
|
|
|
|
public:
|
2013-05-13 03:43:44 +02:00
|
|
|
GTrack(int x, int y, int w, int h, const char* l = 0 ) :
|
2013-04-20 13:20:46 +02:00
|
|
|
Fl_Group(x, y, w, h),
|
2013-05-13 22:11:21 +02:00
|
|
|
title( strdup(l) ),
|
|
|
|
bg( x, y , w, h, title ),
|
2013-05-13 03:43:44 +02:00
|
|
|
|
2013-07-21 16:47:35 +02:00
|
|
|
button1(x + 5, y + 324, 100, 18,"Rec"),
|
|
|
|
button2(x + 5, y + 344, 100, 18,"Play"),
|
|
|
|
button3(x + 5, y + 364, 100, 18,"Stop"),
|
|
|
|
button4(x + 5, y + 384, 48, 18,"-"),
|
|
|
|
button5(x +57, y + 384, 48, 18,"+"),
|
2013-05-16 02:38:11 +02:00
|
|
|
|
2013-07-21 16:47:35 +02:00
|
|
|
button6(x + 5, y + 404, 100, 18,"Load"),
|
2013-05-13 03:43:44 +02:00
|
|
|
|
2013-07-21 16:47:35 +02:00
|
|
|
volume(x+55-22, y +490, 34, 34, "Vol"),
|
2013-05-16 18:16:18 +02:00
|
|
|
|
2013-07-21 16:47:35 +02:00
|
|
|
dial1(x+15, y +455, 24, 24, "A"),
|
|
|
|
dial2(x+45, y +455, 24, 24, "B"),
|
|
|
|
dial3(x+75, y +455, 24, 24, "C"),
|
2013-05-16 14:38:46 +02:00
|
|
|
|
2013-07-21 16:47:35 +02:00
|
|
|
progress(x+5, y+428, 100, 18, "")
|
2013-04-20 13:20:46 +02:00
|
|
|
{
|
2013-05-15 03:17:08 +02:00
|
|
|
ID = privateID++;
|
|
|
|
|
2013-05-16 00:27:31 +02:00
|
|
|
button1.callback( gtrack_button_callback, &ID );
|
|
|
|
button2.callback( gtrack_button_callback, &ID );
|
|
|
|
button3.callback( gtrack_button_callback, &ID );
|
|
|
|
button4.callback( gtrack_button_callback, &ID );
|
|
|
|
button5.callback( gtrack_button_callback, &ID );
|
|
|
|
button6.callback( gtrack_button_callback, &ID );
|
2013-05-13 23:04:12 +02:00
|
|
|
|
2013-05-16 18:16:18 +02:00
|
|
|
volume.callback( gtrack_button_callback, 0 );
|
|
|
|
|
2013-05-16 14:38:46 +02:00
|
|
|
progress.maximum(1.0f);
|
|
|
|
progress.minimum(0.0f);
|
2013-07-21 16:47:35 +02:00
|
|
|
progress.color( fl_color_cube(0.2 * (FL_NUM_RED - 1) / 255,
|
|
|
|
0.2 * (FL_NUM_GREEN - 1) / 255,
|
|
|
|
0.2 * (FL_NUM_BLUE - 1) / 255) );
|
|
|
|
progress.selection_color( FL_BLUE );
|
|
|
|
/*
|
|
|
|
00366 Fl_Color color() const {return color_;}
|
|
|
|
00367
|
|
|
|
00378 void color(Fl_Color bg) {color_ = bg;}
|
|
|
|
00379
|
|
|
|
00384 Fl_Color selection_color() const {return color2_;}
|
|
|
|
00385
|
|
|
|
00394 void selection_color(Fl_Color a) {color2_ = a;}
|
|
|
|
00395
|
|
|
|
00403 void color(Fl_Color bg, Fl_Color sel) {color_=bg; color2_=sel;}
|
|
|
|
00404
|
|
|
|
*/
|
|
|
|
|
2013-05-16 14:38:46 +02:00
|
|
|
|
2013-04-20 13:20:46 +02:00
|
|
|
end(); // close the group
|
|
|
|
}
|
|
|
|
|
2013-05-13 22:11:21 +02:00
|
|
|
~GTrack()
|
|
|
|
{
|
|
|
|
free(title);
|
|
|
|
}
|
|
|
|
|
2013-05-15 03:17:08 +02:00
|
|
|
int ID;
|
|
|
|
|
2013-05-13 22:11:21 +02:00
|
|
|
char* title;
|
|
|
|
|
2013-05-13 03:43:44 +02:00
|
|
|
Avtk::Background bg;
|
|
|
|
|
|
|
|
Avtk::Button button1;
|
|
|
|
Avtk::Button button2;
|
|
|
|
Avtk::Button button3;
|
|
|
|
Avtk::Button button4;
|
|
|
|
Avtk::Button button5;
|
|
|
|
Avtk::Button button6;
|
|
|
|
|
2013-05-16 18:16:18 +02:00
|
|
|
Avtk::Dial volume;
|
|
|
|
|
2013-05-16 14:38:46 +02:00
|
|
|
Avtk::Dial dial1;
|
|
|
|
Avtk::Dial dial2;
|
|
|
|
Avtk::Dial dial3;
|
2013-05-13 03:43:44 +02:00
|
|
|
|
2013-05-16 14:38:46 +02:00
|
|
|
Fl_Progress progress;
|
2013-05-13 22:11:21 +02:00
|
|
|
|
2013-05-13 03:43:44 +02:00
|
|
|
static int privateID;
|
2013-04-20 13:20:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LUPPP_G_TRACK_H
|
|
|
|
|