@@ -45,6 +45,7 @@ HEADERS = MousePlugin.h \ | |||||
../../ChannelHandler.h \ | ../../ChannelHandler.h \ | ||||
../../Sample.h \ | ../../Sample.h \ | ||||
scratch.h \ | scratch.h \ | ||||
../Widgets/Fl_LED_Button.H \ | |||||
../../../GUI/Widgets/SpiralGUI.H | ../../../GUI/Widgets/SpiralGUI.H | ||||
SOURCES = MousePlugin.C \ | SOURCES = MousePlugin.C \ | ||||
MousePluginGUI.C \ | MousePluginGUI.C \ | ||||
@@ -53,6 +54,7 @@ SOURCES = MousePlugin.C \ | |||||
../../ChannelHandler.C \ | ../../ChannelHandler.C \ | ||||
../../Sample.C \ | ../../Sample.C \ | ||||
scratch.C \ | scratch.C \ | ||||
../Widgets/Fl_LED_Button.cxx \ | |||||
../../../GUI/Widgets/SpiralGUI.C | ../../../GUI/Widgets/SpiralGUI.C | ||||
OBJECTS = MousePlugin.o \ | OBJECTS = MousePlugin.o \ | ||||
MousePluginGUI.o \ | MousePluginGUI.o \ | ||||
@@ -61,6 +63,7 @@ OBJECTS = MousePlugin.o \ | |||||
../../ChannelHandler.o \ | ../../ChannelHandler.o \ | ||||
../../Sample.o \ | ../../Sample.o \ | ||||
scratch.o \ | scratch.o \ | ||||
../Widgets/Fl_LED_Button.o \ | |||||
../../../GUI/Widgets/SpiralGUI.o | ../../../GUI/Widgets/SpiralGUI.o | ||||
INTERFACES = | INTERFACES = | ||||
UICDECLS = | UICDECLS = | ||||
@@ -128,6 +131,9 @@ install: | |||||
../../ChannelHandler.h \ | ../../ChannelHandler.h \ | ||||
../../../GUI/Widgets/SpiralGUI.H | ../../../GUI/Widgets/SpiralGUI.H | ||||
../Widgets/Fl_LED_Button.o: ../Widgets/Fl_LED_Button.cxx \ | |||||
../Widgets/Fl_LED_Button.H | |||||
../../../GUI/Widgets/SpiralGUI.o: ../../../GUI/Widgets/SpiralGUI.C \ | ../../../GUI/Widgets/SpiralGUI.o: ../../../GUI/Widgets/SpiralGUI.C \ | ||||
../../../GUI/Widgets/SpiralGUI.H | ../../../GUI/Widgets/SpiralGUI.H | ||||
@@ -148,6 +154,7 @@ MousePluginGUI.o: MousePluginGUI.C \ | |||||
MousePlugin.h \ | MousePlugin.h \ | ||||
../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
../SpiralPlugin.h \ | ../SpiralPlugin.h \ | ||||
../Widgets/Fl_LED_Button.H \ | |||||
../../../GUI/Widgets/SpiralGUI.H \ | ../../../GUI/Widgets/SpiralGUI.H \ | ||||
../../Sample.h \ | ../../Sample.h \ | ||||
scratch.h | scratch.h | ||||
@@ -18,7 +18,7 @@ | |||||
*/ | */ | ||||
#define SCRATCH_DEVICE "/dev/ttyS1" | |||||
#define SCRATCH_DEVICE "/dev/ttyS0" | |||||
#include "MousePlugin.h" | #include "MousePlugin.h" | ||||
#include "MousePluginGUI.h" | #include "MousePluginGUI.h" | ||||
@@ -38,37 +38,34 @@ string SpiralPlugin_GetGroupName() { return "InputOutput"; } | |||||
/////////////////////////////////////////////////////// | /////////////////////////////////////////////////////// | ||||
//static const HostInfo* host; | |||||
MousePluginSingleton* MousePluginSingleton::m_Singleton = NULL; | MousePluginSingleton* MousePluginSingleton::m_Singleton = NULL; | ||||
int MousePlugin::m_RefCount=0; | int MousePlugin::m_RefCount=0; | ||||
/////////////////////////////////////////////////////// | |||||
MousePluginSingleton::MousePluginSingleton() { | MousePluginSingleton::MousePluginSingleton() { | ||||
scr = new scratch(SCRATCH_DEVICE); // create scratch object | scr = new scratch(SCRATCH_DEVICE); // create scratch object | ||||
} | } | ||||
MousePluginSingleton::~MousePluginSingleton() { | MousePluginSingleton::~MousePluginSingleton() { | ||||
if (scr!=NULL) { | |||||
delete scr; | |||||
} | |||||
if (scr!=NULL) delete scr; | |||||
} | } | ||||
/////////////////////////////////////////////////////// | /////////////////////////////////////////////////////// | ||||
MousePlugin::MousePlugin(): | MousePlugin::MousePlugin(): | ||||
m_Port ('0'), | |||||
m_Data (0.0) | m_Data (0.0) | ||||
{ | { | ||||
m_RefCount++; | m_RefCount++; | ||||
m_PluginInfo.Name = "Mouse"; | m_PluginInfo.Name = "Mouse"; | ||||
m_PluginInfo.Width = 70; | |||||
m_PluginInfo.Height = 125; | |||||
m_PluginInfo.Width = 200; | |||||
m_PluginInfo.Height = 400; | |||||
m_PluginInfo.NumInputs = 1; | m_PluginInfo.NumInputs = 1; | ||||
m_PluginInfo.NumOutputs = 1; | m_PluginInfo.NumOutputs = 1; | ||||
m_PluginInfo.PortTips.push_back ("Trigger"); | m_PluginInfo.PortTips.push_back ("Trigger"); | ||||
m_PluginInfo.PortTips.push_back ("Output"); | m_PluginInfo.PortTips.push_back ("Output"); | ||||
m_AudioCH->Register ("Port", &m_Port); | |||||
m_Version = 1; | |||||
} | } | ||||
MousePlugin::~MousePlugin() { | MousePlugin::~MousePlugin() { | ||||
@@ -88,6 +85,15 @@ SpiralGUIType *MousePlugin::CreateGUI() { | |||||
return new MousePluginGUI (m_PluginInfo.Width, m_PluginInfo.Height, this, m_AudioCH, m_HostInfo); | return new MousePluginGUI (m_PluginInfo.Width, m_PluginInfo.Height, this, m_AudioCH, m_HostInfo); | ||||
} | } | ||||
void MousePlugin::ExecuteCommands () { | |||||
if (m_AudioCH->IsCommandWaiting ()) { | |||||
switch (m_AudioCH->GetCommand()) { | |||||
case (SETPORT) : // do something | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
void MousePlugin::Execute() { | void MousePlugin::Execute() { | ||||
float trigger = 1.0; | float trigger = 1.0; | ||||
if (GetOutputBuf(0)) { | if (GetOutputBuf(0)) { | ||||
@@ -15,7 +15,7 @@ | |||||
* You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | ||||
* along with this program; if not, write to the Free Software | * along with this program; if not, write to the Free Software | ||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
*/ | |||||
*/ | |||||
#ifndef MousePlugin_H | #ifndef MousePlugin_H | ||||
#define MousePlugin_H | #define MousePlugin_H | ||||
@@ -51,11 +51,13 @@ class MousePlugin : public SpiralPlugin { | |||||
virtual PluginInfo& Initialise (const HostInfo *Host); | virtual PluginInfo& Initialise (const HostInfo *Host); | ||||
virtual SpiralGUIType* CreateGUI(); | virtual SpiralGUIType* CreateGUI(); | ||||
virtual void Execute(); | virtual void Execute(); | ||||
virtual void ExecuteCommands(); | |||||
virtual void StreamOut (ostream &s); | virtual void StreamOut (ostream &s); | ||||
virtual void StreamIn (istream &s); | virtual void StreamIn (istream &s); | ||||
//float getData() { return data; } | |||||
enum GUICommands {NONE, SETPORT}; | |||||
private: | private: | ||||
static int m_RefCount; | static int m_RefCount; | ||||
char m_Port; | |||||
float m_Data; | float m_Data; | ||||
friend istream &operator>> (istream &s, MousePlugin &o); | friend istream &operator>> (istream &s, MousePlugin &o); | ||||
friend ostream &operator<< (ostream &s, MousePlugin &o); | friend ostream &operator<< (ostream &s, MousePlugin &o); | ||||
@@ -21,24 +21,18 @@ | |||||
#include <FL/fl_draw.h> | #include <FL/fl_draw.h> | ||||
#include <FL/fl_draw.H> | #include <FL/fl_draw.H> | ||||
static const int GUI_COLOUR = 154; | |||||
static const int GUIBG_COLOUR = 144; | |||||
static const int GUIBG2_COLOUR = 145; | |||||
ScratchWidget::ScratchWidget (int x, int y, int w, int h, const char *l, int BUFSIZE) : | |||||
ScratchWidget::ScratchWidget (int x, int y, int w, int h, const char *l) : | |||||
Fl_Widget (x, y, w, h, l), | Fl_Widget (x, y, w, h, l), | ||||
m_Data (0.0), | |||||
m_Channels (1), | |||||
m_Bufsize (BUFSIZE) | |||||
m_Data (0.0) | |||||
{ | { | ||||
} | } | ||||
void ScratchWidget::draw() { | void ScratchWidget::draw() { | ||||
fl_color (GUIBG_COLOUR); | |||||
fl_color (color ()); | |||||
fl_rectf (x(), y(), w(), h()); | fl_rectf (x(), y(), w(), h()); | ||||
fl_push_clip (x(), y(), w(), h()); | fl_push_clip (x(), y(), w(), h()); | ||||
int val = (int)(((m_Data * -1) + 1) * (h() / 2.0)); | int val = (int)(((m_Data * -1) + 1) * (h() / 2.0)); | ||||
fl_color (FL_WHITE); | |||||
fl_color (selection_color ()); | |||||
fl_rectf (x(), y() + val, w(), h()); | fl_rectf (x(), y() + val, w(), h()); | ||||
fl_pop_clip(); | fl_pop_clip(); | ||||
} | } | ||||
@@ -48,7 +42,23 @@ void ScratchWidget::draw() { | |||||
MousePluginGUI::MousePluginGUI (int w, int h, MousePlugin *o, ChannelHandler *ch, const HostInfo *Info) : | MousePluginGUI::MousePluginGUI (int w, int h, MousePlugin *o, ChannelHandler *ch, const HostInfo *Info) : | ||||
SpiralPluginGUI (w, h, o, ch) | SpiralPluginGUI (w, h, o, ch) | ||||
{ | { | ||||
m_Scope = new ScratchWidget (5, 20, 60, 100, "Scratch", Info->BUFSIZE); | |||||
m_Port0 = new Fl_LED_Button (0, 10, 23, 23); | |||||
m_Port0->type (FL_RADIO_BUTTON); | |||||
m_Port0->labelsize (10); | |||||
m_Port0->label ("ttyS0"); | |||||
m_Port0->set(); | |||||
m_Port0->callback ((Fl_Callback*)cb_Port0); | |||||
m_Port1 = new Fl_LED_Button (50, 10, 23, 23); | |||||
m_Port1->type (FL_RADIO_BUTTON); | |||||
m_Port1->labelsize (10); | |||||
m_Port1->label ("ttyS1"); | |||||
m_Port1->callback ((Fl_Callback*)cb_Port1); | |||||
m_Scope = new ScratchWidget (5, 40, 60, 100, "Scratch"); | |||||
m_Scope->color(Info->SCOPE_BG_COLOUR); | |||||
m_Scope->selection_color(Info->SCOPE_FG_COLOUR); | |||||
end(); | end(); | ||||
} | } | ||||
@@ -61,6 +71,24 @@ void MousePluginGUI::Update () { | |||||
void MousePluginGUI::UpdateValues (SpiralPlugin* o) { | void MousePluginGUI::UpdateValues (SpiralPlugin* o) { | ||||
} | } | ||||
inline void MousePluginGUI::cb_Port0_i (Fl_LED_Button* o, void* v) { | |||||
m_GUICH->Set("Port", '0'); | |||||
m_GUICH->SetCommand (MousePlugin::SETPORT); | |||||
} | |||||
void MousePluginGUI::cb_Port0 (Fl_LED_Button* o, void* v) { | |||||
((MousePluginGUI*)(o->parent ()))->cb_Port0 (o, v); | |||||
} | |||||
inline void MousePluginGUI::cb_Port1_i (Fl_LED_Button* o, void* v) { | |||||
m_GUICH->Set("Port", '1'); | |||||
m_GUICH->SetCommand (MousePlugin::SETPORT); | |||||
} | |||||
void MousePluginGUI::cb_Port1 (Fl_LED_Button* o, void* v) { | |||||
((MousePluginGUI*)(o->parent ()))->cb_Port1 (o, v); | |||||
} | |||||
const string MousePluginGUI::GetHelpText (const string &loc) { | const string MousePluginGUI::GetHelpText (const string &loc) { | ||||
return string("") | return string("") | ||||
+ "\n" | + "\n" | ||||
@@ -23,18 +23,13 @@ | |||||
#include <FL/Fl.H> | #include <FL/Fl.H> | ||||
#include "MousePlugin.h" | #include "MousePlugin.h" | ||||
#include "../SpiralPluginGUI.h" | #include "../SpiralPluginGUI.h" | ||||
#include "../Widgets/Fl_LED_Button.H" | |||||
class ScratchWidget : public Fl_Widget { | class ScratchWidget : public Fl_Widget { | ||||
public: | public: | ||||
ScratchWidget (int x, int y, int w, int h, const char *l, int BUFSIZE); | |||||
ScratchWidget (int x, int y, int w, int h, const char *l); | |||||
void draw(); | void draw(); | ||||
void SetNumChannels (int s) { m_Channels = s; } | |||||
float m_Data; | float m_Data; | ||||
int m_Channels; | |||||
private: | |||||
int m_GUIColour; | |||||
int m_GUIBGColour; | |||||
int m_Bufsize; | |||||
}; | }; | ||||
class MousePluginGUI : public SpiralPluginGUI { | class MousePluginGUI : public SpiralPluginGUI { | ||||
@@ -45,11 +40,12 @@ class MousePluginGUI : public SpiralPluginGUI { | |||||
protected: | protected: | ||||
const string GetHelpText (const string &loc); | const string GetHelpText (const string &loc); | ||||
private: | private: | ||||
// virtual void draw(); | |||||
// void Display(float data); | |||||
// virtual SpiralPlugin* GetPlugin() { return m_Plugin; } | |||||
// MousePlugin *m_Plugin; | |||||
ScratchWidget *m_Scope; | ScratchWidget *m_Scope; | ||||
Fl_LED_Button *m_Port0, *m_Port1; | |||||
inline void cb_Port0_i (Fl_LED_Button *o, void *v); | |||||
static void cb_Port0 (Fl_LED_Button *o, void *v); | |||||
inline void cb_Port1_i (Fl_LED_Button *o, void *v); | |||||
static void cb_Port1 (Fl_LED_Button *o, void *v); | |||||
}; | }; | ||||
#endif | #endif |
@@ -15,7 +15,7 @@ | |||||
* You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | ||||
* along with this program; if not, write to the Free Software | * along with this program; if not, write to the Free Software | ||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||||
*/ | |||||
*/ | |||||
#ifndef SCRATCH_H | #ifndef SCRATCH_H | ||||
#define SCRATCH_H | #define SCRATCH_H | ||||
@@ -29,26 +29,21 @@ | |||||
#include <iostream.h> | #include <iostream.h> | ||||
#include <pthread.h> | #include <pthread.h> | ||||
class scratch | |||||
{ | |||||
public: | |||||
scratch(char *dev); | |||||
~scratch(); | |||||
void setData(char c); | |||||
char getData(); | |||||
void stop(); | |||||
private: | |||||
pthread_t scratch_thread; | |||||
pthread_mutex_t mutex; | |||||
char data; | |||||
class scratch { | |||||
public: | |||||
scratch (char *dev); | |||||
~scratch(); | |||||
void setData(char c); | |||||
char getData(); | |||||
void stop(); | |||||
private: | |||||
pthread_t scratch_thread; | |||||
pthread_mutex_t mutex; | |||||
char data; | |||||
}; | }; | ||||
void openSerialPort(char *dev); | |||||
void openSerialPort (char *dev); | |||||
void closeSerialPort(); | void closeSerialPort(); | ||||
void listen(scratch *scr); | |||||
void listen (scratch *scr); | |||||
#endif | #endif |
@@ -1402,7 +1402,7 @@ inline void SynthModular::cb_Connection_i(Fl_Canvas* o, void* v) | |||||
} | } | ||||
if (!di->second->m_Device->SetInput(Wire->InputPort,(const Sample*)sample)) | if (!di->second->m_Device->SetInput(Wire->InputPort,(const Sample*)sample)) | ||||
{ | |||||
{ | |||||
char num[32]; | char num[32]; | ||||
sprintf(num,"%d,%d",Wire->InputID,Wire->InputPort); | sprintf(num,"%d,%d",Wire->InputID,Wire->InputPort); | ||||
SpiralInfo::Alert("Warning: Connection problem - can't find source input "+string(num)); | SpiralInfo::Alert("Warning: Connection problem - can't find source input "+string(num)); | ||||
@@ -1455,12 +1455,12 @@ void SynthModular::LoadPatch(const char *fn) | |||||
{ | { | ||||
ifstream in(fn); | ifstream in(fn); | ||||
if (in) | |||||
{ | |||||
if (in) | |||||
{ | |||||
fstream inf; | fstream inf; | ||||
inf.open(fn, std::ios::in); | inf.open(fn, std::ios::in); | ||||
m_FilePath=fn; | |||||
m_FilePath=fn; | |||||
ClearUp(); | ClearUp(); | ||||
inf>>*this; | inf>>*this; | ||||