| @@ -0,0 +1,312 @@ | |||||
| /* SpiralSound | |||||
| * Copyleft (C) 2002 David Griffiths <dave@pawfal.org> | |||||
| * | |||||
| * This program is free software; you can redistribute it and/or modify | |||||
| * it under the terms of the GNU General Public License as published by | |||||
| * the Free Software Foundation; either version 2 of the License, or | |||||
| * (at your option) any later version. | |||||
| * | |||||
| * This program is distributed in the hope that it will be useful, | |||||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| * GNU General Public License for more details. | |||||
| * | |||||
| * You should have received a copy of the GNU General Public License | |||||
| * along with this program; if not, write to the Free Software | |||||
| * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||||
| */ | |||||
| #include "ChannelHandler.h" | |||||
| #include <unistd.h> | |||||
| ChannelHandler::ChannelHandler() : | |||||
| m_UpdateIndicator(false) | |||||
| { | |||||
| m_Mutex = new pthread_mutex_t; | |||||
| m_Command[0]=0; | |||||
| m_Command[1]=0; | |||||
| m_BulkSrc=NULL; | |||||
| m_BulkSize=0; | |||||
| m_BulkPos=-1; | |||||
| pthread_mutex_init(m_Mutex,NULL); | |||||
| } | |||||
| ChannelHandler::~ChannelHandler() | |||||
| { | |||||
| for(map<string,Channel*>::iterator i=m_ChannelMap.begin(); | |||||
| i!=m_ChannelMap.end(); i++) | |||||
| { | |||||
| free(i->second->data_buf); | |||||
| delete i->second; | |||||
| } | |||||
| pthread_mutex_destroy(m_Mutex); | |||||
| delete m_Mutex; | |||||
| } | |||||
| /////////////////////////////////////////////////////////////// | |||||
| void ChannelHandler::UpdateDataNow() | |||||
| { | |||||
| // make sure the command is cleared even if | |||||
| // we can't get a lock on the data | |||||
| m_Command[0]=0; | |||||
| if (pthread_mutex_trylock(m_Mutex)) | |||||
| { | |||||
| m_UpdateIndicator=!m_UpdateIndicator; | |||||
| for(map<string, Channel*>::iterator i=m_ChannelMap.begin(); | |||||
| i!=m_ChannelMap.end(); i++) | |||||
| { | |||||
| Channel *ch = i->second; | |||||
| switch (ch->type) | |||||
| { | |||||
| case INPUT : | |||||
| { | |||||
| memcpy(ch->data,ch->data_buf,ch->size); | |||||
| } break; | |||||
| case OUTPUT : | |||||
| { | |||||
| memcpy(ch->data_buf,ch->data,ch->size); | |||||
| } break; | |||||
| // one off request type | |||||
| case OUTPUT_REQUEST : | |||||
| { | |||||
| if (m_BulkPos!=-1 && m_BulkID==i->first) | |||||
| { | |||||
| // doing a bulk transfer | |||||
| if (m_BulkPos+ch->size>m_BulkSize) | |||||
| { | |||||
| // last transfer | |||||
| memcpy(ch->data_buf,((char*)m_BulkSrc)+m_BulkPos,m_BulkSize-m_BulkPos); | |||||
| m_BulkPos=-1; | |||||
| } | |||||
| else | |||||
| { | |||||
| memcpy(ch->data_buf,((char*)m_BulkSrc)+m_BulkPos,ch->size); | |||||
| m_BulkPos+=ch->size; | |||||
| } | |||||
| ch->updated=true; | |||||
| } | |||||
| else | |||||
| { | |||||
| // normal request transfer | |||||
| if (ch->requested) | |||||
| { | |||||
| memcpy(ch->data_buf,ch->data,ch->size); | |||||
| ch->updated=true; | |||||
| } | |||||
| } | |||||
| } break; | |||||
| } | |||||
| } | |||||
| m_Command[0]=m_Command[1]; | |||||
| // make sure the command only lasts one update | |||||
| m_Command[1]=0; | |||||
| pthread_mutex_unlock(m_Mutex); | |||||
| //cerr<<"audio out mutex"<<endl; | |||||
| //cerr<<"Update succeeded"<<endl; | |||||
| } | |||||
| else | |||||
| { | |||||
| //cerr<<"Couldn't get lock"<<endl; | |||||
| } | |||||
| } | |||||
| void ChannelHandler::RegisterData(const string &ID, Type t,void* pData, int size) | |||||
| { | |||||
| // probably don't need to lock here, as if get/set are called before | |||||
| // the channels have been set up they won't work anyway, but... | |||||
| //pthread_mutex_lock(m_Mutex); | |||||
| cerr<<"Registering ["<<ID<<"] "<<hex<<pData<<dec<<" as "<<size<<" bytes big"<<endl; | |||||
| map<string,Channel*>::iterator i=m_ChannelMap.find(ID); | |||||
| if (i!=m_ChannelMap.end()) | |||||
| { | |||||
| cerr<<"Channel with ID ["<<ID<<"] already exists"<<endl; | |||||
| } | |||||
| Channel *NewCh=new Channel(t); | |||||
| NewCh->data_buf = malloc(size); | |||||
| NewCh->size = size; | |||||
| NewCh->data = pData; | |||||
| NewCh->requested = false; | |||||
| NewCh->updated = false; | |||||
| memcpy(NewCh->data_buf,NewCh->data,size); | |||||
| m_ChannelMap[ID]=NewCh; | |||||
| //pthread_mutex_unlock(m_Mutex); | |||||
| } | |||||
| ///////////////////////////////////////////////////////////////////////// | |||||
| void ChannelHandler::GetData(const string &ID, void *data) | |||||
| { | |||||
| map<string,Channel*>::iterator i=m_ChannelMap.find(ID); | |||||
| if (i==m_ChannelMap.end()) | |||||
| { | |||||
| cerr<<"ChannelHandler: Channel ["<<ID<<"] does not exist"<<endl; | |||||
| return; | |||||
| } | |||||
| if (!data) | |||||
| { | |||||
| cerr<<"ChannelHandler: Can't copy data to uninitialised mem"<<endl; | |||||
| return; | |||||
| } | |||||
| pthread_mutex_lock(m_Mutex); | |||||
| if (i->second->type==OUTPUT || i->second->type==OUTPUT_REQUEST) | |||||
| { | |||||
| memcpy(data,i->second->data_buf,i->second->size); | |||||
| } | |||||
| else | |||||
| { | |||||
| cerr<<"ChannelHandler: Tried to Get() data registered as input"<<endl; | |||||
| }//cerr<<"unlock 1"<<endl; | |||||
| pthread_mutex_unlock(m_Mutex); | |||||
| } | |||||
| void ChannelHandler::SetData(const string &ID, void *s) | |||||
| { | |||||
| map<string,Channel*>::iterator i=m_ChannelMap.find(ID); | |||||
| if (i==m_ChannelMap.end()) | |||||
| { | |||||
| cerr<<"ChannelHandler: Channel ["<<ID<<"] does not exist"<<endl; | |||||
| return; | |||||
| } | |||||
| //cerr<<"lock 2"<<endl; | |||||
| pthread_mutex_lock(m_Mutex); | |||||
| //cerr<<"lock 2 ok"<<endl; | |||||
| if (i->second->type==INPUT) | |||||
| { | |||||
| memcpy(i->second->data_buf,s,i->second->size); | |||||
| } | |||||
| else | |||||
| { | |||||
| cerr<<"ChannelHandler: Tried to Set() data registered as output"<<endl; | |||||
| }//cerr<<"unlock 2"<<endl; | |||||
| pthread_mutex_unlock(m_Mutex); | |||||
| } | |||||
| void ChannelHandler::SetCommand(char command) | |||||
| { | |||||
| pthread_mutex_lock(m_Mutex); | |||||
| m_Command[1]=command; | |||||
| pthread_mutex_unlock(m_Mutex); | |||||
| } | |||||
| void ChannelHandler::FlushChannels() | |||||
| { | |||||
| pthread_mutex_lock(m_Mutex); | |||||
| for(map<string, Channel*>::iterator i=m_ChannelMap.begin(); | |||||
| i!=m_ChannelMap.end(); i++) | |||||
| { | |||||
| memcpy(i->second->data_buf,i->second->data,i->second->size); | |||||
| } | |||||
| pthread_mutex_unlock(m_Mutex); | |||||
| } | |||||
| void ChannelHandler::RequestChannelAndWait(const string &ID) | |||||
| { | |||||
| map<string,Channel*>::iterator i=m_ChannelMap.find(ID); | |||||
| if (i==m_ChannelMap.end()) | |||||
| { | |||||
| cerr<<"ChannelHandler: Channel ["<<ID<<"] does not exist"<<endl; | |||||
| return; | |||||
| } | |||||
| if (i->second->type!=OUTPUT_REQUEST) | |||||
| { | |||||
| cerr<<"ChannelHandler: Trying to request ["<<ID<<"] which is not a requestable channel"<<endl; | |||||
| return; | |||||
| } | |||||
| pthread_mutex_lock(m_Mutex); | |||||
| i->second->requested=true; | |||||
| pthread_mutex_unlock(m_Mutex); | |||||
| bool ready=false; | |||||
| while (!ready) | |||||
| { | |||||
| usleep(10); // random amount of time :) | |||||
| pthread_mutex_lock(m_Mutex); | |||||
| ready=i->second->updated; | |||||
| pthread_mutex_unlock(m_Mutex); | |||||
| } | |||||
| pthread_mutex_lock(m_Mutex); | |||||
| i->second->requested=false; | |||||
| i->second->updated=false; | |||||
| pthread_mutex_unlock(m_Mutex); | |||||
| } | |||||
| void ChannelHandler::BulkTransfer(const string &ID, void *dest, int size) | |||||
| { | |||||
| map<string,Channel*>::iterator i=m_ChannelMap.find(ID); | |||||
| if (i==m_ChannelMap.end()) | |||||
| { | |||||
| cerr<<"ChannelHandler: Channel ["<<ID<<"] does not exist"<<endl; | |||||
| return; | |||||
| } | |||||
| if (i->second->type!=OUTPUT_REQUEST) | |||||
| { | |||||
| cerr<<"ChannelHandler: Trying to bulk transfer on ["<<ID<<"] which is not a OUTPUT_REQUEST channel"<<endl; | |||||
| return; | |||||
| } | |||||
| m_BulkPos=0; | |||||
| m_BulkSize = size; | |||||
| m_BulkID = ID; | |||||
| int pos=0; | |||||
| int buffersize=i->second->size; | |||||
| // fill up the destination buffer | |||||
| while (m_BulkPos!=-1) | |||||
| { | |||||
| RequestChannelAndWait(ID); | |||||
| if (pos+buffersize>size) | |||||
| { | |||||
| // last copy | |||||
| char *tempbuf = (char*)malloc(buffersize); | |||||
| GetData(ID,(void*)tempbuf); | |||||
| memcpy(((char*)dest)+pos,(void*)tempbuf,size-pos); | |||||
| free(tempbuf); | |||||
| } | |||||
| else | |||||
| { | |||||
| GetData(ID,((char*)dest)+pos); | |||||
| } | |||||
| pos+=buffersize; | |||||
| } | |||||
| } | |||||
| void ChannelHandler::Wait() | |||||
| { | |||||
| pthread_mutex_lock(m_Mutex); | |||||
| bool current=m_UpdateIndicator; | |||||
| bool last=m_UpdateIndicator; | |||||
| pthread_mutex_unlock(m_Mutex); | |||||
| while (current==last) | |||||
| { | |||||
| usleep(10); | |||||
| pthread_mutex_lock(m_Mutex); | |||||
| current=m_UpdateIndicator; | |||||
| pthread_mutex_unlock(m_Mutex); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,136 @@ | |||||
| /* SpiralSound | |||||
| * Copyleft (C) 2002 David Griffiths <dave@pawfal.org> | |||||
| * | |||||
| * This program is free software; you can redistribute it and/or modify | |||||
| * it under the terms of the GNU General Public License as published by | |||||
| * the Free Software Foundation; either version 2 of the License, or | |||||
| * (at your option) any later version. | |||||
| * | |||||
| * This program is distributed in the hope that it will be useful, | |||||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| * GNU General Public License for more details. | |||||
| * | |||||
| * You should have received a copy of the GNU General Public License | |||||
| * along with this program; if not, write to the Free Software | |||||
| * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||||
| */ | |||||
| #ifndef CHANNEL_HANDLER | |||||
| #define CHANNEL_HANDLER | |||||
| #include <pthread.h> | |||||
| #include <string> | |||||
| #include <map> | |||||
| #include <iostream.h> | |||||
| class ChannelHandler | |||||
| { | |||||
| public: | |||||
| enum Type{INPUT,OUTPUT,OUTPUT_REQUEST}; | |||||
| ChannelHandler(); | |||||
| ~ChannelHandler(); | |||||
| // only call these from the audio thread | |||||
| // don't call Register*() when the audio thread is running | |||||
| void RegisterData(const string &ID, Type t, void *pData, int size); | |||||
| void Register(const string &ID, bool* pData, Type t=ChannelHandler::INPUT) | |||||
| { RegisterData(ID, t,(bool*)pData,sizeof(bool)); } | |||||
| void Register(const string &ID, char* pData, Type t=ChannelHandler::INPUT) | |||||
| { RegisterData(ID, t,(char*)pData,sizeof(char)); } | |||||
| void Register(const string &ID, int* pData, Type t=ChannelHandler::INPUT) | |||||
| { RegisterData(ID, t,(int*)pData,sizeof(int)); } | |||||
| void Register(const string &ID, long* pData, Type t=ChannelHandler::INPUT) | |||||
| { RegisterData(ID, t,(long*)pData,sizeof(long)); } | |||||
| void Register(const string &ID, short* pData, Type t=ChannelHandler::INPUT) | |||||
| { RegisterData(ID, t,(short*)pData,sizeof(short)); } | |||||
| void Register(const string &ID, float* pData, Type t=ChannelHandler::INPUT) | |||||
| { RegisterData(ID, t,(float*)pData,sizeof(float)); } | |||||
| void Register(const string &ID, double* pData, Type t=ChannelHandler::INPUT) | |||||
| { RegisterData(ID, t,(double*)pData,sizeof(double)); } | |||||
| void UpdateDataNow(); | |||||
| bool IsCommandWaiting() { return m_Command[0]; } | |||||
| char GetCommand() { return m_Command[0]; } | |||||
| // use bulk transfers to copy variable and large sized data to the gui | |||||
| void SetupBulkTransfer(void *source) { m_BulkSrc=source; } | |||||
| // only call these from the gui thread | |||||
| // the ID comes from the order the channel is registered in | |||||
| void GetData(const string &ID, void *data); | |||||
| const bool GetBool(const string &ID) { bool t; GetData(ID,&t); return t; } | |||||
| const char GetChar(const string &ID) { char t; GetData(ID,&t); return t; } | |||||
| const int GetInt(const string &ID) { int t; GetData(ID,&t); return t; } | |||||
| const long GetLong(const string &ID) { long t; GetData(ID,&t); return t; } | |||||
| const short GetShort(const string &ID) { short t; GetData(ID,&t); return t; } | |||||
| const float GetFloat(const string &ID) { float t; GetData(ID,&t); return t; } | |||||
| const double GetDouble(const string &ID) { double t; GetData(ID,&t); return t; } | |||||
| void SetData(const string &ID, void *s); | |||||
| void Set(const string &ID, const bool& s) { SetData(ID,(void*)&s); } | |||||
| void Set(const string &ID, const char& s) { SetData(ID,(void*)&s); } | |||||
| void Set(const string &ID, const int& s) { SetData(ID,(void*)&s); } | |||||
| void Set(const string &ID, const long& s) { SetData(ID,(void*)&s); } | |||||
| void Set(const string &ID, const short& s) { SetData(ID,(void*)&s); } | |||||
| void Set(const string &ID, const float& s) { SetData(ID,(void*)&s); } | |||||
| void Set(const string &ID, const double& s) { SetData(ID,(void*)&s); } | |||||
| void SetCommand(char command); | |||||
| // initialises the data from the audio side to the internal buffers | |||||
| void FlushChannels(); | |||||
| //////////////////////////////////////////// | |||||
| // This is useful for getting data from the audio side immediately, | |||||
| // as it will block until complete, and for larger amounts of data, as | |||||
| // it won't be doing the copy every update. | |||||
| void RequestChannelAndWait(const string &ID); | |||||
| /////////////////////////////////////////// | |||||
| // Use for copying large variable sized data very infrequently. | |||||
| // uses an OUTPUT_REQUEST channel as a transfer buffer. | |||||
| // Send the size needed to the gui down another channel. | |||||
| // This can be a slowww function, as it can take many audio updates | |||||
| // to complete, depending on the size of the buffer channel and the | |||||
| // total size of the transfer. | |||||
| void BulkTransfer(const string &ID, void *dest, int size); | |||||
| // delays for one or more updates. use for syncing commands | |||||
| void Wait(); | |||||
| private: | |||||
| class Channel | |||||
| { | |||||
| public: | |||||
| Channel(Type t) { type=t; } | |||||
| Type type; | |||||
| void *data_buf; | |||||
| int size; | |||||
| void *data; | |||||
| bool requested; | |||||
| bool updated; | |||||
| }; | |||||
| map<string,Channel*> m_ChannelMap; | |||||
| char m_Command[2]; | |||||
| bool m_UpdateIndicator; | |||||
| void *m_BulkSrc; | |||||
| int m_BulkSize; | |||||
| int m_BulkPos; | |||||
| string m_BulkID; | |||||
| pthread_mutex_t* m_Mutex; | |||||
| }; | |||||
| #endif | |||||
| @@ -30,7 +30,7 @@ | |||||
| using namespace std; | using namespace std; | ||||
| #define KEYBOARD_SUPPORT | |||||
| //#define KEYBOARD_SUPPORT | |||||
| class MidiEvent | class MidiEvent | ||||
| @@ -54,7 +54,10 @@ m_DC(0.0f) | |||||
| m_PluginInfo.PortTips.push_back("Input"); | m_PluginInfo.PortTips.push_back("Input"); | ||||
| m_PluginInfo.PortTips.push_back("Amp CV"); | m_PluginInfo.PortTips.push_back("Amp CV"); | ||||
| m_PluginInfo.PortTips.push_back("DC Offset CV"); | m_PluginInfo.PortTips.push_back("DC Offset CV"); | ||||
| m_PluginInfo.PortTips.push_back("Output"); | |||||
| m_PluginInfo.PortTips.push_back("Output"); | |||||
| m_AudioCH->Register("Amp",&m_Amp); | |||||
| m_AudioCH->Register("DC",&m_DC); | |||||
| } | } | ||||
| AmpPlugin::~AmpPlugin() | AmpPlugin::~AmpPlugin() | ||||
| @@ -68,11 +71,9 @@ PluginInfo &AmpPlugin::Initialise(const HostInfo *Host) | |||||
| SpiralGUIType *AmpPlugin::CreateGUI() | SpiralGUIType *AmpPlugin::CreateGUI() | ||||
| { | { | ||||
| m_GUI = new AmpPluginGUI(m_PluginInfo.Width, | |||||
| return new AmpPluginGUI(m_PluginInfo.Width, | |||||
| m_PluginInfo.Height, | m_PluginInfo.Height, | ||||
| this,m_HostInfo); | |||||
| m_GUI->hide(); | |||||
| return m_GUI; | |||||
| this,m_AudioCH,m_HostInfo); | |||||
| } | } | ||||
| void AmpPlugin::Execute() | void AmpPlugin::Execute() | ||||
| @@ -37,9 +37,7 @@ public: | |||||
| // has to be defined in the plugin | // has to be defined in the plugin | ||||
| virtual void UpdateGUI() { Fl::check(); } | virtual void UpdateGUI() { Fl::check(); } | ||||
| void SetAmp(float s) { m_Amp=s; } | |||||
| void SetDC(float s) { m_DC=s; } | |||||
| float GetAmp() { return m_Amp; } | |||||
| float GetAmp() { return m_Amp; } | |||||
| float GetDC() { return m_DC; } | float GetDC() { return m_DC; } | ||||
| void Randomise(); | void Randomise(); | ||||
| @@ -26,8 +26,8 @@ static const int GUIBG2_COLOUR = 145; | |||||
| //////////////////////////////////////////// | //////////////////////////////////////////// | ||||
| AmpPluginGUI::AmpPluginGUI(int w, int h,AmpPlugin *o,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o) | |||||
| AmpPluginGUI::AmpPluginGUI(int w, int h,AmpPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o,ch) | |||||
| { | { | ||||
| m_Plugin=o; | m_Plugin=o; | ||||
| @@ -79,14 +79,16 @@ SpiralPluginGUI(w,h,o) | |||||
| extern "C" int sprintf(char *,const char *,...); | extern "C" int sprintf(char *,const char *,...); | ||||
| void AmpPluginGUI::UpdateValues() | |||||
| void AmpPluginGUI::UpdateValues(SpiralPlugin *o) | |||||
| { | { | ||||
| m_Amp->value(2.0f-m_Plugin->GetAmp()); | |||||
| m_DC->value(2.0f-m_Plugin->GetDC()); | |||||
| AmpPlugin* Plugin = (AmpPlugin*)o; | |||||
| m_Amp->value(2.0f-Plugin->GetAmp()); | |||||
| m_DC->value(2.0f-Plugin->GetDC()); | |||||
| char str[10]; | char str[10]; | ||||
| sprintf(str,"%4.2f",m_Plugin->GetAmp()); | |||||
| sprintf(str,"%4.2f",Plugin->GetAmp()); | |||||
| m_out_gain->value(str); | m_out_gain->value(str); | ||||
| sprintf(str,"%4.2f",m_Plugin->GetDC()); | |||||
| sprintf(str,"%4.2f",Plugin->GetDC()); | |||||
| m_out_DC->value(str); | m_out_DC->value(str); | ||||
| } | } | ||||
| @@ -95,7 +97,7 @@ inline void AmpPluginGUI::cb_Amp_i(Fl_Slider* o, void* v) | |||||
| char str[10]; | char str[10]; | ||||
| float value=2.0f-o->value(); | float value=2.0f-o->value(); | ||||
| m_Plugin->SetAmp(value); | |||||
| m_GUICH->Set("Amp",value); | |||||
| sprintf(str,"%4.2f",value); | sprintf(str,"%4.2f",value); | ||||
| m_out_gain->value(str); | m_out_gain->value(str); | ||||
| } | } | ||||
| @@ -106,7 +108,7 @@ inline void AmpPluginGUI::cb_DC_i(Fl_Slider* o, void* v) | |||||
| { | { | ||||
| char str[10]; | char str[10]; | ||||
| float value=2.0f-o->value(); | float value=2.0f-o->value(); | ||||
| m_Plugin->SetDC(value); | |||||
| m_GUICH->Set("DC",value); | |||||
| sprintf(str,"%4.2f",value); | sprintf(str,"%4.2f",value); | ||||
| m_out_DC->value(str); | m_out_DC->value(str); | ||||
| } | } | ||||
| @@ -33,9 +33,9 @@ | |||||
| class AmpPluginGUI : public SpiralPluginGUI | class AmpPluginGUI : public SpiralPluginGUI | ||||
| { | { | ||||
| public: | public: | ||||
| AmpPluginGUI(int w, int h, AmpPlugin *o,const HostInfo *Info); | |||||
| AmpPluginGUI(int w, int h, AmpPlugin *o,ChannelHandler *ch,const HostInfo *Info); | |||||
| virtual void UpdateValues(); | |||||
| virtual void UpdateValues(SpiralPlugin *o); | |||||
| virtual SpiralPlugin* GetPlugin() { return m_Plugin; } | virtual SpiralPlugin* GetPlugin() { return m_Plugin; } | ||||
| AmpPlugin *m_Plugin; | AmpPlugin *m_Plugin; | ||||
| @@ -43,6 +43,7 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| @@ -50,6 +51,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| AmpPluginGUI.h | AmpPluginGUI.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../../Sample.C \ | ../../Sample.C \ | ||||
| @@ -57,6 +59,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| AmpPluginGUI.C | AmpPluginGUI.C | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../../Sample.o \ | ../../Sample.o \ | ||||
| @@ -162,3 +165,5 @@ AmpPluginGUI.o: AmpPluginGUI.C \ | |||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../Widgets/Fl_DragBar.H | ../Widgets/Fl_DragBar.H | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -43,6 +43,7 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| @@ -51,6 +52,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| ComplexEnvelopePluginGUI.h | ComplexEnvelopePluginGUI.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../../Sample.C \ | ../../Sample.C \ | ||||
| @@ -59,6 +61,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| ComplexEnvelopePluginGUI.C | ComplexEnvelopePluginGUI.C | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../../Sample.o \ | ../../Sample.o \ | ||||
| @@ -170,3 +173,5 @@ ComplexEnvelopePluginGUI.o: ComplexEnvelopePluginGUI.C \ | |||||
| Bezier.h \ | Bezier.h \ | ||||
| ../Widgets/Fl_DragBar.H | ../Widgets/Fl_DragBar.H | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -60,6 +60,12 @@ m_Num(4) | |||||
| { | { | ||||
| m_ChannelVal[n]=0.0f; | m_ChannelVal[n]=0.0f; | ||||
| } | } | ||||
| m_AudioCH->Register("Number",&m_GUIArgs.Number); | |||||
| m_AudioCH->Register("Value",&m_GUIArgs.Value); | |||||
| m_AudioCH->Register("Min",&m_GUIArgs.Min); | |||||
| m_AudioCH->Register("Max",&m_GUIArgs.Max); | |||||
| m_AudioCH->RegisterData("Name",ChannelHandler::INPUT,m_GUIArgs.Name,sizeof(m_GUIArgs.Name)); | |||||
| } | } | ||||
| ControllerPlugin::~ControllerPlugin() | ControllerPlugin::~ControllerPlugin() | ||||
| @@ -73,11 +79,9 @@ PluginInfo &ControllerPlugin::Initialise(const HostInfo *Host) | |||||
| SpiralGUIType *ControllerPlugin::CreateGUI() | SpiralGUIType *ControllerPlugin::CreateGUI() | ||||
| { | { | ||||
| m_GUI = new ControllerPluginGUI(m_PluginInfo.Width, | |||||
| return new ControllerPluginGUI(m_PluginInfo.Width, | |||||
| m_PluginInfo.Height, | m_PluginInfo.Height, | ||||
| this,m_HostInfo); | |||||
| m_GUI->hide(); | |||||
| return m_GUI; | |||||
| this,m_AudioCH,m_HostInfo); | |||||
| } | } | ||||
| void ControllerPlugin::Execute() | void ControllerPlugin::Execute() | ||||
| @@ -91,6 +95,22 @@ void ControllerPlugin::Execute() | |||||
| } | } | ||||
| } | } | ||||
| void ControllerPlugin::ExecuteCommands() | |||||
| { | |||||
| if (m_AudioCH->IsCommandWaiting()) | |||||
| { | |||||
| switch (m_AudioCH->GetCommand()) | |||||
| { | |||||
| case (SETCHANNEL) : | |||||
| SetChannel(m_GUIArgs.Number,m_GUIArgs.Value,m_GUIArgs.Min,m_GUIArgs.Max,m_GUIArgs.Name); | |||||
| break; | |||||
| case (SETNUM) : | |||||
| SetNum(m_GUIArgs.Number); | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| void ControllerPlugin::SetNum(int n) | void ControllerPlugin::SetNum(int n) | ||||
| { | { | ||||
| // once to clear the connections with the current info | // once to clear the connections with the current info | ||||
| @@ -114,7 +134,7 @@ void ControllerPlugin::SetNum(int n) | |||||
| m_Num=n; | m_Num=n; | ||||
| m_PluginInfo.NumOutputs=n; | m_PluginInfo.NumOutputs=n; | ||||
| // do the actual update | // do the actual update | ||||
| UpdatePluginInfoWithHost(); | UpdatePluginInfoWithHost(); | ||||
| } | } | ||||
| @@ -133,34 +153,28 @@ void ControllerPlugin::StreamOut(ostream &s) | |||||
| switch (m_Version) | switch (m_Version) | ||||
| { | { | ||||
| case 1: | |||||
| { | |||||
| for (int n=0; n<4; n++) | |||||
| { | |||||
| s<<m_ChannelVal[n]<<" "; | |||||
| } | |||||
| } break; | |||||
| case 2: | |||||
| case 3: | |||||
| { | { | ||||
| s<<m_Num<<" "; | s<<m_Num<<" "; | ||||
| for (int n=0; n<m_Num; n++) | for (int n=0; n<m_Num; n++) | ||||
| { | { | ||||
| s<<m_ChannelVal[n]<<" "; | s<<m_ChannelVal[n]<<" "; | ||||
| } | } | ||||
| //s<<*(ControllerPluginGUI*)m_GUI<<" "; | |||||
| ((ControllerPluginGUI*)m_GUI)->StreamOut(s); | |||||
| } break; | |||||
| case 3: | |||||
| { | |||||
| s<<m_Num<<" "; | s<<m_Num<<" "; | ||||
| for (int n=0; n<m_Num; n++) | for (int n=0; n<m_Num; n++) | ||||
| { | |||||
| s<<m_ChannelVal[n]<<" "; | |||||
| { | |||||
| s<<m_Names[n].size()<<endl; | |||||
| s<<m_Names[n]<<" "; | |||||
| s<<m_MinVal[n]<<" "; | |||||
| s<<m_MaxVal[n]<<" "; | |||||
| s<<m_ChannelVal[n]<<endl; | |||||
| } | } | ||||
| ((ControllerPluginGUI*)m_GUI)->StreamOut(s); | |||||
| } break; | } break; | ||||
| default : | |||||
| cerr<<"ControllerPlugin - I dont support this streaming version any more"<<endl; | |||||
| break; | |||||
| } | } | ||||
| } | } | ||||
| @@ -171,15 +185,7 @@ void ControllerPlugin::StreamIn(istream &s) | |||||
| switch (version) | switch (version) | ||||
| { | { | ||||
| case 1: | |||||
| { | |||||
| for (int n=0; n<4; n++) | |||||
| { | |||||
| s>>m_ChannelVal[n]; | |||||
| } | |||||
| } break; | |||||
| case 2: | |||||
| case 3: | |||||
| { | { | ||||
| Clear(); | Clear(); | ||||
| @@ -190,35 +196,21 @@ void ControllerPlugin::StreamIn(istream &s) | |||||
| s>>m_ChannelVal[n]; | s>>m_ChannelVal[n]; | ||||
| } | } | ||||
| s>>*(ControllerPluginGUI*)m_GUI; | |||||
| // add the channels one by one | |||||
| char Buf[4096]; | |||||
| int size; | |||||
| s>>m_Num; | |||||
| for (int n=0; n<m_Num; n++) | for (int n=0; n<m_Num; n++) | ||||
| { | |||||
| char t[256]; | |||||
| sprintf(t,"CV %d",n); | |||||
| m_PluginInfo.PortTips.push_back(t); | |||||
| AddOutput(); | |||||
| { | |||||
| s>>size; | |||||
| s.ignore(1); | |||||
| s.get(Buf,size+1); | |||||
| m_Names[n]=Buf; | |||||
| s>>m_MinVal[n]; | |||||
| s>>m_MaxVal[n]; | |||||
| s>>m_ChannelVal[n]; | |||||
| } | } | ||||
| m_PluginInfo.NumOutputs=m_Num; | |||||
| UpdatePluginInfoWithHost(); | |||||
| } break; | |||||
| case 3: | |||||
| { | |||||
| Clear(); | |||||
| s>>m_Num; | |||||
| for (int n=0; n<m_Num; n++) | |||||
| { | |||||
| s>>m_ChannelVal[n]; | |||||
| } | |||||
| ((ControllerPluginGUI*)m_GUI)->StreamIn(s); | |||||
| // add the channels one by one | // add the channels one by one | ||||
| for (int n=0; n<m_Num; n++) | for (int n=0; n<m_Num; n++) | ||||
| { | { | ||||
| @@ -230,7 +222,10 @@ void ControllerPlugin::StreamIn(istream &s) | |||||
| m_PluginInfo.NumOutputs=m_Num; | m_PluginInfo.NumOutputs=m_Num; | ||||
| UpdatePluginInfoWithHost(); | UpdatePluginInfoWithHost(); | ||||
| } break; | } break; | ||||
| default : | |||||
| cerr<<"ControllerPlugin - I dont support this streaming version any more"<<endl; | |||||
| break; | |||||
| } | } | ||||
| } | } | ||||
| @@ -33,21 +33,39 @@ public: | |||||
| 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); | ||||
| // has to be defined in the plugin | |||||
| virtual void UpdateGUI() { Fl::check(); } | |||||
| void SetChannel(int n, float s) { m_ChannelVal[n]=s; } | |||||
| void SetNum(int n); | |||||
| string GetName(int n) { return m_Names[n]; } | |||||
| int GetNum() { return m_Num; } | |||||
| float GetVal(int n) { return m_ChannelVal[n]; } | |||||
| float GetMin(int n) { return m_MinVal[n]; } | |||||
| float GetMax(int n) { return m_MaxVal[n]; } | |||||
| enum GUICommands{NONE,SETCHANNEL,SETNUM}; | |||||
| struct GUIArgs | |||||
| { | |||||
| int Number; | |||||
| float Value; | |||||
| float Min; | |||||
| float Max; | |||||
| char Name[256]; | |||||
| }; | |||||
| private: | private: | ||||
| GUIArgs m_GUIArgs; | |||||
| void SetChannel(int n, float s, float min, float max, char* name) | |||||
| { m_ChannelVal[n]=s; m_MinVal[n]=min; m_MaxVal[n]=max; m_Names[n]=name; } | |||||
| void SetNum(int n); | |||||
| void Clear(); | void Clear(); | ||||
| int m_Num; | int m_Num; | ||||
| float m_ChannelVal[MAX_CHANNELS]; | |||||
| float m_ChannelVal[MAX_CHANNELS]; | |||||
| string m_Names[MAX_CHANNELS]; | |||||
| float m_MinVal[MAX_CHANNELS]; | |||||
| float m_MaxVal[MAX_CHANNELS]; | |||||
| }; | }; | ||||
| #endif | #endif | ||||
| @@ -66,12 +66,10 @@ ControllerPluginGUI::CVGUI::CVGUI(int n, ControllerPluginGUI *p) | |||||
| //////////////////////////////////////////// | //////////////////////////////////////////// | ||||
| ControllerPluginGUI::ControllerPluginGUI(int w, int h,ControllerPlugin *o,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o), | |||||
| ControllerPluginGUI::ControllerPluginGUI(int w, int h,ControllerPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o,ch), | |||||
| m_CVCount(0) | m_CVCount(0) | ||||
| { | { | ||||
| m_Plugin=o; | |||||
| for (int n=0; n<MAX_CHANNELS; n++) | for (int n=0; n<MAX_CHANNELS; n++) | ||||
| { | { | ||||
| Numbers[n]=n; | Numbers[n]=n; | ||||
| @@ -126,8 +124,29 @@ void ControllerPluginGUI::Clear() | |||||
| m_CVCount=0; | m_CVCount=0; | ||||
| } | } | ||||
| void ControllerPluginGUI::UpdateValues() | |||||
| { | |||||
| void ControllerPluginGUI::UpdateValues(SpiralPlugin *o) | |||||
| { | |||||
| ControllerPlugin *Plugin = (ControllerPlugin *)o; | |||||
| int c; | |||||
| string Title,Min,Max; | |||||
| char temp[64]; | |||||
| Clear(); | |||||
| c=Plugin->GetNum(); | |||||
| for (int n=0; n<c; n++) | |||||
| { | |||||
| AddCV(); | |||||
| m_GuiVec[n]->m_Title->value(Plugin->GetName(n).c_str()); | |||||
| sprintf(temp,"%f",Plugin->GetMin(n)); | |||||
| m_GuiVec[n]->m_Min->value(temp); | |||||
| sprintf(temp,"%f",Plugin->GetMax(n)); | |||||
| m_GuiVec[n]->m_Max->value(temp); | |||||
| m_GuiVec[n]->m_Chan->value(Plugin->GetVal(n)); | |||||
| } | |||||
| resize(x(),y(),c*60,h()); | |||||
| } | } | ||||
| inline void ControllerPluginGUI::cb_Chan_i(Fl_Slider* o, void* v) | inline void ControllerPluginGUI::cb_Chan_i(Fl_Slider* o, void* v) | ||||
| @@ -138,7 +157,14 @@ inline void ControllerPluginGUI::cb_Chan_i(Fl_Slider* o, void* v) | |||||
| long max=strtol(m_GuiVec[num]->m_Min->value(),NULL,10); | long max=strtol(m_GuiVec[num]->m_Min->value(),NULL,10); | ||||
| long min=strtol(m_GuiVec[num]->m_Max->value(),NULL,10); | long min=strtol(m_GuiVec[num]->m_Max->value(),NULL,10); | ||||
| float val=o->value()*(max-min)+min; | float val=o->value()*(max-min)+min; | ||||
| m_Plugin->SetChannel(num,val); | |||||
| m_GUICH->Set("Number",num); | |||||
| m_GUICH->Set("Value",val); | |||||
| m_GUICH->Set("Min",(int)min); | |||||
| m_GUICH->Set("Max",(int)max); | |||||
| char temp[256]; | |||||
| sprintf(temp,"%s",m_GuiVec[num]->m_Title->value()); | |||||
| m_GUICH->Set("Name",temp); | |||||
| m_GUICH->SetCommand(ControllerPlugin::SETCHANNEL); | |||||
| } | } | ||||
| void ControllerPluginGUI::cb_Chan(Fl_Slider* o, void* v) | void ControllerPluginGUI::cb_Chan(Fl_Slider* o, void* v) | ||||
| { ((ControllerPluginGUI*)(o->parent()->user_data()))->cb_Chan_i(o,v);} | { ((ControllerPluginGUI*)(o->parent()->user_data()))->cb_Chan_i(o,v);} | ||||
| @@ -150,8 +176,8 @@ inline void ControllerPluginGUI::cb_Add_i(Fl_Button* o, void* v) | |||||
| AddCV(); | AddCV(); | ||||
| resize(x(),y(),w()+60,h()); | resize(x(),y(),w()+60,h()); | ||||
| redraw(); | redraw(); | ||||
| m_Plugin->SetNum(m_GuiVec.size()); | |||||
| m_GUICH->Set("Number",(int)m_GuiVec.size()); | |||||
| m_GUICH->SetCommand(ControllerPlugin::SETNUM); | |||||
| } | } | ||||
| } | } | ||||
| void ControllerPluginGUI::cb_Add(Fl_Button* o, void* v) | void ControllerPluginGUI::cb_Add(Fl_Button* o, void* v) | ||||
| @@ -165,7 +191,8 @@ inline void ControllerPluginGUI::cb_Delete_i(Fl_Button* o, void* v) | |||||
| resize(x(),y(),w()-60,h()); | resize(x(),y(),w()-60,h()); | ||||
| redraw(); | redraw(); | ||||
| m_Plugin->SetNum(m_GuiVec.size()); | |||||
| m_GUICH->Set("Number",(int)m_GuiVec.size()); | |||||
| m_GUICH->SetCommand(ControllerPlugin::SETNUM); | |||||
| } | } | ||||
| } | } | ||||
| void ControllerPluginGUI::cb_Delete(Fl_Button* o, void* v) | void ControllerPluginGUI::cb_Delete(Fl_Button* o, void* v) | ||||
| @@ -36,12 +36,9 @@ static int Numbers[MAX_CHANNELS]; | |||||
| class ControllerPluginGUI : public SpiralPluginGUI | class ControllerPluginGUI : public SpiralPluginGUI | ||||
| { | { | ||||
| public: | public: | ||||
| ControllerPluginGUI(int w, int h, ControllerPlugin *o,const HostInfo *Info); | |||||
| ControllerPluginGUI(int w, int h, ControllerPlugin *o,ChannelHandler *ch,const HostInfo *Info); | |||||
| virtual void UpdateValues(); | |||||
| virtual SpiralPlugin* GetPlugin() { return m_Plugin; } | |||||
| ControllerPlugin *m_Plugin; | |||||
| virtual void UpdateValues(SpiralPlugin *o); | |||||
| void StreamIn(istream &s); | void StreamIn(istream &s); | ||||
| void StreamOut(ostream &s); | void StreamOut(ostream &s); | ||||
| @@ -43,6 +43,7 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| @@ -50,6 +51,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| ControllerPluginGUI.h | ControllerPluginGUI.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../../Sample.C \ | ../../Sample.C \ | ||||
| @@ -57,6 +59,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| ControllerPluginGUI.C | ControllerPluginGUI.C | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../../Sample.o \ | ../../Sample.o \ | ||||
| @@ -162,3 +165,5 @@ ControllerPluginGUI.o: ControllerPluginGUI.C \ | |||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../Widgets/Fl_DragBar.H | ../Widgets/Fl_DragBar.H | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -56,6 +56,9 @@ m_WriteHeadPos(0) | |||||
| m_PluginInfo.PortTips.push_back("Delay CV"); | m_PluginInfo.PortTips.push_back("Delay CV"); | ||||
| m_PluginInfo.PortTips.push_back("ReadHead CV"); | m_PluginInfo.PortTips.push_back("ReadHead CV"); | ||||
| m_PluginInfo.PortTips.push_back("Output"); | m_PluginInfo.PortTips.push_back("Output"); | ||||
| m_AudioCH->Register("Delay",&m_Delay); | |||||
| m_AudioCH->Register("Mix",&m_Mix); | |||||
| } | } | ||||
| DelayPlugin::~DelayPlugin() | DelayPlugin::~DelayPlugin() | ||||
| @@ -71,11 +74,9 @@ PluginInfo &DelayPlugin::Initialise(const HostInfo *Host) | |||||
| SpiralGUIType *DelayPlugin::CreateGUI() | SpiralGUIType *DelayPlugin::CreateGUI() | ||||
| { | { | ||||
| m_GUI = new DelayPluginGUI(m_PluginInfo.Width, | |||||
| return new DelayPluginGUI(m_PluginInfo.Width, | |||||
| m_PluginInfo.Height, | m_PluginInfo.Height, | ||||
| this,m_HostInfo); | |||||
| m_GUI->hide(); | |||||
| return m_GUI; | |||||
| this,m_AudioCH,m_HostInfo); | |||||
| } | } | ||||
| void DelayPlugin::Execute() | void DelayPlugin::Execute() | ||||
| @@ -34,13 +34,7 @@ public: | |||||
| virtual void StreamOut(ostream &s); | virtual void StreamOut(ostream &s); | ||||
| virtual void StreamIn(istream &s); | virtual void StreamIn(istream &s); | ||||
| // has to be defined in the plugin | |||||
| virtual void UpdateGUI() { Fl::check(); } | |||||
| void SetDelay(float s) { m_Delay=s; } | |||||
| void SetMix(float s) { m_Mix=s; } | |||||
| float GetDelay() { return m_Delay; } | |||||
| float GetDelay() { return m_Delay; } | |||||
| float GetMix() { return m_Mix; } | float GetMix() { return m_Mix; } | ||||
| void Randomise(); | void Randomise(); | ||||
| @@ -26,11 +26,9 @@ static const int GUIBG2_COLOUR = 145; | |||||
| //////////////////////////////////////////// | //////////////////////////////////////////// | ||||
| DelayPluginGUI::DelayPluginGUI(int w, int h,DelayPlugin *o,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o) | |||||
| { | |||||
| m_Plugin=o; | |||||
| DelayPluginGUI::DelayPluginGUI(int w, int h,DelayPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o,ch) | |||||
| { | |||||
| m_Delay = new Fl_Slider(15, 20, 20, 70, "Delay"); | m_Delay = new Fl_Slider(15, 20, 20, 70, "Delay"); | ||||
| m_Delay->type(4); | m_Delay->type(4); | ||||
| m_Delay->selection_color(GUI_COLOUR); | m_Delay->selection_color(GUI_COLOUR); | ||||
| @@ -52,21 +50,23 @@ SpiralPluginGUI(w,h,o) | |||||
| end(); | end(); | ||||
| } | } | ||||
| void DelayPluginGUI::UpdateValues() | |||||
| void DelayPluginGUI::UpdateValues(SpiralPlugin *o) | |||||
| { | { | ||||
| m_Delay->value(m_Plugin->GetDelay()-5.0f); | |||||
| m_Mix->value(m_Plugin->GetMix()); | |||||
| DelayPlugin *Plugin = (DelayPlugin*)o; | |||||
| m_Delay->value(Plugin->GetDelay()-5.0f); | |||||
| m_Mix->value(Plugin->GetMix()); | |||||
| } | } | ||||
| inline void DelayPluginGUI::cb_Delay_i(Fl_Slider* o, void* v) | inline void DelayPluginGUI::cb_Delay_i(Fl_Slider* o, void* v) | ||||
| { | { | ||||
| float value=1.0f-o->value(); | float value=1.0f-o->value(); | ||||
| m_Plugin->SetDelay(value); | |||||
| m_GUICH->Set("Delay",value); | |||||
| } | } | ||||
| void DelayPluginGUI::cb_Delay(Fl_Slider* o, void* v) | void DelayPluginGUI::cb_Delay(Fl_Slider* o, void* v) | ||||
| { ((DelayPluginGUI*)(o->parent()))->cb_Delay_i(o,v); } | { ((DelayPluginGUI*)(o->parent()))->cb_Delay_i(o,v); } | ||||
| inline void DelayPluginGUI::cb_Mix_i(Fl_Knob* o, void* v) | inline void DelayPluginGUI::cb_Mix_i(Fl_Knob* o, void* v) | ||||
| { m_Plugin->SetMix(o->value()); } | |||||
| { m_GUICH->Set("Mix",o->value()); } | |||||
| void DelayPluginGUI::cb_Mix(Fl_Knob* o, void* v) | void DelayPluginGUI::cb_Mix(Fl_Knob* o, void* v) | ||||
| { ((DelayPluginGUI*)(o->parent()))->cb_Mix_i(o,v); } | { ((DelayPluginGUI*)(o->parent()))->cb_Mix_i(o,v); } | ||||
| @@ -32,13 +32,10 @@ | |||||
| class DelayPluginGUI : public SpiralPluginGUI | class DelayPluginGUI : public SpiralPluginGUI | ||||
| { | { | ||||
| public: | public: | ||||
| DelayPluginGUI(int w, int h, DelayPlugin *o,const HostInfo *Info); | |||||
| virtual void UpdateValues(); | |||||
| virtual SpiralPlugin* GetPlugin() { return m_Plugin; } | |||||
| DelayPlugin *m_Plugin; | |||||
| DelayPluginGUI(int w, int h, DelayPlugin *o,ChannelHandler *ch,const HostInfo *Info); | |||||
| virtual void UpdateValues(SpiralPlugin *o); | |||||
| private: | private: | ||||
| Fl_Slider *m_Delay; | Fl_Slider *m_Delay; | ||||
| @@ -43,6 +43,7 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| @@ -50,6 +51,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| DelayPluginGUI.h | DelayPluginGUI.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../../Sample.C \ | ../../Sample.C \ | ||||
| @@ -57,6 +59,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| DelayPluginGUI.C | DelayPluginGUI.C | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../../Sample.o \ | ../../Sample.o \ | ||||
| @@ -164,3 +167,5 @@ DelayPluginGUI.o: DelayPluginGUI.C \ | |||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../Widgets/Fl_Knob.H | ../Widgets/Fl_Knob.H | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -69,8 +69,7 @@ PluginInfo &DistributorPlugin::Initialise(const HostInfo *Host) | |||||
| SpiralGUIType *DistributorPlugin::CreateGUI() | SpiralGUIType *DistributorPlugin::CreateGUI() | ||||
| { | { | ||||
| m_GUI=NULL; | |||||
| return m_GUI; | |||||
| return NULL; | |||||
| } | } | ||||
| void DistributorPlugin::Execute() | void DistributorPlugin::Execute() | ||||
| @@ -34,9 +34,6 @@ public: | |||||
| virtual void StreamOut(ostream &s) {} | virtual void StreamOut(ostream &s) {} | ||||
| virtual void StreamIn(istream &s) {} | virtual void StreamIn(istream &s) {} | ||||
| // has to be defined in the plugin | |||||
| virtual void UpdateGUI() { Fl::check(); } | |||||
| private: | private: | ||||
| bool m_Triggered; | bool m_Triggered; | ||||
| bool m_Switch; | bool m_Switch; | ||||
| @@ -26,16 +26,15 @@ static const int GUIBG2_COLOUR = 145; | |||||
| //////////////////////////////////////////// | //////////////////////////////////////////// | ||||
| DistributorPluginGUI::DistributorPluginGUI(int w, int h,DistributorPlugin *o,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o) | |||||
| DistributorPluginGUI::DistributorPluginGUI(int w, int h,DistributorPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o,ch) | |||||
| { | { | ||||
| m_Plugin=o; | |||||
| end(); | end(); | ||||
| } | } | ||||
| void DistributorPluginGUI::UpdateValues() | |||||
| void DistributorPluginGUI::UpdateValues(SpiralPlugin *o) | |||||
| { | { | ||||
| } | } | ||||
| @@ -33,12 +33,9 @@ | |||||
| class DistributorPluginGUI : public SpiralPluginGUI | class DistributorPluginGUI : public SpiralPluginGUI | ||||
| { | { | ||||
| public: | public: | ||||
| DistributorPluginGUI(int w, int h, DistributorPlugin *o,const HostInfo *Info); | |||||
| virtual void UpdateValues(); | |||||
| virtual SpiralPlugin* GetPlugin() { return m_Plugin; } | |||||
| DistributorPlugin *m_Plugin; | |||||
| DistributorPluginGUI(int w, int h, DistributorPlugin *o,ChannelHandler *ch,const HostInfo *Info); | |||||
| virtual void UpdateValues(SpiralPlugin *o); | |||||
| private: | private: | ||||
| //// Callbacks //// | //// Callbacks //// | ||||
| @@ -44,6 +44,7 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| @@ -51,6 +52,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| DistributorPluginGUI.h | DistributorPluginGUI.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../../Sample.C \ | ../../Sample.C \ | ||||
| @@ -58,6 +60,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| DistributorPluginGUI.C | DistributorPluginGUI.C | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../../Sample.o \ | ../../Sample.o \ | ||||
| @@ -167,4 +170,5 @@ DistributorPluginGUI.o: DistributorPluginGUI.C \ | |||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../Widgets/Fl_DragBar.H | ../Widgets/Fl_DragBar.H | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -55,6 +55,9 @@ m_HeadPos(0) | |||||
| m_PluginInfo.PortTips.push_back("Delay CV"); | m_PluginInfo.PortTips.push_back("Delay CV"); | ||||
| m_PluginInfo.PortTips.push_back("Feedback CV"); | m_PluginInfo.PortTips.push_back("Feedback CV"); | ||||
| m_PluginInfo.PortTips.push_back("Output"); | m_PluginInfo.PortTips.push_back("Output"); | ||||
| m_AudioCH->Register("Delay",&m_Delay); | |||||
| m_AudioCH->Register("Feedback",&m_Feedback); | |||||
| } | } | ||||
| EchoPlugin::~EchoPlugin() | EchoPlugin::~EchoPlugin() | ||||
| @@ -70,11 +73,9 @@ PluginInfo &EchoPlugin::Initialise(const HostInfo *Host) | |||||
| SpiralGUIType *EchoPlugin::CreateGUI() | SpiralGUIType *EchoPlugin::CreateGUI() | ||||
| { | { | ||||
| m_GUI = new EchoPluginGUI(m_PluginInfo.Width, | |||||
| return new EchoPluginGUI(m_PluginInfo.Width, | |||||
| m_PluginInfo.Height, | m_PluginInfo.Height, | ||||
| this,m_HostInfo); | |||||
| m_GUI->hide(); | |||||
| return m_GUI; | |||||
| this,m_AudioCH,m_HostInfo); | |||||
| } | } | ||||
| void EchoPlugin::Execute() | void EchoPlugin::Execute() | ||||
| @@ -33,13 +33,7 @@ public: | |||||
| virtual void Execute(); | virtual void Execute(); | ||||
| virtual void StreamOut(ostream &s); | virtual void StreamOut(ostream &s); | ||||
| virtual void StreamIn(istream &s); | virtual void StreamIn(istream &s); | ||||
| // has to be defined in the plugin | |||||
| virtual void UpdateGUI() { Fl::check(); } | |||||
| void SetDelay(float s) { m_Delay=s; } | |||||
| void SetFeedback(float s) { m_Feedback=s; } | |||||
| float GetDelay() { return m_Delay; } | float GetDelay() { return m_Delay; } | ||||
| float GetFeedback() { return m_Feedback; } | float GetFeedback() { return m_Feedback; } | ||||
| @@ -26,11 +26,9 @@ static const int GUIBG2_COLOUR = 145; | |||||
| //////////////////////////////////////////// | //////////////////////////////////////////// | ||||
| EchoPluginGUI::EchoPluginGUI(int w, int h,EchoPlugin *o,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o) | |||||
| EchoPluginGUI::EchoPluginGUI(int w, int h,EchoPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o,ch) | |||||
| { | { | ||||
| m_Plugin=o; | |||||
| m_Delay = new Fl_Slider(15, 20, 20, 70, "Delay"); | m_Delay = new Fl_Slider(15, 20, 20, 70, "Delay"); | ||||
| m_Delay->type(4); | m_Delay->type(4); | ||||
| m_Delay->selection_color(GUI_COLOUR); | m_Delay->selection_color(GUI_COLOUR); | ||||
| @@ -79,14 +77,16 @@ SpiralPluginGUI(w,h,o) | |||||
| extern "C" int sprintf(char *,const char *,...); | extern "C" int sprintf(char *,const char *,...); | ||||
| void EchoPluginGUI::UpdateValues() | |||||
| void EchoPluginGUI::UpdateValues(SpiralPlugin *o) | |||||
| { | { | ||||
| m_Delay->value(1.0f-m_Plugin->GetDelay()); | |||||
| m_Feedback->value(1.1f-m_Plugin->GetFeedback()); | |||||
| EchoPlugin *Plugin = (EchoPlugin*)o; | |||||
| m_Delay->value(1.0f-Plugin->GetDelay()); | |||||
| m_Feedback->value(1.1f-Plugin->GetFeedback()); | |||||
| char str[10]; | char str[10]; | ||||
| sprintf(str,"%5.3f s", m_Plugin->GetDelay()); | |||||
| sprintf(str,"%5.3f s", Plugin->GetDelay()); | |||||
| m_out_delay->value(str); | m_out_delay->value(str); | ||||
| sprintf(str,"%5.1f %%", 100*m_Plugin->GetFeedback()); | |||||
| sprintf(str,"%5.1f %%", 100*Plugin->GetFeedback()); | |||||
| m_out_feedback->value(str); | m_out_feedback->value(str); | ||||
| } | } | ||||
| @@ -94,7 +94,7 @@ inline void EchoPluginGUI::cb_Delay_i(Fl_Slider* o, void* v) | |||||
| { | { | ||||
| char str[10]; | char str[10]; | ||||
| float value=1.0f-o->value(); | float value=1.0f-o->value(); | ||||
| m_Plugin->SetDelay(value); | |||||
| m_GUICH->Set("Delay",value); | |||||
| sprintf(str,"%5.3f s", value); | sprintf(str,"%5.3f s", value); | ||||
| m_out_delay->value(str); | m_out_delay->value(str); | ||||
| } | } | ||||
| @@ -105,7 +105,7 @@ void EchoPluginGUI::cb_Delay(Fl_Slider* o, void* v) | |||||
| inline void EchoPluginGUI::cb_Feedback_i(Fl_Slider* o, void* v) | inline void EchoPluginGUI::cb_Feedback_i(Fl_Slider* o, void* v) | ||||
| { | { | ||||
| char str[10]; | char str[10]; | ||||
| m_Plugin->SetFeedback(1.1f-o->value()); | |||||
| m_GUICH->Set("Feedback",(float)(1.1f-o->value())); | |||||
| sprintf(str,"%5.1f %%", 100*(1.1f-o->value())); | sprintf(str,"%5.1f %%", 100*(1.1f-o->value())); | ||||
| m_out_feedback->value(str); | m_out_feedback->value(str); | ||||
| } | } | ||||
| @@ -35,12 +35,9 @@ | |||||
| class EchoPluginGUI : public SpiralPluginGUI | class EchoPluginGUI : public SpiralPluginGUI | ||||
| { | { | ||||
| public: | public: | ||||
| EchoPluginGUI(int w, int h, EchoPlugin *o,const HostInfo *Info); | |||||
| EchoPluginGUI(int w, int h, EchoPlugin *o,ChannelHandler *ch,const HostInfo *Info); | |||||
| virtual void UpdateValues(); | |||||
| virtual SpiralPlugin* GetPlugin() { return m_Plugin; } | |||||
| EchoPlugin *m_Plugin; | |||||
| virtual void UpdateValues(SpiralPlugin *o); | |||||
| private: | private: | ||||
| @@ -43,6 +43,7 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| @@ -50,6 +51,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| EchoPluginGUI.h | EchoPluginGUI.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../../Sample.C \ | ../../Sample.C \ | ||||
| @@ -57,6 +59,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| EchoPluginGUI.C | EchoPluginGUI.C | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../../Sample.o \ | ../../Sample.o \ | ||||
| @@ -164,3 +167,5 @@ EchoPluginGUI.o: EchoPluginGUI.C \ | |||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../Widgets/Fl_Knob.H | ../Widgets/Fl_Knob.H | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -4,7 +4,7 @@ for file in `cat PluginList.txt` | |||||
| do | do | ||||
| echo $file | echo $file | ||||
| cd $file/ | cd $file/ | ||||
| nedit $file.h | |||||
| nedit $file.C | |||||
| cvs edit Makefile.in | |||||
| nedit Makefile.in | |||||
| cd .. | cd .. | ||||
| done | done | ||||
| @@ -51,6 +51,9 @@ m_Value(0) | |||||
| m_PluginInfo.NumOutputs=1; | m_PluginInfo.NumOutputs=1; | ||||
| m_PluginInfo.PortTips.push_back("Input"); | m_PluginInfo.PortTips.push_back("Input"); | ||||
| m_PluginInfo.PortTips.push_back("Output"); | m_PluginInfo.PortTips.push_back("Output"); | ||||
| m_AudioCH->Register("Attack",&m_Attack); | |||||
| m_AudioCH->Register("Decay",&m_Decay); | |||||
| } | } | ||||
| EnvFollowerPlugin::~EnvFollowerPlugin() | EnvFollowerPlugin::~EnvFollowerPlugin() | ||||
| @@ -64,11 +67,9 @@ PluginInfo &EnvFollowerPlugin::Initialise(const HostInfo *Host) | |||||
| SpiralGUIType *EnvFollowerPlugin::CreateGUI() | SpiralGUIType *EnvFollowerPlugin::CreateGUI() | ||||
| { | { | ||||
| m_GUI = new EnvFollowerPluginGUI(m_PluginInfo.Width, | |||||
| return new EnvFollowerPluginGUI(m_PluginInfo.Width, | |||||
| m_PluginInfo.Height, | m_PluginInfo.Height, | ||||
| this,m_HostInfo); | |||||
| m_GUI->hide(); | |||||
| return m_GUI; | |||||
| this,m_AudioCH,m_HostInfo); | |||||
| } | } | ||||
| void EnvFollowerPlugin::Execute() | void EnvFollowerPlugin::Execute() | ||||
| @@ -34,12 +34,7 @@ public: | |||||
| virtual void StreamOut(ostream &s); | virtual void StreamOut(ostream &s); | ||||
| virtual void StreamIn(istream &s); | virtual void StreamIn(istream &s); | ||||
| // has to be defined in the plugin | |||||
| virtual void UpdateGUI() { Fl::check(); } | |||||
| void SetAttack(float v) { m_Attack=v; } | |||||
| float GetAttack() { return m_Attack; } | float GetAttack() { return m_Attack; } | ||||
| void SetDecay(float v) { m_Decay=v; } | |||||
| float GetDecay() { return m_Decay; } | float GetDecay() { return m_Decay; } | ||||
| private: | private: | ||||
| @@ -26,11 +26,9 @@ static const int GUIBG2_COLOUR = 145; | |||||
| //////////////////////////////////////////// | //////////////////////////////////////////// | ||||
| EnvFollowerPluginGUI::EnvFollowerPluginGUI(int w, int h,EnvFollowerPlugin *o,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o) | |||||
| EnvFollowerPluginGUI::EnvFollowerPluginGUI(int w, int h,EnvFollowerPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o,ch) | |||||
| { | { | ||||
| m_Plugin=o; | |||||
| m_Attack = new Fl_Knob(20, 25, 40, 40, "Attack"); | m_Attack = new Fl_Knob(20, 25, 40, 40, "Attack"); | ||||
| m_Attack->color(GUI_COLOUR); | m_Attack->color(GUI_COLOUR); | ||||
| m_Attack->type(Fl_Knob::DOTLIN); | m_Attack->type(Fl_Knob::DOTLIN); | ||||
| @@ -56,18 +54,19 @@ SpiralPluginGUI(w,h,o) | |||||
| void EnvFollowerPluginGUI::UpdateValues() | |||||
| void EnvFollowerPluginGUI::UpdateValues(SpiralPlugin *o) | |||||
| { | { | ||||
| m_Attack->value(m_Plugin->GetAttack()); | |||||
| m_Decay->value(m_Plugin->GetDecay()); | |||||
| EnvFollowerPlugin *Plugin = (EnvFollowerPlugin*)o; | |||||
| m_Attack->value(Plugin->GetAttack()); | |||||
| m_Decay->value(Plugin->GetDecay()); | |||||
| } | } | ||||
| inline void EnvFollowerPluginGUI::cb_Decay_i(Fl_Knob* o, void* v) | inline void EnvFollowerPluginGUI::cb_Decay_i(Fl_Knob* o, void* v) | ||||
| { m_Plugin->SetDecay(o->value()); } | |||||
| { m_GUICH->Set("Decay",o->value()); } | |||||
| void EnvFollowerPluginGUI::cb_Decay(Fl_Knob* o, void* v) | void EnvFollowerPluginGUI::cb_Decay(Fl_Knob* o, void* v) | ||||
| { ((EnvFollowerPluginGUI*)(o->parent()))->cb_Decay_i(o,v);} | { ((EnvFollowerPluginGUI*)(o->parent()))->cb_Decay_i(o,v);} | ||||
| inline void EnvFollowerPluginGUI::cb_Attack_i(Fl_Knob* o, void* v) | inline void EnvFollowerPluginGUI::cb_Attack_i(Fl_Knob* o, void* v) | ||||
| { m_Plugin->SetAttack(o->value()); } | |||||
| { m_GUICH->Set("Attack",o->value()); } | |||||
| void EnvFollowerPluginGUI::cb_Attack(Fl_Knob* o, void* v) | void EnvFollowerPluginGUI::cb_Attack(Fl_Knob* o, void* v) | ||||
| { ((EnvFollowerPluginGUI*)(o->parent()))->cb_Attack_i(o,v);} | { ((EnvFollowerPluginGUI*)(o->parent()))->cb_Attack_i(o,v);} | ||||
| @@ -33,12 +33,10 @@ | |||||
| class EnvFollowerPluginGUI : public SpiralPluginGUI | class EnvFollowerPluginGUI : public SpiralPluginGUI | ||||
| { | { | ||||
| public: | public: | ||||
| EnvFollowerPluginGUI(int w, int h, EnvFollowerPlugin *o,const HostInfo *Info); | |||||
| EnvFollowerPluginGUI(int w, int h, EnvFollowerPlugin *o,ChannelHandler *ch,const HostInfo *Info); | |||||
| virtual void UpdateValues(); | |||||
| virtual SpiralPlugin* GetPlugin() { return m_Plugin; } | |||||
| EnvFollowerPlugin *m_Plugin; | |||||
| virtual void UpdateValues(SpiralPlugin *o); | |||||
| private: | private: | ||||
| Fl_Knob* m_Attack; | Fl_Knob* m_Attack; | ||||
| @@ -43,6 +43,7 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| @@ -50,6 +51,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| EnvFollowerPluginGUI.h | EnvFollowerPluginGUI.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../../Sample.C \ | ../../Sample.C \ | ||||
| @@ -57,6 +59,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| EnvFollowerPluginGUI.C | EnvFollowerPluginGUI.C | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../../Sample.o \ | ../../Sample.o \ | ||||
| @@ -166,3 +169,5 @@ EnvFollowerPluginGUI.o: EnvFollowerPluginGUI.C \ | |||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../Widgets/Fl_DragBar.H | ../Widgets/Fl_DragBar.H | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -58,6 +58,13 @@ m_TrigThresh(0.01) | |||||
| m_PluginInfo.PortTips.push_back("Input"); | m_PluginInfo.PortTips.push_back("Input"); | ||||
| m_PluginInfo.PortTips.push_back("CV"); | m_PluginInfo.PortTips.push_back("CV"); | ||||
| m_PluginInfo.PortTips.push_back("Output"); | m_PluginInfo.PortTips.push_back("Output"); | ||||
| m_AudioCH->Register("Attack",&m_Attack); | |||||
| m_AudioCH->Register("Decay",&m_Decay); | |||||
| m_AudioCH->Register("Sustain",&m_Sustain); | |||||
| m_AudioCH->Register("Release",&m_Release); | |||||
| m_AudioCH->Register("Volume",&m_Volume); | |||||
| m_AudioCH->Register("Trig",&m_TrigThresh); | |||||
| } | } | ||||
| EnvelopePlugin::~EnvelopePlugin() | EnvelopePlugin::~EnvelopePlugin() | ||||
| @@ -73,11 +80,9 @@ PluginInfo &EnvelopePlugin::Initialise(const HostInfo *Host) | |||||
| SpiralGUIType *EnvelopePlugin::CreateGUI() | SpiralGUIType *EnvelopePlugin::CreateGUI() | ||||
| { | { | ||||
| m_GUI = new EnvelopePluginGUI(m_PluginInfo.Width, | |||||
| return new EnvelopePluginGUI(m_PluginInfo.Width, | |||||
| m_PluginInfo.Height, | m_PluginInfo.Height, | ||||
| this,m_HostInfo); | |||||
| m_GUI->hide(); | |||||
| return m_GUI; | |||||
| this,m_AudioCH,m_HostInfo); | |||||
| } | } | ||||
| void EnvelopePlugin::Execute() | void EnvelopePlugin::Execute() | ||||
| @@ -35,17 +35,7 @@ public: | |||||
| virtual void Execute(); | virtual void Execute(); | ||||
| virtual void StreamOut(ostream &s); | virtual void StreamOut(ostream &s); | ||||
| virtual void StreamIn(istream &s); | virtual void StreamIn(istream &s); | ||||
| // has to be defined in the plugin | |||||
| virtual void UpdateGUI() { Fl::check(); } | |||||
| void SetAttack(float s) { m_Attack=s; } | |||||
| void SetDecay(float s) { m_Decay=s; } | |||||
| void SetSustain(float s) { m_Sustain=s; } | |||||
| void SetRelease(float s) { m_Release=s; } | |||||
| void SetVolume(float s) { m_Volume=s; } | |||||
| void SetTrigThresh(float s) { m_TrigThresh=s; } | |||||
| float GetAttack() { return m_Attack; } | float GetAttack() { return m_Attack; } | ||||
| float GetDecay() { return m_Decay; } | float GetDecay() { return m_Decay; } | ||||
| float GetSustain() { return m_Sustain; } | float GetSustain() { return m_Sustain; } | ||||
| @@ -27,11 +27,9 @@ static const float TIMED_SLIDER_MAX = 3.0f; | |||||
| //////////////////////////////////////////// | //////////////////////////////////////////// | ||||
| EnvelopePluginGUI::EnvelopePluginGUI(int w, int h,EnvelopePlugin *o,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o) | |||||
| { | |||||
| m_Plugin=o; | |||||
| EnvelopePluginGUI::EnvelopePluginGUI(int w, int h,EnvelopePlugin *o,ChannelHandler *ch,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o,ch) | |||||
| { | |||||
| Thresh = new Fl_Slider(10, 20, 20, 70, "T"); | Thresh = new Fl_Slider(10, 20, 20, 70, "T"); | ||||
| Thresh->type(4); | Thresh->type(4); | ||||
| Thresh->selection_color(GUI_COLOUR); | Thresh->selection_color(GUI_COLOUR); | ||||
| @@ -154,26 +152,28 @@ SpiralPluginGUI(w,h,o) | |||||
| extern "C" int sprintf(char *,const char *,...); | extern "C" int sprintf(char *,const char *,...); | ||||
| void EnvelopePluginGUI::UpdateValues() | |||||
| void EnvelopePluginGUI::UpdateValues(SpiralPlugin *o) | |||||
| { | { | ||||
| Thresh->value(1.0f-sqrt(m_Plugin->GetAttack())); | |||||
| Attack->value(TIMED_SLIDER_MAX-sqrt(m_Plugin->GetAttack())); | |||||
| Decay->value(TIMED_SLIDER_MAX-sqrt(m_Plugin->GetDecay())); | |||||
| Sustain->value(1.0f-m_Plugin->GetSustain()); | |||||
| Release->value(TIMED_SLIDER_MAX-sqrt(m_Plugin->GetRelease())); | |||||
| Volume->value(1.0f-m_Plugin->GetVolume()); | |||||
| EnvelopePlugin *Plugin = (EnvelopePlugin*)o; | |||||
| Thresh->value(1.0f-sqrt(Plugin->GetAttack())); | |||||
| Attack->value(TIMED_SLIDER_MAX-sqrt(Plugin->GetAttack())); | |||||
| Decay->value(TIMED_SLIDER_MAX-sqrt(Plugin->GetDecay())); | |||||
| Sustain->value(1.0f-Plugin->GetSustain()); | |||||
| Release->value(TIMED_SLIDER_MAX-sqrt(Plugin->GetRelease())); | |||||
| Volume->value(1.0f-Plugin->GetVolume()); | |||||
| char str[10]; | char str[10]; | ||||
| sprintf(str,"%4.0f %%", 100*m_Plugin->GetTrigThresh()); | |||||
| sprintf(str,"%4.0f %%", 100*Plugin->GetTrigThresh()); | |||||
| m_out_thresh->value(str); | m_out_thresh->value(str); | ||||
| sprintf(str,"%5.3f s", m_Plugin->GetAttack()); | |||||
| sprintf(str,"%5.3f s", Plugin->GetAttack()); | |||||
| m_out_attack->value(str); | m_out_attack->value(str); | ||||
| sprintf(str,"%5.3f s", m_Plugin->GetDecay()); | |||||
| sprintf(str,"%5.3f s", Plugin->GetDecay()); | |||||
| m_out_decay->value(str); | m_out_decay->value(str); | ||||
| sprintf(str,"%4.0f %%", 100*m_Plugin->GetSustain()); | |||||
| sprintf(str,"%4.0f %%", 100*Plugin->GetSustain()); | |||||
| m_out_sustain->value(str); | m_out_sustain->value(str); | ||||
| sprintf(str,"%5.3f s", m_Plugin->GetRelease()); | |||||
| sprintf(str,"%5.3f s", Plugin->GetRelease()); | |||||
| m_out_release->value(str); | m_out_release->value(str); | ||||
| sprintf(str,"%4.0f %%", 100*m_Plugin->GetVolume()); | |||||
| sprintf(str,"%4.0f %%", 100*Plugin->GetVolume()); | |||||
| m_out_volume->value(str); | m_out_volume->value(str); | ||||
| } | } | ||||
| @@ -181,7 +181,7 @@ void EnvelopePluginGUI::UpdateValues() | |||||
| inline void EnvelopePluginGUI::cb_Thresh_i(Fl_Slider* o, void* v) | inline void EnvelopePluginGUI::cb_Thresh_i(Fl_Slider* o, void* v) | ||||
| { | { | ||||
| char str[10]; | char str[10]; | ||||
| m_Plugin->SetTrigThresh(1.0f-o->value()); | |||||
| m_GUICH->Set("Trig",1.0f-o->value()); | |||||
| sprintf(str,"%4.0f %%", 100*(1.0f-o->value())); | sprintf(str,"%4.0f %%", 100*(1.0f-o->value())); | ||||
| m_out_thresh->value(str); | m_out_thresh->value(str); | ||||
| } | } | ||||
| @@ -193,7 +193,7 @@ inline void EnvelopePluginGUI::cb_Attack_i(Fl_Slider* o, void* v) | |||||
| { | { | ||||
| char str[10]; | char str[10]; | ||||
| float value=TIMED_SLIDER_MAX-o->value(); | float value=TIMED_SLIDER_MAX-o->value(); | ||||
| m_Plugin->SetAttack(value*value); | |||||
| m_GUICH->Set("Attack",value*value); | |||||
| sprintf(str,"%5.3f s", value*value); | sprintf(str,"%5.3f s", value*value); | ||||
| m_out_attack->value(str); | m_out_attack->value(str); | ||||
| } | } | ||||
| @@ -204,7 +204,7 @@ inline void EnvelopePluginGUI::cb_Decay_i(Fl_Slider* o, void* v) | |||||
| { | { | ||||
| char str[10]; | char str[10]; | ||||
| float value=TIMED_SLIDER_MAX-o->value(); | float value=TIMED_SLIDER_MAX-o->value(); | ||||
| m_Plugin->SetDecay(value*value); | |||||
| m_GUICH->Set("Decay",value*value); | |||||
| sprintf(str,"%5.3f s", value*value); | sprintf(str,"%5.3f s", value*value); | ||||
| m_out_decay->value(str); | m_out_decay->value(str); | ||||
| } | } | ||||
| @@ -214,7 +214,7 @@ void EnvelopePluginGUI::cb_Decay(Fl_Slider* o, void* v) | |||||
| inline void EnvelopePluginGUI::cb_Sustain_i(Fl_Slider* o, void* v) | inline void EnvelopePluginGUI::cb_Sustain_i(Fl_Slider* o, void* v) | ||||
| { | { | ||||
| char str[10]; | char str[10]; | ||||
| m_Plugin->SetSustain(1.0f-o->value()); | |||||
| m_GUICH->Set("Sustain",1.0f-o->value()); | |||||
| sprintf(str,"%4.0f %%", 100*(1.0f-o->value())); | sprintf(str,"%4.0f %%", 100*(1.0f-o->value())); | ||||
| m_out_sustain->value(str); | m_out_sustain->value(str); | ||||
| } | } | ||||
| @@ -226,7 +226,7 @@ inline void EnvelopePluginGUI::cb_Release_i(Fl_Slider* o, void* v) | |||||
| { | { | ||||
| char str[10]; | char str[10]; | ||||
| float value=TIMED_SLIDER_MAX-o->value(); | float value=TIMED_SLIDER_MAX-o->value(); | ||||
| m_Plugin->SetRelease(value*value); | |||||
| m_GUICH->Set("Release",value*value); | |||||
| sprintf(str,"%5.3f s", value*value); | sprintf(str,"%5.3f s", value*value); | ||||
| m_out_release->value(str); | m_out_release->value(str); | ||||
| } | } | ||||
| @@ -237,7 +237,7 @@ inline void EnvelopePluginGUI::cb_Volume_i(Fl_Slider* o, void* v) | |||||
| { | { | ||||
| char str[10]; | char str[10]; | ||||
| m_Plugin->SetVolume(1.0f-o->value()); | |||||
| m_GUICH->Set("Volume",1.0f-o->value()); | |||||
| sprintf(str,"%4.0f %%", 100*(1.0f-o->value())); | sprintf(str,"%4.0f %%", 100*(1.0f-o->value())); | ||||
| m_out_volume->value(str); | m_out_volume->value(str); | ||||
| } | } | ||||
| @@ -34,12 +34,10 @@ | |||||
| class EnvelopePluginGUI : public SpiralPluginGUI | class EnvelopePluginGUI : public SpiralPluginGUI | ||||
| { | { | ||||
| public: | public: | ||||
| EnvelopePluginGUI(int w, int h, EnvelopePlugin *o,const HostInfo *Info); | |||||
| EnvelopePluginGUI(int w, int h, EnvelopePlugin *o,ChannelHandler *ch,const HostInfo *Info); | |||||
| virtual void UpdateValues(); | |||||
| virtual SpiralPlugin* GetPlugin() { return m_Plugin; } | |||||
| EnvelopePlugin *m_Plugin; | |||||
| virtual void UpdateValues(SpiralPlugin *o); | |||||
| private: | private: | ||||
| Fl_Slider *Thresh; | Fl_Slider *Thresh; | ||||
| @@ -43,6 +43,7 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| @@ -50,6 +51,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| EnvelopePluginGUI.h | EnvelopePluginGUI.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../../Sample.C \ | ../../Sample.C \ | ||||
| @@ -57,6 +59,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| EnvelopePluginGUI.C | EnvelopePluginGUI.C | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../../Sample.o \ | ../../Sample.o \ | ||||
| @@ -162,3 +165,5 @@ EnvelopePluginGUI.o: EnvelopePluginGUI.C \ | |||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../Widgets/Fl_DragBar.H | ../Widgets/Fl_DragBar.H | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -64,6 +64,12 @@ m_RevResonanceMod(false) | |||||
| m_PluginInfo.PortTips.push_back("Cutoff CV"); | m_PluginInfo.PortTips.push_back("Cutoff CV"); | ||||
| m_PluginInfo.PortTips.push_back("Emphasis CV"); | m_PluginInfo.PortTips.push_back("Emphasis CV"); | ||||
| m_PluginInfo.PortTips.push_back("Output"); | m_PluginInfo.PortTips.push_back("Output"); | ||||
| m_AudioCH->Register("Cutoff",&fc); | |||||
| m_AudioCH->Register("Resonance",&Q); | |||||
| m_AudioCH->Register("RevC",&m_RevCutoffMod); | |||||
| m_AudioCH->Register("RevR",&m_RevResonanceMod); | |||||
| } | } | ||||
| FilterPlugin::~FilterPlugin() | FilterPlugin::~FilterPlugin() | ||||
| @@ -92,11 +98,9 @@ PluginInfo &FilterPlugin::Initialise(const HostInfo *Host) | |||||
| SpiralGUIType *FilterPlugin::CreateGUI() | SpiralGUIType *FilterPlugin::CreateGUI() | ||||
| { | { | ||||
| m_GUI = new FilterPluginGUI(m_PluginInfo.Width, | |||||
| return new FilterPluginGUI(m_PluginInfo.Width, | |||||
| m_PluginInfo.Height, | m_PluginInfo.Height, | ||||
| this,m_HostInfo); | |||||
| m_GUI->hide(); | |||||
| return m_GUI; | |||||
| this,m_AudioCH,m_HostInfo); | |||||
| } | } | ||||
| void FilterPlugin::Execute() | void FilterPlugin::Execute() | ||||
| @@ -142,7 +146,7 @@ void FilterPlugin::Execute() | |||||
| m_LastFC=fc; | m_LastFC=fc; | ||||
| } | } | ||||
| } | } | ||||
| float in = GetInput(0,n); | float in = GetInput(0,n); | ||||
| //if (in!=0) | //if (in!=0) | ||||
| //{ | //{ | ||||
| @@ -36,17 +36,10 @@ public: | |||||
| virtual void Execute(); | virtual void Execute(); | ||||
| virtual void StreamOut(ostream &s); | virtual void StreamOut(ostream &s); | ||||
| virtual void StreamIn(istream &s); | virtual void StreamIn(istream &s); | ||||
| // has to be defined in the plugin | |||||
| virtual void UpdateGUI() { Fl::check(); } | |||||
| void Reset(); | void Reset(); | ||||
| void SetupCoeffs(); | void SetupCoeffs(); | ||||
| void SetCutoff(double s) {fc=s;} | |||||
| void SetResonance(double s) {Q=s;} | |||||
| void SetRevCutoffMod(bool s) {m_RevCutoffMod=s;} | |||||
| void SetRevResonanceMod(bool s) {m_RevResonanceMod=s;} | |||||
| double GetCutoff() {return fc;} | double GetCutoff() {return fc;} | ||||
| double GetResonance() {return Q;} | double GetResonance() {return Q;} | ||||
| bool GetRevCutoffMod() {return m_RevCutoffMod;} | bool GetRevCutoffMod() {return m_RevCutoffMod;} | ||||
| @@ -58,10 +51,10 @@ private: | |||||
| // Voice independant | // Voice independant | ||||
| float *coef; | float *coef; | ||||
| double fs, fc; // Sampling frequency, cutoff frequency | |||||
| double Q; // Resonance > 1.0 < 1000 | |||||
| double m_LastFC; | |||||
| double m_LastQ; | |||||
| float fs, fc; // Sampling frequency, cutoff frequency | |||||
| float Q; // Resonance > 1.0 < 1000 | |||||
| float m_LastFC; | |||||
| float m_LastQ; | |||||
| unsigned nInd; | unsigned nInd; | ||||
| double a0, a1, a2, b0, b1, b2; | double a0, a1, a2, b0, b1, b2; | ||||
| double k; // overall gain factor | double k; // overall gain factor | ||||
| @@ -26,11 +26,9 @@ static const int GUIBG2_COLOUR = 145; | |||||
| //////////////////////////////////////////// | //////////////////////////////////////////// | ||||
| FilterPluginGUI::FilterPluginGUI(int w, int h,FilterPlugin *o,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o) | |||||
| FilterPluginGUI::FilterPluginGUI(int w, int h,FilterPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o,ch) | |||||
| { | { | ||||
| m_Plugin=o; | |||||
| Cutoff = new Fl_Slider(15, 20, 20, 70, "Cutoff"); | Cutoff = new Fl_Slider(15, 20, 20, 70, "Cutoff"); | ||||
| Cutoff->type(4); | Cutoff->type(4); | ||||
| Cutoff->selection_color(GUI_COLOUR); | Cutoff->selection_color(GUI_COLOUR); | ||||
| @@ -64,38 +62,40 @@ SpiralPluginGUI(w,h,o) | |||||
| end(); | end(); | ||||
| } | } | ||||
| void FilterPluginGUI::UpdateValues() | |||||
| void FilterPluginGUI::UpdateValues(SpiralPlugin *o) | |||||
| { | { | ||||
| Cutoff->value(100.0f-sqrt(m_Plugin->GetCutoff()-10.0f)); | |||||
| Resonance->value(m_Plugin->GetResonance()-1.0f); | |||||
| FilterPlugin *Plugin = (FilterPlugin*)o; | |||||
| Cutoff->value(100.0f-sqrt(Plugin->GetCutoff()-10.0f)); | |||||
| Resonance->value(Plugin->GetResonance()-1.0f); | |||||
| RevCutoff->value(0); | RevCutoff->value(0); | ||||
| RevResonance->value(0); | RevResonance->value(0); | ||||
| if (m_Plugin->GetRevCutoffMod()) RevCutoff->value(1); | |||||
| if (m_Plugin->GetRevResonanceMod()) RevResonance->value(1); | |||||
| if (Plugin->GetRevCutoffMod()) RevCutoff->value(1); | |||||
| if (Plugin->GetRevResonanceMod()) RevResonance->value(1); | |||||
| } | } | ||||
| inline void FilterPluginGUI::cb_Cutoff_i(Fl_Slider* o, void* v) | inline void FilterPluginGUI::cb_Cutoff_i(Fl_Slider* o, void* v) | ||||
| { | { | ||||
| float value=100.0f-o->value(); | float value=100.0f-o->value(); | ||||
| m_Plugin->SetCutoff((value*value)+10.0f); | |||||
| m_GUICH->Set("Cutoff",(float)(value*value)+10.0f); | |||||
| } | } | ||||
| void FilterPluginGUI::cb_Cutoff(Fl_Slider* o, void* v) | void FilterPluginGUI::cb_Cutoff(Fl_Slider* o, void* v) | ||||
| { ((FilterPluginGUI*)(o->parent()))->cb_Cutoff_i(o,v); } | { ((FilterPluginGUI*)(o->parent()))->cb_Cutoff_i(o,v); } | ||||
| inline void FilterPluginGUI::cb_Resonance_i(Fl_Knob* o, void* v) | inline void FilterPluginGUI::cb_Resonance_i(Fl_Knob* o, void* v) | ||||
| { m_Plugin->SetResonance(o->value()+1.0f); } | |||||
| { m_GUICH->Set("Resonance",(float)o->value()+1.0f); } | |||||
| void FilterPluginGUI::cb_Resonance(Fl_Knob* o, void* v) | void FilterPluginGUI::cb_Resonance(Fl_Knob* o, void* v) | ||||
| { ((FilterPluginGUI*)(o->parent()))->cb_Resonance_i(o,v); } | { ((FilterPluginGUI*)(o->parent()))->cb_Resonance_i(o,v); } | ||||
| inline void FilterPluginGUI::cb_RevCutoff_i(Fl_Button* o, void* v) | inline void FilterPluginGUI::cb_RevCutoff_i(Fl_Button* o, void* v) | ||||
| { m_Plugin->SetRevCutoffMod(o->value()); } | |||||
| { m_GUICH->Set("RevC",(bool)o->value()); } | |||||
| void FilterPluginGUI::cb_RevCutoff(Fl_Button* o, void* v) | void FilterPluginGUI::cb_RevCutoff(Fl_Button* o, void* v) | ||||
| { ((FilterPluginGUI*)(o->parent()))->cb_RevCutoff_i(o,v); } | { ((FilterPluginGUI*)(o->parent()))->cb_RevCutoff_i(o,v); } | ||||
| inline void FilterPluginGUI::cb_RevResonance_i(Fl_Button* o, void* v) | inline void FilterPluginGUI::cb_RevResonance_i(Fl_Button* o, void* v) | ||||
| { m_Plugin->SetRevResonanceMod(o->value()); } | |||||
| { m_GUICH->Set("RevR",(bool)o->value()); } | |||||
| void FilterPluginGUI::cb_RevResonance(Fl_Button* o, void* v) | void FilterPluginGUI::cb_RevResonance(Fl_Button* o, void* v) | ||||
| { ((FilterPluginGUI*)(o->parent()))->cb_RevResonance_i(o,v); } | { ((FilterPluginGUI*)(o->parent()))->cb_RevResonance_i(o,v); } | ||||
| @@ -32,12 +32,9 @@ | |||||
| class FilterPluginGUI : public SpiralPluginGUI | class FilterPluginGUI : public SpiralPluginGUI | ||||
| { | { | ||||
| public: | public: | ||||
| FilterPluginGUI(int w, int h, FilterPlugin *o,const HostInfo *Info); | |||||
| FilterPluginGUI(int w, int h, FilterPlugin *o,ChannelHandler *ch,const HostInfo *Info); | |||||
| virtual void UpdateValues(); | |||||
| virtual SpiralPlugin* GetPlugin() { return m_Plugin; } | |||||
| FilterPlugin *m_Plugin; | |||||
| virtual void UpdateValues(SpiralPlugin *o); | |||||
| private: | private: | ||||
| @@ -43,6 +43,7 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| @@ -51,6 +52,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| FilterPluginGUI.h | FilterPluginGUI.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../../Sample.C \ | ../../Sample.C \ | ||||
| @@ -59,6 +61,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| FilterPluginGUI.C | FilterPluginGUI.C | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../../Sample.o \ | ../../Sample.o \ | ||||
| @@ -172,3 +175,5 @@ FilterPluginGUI.o: FilterPluginGUI.C \ | |||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../Widgets/Fl_Knob.H | ../Widgets/Fl_Knob.H | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -317,7 +317,8 @@ int GetID() | |||||
| /////////////////////////////////////////////////////// | /////////////////////////////////////////////////////// | ||||
| JackPlugin::JackPlugin() | |||||
| JackPlugin::JackPlugin() : | |||||
| m_UpdateNames(false) | |||||
| { | { | ||||
| m_RefCount++; | m_RefCount++; | ||||
| @@ -340,6 +341,15 @@ JackPlugin::JackPlugin() | |||||
| sprintf(Temp,"SSM Input %d",n); | sprintf(Temp,"SSM Input %d",n); | ||||
| m_PluginInfo.PortTips.push_back(Temp); | m_PluginInfo.PortTips.push_back(Temp); | ||||
| } | } | ||||
| m_AudioCH->Register("Num",&GUIArgs.Num); | |||||
| m_AudioCH->RegisterData("Port",ChannelHandler::INPUT,&GUIArgs.Port,sizeof(GUIArgs.Port)); | |||||
| m_AudioCH->Register("NumInputPortNames",&m_NumInputPortNames,ChannelHandler::OUTPUT); | |||||
| m_AudioCH->Register("NumOutputPortNames",&m_NumOutputPortNames,ChannelHandler::OUTPUT); | |||||
| m_AudioCH->RegisterData("InputPortNames",ChannelHandler::OUTPUT,&m_InputPortNames,sizeof(m_InputPortNames)); | |||||
| m_AudioCH->RegisterData("OutputPortNames",ChannelHandler::OUTPUT,&m_OutputPortNames,sizeof(m_OutputPortNames)); | |||||
| m_AudioCH->Register("UpdateNames",&m_UpdateNames,ChannelHandler::OUTPUT); | |||||
| m_AudioCH->Register("Connected",&m_Connected,ChannelHandler::OUTPUT); | |||||
| } | } | ||||
| JackPlugin::~JackPlugin() | JackPlugin::~JackPlugin() | ||||
| @@ -364,11 +374,9 @@ PluginInfo &JackPlugin::Initialise(const HostInfo *Host) | |||||
| SpiralGUIType *JackPlugin::CreateGUI() | SpiralGUIType *JackPlugin::CreateGUI() | ||||
| { | { | ||||
| m_GUI = new JackPluginGUI(m_PluginInfo.Width, | |||||
| return new JackPluginGUI(m_PluginInfo.Width, | |||||
| m_PluginInfo.Height, | m_PluginInfo.Height, | ||||
| this,m_HostInfo); | |||||
| m_GUI->hide(); | |||||
| return m_GUI; | |||||
| this,m_AudioCH,m_HostInfo); | |||||
| } | } | ||||
| void JackPlugin::Execute() | void JackPlugin::Execute() | ||||
| @@ -401,3 +409,27 @@ void JackPlugin::Execute() | |||||
| } | } | ||||
| void JackPlugin::ExecuteCommands() | |||||
| { | |||||
| if (m_UpdateNames) | |||||
| { | |||||
| vector<string> InputNames,OutputNames; | |||||
| GetPortNames(InputNames,OutputNames); | |||||
| for (vector<string>::iterator i=InputNames.begin(); | |||||
| i!=InputNames.end(); ++i) | |||||
| { | |||||
| strcpy(m_InputPortNames[n],i->c_str()); | |||||
| } | |||||
| for (vector<string>::iterator i=OutputNames.begin(); | |||||
| i!=OutputNames.end(); ++i) | |||||
| { | |||||
| strcpy(m_OutputPortNames[n],i->c_str()); | |||||
| } | |||||
| m_NumInputPortNames=InputNames.size(); | |||||
| m_NumOutputPortNames=OutputNames.size(); | |||||
| m_UpdateNames=false; | |||||
| } | |||||
| } | |||||
| @@ -30,6 +30,8 @@ typedef jack_default_audio_sample_t sample_t; | |||||
| const int NUM_INPUTS = 8; | const int NUM_INPUTS = 8; | ||||
| const int NUM_OUTPUTS = 8; | const int NUM_OUTPUTS = 8; | ||||
| const int MAX_INPUTPORTS = 256; | |||||
| const int MAX_OUTPUTPORTS = 256; | |||||
| class JackClient | class JackClient | ||||
| { | { | ||||
| @@ -99,17 +101,32 @@ public: | |||||
| virtual void StreamOut(ostream &s) {} | virtual void StreamOut(ostream &s) {} | ||||
| virtual void StreamIn(istream &s) {} | virtual void StreamIn(istream &s) {} | ||||
| // has to be defined in the plugin | |||||
| virtual void UpdateGUI() { Fl::check(); } | |||||
| enum GUICommands{NONE,ATTACH,DETACH,CONNECTINPUT,CONNECTOUTPUT}; | |||||
| struct GUIArgs | |||||
| { | |||||
| int Num; | |||||
| char Port[256]; | |||||
| }; | |||||
| private: | |||||
| GUIArgs m_GUIArgs; | |||||
| // slightly clumsy, but we have to share this data with the gui | |||||
| int m_NumInputPortNames; | |||||
| char m_InputPortNames[MAX_INPUTPORTS][256]; | |||||
| int m_NumOutputPortNames; | |||||
| char m_OutputPortNames[MAX_OUTPUTPORTS][256]; | |||||
| void Attach() { JackClient::Get()->Attach(); } | void Attach() { JackClient::Get()->Attach(); } | ||||
| void Detach() { JackClient::Get()->Detach(); } | void Detach() { JackClient::Get()->Detach(); } | ||||
| void GetPortNames(vector<string> &InputNames,vector<string> &OutputNames) { JackClient::Get()->GetPortNames(InputNames,OutputNames); } | void GetPortNames(vector<string> &InputNames,vector<string> &OutputNames) { JackClient::Get()->GetPortNames(InputNames,OutputNames); } | ||||
| void ConnectInput(int n, const string &JackPort) { JackClient::Get()->ConnectInput(n,JackPort); } | void ConnectInput(int n, const string &JackPort) { JackClient::Get()->ConnectInput(n,JackPort); } | ||||
| void ConnectOutput(int n, const string &JackPort) { JackClient::Get()->ConnectOutput(n,JackPort); } | void ConnectOutput(int n, const string &JackPort) { JackClient::Get()->ConnectOutput(n,JackPort); } | ||||
| private: | |||||
| static int m_RefCount; | static int m_RefCount; | ||||
| static int m_NoExecuted; | static int m_NoExecuted; | ||||
| bool m_UpdateNames; | |||||
| bool m_Connected; | |||||
| }; | }; | ||||
| #endif | #endif | ||||
| @@ -75,8 +75,8 @@ int OptionsList(const vector<string> &List) | |||||
| //////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////// | ||||
| JackPluginGUI::JackPluginGUI(int w, int h,JackPlugin *o,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o) | |||||
| JackPluginGUI::JackPluginGUI(int w, int h,JackPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o,ch) | |||||
| { | { | ||||
| for (int n=0; n<255; n++) Numbers[n]=n; | for (int n=0; n<255; n++) Numbers[n]=n; | ||||
| @@ -122,7 +122,7 @@ SpiralPluginGUI(w,h,o) | |||||
| end(); | end(); | ||||
| } | } | ||||
| void JackPluginGUI::UpdateValues() | |||||
| void JackPluginGUI::UpdateValues(SpiralPlugin *o) | |||||
| { | { | ||||
| } | } | ||||
| @@ -146,7 +146,26 @@ inline void JackPluginGUI::cb_OutputConnect_i(Fl_Button* o, void* v) | |||||
| { | { | ||||
| cerr<<"cb_OutputConnect_i"<<endl; | cerr<<"cb_OutputConnect_i"<<endl; | ||||
| vector<string> Inputs,Outputs; | vector<string> Inputs,Outputs; | ||||
| m_Plugin->GetPortNames(Inputs,Outputs); | |||||
| m_GUICH->Set("UpdateNames",true); | |||||
| // bit of a hack for multithreaded safety | |||||
| int ninputs=m_GUICH->GetInt("NumOutputPortNames"), | |||||
| int noutputs=m_GUICH->GetInt("NumOutputPortNames"); | |||||
| char **inputs = new char[MAX_INPUTPORTS][256]; | |||||
| char **outputs = new char[MAX_OUTPUTPORTS][256];; | |||||
| for (int n=0 n<m_GUICH->GetInt("NumInputPortNames"); n++) | |||||
| { | |||||
| Inputs.push_back(inputs[n]); | |||||
| } | |||||
| for (int n=0 n<m_GUICH->GetInt("NumOutputPortNames"); n++) | |||||
| { | |||||
| Inputs.push_back(outputs[n]); | |||||
| } | |||||
| delete[] inputs; | |||||
| delete[] outputs; | |||||
| // connect this plugin's output to a jack input | // connect this plugin's output to a jack input | ||||
| int choice=OptionsList(Inputs); | int choice=OptionsList(Inputs); | ||||
| @@ -35,14 +35,10 @@ | |||||
| class JackPluginGUI : public SpiralPluginGUI | class JackPluginGUI : public SpiralPluginGUI | ||||
| { | { | ||||
| public: | public: | ||||
| JackPluginGUI(int w, int h, JackPlugin *o,const HostInfo *Info); | |||||
| JackPluginGUI(int w, int h, JackPlugin *o,ChannelHandler *ch,const HostInfo *Info); | |||||
| virtual void UpdateValues(); | |||||
| virtual SpiralPlugin* GetPlugin() { return m_Plugin; } | |||||
| void SetAttached(bool s) { m_Indicator->value(s); } | |||||
| JackPlugin *m_Plugin; | |||||
| virtual void UpdateValues(SpiralPlugin *o); | |||||
| virtual void draw() { m_Indicator->value(m_GUICH->GetBool("Connected"); }; | |||||
| private: | private: | ||||
| @@ -45,6 +45,7 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../Widgets/Fl_LED_Button.H \ | ../Widgets/Fl_LED_Button.H \ | ||||
| @@ -54,6 +55,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| JackPluginGUI.h | JackPluginGUI.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../Widgets/Fl_LED_Button.cxx \ | ../Widgets/Fl_LED_Button.cxx \ | ||||
| @@ -63,6 +65,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| JackPluginGUI.C | JackPluginGUI.C | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../Widgets/Fl_LED_Button.o \ | ../Widgets/Fl_LED_Button.o \ | ||||
| @@ -187,3 +190,5 @@ JackPluginGUI.o: JackPluginGUI.C \ | |||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../Widgets/Fl_DragBar.H | ../Widgets/Fl_DragBar.H | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -43,6 +43,7 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| @@ -50,6 +51,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| JoystickPluginGUI.h | JoystickPluginGUI.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../../Sample.C \ | ../../Sample.C \ | ||||
| @@ -57,6 +59,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| JoystickPluginGUI.C | JoystickPluginGUI.C | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../../Sample.o \ | ../../Sample.o \ | ||||
| @@ -166,4 +169,5 @@ JoystickPluginGUI.o: JoystickPluginGUI.C \ | |||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../Widgets/Fl_DragBar.H | ../Widgets/Fl_DragBar.H | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -20,7 +20,75 @@ | |||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include "SpiralIcon.xpm" | #include "SpiralIcon.xpm" | ||||
| #include "utils.h" | #include "utils.h" | ||||
| #include <algorithm> | |||||
| //////////////////////////////////////////// | |||||
| /* FIXME: No matter what, I can't let this as it!! */ | |||||
| static LADSPAPlugin * lg = NULL; | |||||
| void describePluginLibrary(const char * pcFullFilename, void * pvPluginHandle, | |||||
| LADSPA_Descriptor_Function pfDescriptorFunction) { | |||||
| const LADSPA_Descriptor * psDescriptor; | |||||
| long lIndex; | |||||
| unsigned long lPluginIndex; | |||||
| unsigned long lPortIndex; | |||||
| unsigned long lLength; | |||||
| LADSPA_PortRangeHintDescriptor iHintDescriptor; | |||||
| LADSPA_Data fBound; | |||||
| #define testcond(c,s) { \ | |||||
| if (!(c)) { \ | |||||
| cerr << (s); \ | |||||
| failure = 1; \ | |||||
| } \ | |||||
| } | |||||
| for (lIndex = 0; (psDescriptor = pfDescriptorFunction(lIndex)) != NULL; lIndex++) { | |||||
| int failure = 0; | |||||
| testcond(!LADSPA_IS_REALTIME(psDescriptor->Properties), "ERROR: PLUGIN MUST RUN REAL TIME.\n"); | |||||
| testcond(psDescriptor->instantiate, "ERROR: PLUGIN HAS NO INSTANTIATE FUNCTION.\n"); | |||||
| testcond(psDescriptor->connect_port, "ERROR: PLUGIN HAS NO CONNECT_PORT FUNCTION.\n"); | |||||
| testcond(psDescriptor->run, "ERROR: PLUGIN HAS NO RUN FUNCTION.\n"); | |||||
| testcond(!(psDescriptor->run_adding != 0 && psDescriptor->set_run_adding_gain == 0), | |||||
| "ERROR: PLUGIN HAS RUN_ADDING FUNCTION BUT NOT SET_RUN_ADDING_GAIN.\n"); | |||||
| testcond(!(psDescriptor->run_adding == 0 && psDescriptor->set_run_adding_gain != 0), | |||||
| "ERROR: PLUGIN HAS SET_RUN_ADDING_GAIN FUNCTION BUT NOT RUN_ADDING.\n"); | |||||
| testcond(psDescriptor->cleanup, "ERROR: PLUGIN HAS NO CLEANUP FUNCTION.\n"); | |||||
| testcond(!LADSPA_IS_INPLACE_BROKEN(psDescriptor->Properties), | |||||
| "ERROR: THIS PLUGIN CANNOT USE IN-PLACE PROCESSING.\n"); | |||||
| testcond(psDescriptor->PortCount, "ERROR: PLUGIN HAS NO PORTS.\n"); | |||||
| if (!failure) { | |||||
| LPluginInfo pi; | |||||
| pi.Filename = pcFullFilename; | |||||
| pi.Label = psDescriptor->Label; | |||||
| pi.Name = psDescriptor->Name; | |||||
| /* ARGH! I really can't stand this ugly hack */ | |||||
| lg->m_LADSPAList.push_back(pi); | |||||
| } else { | |||||
| cerr << "Plugin ignored...\n\n"; | |||||
| } | |||||
| } | |||||
| dlclose(pvPluginHandle); | |||||
| } | |||||
| void LADSPAPlugin::LoadPluginList(void) | |||||
| { | |||||
| m_LADSPAList.clear(); | |||||
| m_CurrentPlugin.Name = ""; | |||||
| m_CurrentPlugin.Filename = ""; | |||||
| m_CurrentPlugin.Label = ""; | |||||
| lg = this; | |||||
| LADSPAPluginSearch(describePluginLibrary); | |||||
| lg = NULL; | |||||
| sort(m_LADSPAList.begin(), m_LADSPAList.end(), LPluginInfoSortAsc()); | |||||
| } | |||||
| //////////////////////////////////////////////////// | |||||
| extern "C" { | extern "C" { | ||||
| SpiralPlugin* CreateInstance() | SpiralPlugin* CreateInstance() | ||||
| { | { | ||||
| @@ -54,6 +122,17 @@ m_Amped(false) | |||||
| m_PluginInfo.NumInputs=0; | m_PluginInfo.NumInputs=0; | ||||
| m_PluginInfo.NumOutputs=1; | m_PluginInfo.NumOutputs=1; | ||||
| m_PluginInfo.PortTips.push_back("Nuffink yet"); | m_PluginInfo.PortTips.push_back("Nuffink yet"); | ||||
| m_AudioCH->Register("Gain",&m_Gain); | |||||
| m_AudioCH->Register("Amped",&m_Amped); | |||||
| m_AudioCH->RegisterData("Desc",ChannelHandler::OUTPUT,&PlugDesc,sizeof(PlugDesc)); | |||||
| m_AudioCH->Register("Num",&m_GUIArgs.Num); | |||||
| m_AudioCH->Register("Value",&m_GUIArgs.Value); | |||||
| m_AudioCH->Register("Clamp",&m_GUIArgs.Clamp); | |||||
| m_AudioCH->RegisterData("Filename",ChannelHandler::INPUT,&m_GUIArgs.Filename,sizeof(m_GUIArgs.Filename)); | |||||
| m_AudioCH->RegisterData("Label",ChannelHandler::INPUT,&m_GUIArgs.Label,sizeof(m_GUIArgs.Label)); | |||||
| LoadPluginList(); | |||||
| } | } | ||||
| LADSPAPlugin::~LADSPAPlugin() | LADSPAPlugin::~LADSPAPlugin() | ||||
| @@ -70,11 +149,7 @@ PluginInfo &LADSPAPlugin::Initialise(const HostInfo *Host) | |||||
| SpiralGUIType *LADSPAPlugin::CreateGUI() | SpiralGUIType *LADSPAPlugin::CreateGUI() | ||||
| { | { | ||||
| m_GUI = new LADSPAPluginGUI(m_PluginInfo.Width, | |||||
| m_PluginInfo.Height, | |||||
| this,m_HostInfo); | |||||
| m_GUI->hide(); | |||||
| return m_GUI; | |||||
| return new LADSPAPluginGUI(m_PluginInfo.Width,m_PluginInfo.Height,this,m_AudioCH,m_HostInfo,m_LADSPAList); | |||||
| } | } | ||||
| void LADSPAPlugin::Execute() | void LADSPAPlugin::Execute() | ||||
| @@ -106,7 +181,7 @@ void LADSPAPlugin::Execute() | |||||
| } | } | ||||
| } | } | ||||
| // Update the GUI outputs with the first value in the buffer | // Update the GUI outputs with the first value in the buffer | ||||
| ((LADSPAPluginGUI*)m_GUI)->UpdatePortDisplay(n,m_LADSPABufVec[n][0]); | |||||
| //((LADSPAPluginGUI*)m_GUI)->UpdatePortDisplay(n,m_LADSPABufVec[n][0]); | |||||
| } | } | ||||
| else // zero | else // zero | ||||
| { | { | ||||
| @@ -138,6 +213,20 @@ void LADSPAPlugin::Execute() | |||||
| } | } | ||||
| } | } | ||||
| void LADSPAPlugin::ExecuteCommands() | |||||
| { | |||||
| if (m_AudioCH->IsCommandWaiting()) | |||||
| { | |||||
| switch(m_AudioCH->GetCommand()) | |||||
| { | |||||
| case (SETMIN) : SetMin(m_GUIArgs.Num,m_GUIArgs.Value); break; | |||||
| case (SETMAX) : SetMax(m_GUIArgs.Num,m_GUIArgs.Value); break; | |||||
| case (SETCLAMP) : SetPortClamp(m_GUIArgs.Num,m_GUIArgs.Clamp); break; | |||||
| case (UPDATEPLUGIN) : UpdatePlugin(m_GUIArgs.Num); break; | |||||
| }; | |||||
| } | |||||
| } | |||||
| void LADSPAPlugin::StreamOut(ostream &s) | void LADSPAPlugin::StreamOut(ostream &s) | ||||
| { | { | ||||
| s<<m_Version<<" "; | s<<m_Version<<" "; | ||||
| @@ -147,8 +236,8 @@ void LADSPAPlugin::StreamOut(ostream &s) | |||||
| case 3: | case 3: | ||||
| { | { | ||||
| s<<m_Gain<<" "; | s<<m_Gain<<" "; | ||||
| s<<((LADSPAPluginGUI*)m_GUI)->GetFilename()<<" "; | |||||
| s<<((LADSPAPluginGUI*)m_GUI)->GetLabel()<<" "; | |||||
| s<<m_CurrentPlugin.Filename<<" "; | |||||
| s<<m_CurrentPlugin.Label<<" "; | |||||
| s<<m_PortMin.size()<<" "; | s<<m_PortMin.size()<<" "; | ||||
| assert(m_PortMin.size()==m_PortMax.size()); | assert(m_PortMin.size()==m_PortMax.size()); | ||||
| assert(m_PortMin.size()==m_PortClamp.size()); | assert(m_PortMin.size()==m_PortClamp.size()); | ||||
| @@ -174,8 +263,8 @@ void LADSPAPlugin::StreamOut(ostream &s) | |||||
| // version is always 3! | // version is always 3! | ||||
| { | { | ||||
| s<<m_Gain<<" "; | s<<m_Gain<<" "; | ||||
| s<<((LADSPAPluginGUI*)m_GUI)->GetFilename()<<" "; | |||||
| s<<((LADSPAPluginGUI*)m_GUI)->GetLabel()<<" "; | |||||
| s<<m_CurrentPlugin.Filename<<" "; | |||||
| s<<m_CurrentPlugin.Label<<" "; | |||||
| s<<m_PortMin.size()<<" "; | s<<m_PortMin.size()<<" "; | ||||
| assert(m_PortMin.size()==m_PortMax.size()); | assert(m_PortMin.size()==m_PortMax.size()); | ||||
| for (vector<float>::iterator i=m_PortMin.begin(); | for (vector<float>::iterator i=m_PortMin.begin(); | ||||
| @@ -194,8 +283,8 @@ void LADSPAPlugin::StreamOut(ostream &s) | |||||
| case 1: | case 1: | ||||
| { | { | ||||
| s<<m_Gain<<" "; | s<<m_Gain<<" "; | ||||
| s<<((LADSPAPluginGUI*)m_GUI)->GetFilename()<<" "; | |||||
| s<<((LADSPAPluginGUI*)m_GUI)->GetLabel()<<" "; | |||||
| s<<m_CurrentPlugin.Filename<<" "; | |||||
| s<<m_CurrentPlugin.Label<<" "; | |||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| @@ -240,10 +329,14 @@ void LADSPAPlugin::StreamIn(istream &s) | |||||
| { | { | ||||
| UpdatePlugin(Filename.c_str(), Label.c_str(), false); | UpdatePlugin(Filename.c_str(), Label.c_str(), false); | ||||
| } | } | ||||
| m_CurrentPlugin.Ports.reserve(PortCount); | |||||
| for (int n=0; n<PortCount; n++) | for (int n=0; n<PortCount; n++) | ||||
| { | { | ||||
| ((LADSPAPluginGUI*)m_GUI)->SetMinMax(n,m_PortMin[n],m_PortMax[n],m_PortClamp[n]); | |||||
| m_CurrentPlugin.Ports[n].Min=m_PortMin[n]; | |||||
| m_CurrentPlugin.Ports[n].Max=m_PortMax[n]; | |||||
| m_CurrentPlugin.Ports[n].Clamped=m_PortClamp[n]; | |||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| @@ -279,10 +372,14 @@ void LADSPAPlugin::StreamIn(istream &s) | |||||
| { | { | ||||
| UpdatePlugin(Filename.c_str(), Label.c_str(), false); | UpdatePlugin(Filename.c_str(), Label.c_str(), false); | ||||
| } | } | ||||
| m_CurrentPlugin.Ports.reserve(PortCount); | |||||
| for (int n=0; n<PortCount; n++) | for (int n=0; n<PortCount; n++) | ||||
| { | { | ||||
| ((LADSPAPluginGUI*)m_GUI)->SetMinMax(n,m_PortMin[n],m_PortMax[n],m_PortClamp[n]); | |||||
| m_CurrentPlugin.Ports[n].Min=m_PortMin[n]; | |||||
| m_CurrentPlugin.Ports[n].Max=m_PortMax[n]; | |||||
| m_CurrentPlugin.Ports[n].Clamped=m_PortClamp[n]; | |||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| @@ -303,7 +400,12 @@ void LADSPAPlugin::StreamIn(istream &s) | |||||
| } | } | ||||
| } | } | ||||
| bool LADSPAPlugin::UpdatePlugin(const char * filename, const char * label, bool PortClampReset) | |||||
| bool LADSPAPlugin::UpdatePlugin(int n) | |||||
| { | |||||
| return UpdatePlugin(m_LADSPAList[n].Filename.c_str(),m_LADSPAList[n].Label.c_str()); | |||||
| } | |||||
| bool LADSPAPlugin::UpdatePlugin(const char * filename, const char * label, bool PortClampReset=true) | |||||
| { | { | ||||
| // first call with same info, to clear the ports | // first call with same info, to clear the ports | ||||
| UpdatePluginInfoWithHost(); | UpdatePluginInfoWithHost(); | ||||
| @@ -385,11 +487,13 @@ bool LADSPAPlugin::UpdatePlugin(const char * filename, const char * label, bool | |||||
| ////////////////////////////// | ////////////////////////////// | ||||
| // Update the GUI stuff | // Update the GUI stuff | ||||
| ((LADSPAPluginGUI*)m_GUI)->SetName(PlugDesc->Name); | |||||
| ((LADSPAPluginGUI*)m_GUI)->SetMaker(PlugDesc->Maker); | |||||
| m_CurrentPlugin.Name=PlugDesc->Name; | |||||
| m_CurrentPlugin.Maker=PlugDesc->Maker; | |||||
| m_CurrentPlugin.Filename=filename; | |||||
| m_CurrentPlugin.Label=label; | |||||
| m_CurrentPlugin.Ports.clear(); | |||||
| m_PluginInfo.PortTips.clear(); | m_PluginInfo.PortTips.clear(); | ||||
| ((LADSPAPluginGUI*)m_GUI)->ClearPortInfo(); | |||||
| string desc; | string desc; | ||||
| c=0; | c=0; | ||||
| @@ -400,7 +504,11 @@ bool LADSPAPlugin::UpdatePlugin(const char * filename, const char * label, bool | |||||
| desc = string(PlugDesc->PortNames[i]) + | desc = string(PlugDesc->PortNames[i]) + | ||||
| (LADSPA_IS_PORT_CONTROL(PlugDesc->PortDescriptors[i]) ? " (CV)" : " (AU)"); | (LADSPA_IS_PORT_CONTROL(PlugDesc->PortDescriptors[i]) ? " (CV)" : " (AU)"); | ||||
| m_PluginInfo.PortTips.push_back(desc.c_str()); | m_PluginInfo.PortTips.push_back(desc.c_str()); | ||||
| ((LADSPAPluginGUI*)m_GUI)->AddPortInfo(m_PluginInfo.PortTips[c].c_str()); | |||||
| LPluginInfo::LPortDetails PortDetails; | |||||
| PortDetails.Name=m_PluginInfo.PortTips[c].c_str(); | |||||
| m_CurrentPlugin.Ports.push_back(PortDetails); | |||||
| c++; | c++; | ||||
| } | } | ||||
| } | } | ||||
| @@ -415,10 +523,7 @@ bool LADSPAPlugin::UpdatePlugin(const char * filename, const char * label, bool | |||||
| m_PluginInfo.PortTips.push_back(desc.c_str()); | m_PluginInfo.PortTips.push_back(desc.c_str()); | ||||
| } | } | ||||
| } | } | ||||
| ((LADSPAPluginGUI*)m_GUI)->SetFilename(filename); | |||||
| ((LADSPAPluginGUI*)m_GUI)->SetLabel(label); | |||||
| UpdatePluginInfoWithHost(); | UpdatePluginInfoWithHost(); | ||||
| if (PortClampReset) | if (PortClampReset) | ||||
| @@ -455,8 +560,10 @@ bool LADSPAPlugin::UpdatePlugin(const char * filename, const char * label, bool | |||||
| m_PortMax.push_back(Max); | m_PortMax.push_back(Max); | ||||
| // PortClamp defaults to true | // PortClamp defaults to true | ||||
| m_PortClamp.push_back(true); | m_PortClamp.push_back(true); | ||||
| ((LADSPAPluginGUI*)m_GUI)->SetMinMax(n, Min, Max, true); | |||||
| m_CurrentPlugin.Ports[n].Min=Min; | |||||
| m_CurrentPlugin.Ports[n].Max=Max; | |||||
| m_CurrentPlugin.Ports[n].Clamped=true; | |||||
| } | } | ||||
| } | } | ||||
| return true; | return true; | ||||
| @@ -19,12 +19,42 @@ | |||||
| #include "../SpiralPlugin.h" | #include "../SpiralPlugin.h" | ||||
| #include <FL/Fl_Pixmap.H> | #include <FL/Fl_Pixmap.H> | ||||
| #include "ladspa.h" | #include "ladspa.h" | ||||
| #include "utils.h" | |||||
| #ifndef LADSPAPLUGIN | #ifndef LADSPAPLUGIN | ||||
| #define LADSPAPLUGIN | #define LADSPAPLUGIN | ||||
| static const unsigned int NUM_PORTS = 8; | static const unsigned int NUM_PORTS = 8; | ||||
| class LPluginInfo { | |||||
| public: | |||||
| string Filename; | |||||
| string Label; | |||||
| string Name; | |||||
| string Maker; | |||||
| struct LPortDetails | |||||
| { | |||||
| string Name; | |||||
| float Min,Max; | |||||
| bool Clamped; | |||||
| }; | |||||
| vector<LPortDetails> Ports; | |||||
| bool operator<(const LPluginInfo & li) { return (Name < li.Name); } | |||||
| bool operator==(const LPluginInfo& li) { return (Name == li.Name); } | |||||
| }; | |||||
| // For sorting vectors of LPluginInfo's | |||||
| struct LPluginInfoSortAsc | |||||
| { | |||||
| bool operator()(const LPluginInfo & begin, const LPluginInfo & end) | |||||
| { | |||||
| return begin.Name < end.Name; | |||||
| } | |||||
| }; | |||||
| class LADSPAPlugin : public SpiralPlugin | class LADSPAPlugin : public SpiralPlugin | ||||
| { | { | ||||
| public: | public: | ||||
| @@ -34,24 +64,36 @@ public: | |||||
| 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); | ||||
| // has to be defined in the plugin | |||||
| virtual void UpdateGUI() { Fl::check(); } | |||||
| void SetGain(float s) { m_Gain=s; } | |||||
| float GetGain() { return m_Gain; } | float GetGain() { return m_Gain; } | ||||
| void SetMin(int n,float min) { m_PortMin[n]=min; } | |||||
| void SetMax(int n,float max) { m_PortMax[n]=max; } | |||||
| void SetPortClamp(int n,bool i) { m_PortClamp[n]=i; } | |||||
| void SetAmped(bool s) { m_Amped=s; } | |||||
| bool GetAmped() { return m_Amped; } | bool GetAmped() { return m_Amped; } | ||||
| bool UpdatePlugin(const char * filename, const char * label, bool PortClampReset=true); | |||||
| const LADSPA_Descriptor * GetPlugDesc(void) { return PlugDesc; } | |||||
| enum GUICommands{NONE,SETMIN,SETMAX,SETCLAMP,UPDATEPLUGIN}; | |||||
| struct GUIArgs | |||||
| { | |||||
| int Num; | |||||
| float Value; | |||||
| bool Clamp; | |||||
| char Filename[256]; | |||||
| char Label[256]; | |||||
| }; | |||||
| private: | private: | ||||
| GUIArgs m_GUIArgs; | |||||
| void SetMin(int n,float min) { m_PortMin[n]=min; } | |||||
| void SetMax(int n,float max) { m_PortMax[n]=max; } | |||||
| void SetPortClamp(int n,bool i) { m_PortClamp[n]=i; } | |||||
| bool UpdatePlugin(int n); | |||||
| bool UpdatePlugin(const char * filename, const char * label, bool PortClampReset=true); | |||||
| friend void describePluginLibrary(const char * pcFullFilename, void * pvPluginHandle, LADSPA_Descriptor_Function pfDescriptorFunction); | |||||
| void LoadPluginList(void); | |||||
| void * PlugHandle; | void * PlugHandle; | ||||
| const LADSPA_Descriptor * PlugDesc; | const LADSPA_Descriptor * PlugDesc; | ||||
| @@ -62,6 +104,10 @@ private: | |||||
| vector<float> m_PortMax; | vector<float> m_PortMax; | ||||
| vector<bool> m_PortClamp; | vector<bool> m_PortClamp; | ||||
| // our database of ladspa plugins | |||||
| vector<LPluginInfo> m_LADSPAList; | |||||
| LPluginInfo m_CurrentPlugin; | |||||
| float m_Gain; | float m_Gain; | ||||
| bool m_Amped; | bool m_Amped; | ||||
| }; | }; | ||||
| @@ -25,97 +25,30 @@ | |||||
| #include <math.h> | #include <math.h> | ||||
| #include <dlfcn.h> | #include <dlfcn.h> | ||||
| #include <vector> | #include <vector> | ||||
| #include <algorithm> | |||||
| #include "utils.h" | #include "utils.h" | ||||
| static const int GUI_COLOUR = 179; | static const int GUI_COLOUR = 179; | ||||
| static const int GUIBG_COLOUR = 144; | static const int GUIBG_COLOUR = 144; | ||||
| static const int GUIBG2_COLOUR = 145; | static const int GUIBG2_COLOUR = 145; | ||||
| //////////////////////////////////////////// | |||||
| /* FIXME: No matter what, I can't let this as it!! */ | |||||
| static LADSPAPluginGUI * lg = NULL; | |||||
| void describePluginLibrary(const char * pcFullFilename, void * pvPluginHandle, | |||||
| LADSPA_Descriptor_Function pfDescriptorFunction) { | |||||
| const LADSPA_Descriptor * psDescriptor; | |||||
| long lIndex; | |||||
| unsigned long lPluginIndex; | |||||
| unsigned long lPortIndex; | |||||
| unsigned long lLength; | |||||
| LADSPA_PortRangeHintDescriptor iHintDescriptor; | |||||
| LADSPA_Data fBound; | |||||
| #define testcond(c,s) { \ | |||||
| if (!(c)) { \ | |||||
| cerr << (s); \ | |||||
| failure = 1; \ | |||||
| } \ | |||||
| } | |||||
| for (lIndex = 0; (psDescriptor = pfDescriptorFunction(lIndex)) != NULL; lIndex++) { | |||||
| int failure = 0; | |||||
| testcond(!LADSPA_IS_REALTIME(psDescriptor->Properties), "ERROR: PLUGIN MUST RUN REAL TIME.\n"); | |||||
| testcond(psDescriptor->instantiate, "ERROR: PLUGIN HAS NO INSTANTIATE FUNCTION.\n"); | |||||
| testcond(psDescriptor->connect_port, "ERROR: PLUGIN HAS NO CONNECT_PORT FUNCTION.\n"); | |||||
| testcond(psDescriptor->run, "ERROR: PLUGIN HAS NO RUN FUNCTION.\n"); | |||||
| testcond(!(psDescriptor->run_adding != 0 && psDescriptor->set_run_adding_gain == 0), | |||||
| "ERROR: PLUGIN HAS RUN_ADDING FUNCTION BUT NOT SET_RUN_ADDING_GAIN.\n"); | |||||
| testcond(!(psDescriptor->run_adding == 0 && psDescriptor->set_run_adding_gain != 0), | |||||
| "ERROR: PLUGIN HAS SET_RUN_ADDING_GAIN FUNCTION BUT NOT RUN_ADDING.\n"); | |||||
| testcond(psDescriptor->cleanup, "ERROR: PLUGIN HAS NO CLEANUP FUNCTION.\n"); | |||||
| testcond(!LADSPA_IS_INPLACE_BROKEN(psDescriptor->Properties), | |||||
| "ERROR: THIS PLUGIN CANNOT USE IN-PLACE PROCESSING.\n"); | |||||
| testcond(psDescriptor->PortCount, "ERROR: PLUGIN HAS NO PORTS.\n"); | |||||
| if (!failure) { | |||||
| LPluginInfo pi; | |||||
| pi.Filename = pcFullFilename; | |||||
| pi.Label = psDescriptor->Label; | |||||
| pi.Name = psDescriptor->Name; | |||||
| /* ARGH! I really can't stand this ugly hack */ | |||||
| lg->PluginList.push_back(pi); | |||||
| } else { | |||||
| cerr << "Plugin ignored...\n\n"; | |||||
| } | |||||
| } | |||||
| dlclose(pvPluginHandle); | |||||
| } | |||||
| void LADSPAPluginGUI::refreshPluginList(void) | |||||
| { | |||||
| PluginList.clear(); | |||||
| CurrentPlugin.Name = ""; | |||||
| CurrentPlugin.Filename = ""; | |||||
| CurrentPlugin.Label = ""; | |||||
| lg = this; | |||||
| LADSPAPluginSearch(describePluginLibrary); | |||||
| lg = NULL; | |||||
| m_Browser->clear(); | |||||
| sort(PluginList.begin(), PluginList.end(), LPluginInfoSortAsc()); | |||||
| for (vector<LPluginInfo>::iterator i = PluginList.begin(); i != PluginList.end(); i++) | |||||
| { | |||||
| m_Browser->add((*i).Name.c_str()); | |||||
| } | |||||
| } | |||||
| LADSPAPluginGUI::LADSPAPluginGUI(int w, int h,LADSPAPlugin *o,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o) | |||||
| LADSPAPluginGUI::LADSPAPluginGUI(int w, int h,LADSPAPlugin *o, ChannelHandler *ch,const HostInfo *Info, const vector<LPluginInfo> &PVec) : | |||||
| SpiralPluginGUI(w,h,o,ch) | |||||
| { | { | ||||
| PluginList=PVec; | |||||
| m_Filename="None"; | m_Filename="None"; | ||||
| m_Plugin=o; | |||||
| int Width=20; | int Width=20; | ||||
| int Height=100; | int Height=100; | ||||
| m_Browser= new Fl_Hold_Browser(5,20,290,260,"LADSPA Plugins"); | m_Browser= new Fl_Hold_Browser(5,20,290,260,"LADSPA Plugins"); | ||||
| m_Browser->callback((Fl_Callback*)cb_Select); | m_Browser->callback((Fl_Callback*)cb_Select); | ||||
| for (vector<LPluginInfo>::iterator i=PluginList.begin(); | |||||
| i!=PluginList.end(); i++) | |||||
| { | |||||
| m_Browser->add((*i).Name.c_str()); | |||||
| } | |||||
| m_InputScroll = new Fl_Scroll(300,80,290,150," Value Min Max Clamp?"); | m_InputScroll = new Fl_Scroll(300,80,290,150," Value Min Max Clamp?"); | ||||
| m_InputScroll->align(FL_ALIGN_TOP_LEFT); | m_InputScroll->align(FL_ALIGN_TOP_LEFT); | ||||
| @@ -165,10 +98,6 @@ SpiralPluginGUI(w,h,o) | |||||
| m_PowerAmp->callback((Fl_Callback*)cb_PowerAmp); | m_PowerAmp->callback((Fl_Callback*)cb_PowerAmp); | ||||
| add(m_PowerAmp); | add(m_PowerAmp); | ||||
| inited = 0; | |||||
| refreshPluginList(); | |||||
| inited = 1; | |||||
| end(); | end(); | ||||
| } | } | ||||
| @@ -280,21 +209,24 @@ void LADSPAPluginGUI::AddPortInfo(const char *Info) | |||||
| } | } | ||||
| void LADSPAPluginGUI::UpdateValues() | |||||
| void LADSPAPluginGUI::UpdateValues(SpiralPlugin *o) | |||||
| { | { | ||||
| m_OutputGain->value(m_Plugin->GetGain()); | |||||
| LADSPAPlugin* Plugin = (LADSPAPlugin*)o; | |||||
| m_OutputGain->value(Plugin->GetGain()); | |||||
| } | } | ||||
| inline void LADSPAPluginGUI::cb_Gain_i(Fl_Knob* o, void* v) | inline void LADSPAPluginGUI::cb_Gain_i(Fl_Knob* o, void* v) | ||||
| { m_Plugin->SetGain(o->value()); } | |||||
| { m_GUICH->Set("Gain",(float)(o->value())); } | |||||
| void LADSPAPluginGUI::cb_Gain(Fl_Knob* o, void* v) | void LADSPAPluginGUI::cb_Gain(Fl_Knob* o, void* v) | ||||
| { ((LADSPAPluginGUI*)(o->parent()))->cb_Gain_i(o,v); } | { ((LADSPAPluginGUI*)(o->parent()))->cb_Gain_i(o,v); } | ||||
| inline void LADSPAPluginGUI::cb_Select_i(Fl_Hold_Browser* o) | inline void LADSPAPluginGUI::cb_Select_i(Fl_Hold_Browser* o) | ||||
| { | { | ||||
| m_Filename=PluginList[o->value()-1].Filename; | m_Filename=PluginList[o->value()-1].Filename; | ||||
| m_Label=PluginList[o->value()-1].Label; | |||||
| m_Plugin->UpdatePlugin(m_Filename.c_str(), m_Label.c_str()); | |||||
| m_Label=PluginList[o->value()-1].Label; | |||||
| m_GUICH->Set("Num",o->value()-1); | |||||
| m_GUICH->SetCommand(LADSPAPlugin::UPDATEPLUGIN); | |||||
| } | } | ||||
| void LADSPAPluginGUI::cb_Select(Fl_Hold_Browser* o) | void LADSPAPluginGUI::cb_Select(Fl_Hold_Browser* o) | ||||
| { ((LADSPAPluginGUI*)(o->parent()))->cb_Select_i(o);} | { ((LADSPAPluginGUI*)(o->parent()))->cb_Select_i(o);} | ||||
| @@ -305,21 +237,21 @@ inline void LADSPAPluginGUI::cb_MinMax_i(Fl_Button* o, void* v) | |||||
| for (vector<Fl_Input*>::iterator i=m_PortMin.begin(); | for (vector<Fl_Input*>::iterator i=m_PortMin.begin(); | ||||
| i!=m_PortMin.end(); i++) | i!=m_PortMin.end(); i++) | ||||
| { | { | ||||
| m_Plugin->SetMin(n,atof((*i)->value())); | |||||
| m_GUICH->Set("Min",(float)(n,atof((*i)->value()))); | |||||
| n++; | n++; | ||||
| } | } | ||||
| n=0; | n=0; | ||||
| for (vector<Fl_Input*>::iterator i=m_PortMax.begin(); | for (vector<Fl_Input*>::iterator i=m_PortMax.begin(); | ||||
| i!=m_PortMax.end(); i++) | i!=m_PortMax.end(); i++) | ||||
| { | { | ||||
| m_Plugin->SetMax(n,atof((*i)->value())); | |||||
| m_GUICH->Set("Max",(n,atof((*i)->value()))); | |||||
| n++; | n++; | ||||
| } | } | ||||
| n=0; | n=0; | ||||
| for (vector<Fl_Check_Button*>::iterator i=m_PortClamp.begin(); | for (vector<Fl_Check_Button*>::iterator i=m_PortClamp.begin(); | ||||
| i!=m_PortClamp.end(); i++) | i!=m_PortClamp.end(); i++) | ||||
| { | { | ||||
| m_Plugin->SetPortClamp(n,(*i)->value()); | |||||
| m_GUICH->Set("Clamp",(bool)(n,(*i)->value())); | |||||
| n++; | n++; | ||||
| } | } | ||||
| } | } | ||||
| @@ -328,7 +260,7 @@ void LADSPAPluginGUI::cb_MinMax(Fl_Button* o, void* v) | |||||
| inline void LADSPAPluginGUI::cb_PowerAmp_i(Fl_Button* o, void* v) | inline void LADSPAPluginGUI::cb_PowerAmp_i(Fl_Button* o, void* v) | ||||
| { | { | ||||
| m_Plugin->SetAmped(o->value()); | |||||
| m_GUICH->Set("Amped",(bool)(o->value())); | |||||
| } | } | ||||
| void LADSPAPluginGUI::cb_PowerAmp(Fl_Button* o, void* v) | void LADSPAPluginGUI::cb_PowerAmp(Fl_Button* o, void* v) | ||||
| { ((LADSPAPluginGUI*)(o->parent()))->cb_PowerAmp_i(o,v);} | { ((LADSPAPluginGUI*)(o->parent()))->cb_PowerAmp_i(o,v);} | ||||
| @@ -31,7 +31,6 @@ | |||||
| #include "../Widgets/Fl_Knob.H" | #include "../Widgets/Fl_Knob.H" | ||||
| #include <vector> | #include <vector> | ||||
| #include "ladspa.h" | |||||
| #include <string> | #include <string> | ||||
| #include "LADSPAPlugin.h" | #include "LADSPAPlugin.h" | ||||
| @@ -40,39 +39,18 @@ | |||||
| #ifndef LADSPAGUI | #ifndef LADSPAGUI | ||||
| #define LADSPAGUI | #define LADSPAGUI | ||||
| #include "ladspa.h" | |||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include <math.h> | #include <math.h> | ||||
| #include <dlfcn.h> | #include <dlfcn.h> | ||||
| #include <vector> | #include <vector> | ||||
| #include "utils.h" | |||||
| class LPluginInfo { | |||||
| public: | |||||
| string Filename; | |||||
| string Label; | |||||
| string Name; | |||||
| bool operator<(const LPluginInfo & li) { return (Name < li.Name); } | |||||
| bool operator==(const LPluginInfo& li) { return (Name == li.Name); } | |||||
| }; | |||||
| // For sorting vectors of LPluginInfo's | |||||
| struct LPluginInfoSortAsc | |||||
| { | |||||
| bool operator()(const LPluginInfo & begin, const LPluginInfo & end) | |||||
| { | |||||
| return begin.Name < end.Name; | |||||
| } | |||||
| }; | |||||
| class LADSPAPluginGUI : public SpiralPluginGUI | class LADSPAPluginGUI : public SpiralPluginGUI | ||||
| { | { | ||||
| public: | public: | ||||
| LADSPAPluginGUI(int w, int h, LADSPAPlugin *o,const HostInfo *Info); | |||||
| LADSPAPluginGUI(int w, int h, LADSPAPlugin *o, ChannelHandler *ch, const HostInfo *Info, const vector<LPluginInfo> &PVec); | |||||
| ~LADSPAPluginGUI(); | ~LADSPAPluginGUI(); | ||||
| virtual void UpdateValues(); | |||||
| virtual SpiralPlugin* GetPlugin() { return m_Plugin; } | |||||
| virtual void UpdateValues(SpiralPlugin *o); | |||||
| void SetName(const char *s); | void SetName(const char *s); | ||||
| void SetMaker(const char *s); | void SetMaker(const char *s); | ||||
| @@ -87,14 +65,9 @@ public: | |||||
| string GetLabel() { return m_Label; } | string GetLabel() { return m_Label; } | ||||
| void SetFilename(string s) { m_Filename=s; } | void SetFilename(string s) { m_Filename=s; } | ||||
| void SetLabel(string s) { m_Label=s; } | void SetLabel(string s) { m_Label=s; } | ||||
| LADSPAPlugin *m_Plugin; | |||||
| private: | private: | ||||
| vector<LPluginInfo> PluginList; | |||||
| LPluginInfo CurrentPlugin; | |||||
| friend void describePluginLibrary(const char * pcFullFilename, void * pvPluginHandle, LADSPA_Descriptor_Function pfDescriptorFunction); | |||||
| void refreshPluginList(void); | |||||
| LPluginInfo m_CurrentPlugin; | |||||
| Fl_Scroll *m_InputScroll; | Fl_Scroll *m_InputScroll; | ||||
| Fl_Pack *m_InputPack; | Fl_Pack *m_InputPack; | ||||
| @@ -110,6 +83,8 @@ private: | |||||
| vector<Fl_Input*> m_PortMax; | vector<Fl_Input*> m_PortMax; | ||||
| vector<Fl_Check_Button*> m_PortClamp; | vector<Fl_Check_Button*> m_PortClamp; | ||||
| vector<LPluginInfo> PluginList; | |||||
| // this is needed as fltk seems to crash if you delete | // this is needed as fltk seems to crash if you delete | ||||
| // the pack, is won't delete the children properly??? | // the pack, is won't delete the children properly??? | ||||
| vector<Fl_Group*> m_PackVec; | vector<Fl_Group*> m_PackVec; | ||||
| @@ -43,6 +43,7 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| @@ -52,6 +53,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| utils.h | utils.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../../Sample.C \ | ../../Sample.C \ | ||||
| @@ -63,6 +65,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| search.c | search.c | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../../Sample.o \ | ../../Sample.o \ | ||||
| @@ -190,3 +193,5 @@ misc.o: misc.c \ | |||||
| search.o: search.c \ | search.o: search.c \ | ||||
| utils.h | utils.h | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -45,6 +45,9 @@ m_TableLength (DEFAULT_TABLE_LEN) { | |||||
| m_PluginInfo.PortTips.push_back ("Output"); | m_PluginInfo.PortTips.push_back ("Output"); | ||||
| m_PluginInfo.PortTips.push_back ("'Cosine' Output"); | m_PluginInfo.PortTips.push_back ("'Cosine' Output"); | ||||
| m_PluginInfo.PortTips.push_back ("Inverted Output"); | m_PluginInfo.PortTips.push_back ("Inverted Output"); | ||||
| m_AudioCH->Register("Freq",&m_Freq); | |||||
| m_AudioCH->Register("Type",(char*)&m_Type); | |||||
| } | } | ||||
| LFOPlugin::~LFOPlugin() { | LFOPlugin::~LFOPlugin() { | ||||
| @@ -59,9 +62,7 @@ PluginInfo &LFOPlugin::Initialise (const HostInfo *Host) { | |||||
| } | } | ||||
| SpiralGUIType *LFOPlugin::CreateGUI() { | SpiralGUIType *LFOPlugin::CreateGUI() { | ||||
| m_GUI = new LFOPluginGUI(m_PluginInfo.Width, m_PluginInfo.Height, this, m_HostInfo); | |||||
| m_GUI->hide(); | |||||
| return m_GUI; | |||||
| return new LFOPluginGUI(m_PluginInfo.Width, m_PluginInfo.Height, this, m_AudioCH, m_HostInfo); | |||||
| } | } | ||||
| void LFOPlugin::WriteWaves() { | void LFOPlugin::WriteWaves() { | ||||
| @@ -34,16 +34,16 @@ class LFOPlugin : public SpiralPlugin { | |||||
| virtual void Execute(); | virtual void Execute(); | ||||
| virtual void StreamOut (ostream &s); | virtual void StreamOut (ostream &s); | ||||
| virtual void StreamIn (istream &s); | virtual void StreamIn (istream &s); | ||||
| // has to be defined in the plugin | |||||
| virtual void UpdateGUI() { Fl::check(); } | |||||
| enum Type {SINE, TRIANGLE, SQUARE, SAW}; | enum Type {SINE, TRIANGLE, SQUARE, SAW}; | ||||
| void WriteWaves(); | void WriteWaves(); | ||||
| void NoteTrigger (int V, int s, int v); | void NoteTrigger (int V, int s, int v); | ||||
| void SetFreq (float s) { m_Freq=s; } | |||||
| float GetFreq() { return m_Freq; } | float GetFreq() { return m_Freq; } | ||||
| void SetType (Type t) { m_Type=t; } | |||||
| Type GetType() { return m_Type; } | Type GetType() { return m_Type; } | ||||
| private: | private: | ||||
| float AdjustPos (float pos); | float AdjustPos (float pos); | ||||
| // Voice specific parameter | // Voice specific parameter | ||||
| int m_Note; | int m_Note; | ||||
| @@ -124,15 +124,13 @@ static unsigned char *image_Saw[] = { | |||||
| (unsigned char*)" ", | (unsigned char*)" ", | ||||
| (unsigned char*)" "}; | (unsigned char*)" "}; | ||||
| LFOPluginGUI::LFOPluginGUI(int w, int h,LFOPlugin *o,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o), | |||||
| LFOPluginGUI::LFOPluginGUI(int w, int h,LFOPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o,ch), | |||||
| pixmap_Sine(image_Sine), | pixmap_Sine(image_Sine), | ||||
| pixmap_Tri(image_Tri), | pixmap_Tri(image_Tri), | ||||
| pixmap_Square(image_Square), | pixmap_Square(image_Square), | ||||
| pixmap_Saw(image_Saw) { | pixmap_Saw(image_Saw) { | ||||
| m_Plugin=o; | |||||
| ShapeSine = new Fl_Check_Button (5, 15, 55, 30); | ShapeSine = new Fl_Check_Button (5, 15, 55, 30); | ||||
| ShapeSine->type (FL_RADIO_BUTTON); | ShapeSine->type (FL_RADIO_BUTTON); | ||||
| ShapeSine->down_box (FL_DIAMOND_DOWN_BOX); | ShapeSine->down_box (FL_DIAMOND_DOWN_BOX); | ||||
| @@ -196,18 +194,20 @@ pixmap_Saw(image_Saw) { | |||||
| end(); | end(); | ||||
| } | } | ||||
| void LFOPluginGUI::UpdateValues() { | |||||
| void LFOPluginGUI::UpdateValues(SpiralPlugin *o) { | |||||
| LFOPlugin* Plugin = (LFOPlugin*)o; | |||||
| ShapeSine->value (0); | ShapeSine->value (0); | ||||
| ShapeTri->value (0); | ShapeTri->value (0); | ||||
| ShapeSquare->value (0); | ShapeSquare->value (0); | ||||
| ShapeSaw->value (0); | ShapeSaw->value (0); | ||||
| switch (m_Plugin->GetType()) { | |||||
| switch (Plugin->GetType()) { | |||||
| case LFOPlugin::SINE : ShapeSine->value (1); break; | case LFOPlugin::SINE : ShapeSine->value (1); break; | ||||
| case LFOPlugin::TRIANGLE : ShapeTri->value (1); break; | case LFOPlugin::TRIANGLE : ShapeTri->value (1); break; | ||||
| case LFOPlugin::SQUARE : ShapeSquare->value (1); break; | case LFOPlugin::SQUARE : ShapeSquare->value (1); break; | ||||
| case LFOPlugin::SAW : ShapeSaw->value (1); break; | case LFOPlugin::SAW : ShapeSaw->value (1); break; | ||||
| } | } | ||||
| float x = m_Plugin->GetFreq(); | |||||
| float x = Plugin->GetFreq(); | |||||
| NumFreq->value (x); | NumFreq->value (x); | ||||
| x = 1 / x; | x = 1 / x; | ||||
| Perd->value (x); | Perd->value (x); | ||||
| @@ -217,8 +217,7 @@ void LFOPluginGUI::UpdateValues() { | |||||
| // Callbacks for knobs and counters | // Callbacks for knobs and counters | ||||
| inline void LFOPluginGUI::cb_Perd_i (Fl_Knob* o, void* v) { | inline void LFOPluginGUI::cb_Perd_i (Fl_Knob* o, void* v) { | ||||
| m_Plugin->SetFreq (1 / o->value()); | |||||
| UpdateValues(); | |||||
| m_GUICH->Set("Freq",(float)(1.0f / o->value())); | |||||
| } | } | ||||
| void LFOPluginGUI::cb_Perd (Fl_Knob* o, void* v) { | void LFOPluginGUI::cb_Perd (Fl_Knob* o, void* v) { | ||||
| ((LFOPluginGUI*)(o->parent()))->cb_Perd_i (o, v); | ((LFOPluginGUI*)(o->parent()))->cb_Perd_i (o, v); | ||||
| @@ -226,8 +225,7 @@ void LFOPluginGUI::cb_Perd (Fl_Knob* o, void* v) { | |||||
| inline void LFOPluginGUI::cb_NumPerd_i (Fl_Knob* o, void* v) { | inline void LFOPluginGUI::cb_NumPerd_i (Fl_Knob* o, void* v) { | ||||
| m_Plugin->SetFreq (1 / o->value()); | |||||
| UpdateValues(); | |||||
| m_GUICH->Set("Freq",(float)(1.0f / o->value())); | |||||
| } | } | ||||
| void LFOPluginGUI::cb_NumPerd (Fl_Knob* o, void* v) { | void LFOPluginGUI::cb_NumPerd (Fl_Knob* o, void* v) { | ||||
| ((LFOPluginGUI*)(o->parent()))->cb_NumPerd_i (o, v); | ((LFOPluginGUI*)(o->parent()))->cb_NumPerd_i (o, v); | ||||
| @@ -235,8 +233,7 @@ void LFOPluginGUI::cb_NumPerd (Fl_Knob* o, void* v) { | |||||
| inline void LFOPluginGUI::cb_NumFreq_i (Fl_Knob* o, void* v) { | inline void LFOPluginGUI::cb_NumFreq_i (Fl_Knob* o, void* v) { | ||||
| m_Plugin->SetFreq (o->value()); | |||||
| UpdateValues(); | |||||
| m_GUICH->Set("Freq",(float)(o->value())); | |||||
| } | } | ||||
| void LFOPluginGUI::cb_NumFreq (Fl_Knob* o, void* v) { | void LFOPluginGUI::cb_NumFreq (Fl_Knob* o, void* v) { | ||||
| @@ -246,7 +243,7 @@ void LFOPluginGUI::cb_NumFreq (Fl_Knob* o, void* v) { | |||||
| // Callbacks for waveform buttons | // Callbacks for waveform buttons | ||||
| inline void LFOPluginGUI::cb_Sine_i (Fl_Check_Button* o, void* v) { | inline void LFOPluginGUI::cb_Sine_i (Fl_Check_Button* o, void* v) { | ||||
| m_Plugin->SetType (LFOPlugin::SINE); | |||||
| m_GUICH->Set("Type",(char)(LFOPlugin::SINE)); | |||||
| } | } | ||||
| void LFOPluginGUI::cb_Sine(Fl_Check_Button* o, void* v) { | void LFOPluginGUI::cb_Sine(Fl_Check_Button* o, void* v) { | ||||
| ((LFOPluginGUI*)(o->parent()))->cb_Sine_i (o, v); | ((LFOPluginGUI*)(o->parent()))->cb_Sine_i (o, v); | ||||
| @@ -254,7 +251,7 @@ void LFOPluginGUI::cb_Sine(Fl_Check_Button* o, void* v) { | |||||
| inline void LFOPluginGUI::cb_Tri_i (Fl_Check_Button* o, void* v) { | inline void LFOPluginGUI::cb_Tri_i (Fl_Check_Button* o, void* v) { | ||||
| m_Plugin->SetType (LFOPlugin::TRIANGLE); | |||||
| m_GUICH->Set("Type",(char)(LFOPlugin::TRIANGLE)); | |||||
| } | } | ||||
| void LFOPluginGUI::cb_Tri (Fl_Check_Button* o, void* v) { | void LFOPluginGUI::cb_Tri (Fl_Check_Button* o, void* v) { | ||||
| ((LFOPluginGUI*)(o->parent()))->cb_Tri_i (o, v); | ((LFOPluginGUI*)(o->parent()))->cb_Tri_i (o, v); | ||||
| @@ -262,7 +259,7 @@ void LFOPluginGUI::cb_Tri (Fl_Check_Button* o, void* v) { | |||||
| inline void LFOPluginGUI::cb_Square_i (Fl_Check_Button* o, void* v) { | inline void LFOPluginGUI::cb_Square_i (Fl_Check_Button* o, void* v) { | ||||
| m_Plugin->SetType (LFOPlugin::SQUARE); | |||||
| m_GUICH->Set("Type",(char)(LFOPlugin::SQUARE)); | |||||
| } | } | ||||
| void LFOPluginGUI::cb_Square (Fl_Check_Button* o, void* v) { | void LFOPluginGUI::cb_Square (Fl_Check_Button* o, void* v) { | ||||
| ((LFOPluginGUI*)(o->parent()))->cb_Square_i (o, v); | ((LFOPluginGUI*)(o->parent()))->cb_Square_i (o, v); | ||||
| @@ -270,7 +267,7 @@ void LFOPluginGUI::cb_Square (Fl_Check_Button* o, void* v) { | |||||
| inline void LFOPluginGUI::cb_Saw_i (Fl_Check_Button* o, void* v) { | inline void LFOPluginGUI::cb_Saw_i (Fl_Check_Button* o, void* v) { | ||||
| m_Plugin->SetType (LFOPlugin::SAW); | |||||
| m_GUICH->Set("Type",(LFOPlugin::SAW)); | |||||
| } | } | ||||
| void LFOPluginGUI::cb_Saw (Fl_Check_Button* o, void* v) { | void LFOPluginGUI::cb_Saw (Fl_Check_Button* o, void* v) { | ||||
| ((LFOPluginGUI*)(o->parent()))->cb_Saw_i (o, v); | ((LFOPluginGUI*)(o->parent()))->cb_Saw_i (o, v); | ||||
| @@ -28,11 +28,10 @@ | |||||
| class LFOPluginGUI : public SpiralPluginGUI { | class LFOPluginGUI : public SpiralPluginGUI { | ||||
| public: | public: | ||||
| LFOPluginGUI(int w, int h, LFOPlugin *o,const HostInfo *Info); | |||||
| virtual void UpdateValues(); | |||||
| virtual SpiralPlugin* GetPlugin() { return m_Plugin; } | |||||
| LFOPlugin *m_Plugin; | |||||
| private: | |||||
| LFOPluginGUI(int w, int h, LFOPlugin *o,ChannelHandler *ch,const HostInfo *Info); | |||||
| virtual void UpdateValues(SpiralPlugin *o); | |||||
| private: | |||||
| Fl_Check_Button* ShapeSine; | Fl_Check_Button* ShapeSine; | ||||
| Fl_Pixmap pixmap_Sine; | Fl_Pixmap pixmap_Sine; | ||||
| Fl_Check_Button* ShapeTri; | Fl_Check_Button* ShapeTri; | ||||
| @@ -10,8 +10,8 @@ | |||||
| CC = gcc | CC = gcc | ||||
| CXX = g++ | CXX = g++ | ||||
| CFLAGS = -pipe -Wall -O3 -ffast-math -DNO_DEBUG -Wno-unused | |||||
| CXXFLAGS= -pipe -Wall -O3 -ffast-math -DNO_DEBUG -Wno-unused | |||||
| CFLAGS = -pipe -Wall -O3 -ffast-math -DNO_DEBUG -Wno-unused -fPIC | |||||
| CXXFLAGS= -pipe -Wall -O3 -ffast-math -DNO_DEBUG -Wno-unused -fPIC -fPIC | |||||
| INCPATH = -I/usr/X11R6/include | INCPATH = -I/usr/X11R6/include | ||||
| LINK = g++ -shared | LINK = g++ -shared | ||||
| LFLAGS = | LFLAGS = | ||||
| @@ -44,6 +44,7 @@ mandir = ${prefix}/man | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| @@ -51,6 +52,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| LFOPluginGUI.h | LFOPluginGUI.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../../Sample.C \ | ../../Sample.C \ | ||||
| @@ -58,6 +60,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| LFOPluginGUI.C | LFOPluginGUI.C | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../../Sample.o \ | ../../Sample.o \ | ||||
| @@ -165,3 +168,5 @@ LFOPluginGUI.o: LFOPluginGUI.C \ | |||||
| ../../SpiralInfo.h \ | ../../SpiralInfo.h \ | ||||
| ../../Sample.h | ../../Sample.h | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -43,6 +43,7 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| @@ -50,6 +51,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| LFOPluginGUI.h | LFOPluginGUI.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../../Sample.C \ | ../../Sample.C \ | ||||
| @@ -57,6 +59,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| LFOPluginGUI.C | LFOPluginGUI.C | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../../Sample.o \ | ../../Sample.o \ | ||||
| @@ -164,3 +167,5 @@ LFOPluginGUI.o: LFOPluginGUI.C \ | |||||
| ../../SpiralInfo.h \ | ../../SpiralInfo.h \ | ||||
| ../../Sample.h | ../../Sample.h | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -43,6 +43,7 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../Widgets/Fl_LED_Button.H \ | ../Widgets/Fl_LED_Button.H \ | ||||
| @@ -51,6 +52,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| MatrixPluginGUI.h | MatrixPluginGUI.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../Widgets/Fl_LED_Button.cxx \ | ../Widgets/Fl_LED_Button.cxx \ | ||||
| @@ -59,6 +61,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| MatrixPluginGUI.C | MatrixPluginGUI.C | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../Widgets/Fl_LED_Button.o \ | ../Widgets/Fl_LED_Button.o \ | ||||
| @@ -174,3 +177,5 @@ MatrixPluginGUI.o: MatrixPluginGUI.C \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_LED_Button.H | ../Widgets/Fl_LED_Button.H | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -101,6 +101,18 @@ m_CopyPattern(0) | |||||
| m_TriggerLevel[n]=0; | m_TriggerLevel[n]=0; | ||||
| } | } | ||||
| m_AudioCH->Register("NoteCut",&m_NoteCut,ChannelHandler::INPUT); | |||||
| m_AudioCH->Register("Current",&m_Current,ChannelHandler::INPUT); | |||||
| m_AudioCH->Register("StepTime",&m_StepTime,ChannelHandler::INPUT); | |||||
| m_AudioCH->Register("Num",&m_GUIArgs.Num,ChannelHandler::INPUT); | |||||
| m_AudioCH->Register("Length",&m_GUIArgs.Length,ChannelHandler::INPUT); | |||||
| m_AudioCH->Register("Speed",&m_GUIArgs.Speed,ChannelHandler::INPUT); | |||||
| m_AudioCH->Register("X",&m_GUIArgs.X,ChannelHandler::INPUT); | |||||
| m_AudioCH->Register("Y",&m_GUIArgs.Y,ChannelHandler::INPUT); | |||||
| m_AudioCH->Register("Octave",&m_GUIArgs.Octave,ChannelHandler::INPUT); | |||||
| m_AudioCH->Register("Step",&m_Step,ChannelHandler::OUTPUT); | |||||
| m_AudioCH->RegisterData("Matrix",ChannelHandler::OUTPUT_REQUEST,&m_Matrix,sizeof(m_Matrix)); | |||||
| } | } | ||||
| MatrixPlugin::~MatrixPlugin() | MatrixPlugin::~MatrixPlugin() | ||||
| @@ -116,11 +128,9 @@ PluginInfo &MatrixPlugin::Initialise(const HostInfo *Host) | |||||
| SpiralGUIType *MatrixPlugin::CreateGUI() | SpiralGUIType *MatrixPlugin::CreateGUI() | ||||
| { | { | ||||
| m_GUI = new MatrixPluginGUI(m_PluginInfo.Width, | |||||
| return new MatrixPluginGUI(m_PluginInfo.Width, | |||||
| m_PluginInfo.Height, | m_PluginInfo.Height, | ||||
| this,m_HostInfo); | |||||
| m_GUI->hide(); | |||||
| return m_GUI; | |||||
| this,m_AudioCH,m_HostInfo); | |||||
| } | } | ||||
| void MatrixPlugin::Execute() | void MatrixPlugin::Execute() | ||||
| @@ -157,7 +167,7 @@ void MatrixPlugin::Execute() | |||||
| // make it so the next note to trigger | // make it so the next note to trigger | ||||
| // will be the first one | // will be the first one | ||||
| if (m_GUI) ((MatrixPluginGUI*)m_GUI)->UpdateValues(); | |||||
| //if (m_GUI) ((MatrixPluginGUI*)m_GUI)->UpdateValues(); | |||||
| m_Time=m_StepTime*(1/m_Matrix[m_Current].Speed); | m_Time=m_StepTime*(1/m_Matrix[m_Current].Speed); | ||||
| m_Step=-1; | m_Step=-1; | ||||
| @@ -206,7 +216,7 @@ void MatrixPlugin::Execute() | |||||
| if (m_Step >= m_Matrix[m_Current].Length) m_Step=0; | if (m_Step >= m_Matrix[m_Current].Length) m_Step=0; | ||||
| if (m_GUI) ((MatrixPluginGUI*)m_GUI)->SetLED(m_Step); | |||||
| //if (m_GUI) ((MatrixPluginGUI*)m_GUI)->SetLED(m_Step); | |||||
| // Reset the values | // Reset the values | ||||
| m_CurrentTriggerCV=0; | m_CurrentTriggerCV=0; | ||||
| @@ -236,10 +246,52 @@ void MatrixPlugin::Execute() | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void MatrixPlugin::PastePattern() { | |||||
| cerr<<hex<<this<<dec<<endl; | |||||
| cerr<<m_CopyPattern<<endl; | |||||
| void MatrixPlugin::ExecuteCommands() | |||||
| { | |||||
| if (m_AudioCH->IsCommandWaiting()) | |||||
| { | |||||
| switch (m_AudioCH->GetCommand()) | |||||
| { | |||||
| case MAT_LENGTH : | |||||
| cerr<<m_GUIArgs.Length<<endl; | |||||
| m_Matrix[m_Current].Length=m_GUIArgs.Length; | |||||
| break; | |||||
| case MAT_SPEED : | |||||
| m_Matrix[m_Current].Speed=m_GUIArgs.Speed; | |||||
| break; | |||||
| case MAT_ACTIVATE : | |||||
| m_Matrix[m_Current].Matrix[m_GUIArgs.X][m_GUIArgs.Y]=true; | |||||
| break; | |||||
| case MAT_DEACTIVATE : | |||||
| m_Matrix[m_Current].Matrix[m_GUIArgs.X][m_GUIArgs.Y]=false; | |||||
| break; | |||||
| case MAT_OCTAVE : | |||||
| m_Matrix[m_Current].Octave=m_GUIArgs.Octave; | |||||
| break; | |||||
| case COPY : | |||||
| CopyPattern(); | |||||
| break; | |||||
| case PASTE : | |||||
| PastePattern(); | |||||
| break; | |||||
| case CLEAR : | |||||
| ClearPattern(); | |||||
| break; | |||||
| case TUP : | |||||
| if (CanTransposeUp()) TransposeUp(); | |||||
| break; | |||||
| case TDOWN : | |||||
| if (CanTransposeDown()) TransposeDown(); | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| void MatrixPlugin::PastePattern() { | |||||
| m_Matrix[m_Current].Length = m_Matrix[m_CopyPattern].Length; | m_Matrix[m_Current].Length = m_Matrix[m_CopyPattern].Length; | ||||
| m_Matrix[m_Current].Speed = m_Matrix[m_CopyPattern].Speed; | m_Matrix[m_Current].Speed = m_Matrix[m_CopyPattern].Speed; | ||||
| m_Matrix[m_Current].Octave = m_Matrix[m_CopyPattern].Octave; | m_Matrix[m_Current].Octave = m_Matrix[m_CopyPattern].Octave; | ||||
| @@ -43,20 +43,31 @@ public: | |||||
| 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); | ||||
| // has to be defined in the plugin | |||||
| virtual void UpdateGUI() { Fl::check(); } | |||||
| void SetNoteCut(bool s) { m_NoteCut=s; } | |||||
| bool GetNoteCut() { return m_NoteCut; } | bool GetNoteCut() { return m_NoteCut; } | ||||
| void SetCurrent(int s) { m_Current=s; } | |||||
| int GetCurrent() { return m_Current; } | int GetCurrent() { return m_Current; } | ||||
| void SetStepTime(float s) { m_StepTime=s; } | |||||
| float GetStepTime() { return m_StepTime; } | float GetStepTime() { return m_StepTime; } | ||||
| Pattern* GetPattern() { return &m_Matrix[m_Current]; } | Pattern* GetPattern() { return &m_Matrix[m_Current]; } | ||||
| enum GUICommands{NONE,MAT_LENGTH,MAT_SPEED,MAT_ACTIVATE,MAT_DEACTIVATE, | |||||
| MAT_OCTAVE,COPY,PASTE,CLEAR,TUP,TDOWN}; | |||||
| struct GUIArgs | |||||
| { | |||||
| int Num; | |||||
| int Length; | |||||
| float Speed; | |||||
| int X,Y; | |||||
| int Octave; | |||||
| }; | |||||
| private: | |||||
| GUIArgs m_GUIArgs; | |||||
| void CopyPattern() { m_CopyPattern = m_Current; } | void CopyPattern() { m_CopyPattern = m_Current; } | ||||
| void PastePattern(); | void PastePattern(); | ||||
| void ClearPattern(); | void ClearPattern(); | ||||
| @@ -65,7 +76,6 @@ public: | |||||
| void TransposeDown(); | void TransposeDown(); | ||||
| bool CanTransposeDown(); | bool CanTransposeDown(); | ||||
| private: | |||||
| float m_TickTime; | float m_TickTime; | ||||
| float m_StepTime; | float m_StepTime; | ||||
| float m_Time; | float m_Time; | ||||
| @@ -27,10 +27,9 @@ static const int GUIBG2_COLOUR = 145; | |||||
| //////////////////////////////////////////// | //////////////////////////////////////////// | ||||
| MatrixPluginGUI::MatrixPluginGUI(int w, int h,MatrixPlugin *o,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o) | |||||
| MatrixPluginGUI::MatrixPluginGUI(int w, int h,MatrixPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o,ch) | |||||
| { | { | ||||
| m_Plugin=o; | |||||
| //size_range(10,10); | //size_range(10,10); | ||||
| m_NoteCut = new Fl_Button (5, h-30, 85, 20,"NoteCut"); | m_NoteCut = new Fl_Button (5, h-30, 85, 20,"NoteCut"); | ||||
| m_NoteCut->type(1); | m_NoteCut->type(1); | ||||
| @@ -142,25 +141,39 @@ SpiralPluginGUI(w,h,o) | |||||
| end(); | end(); | ||||
| } | } | ||||
| void MatrixPluginGUI::UpdateValues() | |||||
| void MatrixPluginGUI::draw() | |||||
| { | |||||
| SpiralPluginGUI::draw(); | |||||
| for(int x=0; x<MATX; x++) | |||||
| { | |||||
| m_Flash[x]->value(0); | |||||
| } | |||||
| m_Flash[m_GUICH->GetInt("Step")]->value(1); | |||||
| } | |||||
| void MatrixPluginGUI::UpdateValues(SpiralPlugin *o) | |||||
| { | { | ||||
| m_Pattern->value(m_Plugin->GetCurrent()); | |||||
| m_Length->value(m_Plugin->GetPattern()->Length); | |||||
| m_Speed->value(m_Plugin->GetPattern()->Speed); | |||||
| MatrixPlugin *Plugin = (MatrixPlugin*)o; | |||||
| m_Pattern->value(Plugin->GetCurrent()); | |||||
| m_Length->value(Plugin->GetPattern()->Length); | |||||
| m_Speed->value(Plugin->GetPattern()->Speed); | |||||
| m_SpeedVal->value((int)m_Speed->value()); | m_SpeedVal->value((int)m_Speed->value()); | ||||
| m_Octave->value(m_Plugin->GetPattern()->Octave); | |||||
| m_Octave->value(Plugin->GetPattern()->Octave); | |||||
| for(int x=0; x<MATX; x++) | for(int x=0; x<MATX; x++) | ||||
| for(int y=0; y<MATY; y++) | for(int y=0; y<MATY; y++) | ||||
| { | { | ||||
| m_Matrix[x][y]->value(m_Plugin->GetPattern()->Matrix[x][y]); | |||||
| m_Matrix[x][y]->value(Plugin->GetPattern()->Matrix[x][y]); | |||||
| } | } | ||||
| if (m_Plugin->CanTransposeUp()) m_TransUpBtn->activate(); else m_TransUpBtn->deactivate(); | |||||
| if (m_Plugin->CanTransposeDown()) m_TransDnBtn->activate(); else m_TransDnBtn->deactivate(); | |||||
| //if (Plugin->CanTransposeUp()) m_TransUpBtn->activate(); else m_TransUpBtn->deactivate(); | |||||
| //if (Plugin->CanTransposeDown()) m_TransDnBtn->activate(); else m_TransDnBtn->deactivate(); | |||||
| } | } | ||||
| void MatrixPluginGUI::SetLED(int n) | |||||
| /*void MatrixPluginGUI::SetLED(int n) | |||||
| { | { | ||||
| for (int i=0; i<MATX; i++) | for (int i=0; i<MATX; i++) | ||||
| { | { | ||||
| @@ -168,20 +181,35 @@ void MatrixPluginGUI::SetLED(int n) | |||||
| } | } | ||||
| m_Flash[n]->value(true); | m_Flash[n]->value(true); | ||||
| } | |||||
| }*/ | |||||
| void MatrixPluginGUI::UpdateMatrix() | |||||
| { | |||||
| m_GUICH->RequestChannelAndWait("Matrix"); | |||||
| m_GUICH->GetData("Matrix",(void*)m_GUIMatrix); | |||||
| for(int x=0; x<MATX; x++) | |||||
| for(int y=0; y<MATY; y++) | |||||
| { | |||||
| m_Matrix[x][y]->value(m_GUIMatrix[(int)m_Pattern->value()].Matrix[x][y]); | |||||
| } | |||||
| } | |||||
| inline void MatrixPluginGUI::cb_NoteCut_i(Fl_Button* o, void* v) | inline void MatrixPluginGUI::cb_NoteCut_i(Fl_Button* o, void* v) | ||||
| { | { | ||||
| m_Plugin->SetNoteCut(o->value()); | |||||
| m_GUICH->Set("NoteCut",o->value()); | |||||
| } | } | ||||
| void MatrixPluginGUI::cb_NoteCut(Fl_Button* o, void* v) | void MatrixPluginGUI::cb_NoteCut(Fl_Button* o, void* v) | ||||
| { ((MatrixPluginGUI*)(o->parent()))->cb_NoteCut_i(o,v);} | { ((MatrixPluginGUI*)(o->parent()))->cb_NoteCut_i(o,v);} | ||||
| inline void MatrixPluginGUI::cb_Matrix_i(Fl_Button* o, void* v) | inline void MatrixPluginGUI::cb_Matrix_i(Fl_Button* o, void* v) | ||||
| { | { | ||||
| m_Plugin->GetPattern()->Matrix[*(int*)v/MATY][*(int*)v%MATY]=o->value(); | |||||
| UpdateValues(); | |||||
| m_GUICH->Set("X",*(int*)v/MATY); | |||||
| m_GUICH->Set("Y",*(int*)v%MATY); | |||||
| if (o->value()) m_GUICH->SetCommand(MatrixPlugin::MAT_ACTIVATE); | |||||
| else m_GUICH->SetCommand(MatrixPlugin::MAT_DEACTIVATE); | |||||
| } | } | ||||
| void MatrixPluginGUI::cb_Matrix(Fl_Button* o, void* v) | void MatrixPluginGUI::cb_Matrix(Fl_Button* o, void* v) | ||||
| { ((MatrixPluginGUI*)(o->parent()))->cb_Matrix_i(o,v);} | { ((MatrixPluginGUI*)(o->parent()))->cb_Matrix_i(o,v);} | ||||
| @@ -190,8 +218,8 @@ inline void MatrixPluginGUI::cb_Pattern_i(Fl_Counter* o, void* v) | |||||
| { | { | ||||
| if (o->value()<0) o->value(0); | if (o->value()<0) o->value(0); | ||||
| if (o->value()>NUM_PATTERNS-1) o->value(NUM_PATTERNS-1); | if (o->value()>NUM_PATTERNS-1) o->value(NUM_PATTERNS-1); | ||||
| m_Plugin->SetCurrent((int)o->value()); | |||||
| UpdateValues(); | |||||
| m_GUICH->Set("Current",(int)o->value()); | |||||
| UpdateMatrix(); | |||||
| } | } | ||||
| void MatrixPluginGUI::cb_Pattern(Fl_Counter* o, void* v) | void MatrixPluginGUI::cb_Pattern(Fl_Counter* o, void* v) | ||||
| { ((MatrixPluginGUI*)(o->parent()))->cb_Pattern_i(o,v);} | { ((MatrixPluginGUI*)(o->parent()))->cb_Pattern_i(o,v);} | ||||
| @@ -200,7 +228,13 @@ inline void MatrixPluginGUI::cb_Length_i(Fl_Counter* o, void* v) | |||||
| { | { | ||||
| if (o->value()<1) o->value(1); | if (o->value()<1) o->value(1); | ||||
| if (o->value()>64) o->value(64); | if (o->value()>64) o->value(64); | ||||
| m_Plugin->GetPattern()->Length=(int)o->value(); | |||||
| //m_GUICH->GetPattern()->Length=(int)o->value(); | |||||
| cerr<<(int)o->value()<<endl; | |||||
| m_GUICH->Set("Length",(int)o->value()); | |||||
| m_GUICH->SetCommand(MatrixPlugin::MAT_LENGTH); | |||||
| } | } | ||||
| void MatrixPluginGUI::cb_Length(Fl_Counter* o, void* v) | void MatrixPluginGUI::cb_Length(Fl_Counter* o, void* v) | ||||
| { ((MatrixPluginGUI*)(o->parent()))->cb_Length_i(o,v);} | { ((MatrixPluginGUI*)(o->parent()))->cb_Length_i(o,v);} | ||||
| @@ -209,8 +243,10 @@ inline void MatrixPluginGUI::cb_Speed_i(Fl_Knob* o, void* v) | |||||
| { | { | ||||
| // Round off value, but it should be a float for tweaking | // Round off value, but it should be a float for tweaking | ||||
| float value=o->value()+((int)o->value()-o->value()); | float value=o->value()+((int)o->value()-o->value()); | ||||
| m_Plugin->GetPattern()->Speed=o->value(); | |||||
| m_SpeedVal->value(value); | m_SpeedVal->value(value); | ||||
| m_GUICH->Set("Speed",(float)value); | |||||
| m_GUICH->SetCommand(MatrixPlugin::MAT_SPEED); | |||||
| } | } | ||||
| void MatrixPluginGUI::cb_Speed(Fl_Knob* o, void* v) | void MatrixPluginGUI::cb_Speed(Fl_Knob* o, void* v) | ||||
| { ((MatrixPluginGUI*)(o->parent()))->cb_Speed_i(o,v);} | { ((MatrixPluginGUI*)(o->parent()))->cb_Speed_i(o,v);} | ||||
| @@ -218,16 +254,17 @@ void MatrixPluginGUI::cb_Speed(Fl_Knob* o, void* v) | |||||
| inline void MatrixPluginGUI::cb_Octave_i(Fl_Counter* o, void* v) | inline void MatrixPluginGUI::cb_Octave_i(Fl_Counter* o, void* v) | ||||
| { | { | ||||
| if (o->value()<0) o->value(0); | if (o->value()<0) o->value(0); | ||||
| if (o->value()>6) o->value(6); | |||||
| m_Plugin->GetPattern()->Octave=(int)o->value(); | |||||
| if (o->value()>6) o->value(6); | |||||
| m_GUICH->Set("Octave",(int)o->value()); | |||||
| m_GUICH->SetCommand(MatrixPlugin::MAT_OCTAVE); | |||||
| } | } | ||||
| void MatrixPluginGUI::cb_Octave(Fl_Counter* o, void* v) | void MatrixPluginGUI::cb_Octave(Fl_Counter* o, void* v) | ||||
| { ((MatrixPluginGUI*)(o->parent()))->cb_Octave_i(o,v);} | { ((MatrixPluginGUI*)(o->parent()))->cb_Octave_i(o,v);} | ||||
| inline void MatrixPluginGUI::cb_SpeedVal_i (Fl_Counter* o, void* v) | inline void MatrixPluginGUI::cb_SpeedVal_i (Fl_Counter* o, void* v) | ||||
| { | { | ||||
| m_Speed->value (o->value()); | |||||
| m_Plugin->GetPattern()->Speed = (float)o->value() * 0.1; | |||||
| m_Speed->value(o->value()); | |||||
| } | } | ||||
| void MatrixPluginGUI::cb_SpeedVal (Fl_Counter* o, void* v) | void MatrixPluginGUI::cb_SpeedVal (Fl_Counter* o, void* v) | ||||
| @@ -238,7 +275,7 @@ void MatrixPluginGUI::cb_SpeedVal (Fl_Counter* o, void* v) | |||||
| inline void MatrixPluginGUI::cb_CopyBtn_i (Fl_Button* o, void* v) | inline void MatrixPluginGUI::cb_CopyBtn_i (Fl_Button* o, void* v) | ||||
| { | { | ||||
| m_PasteBtn->activate(); | m_PasteBtn->activate(); | ||||
| m_Plugin->CopyPattern(); | |||||
| m_GUICH->SetCommand(MatrixPlugin::COPY); | |||||
| } | } | ||||
| void MatrixPluginGUI::cb_CopyBtn (Fl_Button* o, void* v) | void MatrixPluginGUI::cb_CopyBtn (Fl_Button* o, void* v) | ||||
| @@ -248,8 +285,8 @@ void MatrixPluginGUI::cb_CopyBtn (Fl_Button* o, void* v) | |||||
| inline void MatrixPluginGUI::cb_PasteBtn_i (Fl_Button* o, void* v) | inline void MatrixPluginGUI::cb_PasteBtn_i (Fl_Button* o, void* v) | ||||
| { | { | ||||
| m_Plugin->PastePattern(); | |||||
| UpdateValues(); | |||||
| m_GUICH->SetCommand(MatrixPlugin::PASTE); | |||||
| UpdateMatrix(); | |||||
| } | } | ||||
| void MatrixPluginGUI::cb_PasteBtn (Fl_Button* o, void* v) | void MatrixPluginGUI::cb_PasteBtn (Fl_Button* o, void* v) | ||||
| @@ -259,8 +296,8 @@ void MatrixPluginGUI::cb_PasteBtn (Fl_Button* o, void* v) | |||||
| inline void MatrixPluginGUI::cb_ClearBtn_i (Fl_Button* o, void* v) | inline void MatrixPluginGUI::cb_ClearBtn_i (Fl_Button* o, void* v) | ||||
| { | { | ||||
| m_Plugin->ClearPattern(); | |||||
| UpdateValues(); | |||||
| m_GUICH->SetCommand(MatrixPlugin::CLEAR); | |||||
| UpdateMatrix(); | |||||
| } | } | ||||
| void MatrixPluginGUI::cb_ClearBtn (Fl_Button* o, void* v) | void MatrixPluginGUI::cb_ClearBtn (Fl_Button* o, void* v) | ||||
| @@ -270,8 +307,8 @@ void MatrixPluginGUI::cb_ClearBtn (Fl_Button* o, void* v) | |||||
| inline void MatrixPluginGUI::cb_TransUpBtn_i (Fl_Button* o, void* v) | inline void MatrixPluginGUI::cb_TransUpBtn_i (Fl_Button* o, void* v) | ||||
| { | { | ||||
| m_Plugin->TransposeUp(); | |||||
| UpdateValues(); | |||||
| m_GUICH->SetCommand(MatrixPlugin::TUP); | |||||
| UpdateMatrix(); | |||||
| } | } | ||||
| void MatrixPluginGUI::cb_TransUpBtn (Fl_Button* o, void* v) | void MatrixPluginGUI::cb_TransUpBtn (Fl_Button* o, void* v) | ||||
| @@ -281,8 +318,8 @@ void MatrixPluginGUI::cb_TransUpBtn (Fl_Button* o, void* v) | |||||
| inline void MatrixPluginGUI::cb_TransDnBtn_i (Fl_Button* o, void* v) | inline void MatrixPluginGUI::cb_TransDnBtn_i (Fl_Button* o, void* v) | ||||
| { | { | ||||
| m_Plugin->TransposeDown(); | |||||
| UpdateValues(); | |||||
| m_GUICH->SetCommand(MatrixPlugin::TDOWN); | |||||
| UpdateMatrix(); | |||||
| } | } | ||||
| void MatrixPluginGUI::cb_TransDnBtn (Fl_Button* o, void* v) | void MatrixPluginGUI::cb_TransDnBtn (Fl_Button* o, void* v) | ||||
| @@ -33,21 +33,19 @@ | |||||
| #ifndef MatrixGUI | #ifndef MatrixGUI | ||||
| #define MatrixGUI | #define MatrixGUI | ||||
| class MatrixPluginGUI : public SpiralPluginGUI | class MatrixPluginGUI : public SpiralPluginGUI | ||||
| { | { | ||||
| public: | public: | ||||
| MatrixPluginGUI(int w, int h, MatrixPlugin *o,const HostInfo *Info); | |||||
| virtual void UpdateValues(); | |||||
| virtual SpiralPlugin* GetPlugin() { return m_Plugin; } | |||||
| MatrixPluginGUI(int w, int h, MatrixPlugin *o,ChannelHandler *ch,const HostInfo *Info); | |||||
| virtual void draw(); | |||||
| virtual void UpdateValues(SpiralPlugin *o); | |||||
| void SetLED(int n); | |||||
| MatrixPlugin *m_Plugin; | |||||
| private: | private: | ||||
| void UpdateMatrix(); | |||||
| int Numbers[MATX*MATY]; | int Numbers[MATX*MATY]; | ||||
| Pattern m_GUIMatrix[NUM_PATTERNS]; | |||||
| Fl_Button* m_NoteCut; | Fl_Button* m_NoteCut; | ||||
| Fl_Counter* m_Pattern; | Fl_Counter* m_Pattern; | ||||
| @@ -7,8 +7,8 @@ | |||||
| CC = gcc | CC = gcc | ||||
| CXX = g++ | CXX = g++ | ||||
| CFLAGS = -pipe -Wall -O3 -ffast-math -DNO_DEBUG -Wno-unused | |||||
| CXXFLAGS= -pipe -Wall -O3 -ffast-math -DNO_DEBUG -Wno-unused | |||||
| CFLAGS = -pipe -Wall -O3 -ffast-math -DNO_DEBUG -Wno-unused -fPIC | |||||
| CXXFLAGS= -pipe -Wall -O3 -ffast-math -DNO_DEBUG -Wno-unused -fPIC -fPIC | |||||
| INCPATH = -I/usr/X11R6/include | INCPATH = -I/usr/X11R6/include | ||||
| LINK = g++ -shared | LINK = g++ -shared | ||||
| LFLAGS = | LFLAGS = | ||||
| @@ -43,6 +43,7 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| @@ -51,6 +52,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| MidiPluginGUI.h | MidiPluginGUI.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../../Sample.C \ | ../../Sample.C \ | ||||
| @@ -59,6 +61,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| MidiPluginGUI.C | MidiPluginGUI.C | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../../Sample.o \ | ../../Sample.o \ | ||||
| @@ -175,3 +178,5 @@ MidiPluginGUI.o: MidiPluginGUI.C \ | |||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../Widgets/Fl_DragBar.H | ../Widgets/Fl_DragBar.H | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -73,6 +73,12 @@ m_CurrentNote(0) | |||||
| m_PluginInfo.PortTips.push_back("Aftertouch CV"); | m_PluginInfo.PortTips.push_back("Aftertouch CV"); | ||||
| for (int n=0; n<128; n++) m_ControlLevel[n]=0; | for (int n=0; n<128; n++) m_ControlLevel[n]=0; | ||||
| m_AudioCH->Register("DeviceNum",&m_DeviceNum); | |||||
| m_AudioCH->Register("NoteCut",&m_NoteCut); | |||||
| m_AudioCH->Register("CC",&m_GUIArgs.s); | |||||
| m_AudioCH->RegisterData("Name",ChannelHandler::INPUT, | |||||
| &m_GUIArgs.Name,sizeof(m_GUIArgs.Name)); | |||||
| } | } | ||||
| MidiPlugin::~MidiPlugin() | MidiPlugin::~MidiPlugin() | ||||
| @@ -91,16 +97,14 @@ PluginInfo &MidiPlugin::Initialise(const HostInfo *Host) | |||||
| SpiralGUIType *MidiPlugin::CreateGUI() | SpiralGUIType *MidiPlugin::CreateGUI() | ||||
| { | { | ||||
| m_GUI = new MidiPluginGUI(m_PluginInfo.Width, | |||||
| return new MidiPluginGUI(m_PluginInfo.Width, | |||||
| m_PluginInfo.Height, | m_PluginInfo.Height, | ||||
| this,m_HostInfo); | |||||
| // m_GUI->show(); | |||||
| m_GUI->hide(); | |||||
| return m_GUI; | |||||
| this,m_AudioCH,m_HostInfo); | |||||
| } | } | ||||
| void MidiPlugin::Execute() | void MidiPlugin::Execute() | ||||
| { | { | ||||
| // Done to clear IsEmpty field... | // Done to clear IsEmpty field... | ||||
| GetOutputBuf(0)->Zero(); | GetOutputBuf(0)->Zero(); | ||||
| GetOutputBuf(1)->Zero(); | GetOutputBuf(1)->Zero(); | ||||
| @@ -229,6 +233,19 @@ void MidiPlugin::Execute() | |||||
| if (Triggered && !m_ContinuousNotes) SetOutput(1,0,0); | if (Triggered && !m_ContinuousNotes) SetOutput(1,0,0); | ||||
| } | } | ||||
| void MidiPlugin::ExecuteCommands() | |||||
| { | |||||
| // Process any commands from the GUI | |||||
| if (m_AudioCH->IsCommandWaiting()) | |||||
| { | |||||
| switch (m_AudioCH->GetCommand()) | |||||
| { | |||||
| case (ADDCONTROL) : AddControl(m_GUIArgs.s,m_GUIArgs.Name); break; | |||||
| case (DELCONTROL) : DeleteControl(); | |||||
| }; | |||||
| } | |||||
| } | |||||
| void MidiPlugin::AddControl(int s, const string &Name) | void MidiPlugin::AddControl(int s, const string &Name) | ||||
| { | { | ||||
| m_ControlList.push_back(s); | m_ControlList.push_back(s); | ||||
| @@ -31,22 +31,29 @@ public: | |||||
| 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); | ||||
| // has to be defined in the plugin | // has to be defined in the plugin | ||||
| virtual void UpdateGUI() { Fl::check(); } | virtual void UpdateGUI() { Fl::check(); } | ||||
| void SetDeviceNum(int s) { m_DeviceNum=s; } | |||||
| int GetDeviceNum() { return m_DeviceNum; } | int GetDeviceNum() { return m_DeviceNum; } | ||||
| void SetNoteCut(bool s) { m_NoteCut=s; } | |||||
| bool GetNoteCut() { return m_NoteCut; } | bool GetNoteCut() { return m_NoteCut; } | ||||
| void SetContinuousNotes(bool s) { m_ContinuousNotes=s; } | |||||
| bool GetContinuousNotes() { return m_ContinuousNotes; } | bool GetContinuousNotes() { return m_ContinuousNotes; } | ||||
| void AddControl(int s,const string &Name); | |||||
| void DeleteControl(); | |||||
| enum GUICommands{NONE,ADDCONTROL,DELCONTROL}; | |||||
| struct GUIArgs | |||||
| { | |||||
| int s; | |||||
| char Name[256]; | |||||
| }; | |||||
| private: | private: | ||||
| GUIArgs m_GUIArgs; | |||||
| void AddControl(int s,const string &Name); | |||||
| void DeleteControl(); | |||||
| int m_DeviceNum; | int m_DeviceNum; | ||||
| @@ -74,11 +74,9 @@ int OptionsList(const vector<string> &List) | |||||
| //////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////// | ||||
| MidiPluginGUI::MidiPluginGUI(int w, int h,MidiPlugin *o,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o) | |||||
| MidiPluginGUI::MidiPluginGUI(int w, int h,MidiPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o,ch) | |||||
| { | { | ||||
| m_Plugin=o; | |||||
| m_DeviceNum = new Fl_Counter(20,30,40,20,"Channel"); | m_DeviceNum = new Fl_Counter(20,30,40,20,"Channel"); | ||||
| m_DeviceNum->type(FL_SIMPLE_COUNTER); | m_DeviceNum->type(FL_SIMPLE_COUNTER); | ||||
| m_DeviceNum->step(1); | m_DeviceNum->step(1); | ||||
| @@ -103,24 +101,25 @@ SpiralPluginGUI(w,h,o) | |||||
| m_RemoveControl->callback((Fl_Callback*)cb_RemoveControl, NULL); | m_RemoveControl->callback((Fl_Callback*)cb_RemoveControl, NULL); | ||||
| } | } | ||||
| void MidiPluginGUI::UpdateValues() | |||||
| void MidiPluginGUI::UpdateValues(SpiralPlugin *o) | |||||
| { | { | ||||
| m_DeviceNum->value(m_Plugin->GetDeviceNum()); | |||||
| MidiPlugin *Plugin = (MidiPlugin*)o; | |||||
| m_DeviceNum->value(Plugin->GetDeviceNum()); | |||||
| } | } | ||||
| //// Callbacks //// | //// Callbacks //// | ||||
| inline void MidiPluginGUI::cb_DeviceNum_i(Fl_Counter* o, void* v) | inline void MidiPluginGUI::cb_DeviceNum_i(Fl_Counter* o, void* v) | ||||
| { m_Plugin->SetDeviceNum((int)o->value()); } | |||||
| { m_GUICH->Set("DeviceNum",(int)o->value()); } | |||||
| void MidiPluginGUI::cb_DeviceNum(Fl_Counter* o, void* v) | void MidiPluginGUI::cb_DeviceNum(Fl_Counter* o, void* v) | ||||
| { ((MidiPluginGUI*)(o->parent()))->cb_DeviceNum_i(o,v);} | { ((MidiPluginGUI*)(o->parent()))->cb_DeviceNum_i(o,v);} | ||||
| inline void MidiPluginGUI::cb_NoteCut_i(Fl_Button* o, void* v) | inline void MidiPluginGUI::cb_NoteCut_i(Fl_Button* o, void* v) | ||||
| { m_Plugin->SetNoteCut(o->value()); } | |||||
| { m_GUICH->Set("NoteCut",o->value()); } | |||||
| void MidiPluginGUI::cb_NoteCut(Fl_Button* o, void* v) | void MidiPluginGUI::cb_NoteCut(Fl_Button* o, void* v) | ||||
| { ((MidiPluginGUI*)(o->parent()))->cb_NoteCut_i(o,v);} | { ((MidiPluginGUI*)(o->parent()))->cb_NoteCut_i(o,v);} | ||||
| inline void MidiPluginGUI::cb_ContinuousNotes_i(Fl_Button* o, void* v) | inline void MidiPluginGUI::cb_ContinuousNotes_i(Fl_Button* o, void* v) | ||||
| { m_Plugin->SetContinuousNotes(o->value()); } | |||||
| { m_GUICH->Set("ContinuousNotes",o->value()); } | |||||
| void MidiPluginGUI::cb_ContinuousNotes(Fl_Button* o, void* v) | void MidiPluginGUI::cb_ContinuousNotes(Fl_Button* o, void* v) | ||||
| { ((MidiPluginGUI*)(o->parent()))->cb_ContinuousNotes_i(o,v);} | { ((MidiPluginGUI*)(o->parent()))->cb_ContinuousNotes_i(o,v);} | ||||
| @@ -258,12 +257,23 @@ inline void MidiPluginGUI::cb_AddControl_i(Fl_Button* o, void* v) | |||||
| List.push_back("127 Poly Operation"); | List.push_back("127 Poly Operation"); | ||||
| int c=OptionsList(List)-1; | int c=OptionsList(List)-1; | ||||
| if (c>-1) m_Plugin->AddControl(c,List[c]); | |||||
| if (c>-1) | |||||
| { | |||||
| m_GUICH->Set("CC",c); | |||||
| char Temp[256]; | |||||
| sprintf(Temp,"%s",List[c].c_str()); | |||||
| m_GUICH->SetData("Name",Temp); | |||||
| m_GUICH->SetCommand(MidiPlugin::ADDCONTROL); | |||||
| //m_Plugin->AddControl(c,List[c]); | |||||
| } | |||||
| } | } | ||||
| void MidiPluginGUI::cb_AddControl(Fl_Button* o, void* v) | void MidiPluginGUI::cb_AddControl(Fl_Button* o, void* v) | ||||
| { ((MidiPluginGUI*)(o->parent()))->cb_AddControl_i(o,v);} | { ((MidiPluginGUI*)(o->parent()))->cb_AddControl_i(o,v);} | ||||
| inline void MidiPluginGUI::cb_RemoveControl_i(Fl_Button* o, void* v) | inline void MidiPluginGUI::cb_RemoveControl_i(Fl_Button* o, void* v) | ||||
| { m_Plugin->DeleteControl(); } | |||||
| { | |||||
| m_GUICH->SetCommand(MidiPlugin::DELCONTROL); | |||||
| } | |||||
| void MidiPluginGUI::cb_RemoveControl(Fl_Button* o, void* v) | void MidiPluginGUI::cb_RemoveControl(Fl_Button* o, void* v) | ||||
| { ((MidiPluginGUI*)(o->parent()))->cb_RemoveControl_i(o,v);} | { ((MidiPluginGUI*)(o->parent()))->cb_RemoveControl_i(o,v);} | ||||
| @@ -36,12 +36,9 @@ int OptionsList(const vector<string> &List); | |||||
| class MidiPluginGUI : public SpiralPluginGUI | class MidiPluginGUI : public SpiralPluginGUI | ||||
| { | { | ||||
| public: | public: | ||||
| MidiPluginGUI(int w, int h, MidiPlugin *o,const HostInfo *Info); | |||||
| MidiPluginGUI(int w, int h, MidiPlugin *o,ChannelHandler *ch,const HostInfo *Info); | |||||
| virtual void UpdateValues(); | |||||
| virtual SpiralPlugin* GetPlugin() { return m_Plugin; } | |||||
| MidiPlugin *m_Plugin; | |||||
| virtual void UpdateValues(SpiralPlugin *o); | |||||
| private: | private: | ||||
| @@ -43,6 +43,7 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| @@ -50,6 +51,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| MixerPluginGUI.h | MixerPluginGUI.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../../Sample.C \ | ../../Sample.C \ | ||||
| @@ -57,6 +59,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| MixerPluginGUI.C | MixerPluginGUI.C | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../../Sample.o \ | ../../Sample.o \ | ||||
| @@ -162,3 +165,5 @@ MixerPluginGUI.o: MixerPluginGUI.C \ | |||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../Widgets/Fl_DragBar.H | ../Widgets/Fl_DragBar.H | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -56,6 +56,9 @@ MixerPlugin::MixerPlugin() | |||||
| { | { | ||||
| m_ChannelVal[n]=1.0f; | m_ChannelVal[n]=1.0f; | ||||
| } | } | ||||
| m_AudioCH->Register("Value",&m_GUIArgs.Value); | |||||
| m_AudioCH->Register("Num",&m_GUIArgs.Num); | |||||
| } | } | ||||
| MixerPlugin::~MixerPlugin() | MixerPlugin::~MixerPlugin() | ||||
| @@ -69,11 +72,9 @@ PluginInfo &MixerPlugin::Initialise(const HostInfo *Host) | |||||
| SpiralGUIType *MixerPlugin::CreateGUI() | SpiralGUIType *MixerPlugin::CreateGUI() | ||||
| { | { | ||||
| m_GUI = new MixerPluginGUI(m_PluginInfo.Width, | |||||
| return new MixerPluginGUI(m_PluginInfo.Width, | |||||
| m_PluginInfo.Height, | m_PluginInfo.Height, | ||||
| this,m_HostInfo); | |||||
| m_GUI->hide(); | |||||
| return m_GUI; | |||||
| this,m_AudioCH,m_HostInfo); | |||||
| } | } | ||||
| void MixerPlugin::Execute() | void MixerPlugin::Execute() | ||||
| @@ -88,6 +89,17 @@ void MixerPlugin::Execute() | |||||
| } | } | ||||
| } | } | ||||
| void MixerPlugin::ExecuteCommands() | |||||
| { | |||||
| if (m_AudioCH->IsCommandWaiting()) | |||||
| { | |||||
| switch (m_AudioCH->GetCommand()) | |||||
| { | |||||
| case (SETCH) : SetChannel(m_GUIArgs.Num,m_GUIArgs.Value); break; | |||||
| } | |||||
| } | |||||
| } | |||||
| void MixerPlugin::StreamOut(ostream &s) | void MixerPlugin::StreamOut(ostream &s) | ||||
| { | { | ||||
| s<<m_Version<<" "; | s<<m_Version<<" "; | ||||
| @@ -33,16 +33,27 @@ public: | |||||
| 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); | ||||
| // has to be defined in the plugin | // has to be defined in the plugin | ||||
| virtual void UpdateGUI() { Fl::check(); } | virtual void UpdateGUI() { Fl::check(); } | ||||
| void SetChannel(int n, float s) { m_ChannelVal[n]=s; } | |||||
| enum GUICommands{NONE,SETCH}; | |||||
| struct GUIArgs | |||||
| { | |||||
| int Num; | |||||
| float Value; | |||||
| }; | |||||
| float GetChannel(int n) { return m_ChannelVal[n]; } | float GetChannel(int n) { return m_ChannelVal[n]; } | ||||
| private: | private: | ||||
| GUIArgs m_GUIArgs; | |||||
| void SetChannel(int n, float s) { m_ChannelVal[n]=s; } | |||||
| float m_ChannelVal[NUM_CHANNELS]; | float m_ChannelVal[NUM_CHANNELS]; | ||||
| }; | }; | ||||
| @@ -26,11 +26,9 @@ static const int GUIBG2_COLOUR = 145; | |||||
| //////////////////////////////////////////// | //////////////////////////////////////////// | ||||
| MixerPluginGUI::MixerPluginGUI(int w, int h,MixerPlugin *o,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o) | |||||
| MixerPluginGUI::MixerPluginGUI(int w, int h,MixerPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o,ch) | |||||
| { | { | ||||
| m_Plugin=o; | |||||
| int Width=20; | int Width=20; | ||||
| int Height=100; | int Height=100; | ||||
| @@ -52,15 +50,22 @@ SpiralPluginGUI(w,h,o) | |||||
| end(); | end(); | ||||
| } | } | ||||
| void MixerPluginGUI::UpdateValues() | |||||
| void MixerPluginGUI::UpdateValues(SpiralPlugin *o) | |||||
| { | { | ||||
| MixerPlugin *Plugin = (MixerPlugin *)o; | |||||
| for (int n=0; n<NUM_CHANNELS; n++) | for (int n=0; n<NUM_CHANNELS; n++) | ||||
| { | { | ||||
| m_Chan[n]->value(2.0f-m_Plugin->GetChannel(n)); | |||||
| m_Chan[n]->value(2.0f-Plugin->GetChannel(n)); | |||||
| } | } | ||||
| } | } | ||||
| inline void MixerPluginGUI::cb_Chan_i(Fl_Slider* o, void* v) | inline void MixerPluginGUI::cb_Chan_i(Fl_Slider* o, void* v) | ||||
| { m_Plugin->SetChannel(*(int*)(v),2.0f-o->value()); } | |||||
| { | |||||
| m_GUICH->Set("Num",(*(int*)(v))); | |||||
| m_GUICH->Set("Value",(float)(2.0f-o->value())); | |||||
| m_GUICH->SetCommand(MixerPlugin::SETCH); | |||||
| } | |||||
| void MixerPluginGUI::cb_Chan(Fl_Slider* o, void* v) | void MixerPluginGUI::cb_Chan(Fl_Slider* o, void* v) | ||||
| { ((MixerPluginGUI*)(o->parent()))->cb_Chan_i(o,v);} | { ((MixerPluginGUI*)(o->parent()))->cb_Chan_i(o,v);} | ||||
| @@ -31,12 +31,10 @@ | |||||
| class MixerPluginGUI : public SpiralPluginGUI | class MixerPluginGUI : public SpiralPluginGUI | ||||
| { | { | ||||
| public: | public: | ||||
| MixerPluginGUI(int w, int h, MixerPlugin *o,const HostInfo *Info); | |||||
| MixerPluginGUI(int w, int h, MixerPlugin *o,ChannelHandler *ch,const HostInfo *Info); | |||||
| virtual void UpdateValues(); | |||||
| virtual SpiralPlugin* GetPlugin() { return m_Plugin; } | |||||
| MixerPlugin *m_Plugin; | |||||
| virtual void UpdateValues(SpiralPlugin *o); | |||||
| private: | private: | ||||
| int Numbers[NUM_CHANNELS]; | int Numbers[NUM_CHANNELS]; | ||||
| @@ -43,6 +43,7 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| @@ -50,6 +51,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| MoogFilterPluginGUI.h | MoogFilterPluginGUI.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../../Sample.C \ | ../../Sample.C \ | ||||
| @@ -57,6 +59,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| MoogFilterPluginGUI.C | MoogFilterPluginGUI.C | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../../Sample.o \ | ../../Sample.o \ | ||||
| @@ -164,3 +167,6 @@ MoogFilterPluginGUI.o: MoogFilterPluginGUI.C \ | |||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../Widgets/Fl_Knob.H | ../Widgets/Fl_Knob.H | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -71,6 +71,9 @@ t2(0.0f) | |||||
| m_PluginInfo.PortTips.push_back("LowPass output"); | m_PluginInfo.PortTips.push_back("LowPass output"); | ||||
| m_PluginInfo.PortTips.push_back("BandPass output"); | m_PluginInfo.PortTips.push_back("BandPass output"); | ||||
| m_PluginInfo.PortTips.push_back("HighPass output"); | m_PluginInfo.PortTips.push_back("HighPass output"); | ||||
| m_AudioCH->Register("Cutoff",&Cutoff); | |||||
| m_AudioCH->Register("Resonance",&Resonance); | |||||
| } | } | ||||
| MoogFilterPlugin::~MoogFilterPlugin() | MoogFilterPlugin::~MoogFilterPlugin() | ||||
| @@ -86,11 +89,9 @@ PluginInfo &MoogFilterPlugin::Initialise(const HostInfo *Host) | |||||
| SpiralGUIType *MoogFilterPlugin::CreateGUI() | SpiralGUIType *MoogFilterPlugin::CreateGUI() | ||||
| { | { | ||||
| m_GUI = new MoogFilterPluginGUI(m_PluginInfo.Width, | |||||
| return new MoogFilterPluginGUI(m_PluginInfo.Width, | |||||
| m_PluginInfo.Height, | m_PluginInfo.Height, | ||||
| this,m_HostInfo); | |||||
| m_GUI->hide(); | |||||
| return m_GUI; | |||||
| this,m_AudioCH,m_HostInfo); | |||||
| } | } | ||||
| void MoogFilterPlugin::Execute() | void MoogFilterPlugin::Execute() | ||||
| @@ -34,11 +34,6 @@ public: | |||||
| virtual void StreamOut(ostream &s); | virtual void StreamOut(ostream &s); | ||||
| virtual void StreamIn(istream &s); | virtual void StreamIn(istream &s); | ||||
| // has to be defined in the plugin | |||||
| virtual void UpdateGUI() { Fl::check(); } | |||||
| void SetCutoff(float s) { Cutoff=s; } | |||||
| void SetResonance(float s) { Resonance=s; } | |||||
| float GetCutoff() { return Cutoff; } | float GetCutoff() { return Cutoff; } | ||||
| float GetResonance() { return Resonance; } | float GetResonance() { return Resonance; } | ||||
| @@ -26,11 +26,9 @@ static const int GUIBG2_COLOUR = 145; | |||||
| //////////////////////////////////////////// | //////////////////////////////////////////// | ||||
| MoogFilterPluginGUI::MoogFilterPluginGUI(int w, int h,MoogFilterPlugin *o,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o) | |||||
| MoogFilterPluginGUI::MoogFilterPluginGUI(int w, int h,MoogFilterPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o,ch) | |||||
| { | { | ||||
| m_Plugin=o; | |||||
| Cutoff = new Fl_Slider(15, 20, 20, 70, "Cutoff"); | Cutoff = new Fl_Slider(15, 20, 20, 70, "Cutoff"); | ||||
| Cutoff->type(4); | Cutoff->type(4); | ||||
| Cutoff->selection_color(GUI_COLOUR); | Cutoff->selection_color(GUI_COLOUR); | ||||
| @@ -52,22 +50,24 @@ SpiralPluginGUI(w,h,o) | |||||
| end(); | end(); | ||||
| } | } | ||||
| void MoogFilterPluginGUI::UpdateValues() | |||||
| void MoogFilterPluginGUI::UpdateValues(SpiralPlugin *o) | |||||
| { | { | ||||
| Cutoff->value(1.0f-m_Plugin->GetCutoff()); | |||||
| Resonance->value(m_Plugin->GetResonance()); | |||||
| MoogFilterPlugin *Plugin = (MoogFilterPlugin*)o; | |||||
| Cutoff->value(1.0f-Plugin->GetCutoff()); | |||||
| Resonance->value(Plugin->GetResonance()); | |||||
| } | } | ||||
| inline void MoogFilterPluginGUI::cb_Cutoff_i(Fl_Slider* o, void* v) | inline void MoogFilterPluginGUI::cb_Cutoff_i(Fl_Slider* o, void* v) | ||||
| { | { | ||||
| float value=1.0f-o->value(); | float value=1.0f-o->value(); | ||||
| // m_Plugin->SetCutoff((value*value)+10.0f); | // m_Plugin->SetCutoff((value*value)+10.0f); | ||||
| m_Plugin->SetCutoff(value); | |||||
| m_GUICH->Set("Cutoff",value); | |||||
| } | } | ||||
| void MoogFilterPluginGUI::cb_Cutoff(Fl_Slider* o, void* v) | void MoogFilterPluginGUI::cb_Cutoff(Fl_Slider* o, void* v) | ||||
| { ((MoogFilterPluginGUI*)(o->parent()))->cb_Cutoff_i(o,v); } | { ((MoogFilterPluginGUI*)(o->parent()))->cb_Cutoff_i(o,v); } | ||||
| inline void MoogFilterPluginGUI::cb_Resonance_i(Fl_Knob* o, void* v) | inline void MoogFilterPluginGUI::cb_Resonance_i(Fl_Knob* o, void* v) | ||||
| { m_Plugin->SetResonance(o->value()); } | |||||
| { m_GUICH->Set("Resonance",o->value()); } | |||||
| void MoogFilterPluginGUI::cb_Resonance(Fl_Knob* o, void* v) | void MoogFilterPluginGUI::cb_Resonance(Fl_Knob* o, void* v) | ||||
| { ((MoogFilterPluginGUI*)(o->parent()))->cb_Resonance_i(o,v); } | { ((MoogFilterPluginGUI*)(o->parent()))->cb_Resonance_i(o,v); } | ||||
| @@ -32,12 +32,9 @@ | |||||
| class MoogFilterPluginGUI : public SpiralPluginGUI | class MoogFilterPluginGUI : public SpiralPluginGUI | ||||
| { | { | ||||
| public: | public: | ||||
| MoogFilterPluginGUI(int w, int h, MoogFilterPlugin *o,const HostInfo *Info); | |||||
| MoogFilterPluginGUI(int w, int h, MoogFilterPlugin *o,ChannelHandler *ch,const HostInfo *Info); | |||||
| virtual void UpdateValues(); | |||||
| virtual SpiralPlugin* GetPlugin() { return m_Plugin; } | |||||
| MoogFilterPlugin *m_Plugin; | |||||
| virtual void UpdateValues(SpiralPlugin *o); | |||||
| private: | private: | ||||
| @@ -43,6 +43,7 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| @@ -50,6 +51,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| NoteSnapPluginGUI.h | NoteSnapPluginGUI.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../../Sample.C \ | ../../Sample.C \ | ||||
| @@ -57,6 +59,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| NoteSnapPluginGUI.C | NoteSnapPluginGUI.C | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../../Sample.o \ | ../../Sample.o \ | ||||
| @@ -148,3 +151,5 @@ NoteSnapPlugin.o: NoteSnapPlugin.C \ | |||||
| NoteSnapPluginGUI.o: NoteSnapPluginGUI.C | NoteSnapPluginGUI.o: NoteSnapPluginGUI.C | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -62,8 +62,7 @@ PluginInfo &NoteSnapPlugin::Initialise(const HostInfo *Host) | |||||
| SpiralGUIType *NoteSnapPlugin::CreateGUI() | SpiralGUIType *NoteSnapPlugin::CreateGUI() | ||||
| { | { | ||||
| m_GUI=NULL; | |||||
| return m_GUI; | |||||
| return NULL; | |||||
| } | } | ||||
| void NoteSnapPlugin::Execute() | void NoteSnapPlugin::Execute() | ||||
| @@ -33,9 +33,6 @@ public: | |||||
| virtual void Execute(); | virtual void Execute(); | ||||
| virtual void StreamOut(ostream &s) {} | virtual void StreamOut(ostream &s) {} | ||||
| virtual void StreamIn(istream &s) {} | virtual void StreamIn(istream &s) {} | ||||
| // has to be defined in the plugin | |||||
| virtual void UpdateGUI() { Fl::check(); } | |||||
| private: | private: | ||||
| }; | }; | ||||
| @@ -26,16 +26,15 @@ static const int GUIBG2_COLOUR = 145; | |||||
| //////////////////////////////////////////// | //////////////////////////////////////////// | ||||
| NoteSnapPluginGUI::NoteSnapPluginGUI(int w, int h,NoteSnapPlugin *o,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o) | |||||
| NoteSnapPluginGUI::NoteSnapPluginGUI(int w, int h,NoteSnapPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o,ch) | |||||
| { | { | ||||
| m_Plugin=o; | |||||
| end(); | end(); | ||||
| } | } | ||||
| void NoteSnapPluginGUI::UpdateValues() | |||||
| void NoteSnapPluginGUI::UpdateValues(SpiralPlugin *o) | |||||
| { | { | ||||
| } | } | ||||
| @@ -33,12 +33,10 @@ | |||||
| class NoteSnapPluginGUI : public SpiralPluginGUI | class NoteSnapPluginGUI : public SpiralPluginGUI | ||||
| { | { | ||||
| public: | public: | ||||
| NoteSnapPluginGUI(int w, int h, NoteSnapPlugin *o,const HostInfo *Info); | |||||
| NoteSnapPluginGUI(int w, int h, NoteSnapPlugin *o,ChannelHandler *ch,const HostInfo *Info); | |||||
| virtual void UpdateValues(); | |||||
| virtual SpiralPlugin* GetPlugin() { return m_Plugin; } | |||||
| virtual void UpdateValues(SpiralPlugin *o); | |||||
| NoteSnapPlugin *m_Plugin; | |||||
| private: | private: | ||||
| //// Callbacks //// | //// Callbacks //// | ||||
| @@ -43,6 +43,7 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| @@ -50,6 +51,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| OscillatorPluginGUI.h | OscillatorPluginGUI.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../../Sample.C \ | ../../Sample.C \ | ||||
| @@ -57,6 +59,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| OscillatorPluginGUI.C | OscillatorPluginGUI.C | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../../Sample.o \ | ../../Sample.o \ | ||||
| @@ -164,3 +167,5 @@ OscillatorPluginGUI.o: OscillatorPluginGUI.C \ | |||||
| ../../SpiralInfo.h \ | ../../SpiralInfo.h \ | ||||
| ../../Sample.h | ../../Sample.h | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -71,6 +71,13 @@ m_SHModBuf(NULL) | |||||
| m_PluginInfo.PortTips.push_back("PulseWidth CV"); | m_PluginInfo.PortTips.push_back("PulseWidth CV"); | ||||
| m_PluginInfo.PortTips.push_back("Sample & Hold length CV"); | m_PluginInfo.PortTips.push_back("Sample & Hold length CV"); | ||||
| m_PluginInfo.PortTips.push_back("Output"); | m_PluginInfo.PortTips.push_back("Output"); | ||||
| m_AudioCH->Register("Octave",&m_Octave); | |||||
| m_AudioCH->Register("FineFreq",&m_FineFreq); | |||||
| m_AudioCH->Register("PulseWidth",&m_PulseWidth); | |||||
| m_AudioCH->Register("Type",(char*)&m_Type); | |||||
| m_AudioCH->Register("SHLen",&m_SHLen); | |||||
| m_AudioCH->Register("ModAmount",&m_ModAmount); | |||||
| } | } | ||||
| OscillatorPlugin::~OscillatorPlugin() | OscillatorPlugin::~OscillatorPlugin() | ||||
| @@ -84,11 +91,9 @@ PluginInfo &OscillatorPlugin::Initialise(const HostInfo *Host) | |||||
| SpiralGUIType *OscillatorPlugin::CreateGUI() | SpiralGUIType *OscillatorPlugin::CreateGUI() | ||||
| { | { | ||||
| m_GUI = new OscillatorPluginGUI(m_PluginInfo.Width, | |||||
| return new OscillatorPluginGUI(m_PluginInfo.Width, | |||||
| m_PluginInfo.Height, | m_PluginInfo.Height, | ||||
| this,m_HostInfo); | |||||
| m_GUI->hide(); | |||||
| return m_GUI; | |||||
| this,m_AudioCH,m_HostInfo); | |||||
| } | } | ||||
| void OscillatorPlugin::Execute() | void OscillatorPlugin::Execute() | ||||
| @@ -34,9 +34,6 @@ public: | |||||
| virtual void StreamOut(ostream &s); | virtual void StreamOut(ostream &s); | ||||
| virtual void StreamIn(istream &s); | virtual void StreamIn(istream &s); | ||||
| // has to be defined in the plugin | |||||
| virtual void UpdateGUI() { Fl::check(); } | |||||
| enum Type{NONE,SQUARE,SAW,NOISE}; | enum Type{NONE,SQUARE,SAW,NOISE}; | ||||
| void ModulateFreq(Sample *data) {m_FreqModBuf=data;} | void ModulateFreq(Sample *data) {m_FreqModBuf=data;} | ||||
| @@ -44,12 +41,6 @@ public: | |||||
| void ModulateSHLen(Sample *data) {m_SHModBuf=data;} | void ModulateSHLen(Sample *data) {m_SHModBuf=data;} | ||||
| void NoteTrigger(int V,int s,int v); | void NoteTrigger(int V,int s,int v); | ||||
| void SetOctave(int o) {m_Octave=o;} | |||||
| void SetFineFreq(float s) {m_FineFreq=s;} | |||||
| void SetPulseWidth(float p) {m_PulseWidth=p;} | |||||
| void SetType(Type t) {m_Type=t;} | |||||
| void SetSHLen(float s) {m_SHLen=s;} | |||||
| void SetModAmount(float s) {m_ModAmount=s;} | |||||
| int GetOctave() {return m_Octave;} | int GetOctave() {return m_Octave;} | ||||
| float GetFineFreq() {return m_FineFreq;} | float GetFineFreq() {return m_FineFreq;} | ||||
| float GetPulseWidth() {return m_PulseWidth;} | float GetPulseWidth() {return m_PulseWidth;} | ||||
| @@ -100,14 +100,12 @@ static unsigned char *image_Saw[] = { | |||||
| (unsigned char*)" "}; | (unsigned char*)" "}; | ||||
| OscillatorPluginGUI::OscillatorPluginGUI(int w, int h,OscillatorPlugin *o,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o), | |||||
| OscillatorPluginGUI::OscillatorPluginGUI(int w, int h,OscillatorPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o,ch), | |||||
| pixmap_Square(image_Square), | pixmap_Square(image_Square), | ||||
| pixmap_Noise(image_Noise), | pixmap_Noise(image_Noise), | ||||
| pixmap_Saw(image_Saw) | pixmap_Saw(image_Saw) | ||||
| { | { | ||||
| m_Plugin=o; | |||||
| ShapeSquare = new Fl_Check_Button(5, 15, 55, 30); | ShapeSquare = new Fl_Check_Button(5, 15, 55, 30); | ||||
| ShapeSquare->type(102); | ShapeSquare->type(102); | ||||
| ShapeSquare->down_box(FL_DIAMOND_DOWN_BOX); | ShapeSquare->down_box(FL_DIAMOND_DOWN_BOX); | ||||
| @@ -224,13 +222,15 @@ pixmap_Saw(image_Saw) | |||||
| extern "C" int sprintf(char *,const char *,...); | extern "C" int sprintf(char *,const char *,...); | ||||
| void OscillatorPluginGUI::UpdateValues() | |||||
| void OscillatorPluginGUI::UpdateValues(SpiralPlugin *o) | |||||
| { | { | ||||
| OscillatorPlugin *Plugin = (OscillatorPlugin*)o; | |||||
| ShapeSquare->value(0); | ShapeSquare->value(0); | ||||
| ShapeNoise->value(0); | ShapeNoise->value(0); | ||||
| ShapeSaw->value(0); | ShapeSaw->value(0); | ||||
| switch (m_Plugin->GetType()) | |||||
| switch (Plugin->GetType()) | |||||
| { | { | ||||
| case OscillatorPlugin::SQUARE : ShapeSquare->value(1); break; | case OscillatorPlugin::SQUARE : ShapeSquare->value(1); break; | ||||
| case OscillatorPlugin::NOISE : ShapeNoise->value(1); break; | case OscillatorPlugin::NOISE : ShapeNoise->value(1); break; | ||||
| @@ -238,25 +238,25 @@ void OscillatorPluginGUI::UpdateValues() | |||||
| case OscillatorPlugin::NONE : break; | case OscillatorPlugin::NONE : break; | ||||
| } | } | ||||
| Freq->value(m_Plugin->GetOctave()+3); | |||||
| ModAmount->value(m_Plugin->GetModAmount()); | |||||
| FineTune->value(sqrt(m_Plugin->GetFineFreq())); | |||||
| PulseWidth->value(m_Plugin->GetPulseWidth()); | |||||
| Freq->value(Plugin->GetOctave()+3); | |||||
| ModAmount->value(Plugin->GetModAmount()); | |||||
| FineTune->value(sqrt(Plugin->GetFineFreq())); | |||||
| PulseWidth->value(Plugin->GetPulseWidth()); | |||||
| SHLen->value(0.2f-m_Plugin->GetSHLen()); | |||||
| SHLen->value(0.2f-Plugin->GetSHLen()); | |||||
| char str[10]; | char str[10]; | ||||
| float fr = 110.0f * m_Plugin->GetFineFreq(); | |||||
| int oc = m_Plugin->GetOctave(); | |||||
| float fr = 110.0f * Plugin->GetFineFreq(); | |||||
| int oc = Plugin->GetOctave(); | |||||
| if (oc > 0) fr *= 1 << oc; | if (oc > 0) fr *= 1 << oc; | ||||
| if (oc < 0) fr /= 1 << (-oc); | if (oc < 0) fr /= 1 << (-oc); | ||||
| sprintf(str,"%4.1f Hz", fr); | sprintf(str,"%4.1f Hz", fr); | ||||
| m_out_freq->value(str); | m_out_freq->value(str); | ||||
| sprintf(str,"%4.0f %%", 100*m_Plugin->GetPulseWidth()); | |||||
| sprintf(str,"%4.0f %%", 100*Plugin->GetPulseWidth()); | |||||
| m_out_pulseW->value(str); | m_out_pulseW->value(str); | ||||
| sprintf(str,"%4.0f %%", 100*m_Plugin->GetModAmount()); | |||||
| sprintf(str,"%4.0f %%", 100*Plugin->GetModAmount()); | |||||
| m_out_mod->value(str); | m_out_mod->value(str); | ||||
| sprintf(str,"%4.3f s", m_Plugin->GetSHLen()); | |||||
| sprintf(str,"%4.3f s", Plugin->GetSHLen()); | |||||
| m_out_SHlen->value(str); | m_out_SHlen->value(str); | ||||
| } | } | ||||
| @@ -266,13 +266,13 @@ void OscillatorPluginGUI::UpdateValues() | |||||
| inline void OscillatorPluginGUI::cb_Freq_i(Fl_Knob* o, void* v) | inline void OscillatorPluginGUI::cb_Freq_i(Fl_Knob* o, void* v) | ||||
| { | { | ||||
| char str[10]; | char str[10]; | ||||
| m_Plugin->SetOctave((int)o->value()-3); | |||||
| float fr = 110.0f * m_Plugin->GetFineFreq(); | |||||
| int oc = m_Plugin->GetOctave(); | |||||
| if (oc > 0) fr *= 1 << oc; | |||||
| if (oc < 0) fr /= 1 << (-oc); | |||||
| sprintf(str,"%4.1f Hz", fr); | |||||
| m_out_freq->value(str); | |||||
| m_GUICH->Set("Octave",(int)o->value()-3); | |||||
| //float fr = 110.0f * m_Plugin->GetFineFreq(); | |||||
| //int oc = m_Plugin->GetOctave(); | |||||
| //if (oc > 0) fr *= 1 << oc; | |||||
| //if (oc < 0) fr /= 1 << (-oc); | |||||
| //sprintf(str,"%4.1f Hz", fr); | |||||
| //m_out_freq->value(str); | |||||
| } | } | ||||
| void OscillatorPluginGUI::cb_Freq(Fl_Knob* o, void* v) | void OscillatorPluginGUI::cb_Freq(Fl_Knob* o, void* v) | ||||
| @@ -281,13 +281,13 @@ void OscillatorPluginGUI::cb_Freq(Fl_Knob* o, void* v) | |||||
| inline void OscillatorPluginGUI::cb_FineTune_i(Fl_Knob* o, void* v) | inline void OscillatorPluginGUI::cb_FineTune_i(Fl_Knob* o, void* v) | ||||
| { | { | ||||
| char str[10]; | char str[10]; | ||||
| m_Plugin->SetFineFreq(o->value()*o->value()); | |||||
| float fr = 110.0f * m_Plugin->GetFineFreq(); | |||||
| int oc = m_Plugin->GetOctave(); | |||||
| if (oc > 0) fr *= 1 << oc; | |||||
| if (oc < 0) fr /= 1 << (-oc); | |||||
| sprintf(str,"%4.1f Hz", fr); | |||||
| m_out_freq->value(str); | |||||
| m_GUICH->Set("FineFreq",o->value()*o->value()); | |||||
| //float fr = 110.0f * m_Plugin->GetFineFreq(); | |||||
| //int oc = m_Plugin->GetOctave(); | |||||
| //if (oc > 0) fr *= 1 << oc; | |||||
| //if (oc < 0) fr /= 1 << (-oc); | |||||
| //sprintf(str,"%4.1f Hz", fr); | |||||
| //m_out_freq->value(str); | |||||
| } | } | ||||
| void OscillatorPluginGUI::cb_FineTune(Fl_Knob* o, void* v) | void OscillatorPluginGUI::cb_FineTune(Fl_Knob* o, void* v) | ||||
| @@ -296,7 +296,7 @@ void OscillatorPluginGUI::cb_FineTune(Fl_Knob* o, void* v) | |||||
| inline void OscillatorPluginGUI::cb_PulseWidth_i(Fl_Slider* o, void* v) | inline void OscillatorPluginGUI::cb_PulseWidth_i(Fl_Slider* o, void* v) | ||||
| { | { | ||||
| char str[10]; | char str[10]; | ||||
| m_Plugin->SetPulseWidth(o->value()); | |||||
| m_GUICH->Set("PulseWidth",o->value()); | |||||
| sprintf(str,"%4.0f %%", 100*o->value()); | sprintf(str,"%4.0f %%", 100*o->value()); | ||||
| m_out_pulseW->value(str); | m_out_pulseW->value(str); | ||||
| } | } | ||||
| @@ -305,24 +305,24 @@ void OscillatorPluginGUI::cb_PulseWidth(Fl_Slider* o, void* v) | |||||
| { ((OscillatorPluginGUI*)(o->parent()))->cb_PulseWidth_i(o,v);} | { ((OscillatorPluginGUI*)(o->parent()))->cb_PulseWidth_i(o,v);} | ||||
| inline void OscillatorPluginGUI::cb_Square_i(Fl_Check_Button* o, void* v) | inline void OscillatorPluginGUI::cb_Square_i(Fl_Check_Button* o, void* v) | ||||
| { m_Plugin->SetType(OscillatorPlugin::SQUARE); } | |||||
| { m_GUICH->Set("Type",(char)OscillatorPlugin::SQUARE); } | |||||
| void OscillatorPluginGUI::cb_Square(Fl_Check_Button* o, void* v) | void OscillatorPluginGUI::cb_Square(Fl_Check_Button* o, void* v) | ||||
| { ((OscillatorPluginGUI*)(o->parent()))->cb_Square_i(o,v); } | { ((OscillatorPluginGUI*)(o->parent()))->cb_Square_i(o,v); } | ||||
| inline void OscillatorPluginGUI::cb_Saw_i(Fl_Check_Button* o, void* v) | inline void OscillatorPluginGUI::cb_Saw_i(Fl_Check_Button* o, void* v) | ||||
| { m_Plugin->SetType(OscillatorPlugin::SAW); } | |||||
| { m_GUICH->Set("Type",(char)OscillatorPlugin::SAW); } | |||||
| void OscillatorPluginGUI::cb_Saw(Fl_Check_Button* o, void* v) | void OscillatorPluginGUI::cb_Saw(Fl_Check_Button* o, void* v) | ||||
| { ((OscillatorPluginGUI*)(o->parent()))->cb_Saw_i(o,v); } | { ((OscillatorPluginGUI*)(o->parent()))->cb_Saw_i(o,v); } | ||||
| inline void OscillatorPluginGUI::cb_Noise_i(Fl_Check_Button* o, void* v) | inline void OscillatorPluginGUI::cb_Noise_i(Fl_Check_Button* o, void* v) | ||||
| { m_Plugin->SetType(OscillatorPlugin::NOISE); } | |||||
| { m_GUICH->Set("Type",(char)OscillatorPlugin::NOISE); } | |||||
| void OscillatorPluginGUI::cb_Noise(Fl_Check_Button* o, void* v) | void OscillatorPluginGUI::cb_Noise(Fl_Check_Button* o, void* v) | ||||
| { ((OscillatorPluginGUI*)(o->parent()))->cb_Noise_i(o,v); } | { ((OscillatorPluginGUI*)(o->parent()))->cb_Noise_i(o,v); } | ||||
| inline void OscillatorPluginGUI::cb_SHLen_i(Fl_Slider* o, void* v) | inline void OscillatorPluginGUI::cb_SHLen_i(Fl_Slider* o, void* v) | ||||
| { | { | ||||
| char str[10]; | char str[10]; | ||||
| m_Plugin->SetSHLen(0.2f-o->value()); | |||||
| m_GUICH->Set("SHLen",0.2f-o->value()); | |||||
| sprintf(str,"%4.3f s", 0.2f-o->value()); | sprintf(str,"%4.3f s", 0.2f-o->value()); | ||||
| m_out_SHlen->value(str); | m_out_SHlen->value(str); | ||||
| } | } | ||||
| @@ -333,7 +333,7 @@ void OscillatorPluginGUI::cb_SHLen(Fl_Slider* o, void* v) | |||||
| inline void OscillatorPluginGUI::cb_ModAmount_i(Fl_Knob* o, void* v) | inline void OscillatorPluginGUI::cb_ModAmount_i(Fl_Knob* o, void* v) | ||||
| { | { | ||||
| char str[10]; | char str[10]; | ||||
| m_Plugin->SetModAmount(o->value()); | |||||
| m_GUICH->Set("ModAmount",o->value()); | |||||
| sprintf(str,"%4.0f %%", 100*o->value()); | sprintf(str,"%4.0f %%", 100*o->value()); | ||||
| m_out_mod->value(str); | m_out_mod->value(str); | ||||
| } | } | ||||
| @@ -33,13 +33,10 @@ | |||||
| class OscillatorPluginGUI : public SpiralPluginGUI | class OscillatorPluginGUI : public SpiralPluginGUI | ||||
| { | { | ||||
| public: | public: | ||||
| OscillatorPluginGUI(int w, int h, OscillatorPlugin *o,const HostInfo *Info); | |||||
| OscillatorPluginGUI(int w, int h, OscillatorPlugin *o,ChannelHandler *ch,const HostInfo *Info); | |||||
| virtual void UpdateValues(); | |||||
| virtual SpiralPlugin* GetPlugin() { return m_Plugin; } | |||||
| virtual void UpdateValues(SpiralPlugin *o); | |||||
| OscillatorPlugin *m_Plugin; | |||||
| private: | private: | ||||
| Fl_Check_Button *ShapeSquare; | Fl_Check_Button *ShapeSquare; | ||||
| @@ -43,6 +43,7 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| @@ -51,6 +52,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| OutputPluginGUI.h | OutputPluginGUI.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../../Sample.C \ | ../../Sample.C \ | ||||
| @@ -59,6 +61,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| OutputPluginGUI.C | OutputPluginGUI.C | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../../Sample.o \ | ../../Sample.o \ | ||||
| @@ -176,3 +179,5 @@ OutputPluginGUI.o: OutputPluginGUI.C \ | |||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../Widgets/Fl_DragBar.H | ../Widgets/Fl_DragBar.H | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -63,7 +63,8 @@ int OutputPlugin::m_NoExecuted=0; | |||||
| return; \ | return; \ | ||||
| } | } | ||||
| extern "C" { | |||||
| extern "C" | |||||
| { | |||||
| SpiralPlugin* CreateInstance() | SpiralPlugin* CreateInstance() | ||||
| { | { | ||||
| return new OutputPlugin; | return new OutputPlugin; | ||||
| @@ -97,6 +98,8 @@ OutputPlugin::OutputPlugin() | |||||
| m_PluginInfo.PortTips.push_back("Left In"); | m_PluginInfo.PortTips.push_back("Left In"); | ||||
| m_PluginInfo.PortTips.push_back("Right In"); | m_PluginInfo.PortTips.push_back("Right In"); | ||||
| m_AudioCH->Register("Mode",(char*)&m_Mode,ChannelHandler::INPUT); | |||||
| m_Mode=OUTPUT; | m_Mode=OUTPUT; | ||||
| } | } | ||||
| @@ -119,11 +122,11 @@ PluginInfo &OutputPlugin::Initialise(const HostInfo *Host) | |||||
| SpiralGUIType *OutputPlugin::CreateGUI() | SpiralGUIType *OutputPlugin::CreateGUI() | ||||
| { | { | ||||
| m_GUI = new OutputPluginGUI(m_PluginInfo.Width, | |||||
| return new OutputPluginGUI(m_PluginInfo.Width, | |||||
| m_PluginInfo.Height, | m_PluginInfo.Height, | ||||
| this,m_HostInfo); | |||||
| m_GUI->hide(); | |||||
| return m_GUI; | |||||
| this, | |||||
| m_AudioCH, | |||||
| m_HostInfo); | |||||
| } | } | ||||
| void OutputPlugin::Execute() | void OutputPlugin::Execute() | ||||
| @@ -472,6 +475,3 @@ void OSSOutput::OpenReadWrite() | |||||
| result = ioctl(m_Dspfd,SNDCTL_DSP_SPEED,&val); | result = ioctl(m_Dspfd,SNDCTL_DSP_SPEED,&val); | ||||
| CHECK_AND_REPORT_ERROR; | CHECK_AND_REPORT_ERROR; | ||||
| } | } | ||||
| @@ -74,16 +74,13 @@ public: | |||||
| virtual ~OutputPlugin(); | virtual ~OutputPlugin(); | ||||
| 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 StreamOut(ostream &s) {} | virtual void StreamOut(ostream &s) {} | ||||
| virtual void StreamIn(istream &s) {} | virtual void StreamIn(istream &s) {} | ||||
| // has to be defined in the plugin | |||||
| virtual void UpdateGUI() { Fl::check(); } | |||||
| void SetMode(Mode s) { m_Mode=s; } | |||||
| Mode GetMode() { return m_Mode; } | |||||
| private: | private: | ||||
| static int m_RefCount; | static int m_RefCount; | ||||
| static int m_NoExecuted; | static int m_NoExecuted; | ||||
| @@ -24,11 +24,9 @@ static const int GUI_COLOUR = 179; | |||||
| static const int GUIBG_COLOUR = 144; | static const int GUIBG_COLOUR = 144; | ||||
| static const int GUIBG2_COLOUR = 145; | static const int GUIBG2_COLOUR = 145; | ||||
| OutputPluginGUI::OutputPluginGUI(int w, int h,OutputPlugin *o,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o) | |||||
| OutputPluginGUI::OutputPluginGUI(int w, int h, SpiralPlugin *o, ChannelHandler *ch,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o,ch) | |||||
| { | { | ||||
| m_Plugin=o; | |||||
| Volume = new Fl_Knob(30, 22, 40, 40, "Volume"); | Volume = new Fl_Knob(30, 22, 40, 40, "Volume"); | ||||
| Volume->color(GUI_COLOUR); | Volume->color(GUI_COLOUR); | ||||
| Volume->type(Fl_Knob::DOTLIN); | Volume->type(Fl_Knob::DOTLIN); | ||||
| @@ -65,7 +63,7 @@ SpiralPluginGUI(w,h,o) | |||||
| end(); | end(); | ||||
| } | } | ||||
| void OutputPluginGUI::UpdateValues() | |||||
| void OutputPluginGUI::UpdateValues(SpiralPlugin *o) | |||||
| { | { | ||||
| Volume->value(OSSOutput::Get()->GetVolume()); | Volume->value(OSSOutput::Get()->GetVolume()); | ||||
| } | } | ||||
| @@ -108,7 +106,7 @@ inline void OutputPluginGUI::cb_OpenRead_i(Fl_Button* o, void* v) | |||||
| OpenWrite->value(0); | OpenWrite->value(0); | ||||
| OSSOutput::Get()->Close(); | OSSOutput::Get()->Close(); | ||||
| OSSOutput::Get()->OpenRead(); | OSSOutput::Get()->OpenRead(); | ||||
| m_Plugin->SetMode(OutputPlugin::INPUT); | |||||
| m_GUICH->Set("Mode",(char)OutputPlugin::INPUT); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -126,7 +124,7 @@ inline void OutputPluginGUI::cb_OpenDuplex_i(Fl_Button* o, void* v) | |||||
| OpenRead->value(0); | OpenRead->value(0); | ||||
| OSSOutput::Get()->Close(); | OSSOutput::Get()->Close(); | ||||
| OSSOutput::Get()->OpenReadWrite(); | OSSOutput::Get()->OpenReadWrite(); | ||||
| m_Plugin->SetMode(OutputPlugin::DUPLEX); | |||||
| m_GUICH->Set("Mode",(char)OutputPlugin::DUPLEX); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -144,7 +142,7 @@ inline void OutputPluginGUI::cb_OpenWrite_i(Fl_Button* o, void* v) | |||||
| OpenRead->value(0); | OpenRead->value(0); | ||||
| OSSOutput::Get()->Close(); | OSSOutput::Get()->Close(); | ||||
| OSSOutput::Get()->OpenWrite(); | OSSOutput::Get()->OpenWrite(); | ||||
| m_Plugin->SetMode(OutputPlugin::OUTPUT); | |||||
| m_GUICH->Set("Mode",(char)OutputPlugin::OUTPUT); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -33,12 +33,9 @@ | |||||
| class OutputPluginGUI : public SpiralPluginGUI | class OutputPluginGUI : public SpiralPluginGUI | ||||
| { | { | ||||
| public: | public: | ||||
| OutputPluginGUI(int w, int h, OutputPlugin *o,const HostInfo *Info); | |||||
| OutputPluginGUI(int w, int h, SpiralPlugin *o, ChannelHandler *ch, const HostInfo *Info); | |||||
| virtual void UpdateValues(); | |||||
| virtual SpiralPlugin* GetPlugin() { return m_Plugin; } | |||||
| OutputPlugin *m_Plugin; | |||||
| virtual void UpdateValues(SpiralPlugin *o); | |||||
| private: | private: | ||||
| @@ -43,6 +43,7 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | |||||
| ../Widgets/Fl_Knob.H \ | ../Widgets/Fl_Knob.H \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| @@ -51,6 +52,7 @@ HEADERS = ../SpiralPlugin.h \ | |||||
| PoshSamplerPluginGUI.h | PoshSamplerPluginGUI.h | ||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | ../Widgets/Fl_Knob.cxx \ | ||||
| ../Widgets/Fl_DragBar.cxx \ | ../Widgets/Fl_DragBar.cxx \ | ||||
| ../../Sample.C \ | ../../Sample.C \ | ||||
| @@ -59,6 +61,7 @@ SOURCES = ../SpiralPlugin.C \ | |||||
| PoshSamplerPluginGUI.C | PoshSamplerPluginGUI.C | ||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | ../Widgets/Fl_Knob.o \ | ||||
| ../Widgets/Fl_DragBar.o \ | ../Widgets/Fl_DragBar.o \ | ||||
| ../../Sample.o \ | ../../Sample.o \ | ||||
| @@ -174,3 +177,5 @@ PoshSamplerPluginGUI.o: PoshSamplerPluginGUI.C \ | |||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../Widgets/Fl_Knob.H | ../Widgets/Fl_Knob.H | ||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -118,6 +118,20 @@ m_Recording(false) | |||||
| } | } | ||||
| m_Version=3; | m_Version=3; | ||||
| m_Current = 0; | |||||
| m_AudioCH->Register("Num",&m_GUIArgs.Num); | |||||
| m_AudioCH->Register("Value",&m_GUIArgs.Value); | |||||
| m_AudioCH->Register("Bool",&m_GUIArgs.Boole); | |||||
| m_AudioCH->Register("Int",&m_GUIArgs.Int); | |||||
| m_AudioCH->Register("Start",&m_GUIArgs.Start); | |||||
| m_AudioCH->Register("End",&m_GUIArgs.End); | |||||
| m_AudioCH->Register("LoopStart",&m_GUIArgs.LoopStart); | |||||
| m_AudioCH->RegisterData("Name",ChannelHandler::INPUT,&m_GUIArgs.Name,sizeof(m_GUIArgs.Name)); | |||||
| m_AudioCH->Register("PlayPos",&m_CurrentPlayPos,ChannelHandler::OUTPUT); | |||||
| m_AudioCH->RegisterData("SampleBuffer",ChannelHandler::OUTPUT_REQUEST,&m_SampleBuffer,TRANSBUF_SIZE); | |||||
| m_AudioCH->Register("SampleSize",&m_SampleSize,ChannelHandler::OUTPUT_REQUEST); | |||||
| } | } | ||||
| PoshSamplerPlugin::~PoshSamplerPlugin() | PoshSamplerPlugin::~PoshSamplerPlugin() | ||||
| @@ -142,11 +156,9 @@ PluginInfo &PoshSamplerPlugin::Initialise(const HostInfo *Host) | |||||
| SpiralGUIType *PoshSamplerPlugin::CreateGUI() | SpiralGUIType *PoshSamplerPlugin::CreateGUI() | ||||
| { | { | ||||
| m_GUI = new PoshSamplerPluginGUI(m_PluginInfo.Width, | |||||
| return new PoshSamplerPluginGUI(m_PluginInfo.Width, | |||||
| m_PluginInfo.Height, | m_PluginInfo.Height, | ||||
| this,m_HostInfo); | |||||
| m_GUI->hide(); | |||||
| return m_GUI; | |||||
| this,m_AudioCH,m_HostInfo); | |||||
| } | } | ||||
| void PoshSamplerPlugin::Execute() | void PoshSamplerPlugin::Execute() | ||||
| @@ -249,14 +261,12 @@ void PoshSamplerPlugin::Execute() | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| PoshSamplerPluginGUI *GUI=(PoshSamplerPluginGUI *)m_GUI; | |||||
| // record | // record | ||||
| static int LastRecording=false; | static int LastRecording=false; | ||||
| if(m_Recording && InputExists(REC_INPUT)) | if(m_Recording && InputExists(REC_INPUT)) | ||||
| { | { | ||||
| int s=GUI->GetCurrentSample(); | |||||
| int s=0;//GUI->GetCurrentSample(); | |||||
| if (!LastRecording) m_SampleVec[s]->Clear(); | if (!LastRecording) m_SampleVec[s]->Clear(); | ||||
| @@ -279,13 +289,49 @@ void PoshSamplerPlugin::Execute() | |||||
| } | } | ||||
| LastRecording=m_Recording; | LastRecording=m_Recording; | ||||
| if (m_SampleDescVec[GUI->GetCurrentSample()]->SamplePos>0) | |||||
| if (m_SampleDescVec[m_Current]->SamplePos>0) | |||||
| { | { | ||||
| GUI->SetPlayPos((int)m_SampleDescVec[GUI->GetCurrentSample()]->SamplePos); | |||||
| m_CurrentPlayPos=(long)m_SampleDescVec[m_Current]->SamplePos; | |||||
| } | } | ||||
| } | } | ||||
| #include <FL/fl_file_chooser.H> | |||||
| void PoshSamplerPlugin::ExecuteCommands() | |||||
| { | |||||
| if (m_AudioCH->IsCommandWaiting()) | |||||
| { | |||||
| switch(m_AudioCH->GetCommand()) | |||||
| { | |||||
| case (LOAD) : LoadSample(m_GUIArgs.Num,m_GUIArgs.Name); break; | |||||
| case (SAVE) : SaveSample(m_GUIArgs.Num,m_GUIArgs.Name); break; | |||||
| case (SETVOL) : SetVolume(m_GUIArgs.Num,m_GUIArgs.Value); break; | |||||
| case (SETPITCH) : SetPitch(m_GUIArgs.Num,m_GUIArgs.Value); break; | |||||
| case (SETLOOP) : SetLoop(m_GUIArgs.Num,m_GUIArgs.Boole); break; | |||||
| case (SETPING) : SetPingPong(m_GUIArgs.Num,m_GUIArgs.Boole); break; | |||||
| case (SETNOTE) : SetNote(m_GUIArgs.Num,m_GUIArgs.Int); break; | |||||
| case (SETOCT) : SetOctave(m_GUIArgs.Num,m_GUIArgs.Int); break; | |||||
| case (SETPLAYPOINTS): | |||||
| { | |||||
| SetPlayStart(m_GUIArgs.Num,m_GUIArgs.Start); | |||||
| SetLoopStart(m_GUIArgs.Num,m_GUIArgs.LoopStart); | |||||
| SetLoopEnd(m_GUIArgs.Num,m_GUIArgs.End); | |||||
| } break; | |||||
| case (SETREC) : SetRecord(m_GUIArgs.Boole); break; | |||||
| case (CUT) : Cut(m_GUIArgs.Num,m_GUIArgs.Start,m_GUIArgs.End); break; | |||||
| case (COPY) : Copy(m_GUIArgs.Num,m_GUIArgs.Start,m_GUIArgs.End); break; | |||||
| case (PASTE) : Paste(m_GUIArgs.Num,m_GUIArgs.Start,m_GUIArgs.End); break; | |||||
| case (MIX) : Mix(m_GUIArgs.Num,m_GUIArgs.Start,m_GUIArgs.End); break; | |||||
| case (CROP) : Crop(m_GUIArgs.Num,m_GUIArgs.Start,m_GUIArgs.End); break; | |||||
| case (REV) : Reverse(m_GUIArgs.Num,m_GUIArgs.Start,m_GUIArgs.End); break; | |||||
| case (AMP) : Amp(m_GUIArgs.Num,m_GUIArgs.Start,m_GUIArgs.End); break; | |||||
| case (SETCURRENT) : m_Current = m_GUIArgs.Num; break; | |||||
| case (GETSAMPLE) : | |||||
| { | |||||
| m_AudioCH->SetupBulkTransfer((void*)m_SampleVec[m_Current]->GetBuffer()); | |||||
| m_SampleSize=m_SampleVec[m_Current]->GetLengthInBytes(); | |||||
| } break; | |||||
| }; | |||||
| } | |||||
| } | |||||
| void PoshSamplerPlugin::StreamOut(ostream &s) | void PoshSamplerPlugin::StreamOut(ostream &s) | ||||
| { | { | ||||
| @@ -334,8 +380,6 @@ void PoshSamplerPlugin::StreamIn(istream &s) | |||||
| s.get(Buf,size+1); | s.get(Buf,size+1); | ||||
| } | } | ||||
| } | } | ||||
| ((PoshSamplerPluginGUI*)m_GUI)->UpdateValues(); | |||||
| } | } | ||||
| void PoshSamplerPlugin::LoadSample(int n, const string &Name) | void PoshSamplerPlugin::LoadSample(int n, const string &Name) | ||||
| @@ -349,7 +393,7 @@ void PoshSamplerPlugin::LoadSample(int n, const string &Name) | |||||
| m_SampleDescVec[n]->SampleRate=Wav.GetSamplerate(); | m_SampleDescVec[n]->SampleRate=Wav.GetSamplerate(); | ||||
| m_SampleDescVec[n]->Stereo=Wav.IsStereo(); | m_SampleDescVec[n]->Stereo=Wav.IsStereo(); | ||||
| m_SampleDescVec[n]->Pitch *= m_SampleDescVec[n]->SampleRate/(float)m_HostInfo->SAMPLERATE; | m_SampleDescVec[n]->Pitch *= m_SampleDescVec[n]->SampleRate/(float)m_HostInfo->SAMPLERATE; | ||||
| m_SampleDescVec[n]->LoopEnd=m_SampleVec[n]->GetLength()-1; | |||||
| m_SampleDescVec[n]->LoopEnd=m_SampleVec[n]->GetLength()-1; | |||||
| } | } | ||||
| } | } | ||||