From bd37b5535169f85f87c962df4b9c29855b9aa280 Mon Sep 17 00:00:00 2001 From: edgeeffect Date: Sat, 18 Jan 2003 20:38:27 +0000 Subject: [PATCH] Rotary switch emulation - SplitSwitchPlugin --- .../Plugins/SplitSwitchPlugin/Makefile.in | 170 +++++++++ .../Plugins/SplitSwitchPlugin/SpiralIcon.xpm | 325 ++++++++++++++++++ .../SplitSwitchPlugin/SplitSwitchPlugin.C | 146 ++++++++ .../SplitSwitchPlugin/SplitSwitchPlugin.h | 56 +++ .../SplitSwitchPlugin/SplitSwitchPluginGUI.C | 95 +++++ .../SplitSwitchPlugin/SplitSwitchPluginGUI.h | 45 +++ 6 files changed, 837 insertions(+) create mode 100644 SpiralSound/Plugins/SplitSwitchPlugin/Makefile.in create mode 100644 SpiralSound/Plugins/SplitSwitchPlugin/SpiralIcon.xpm create mode 100644 SpiralSound/Plugins/SplitSwitchPlugin/SplitSwitchPlugin.C create mode 100644 SpiralSound/Plugins/SplitSwitchPlugin/SplitSwitchPlugin.h create mode 100644 SpiralSound/Plugins/SplitSwitchPlugin/SplitSwitchPluginGUI.C create mode 100644 SpiralSound/Plugins/SplitSwitchPlugin/SplitSwitchPluginGUI.h diff --git a/SpiralSound/Plugins/SplitSwitchPlugin/Makefile.in b/SpiralSound/Plugins/SplitSwitchPlugin/Makefile.in new file mode 100644 index 0000000..ff14431 --- /dev/null +++ b/SpiralSound/Plugins/SplitSwitchPlugin/Makefile.in @@ -0,0 +1,170 @@ +############################################################################# +# Makefile for building SplitSwitchPlugin.so +############################################################################# + +####### Compiler, tools and options + +CC = gcc +CXX = g++ +CFLAGS = @CFLAGS@ +CXXFLAGS= @CXXFLAGS@ +INCPATH = -I/usr/X11R6/include +LINK = g++ -shared +LFLAGS = +LIBS = -L/usr/X11R6/lib @FLTK_LIBS@ -lGL -lXext -lX11 -ldl +MOC = moc +UIC = + +TAR = tar -cf +GZIP = gzip -9f + +INSTALL = @INSTALL@ + +###### Autoconf variables + +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ + +####### Files + +HEADERS = ../SpiralPlugin.h \ + ../SpiralPluginGUI.h \ + ../../ChannelHandler.h \ + ../Widgets/Fl_Knob.H \ + ../Widgets/Fl_DragBar.H \ + ../../Sample.h \ + SplitSwitchPlugin.h \ + SplitSwitchPluginGUI.h +SOURCES = ../SpiralPlugin.C \ + ../SpiralPluginGUI.C \ + ../../ChannelHandler.C \ + ../Widgets/Fl_Knob.cxx \ + ../Widgets/Fl_DragBar.cxx \ + ../../Sample.C \ + SplitSwitchPlugin.C \ + SplitSwitchPluginGUI.C +OBJECTS = ../SpiralPlugin.o \ + ../SpiralPluginGUI.o \ + ../../ChannelHandler.o \ + ../Widgets/Fl_Knob.o \ + ../Widgets/Fl_DragBar.o \ + ../../Sample.o \ + SplitSwitchPlugin.o \ + SplitSwitchPluginGUI.o +INTERFACES = +UICDECLS = +UICIMPLS = +SRCMOC = +OBJMOC = +DIST = +TARGET = SplitSwitchPlugin.so + +####### Implicit rules + +.SUFFIXES: .cpp .cxx .cc .C .c + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< + +####### Build rules + + +all: $(TARGET) + +$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) + $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) + +moc: $(SRCMOC) + +tmake: + tmake SplitSwitchPlugin.pro + +dist: + $(TAR) SplitSwitchPlugin.tar SplitSwitchPlugin.pro $(SOURCES) $(HEADERS) $(INTERFACES) $(DIST) + $(GZIP) SplitSwitchPlugin.tar + +clean: + -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) $(TARGET) + -rm -f *~ core + +install: + $(INSTALL) $(TARGET) $(libdir)/SpiralPlugins + +####### Sub-libraries + + +###### Combined headers + + +####### Compile + +../SpiralPlugin.o: ../SpiralPlugin.C \ + ../SpiralPlugin.h \ + ../../Sample.h + +../SpiralPluginGUI.o: ../SpiralPluginGUI.C \ + ../SpiralPluginGUI.h \ + ../Widgets/Fl_DragBar.H \ + ../SpiralPlugin.h \ + ../../Sample.h + +../Widgets/Fl_Knob.o: ../Widgets/Fl_Knob.cxx \ + ../Widgets/Fl_Knob.H + +../Widgets/Fl_DragBar.o: ../Widgets/Fl_DragBar.cxx \ + ../Widgets/Fl_DragBar.H + +../../Sample.o: ../../Sample.C \ + ../../Sample.h \ + ../../SpiralInfo.h + +SplitSwitchPlugin.o: SplitSwitchPlugin.C \ + SplitSwitchPlugin.h \ + ../SpiralPlugin.h \ + ../../Sample.h \ + ../../SpiralInfo.h \ + ../../Sample.h \ + SplitSwitchPluginGUI.h \ + ../Widgets/Fl_Knob.H \ + ../Widgets/Fl_DragBar.H \ + ../SpiralPluginGUI.h \ + ../Widgets/Fl_DragBar.H \ + SpiralIcon.xpm + +SplitSwitchPluginGUI.o: SplitSwitchPluginGUI.C \ + SplitSwitchPluginGUI.h \ + ../Widgets/Fl_Knob.H \ + ../Widgets/Fl_DragBar.H \ + SplitSwitchPlugin.h \ + ../SpiralPlugin.h \ + ../../Sample.h \ + ../../SpiralInfo.h \ + ../../Sample.h \ + ../SpiralPluginGUI.h \ + ../Widgets/Fl_DragBar.H + +../../ChannelHandler.o: ../../ChannelHandler.C \ + ../../ChannelHandler.h diff --git a/SpiralSound/Plugins/SplitSwitchPlugin/SpiralIcon.xpm b/SpiralSound/Plugins/SplitSwitchPlugin/SpiralIcon.xpm new file mode 100644 index 0000000..15d9933 --- /dev/null +++ b/SpiralSound/Plugins/SplitSwitchPlugin/SpiralIcon.xpm @@ -0,0 +1,325 @@ +/* XPM */ +static char * SpiralIcon_xpm[] = { +"36 36 286 2", +" c None", +". c #8B889B", +"+ c #9C99AA", +"@ c #ADAAB9", +"# c #837F94", +"$ c #7D7990", +"% c #9995A7", +"& c #67627C", +"* c #CDCBD4", +"= c #FCFCFC", +"- c #D1D0D8", +"; c #FFFFFF", +"> c #F1F1F3", +", c #848095", +"' c #2A2248", +") c #CFCED6", +"! c #68637D", +"~ c #ABA8B6", +"{ c #D5D3DB", +"] c #9490A2", +"^ c #C4C4C4", +"/ c #1D1C1D", +"( c #313134", +"_ c #EEEFEE", +": c #FBFBFB", +"< c #EFEFEF", +"[ c #7B768D", +"} c #464060", +"| c #DEDEE1", +"1 c #CBCACC", +"2 c #EEEEF1", +"3 c #79758C", +"4 c #FBFBFC", +"5 c #A2A2A2", +"6 c #000000", +"7 c #F5F6F5", +"8 c #747474", +"9 c #2A2A2B", +"0 c #403958", +"a c #7D788F", +"b c #C0BEC8", +"c c #BCBAC6", +"d c #BCBAC5", +"e c #625C79", +"f c #2B2932", +"g c #191919", +"h c #CCCCCC", +"i c #807B91", +"j c #3B3556", +"k c #F2F2F4", +"l c #929292", +"m c #0E0E0E", +"n c #BFBFBF", +"o c #111111", +"p c #100E15", +"q c #868689", +"r c #FEFDFE", +"s c #D9D7DE", +"t c #9C98AA", +"u c #FDFCFD", +"v c #DDDDDD", +"w c #575755", +"x c #5E5E5E", +"y c #C4C2CD", +"z c #423C5C", +"A c #F0F0F2", +"B c #939393", +"C c #555555", +"D c #4A4A4A", +"E c #010101", +"F c #282828", +"G c #C2C2C2", +"H c #DBDAE0", +"I c #615C78", +"J c #F6F6F7", +"K c #DADADA", +"L c #545454", +"M c #0F0F0F", +"N c #B8B8B8", +"O c #48445C", +"P c #2B2B2C", +"Q c #181900", +"R c #D3D3D3", +"S c #C1BEC9", +"T c #474060", +"U c #31294D", +"V c #716C85", +"W c #65607A", +"X c #625D78", +"Y c #D5D4DB", +"Z c #F7F7F7", +"` c #8B8B8B", +" . c #161616", +".. c #0C0C0C", +"+. c #161800", +"@. c #1A1B00", +"#. c #060600", +"$. c #191A00", +"%. c #393643", +"&. c #47415F", +"*. c #9692A4", +"=. c #D9D8DE", +"-. c #F7F7F8", +";. c #918DA0", +">. c #B8B5C1", +",. c #D1D1D1", +"'. c #252525", +"). c #040400", +"!. c #141500", +"~. c #FFFF00", +"{. c #727175", +"]. c #FEFEFF", +"^. c #9D99AA", +"/. c #DBD9E0", +"(. c #E9E9E9", +"_. c #CBCBCB", +":. c #E0E0E0", +"<. c #6C6C6C", +"[. c #010200", +"}. c #515151", +"|. c #A6A6A7", +"1. c #827E93", +"2. c #615C77", +"3. c #EAEAED", +"4. c #DFDFE1", +"5. c #1E1D24", +"6. c #9894A7", +"7. c #B1AEBB", +"8. c #69686F", +"9. c #000001", +"0. c #0A0A00", +"a. c #171800", +"b. c #615C76", +"c. c #5F5A75", +"d. c #413E4D", +"e. c #020203", +"f. c #040500", +"g. c #050500", +"h. c #1A1A1C", +"i. c #C3C1CB", +"j. c #9D9D9D", +"k. c #202020", +"l. c #383838", +"m. c #4C4C4C", +"n. c #111112", +"o. c #C9C7D0", +"p. c #F1F1F1", +"q. c #F8F8F8", +"r. c #232323", +"s. c #010100", +"t. c #121300", +"u. c #050408", +"v. c #AEACB9", +"w. c #FEFEFE", +"x. c #1D1D1D", +"y. c #020200", +"z. c #101100", +"A. c #B7B5C1", +"B. c #9390A2", +"C. c #BBBBBB", +"D. c #414141", +"E. c #030303", +"F. c #28272A", +"G. c #F4F4F6", +"H. c #605B76", +"I. c #736E86", +"J. c #D8D8D8", +"K. c #727272", +"L. c #101010", +"M. c #848486", +"N. c #CCCBD3", +"O. c #747087", +"P. c #6D6881", +"Q. c #1C1C1C", +"R. c #242424", +"S. c #656566", +"T. c #F6F6F6", +"U. c #E8E6EA", +"V. c #706B84", +"W. c #E3E1E6", +"X. c #474746", +"Y. c #151515", +"Z. c #C8C8C8", +"`. c #AEAEAE", +" + c #080808", +".+ c #373639", +"++ c #FDFCFE", +"@+ c #ABA8B7", +"#+ c #F1F0F3", +"$+ c #6D6980", +"%+ c #0A090E", +"&+ c #95929E", +"*+ c #0A0810", +"=+ c #0D0D0D", +"-+ c #050505", +";+ c #5B5A5C", +">+ c #F7F6F7", +",+ c #F4F3F5", +"'+ c #908C9F", +")+ c #C8C6D0", +"!+ c #837E96", +"~+ c #86868A", +"{+ c #070608", +"]+ c #ECEBEE", +"^+ c #5B5571", +"/+ c #646078", +"(+ c #AFAFB0", +"_+ c #454545", +":+ c #363636", +"<+ c #7A7A7A", +"[+ c #C8C8C9", +"}+ c #212025", +"|+ c #060607", +"1+ c #969699", +"2+ c #FAFAFA", +"3+ c #F8F8F9", +"4+ c #A29EAF", +"5+ c #F7F6F8", +"6+ c #F0F0F1", +"7+ c #B8B7B9", +"8+ c #E4E4E4", +"9+ c #FDFDFD", +"0+ c #A5A2B2", +"a+ c #3B3456", +"b+ c #A8A5B4", +"c+ c #525252", +"d+ c #848387", +"e+ c #CDCDCD", +"f+ c #8D899C", +"g+ c #494262", +"h+ c #68627C", +"i+ c #40395A", +"j+ c #ECECEC", +"k+ c #020202", +"l+ c #B4B5B5", +"m+ c #0B0B0B", +"n+ c #313232", +"o+ c #E3E3E3", +"p+ c #B1AEBC", +"q+ c #BDBBC6", +"r+ c #3C3556", +"s+ c #898599", +"t+ c #EDEDED", +"u+ c #39393A", +"v+ c #040404", +"w+ c #333333", +"x+ c #F5F5F5", +"y+ c #2B2B2B", +"z+ c #2D2A3D", +"A+ c #B6B4C1", +"B+ c #F5F5F6", +"C+ c #605A76", +"D+ c #DAD8DF", +"E+ c #F5F4F6", +"F+ c #615B76", +"G+ c #524D6A", +"H+ c #E4E3E8", +"I+ c #D5D5D5", +"J+ c #1B1B1B", +"K+ c #303030", +"L+ c #AAABAB", +"M+ c #585464", +"N+ c #B0AEBB", +"O+ c #A29FAF", +"P+ c #E9E8E9", +"Q+ c #787779", +"R+ c #0F0E15", +"S+ c #2D2D2E", +"T+ c #595959", +"U+ c #FAFAFB", +"V+ c #807B92", +"W+ c #B0ADBB", +"X+ c #E8E7EB", +"Y+ c #3A3258", +"Z+ c #E6E5EA", +"`+ c #DFDEE3", +" @ c #443E5E", +".@ c #BAB8C4", +"+@ c #C1BFCA", +"@@ c #E0E0E5", +"#@ c #D0CED6", +"$@ c #362F52", +"%@ c #CECCD5", +"&@ c #413A5B", +"*@ c #6A657F", +"=@ c #9793A6", +" ", +" ", +" ", +" . + @ # $ % ", +" & * = * - ; > , ' ; ; ; ) ! ", +" ~ ; ; { ] ; ^ / ( _ ; : < [ ", +" } | 1 2 3 4 5 6 6 7 : 8 9 0 a b ", +" c : d e f g h i j k l 6 m ; n o 6 p q r s ", +" t u ; v w 6 6 x y z A B 6 C ; D E 6 F G ; H ", +" I J ; ; K L 6 6 M N O P E 6 6 6 Q Q M R S T U V W ", +" X Y ; ; ; ; Z ` .6 ..6 6 6 6 6 +.@.#.$.%.&.*.=.-.;. ", +" >.; ; ; ; ; ; = ,.'.6 6 ).6 6 !.~.6 6 6 E {.].; ; ^. ", +" /.; ; (.R h _.:.<.6 6 6 [.6 6 ~.~.~.~.~.~.E }.|.4 1. ", +" 2.3.; 4...6 6 6 6 6 6 6 6 6 6 ~.~.~.6 6 6 6 6 6 5.6. ", +" V @ 7.8.9.6 6 6 6 6 0.a.6 6 ~.~.6 6 6 6 6 6 6 6 ", +" b.c.d.6 e.6 6 6 6 6 f.6 ~.~.6 6 ~.6 6 g.6 6 6 h. ", +" i.; ; j.k.k.l.m.k.~.~.~.~.~.6 6 ~.~.~.~.~.~.6 6 n. ", +" o.; ; p.q.; ; ; r.6 s.!.6 6 6 6 6 ~.6 6 t.6 6 6 u. ", +" v.; ; ; ; w.; ; x.6 y.z.6 6 6 6 6 6 6 6 t.6 6 6 6 A., ", +" B.; ; w.; : C.D.E.6 6 6 6 6 6 6 6 ~.6 6 y.6 6 6 F.w.G.H. ", +" I.; ; ; J.K.L.6 6 6 6 6 6 6 6 6 ~.~.~.~.~.~.6 6 M.; ; N.O. ", +" P.J ; : Q.6 6 6 6 R...6 6 6 6 6 6 ~.6 6 s.6 6 6 S.T.; ; U.V. ", +" W.; ; X.6 E 6 Y.Z.`. +6 6 6 6 6 6 6 6 s.6 6 6 6 .+++; ; > V. ", +" @+; #+$+%+6 6 `.w.; &+*+6 6 6 6 6 6 6 6 =+-+6 6 6 ;+>+; ; ,+'+ ", +" V.)+! !+~+{+x ; ; ]+^+/+(+l _+6 6 6 :+<+[+}+6 6 6 |+1+2+; ; 3+@ ", +" 4+5+6+7+8+9+; 0+a+b+; T._+6 6 E c+; ; d+6 6 E 6 o e+; ; = f+ ", +" g+> ; ; ; ; ; ; h+i+; ; j+l.6 6 k+D ; ; l+m+6 6 6 n+o+; ; p+ ", +" > ; ; ; ; q+r+s+; ; t+u+6 6 v+w+; ; x+y+6 6 z+A+; B+3 ", +" C+D+= ; E+F+G+H+; ; I+J+6 6 k+K+; ; ; L+c+M+ ", +" N+4 O+ X ; ; ; P+Q+K+R+S+T+; ; ; w.U+V+ ", +" W+; ; ; ; ; X+Y+Z+; ; ; ; = `+ @ ", +" .@+@@@4 ; ; #@$@%@; ; ; s s+T ", +" &@ *@=@s+ ", +" ", +" ", +" "}; diff --git a/SpiralSound/Plugins/SplitSwitchPlugin/SplitSwitchPlugin.C b/SpiralSound/Plugins/SplitSwitchPlugin/SplitSwitchPlugin.C new file mode 100644 index 0000000..ddff326 --- /dev/null +++ b/SpiralSound/Plugins/SplitSwitchPlugin/SplitSwitchPlugin.C @@ -0,0 +1,146 @@ +/* SpiralSound + * Copyleft (C) 2001 David Griffiths + * + * 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 "SplitSwitchPlugin.h" +#include "SplitSwitchPluginGUI.h" +#include +#include +#include "SpiralIcon.xpm" + +extern "C" { + + SpiralPlugin* CreateInstance () { return new SplitSwitchPlugin; } + + char** GetIcon () { return SpiralIcon_xpm; } + + int GetID () { return 125; } + +} + +/////////////////////////////////////////////////////// + +SplitSwitchPlugin::SplitSwitchPlugin () : +m_SwitchPos (0), +m_Triggered (false) +{ + m_GUIArgs.Chans = 2; + m_GUIArgs.Switch = 1; + m_GUIArgs.Echo = 1; + m_PluginInfo.Name = "SplitSwitch"; + m_PluginInfo.Width = 93; + m_PluginInfo.Height = 55; + m_PluginInfo.NumInputs = 3; + m_PluginInfo.NumOutputs = 3; + // Inputs + m_PluginInfo.PortTips.push_back ("CV"); + m_PluginInfo.PortTips.push_back ("Clock"); + m_PluginInfo.PortTips.push_back ("In"); + // Outputs + m_PluginInfo.PortTips.push_back ("CV"); + m_PluginInfo.PortTips.push_back ("Out 1"); + m_PluginInfo.PortTips.push_back ("Out 2"); + m_AudioCH->Register ("Chans", &m_GUIArgs.Chans); + m_AudioCH->Register ("Switch", &m_GUIArgs.Switch); + m_AudioCH->Register ("Echo", &m_GUIArgs.Echo, ChannelHandler::OUTPUT); +} + +SplitSwitchPlugin::~SplitSwitchPlugin () { +} + +PluginInfo &SplitSwitchPlugin::Initialise (const HostInfo *Host) { + return SpiralPlugin::Initialise (Host); +} + +SpiralGUIType *SplitSwitchPlugin::CreateGUI () { + return new SplitSwitchPluginGUI (m_PluginInfo.Width, m_PluginInfo.Height, this, m_AudioCH, m_HostInfo); +} + +void SplitSwitchPlugin::ExecuteCommands () { + if (m_AudioCH->IsCommandWaiting ()) { + switch (m_AudioCH->GetCommand()) { + case (SETCHANS) : SetChans (m_GUIArgs.Chans); + break; + case (SETSWITCH) : SetSwitch (m_GUIArgs.Switch); + break; + } + } +} + +void SplitSwitchPlugin::SetChans (int n) { + // once to clear the connections with the current info + UpdatePluginInfoWithHost(); + while (n > m_PluginInfo.NumOutputs - 1) { + m_PluginInfo.NumOutputs++; + char t[256]; + sprintf (t, "Out %d", n); + m_PluginInfo.PortTips.push_back (t); + AddOutput (); + } + while (n < m_PluginInfo.NumOutputs - 1) { + vector::iterator i = m_PluginInfo.PortTips.end (); + m_PluginInfo.PortTips.erase (i--); + RemoveOutput(); + m_PluginInfo.NumOutputs--; + } + // do the actual update + UpdatePluginInfoWithHost (); +} + +void SplitSwitchPlugin::SetSwitch (int n) { + m_SwitchPos=(m_GUIArgs.Switch - 1) % (m_PluginInfo.NumOutputs - 1); +} + +void SplitSwitchPlugin::Execute() { + int n; + int NumChans = m_PluginInfo.NumOutputs - 1; + for (n=1; nZero(); + if (InputExists (2)) { + for (n=0; nBUFSIZE; n++) { + if (InputExists (0)) { + // Check the Switch Pos CV Value + m_SwitchPos = int (GetInput (0, n)-1) % NumChans; + } + else if (InputExists (1)) { + // Check the trigger CV value + if (GetInput (1, n) < 0.01) { + m_Triggered = false; + } + else { + if (!m_Triggered) { + m_Triggered = true; + m_SwitchPos = (m_SwitchPos+1) % NumChans; + } + } + } + int o = m_SwitchPos+1; + m_GUIArgs.Echo = o; + SetOutput (0, n, o); + SetOutput (o, n, GetInput (2, n)); + } + } +} + +void SplitSwitchPlugin::StreamOut (ostream &s) { + s << m_Version << " " << m_PluginInfo.NumOutputs - 1 << " " << m_SwitchPos << " "; +} + +void SplitSwitchPlugin::StreamIn (istream &s) { + int Version, Chans, SwitchPos; + s >> Version >> Chans >> SwitchPos; + SetChans (Chans); + m_SwitchPos = SwitchPos; +} diff --git a/SpiralSound/Plugins/SplitSwitchPlugin/SplitSwitchPlugin.h b/SpiralSound/Plugins/SplitSwitchPlugin/SplitSwitchPlugin.h new file mode 100644 index 0000000..1fb286f --- /dev/null +++ b/SpiralSound/Plugins/SplitSwitchPlugin/SplitSwitchPlugin.h @@ -0,0 +1,56 @@ +/* SpiralSound + * Copyleft (C) 2001 David Griffiths + * + * 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 "../SpiralPlugin.h" +#include + +#ifndef SplitSwitchPLUGIN +#define SplitSwitchPLUGIN + +class SplitSwitchPlugin : public SpiralPlugin { + public: + SplitSwitchPlugin (); + virtual ~SplitSwitchPlugin (); + virtual PluginInfo& Initialise (const HostInfo *Host); + virtual SpiralGUIType* CreateGUI (); + virtual void Execute (); + virtual void ExecuteCommands (); + virtual void StreamOut (ostream &s); + virtual void StreamIn (istream &s); + int GetSwitch (void) { return m_SwitchPos + 1; } + int GetChans (void) { return m_PluginInfo.NumOutputs - 1; } + enum GUICommands {NONE, SETCHANS, SETSWITCH}; + struct GUIArgs { + int Chans; + int Switch; + int Echo; + }; + private: + GUIArgs m_GUIArgs; + void SetChans (int n); + void SetSwitch (int n); + int m_SwitchPos; + bool m_Triggered; + friend istream &operator>> (istream &s, SplitSwitchPlugin &o); + friend ostream &operator<< (ostream &s, SplitSwitchPlugin &o); +}; + +istream &operator>> (istream &s, SplitSwitchPlugin &o); +ostream &operator<< (ostream &s, SplitSwitchPlugin &o); + +#endif diff --git a/SpiralSound/Plugins/SplitSwitchPlugin/SplitSwitchPluginGUI.C b/SpiralSound/Plugins/SplitSwitchPlugin/SplitSwitchPluginGUI.C new file mode 100644 index 0000000..40d32bc --- /dev/null +++ b/SpiralSound/Plugins/SplitSwitchPlugin/SplitSwitchPluginGUI.C @@ -0,0 +1,95 @@ +/* SpiralPlugin + * Copyleft (C) 2000 David Griffiths + * + * 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 "SplitSwitchPluginGUI.h" +#include +#include +#include + +static const int GUI_COLOUR = 179; +static const int GUIBG_COLOUR = 144; +static const int GUIBG2_COLOUR = 145; + +//////////////////////////////////////////// + +SplitSwitchPluginGUI::SplitSwitchPluginGUI (int w, int h, SplitSwitchPlugin *o, ChannelHandler *ch, const HostInfo *Info) : +SpiralPluginGUI (w, h, o, ch) +{ + m_Chans = new Fl_Counter (5, 20, 40, 20, "Channels"); + m_Chans->labelsize (10); + m_Chans->type (FL_SIMPLE_COUNTER); + m_Chans->step (1); + m_Chans->value (2); + m_Chans->callback ((Fl_Callback*) cb_Chans); + add (m_Chans); + + m_Switch = new Fl_Counter (49, 20, 40, 20, "Select"); + m_Switch->labelsize (10); + m_Switch->type (FL_SIMPLE_COUNTER); + m_Switch->step (1); + m_Switch->value (1); + m_Switch->callback ((Fl_Callback*) cb_Switch); + add (m_Switch); +} + +inline void SplitSwitchPluginGUI::cb_Chans_i (Fl_Counter* o, void* v) { + if (o->value() < 2) o->value(2); + else { + m_GUICH->Set ("Chans", int (o->value ())); + m_GUICH->SetCommand (SplitSwitchPlugin::SETCHANS); + } +} + +void SplitSwitchPluginGUI::cb_Chans (Fl_Counter* o, void* v) { + ((SplitSwitchPluginGUI*) (o->parent ())) -> cb_Chans_i (o, v); +} + + +inline void SplitSwitchPluginGUI::cb_Switch_i (Fl_Counter* o, void* v) { + if (o->value()<1 || o->value() > m_Chans->value ()) + o->value (1); + m_GUICH->Set ("Switch", int (o->value ())); + m_GUICH->SetCommand (SplitSwitchPlugin::SETSWITCH); +} + +void SplitSwitchPluginGUI::cb_Switch (Fl_Counter* o, void* v) { + ((SplitSwitchPluginGUI*) (o->parent ())) -> cb_Switch_i (o, v); +} + +void SplitSwitchPluginGUI::Update () { + m_Switch->value (m_GUICH->GetInt ("Echo")); +} + +void SplitSwitchPluginGUI::UpdateValues (SpiralPlugin *o) { + SplitSwitchPlugin* Plugin = (SplitSwitchPlugin*)o; + m_Chans->value (Plugin->GetChans ()); + m_Switch->value (Plugin->GetSwitch ()); +} + +const string SplitSwitchPluginGUI::GetHelpText(const string &loc){ + return string("") + + "It's a simple 1-input n-output rotary switch.\n\n" + + "The 'Channels' parameter controls the number of outputs.\n\n" + + "The 'Select' parameter selects which output echos the input.\n\n" + + "The 'CV' input also selects which output echos the input.\n\n" + + "The 'Clock' input is a trigger to select the next output chanel.\n\n" + + "The 'CV' output enables you to gang several switches together, by\n" + + "connecting it to the other switches' 'CV' input.\n"; +} diff --git a/SpiralSound/Plugins/SplitSwitchPlugin/SplitSwitchPluginGUI.h b/SpiralSound/Plugins/SplitSwitchPlugin/SplitSwitchPluginGUI.h new file mode 100644 index 0000000..6999fd4 --- /dev/null +++ b/SpiralSound/Plugins/SplitSwitchPlugin/SplitSwitchPluginGUI.h @@ -0,0 +1,45 @@ +/* SpiralPlugin + * Copyleft (C) 2000 David Griffiths + * + * 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 +#include +#include +#include + +#include "SplitSwitchPlugin.h" +#include "../SpiralPluginGUI.h" + +#ifndef SplitSwitchGUI +#define SplitSwitchGUI + +class SplitSwitchPluginGUI : public SpiralPluginGUI { + public: + SplitSwitchPluginGUI(int w, int h, SplitSwitchPlugin *o, ChannelHandler *ch, const HostInfo *Info); + virtual void UpdateValues(SpiralPlugin *o); + virtual void Update(); + protected: + const string GetHelpText(const string &loc); + private: + Fl_Counter *m_Switch, *m_Chans; + inline void cb_Switch_i (Fl_Counter* o, void* v); + static void cb_Switch (Fl_Counter* o, void* v); + inline void cb_Chans_i (Fl_Counter* o, void* v); + static void cb_Chans (Fl_Counter* o, void* v); +}; + +#endif