@@ -93,7 +93,7 @@ void ChannelHandler::UpdateDataNow() | |||
// one off request type | |||
case OUTPUT_REQUEST : | |||
{ | |||
if (m_BulkID==i->first) | |||
if (m_BulkID==i->first && ch->requested) | |||
{ | |||
if (m_BulkPos!=-1) | |||
{ | |||
@@ -103,6 +103,7 @@ void ChannelHandler::UpdateDataNow() | |||
// last transfer | |||
#ifdef CHANNEL_DEBUG | |||
cerr<<"memcpy (last) bulk output channel: ["<<i->first<<"]"<<endl; | |||
cerr<<"pos:"<<m_BulkPos<<" size:"<<m_BulkSize<<" chsize:"<<ch->size<<endl; | |||
#endif | |||
memcpy(ch->data_buf,((char*)m_BulkSrc)+m_BulkPos,m_BulkSize-m_BulkPos); | |||
m_BulkPos=-1; | |||
@@ -111,11 +112,13 @@ void ChannelHandler::UpdateDataNow() | |||
{ | |||
#ifdef CHANNEL_DEBUG | |||
cerr<<"memcpy bulk output channel: ["<<i->first<<"]"<<endl; | |||
cerr<<"pos:"<<m_BulkPos<<" size:"<<m_BulkSize<<endl; | |||
#endif | |||
memcpy(ch->data_buf,((char*)m_BulkSrc)+m_BulkPos,ch->size); | |||
m_BulkPos+=ch->size; | |||
} | |||
ch->updated=true; | |||
ch->requested=false; | |||
} | |||
} | |||
else | |||
@@ -128,6 +131,7 @@ void ChannelHandler::UpdateDataNow() | |||
#endif | |||
memcpy(ch->data_buf,ch->data,ch->size); | |||
ch->updated=true; | |||
ch->requested=false; | |||
} | |||
} | |||
} break; | |||
@@ -46,20 +46,24 @@ string GetGroupName() | |||
/////////////////////////////////////////////////////// | |||
FlipflopPlugin::FlipflopPlugin() : | |||
m_Count(4), | |||
m_TriggerTime(0.01f), | |||
m_Monostable(false), | |||
m_Current(0), | |||
m_Triggered(false), | |||
m_CurrentLevel(1.0f) | |||
m_CurrentLevel(1.0f), | |||
m_TriggerSamples(0) | |||
{ | |||
m_Version = 2; | |||
m_PluginInfo.Name="Flipflop"; | |||
m_PluginInfo.Width=90; | |||
m_PluginInfo.Height=80; | |||
m_PluginInfo.Width=70; | |||
m_PluginInfo.Height=100; | |||
m_PluginInfo.NumInputs=1; | |||
m_PluginInfo.NumOutputs=1; | |||
m_PluginInfo.PortTips.push_back("Input"); | |||
m_PluginInfo.PortTips.push_back("Output"); | |||
m_AudioCH->Register("Count",&m_Count); | |||
m_AudioCH->Register("TriggerTime",&m_TriggerTime); | |||
m_AudioCH->Register("Monostable",&m_Monostable); | |||
} | |||
FlipflopPlugin::~FlipflopPlugin() | |||
@@ -73,32 +77,65 @@ PluginInfo &FlipflopPlugin::Initialise(const HostInfo *Host) | |||
SpiralGUIType *FlipflopPlugin::CreateGUI() | |||
{ | |||
return NULL; | |||
return new FlipflopPluginGUI(m_PluginInfo.Width, | |||
m_PluginInfo.Height, | |||
this,m_AudioCH,m_HostInfo); | |||
} | |||
void FlipflopPlugin::Execute() | |||
{ | |||
bool Triggered; | |||
for (int n=0; n<m_HostInfo->BUFSIZE; n++) | |||
if (m_Monostable) | |||
{ | |||
if (GetInput(0,n)>0) | |||
for (int n=0; n<m_HostInfo->BUFSIZE; n++) | |||
{ | |||
if(!m_Triggered) | |||
if (GetInput(0,n)>0) | |||
{ | |||
m_Triggered=true; | |||
m_CurrentLevel=-m_CurrentLevel; | |||
if(!m_Triggered) | |||
{ | |||
m_Triggered=true; | |||
m_CurrentLevel=1.0f; | |||
m_TriggerSamples=(int)(m_TriggerTime*m_HostInfo->SAMPLERATE)+1; | |||
} | |||
} | |||
} | |||
else | |||
{ | |||
if (m_Triggered) | |||
else | |||
{ | |||
m_Triggered=false; | |||
} | |||
if (m_TriggerSamples<=0) | |||
{ | |||
m_CurrentLevel=-1.0f; | |||
} | |||
if (m_TriggerSamples>0) m_TriggerSamples--; | |||
SetOutput(0,n,m_CurrentLevel); | |||
} | |||
} | |||
else | |||
{ | |||
for (int n=0; n<m_HostInfo->BUFSIZE; n++) | |||
{ | |||
if (GetInput(0,n)>0) | |||
{ | |||
if(!m_Triggered) | |||
{ | |||
m_Triggered=true; | |||
m_CurrentLevel=-m_CurrentLevel; | |||
} | |||
} | |||
else | |||
{ | |||
if (m_Triggered) | |||
{ | |||
m_Triggered=false; | |||
} | |||
} | |||
SetOutput(0,n,m_CurrentLevel); | |||
} | |||
SetOutput(0,n,m_CurrentLevel); | |||
} | |||
} | |||
@@ -108,11 +145,16 @@ void FlipflopPlugin::ExecuteCommands() | |||
void FlipflopPlugin::StreamOut(ostream &s) | |||
{ | |||
s<<m_Version<<endl; | |||
s<<m_Version<<" "; | |||
s<<m_TriggerTime<<" "<<m_Monostable<<" "<<endl; | |||
} | |||
void FlipflopPlugin::StreamIn(istream &s) | |||
{ | |||
int version; | |||
s>>version; | |||
if (version>1) | |||
{ | |||
s>>m_TriggerTime>>m_Monostable; | |||
} | |||
} |
@@ -35,13 +35,16 @@ public: | |||
virtual void StreamOut(ostream &s); | |||
virtual void StreamIn(istream &s); | |||
int GetCount() { return m_Count; } | |||
float GetTriggerTime() { return m_TriggerTime; } | |||
bool GetMonostable() { return m_Monostable; } | |||
private: | |||
int m_Count; | |||
float m_TriggerTime; | |||
bool m_Monostable; | |||
int m_Current; | |||
bool m_Triggered; | |||
float m_CurrentLevel; | |||
int m_TriggerSamples; | |||
}; | |||
#endif |
@@ -29,6 +29,20 @@ static const int GUIBG2_COLOUR = 145; | |||
FlipflopPluginGUI::FlipflopPluginGUI(int w, int h,FlipflopPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | |||
SpiralPluginGUI(w,h,o,ch) | |||
{ | |||
m_TriggerTime = new Fl_Knob(15, 15, 40, 40, "Trigger Time"); | |||
m_TriggerTime->color(GUI_COLOUR); | |||
m_TriggerTime->labelsize(8); | |||
m_TriggerTime->maximum(1.0f); | |||
m_TriggerTime->minimum(0.0f); | |||
m_TriggerTime->step(0.0001f); | |||
m_TriggerTime->labelsize(8); | |||
m_TriggerTime->callback((Fl_Callback*)cb_TriggerTime); | |||
m_Monostable = new Fl_Button(5,75,60,20,"Monostable"); | |||
m_Monostable->labelsize(8); | |||
m_Monostable->type(1); | |||
m_Monostable->callback((Fl_Callback*)cb_Monostable); | |||
end(); | |||
} | |||
@@ -36,10 +50,35 @@ SpiralPluginGUI(w,h,o,ch) | |||
void FlipflopPluginGUI::UpdateValues(SpiralPlugin *o) | |||
{ | |||
FlipflopPlugin* Plugin=(FlipflopPlugin*)o; | |||
m_TriggerTime->value(Plugin->GetTriggerTime()); | |||
m_Monostable->value(Plugin->GetMonostable()); | |||
} | |||
//// Callbacks //// | |||
inline void FlipflopPluginGUI::cb_TriggerTime_i(Fl_Knob* o, void* v) | |||
{ | |||
m_GUICH->Set("TriggerTime",(float)o->value()); | |||
} | |||
void FlipflopPluginGUI::cb_TriggerTime(Fl_Knob* o, void* v) | |||
{ ((FlipflopPluginGUI*)(o->parent()))->cb_TriggerTime_i(o,v);} | |||
inline void FlipflopPluginGUI::cb_Monostable_i(Fl_Button* o, void* v) | |||
{ | |||
m_GUICH->Set("Monostable",(bool)o->value()); | |||
} | |||
void FlipflopPluginGUI::cb_Monostable(Fl_Button* o, void* v) | |||
{ ((FlipflopPluginGUI*)(o->parent()))->cb_Monostable_i(o,v);} | |||
const string FlipflopPluginGUI::GetHelpText(const string &loc){ | |||
return string("") | |||
+ "Converts a momentary pulse into a sustained one."; | |||
+ "This plugin has two modes, bistable (the default) converts momentary\n" | |||
+ "pulses into sustained pulses, i.e one pulse to set the output to 1.0,\n" | |||
+ "and another pulse to flip it back to -1.0.\n\n" | |||
+ "Monostable mode is sort of the reverse, any input pulse detected will\n" | |||
+ "cause an output pulse to be generated, the length of which is set by the\n" | |||
+ "trigger time control (out of 1 second max)\n\n" | |||
+ "For a better description, google \"flipflop bistable monostable\" :)"; | |||
} |
@@ -42,8 +42,14 @@ protected: | |||
const string GetHelpText(const string &loc); | |||
private: | |||
Fl_Knob *m_TriggerTime; | |||
Fl_Button *m_Monostable; | |||
//// Callbacks //// | |||
inline void cb_TriggerTime_i(Fl_Knob* o, void*); | |||
static void cb_TriggerTime(Fl_Knob* o, void*); | |||
inline void cb_Monostable_i(Fl_Button* o, void*); | |||
static void cb_Monostable(Fl_Button* o, void*); | |||
}; | |||
#endif |
@@ -50,6 +50,7 @@ HEADERS = ../SpiralPlugin.h \ | |||
Fl_Trigger.h \ | |||
SpiralLoopPlugin.h \ | |||
SpiralLoopPluginGUI.h \ | |||
../Widgets/Fl_DragBar.H \ | |||
../Widgets/Fl_Knob.H \ | |||
../Widgets/Fl_LED_Button.H | |||
SOURCES = ../SpiralPlugin.C \ | |||
@@ -61,6 +62,7 @@ SOURCES = ../SpiralPlugin.C \ | |||
Fl_Trigger.C \ | |||
SpiralLoopPlugin.C \ | |||
SpiralLoopPluginGUI.C \ | |||
../Widgets/Fl_DragBar.cxx \ | |||
../Widgets/Fl_Knob.cxx \ | |||
../Widgets/Fl_LED_Button.cxx | |||
OBJECTS = ../SpiralPlugin.o \ | |||
@@ -72,6 +74,7 @@ OBJECTS = ../SpiralPlugin.o \ | |||
Fl_Trigger.o \ | |||
SpiralLoopPlugin.o \ | |||
SpiralLoopPluginGUI.o \ | |||
../Widgets/Fl_DragBar.o \ | |||
../Widgets/Fl_Knob.o \ | |||
../Widgets/Fl_LED_Button.o | |||
INTERFACES = | |||
@@ -142,6 +145,9 @@ install: | |||
../SpiralPlugin.h \ | |||
../../Sample.h | |||
../Widgets/Fl_DragBar.o: ../Widgets/Fl_DragBar.cxx \ | |||
../Widgets/Fl_DragBar.H | |||
../../Sample.o: ../../Sample.C \ | |||
../../Sample.h \ | |||
../../SpiralInfo.h | |||
@@ -28,9 +28,12 @@ static const int GUI_COLOUR = 154; | |||
static const int GUIBG_COLOUR = 144; | |||
static const int GUIBG2_COLOUR = 145; | |||
Fl_Double_Window* SpiralPluginGUI::m_HelpWin=NULL; | |||
Fl_Text_Display* SpiralPluginGUI::m_HelpWin_text=NULL; | |||
SpiralPluginGUI* SpiralPluginGUI::Help_owner=NULL; | |||
SpiralPluginGUI::SpiralPluginGUI(int w, int h, SpiralPlugin* o, ChannelHandler *ch) : | |||
SpiralGUIType(0,0,w,h,""), | |||
m_HelpWin(NULL) | |||
SpiralGUIType(0,0,w,h,"") | |||
{ | |||
Fl::visible_focus(false); | |||
@@ -75,29 +78,47 @@ inline void SpiralPluginGUI::cb_Hide_i(Fl_Button* o, void* v) | |||
void SpiralPluginGUI::cb_Hide(Fl_Button* o, void* v) | |||
{ ((SpiralPluginGUI*)(o->parent()))->cb_Hide_i(o,v); } | |||
// Boo - changed to use one 'global' help win. for all plugins, coz Fl_Text_Display | |||
// seems to be too buggy to create and destroy it multiple times. | |||
// (symptom was - ssm crashes after opening/closing plugin help window 4-7 times) | |||
// (i use FLTK 1.1.0 rc7) | |||
inline void SpiralPluginGUI::cb_Help_i(Fl_Button* o, void* v) | |||
{ | |||
//Boo - create 'global' help window | |||
if (m_HelpWin==NULL) | |||
{ | |||
int w=450,h=200; | |||
m_HelpWin = new Fl_Double_Window(w,h,"Help"); | |||
int h_w=450,h_h=200; | |||
m_HelpWin = new Fl_Double_Window(h_w,h_h,"Help"); | |||
Fl_Text_Display* text = new Fl_Text_Display(0,0,10,10); | |||
text->buffer(new Fl_Text_Buffer); | |||
text->insert(GetHelpText(SpiralInfo::LOCALE).c_str()); | |||
text->textsize(12); | |||
m_HelpWin->add(text); | |||
m_HelpWin->resizable(text); | |||
m_HelpWin->show(); | |||
text->size(w,h); // hack to get the text widget to appear??? | |||
m_HelpWin_text = new Fl_Text_Display(0,0,h_w,h_h); | |||
m_HelpWin_text->buffer(new Fl_Text_Buffer); | |||
m_HelpWin_text->textsize(12); | |||
m_HelpWin->add(m_HelpWin_text); | |||
m_HelpWin->resizable(m_HelpWin_text); | |||
m_HelpWin->callback((Fl_Callback*)cb_Help_close); | |||
} | |||
else | |||
if(Help_owner!=this) | |||
{ | |||
m_HelpWin->hide(); | |||
delete m_HelpWin; | |||
m_HelpWin=NULL; | |||
m_HelpWin_text->buffer()->text(GetHelpText(SpiralInfo::LOCALE).c_str()); | |||
m_HelpWin->show(); | |||
Help_owner=this; | |||
} | |||
else cb_Help_close_i(m_HelpWin, NULL); | |||
} | |||
void SpiralPluginGUI::cb_Help(Fl_Button* o, void* v) | |||
{ ((SpiralPluginGUI*)(o->parent()))->cb_Help_i(o,v); } | |||
inline void SpiralPluginGUI::cb_Help_close_i(Fl_Double_Window* w, void* v) | |||
{ | |||
w->hide(); | |||
Help_owner=NULL; | |||
} | |||
void SpiralPluginGUI::cb_Help_close(Fl_Double_Window* w, void* v) | |||
{ ((SpiralPluginGUI*)(w->parent()))->cb_Help_close_i(w,v); } | |||
@@ -19,6 +19,7 @@ | |||
#include <FL/Fl.H> | |||
#include <FL/Fl_Double_Window.H> | |||
#include <FL/Fl_Button.H> | |||
#include <FL/Fl_Text_Display.H> | |||
#include <iostream> | |||
#include <math.h> | |||
@@ -50,7 +51,10 @@ protected: | |||
private: | |||
Fl_Button* m_Hide; | |||
Fl_Button* m_Help; | |||
Fl_Double_Window *m_HelpWin; | |||
static Fl_Double_Window* m_HelpWin; | |||
static Fl_Text_Display* m_HelpWin_text; | |||
static SpiralPluginGUI* Help_owner; | |||
string m_Title; | |||
@@ -59,6 +63,8 @@ private: | |||
static void cb_Hide(Fl_Button*, void*); | |||
inline void cb_Help_i(Fl_Button* o, void* v); | |||
static void cb_Help(Fl_Button*, void*); | |||
inline void cb_Help_close_i(Fl_Double_Window* w, void* v); | |||
static void cb_Help_close(Fl_Double_Window*, void*); | |||
}; | |||
#endif |