/* 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 "MatrixPlugin.h" #include "MatrixPluginGUI.h" #include #include "SpiralIcon.xpm" #include "../../RiffWav.h" #include "../../NoteTable.h" extern "C" { SpiralPlugin* CreateInstance() { return new MatrixPlugin; } char** GetIcon() { return SpiralIcon_xpm; } int GetID() { return 0x0012; } } /////////////////////////////////////////////////////// MatrixPlugin::MatrixPlugin() : m_TickTime(1.0f), m_StepTime(1.0f), m_Time(0.0f), m_Step(0), m_Loop(true), m_NoteCut(false), m_Current(0), m_CurrentNoteCV(0), m_CurrentTriggerCV(0), m_Triggered(false), m_ClockHigh(false), m_CopyPattern(0) { m_Version=2; m_PluginInfo.Name="Matrix"; m_PluginInfo.Width=555; m_PluginInfo.Height=270; m_PluginInfo.NumInputs=5; m_PluginInfo.NumOutputs=19; m_PluginInfo.PortTips.push_back("Play Trigger"); m_PluginInfo.PortTips.push_back("StepTime CV"); m_PluginInfo.PortTips.push_back("Input Pitch CV"); m_PluginInfo.PortTips.push_back("Input Trigger CV"); m_PluginInfo.PortTips.push_back("External Clock"); m_PluginInfo.PortTips.push_back("Output Pitch"); m_PluginInfo.PortTips.push_back("Output Trigger"); m_PluginInfo.PortTips.push_back("Trigger 1"); m_PluginInfo.PortTips.push_back("Trigger 2"); m_PluginInfo.PortTips.push_back("Trigger 3"); m_PluginInfo.PortTips.push_back("Trigger 4"); m_PluginInfo.PortTips.push_back("Trigger 5"); m_PluginInfo.PortTips.push_back("Trigger 6"); m_PluginInfo.PortTips.push_back("Trigger 7"); m_PluginInfo.PortTips.push_back("Trigger 8"); m_PluginInfo.PortTips.push_back("Trigger 9"); m_PluginInfo.PortTips.push_back("Trigger 10"); m_PluginInfo.PortTips.push_back("Trigger 11"); m_PluginInfo.PortTips.push_back("Trigger 12"); m_PluginInfo.PortTips.push_back("Trigger 13"); m_PluginInfo.PortTips.push_back("Trigger 14"); m_PluginInfo.PortTips.push_back("Trigger 15"); m_PluginInfo.PortTips.push_back("Trigger 16"); m_PluginInfo.PortTips.push_back("Reset Trigger"); for (int n=0; nSAMPLERATE; return Info; } SpiralGUIType *MatrixPlugin::CreateGUI() { m_GUI = new MatrixPluginGUI(m_PluginInfo.Width, m_PluginInfo.Height, this,m_HostInfo); m_GUI->hide(); return m_GUI; } void MatrixPlugin::Execute() { for (int n=0; nBUFSIZE; n++) { if (InputExists(1)) m_StepTime = GetInput(1,n); // inc time m_Time+=m_TickTime; SetOutputPitch(0,n,m_CurrentNoteCV); SetOutput(1,n,m_CurrentTriggerCV); if (m_Step+1 >= m_Matrix[m_Current].Length) SetOutput(18, n, 1); else SetOutput(18, n, 0); if (GetInputPitch(0,n)>0) { if (!m_Triggered) { float Freq=GetInputPitch(0,n); // Notes 0 to 16 trigger patterns 0 to 16 // No other notes catered for for (int i=0; iUpdateValues(); m_Time=m_StepTime*(1/m_Matrix[m_Current].Speed); m_Step=-1; m_Triggered=true; } } else { m_Triggered=false; } // set the individual triggers for (int t=0; t0) { if(!m_ClockHigh) { m_ClockHigh=true; ExternalClockTriggered=true; } } else { if (m_ClockHigh) { m_ClockHigh=false; ExternalClockTriggered=true; } } } // An external clock pulse overrides the internal timing if ((!ExternalClock && m_Time>=m_StepTime*(1/m_Matrix[m_Current].Speed)) || (ExternalClock && ExternalClockTriggered)) { m_Time=0; m_Step++; if (m_Step >= m_Matrix[m_Current].Length) m_Step=0; if (m_GUI) ((MatrixPluginGUI*)m_GUI)->SetLED(m_Step); // Reset the values m_CurrentTriggerCV=0; if (m_NoteCut) m_CurrentNoteCV=0; for (int t=0; t=0; y--) { for (x=0; x>version; switch (version) { case 1: { s>>m_Current>>m_Time>>m_Step>>m_Loop>>m_NoteCut; for (int n=0; n>m_Matrix[n].Length>>m_Matrix[n].Speed>>m_Matrix[n].Octave; for (int y=0; y>m_Matrix[n].Matrix[x][y]; } } } break; case 2: { s>>m_Current>>m_Time>>m_Step>>m_Loop>>m_NoteCut; for (int n=0; n>m_Matrix[n].Length>>m_Matrix[n].Speed>>m_Matrix[n].Octave; int x=0,y=0; while(x!=-1) { s>>x; if (x!=-1) { s>>y; if (y!=-1) m_Matrix[n].Matrix[x][y]=true; } } } } break; } }