| @@ -64,9 +64,9 @@ m_IsTerminal(Terminal), | |||||
| m_Minimised(true) | m_Minimised(true) | ||||
| { | { | ||||
| for (int n=0; n<512; n++) Numbers[n]=n; | for (int n=0; n<512; n++) Numbers[n]=n; | ||||
| type(1); | type(1); | ||||
| box(FL_PLASTIC_UP_BOX); | |||||
| box((Fl_Boxtype)SpiralSynthModularInfo::GUIDEVICE_Box); | |||||
| labeltype(FL_ENGRAVED_LABEL); | labeltype(FL_ENGRAVED_LABEL); | ||||
| align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE); | align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE); | ||||
| color(SpiralSynthModularInfo::GUICOL_Device); | color(SpiralSynthModularInfo::GUICOL_Device); | ||||
| @@ -87,6 +87,12 @@ m_Minimised(true) | |||||
| m_Menu->add("rename", 0, (Fl_Callback*)cb_Rename,this); | m_Menu->add("rename", 0, (Fl_Callback*)cb_Rename,this); | ||||
| m_Menu->add("delete", 0, (Fl_Callback*)cb_Delete,this); | m_Menu->add("delete", 0, (Fl_Callback*)cb_Delete,this); | ||||
| int Centx=x()+w()/2; | |||||
| int Centy=y()+h()/2; | |||||
| m_IconButton = new Fl_Button(Centx-m_Icon->w()/2,Centy-m_Icon->h()/2,m_Icon->w(),m_Icon->h()); | |||||
| m_IconButton->box(FL_NO_BOX); | |||||
| if (m_Icon) m_IconButton->image(m_Icon); | |||||
| m_PluginWindow = PW; | m_PluginWindow = PW; | ||||
| if (m_PluginWindow) | if (m_PluginWindow) | ||||
| { | { | ||||
| @@ -109,41 +115,25 @@ int Fl_DeviceGUI::handle(int event) | |||||
| { | { | ||||
| int t=Fl_Group::handle(event); | int t=Fl_Group::handle(event); | ||||
| /*if (m_PluginWindow) | |||||
| if (m_IconButton->value()) | |||||
| { | { | ||||
| if (Fl::event_x()>x() && Fl::event_x()<x()+w() && Fl::event_y()>y() && Fl::event_y()<y()+h()) | |||||
| { | |||||
| if (!m_PluginWindow->visible() && m_PluginWindow && !m_DelMe) | |||||
| m_IconButton->value(false); | |||||
| if (m_PluginWindow && !m_DelMe) | |||||
| { | { | ||||
| m_Minimised=false; | |||||
| Resize(m_PluginWindow->w()+(PortGroupWidth*2),m_PluginWindow->h()+TitleBarHeight); | |||||
| m_PluginWindow->show(); | |||||
| } | |||||
| } | |||||
| else | |||||
| { | |||||
| if (m_Minimised==false)// && !m_PluginWindow->visible()) | |||||
| { | |||||
| m_Minimised=true; | |||||
| Resize(m_MiniWidth,m_MiniHeight); | |||||
| m_PluginWindow->hide(); | |||||
| parent()->redraw(); | |||||
| } | |||||
| }*/ | |||||
| if (t==0 && Fl::belowmouse()==this) | |||||
| { | |||||
| if (event==FL_PUSH && Fl::event_button()==1) | |||||
| { | |||||
| if (m_PluginWindow && !m_DelMe) | |||||
| { | |||||
| if(!m_PluginWindow->visible()) Maximise(); | |||||
| if(!m_PluginWindow->visible()) | |||||
| { | |||||
| Maximise(); | |||||
| m_IconButton->hide(); | |||||
| } | } | ||||
| } | |||||
| } | |||||
| } | } | ||||
| if (m_Minimised==false && !m_PluginWindow->visible()) Minimise(); | |||||
| if (m_Minimised==false && !m_PluginWindow->visible()) | |||||
| { | |||||
| Minimise(); | |||||
| m_IconButton->show(); | |||||
| } | |||||
| return t; | return t; | ||||
| } | } | ||||
| @@ -168,6 +158,7 @@ void Fl_DeviceGUI::Maximise() | |||||
| } | } | ||||
| m_PluginWindow->show(); | m_PluginWindow->show(); | ||||
| m_IconButton->hide(); | |||||
| } | } | ||||
| void Fl_DeviceGUI::Resize(int width, int height) | void Fl_DeviceGUI::Resize(int width, int height) | ||||
| @@ -185,17 +176,6 @@ void Fl_DeviceGUI::Resize(int width, int height) | |||||
| position(x()+(oldw-w())/2,y()+(oldh-h())/2); | position(x()+(oldw-w())/2,y()+(oldh-h())/2); | ||||
| } | } | ||||
| void Fl_DeviceGUI::draw() | |||||
| { | |||||
| Fl_Group::draw(); | |||||
| if (m_Icon && m_Minimised) | |||||
| { | |||||
| int Centx=x()+w()/2; | |||||
| int Centy=y()+h()/2; | |||||
| m_Icon->draw(Centx-m_Icon->w()/2,Centy-m_Icon->h()/2); | |||||
| } | |||||
| } | |||||
| void Fl_DeviceGUI::Setup(const DeviceGUIInfo& Info, bool FirstTime) | void Fl_DeviceGUI::Setup(const DeviceGUIInfo& Info, bool FirstTime) | ||||
| { | { | ||||
| m_Info=Info; | m_Info=Info; | ||||
| @@ -217,14 +197,23 @@ void Fl_DeviceGUI::Setup(const DeviceGUIInfo& Info, bool FirstTime) | |||||
| m_PortVec.clear(); | m_PortVec.clear(); | ||||
| int InputX=x()+2; | int InputX=x()+2; | ||||
| int OutputX=x()+PortGroupWidth+Info.Width+4; | |||||
| int OutputX=0; | |||||
| int StartY=y()+TitleBarHeight; | int StartY=y()+TitleBarHeight; | ||||
| int PortDist=10; | int PortDist=10; | ||||
| int PortNum=0; | int PortNum=0; | ||||
| m_MiniHeight=Info.Height+TitleBarHeight; | m_MiniHeight=Info.Height+TitleBarHeight; | ||||
| h(m_MiniHeight); | |||||
| bool Maximised = (m_PluginWindow && m_PluginWindow->visible()); | |||||
| if (!Maximised) | |||||
| { | |||||
| h(m_MiniHeight); | |||||
| OutputX=x()+PortGroupWidth+Info.Width+4; | |||||
| } | |||||
| else | |||||
| { | |||||
| OutputX=x()+w()-8; | |||||
| } | |||||
| for (int n=0; n<Info.NumInputs; n++) | for (int n=0; n<Info.NumInputs; n++) | ||||
| { | { | ||||
| Fl_PortButton* NewInput = new Fl_PortButton(InputX,StartY+PortDist*n,PortSize,PortSize,""); | Fl_PortButton* NewInput = new Fl_PortButton(InputX,StartY+PortDist*n,PortSize,PortSize,""); | ||||
| @@ -259,7 +248,7 @@ void Fl_DeviceGUI::Setup(const DeviceGUIInfo& Info, bool FirstTime) | |||||
| for (int n=0; n<Info.NumOutputs; n++) | for (int n=0; n<Info.NumOutputs; n++) | ||||
| { | { | ||||
| Fl_PortButton* NewOutput = new Fl_PortButton(OutputX,StartY+PortDist*n,PortSize,PortSize,""); | |||||
| Fl_PortButton* NewOutput= NewOutput = new Fl_PortButton(OutputX,StartY+PortDist*n,PortSize,PortSize,""); | |||||
| NewOutput->type(1); | NewOutput->type(1); | ||||
| NewOutput->SetType(Fl_PortButton::OUTPUT); | NewOutput->SetType(Fl_PortButton::OUTPUT); | ||||
| NewOutput->value(false); | NewOutput->value(false); | ||||
| @@ -21,6 +21,7 @@ | |||||
| #include <FL/Fl_Button.H> | #include <FL/Fl_Button.H> | ||||
| #include <FL/Fl_Pixmap.h> | #include <FL/Fl_Pixmap.h> | ||||
| #include <FL/Fl_Menu_Button.h> | #include <FL/Fl_Menu_Button.h> | ||||
| #include <FL/Fl_Box.h> | |||||
| #include <iostream> | #include <iostream> | ||||
| #include <vector> | #include <vector> | ||||
| #include <string> | #include <string> | ||||
| @@ -83,7 +84,6 @@ public: | |||||
| Fl_DeviceGUI(const DeviceGUIInfo& Info, Fl_Group *PW, Fl_Pixmap *Icon, bool Terminal=false); | Fl_DeviceGUI(const DeviceGUIInfo& Info, Fl_Group *PW, Fl_Pixmap *Icon, bool Terminal=false); | ||||
| virtual int handle(int event); | virtual int handle(int event); | ||||
| virtual void draw(); | |||||
| enum PortType {INPUT,OUTPUT}; | enum PortType {INPUT,OUTPUT}; | ||||
| @@ -123,6 +123,7 @@ protected: | |||||
| Fl_DragBar* m_DragBar; | Fl_DragBar* m_DragBar; | ||||
| Fl_Group* m_PluginWindow; | Fl_Group* m_PluginWindow; | ||||
| Fl_Pixmap* m_Icon; | Fl_Pixmap* m_Icon; | ||||
| Fl_Button* m_IconButton; | |||||
| Fl_Menu_Button* m_Menu; | Fl_Menu_Button* m_Menu; | ||||
| private: | private: | ||||
| @@ -50,7 +50,9 @@ string MidiDevice::m_DeviceName; | |||||
| #endif | #endif | ||||
| MidiDevice::MidiDevice() : | MidiDevice::MidiDevice() : | ||||
| m_Poly(1) | |||||
| m_Poly(1), | |||||
| m_Clock(1.0f), | |||||
| m_ClockCount(0) | |||||
| { | { | ||||
| #ifdef ALSA_MIDI | #ifdef ALSA_MIDI | ||||
| seq_handle=AlsaOpen(); | seq_handle=AlsaOpen(); | ||||
| @@ -196,9 +198,9 @@ void MidiDevice::SendEvent(int Device,const MidiEvent &Event) | |||||
| // little helper to strip out the realtime and unused messages | // little helper to strip out the realtime and unused messages | ||||
| void MidiDevice::ReadByte(unsigned char *c) | void MidiDevice::ReadByte(unsigned char *c) | ||||
| { | { | ||||
| *c=MIDI_CLOCK; | |||||
| *c=ACTIVE_SENSE; | |||||
| do read(m_MidiFd,c,1); | do read(m_MidiFd,c,1); | ||||
| while (*c>=STATUS_END); | |||||
| while (*c>=STATUS_END && *c!=MIDI_CLOCK); | |||||
| } | } | ||||
| // collect events deals with the byte level messages, and sorts | // collect events deals with the byte level messages, and sorts | ||||
| @@ -221,6 +223,16 @@ void MidiDevice::CollectEvents() | |||||
| { | { | ||||
| ReadByte(buf); | ReadByte(buf); | ||||
| if (*buf==MIDI_CLOCK) | |||||
| { | |||||
| m_ClockCount++; | |||||
| if (m_ClockCount==6) | |||||
| { | |||||
| m_Clock=-m_Clock; | |||||
| m_ClockCount=0; | |||||
| } | |||||
| } | |||||
| else | |||||
| if (*buf>=STATUS_START) // we've got a status byte | if (*buf>=STATUS_START) // we've got a status byte | ||||
| { | { | ||||
| if (*buf==SYSEX_TERMINATOR) InSysex=false; | if (*buf==SYSEX_TERMINATOR) InSysex=false; | ||||
| @@ -329,7 +341,7 @@ void MidiDevice::AddEvent(unsigned char* midi) | |||||
| Volume=midi[2]; | Volume=midi[2]; | ||||
| EventDevice=midi[0]-STATUS_PITCH_WHEEL; | EventDevice=midi[0]-STATUS_PITCH_WHEEL; | ||||
| } | } | ||||
| if (EventDevice<0 || EventDevice>15) | if (EventDevice<0 || EventDevice>15) | ||||
| { | { | ||||
| cerr<<"Error - Midi device "<<EventDevice<<" ??"<<endl; | cerr<<"Error - Midi device "<<EventDevice<<" ??"<<endl; | ||||
| @@ -74,6 +74,8 @@ public: | |||||
| void SetPoly(int s) { m_Poly=s; } | void SetPoly(int s) { m_Poly=s; } | ||||
| float GetClock() { return m_Clock; } | |||||
| private: | private: | ||||
| MidiDevice(); | MidiDevice(); | ||||
| @@ -88,6 +90,8 @@ private: | |||||
| int m_MidiWrFd; | int m_MidiWrFd; | ||||
| static string m_DeviceName; | static string m_DeviceName; | ||||
| int m_Poly; | int m_Poly; | ||||
| float m_Clock; | |||||
| int m_ClockCount; | |||||
| queue<MidiEvent> m_EventVec[16]; | queue<MidiEvent> m_EventVec[16]; | ||||
| @@ -68,7 +68,7 @@ m_CurrentNote(0) | |||||
| m_PluginInfo.Width=85; | m_PluginInfo.Width=85; | ||||
| m_PluginInfo.Height=155; | m_PluginInfo.Height=155; | ||||
| m_PluginInfo.NumInputs=2; | m_PluginInfo.NumInputs=2; | ||||
| m_PluginInfo.NumOutputs=5; | |||||
| m_PluginInfo.NumOutputs=6; | |||||
| m_PluginInfo.PortTips.push_back("Note CV"); | m_PluginInfo.PortTips.push_back("Note CV"); | ||||
| m_PluginInfo.PortTips.push_back("Trigger CV"); | m_PluginInfo.PortTips.push_back("Trigger CV"); | ||||
| m_PluginInfo.PortTips.push_back("Note CV"); | m_PluginInfo.PortTips.push_back("Note CV"); | ||||
| @@ -76,6 +76,7 @@ m_CurrentNote(0) | |||||
| m_PluginInfo.PortTips.push_back("PitchBend CV"); | m_PluginInfo.PortTips.push_back("PitchBend CV"); | ||||
| m_PluginInfo.PortTips.push_back("ChannelPressure CV"); | m_PluginInfo.PortTips.push_back("ChannelPressure CV"); | ||||
| m_PluginInfo.PortTips.push_back("Aftertouch CV"); | m_PluginInfo.PortTips.push_back("Aftertouch CV"); | ||||
| m_PluginInfo.PortTips.push_back("Clock CV"); | |||||
| for (int n=0; n<128; n++) m_ControlLevel[n]=0; | for (int n=0; n<128; n++) m_ControlLevel[n]=0; | ||||
| @@ -116,6 +117,7 @@ void MidiPlugin::Execute() | |||||
| GetOutputBuf(2)->Zero(); | GetOutputBuf(2)->Zero(); | ||||
| GetOutputBuf(3)->Zero(); | GetOutputBuf(3)->Zero(); | ||||
| GetOutputBuf(4)->Zero(); | GetOutputBuf(4)->Zero(); | ||||
| GetOutputBuf(5)->Zero(); | |||||
| for (unsigned int c=0; c<m_ControlList.size(); c++) | for (unsigned int c=0; c<m_ControlList.size(); c++) | ||||
| { | { | ||||
| @@ -219,6 +221,7 @@ void MidiPlugin::Execute() | |||||
| Event=MidiDevice::Get()->GetEvent(m_DeviceNum); | Event=MidiDevice::Get()->GetEvent(m_DeviceNum); | ||||
| } | } | ||||
| for (int n=0; n<m_HostInfo->BUFSIZE; n++) | for (int n=0; n<m_HostInfo->BUFSIZE; n++) | ||||
| { | { | ||||
| SetOutputPitch(0,n,m_NoteLevel); | SetOutputPitch(0,n,m_NoteLevel); | ||||
| @@ -226,6 +229,7 @@ void MidiPlugin::Execute() | |||||
| SetOutput(2,n,m_PitchBendLevel); | SetOutput(2,n,m_PitchBendLevel); | ||||
| SetOutput(3,n,m_ChannelPressureLevel); | SetOutput(3,n,m_ChannelPressureLevel); | ||||
| SetOutput(4,n,m_AfterTouchLevel); | SetOutput(4,n,m_AfterTouchLevel); | ||||
| SetOutput(5,n,MidiDevice::Get()->GetClock()); | |||||
| } | } | ||||
| for (unsigned int c=0; c<m_ControlList.size(); c++) | for (unsigned int c=0; c<m_ControlList.size(); c++) | ||||
| @@ -66,6 +66,7 @@ private: | |||||
| bool m_NoteCut; | bool m_NoteCut; | ||||
| bool m_ContinuousNotes; | bool m_ContinuousNotes; | ||||
| int m_CurrentNote; | int m_CurrentNote; | ||||
| static int m_RefCount; | static int m_RefCount; | ||||
| vector<int> m_ControlList; | vector<int> m_ControlList; | ||||
| @@ -428,7 +428,7 @@ void PoshSamplerPluginGUI::Update() | |||||
| m_Display->redraw(); | m_Display->redraw(); | ||||
| m_UpdateMe=false; | m_UpdateMe=false; | ||||
| } | } | ||||
| redraw(); | |||||
| //redraw(); | |||||
| } | } | ||||
| void PoshSamplerPluginGUI::UpdateValues(SpiralPlugin *o) | void PoshSamplerPluginGUI::UpdateValues(SpiralPlugin *o) | ||||
| @@ -1,464 +0,0 @@ | |||||
| /* SpiralLoops | |||||
| * Copyleft (C) 2000 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 <FL/fl_file_chooser.h> | |||||
| #include "Loop.h" | |||||
| #include "../../RiffWav.h" | |||||
| //#include "SpiralLoopsInfo.h" | |||||
| static const int RECBUFFERSIZE = 16384; | |||||
| static const float RECORD_GAIN = 1.0f; | |||||
| Loop::Loop() : | |||||
| m_Id(0), | |||||
| m_Pos(0), | |||||
| m_IntPos(0), | |||||
| m_PlayBufPos(0), | |||||
| m_Playing(true), | |||||
| m_Recording(false), | |||||
| m_Master(false), | |||||
| m_DelMe(false), | |||||
| m_LoopPoint(0), | |||||
| m_Speed(1.0f), | |||||
| m_Volume(1.0f), | |||||
| m_RecordingSource(NULL), | |||||
| m_Balance(1.0f), | |||||
| m_LeftVol(1.0f), | |||||
| m_RightVol(1.0f), | |||||
| m_FirstRecord(true), | |||||
| m_FixedRecord(false), | |||||
| m_RecLength(0), | |||||
| m_EffectsOn(false) | |||||
| { | |||||
| } | |||||
| Loop::~Loop() | |||||
| { | |||||
| } | |||||
| void Loop::LoadWav(const char *Filename) | |||||
| { | |||||
| WavFile wav; | |||||
| if (wav.Open(Filename, WavFile::READ)) | |||||
| { | |||||
| Clear(); | |||||
| AllocateMem(wav.GetSize()); | |||||
| wav.Load(m_StoreBuffer); | |||||
| //((Fl_Loop*)(m_GUI->GetGUI()))->DrawEveryThing(); | |||||
| m_GUI->UpdateDataPtr(); | |||||
| } | |||||
| } | |||||
| void Loop::SaveWav(const char *Filename) | |||||
| { | |||||
| WavFile wav; | |||||
| if (wav.Open(Filename, WavFile::WRITE, WavFile::MONO)) | |||||
| { | |||||
| wav.Save(m_StoreBuffer); | |||||
| } | |||||
| m_Sample=Filename; | |||||
| } | |||||
| bool Loop::GetOutput(Sample &data) | |||||
| { | |||||
| if (!m_Recording && !m_Playing) | |||||
| { | |||||
| return false; | |||||
| } | |||||
| if (!m_Recording && m_StoreBuffer.GetLength()==0) | |||||
| { | |||||
| return false; | |||||
| } | |||||
| if (m_Recording) | |||||
| { | |||||
| RecordBuf(m_Pos, data.GetLength()); | |||||
| if (!m_StoreBuffer.GetLength()) | |||||
| { | |||||
| return false; | |||||
| } | |||||
| } | |||||
| int Pos; | |||||
| for (int n=0; n<data.GetLength(); n++) | |||||
| { | |||||
| Pos=static_cast<int>(m_Pos); | |||||
| // brute force fix | |||||
| if (Pos>0 && Pos<m_LoopPoint) | |||||
| { | |||||
| data.Set(n,m_StoreBuffer[m_Pos]*m_Volume); | |||||
| } | |||||
| else data.Set(n,0); | |||||
| m_Pos+=m_Speed; | |||||
| if (static_cast<int>(m_Pos)>=m_LoopPoint) | |||||
| { | |||||
| m_Pos=0; | |||||
| } | |||||
| } | |||||
| m_Filter.GetOutput(0,data); | |||||
| // causes problems if we save to a hold buffer | |||||
| // while we're recording, as we might not know | |||||
| // the size of the final buffer | |||||
| if (!m_Recording) | |||||
| { | |||||
| for (int n=0; n<data.GetLength(); n++) | |||||
| { | |||||
| if (m_PlayBufPos>=m_LoopPoint) | |||||
| { | |||||
| m_PlayBufPos=0; | |||||
| } | |||||
| m_HoldBuffer.Set(m_PlayBufPos,data[n]); | |||||
| m_PlayBufPos++; | |||||
| } | |||||
| } | |||||
| m_IntPos=static_cast<int>(m_Pos); | |||||
| m_GUI->UpdatePos(); | |||||
| return true; | |||||
| } | |||||
| void Loop::AllocateMem(int Length) | |||||
| { | |||||
| // We might need to keep these values (if loading workspace) | |||||
| if (m_LoopPoint>Length) m_LoopPoint=Length; | |||||
| if (m_Pos>Length) m_Pos=0; | |||||
| if (m_LoopPoint==0) m_LoopPoint=Length; | |||||
| if (!m_StoreBuffer.Allocate(Length) || | |||||
| !m_HoldBuffer.Allocate(Length)) | |||||
| { | |||||
| cerr<<"AllocateMem can't allocate any more memory!"<<endl; | |||||
| Clear(); | |||||
| } | |||||
| } | |||||
| void Loop::Clear() | |||||
| { | |||||
| m_StoreBuffer.Clear(); | |||||
| m_HoldBuffer.Clear(); | |||||
| //m_LoopPoint=0; | |||||
| } | |||||
| void Loop::RecordBuf(float Pos, int Length) | |||||
| { | |||||
| if (!m_RecordingSource) return; | |||||
| static float OldPos=Pos; | |||||
| if (m_FirstRecord) | |||||
| { | |||||
| // Find out if we want a fixed length record | |||||
| // based on the last sample length, or not | |||||
| if (m_StoreBuffer.GetLength()) | |||||
| { | |||||
| m_FixedRecord=true; | |||||
| } | |||||
| else | |||||
| { | |||||
| m_FixedRecord=false; | |||||
| m_RecBuffer.Allocate(RECBUFFERSIZE); | |||||
| m_StoreBuffer.Clear(); | |||||
| m_RecPos=0; | |||||
| } | |||||
| m_FirstRecord=false; | |||||
| m_RecLength=0; | |||||
| OldPos=Pos; | |||||
| } | |||||
| if (m_FixedRecord) | |||||
| { | |||||
| m_RecLength=m_LoopPoint; | |||||
| if (Pos>=m_StoreBuffer.GetLength()) | |||||
| { | |||||
| Pos=0; | |||||
| } | |||||
| for (int n=0; n<Length; n++) | |||||
| { | |||||
| // just add directly to the old buffer | |||||
| float temp=m_StoreBuffer[static_cast<int>(Pos)]+m_RecordingSource[n]*RECORD_GAIN; | |||||
| // fill in all the samples between the speed jump with the same value | |||||
| m_StoreBuffer.Set((int)Pos,temp); | |||||
| for (int i=static_cast<int>(OldPos); i<=static_cast<int>(Pos); i++) | |||||
| { | |||||
| m_StoreBuffer.Set(i,temp); | |||||
| } | |||||
| OldPos=Pos; | |||||
| Pos+=m_Speed; | |||||
| if (Pos>=m_StoreBuffer.GetLength()) | |||||
| { | |||||
| Pos-=m_StoreBuffer.GetLength(); | |||||
| // remember to fill up to the end of the last buffer | |||||
| for (int i=static_cast<int>(OldPos); i<m_StoreBuffer.GetLength(); i++) | |||||
| { | |||||
| m_StoreBuffer.Set(i,temp); | |||||
| } | |||||
| // and the beggining of this one | |||||
| for (int i=0; i<Pos; i++) | |||||
| { | |||||
| m_StoreBuffer.Set(i,temp); | |||||
| } | |||||
| OldPos=0; | |||||
| } | |||||
| } | |||||
| } | |||||
| else | |||||
| { | |||||
| for (int n=0; n<Length; n++) | |||||
| { | |||||
| // see if we need a new buffer | |||||
| if (m_RecPos>=RECBUFFERSIZE) | |||||
| { | |||||
| // put the two buffers together | |||||
| m_StoreBuffer.Add(m_RecBuffer); | |||||
| m_RecPos=0; | |||||
| } | |||||
| long temp=(long)(m_RecordingSource[n]*RECORD_GAIN); | |||||
| m_RecBuffer.Set(m_RecPos,temp); | |||||
| m_RecLength++; | |||||
| m_RecPos++; | |||||
| } | |||||
| } | |||||
| } | |||||
| void Loop::EndRecordBuf() | |||||
| { | |||||
| m_FirstRecord=true; | |||||
| m_LoopPoint=m_StoreBuffer.GetLength(); | |||||
| if (!m_FixedRecord) | |||||
| { | |||||
| // reallocate the hold buffer for the new size | |||||
| // (if the size has changed) | |||||
| m_HoldBuffer.Allocate(m_LoopPoint); | |||||
| } | |||||
| } | |||||
| void Loop::Crop() | |||||
| { | |||||
| if (m_LoopPoint<m_StoreBuffer.GetLength()) | |||||
| { | |||||
| m_StoreBuffer.CropTo(m_LoopPoint); | |||||
| m_HoldBuffer.CropTo(m_LoopPoint); | |||||
| } | |||||
| } | |||||
| void Loop::Double() | |||||
| { | |||||
| Crop(); | |||||
| m_StoreBuffer.Add(m_StoreBuffer); | |||||
| m_HoldBuffer.Add(m_HoldBuffer); | |||||
| m_LoopPoint=m_StoreBuffer.GetLength(); | |||||
| } | |||||
| void Loop::MatchLength(int Len) | |||||
| { | |||||
| // set the length, and make sure enough data is allocated | |||||
| if (m_StoreBuffer.GetLength()>Len) | |||||
| { | |||||
| SetLength(Len); | |||||
| return; | |||||
| } | |||||
| else | |||||
| { | |||||
| // if it's empty | |||||
| if (!m_StoreBuffer.GetLength()) | |||||
| { | |||||
| AllocateMem(Len); | |||||
| m_StoreBuffer.Zero(); | |||||
| } | |||||
| else | |||||
| // there is something in the buffer already, but we need to | |||||
| // add on some extra data to make the length the same | |||||
| { | |||||
| int ExtraLen=Len-m_StoreBuffer.GetLength(); | |||||
| m_StoreBuffer.Expand(ExtraLen); | |||||
| m_HoldBuffer.Expand(ExtraLen); | |||||
| } | |||||
| } | |||||
| } | |||||
| void Loop::Cut(int Start, int End) | |||||
| { | |||||
| //m_Parent->Cut(m_StoreBuffer,Start,End); | |||||
| if (m_StoreBuffer.GetLength()<m_LoopPoint) | |||||
| { | |||||
| m_LoopPoint=m_StoreBuffer.GetLength(); | |||||
| } | |||||
| if (m_Pos>m_LoopPoint) | |||||
| { | |||||
| m_Pos=0; | |||||
| } | |||||
| m_HoldBuffer.Allocate(m_StoreBuffer.GetLength()); | |||||
| } | |||||
| void Loop::Copy(int Start, int End) | |||||
| { | |||||
| //m_Parent->Copy(m_StoreBuffer,Start,End); | |||||
| } | |||||
| void Loop::Paste(int Start) | |||||
| { | |||||
| //m_Parent->Paste(m_StoreBuffer,Start); | |||||
| if (m_StoreBuffer.GetLength()<m_LoopPoint) | |||||
| { | |||||
| m_LoopPoint=m_StoreBuffer.GetLength(); | |||||
| } | |||||
| if (m_Pos>m_LoopPoint) | |||||
| { | |||||
| m_Pos=0; | |||||
| } | |||||
| m_HoldBuffer.Allocate(m_StoreBuffer.GetLength()); | |||||
| } | |||||
| void Loop::PasteMix(int Start) | |||||
| { | |||||
| //m_Parent->PasteMix(m_StoreBuffer,Start); | |||||
| } | |||||
| void Loop::ZeroRange(int Start, int End) | |||||
| { | |||||
| for (int n=Start; n<End; n++) | |||||
| { | |||||
| m_StoreBuffer.Set(n,0); | |||||
| } | |||||
| } | |||||
| void Loop::ReverseRange(int Start, int End) | |||||
| { | |||||
| m_StoreBuffer.Reverse(Start,End); | |||||
| } | |||||
| void Loop::Halve() | |||||
| { | |||||
| m_StoreBuffer.Shrink(m_StoreBuffer.GetLength()/2); | |||||
| m_HoldBuffer.Shrink(m_HoldBuffer.GetLength()/2); | |||||
| if (m_StoreBuffer.GetLength()<m_LoopPoint) | |||||
| { | |||||
| m_LoopPoint=m_StoreBuffer.GetLength(); | |||||
| } | |||||
| if (m_Pos>m_LoopPoint) | |||||
| { | |||||
| m_Pos=0; | |||||
| } | |||||
| } | |||||
| void Loop::SelectAll() | |||||
| { | |||||
| } | |||||
| void Loop::Move(int Start) | |||||
| { | |||||
| m_StoreBuffer.Move(Start); | |||||
| } | |||||
| void Loop::StreamIn(istream &s) | |||||
| { | |||||
| s>>m_Id>>m_Pos>>m_IntPos>>m_PlayBufPos>>m_Playing>>m_Master>>m_LoopPoint>> | |||||
| m_Speed>>m_Volume>>m_Balance>>m_LeftVol>>m_RightVol>>m_Filter>> | |||||
| m_EffectsOn; | |||||
| } | |||||
| void Loop::StreamOut(ostream &s) | |||||
| { | |||||
| s<<m_Id<<" "<<m_Pos<<" "<<m_IntPos<<" "<<m_PlayBufPos<<" "<<m_Playing | |||||
| <<" "<<m_Master<<" "<<m_LoopPoint<<" "<<m_Speed<<" "<<m_Volume<<" " | |||||
| <<m_Balance<<" "<<m_LeftVol<<" "<<m_RightVol<<" "<<m_Filter<<" " | |||||
| <<m_EffectsOn<<" "; | |||||
| } | |||||
| istream &operator>>(istream &s, Loop &o) | |||||
| { | |||||
| s>>o.m_Id>>o.m_Pos>>o.m_IntPos>>o.m_PlayBufPos>>o.m_Playing>>o.m_Master>>o.m_LoopPoint>> | |||||
| o.m_Speed>>o.m_Volume>>o.m_Balance>>o.m_LeftVol>>o.m_RightVol>>o.m_Filter>> | |||||
| o.m_EffectsOn; | |||||
| char Buf[4096]; | |||||
| int size; | |||||
| s>>size; | |||||
| s.ignore(1); | |||||
| s.get(Buf,size+1); | |||||
| o.m_Sample=Buf; | |||||
| if (o.m_Sample!="") | |||||
| { | |||||
| o.LoadWav(o.m_Sample.c_str()); | |||||
| } | |||||
| return s; | |||||
| } | |||||
| ostream &operator<<(ostream &s, Loop &o) | |||||
| { | |||||
| // if this sample is not saved, get the user to pick a filename. | |||||
| if (o.m_Sample=="") | |||||
| { | |||||
| char *fn=fl_file_chooser("Save loop as Wav file", "*.wav", NULL); | |||||
| if (fn && fn!="") | |||||
| { | |||||
| o.m_Sample=fn; | |||||
| o.SaveWav(o.m_Sample.c_str()); | |||||
| } | |||||
| } | |||||
| else | |||||
| { | |||||
| if (fl_ask("Save loop sample %s?",o.m_Sample.c_str())) | |||||
| { | |||||
| o.SaveWav(o.m_Sample.c_str()); | |||||
| } | |||||
| } | |||||
| s<<o.m_Id<<" "<<o.m_Pos<<" "<<o.m_IntPos<<" "<<o.m_PlayBufPos<<" "<<o.m_Playing | |||||
| <<" "<<o.m_Master<<" "<<o.m_LoopPoint<<" "<<o.m_Speed<<" "<<o.m_Volume<<" " | |||||
| <<o.m_Balance<<" "<<o.m_LeftVol<<" "<<o.m_RightVol<<" "<<o.m_Filter<<" " | |||||
| <<o.m_EffectsOn<<" "<<o.m_Sample.size()<<" "<<o.m_Sample<<" "; | |||||
| return s; | |||||
| } | |||||
| @@ -1,134 +0,0 @@ | |||||
| /* SpiralLoops | |||||
| * Copyleft (C) 2000 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 LOOP | |||||
| #define LOOP | |||||
| #include "SpiralSound/Filter.h" | |||||
| #include "GUI/LoopGUI.h" | |||||
| #include "../../Sample.h" | |||||
| class Loop | |||||
| { | |||||
| public: | |||||
| Loop(); | |||||
| ~Loop(); | |||||
| void LoadWav(const char *Filename); | |||||
| void SaveWav(const char *Filename); | |||||
| bool GetOutput(Sample &data); | |||||
| void AllocateMem(int Length); | |||||
| void Clear(); | |||||
| void Hold() {m_StoreBuffer=m_HoldBuffer;} | |||||
| void Double(); | |||||
| void MatchLength(int Len); | |||||
| void Crop(); | |||||
| void StreamIn(istream &s); | |||||
| void StreamOut(ostream &s); | |||||
| void SetGUI(LoopGUI *s) { m_GUI=s; } | |||||
| void SetId(int Id) { m_Id=Id; } | |||||
| void SetCutoff(int c) { m_Filter.SetCutoff(c); } | |||||
| void SetResonance(int r) { m_Filter.SetResonance(r); } | |||||
| void SetPos(int Pos) { m_Pos=Pos; } | |||||
| void SetLength(int Len) { m_LoopPoint=Len; } | |||||
| void SetSpeed(float Speed) { m_Speed=Speed; } | |||||
| void SetVolume(float Vol) { m_Volume=Vol; } | |||||
| void SetPlaying(bool Playing) { m_Playing=Playing; } | |||||
| void SetRecordingSource(const float *s) { m_RecordingSource=s; } | |||||
| void Record(bool r) { m_Recording=r; if (!r) EndRecordBuf(); } | |||||
| void SetMasterStatus(bool m) { m_Master=m; } | |||||
| void FilterBypass(bool s) { m_Filter.FilterBypass(s); } | |||||
| void DelMe() { m_DelMe=true; } | |||||
| void SetBalance(float s) { m_Balance=s; m_LeftVol=(2-s)/2; m_RightVol=(1+s-1.0f)/2;} | |||||
| void Trigger() { m_Pos=0; SetPlaying(true); } | |||||
| void SetEffects(bool s) { m_EffectsOn=s; } | |||||
| const float GetVolume() {return m_Volume;} | |||||
| const float GetCutoff() {return m_Filter.GetCutoff();} | |||||
| const float GetResonance() {return m_Filter.GetCutoff();} | |||||
| const float GetBalance() {return m_Balance;} | |||||
| const bool GetEffects() {return m_EffectsOn;} | |||||
| const bool IsPlaying() {return m_Playing;} | |||||
| const float *GetLoopPtr() {return m_StoreBuffer.GetBuffer();} | |||||
| const int GetId() {return m_Id;} | |||||
| const int GetLoopLength() {return m_LoopPoint;} | |||||
| float *GetPosPtr() {return &m_Pos;} | |||||
| const int GetTotalLength() {assert(m_StoreBuffer.GetLength()==m_HoldBuffer.GetLength()); return m_StoreBuffer.GetLength();} | |||||
| const bool IsMaster() {return m_Master;} | |||||
| const bool Delete() {return m_DelMe; } | |||||
| const float GetSpeed() {return m_Speed;} | |||||
| const float GetLeftVol() { return m_LeftVol; } | |||||
| const float GetRightVol() { return m_RightVol; } | |||||
| const float GetCurrentAngle() { return m_LoopPoint?(m_Pos/m_LoopPoint)*360.0f:0; } | |||||
| const string& GetSampleName() { return m_Sample; } | |||||
| void Cut(int Start, int End); | |||||
| void Copy(int Start, int End); | |||||
| void Paste(int Start); | |||||
| void PasteMix(int Start); | |||||
| void ZeroRange(int Start, int End); | |||||
| void ReverseRange(int Start, int End); | |||||
| void Halve(); | |||||
| void SelectAll(); | |||||
| void Move(int Start); | |||||
| private: | |||||
| void RecordBuf(float Pos, int Length); | |||||
| void EndRecordBuf(); | |||||
| Filter m_Filter; | |||||
| int m_Id; | |||||
| float m_Pos; | |||||
| int m_IntPos; | |||||
| int m_PlayBufPos; | |||||
| bool m_Playing; | |||||
| bool m_Recording; | |||||
| bool m_Master; | |||||
| bool m_DelMe; | |||||
| long int m_LoopPoint; | |||||
| float m_Speed; | |||||
| float m_Volume; | |||||
| const float *m_RecordingSource; | |||||
| Sample m_StoreBuffer; | |||||
| Sample m_HoldBuffer; | |||||
| Sample m_RecBuffer; | |||||
| int m_RecPos; | |||||
| float m_Balance; | |||||
| float m_LeftVol,m_RightVol; | |||||
| bool m_FirstRecord; | |||||
| bool m_FixedRecord; | |||||
| int m_RecLength; | |||||
| bool m_EffectsOn; | |||||
| string m_Sample; | |||||
| LoopGUI *m_GUI; | |||||
| friend istream &operator>>(istream &s, Loop &o); | |||||
| friend ostream &operator<<(ostream &s, Loop &o); | |||||
| }; | |||||
| istream &operator>>(istream &s, Loop &o); | |||||
| ostream &operator<<(ostream &s, Loop &o); | |||||
| #endif | |||||
| @@ -44,69 +44,36 @@ mandir = @mandir@ | |||||
| HEADERS = ../SpiralPlugin.h \ | HEADERS = ../SpiralPlugin.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../../ChannelHandler.h \ | ../../ChannelHandler.h \ | ||||
| ../Widgets/Fl_Knob.H \ | |||||
| ../Widgets/Fl_DragBar.H \ | |||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| ../../RiffWav.h \ | ../../RiffWav.h \ | ||||
| SpiralSound/Delay.h \ | |||||
| SpiralSound/Filter.h \ | |||||
| SpiralSound/Reverb.h \ | |||||
| SpiralSound/iir_filter.h \ | |||||
| GUI/DelayGUI.h \ | |||||
| GUI/FilterGUI.h \ | |||||
| GUI/GUIBase.h \ | |||||
| GUI/LoopGUI.h \ | |||||
| GUI/ReverbGUI.h \ | |||||
| GUI/Widgets/Fl_LED_Button.H \ | |||||
| GUI/Widgets/Fl_Loop.h \ | |||||
| GUI/Widgets/Fl_Trigger.h \ | |||||
| Loop.h \ | |||||
| Fl_Loop.h \ | |||||
| Fl_Trigger.h \ | |||||
| SpiralLoopPlugin.h \ | SpiralLoopPlugin.h \ | ||||
| SpiralLoopPluginGUI.h | |||||
| SpiralLoopPluginGUI.h \ | |||||
| ../Widgets/Fl_Knob.H \ | |||||
| ../Widgets/Fl_LED_Button.H | |||||
| SOURCES = ../SpiralPlugin.C \ | SOURCES = ../SpiralPlugin.C \ | ||||
| ../SpiralPluginGUI.C \ | ../SpiralPluginGUI.C \ | ||||
| ../../ChannelHandler.C \ | ../../ChannelHandler.C \ | ||||
| ../Widgets/Fl_Knob.cxx \ | |||||
| ../Widgets/Fl_DragBar.cxx \ | |||||
| ../../Sample.C \ | ../../Sample.C \ | ||||
| ../../RiffWav.C \ | ../../RiffWav.C \ | ||||
| SpiralSound/Delay.C \ | |||||
| SpiralSound/Filter.C \ | |||||
| SpiralSound/Reverb.C \ | |||||
| SpiralSound/iir_filter.C \ | |||||
| GUI/DelayGUI.C \ | |||||
| GUI/FilterGUI.C \ | |||||
| GUI/GUIBase.C \ | |||||
| GUI/LoopGUI.C \ | |||||
| GUI/ReverbGUI.C \ | |||||
| GUI/Widgets/Fl_LED_Button.cxx \ | |||||
| GUI/Widgets/Fl_Loop.C \ | |||||
| GUI/Widgets/Fl_Trigger.C \ | |||||
| Loop.C \ | |||||
| Fl_Loop.C \ | |||||
| Fl_Trigger.C \ | |||||
| SpiralLoopPlugin.C \ | SpiralLoopPlugin.C \ | ||||
| SpiralLoopPluginGUI.C | |||||
| SpiralLoopPluginGUI.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | |||||
| ../Widgets/Fl_LED_Button.cxx | |||||
| OBJECTS = ../SpiralPlugin.o \ | OBJECTS = ../SpiralPlugin.o \ | ||||
| ../SpiralPluginGUI.o \ | ../SpiralPluginGUI.o \ | ||||
| ../../ChannelHandler.o \ | ../../ChannelHandler.o \ | ||||
| ../Widgets/Fl_Knob.o \ | |||||
| ../Widgets/Fl_DragBar.o \ | |||||
| ../../Sample.o \ | ../../Sample.o \ | ||||
| ../../RiffWav.o \ | ../../RiffWav.o \ | ||||
| SpiralSound/Delay.o \ | |||||
| SpiralSound/Filter.o \ | |||||
| SpiralSound/Reverb.o \ | |||||
| SpiralSound/iir_filter.o \ | |||||
| GUI/DelayGUI.o \ | |||||
| GUI/FilterGUI.o \ | |||||
| GUI/GUIBase.o \ | |||||
| GUI/LoopGUI.o \ | |||||
| GUI/ReverbGUI.o \ | |||||
| GUI/Widgets/Fl_LED_Button.o \ | |||||
| GUI/Widgets/Fl_Loop.o \ | |||||
| GUI/Widgets/Fl_Trigger.o \ | |||||
| Loop.o \ | |||||
| Fl_Loop.o \ | |||||
| Fl_Trigger.o \ | |||||
| SpiralLoopPlugin.o \ | SpiralLoopPlugin.o \ | ||||
| SpiralLoopPluginGUI.o | |||||
| SpiralLoopPluginGUI.o \ | |||||
| ../Widgets/Fl_Knob.o \ | |||||
| ../Widgets/Fl_LED_Button.o | |||||
| INTERFACES = | INTERFACES = | ||||
| UICDECLS = | UICDECLS = | ||||
| UICIMPLS = | UICIMPLS = | ||||
| @@ -175,12 +142,6 @@ install: | |||||
| ../SpiralPlugin.h \ | ../SpiralPlugin.h \ | ||||
| ../../Sample.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.o: ../../Sample.C \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| ../../SpiralInfo.h | ../../SpiralInfo.h | ||||
| @@ -190,129 +151,13 @@ install: | |||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| ../../SpiralInfo.h | ../../SpiralInfo.h | ||||
| SpiralSound/Delay.o: SpiralSound/Delay.C \ | |||||
| SpiralSound/Delay.h \ | |||||
| SpiralSound/../../../SpiralInfo.h \ | |||||
| ../../Sample.h \ | |||||
| ../../SpiralInfo.h \ | |||||
| SpiralSound/../../../Sample.h | |||||
| SpiralSound/Filter.o: SpiralSound/Filter.C \ | |||||
| SpiralSound/Filter.h \ | |||||
| SpiralSound/../../../NoteTable.h \ | |||||
| SpiralSound/../../../SpiralInfo.h \ | |||||
| ../../Sample.h \ | |||||
| ../../SpiralInfo.h \ | |||||
| SpiralSound/iir_filter.h \ | |||||
| SpiralSound/../../../Sample.h | |||||
| SpiralSound/Reverb.o: SpiralSound/Reverb.C \ | |||||
| SpiralSound/Reverb.h \ | |||||
| SpiralSound/../../../SpiralInfo.h \ | |||||
| ../../Sample.h \ | |||||
| ../../SpiralInfo.h \ | |||||
| SpiralSound/Delay.h | |||||
| SpiralSound/iir_filter.o: SpiralSound/iir_filter.C \ | |||||
| SpiralSound/iir_filter.h | |||||
| GUI/DelayGUI.o: GUI/DelayGUI.C \ | |||||
| GUI/DelayGUI.h \ | |||||
| GUI/../../Widgets/Fl_Knob.H \ | |||||
| GUI/GUIBase.h \ | |||||
| SpiralSound/../../../SpiralInfo.h \ | |||||
| ../../Sample.h \ | |||||
| ../../SpiralInfo.h \ | |||||
| GUI/../SpiralSound/Delay.h | |||||
| GUI/FilterGUI.o: GUI/FilterGUI.C \ | |||||
| GUI/FilterGUI.h \ | |||||
| GUI/Widgets/Fl_Knob.H \ | |||||
| GUI/GUIBase.h \ | |||||
| SpiralSound/../../../SpiralInfo.h \ | |||||
| ../../Sample.h \ | |||||
| ../../SpiralInfo.h \ | |||||
| GUI/../SpiralSound/Filter.h \ | |||||
| GUI/../../../NoteTable.h \ | |||||
| SpiralSound/iir_filter.h | |||||
| GUI/GUIBase.o: GUI/GUIBase.C \ | |||||
| GUI/GUIBase.h \ | |||||
| SpiralSound/../../../SpiralInfo.h \ | |||||
| ../../Sample.h \ | |||||
| ../../SpiralInfo.h | |||||
| GUI/LoopGUI.o: GUI/LoopGUI.C \ | |||||
| SpiralSound/../../../SpiralInfo.h \ | |||||
| ../../Sample.h \ | |||||
| ../../SpiralInfo.h \ | |||||
| GUI/Widgets/Fl_Loop.h \ | |||||
| GUI/LoopGUI.h \ | |||||
| GUI/Widgets/Fl_Knob.H \ | |||||
| GUI/Widgets/Fl_LED_Button.H \ | |||||
| GUI/Widgets/Fl_Trigger.h \ | |||||
| GUI/DelayGUI.h \ | |||||
| GUI/../../Widgets/Fl_Knob.H \ | |||||
| GUI/GUIBase.h \ | |||||
| GUI/../SpiralSound/Delay.h \ | |||||
| GUI/ReverbGUI.h \ | |||||
| GUI/../SpiralSound/Reverb.h \ | |||||
| SpiralSound/Delay.h \ | |||||
| GUI/../SpiralSound/Filter.h \ | |||||
| GUI/../../../NoteTable.h \ | |||||
| SpiralSound/iir_filter.h \ | |||||
| GUI/../Loop.h \ | |||||
| SpiralSound/Filter.h \ | |||||
| SpiralSound/Delay.h \ | |||||
| SpiralSound/Reverb.h \ | |||||
| GUI/LoopGUI.h \ | |||||
| ../../Sample.h | |||||
| GUI/ReverbGUI.o: GUI/ReverbGUI.C \ | |||||
| GUI/ReverbGUI.h \ | |||||
| GUI/Widgets/Fl_Knob.H \ | |||||
| GUI/GUIBase.h \ | |||||
| SpiralSound/../../../SpiralInfo.h \ | |||||
| ../../Sample.h \ | |||||
| ../../SpiralInfo.h \ | |||||
| GUI/../SpiralSound/Reverb.h \ | |||||
| SpiralSound/Delay.h | |||||
| GUI/Widgets/Fl_LED_Button.o: GUI/Widgets/Fl_LED_Button.cxx \ | |||||
| GUI/Widgets/Fl_LED_Button.H | |||||
| GUI/Widgets/Fl_Loop.o: GUI/Widgets/Fl_Loop.C \ | GUI/Widgets/Fl_Loop.o: GUI/Widgets/Fl_Loop.C \ | ||||
| GUI/Widgets/Fl_Loop.h | GUI/Widgets/Fl_Loop.h | ||||
| GUI/Widgets/Fl_Trigger.o: GUI/Widgets/Fl_Trigger.C \ | |||||
| GUI/Widgets/Fl_Trigger.h \ | |||||
| GUI/Widgets/Fl_Loop.h | |||||
| Loop.o: Loop.C \ | |||||
| Loop.h \ | |||||
| SpiralSound/Filter.h \ | |||||
| GUI/../../../NoteTable.h \ | |||||
| SpiralSound/../../../SpiralInfo.h \ | |||||
| ../../Sample.h \ | |||||
| ../../SpiralInfo.h \ | |||||
| SpiralSound/iir_filter.h \ | |||||
| SpiralSound/Delay.h \ | |||||
| SpiralSound/Reverb.h \ | |||||
| SpiralSound/Delay.h \ | |||||
| GUI/LoopGUI.h \ | |||||
| GUI/Widgets/Fl_Knob.H \ | |||||
| GUI/Widgets/Fl_Loop.h \ | |||||
| GUI/Widgets/Fl_LED_Button.H \ | |||||
| GUI/Widgets/Fl_Trigger.h \ | |||||
| GUI/DelayGUI.h \ | |||||
| GUI/../../Widgets/Fl_Knob.H \ | |||||
| GUI/GUIBase.h \ | |||||
| GUI/../SpiralSound/Delay.h \ | |||||
| GUI/ReverbGUI.h \ | |||||
| GUI/../SpiralSound/Reverb.h \ | |||||
| GUI/../SpiralSound/Filter.h \ | |||||
| ../../Sample.h \ | |||||
| ../../RiffWav.h | |||||
| Fl_Trigger.o: Fl_Trigger.C \ | |||||
| Fl_Trigger.h \ | |||||
| Fl_Loop.h | |||||
| SpiralLoopPlugin.o: SpiralLoopPlugin.C \ | SpiralLoopPlugin.o: SpiralLoopPlugin.C \ | ||||
| SpiralLoopPlugin.h \ | SpiralLoopPlugin.h \ | ||||
| @@ -320,26 +165,9 @@ SpiralLoopPlugin.o: SpiralLoopPlugin.C \ | |||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| ../../SpiralInfo.h \ | ../../SpiralInfo.h \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| Loop.h \ | |||||
| SpiralSound/Filter.h \ | |||||
| GUI/../../../NoteTable.h \ | |||||
| SpiralSound/../../../SpiralInfo.h \ | |||||
| SpiralSound/iir_filter.h \ | |||||
| SpiralSound/Delay.h \ | |||||
| SpiralSound/Reverb.h \ | |||||
| SpiralSound/Delay.h \ | |||||
| GUI/LoopGUI.h \ | |||||
| GUI/Widgets/Fl_Knob.H \ | |||||
| GUI/Widgets/Fl_Loop.h \ | |||||
| GUI/Widgets/Fl_LED_Button.H \ | |||||
| GUI/Widgets/Fl_Trigger.h \ | |||||
| GUI/DelayGUI.h \ | |||||
| GUI/../../Widgets/Fl_Knob.H \ | |||||
| GUI/GUIBase.h \ | |||||
| GUI/../SpiralSound/Delay.h \ | |||||
| GUI/ReverbGUI.h \ | |||||
| GUI/../SpiralSound/Reverb.h \ | |||||
| GUI/../SpiralSound/Filter.h \ | |||||
| ../../NoteTable.h \ | |||||
| Fl_Loop.h \ | |||||
| Fl_Trigger.h \ | |||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| SpiralLoopPluginGUI.h \ | SpiralLoopPluginGUI.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| @@ -356,30 +184,19 @@ SpiralLoopPluginGUI.o: SpiralLoopPluginGUI.C \ | |||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| ../../SpiralInfo.h \ | ../../SpiralInfo.h \ | ||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| Loop.h \ | |||||
| SpiralSound/Filter.h \ | |||||
| GUI/../../../NoteTable.h \ | |||||
| SpiralSound/../../../SpiralInfo.h \ | |||||
| SpiralSound/iir_filter.h \ | |||||
| SpiralSound/Delay.h \ | |||||
| SpiralSound/Reverb.h \ | |||||
| SpiralSound/Delay.h \ | |||||
| GUI/LoopGUI.h \ | |||||
| GUI/Widgets/Fl_Knob.H \ | |||||
| GUI/Widgets/Fl_Loop.h \ | |||||
| GUI/Widgets/Fl_LED_Button.H \ | |||||
| GUI/Widgets/Fl_Trigger.h \ | |||||
| GUI/DelayGUI.h \ | |||||
| GUI/../../Widgets/Fl_Knob.H \ | |||||
| GUI/GUIBase.h \ | |||||
| GUI/../SpiralSound/Delay.h \ | |||||
| GUI/ReverbGUI.h \ | |||||
| GUI/../SpiralSound/Reverb.h \ | |||||
| GUI/../SpiralSound/Filter.h \ | |||||
| ../../NoteTable.h \ | |||||
| Fl_Loop.h \ | |||||
| Fl_Trigger.h \ | |||||
| ../../Sample.h \ | ../../Sample.h \ | ||||
| ../SpiralPluginGUI.h \ | ../SpiralPluginGUI.h \ | ||||
| ../Widgets/Fl_DragBar.H \ | ../Widgets/Fl_DragBar.H \ | ||||
| ../Widgets/Fl_Knob.H | ../Widgets/Fl_Knob.H | ||||
| ../Widgets/Fl_Knob.o: ../Widgets/Fl_Knob.cxx \ | |||||
| ../Widgets/Fl_Knob.H | |||||
| ../Widgets/Fl_LED_Button.o: ../Widgets/Fl_LED_Button.cxx \ | |||||
| ../Widgets/Fl_LED_Button.H | |||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | ../../ChannelHandler.o: ../../ChannelHandler.C \ | ||||
| ../../ChannelHandler.h | ../../ChannelHandler.h | ||||
| @@ -23,7 +23,8 @@ | |||||
| #include "../../NoteTable.h" | #include "../../NoteTable.h" | ||||
| static const float TRIG_THRESH = 0.1; | static const float TRIG_THRESH = 0.1; | ||||
| static const int NOTETRIG = NUM_SAMPLES*2+1; | |||||
| static const int RECBUFFERSIZE = 16384; | |||||
| static const float RECORD_GAIN = 1.0f; | |||||
| extern "C" { | extern "C" { | ||||
| SpiralPlugin* CreateInstance() | SpiralPlugin* CreateInstance() | ||||
| @@ -49,16 +50,39 @@ string GetGroupName() | |||||
| /////////////////////////////////////////////////////// | /////////////////////////////////////////////////////// | ||||
| SpiralLoopPlugin::SpiralLoopPlugin() | |||||
| SpiralLoopPlugin::SpiralLoopPlugin() : | |||||
| m_Id(0), | |||||
| m_Pos(0), | |||||
| m_IntPos(0), | |||||
| m_PlayBufPos(0), | |||||
| m_Playing(true), | |||||
| m_Recording(false), | |||||
| m_DelMe(false), | |||||
| m_LoopPoint(0), | |||||
| m_Speed(1.0f), | |||||
| m_Volume(1.0f), | |||||
| m_RecordingSource(NULL), | |||||
| m_Balance(1.0f), | |||||
| m_LeftVol(1.0f), | |||||
| m_RightVol(1.0f), | |||||
| m_FirstRecord(true), | |||||
| m_FixedRecord(false), | |||||
| m_RecLength(0), | |||||
| m_TickTime(0), | |||||
| m_TickCurrent(0), | |||||
| m_TicksPerLoop(64), | |||||
| m_TickOutput(1.0f), | |||||
| m_Triggered(false) | |||||
| { | { | ||||
| m_PluginInfo.Name="SpiralLoop"; | m_PluginInfo.Name="SpiralLoop"; | ||||
| m_PluginInfo.Width=300; | m_PluginInfo.Width=300; | ||||
| m_PluginInfo.Height=320; | m_PluginInfo.Height=320; | ||||
| m_PluginInfo.NumInputs=2; | m_PluginInfo.NumInputs=2; | ||||
| m_PluginInfo.NumOutputs=9; | |||||
| m_PluginInfo.NumOutputs=10; | |||||
| m_PluginInfo.PortTips.push_back("Input"); | m_PluginInfo.PortTips.push_back("Input"); | ||||
| m_PluginInfo.PortTips.push_back("Play Trigger"); | m_PluginInfo.PortTips.push_back("Play Trigger"); | ||||
| m_PluginInfo.PortTips.push_back("Output"); | m_PluginInfo.PortTips.push_back("Output"); | ||||
| m_PluginInfo.PortTips.push_back("Clock"); | |||||
| m_PluginInfo.PortTips.push_back("LoopTrigger 0"); | m_PluginInfo.PortTips.push_back("LoopTrigger 0"); | ||||
| m_PluginInfo.PortTips.push_back("LoopTrigger 1"); | m_PluginInfo.PortTips.push_back("LoopTrigger 1"); | ||||
| m_PluginInfo.PortTips.push_back("LoopTrigger 2"); | m_PluginInfo.PortTips.push_back("LoopTrigger 2"); | ||||
| @@ -67,8 +91,18 @@ SpiralLoopPlugin::SpiralLoopPlugin() | |||||
| m_PluginInfo.PortTips.push_back("LoopTrigger 5"); | m_PluginInfo.PortTips.push_back("LoopTrigger 5"); | ||||
| m_PluginInfo.PortTips.push_back("LoopTrigger 6"); | m_PluginInfo.PortTips.push_back("LoopTrigger 6"); | ||||
| m_PluginInfo.PortTips.push_back("LoopTrigger 7"); | m_PluginInfo.PortTips.push_back("LoopTrigger 7"); | ||||
| m_Loop = new Loop; | |||||
| m_AudioCH->Register("TicksPerLoop",&m_TicksPerLoop); | |||||
| m_AudioCH->Register("Volume",&m_Volume); | |||||
| m_AudioCH->Register("Speed",&m_Speed); | |||||
| m_AudioCH->Register("Length",&m_GUIArgs.Length); | |||||
| m_AudioCH->Register("Start",&m_GUIArgs.Start); | |||||
| m_AudioCH->Register("End",&m_GUIArgs.End); | |||||
| m_AudioCH->Register("Pos",&m_Pos,ChannelHandler::OUTPUT); | |||||
| m_AudioCH->RegisterData("Name",ChannelHandler::INPUT,&m_GUIArgs.Name,sizeof(m_GUIArgs.Name)); | |||||
| m_AudioCH->RegisterData("SampleBuffer",ChannelHandler::OUTPUT_REQUEST,&m_SampleBuffer,TRANSBUF_SIZE); | |||||
| m_AudioCH->Register("SampleSize",&m_SampleSize,ChannelHandler::OUTPUT_REQUEST); | |||||
| m_Version=2; | m_Version=2; | ||||
| } | } | ||||
| @@ -83,84 +117,129 @@ PluginInfo &SpiralLoopPlugin::Initialise(const HostInfo *Host) | |||||
| SpiralGUIType *SpiralLoopPlugin::CreateGUI() | SpiralGUIType *SpiralLoopPlugin::CreateGUI() | ||||
| { | { | ||||
| m_GUI = new SpiralLoopPluginGUI(m_Loop, m_PluginInfo.Width, | |||||
| return new SpiralLoopPluginGUI(m_PluginInfo.Width, | |||||
| m_PluginInfo.Height, | m_PluginInfo.Height, | ||||
| this,m_HostInfo); | |||||
| m_GUI->hide(); | |||||
| return m_GUI; | |||||
| this,m_AudioCH,m_HostInfo); | |||||
| } | } | ||||
| void SpiralLoopPlugin::Execute() | void SpiralLoopPlugin::Execute() | ||||
| { | { | ||||
| if (InputExists(0)) m_Loop->SetRecordingSource(GetInput(0)->GetBuffer()); | |||||
| else m_Loop->SetRecordingSource(NULL); | |||||
| if (InputExists(0)) SetRecordingSource(GetInput(0)->GetBuffer()); | |||||
| else SetRecordingSource(NULL); | |||||
| for (int n=0; n<8; n++) GetOutputBuf(n+1)->Zero(); | for (int n=0; n<8; n++) GetOutputBuf(n+1)->Zero(); | ||||
| // get the triggers active this frame | // get the triggers active this frame | ||||
| vector<int> TriggerVec; | |||||
| ((SpiralLoopPluginGUI*)m_GUI)->GetGUI()-> | |||||
| CheckTriggers(m_Loop->GetCurrentAngle(),TriggerVec); | |||||
| for (vector<int>::iterator i=TriggerVec.begin(); | |||||
| i!=TriggerVec.end(); i++) | |||||
| for (vector<TriggerInfo>::iterator i=m_TriggerVec.begin(); | |||||
| i!=m_TriggerVec.end(); i++) | |||||
| { | { | ||||
| GetOutputBuf(*i+1)->Set(1); | |||||
| if (m_Pos > i->Time*m_StoreBuffer.GetLength() && | |||||
| !i->Triggered) | |||||
| { | |||||
| GetOutputBuf(i->Channel+2)->Set(1); | |||||
| i->Triggered=true; | |||||
| } | |||||
| } | } | ||||
| m_Loop->GetOutput(*GetOutputBuf(0)); | |||||
| static bool Triggered=false; | |||||
| if (GetOutput(*GetOutputBuf(0))) | |||||
| { | |||||
| // if it's looped - reset the triggers | |||||
| for (vector<TriggerInfo>::iterator i=m_TriggerVec.begin(); | |||||
| i!=m_TriggerVec.end(); i++) | |||||
| { | |||||
| i->Triggered=false; | |||||
| } | |||||
| m_TickCurrent=m_TickTime; | |||||
| } | |||||
| if (GetInput(1,0)>TRIG_THRESH) | if (GetInput(1,0)>TRIG_THRESH) | ||||
| { | { | ||||
| if (!Triggered) | |||||
| if (!m_Triggered) | |||||
| { | { | ||||
| m_Loop->Trigger(); | |||||
| Triggered=true; | |||||
| Trigger(); | |||||
| m_Triggered=true; | |||||
| } | } | ||||
| } | } | ||||
| else Triggered=false; | |||||
| } | |||||
| void SpiralLoopPlugin::StreamOut(ostream &s) | |||||
| { | |||||
| s<<m_Version<<" "; | |||||
| else m_Triggered=false; | |||||
| if (m_Version==1) | |||||
| m_TickCurrent+=m_HostInfo->BUFSIZE; | |||||
| if (m_TickCurrent>=m_TickTime) | |||||
| { | { | ||||
| s<<*m_Loop<<" "; | |||||
| s<<*((SpiralLoopPluginGUI*)m_GUI)->GetGUI()<<" "; | |||||
| m_TickOutput=-m_TickOutput; | |||||
| m_TickTime=m_StoreBuffer.GetLength()/m_TicksPerLoop; | |||||
| m_TickCurrent=0; | |||||
| } | } | ||||
| else | |||||
| GetOutputBuf(1)->Set(m_TickOutput); | |||||
| } | |||||
| void SpiralLoopPlugin::ExecuteCommands() | |||||
| { | |||||
| if (m_AudioCH->IsCommandWaiting()) | |||||
| { | { | ||||
| m_Loop->StreamOut(s); | |||||
| s<<*((SpiralLoopPluginGUI*)m_GUI)->GetGUI()<<" "; | |||||
| switch(m_AudioCH->GetCommand()) | |||||
| { | |||||
| case START : SetPlaying(true); break; | |||||
| case STOP : SetPlaying(false); break; | |||||
| case RECORD : Clear(); Record(true); break; | |||||
| case OVERDUB : Record(true); break; | |||||
| case ENDRECORD : Record(false); break; | |||||
| case LOAD : LoadWav(m_GUIArgs.Name); break; | |||||
| case SAVE : SaveWav(m_GUIArgs.Name); break; | |||||
| case CUT : Cut(m_GUIArgs.Start, m_GUIArgs.End); break; | |||||
| case COPY : Copy(m_GUIArgs.Start, m_GUIArgs.End); break; | |||||
| case PASTE : Paste(m_GUIArgs.Start); break; | |||||
| case PASTEMIX : PasteMix(m_GUIArgs.Start); break; | |||||
| case ZERO_RANGE : ZeroRange(m_GUIArgs.Start, m_GUIArgs.End); break; | |||||
| case REVERSE_RANGE : ReverseRange(m_GUIArgs.Start, m_GUIArgs.End); break; | |||||
| case SELECT_ALL : SelectAll(); break; | |||||
| case DOUBLE : Double(); break; | |||||
| case HALF : Halve(); break; | |||||
| case MOVE : Move(m_GUIArgs.Start); break; | |||||
| case CROP : Crop(); break; | |||||
| case KEEPDUB : MixDub(); break; | |||||
| case UNDODUB : ClearDub(); break; | |||||
| case CHANGE_LENGTH : m_LoopPoint=(int)(m_StoreBuffer.GetLength()*m_GUIArgs.Length); break; | |||||
| case NEW_TRIGGER : | |||||
| { | |||||
| TriggerInfo NewTrigger; | |||||
| NewTrigger.Channel = m_GUIArgs.End; | |||||
| NewTrigger.Time = m_GUIArgs.Length; | |||||
| if ((int)m_TriggerVec.size()!=m_GUIArgs.Start) cerr<<"no of triggers error!"<<endl; | |||||
| m_TriggerVec.push_back(NewTrigger); break; | |||||
| } | |||||
| case UPDATE_TRIGGER : | |||||
| { | |||||
| m_TriggerVec[m_GUIArgs.Start].Channel = m_GUIArgs.End; | |||||
| m_TriggerVec[m_GUIArgs.Start].Time = m_GUIArgs.Length; | |||||
| } | |||||
| case GETSAMPLE : | |||||
| { | |||||
| m_AudioCH->SetupBulkTransfer((void*)m_StoreBuffer.GetBuffer()); | |||||
| m_SampleSize=m_StoreBuffer.GetLength(); | |||||
| } break; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| void SpiralLoopPlugin::StreamOut(ostream &s) | |||||
| { | |||||
| } | |||||
| void SpiralLoopPlugin::StreamIn(istream &s) | void SpiralLoopPlugin::StreamIn(istream &s) | ||||
| { | { | ||||
| int version; | int version; | ||||
| s>>version; | s>>version; | ||||
| if (version==1) | |||||
| { | |||||
| s>>*m_Loop; | |||||
| s>>*((SpiralLoopPluginGUI*)m_GUI)->GetGUI(); | |||||
| } | |||||
| else | |||||
| { | |||||
| m_Loop->StreamIn(s); | |||||
| s>>*((SpiralLoopPluginGUI*)m_GUI)->GetGUI(); | |||||
| } | |||||
| } | } | ||||
| bool SpiralLoopPlugin::SaveExternalFiles(const string &Dir) | bool SpiralLoopPlugin::SaveExternalFiles(const string &Dir) | ||||
| { | { | ||||
| char temp[256]; | char temp[256]; | ||||
| sprintf(temp,"%sSpiralLoopSample%d.wav",Dir.c_str(),GetID()); | sprintf(temp,"%sSpiralLoopSample%d.wav",Dir.c_str(),GetID()); | ||||
| m_Loop->SaveWav(temp); | |||||
| SaveWav(temp); | |||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -168,5 +247,339 @@ void SpiralLoopPlugin::LoadExternalFiles(const string &Dir) | |||||
| { | { | ||||
| char temp[256]; | char temp[256]; | ||||
| sprintf(temp,"%sSpiralLoopSample%d.wav",Dir.c_str(),GetID()); | sprintf(temp,"%sSpiralLoopSample%d.wav",Dir.c_str(),GetID()); | ||||
| m_Loop->LoadWav(temp); | |||||
| LoadWav(temp); | |||||
| } | |||||
| void SpiralLoopPlugin::LoadWav(const char *Filename) | |||||
| { | |||||
| WavFile wav; | |||||
| if (wav.Open(Filename, WavFile::READ)) | |||||
| { | |||||
| Clear(); | |||||
| AllocateMem(wav.GetSize()); | |||||
| wav.Load(m_StoreBuffer); | |||||
| } | |||||
| } | |||||
| void SpiralLoopPlugin::SaveWav(const char *Filename) | |||||
| { | |||||
| WavFile wav; | |||||
| if (wav.Open(Filename, WavFile::WRITE, WavFile::MONO)) | |||||
| { | |||||
| wav.Save(m_StoreBuffer); | |||||
| } | |||||
| m_Sample=Filename; | |||||
| } | |||||
| bool SpiralLoopPlugin::GetOutput(Sample &data) | |||||
| { | |||||
| if (!m_Recording && !m_Playing) | |||||
| { | |||||
| return false; | |||||
| } | |||||
| if (!m_Recording && m_StoreBuffer.GetLength()==0) | |||||
| { | |||||
| return false; | |||||
| } | |||||
| if (m_FixedRecord && m_DubBuffer.GetLength()!=m_StoreBuffer.GetLength()) | |||||
| { | |||||
| cerr<<"eek! dub and store buffers don't match!"<<endl; | |||||
| } | |||||
| if (m_Recording) | |||||
| { | |||||
| RecordBuf(m_Pos, data.GetLength()); | |||||
| if (!m_StoreBuffer.GetLength()) | |||||
| { | |||||
| return false; | |||||
| } | |||||
| } | |||||
| int Pos; | |||||
| bool ret=false; | |||||
| for (int n=0; n<data.GetLength(); n++) | |||||
| { | |||||
| Pos=static_cast<int>(m_Pos); | |||||
| // brute force fix | |||||
| if (Pos>0 && Pos<m_LoopPoint) | |||||
| { | |||||
| data.Set(n,m_StoreBuffer[m_Pos]+m_DubBuffer[m_Pos]*m_Volume); | |||||
| } | |||||
| else data.Set(n,0); | |||||
| m_Pos+=m_Speed; | |||||
| if (static_cast<int>(m_Pos)>=m_LoopPoint) | |||||
| { | |||||
| ret=true; | |||||
| m_Pos=0; | |||||
| } | |||||
| } | |||||
| m_IntPos=static_cast<int>(m_Pos); | |||||
| return ret; | |||||
| } | |||||
| void SpiralLoopPlugin::AllocateMem(int Length) | |||||
| { | |||||
| // We might need to keep these values (if loading workspace) | |||||
| if (m_LoopPoint>Length) m_LoopPoint=Length; | |||||
| if (m_Pos>Length) m_Pos=0; | |||||
| if (m_LoopPoint==0) m_LoopPoint=Length; | |||||
| if (!m_StoreBuffer.Allocate(Length) || | |||||
| !m_DubBuffer.Allocate(Length)) | |||||
| { | |||||
| cerr<<"AllocateMem can't allocate any more memory!"<<endl; | |||||
| Clear(); | |||||
| } | |||||
| } | |||||
| void SpiralLoopPlugin::Clear() | |||||
| { | |||||
| m_StoreBuffer.Clear(); | |||||
| m_DubBuffer.Clear(); | |||||
| m_FixedRecord=false; | |||||
| m_FirstRecord=true; | |||||
| m_LoopPoint=0; | |||||
| } | |||||
| void SpiralLoopPlugin::RecordBuf(float Pos, int Length) | |||||
| { | |||||
| if (!m_RecordingSource) return; | |||||
| static float OldPos=Pos; | |||||
| if (m_FirstRecord) | |||||
| { | |||||
| // Find out if we want a fixed length record | |||||
| // based on the last sample length, or not | |||||
| if (m_StoreBuffer.GetLength()) | |||||
| { | |||||
| m_FixedRecord=true; | |||||
| } | |||||
| else | |||||
| { | |||||
| m_FixedRecord=false; | |||||
| m_RecBuffer.Allocate(RECBUFFERSIZE); | |||||
| m_StoreBuffer.Clear(); | |||||
| m_RecPos=0; | |||||
| } | |||||
| m_FirstRecord=false; | |||||
| m_RecLength=0; | |||||
| OldPos=Pos; | |||||
| } | |||||
| if (m_FixedRecord) | |||||
| { | |||||
| m_RecLength=m_LoopPoint; | |||||
| if (Pos>=m_StoreBuffer.GetLength()) | |||||
| { | |||||
| Pos=0; | |||||
| } | |||||
| for (int n=0; n<Length; n++) | |||||
| { | |||||
| // just add directly to the old buffer | |||||
| float temp=m_DubBuffer[static_cast<int>(Pos)]+m_RecordingSource[n]*RECORD_GAIN; | |||||
| // fill in all the samples between the speed jump with the same value | |||||
| m_DubBuffer.Set((int)Pos,temp); | |||||
| for (int i=static_cast<int>(OldPos); i<=static_cast<int>(Pos); i++) | |||||
| { | |||||
| m_DubBuffer.Set(i,temp); | |||||
| } | |||||
| OldPos=Pos; | |||||
| Pos+=m_Speed; | |||||
| if (Pos>=m_StoreBuffer.GetLength()) | |||||
| { | |||||
| Pos-=m_StoreBuffer.GetLength(); | |||||
| // remember to fill up to the end of the last buffer | |||||
| for (int i=static_cast<int>(OldPos); i<m_StoreBuffer.GetLength(); i++) | |||||
| { | |||||
| m_DubBuffer.Set(i,temp); | |||||
| } | |||||
| // and the beggining of this one | |||||
| for (int i=0; i<Pos; i++) | |||||
| { | |||||
| m_DubBuffer.Set(i,temp); | |||||
| } | |||||
| OldPos=0; | |||||
| } | |||||
| } | |||||
| } | |||||
| else | |||||
| { | |||||
| for (int n=0; n<Length; n++) | |||||
| { | |||||
| // see if we need a new buffer | |||||
| if (m_RecPos>=RECBUFFERSIZE) | |||||
| { | |||||
| // put the two buffers together | |||||
| m_StoreBuffer.Add(m_RecBuffer); | |||||
| m_RecPos=0; | |||||
| } | |||||
| m_RecBuffer.Set(m_RecPos,m_RecordingSource[n]*RECORD_GAIN); | |||||
| m_RecLength++; | |||||
| m_RecPos++; | |||||
| } | |||||
| } | |||||
| } | |||||
| void SpiralLoopPlugin::EndRecordBuf() | |||||
| { | |||||
| m_FirstRecord=true; | |||||
| m_LoopPoint=m_StoreBuffer.GetLength(); | |||||
| if (!m_FixedRecord) | |||||
| { | |||||
| // reallocate the hold buffer for the new size | |||||
| // (if the size has changed) | |||||
| m_DubBuffer.Allocate(m_LoopPoint); | |||||
| } | |||||
| } | |||||
| void SpiralLoopPlugin::Crop() | |||||
| { | |||||
| if (m_LoopPoint<m_StoreBuffer.GetLength()) | |||||
| { | |||||
| m_StoreBuffer.CropTo(m_LoopPoint); | |||||
| m_DubBuffer.CropTo(m_LoopPoint); | |||||
| } | |||||
| } | |||||
| void SpiralLoopPlugin::Double() | |||||
| { | |||||
| Crop(); | |||||
| m_StoreBuffer.Add(m_StoreBuffer); | |||||
| m_DubBuffer.Add(m_DubBuffer); | |||||
| m_LoopPoint=m_StoreBuffer.GetLength(); | |||||
| } | |||||
| void SpiralLoopPlugin::MatchLength(int Len) | |||||
| { | |||||
| // set the length, and make sure enough data is allocated | |||||
| if (m_StoreBuffer.GetLength()>Len) | |||||
| { | |||||
| SetLength(Len); | |||||
| return; | |||||
| } | |||||
| else | |||||
| { | |||||
| // if it's empty | |||||
| if (!m_StoreBuffer.GetLength()) | |||||
| { | |||||
| AllocateMem(Len); | |||||
| m_StoreBuffer.Zero(); | |||||
| } | |||||
| else | |||||
| // there is something in the buffer already, but we need to | |||||
| // add on some extra data to make the length the same | |||||
| { | |||||
| int ExtraLen=Len-m_StoreBuffer.GetLength(); | |||||
| m_StoreBuffer.Expand(ExtraLen); | |||||
| m_DubBuffer.Expand(ExtraLen); | |||||
| } | |||||
| } | |||||
| } | |||||
| void SpiralLoopPlugin::Cut(int Start, int End) | |||||
| { | |||||
| m_StoreBuffer.GetRegion(m_CopyBuffer,Start,End); | |||||
| m_StoreBuffer.Remove(Start,End); | |||||
| if (m_StoreBuffer.GetLength()<m_LoopPoint) | |||||
| { | |||||
| m_LoopPoint=m_StoreBuffer.GetLength(); | |||||
| } | |||||
| if (m_Pos>m_LoopPoint) | |||||
| { | |||||
| m_Pos=0; | |||||
| } | |||||
| m_DubBuffer.Allocate(m_StoreBuffer.GetLength()); | |||||
| } | |||||
| void SpiralLoopPlugin::Copy(int Start, int End) | |||||
| { | |||||
| m_StoreBuffer.GetRegion(m_CopyBuffer,Start,End); | |||||
| } | |||||
| void SpiralLoopPlugin::Paste(int Start) | |||||
| { | |||||
| m_StoreBuffer.Insert(m_CopyBuffer,Start); | |||||
| if (m_StoreBuffer.GetLength()<m_LoopPoint) | |||||
| { | |||||
| m_LoopPoint=m_StoreBuffer.GetLength(); | |||||
| } | |||||
| if (m_Pos>m_LoopPoint) | |||||
| { | |||||
| m_Pos=0; | |||||
| } | |||||
| m_DubBuffer.Allocate(m_StoreBuffer.GetLength()); | |||||
| } | |||||
| void SpiralLoopPlugin::PasteMix(int Start) | |||||
| { | |||||
| m_StoreBuffer.Mix(m_CopyBuffer,Start); | |||||
| } | |||||
| void SpiralLoopPlugin::ZeroRange(int Start, int End) | |||||
| { | |||||
| for (int n=Start; n<End; n++) | |||||
| { | |||||
| m_StoreBuffer.Set(n,0); | |||||
| } | |||||
| } | |||||
| void SpiralLoopPlugin::ReverseRange(int Start, int End) | |||||
| { | |||||
| m_StoreBuffer.Reverse(Start,End); | |||||
| } | |||||
| void SpiralLoopPlugin::Halve() | |||||
| { | |||||
| m_StoreBuffer.Shrink(m_StoreBuffer.GetLength()/2); | |||||
| m_DubBuffer.Shrink(m_DubBuffer.GetLength()/2); | |||||
| if (m_StoreBuffer.GetLength()<m_LoopPoint) | |||||
| { | |||||
| m_LoopPoint=m_StoreBuffer.GetLength(); | |||||
| } | |||||
| if (m_Pos>m_LoopPoint) | |||||
| { | |||||
| m_Pos=0; | |||||
| } | |||||
| } | |||||
| void SpiralLoopPlugin::SelectAll() | |||||
| { | |||||
| } | |||||
| void SpiralLoopPlugin::Move(int Start) | |||||
| { | |||||
| m_StoreBuffer.Move(Start); | |||||
| } | } | ||||
| @@ -19,13 +19,11 @@ | |||||
| #include "../SpiralPlugin.h" | #include "../SpiralPlugin.h" | ||||
| #include <FL/Fl_Pixmap.H> | #include <FL/Fl_Pixmap.H> | ||||
| #include "Loop.h" | |||||
| #include "GUI/LoopGUI.h" | |||||
| #ifndef SpiralLoopPLUGIN | #ifndef SpiralLoopPLUGIN | ||||
| #define SpiralLoopPLUGIN | #define SpiralLoopPLUGIN | ||||
| static const int NUM_SAMPLES = 8; | |||||
| static const int TRANSBUF_SIZE = 0x10000; | |||||
| static const int MAX_TRIGGERS = 8; | |||||
| struct SampleDesc | struct SampleDesc | ||||
| { | { | ||||
| @@ -50,17 +48,123 @@ 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); | ||||
| virtual bool SaveExternalFiles(const string &Dir); | virtual bool SaveExternalFiles(const string &Dir); | ||||
| virtual void LoadExternalFiles(const string &Dir); | virtual void LoadExternalFiles(const string &Dir); | ||||
| // has to be defined in the plugin | |||||
| virtual void UpdateGUI() { Fl::check(); } | |||||
| enum GUICommands{NONE,START,STOP,RECORD,OVERDUB,ENDRECORD,LOAD,SAVE,CUT, | |||||
| COPY,PASTE,PASTEMIX,ZERO_RANGE,REVERSE_RANGE,SELECT_ALL,DOUBLE,HALF, | |||||
| MOVE,CROP,KEEPDUB,UNDODUB,CHANGE_LENGTH,NEW_TRIGGER,UPDATE_TRIGGER, | |||||
| GETSAMPLE}; | |||||
| void LoadWav(const char *Filename); | |||||
| void SaveWav(const char *Filename); | |||||
| bool GetOutput(Sample &data); | |||||
| void AllocateMem(int Length); | |||||
| void Clear(); | |||||
| void MixDub() { m_StoreBuffer.Mix(m_DubBuffer,0); ClearDub(); } | |||||
| void ClearDub() { m_DubBuffer.Zero(); } | |||||
| void Double(); | |||||
| void MatchLength(int Len); | |||||
| void Crop(); | |||||
| void SetId(int Id) { m_Id=Id; } | |||||
| void SetPos(int Pos) { m_Pos=Pos; } | |||||
| void SetLength(int Len) { m_LoopPoint=Len; } | |||||
| void SetSpeed(float Speed) { m_Speed=Speed; } | |||||
| void SetVolume(float Vol) { m_Volume=Vol; } | |||||
| void SetPlaying(bool Playing) { m_Playing=Playing; } | |||||
| void SetRecordingSource(const float *s) { m_RecordingSource=s; } | |||||
| void Record(bool r) { m_Recording=r; if (!r) EndRecordBuf(); } | |||||
| void DelMe() { m_DelMe=true; } | |||||
| void SetBalance(float s) { m_Balance=s; m_LeftVol=(2-s)/2; m_RightVol=(1+s-1.0f)/2;} | |||||
| void Trigger() { m_Pos=0; SetPlaying(true); } | |||||
| const float GetBalance() {return m_Balance;} | |||||
| const bool IsPlaying() {return m_Playing;} | |||||
| const float *GetLoopPtr() {return m_StoreBuffer.GetBuffer();} | |||||
| const int GetId() {return m_Id;} | |||||
| const int GetLoopLength() {return m_LoopPoint;} | |||||
| float *GetPosPtr() {return &m_Pos;} | |||||
| const int GetTotalLength() {assert(m_StoreBuffer.GetLength()==m_DubBuffer.GetLength()); return m_StoreBuffer.GetLength();} | |||||
| const bool Delete() {return m_DelMe; } | |||||
| const float GetSpeed() {return m_Speed;} | |||||
| const float GetLeftVol() { return m_LeftVol; } | |||||
| const float GetRightVol() { return m_RightVol; } | |||||
| const float GetCurrentAngle() { return m_LoopPoint?(m_Pos/m_LoopPoint)*360.0f:0; } | |||||
| const string& GetSampleName() { return m_Sample; } | |||||
| void Cut(int Start, int End); | |||||
| void Copy(int Start, int End); | |||||
| void Paste(int Start); | |||||
| void PasteMix(int Start); | |||||
| void ZeroRange(int Start, int End); | |||||
| void ReverseRange(int Start, int End); | |||||
| void Halve(); | |||||
| void SelectAll(); | |||||
| void Move(int Start); | |||||
| private: | private: | ||||
| Loop *m_Loop; | |||||
| struct GUIArgs | |||||
| { | |||||
| long Start; | |||||
| long End; | |||||
| float Length; | |||||
| char Name[256]; | |||||
| }; | |||||
| GUIArgs m_GUIArgs; | |||||
| void RecordBuf(float Pos, int Length); | |||||
| void EndRecordBuf(); | |||||
| int m_Id; | |||||
| float m_Pos; | |||||
| int m_IntPos; | |||||
| int m_PlayBufPos; | |||||
| bool m_Playing; | |||||
| bool m_Recording; | |||||
| bool m_DelMe; | |||||
| long int m_LoopPoint; | |||||
| float m_Speed; | |||||
| float m_Volume; | |||||
| const float *m_RecordingSource; | |||||
| Sample m_StoreBuffer; | |||||
| Sample m_DubBuffer; | |||||
| Sample m_RecBuffer; | |||||
| Sample m_CopyBuffer; | |||||
| int m_RecPos; | |||||
| float m_Balance; | |||||
| float m_LeftVol,m_RightVol; | |||||
| bool m_FirstRecord; | |||||
| bool m_FixedRecord; | |||||
| int m_RecLength; | |||||
| int m_TickTime; | |||||
| int m_TickCurrent; | |||||
| int m_TicksPerLoop; | |||||
| float m_TickOutput; | |||||
| bool m_Triggered; | |||||
| char m_SampleBuffer[TRANSBUF_SIZE]; | |||||
| long m_SampleSize; | |||||
| struct TriggerInfo | |||||
| { | |||||
| int Channel; | |||||
| float Time; | |||||
| bool Triggered; | |||||
| }; | |||||
| vector<TriggerInfo> m_TriggerVec; | |||||
| string m_Sample; | |||||
| }; | }; | ||||
| #endif | #endif | ||||
| @@ -27,22 +27,495 @@ static const int GUIBG2_COLOUR = 145; | |||||
| //////////////////////////////////////////// | //////////////////////////////////////////// | ||||
| SpiralLoopPluginGUI::SpiralLoopPluginGUI(Loop *pLoop, int w, int h,SpiralLoopPlugin *o,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o) | |||||
| { | |||||
| m_Plugin=o; | |||||
| SpiralLoopPluginGUI::SpiralLoopPluginGUI(int w, int h,SpiralLoopPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o,ch) | |||||
| { | |||||
| m_LoopGUI = new Fl_Loop(0,15,w,h-15); | |||||
| m_Play = new Fl_LED_Button(255, h-35, 40, 25, "Play"); | |||||
| m_Play->color(GUIBG2_COLOUR); | |||||
| m_Play->type(1); | |||||
| m_Play->value(1); | |||||
| m_Play->down_box(FL_DOWN_BOX); | |||||
| m_Play->labelsize(10); | |||||
| m_Play->callback((Fl_Callback*)cb_Play); | |||||
| m_LoopGUI->add(m_Play); | |||||
| m_Volume = new Fl_Knob(95, 100, 45, 45, "Volume"); | |||||
| m_Volume->color(GUI_COLOUR); | |||||
| m_Volume->type(Fl_Knob::DOTLIN); | |||||
| m_Volume->labelsize(8); | |||||
| m_Volume->maximum(2); | |||||
| m_Volume->step(0.0001); | |||||
| m_Volume->value(1); | |||||
| m_Volume->callback((Fl_Callback*)cb_Volume); | |||||
| m_LoopGUI->add(m_Volume); | |||||
| m_Speed = new Fl_Knob(60, 150, 45, 45, "Speed"); | |||||
| m_Speed->color(GUI_COLOUR); | |||||
| m_Speed->type(Fl_Knob::DOTLIN); | |||||
| m_Speed->labelsize(8); | |||||
| m_Speed->maximum(2); | |||||
| m_Speed->step(0.0001); | |||||
| m_Speed->value(1); | |||||
| m_Speed->callback((Fl_Callback*)cb_Speed); | |||||
| m_LoopGUI->add(m_Speed); | |||||
| m_Length = new Fl_Knob(120, 160, 45, 45, "Length"); | |||||
| m_Length->color(GUI_COLOUR); | |||||
| m_Length->type(Fl_Knob::DOTLIN); | |||||
| m_Length->labelsize(8); | |||||
| m_Length->maximum(1); | |||||
| m_Length->step(0.0001); | |||||
| m_Length->value(1); | |||||
| m_Length->callback((Fl_Callback*)cb_Length); | |||||
| m_LoopGUI->add(m_Length); | |||||
| m_WavSize = new Fl_Knob(w-45, 15, 30, 30, "WaveSize"); | |||||
| m_WavSize->color(GUI_COLOUR); | |||||
| m_WavSize->type(Fl_Knob::DOTLIN); | |||||
| m_WavSize->labelsize(8); | |||||
| m_WavSize->maximum(3); | |||||
| m_WavSize->step(0.0001); | |||||
| m_WavSize->value(1); | |||||
| m_WavSize->callback((Fl_Callback*)cb_WavSize); | |||||
| m_LoopGUI->add(m_WavSize); | |||||
| m_Ticks = new Fl_Counter(5,h-30,30,14,"Ticks/Loop"); | |||||
| m_Ticks->labelsize(8); | |||||
| m_Ticks->textsize(8); | |||||
| m_Ticks->step(1); | |||||
| m_Ticks->type(FL_SIMPLE_COUNTER); | |||||
| m_Ticks->value(64); | |||||
| m_Ticks->callback((Fl_Callback*)cb_Ticks); | |||||
| m_LoopGUI->add(m_Ticks); | |||||
| int X=w/2-30,Y=60,WIDTH=60,HEIGHT=12; | |||||
| int ycount=0; | |||||
| float phase=0.19f; | |||||
| float scale=70.0f; | |||||
| Fl_Boxtype boxtype=FL_THIN_UP_BOX; | |||||
| m_Rec = new Fl_Button(X+(int)(sin(ycount*phase)*scale), Y+ycount*HEIGHT, WIDTH, HEIGHT, "Record"); | |||||
| m_Rec->type(1); | |||||
| m_Rec->box(boxtype); | |||||
| m_Rec->labelsize(8); | |||||
| m_Rec->labelcolor(FL_RED); | |||||
| m_Rec->callback((Fl_Callback*)cb_Rec); | |||||
| m_LoopGUI->add(m_Rec); | |||||
| ycount++; | |||||
| m_OverDub = new Fl_Button(X+(int)(sin(ycount*phase)*scale), Y+ycount*HEIGHT, WIDTH, HEIGHT, "OverDub"); | |||||
| m_OverDub->type(1); | |||||
| m_OverDub->box(boxtype); | |||||
| m_OverDub->labelsize(8); | |||||
| m_OverDub->labelcolor(FL_RED); | |||||
| m_OverDub->callback((Fl_Callback*)cb_OverDub); | |||||
| m_LoopGUI->add(m_OverDub); | |||||
| ycount++; | |||||
| m_Hold = new Fl_Button(X+(int)(sin(ycount*phase)*scale), Y+ycount*HEIGHT, WIDTH, HEIGHT, "Keep Dub"); | |||||
| m_Hold->box(boxtype); | |||||
| m_Hold->labelsize(8); | |||||
| m_Hold->callback((Fl_Callback*)cb_Hold); | |||||
| m_LoopGUI->add(m_Hold); | |||||
| ycount++; | |||||
| m_Undo = new Fl_Button(X+(int)(sin(ycount*phase)*scale), Y+ycount*HEIGHT, WIDTH, HEIGHT, "Undo Dub"); | |||||
| m_Undo->box(boxtype); | |||||
| m_Undo->labelsize(8); | |||||
| m_Undo->callback((Fl_Callback*)cb_Undo); | |||||
| m_LoopGUI->add(m_Undo); | |||||
| ycount++; | |||||
| m_Load = new Fl_Button(X+(int)(sin(ycount*phase)*scale), Y+ycount*HEIGHT, WIDTH, HEIGHT, "Load"); | |||||
| m_Load->box(boxtype); | |||||
| m_Load->labelsize(8); | |||||
| m_Load->callback((Fl_Callback*)cb_Load); | |||||
| m_LoopGUI->add(m_Load); | |||||
| ycount++; | |||||
| m_Save = new Fl_Button(X+(int)(sin(ycount*phase)*scale), Y+ycount*HEIGHT, WIDTH, HEIGHT, "Save"); | |||||
| m_Save->box(boxtype); | |||||
| m_Save->labelsize(8); | |||||
| m_Save->callback((Fl_Callback*)cb_Save); | |||||
| m_LoopGUI->add(m_Save); | |||||
| ycount++; | |||||
| m_Trig = new Fl_Button(X+(int)(sin(ycount*phase)*scale), Y+ycount*HEIGHT, WIDTH, HEIGHT, "New trigger"); | |||||
| m_Trig->box(boxtype); | |||||
| m_Trig->labelsize(8); | |||||
| m_Trig->callback((Fl_Callback*)cb_Trig); | |||||
| m_LoopGUI->add(m_Trig); | |||||
| ycount++; | |||||
| m_Cut = new Fl_Button(X+(int)(sin(ycount*phase)*scale), Y+ycount*HEIGHT, WIDTH, HEIGHT, "Cut"); | |||||
| m_Cut->box(boxtype); | |||||
| m_Cut->labelsize(8); | |||||
| m_Cut->callback((Fl_Callback*)cb_Cut); | |||||
| m_LoopGUI->add(m_Trig); | |||||
| ycount++; | |||||
| m_Copy = new Fl_Button(X+(int)(sin(ycount*phase)*scale), Y+ycount*HEIGHT, WIDTH, HEIGHT, "Copy"); | |||||
| m_Copy->box(boxtype); | |||||
| m_Copy->labelsize(8); | |||||
| m_Copy->callback((Fl_Callback*)cb_Copy); | |||||
| m_LoopGUI->add(m_Trig); | |||||
| ycount++; | |||||
| m_Paste = new Fl_Button(X+(int)(sin(ycount*phase)*scale), Y+ycount*HEIGHT, WIDTH, HEIGHT, "Paste"); | |||||
| m_Paste->box(boxtype); | |||||
| m_Paste->labelsize(8); | |||||
| m_Paste->callback((Fl_Callback*)cb_Paste); | |||||
| m_LoopGUI->add(m_Paste); | |||||
| ycount++; | |||||
| m_PasteMix = new Fl_Button(X+(int)(sin(ycount*phase)*scale), Y+ycount*HEIGHT, WIDTH, HEIGHT, "PasteMix"); | |||||
| m_PasteMix->box(boxtype); | |||||
| m_PasteMix->labelsize(8); | |||||
| m_PasteMix->callback((Fl_Callback*)cb_PasteMix); | |||||
| m_LoopGUI->add(m_PasteMix); | |||||
| ycount++; | |||||
| m_ZeroR = new Fl_Button(X+(int)(sin(ycount*phase)*scale), Y+ycount*HEIGHT, WIDTH, HEIGHT, "Zero Range"); | |||||
| m_ZeroR->box(boxtype); | |||||
| m_ZeroR->labelsize(8); | |||||
| m_ZeroR->callback((Fl_Callback*)cb_ZeroR); | |||||
| m_LoopGUI->add(m_ZeroR); | |||||
| ycount++; | |||||
| m_ReverseR = new Fl_Button(X+(int)(sin(ycount*phase)*scale), Y+ycount*HEIGHT, WIDTH, HEIGHT, "Rev Range"); | |||||
| m_ReverseR->box(boxtype); | |||||
| m_ReverseR->labelsize(8); | |||||
| m_ReverseR->callback((Fl_Callback*)cb_ReverseR); | |||||
| m_LoopGUI->add(m_ReverseR); | |||||
| ycount++; | |||||
| m_SelectAll = new Fl_Button(X+(int)(sin(ycount*phase)*scale), Y+ycount*HEIGHT, WIDTH, HEIGHT, "Select all"); | |||||
| m_SelectAll->box(boxtype); | |||||
| m_SelectAll->labelsize(8); | |||||
| m_SelectAll->callback((Fl_Callback*)cb_SelectAll); | |||||
| m_LoopGUI->add(m_SelectAll); | |||||
| ycount++; | |||||
| m_Double = new Fl_Button(X+(int)(sin(ycount*phase)*scale), Y+ycount*HEIGHT, WIDTH, HEIGHT, "Double"); | |||||
| m_Double->box(boxtype); | |||||
| m_Double->labelsize(8); | |||||
| m_Double->callback((Fl_Callback*)cb_Double); | |||||
| m_LoopGUI->add(m_Double); | |||||
| ycount++; | |||||
| m_Half = new Fl_Button(X+(int)(sin(ycount*phase)*scale), Y+ycount*HEIGHT, WIDTH, HEIGHT, "Half"); | |||||
| m_Half->box(boxtype); | |||||
| m_Half->labelsize(8); | |||||
| m_Half->callback((Fl_Callback*)cb_Half); | |||||
| m_LoopGUI->add(m_Half); | |||||
| ycount++; | |||||
| m_Crop = new Fl_Button(X+(int)(sin(ycount*phase)*scale), Y+ycount*HEIGHT, WIDTH, HEIGHT, "Crop"); | |||||
| m_Crop->box(boxtype); | |||||
| m_Crop->labelsize(8); | |||||
| m_Crop->callback((Fl_Callback*)cb_Crop); | |||||
| m_LoopGUI->add(m_Crop); | |||||
| ycount++; | |||||
| } | |||||
| void SpiralLoopPluginGUI::UpdateValues(SpiralPlugin *o) | |||||
| { | |||||
| } | |||||
| void SpiralLoopPluginGUI::Update() | |||||
| { | |||||
| m_LoopGUI->SetPos(m_GUICH->GetFloat("Pos")); | |||||
| m_LoopGUI->DrawPosMarker(); | |||||
| } | |||||
| void SpiralLoopPluginGUI::UpdateSampleDisplay() | |||||
| { | |||||
| m_GUICH->Wait(); | |||||
| m_GUICH->SetCommand(SpiralLoopPlugin::GETSAMPLE); | |||||
| m_GUICH->Wait(); | |||||
| m_GUICH->RequestChannelAndWait("SampleSize"); | |||||
| m_SampleSize=m_GUICH->GetLong("SampleSize"); | |||||
| if (m_SampleSize) | |||||
| { | |||||
| char *TempBuf = new char[m_SampleSize*sizeof(float)]; | |||||
| m_GUICH->BulkTransfer("SampleBuffer",(void*)TempBuf,m_SampleSize*sizeof(float)); | |||||
| m_LoopGUI->SetData((float*)TempBuf,m_SampleSize); | |||||
| delete[] TempBuf; | |||||
| } | |||||
| redraw(); | |||||
| } | |||||
| inline void SpiralLoopPluginGUI::cb_Play_i(Fl_LED_Button* o, void* v) | |||||
| { | |||||
| if (o->value()) m_GUICH->SetCommand(SpiralLoopPlugin::START); | |||||
| else m_GUICH->SetCommand(SpiralLoopPlugin::STOP); | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_Play(Fl_LED_Button* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_Play_i(o,v); } | |||||
| inline void SpiralLoopPluginGUI::cb_Volume_i(Fl_Knob* o, void* v) | |||||
| { | |||||
| m_GUICH->Set("Volume",(float)o->value()); | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_Volume(Fl_Knob* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_Volume_i(o,v); } | |||||
| inline void SpiralLoopPluginGUI::cb_Speed_i(Fl_Knob* o, void* v) | |||||
| { | |||||
| m_GUICH->Set("Speed",(float)o->value()); | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_Speed(Fl_Knob* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_Speed_i(o,v); } | |||||
| inline void SpiralLoopPluginGUI::cb_Length_i(Fl_Knob* o, void* v) | |||||
| { | |||||
| m_GUICH->SetCommand(SpiralLoopPlugin::CHANGE_LENGTH); | |||||
| m_GUICH->Set("Length",(float)o->value()); | |||||
| m_LoopGUI->SetLength((int)(m_SampleSize*o->value())); | |||||
| m_LoopGUI->redraw(); | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_Length(Fl_Knob* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_Length_i(o,v); } | |||||
| inline void SpiralLoopPluginGUI::cb_WavSize_i(Fl_Knob* o, void* v) | |||||
| { | |||||
| m_LoopGUI->SetWaveSize(o->value()); | |||||
| redraw(); | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_WavSize(Fl_Knob* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_WavSize_i(o,v); } | |||||
| inline void SpiralLoopPluginGUI::cb_Rec_i(Fl_Button* o, void* v) | |||||
| { | |||||
| if (o->value()) m_GUICH->SetCommand(SpiralLoopPlugin::RECORD); | |||||
| else m_GUICH->SetCommand(SpiralLoopPlugin::ENDRECORD); | |||||
| UpdateSampleDisplay(); | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_Rec(Fl_Button* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_Rec_i(o,v); } | |||||
| inline void SpiralLoopPluginGUI::cb_OverDub_i(Fl_Button* o, void* v) | |||||
| { | |||||
| if (o->value()) m_GUICH->SetCommand(SpiralLoopPlugin::OVERDUB); | |||||
| else m_GUICH->SetCommand(SpiralLoopPlugin::ENDRECORD); | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_OverDub(Fl_Button* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_OverDub_i(o,v); } | |||||
| inline void SpiralLoopPluginGUI::cb_Load_i(Fl_Button* o, void* v) | |||||
| { | |||||
| char *fn=fl_file_chooser("Load a sample", "{*.wav,*.WAV}", NULL); | |||||
| if (fn && fn!='\0') | |||||
| { | |||||
| strcpy(m_TextBuf,fn); | |||||
| m_GUICH->SetData("Name",m_TextBuf); | |||||
| m_GUICH->SetCommand(SpiralLoopPlugin::LOAD); | |||||
| int Width=20; | |||||
| int Height=100; | |||||
| m_GUICH->Wait(); // wait for the sample to load | |||||
| UpdateSampleDisplay(); | |||||
| } | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_Load(Fl_Button* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_Load_i(o,v); } | |||||
| m_LoopGUI = new LoopGUI(pLoop); | |||||
| pLoop->SetGUI(m_LoopGUI); | |||||
| m_LoopGUI->CreateGUI(""); | |||||
| add(m_LoopGUI->GetGUI()); | |||||
| inline void SpiralLoopPluginGUI::cb_Save_i(Fl_Button* o, void* v) | |||||
| { | |||||
| char *fn=fl_file_chooser("Load a sample", "{*.wav,*.WAV}", NULL); | |||||
| end(); | |||||
| if (fn && fn!='\0') | |||||
| { | |||||
| strcpy(m_TextBuf,fn); | |||||
| m_GUICH->SetData("Name",m_TextBuf); | |||||
| m_GUICH->SetCommand(SpiralLoopPlugin::SAVE); | |||||
| } | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_Save(Fl_Button* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_Save_i(o,v); } | |||||
| inline void SpiralLoopPluginGUI::cb_Trig_i(Fl_Button* o, void* v) | |||||
| { | |||||
| Fl_Trigger *NewTrigger = new Fl_Trigger(parent()->x(), parent()->y(), 20, 20); | |||||
| NewTrigger->SetCentreX(150); | |||||
| NewTrigger->SetCentreY(150); | |||||
| NewTrigger->SetCentreRadius(125); | |||||
| NewTrigger->SetID(m_TriggerVec.size()); | |||||
| if (m_TriggerVec.size()<8) NewTrigger->SetChannel(m_TriggerVec.size()); | |||||
| else NewTrigger->SetChannel(7); | |||||
| NewTrigger->callback((Fl_Callback*)cb_Trigger); | |||||
| m_LoopGUI->add(NewTrigger); | |||||
| m_TriggerVec.push_back(NewTrigger); | |||||
| NewTrigger->redraw(); | |||||
| m_GUICH->Set("Start",NewTrigger->GetID()); | |||||
| m_GUICH->Set("End",NewTrigger->GetChannel()); | |||||
| m_GUICH->Set("Length",0); | |||||
| m_GUICH->SetCommand(SpiralLoopPlugin::NEW_TRIGGER); | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_Trig(Fl_Button* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_Trig_i(o,v); } | |||||
| inline void SpiralLoopPluginGUI::cb_Cut_i(Fl_Button* o, void* v) | |||||
| { | |||||
| m_GUICH->Set("Start",m_LoopGUI->GetRangeStart()); | |||||
| m_GUICH->Set("End",m_LoopGUI->GetRangeEnd()); | |||||
| m_GUICH->SetCommand(SpiralLoopPlugin::CUT); | |||||
| UpdateSampleDisplay(); | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_Cut(Fl_Button* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_Cut_i(o,v); } | |||||
| inline void SpiralLoopPluginGUI::cb_Copy_i(Fl_Button* o, void* v) | |||||
| { | |||||
| m_GUICH->Set("Start",m_LoopGUI->GetRangeStart()); | |||||
| m_GUICH->Set("End",m_LoopGUI->GetRangeEnd()); | |||||
| m_GUICH->SetCommand(SpiralLoopPlugin::COPY); | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_Copy(Fl_Button* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_Copy_i(o,v); } | |||||
| inline void SpiralLoopPluginGUI::cb_Paste_i(Fl_Button* o, void* v) | |||||
| { | |||||
| m_GUICH->Set("Start",m_LoopGUI->GetRangeStart()); | |||||
| m_GUICH->SetCommand(SpiralLoopPlugin::PASTE); | |||||
| UpdateSampleDisplay(); | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_Paste(Fl_Button* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_Paste_i(o,v); } | |||||
| inline void SpiralLoopPluginGUI::cb_PasteMix_i(Fl_Button* o, void* v) | |||||
| { | |||||
| m_GUICH->Set("Start",m_LoopGUI->GetRangeStart()); | |||||
| m_GUICH->SetCommand(SpiralLoopPlugin::PASTEMIX); | |||||
| UpdateSampleDisplay(); | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_PasteMix(Fl_Button* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_PasteMix_i(o,v); } | |||||
| inline void SpiralLoopPluginGUI::cb_ZeroR_i(Fl_Button* o, void* v) | |||||
| { | |||||
| m_GUICH->Set("Start",m_LoopGUI->GetRangeStart()); | |||||
| m_GUICH->Set("End",m_LoopGUI->GetRangeEnd()); | |||||
| m_GUICH->SetCommand(SpiralLoopPlugin::ZERO_RANGE); | |||||
| UpdateSampleDisplay(); | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_ZeroR(Fl_Button* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_ZeroR_i(o,v); } | |||||
| inline void SpiralLoopPluginGUI::cb_ReverseR_i(Fl_Button* o, void* v) | |||||
| { | |||||
| m_GUICH->Set("Start",m_LoopGUI->GetRangeStart()); | |||||
| m_GUICH->Set("End",m_LoopGUI->GetRangeEnd()); | |||||
| m_GUICH->SetCommand(SpiralLoopPlugin::REVERSE_RANGE); | |||||
| UpdateSampleDisplay(); | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_ReverseR(Fl_Button* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_ReverseR_i(o,v); } | |||||
| inline void SpiralLoopPluginGUI::cb_SelectAll_i(Fl_Button* o, void* v) | |||||
| { | |||||
| m_LoopGUI->SelectAll(); | |||||
| //m_GUICH->SetCommand(SpiralLoopPlugin::SELECT_ALL); | |||||
| } | } | ||||
| void SpiralLoopPluginGUI::cb_SelectAll(Fl_Button* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_SelectAll_i(o,v); } | |||||
| void SpiralLoopPluginGUI::UpdateValues() | |||||
| inline void SpiralLoopPluginGUI::cb_Double_i(Fl_Button* o, void* v) | |||||
| { | { | ||||
| m_GUICH->SetCommand(SpiralLoopPlugin::DOUBLE); | |||||
| UpdateSampleDisplay(); | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_Double(Fl_Button* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_Double_i(o,v); } | |||||
| inline void SpiralLoopPluginGUI::cb_Half_i(Fl_Button* o, void* v) | |||||
| { | |||||
| m_GUICH->SetCommand(SpiralLoopPlugin::HALF); | |||||
| UpdateSampleDisplay(); | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_Half(Fl_Button* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_Half_i(o,v); } | |||||
| inline void SpiralLoopPluginGUI::cb_Crop_i(Fl_Button* o, void* v) | |||||
| { | |||||
| m_GUICH->SetCommand(SpiralLoopPlugin::CROP); | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_Crop(Fl_Button* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_Crop_i(o,v); } | |||||
| inline void SpiralLoopPluginGUI::cb_Hold_i(Fl_Button* o, void* v) | |||||
| { | |||||
| m_GUICH->SetCommand(SpiralLoopPlugin::KEEPDUB); | |||||
| UpdateSampleDisplay(); | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_Hold(Fl_Button* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_Hold_i(o,v); } | |||||
| inline void SpiralLoopPluginGUI::cb_Undo_i(Fl_Button* o, void* v) | |||||
| { | |||||
| m_GUICH->SetCommand(SpiralLoopPlugin::UNDODUB); | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_Undo(Fl_Button* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_Undo_i(o,v); } | |||||
| inline void SpiralLoopPluginGUI::cb_Trigger_i(Fl_Trigger* o, void* v) | |||||
| { | |||||
| m_GUICH->Set("Start",o->GetID()); | |||||
| m_GUICH->Set("End",o->GetChannel()); | |||||
| m_GUICH->Set("Length",o->GetAngle()/360.0f); | |||||
| m_GUICH->SetCommand(SpiralLoopPlugin::UPDATE_TRIGGER); | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_Trigger(Fl_Trigger* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_Trigger_i(o,v); } | |||||
| inline void SpiralLoopPluginGUI::cb_Ticks_i(Fl_Counter* o, void* v) | |||||
| { | |||||
| if (o->value()<1) o->value(1); | |||||
| m_GUICH->Set("TicksPerLoop",(int)o->value()); | |||||
| } | |||||
| void SpiralLoopPluginGUI::cb_Ticks(Fl_Counter* o, void* v) | |||||
| { ((SpiralLoopPluginGUI*)(o->parent()->parent()))->cb_Ticks_i(o,v); } | |||||
| const string SpiralLoopPluginGUI::GetHelpText(const string &loc){ | |||||
| return string("") | |||||
| + "The SpiralLoop is designed for live jamming and the creation of freeform\n" | |||||
| + " loops that you can sync to other loops, or other sequences within ssm.\n" | |||||
| + "This plugin is based on the old SpiralLoop design with a few improvements.\n" | |||||
| + "The main differece is the 'dub buffer' - a recording area that enables you to\n" | |||||
| + "audition recording before deciding whether to write them to the main loop\n" | |||||
| + "to undo them.\n" | |||||
| + "\n" | |||||
| + "Features:\n" | |||||
| + "Record : Records a new loop, and deletes the old one\n" | |||||
| + "OverDub : Records input into a the dub buffer\n" | |||||
| + "KeepDub : Writes the dub buffer into the main loop\n" | |||||
| + "UndoDub : Clears the dub buffer (erasing previous recordings)\n" | |||||
| + "Load : Loads a wav into the loop\n" | |||||
| + "Save : Saves the loop as a wav file\n" | |||||
| + "New Trigger : Create a new trigger (see below)\n" | |||||
| + "Cut : Cut highlighted section of the loop\n" | |||||
| + "Copy : Store highlighted section of the loop\n" | |||||
| + "Paste : Insert copied/cut loop section\n" | |||||
| + "PasteMix : Mix in copied/cut loop section\n" | |||||
| + "Zero Range : Silence highlighted section\n" | |||||
| + "RevRange : Reverse highlighted section\n" | |||||
| + "Select all : Select the whole loop\n" | |||||
| + "Double : Copy the loop to the end (doubling the size)\n" | |||||
| + "Half : Chop the last half of the loop (halving the size)\n" | |||||
| + "Crop : Lose the sampledata after the loop point (set with the length control)\n" | |||||
| + "\n" | |||||
| + "Ticks/Loop : Sets the number of logic ticks per loop output via the clock port\n" | |||||
| + " use this to sync matrix sequencers and the like.\n" | |||||
| + "\n" | |||||
| + "LoopTriggers\n" | |||||
| + "\n" | |||||
| + "Loop triggers are sync points that you can drag around the loop. When the play\n" | |||||
| + "position crosses one, the corresponding output CV will go high. Multiple triggers\n" | |||||
| + "can effect the same CV, use the right mouse button to cycle through the outputs"; | |||||
| } | } | ||||
| @@ -19,11 +19,14 @@ | |||||
| #include <FL/Fl.H> | #include <FL/Fl.H> | ||||
| #include <FL/Fl_Window.H> | #include <FL/Fl_Window.H> | ||||
| #include <FL/Fl_Group.H> | #include <FL/Fl_Group.H> | ||||
| #include <FL/Fl_Counter.H> | |||||
| #include "Fl_Loop.h" | |||||
| #include "Fl_Trigger.h" | |||||
| #include "SpiralLoopPlugin.h" | #include "SpiralLoopPlugin.h" | ||||
| #include "../SpiralPluginGUI.h" | #include "../SpiralPluginGUI.h" | ||||
| #include "../Widgets/Fl_Knob.H" | #include "../Widgets/Fl_Knob.H" | ||||
| #include "GUI/LoopGUI.h" | |||||
| #include "../Widgets/Fl_LED_Button.H" | |||||
| #ifndef MixerGUI | #ifndef MixerGUI | ||||
| #define MixerGUI | #define MixerGUI | ||||
| @@ -32,17 +35,97 @@ | |||||
| class SpiralLoopPluginGUI : public SpiralPluginGUI | class SpiralLoopPluginGUI : public SpiralPluginGUI | ||||
| { | { | ||||
| public: | public: | ||||
| SpiralLoopPluginGUI(Loop *pLoop, int w, int h, SpiralLoopPlugin *o,const HostInfo *Info); | |||||
| SpiralLoopPluginGUI(int w, int h, SpiralLoopPlugin *o,ChannelHandler *ch,const HostInfo *Info); | |||||
| virtual void UpdateValues(SpiralPlugin *o); | |||||
| virtual void Update(); | |||||
| virtual const string GetHelpText(const string &loc); | |||||
| virtual void UpdateValues(); | |||||
| virtual SpiralPlugin* GetPlugin() { return m_Plugin; } | |||||
| private: | |||||
| void UpdateSampleDisplay(); | |||||
| LoopGUI* GetGUI() { return m_LoopGUI; } | |||||
| Fl_LED_Button *m_Play; | |||||
| SpiralLoopPlugin *m_Plugin; | |||||
| private: | |||||
| Fl_Knob *m_Volume; | |||||
| Fl_Knob *m_Speed; | |||||
| Fl_Knob *m_Length; | |||||
| Fl_Knob *m_WavSize; | |||||
| Fl_Counter *m_Ticks; | |||||
| LoopGUI* m_LoopGUI; | |||||
| }; | |||||
| Fl_Button *m_Rec; | |||||
| Fl_Button *m_OverDub; | |||||
| Fl_Button *m_Load; | |||||
| Fl_Button *m_Save; | |||||
| Fl_Button *m_Trig; | |||||
| Fl_Button *m_Cut; | |||||
| Fl_Button *m_Copy; | |||||
| Fl_Button *m_Paste; | |||||
| Fl_Button *m_PasteMix; | |||||
| Fl_Button *m_ZeroR; | |||||
| Fl_Button *m_ReverseR; | |||||
| Fl_Button *m_SelectAll; | |||||
| Fl_Button *m_Double; | |||||
| Fl_Button *m_Half; | |||||
| Fl_Button *m_Crop; | |||||
| Fl_Button *m_Hold; | |||||
| Fl_Button *m_Undo; | |||||
| vector<Fl_Trigger*> m_TriggerVec; | |||||
| Fl_Loop* m_LoopGUI; | |||||
| char m_TextBuf[256]; | |||||
| long m_SampleSize; | |||||
| inline void cb_Play_i(Fl_LED_Button* o, void* v); | |||||
| static void cb_Play(Fl_LED_Button* o, void* v); | |||||
| inline void cb_Volume_i(Fl_Knob* o, void* v); | |||||
| static void cb_Volume(Fl_Knob* o, void* v); | |||||
| inline void cb_Speed_i(Fl_Knob* o, void* v); | |||||
| static void cb_Speed(Fl_Knob* o, void* v); | |||||
| inline void cb_Length_i(Fl_Knob* o, void* v); | |||||
| static void cb_Length(Fl_Knob* o, void* v); | |||||
| inline void cb_WavSize_i(Fl_Knob* o, void* v); | |||||
| static void cb_WavSize(Fl_Knob* o, void* v); | |||||
| inline void cb_Rec_i(Fl_Button* o, void* v); | |||||
| static void cb_Rec(Fl_Button* o, void* v); | |||||
| inline void cb_OverDub_i(Fl_Button* o, void* v); | |||||
| static void cb_OverDub(Fl_Button* o, void* v); | |||||
| inline void cb_Load_i(Fl_Button* o, void* v); | |||||
| static void cb_Load(Fl_Button* o, void* v); | |||||
| inline void cb_Save_i(Fl_Button* o, void* v); | |||||
| static void cb_Save(Fl_Button* o, void* v); | |||||
| inline void cb_Trig_i(Fl_Button* o, void* v); | |||||
| static void cb_Trig(Fl_Button* o, void* v); | |||||
| inline void cb_Cut_i(Fl_Button* o, void* v); | |||||
| static void cb_Cut(Fl_Button* o, void* v); | |||||
| inline void cb_Copy_i(Fl_Button* o, void* v); | |||||
| static void cb_Copy(Fl_Button* o, void* v); | |||||
| inline void cb_Paste_i(Fl_Button* o, void* v); | |||||
| static void cb_Paste(Fl_Button* o, void* v); | |||||
| inline void cb_PasteMix_i(Fl_Button* o, void* v); | |||||
| static void cb_PasteMix(Fl_Button* o, void* v); | |||||
| inline void cb_ZeroR_i(Fl_Button* o, void* v); | |||||
| static void cb_ZeroR(Fl_Button* o, void* v); | |||||
| inline void cb_ReverseR_i(Fl_Button* o, void* v); | |||||
| static void cb_ReverseR(Fl_Button* o, void* v); | |||||
| inline void cb_SelectAll_i(Fl_Button* o, void* v); | |||||
| static void cb_SelectAll(Fl_Button* o, void* v); | |||||
| inline void cb_Double_i(Fl_Button* o, void* v); | |||||
| static void cb_Double(Fl_Button* o, void* v); | |||||
| inline void cb_Half_i(Fl_Button* o, void* v); | |||||
| static void cb_Half(Fl_Button* o, void* v); | |||||
| inline void cb_Crop_i(Fl_Button* o, void* v); | |||||
| static void cb_Crop(Fl_Button* o, void* v); | |||||
| inline void cb_Hold_i(Fl_Button* o, void* v); | |||||
| static void cb_Hold(Fl_Button* o, void* v); | |||||
| inline void cb_Undo_i(Fl_Button* o, void* v); | |||||
| static void cb_Undo(Fl_Button* o, void* v); | |||||
| inline void cb_Trigger_i(Fl_Trigger* o, void* v); | |||||
| static void cb_Trigger(Fl_Trigger* o, void* v); | |||||
| inline void cb_Ticks_i(Fl_Counter* o, void* v); | |||||
| static void cb_Ticks(Fl_Counter* o, void* v); | |||||
| }; | |||||
| #endif | #endif | ||||
| @@ -0,0 +1,155 @@ | |||||
| ############################################################################# | |||||
| # Makefile for building TrigPlugin.so | |||||
| # Generated by tmake at 21:08, 2001/11/12 | |||||
| # Project: TrigPlugin | |||||
| # Template: app | |||||
| ############################################################################# | |||||
| ####### 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 \ | |||||
| TrigPlugin.h \ | |||||
| TrigPluginGUI.h | |||||
| SOURCES = ../SpiralPlugin.C \ | |||||
| ../SpiralPluginGUI.C \ | |||||
| ../../ChannelHandler.C \ | |||||
| ../Widgets/Fl_Knob.cxx \ | |||||
| ../Widgets/Fl_DragBar.cxx \ | |||||
| ../../Sample.C \ | |||||
| TrigPlugin.C \ | |||||
| TrigPluginGUI.C | |||||
| OBJECTS = ../SpiralPlugin.o \ | |||||
| ../SpiralPluginGUI.o \ | |||||
| ../../ChannelHandler.o \ | |||||
| ../Widgets/Fl_Knob.o \ | |||||
| ../Widgets/Fl_DragBar.o \ | |||||
| ../../Sample.o \ | |||||
| TrigPlugin.o \ | |||||
| TrigPluginGUI.o | |||||
| INTERFACES = | |||||
| UICDECLS = | |||||
| UICIMPLS = | |||||
| SRCMOC = | |||||
| OBJMOC = | |||||
| DIST = | |||||
| TARGET = TrigPlugin.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) | |||||
| 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 | |||||
| TrigPlugin.o: TrigPlugin.C \ | |||||
| TrigPlugin.h \ | |||||
| TrigPluginGUI.h \ | |||||
| ../../NoteTable.h \ | |||||
| ../SpiralPlugin.h \ | |||||
| ../SpiralPluginGUI.h \ | |||||
| SpiralIcon.xpm | |||||
| TrigPluginGUI.o: TrigPluginGUI.C \ | |||||
| TrigPlugin.h \ | |||||
| TrigPluginGUI.h \ | |||||
| ../SpiralPlugin.h \ | |||||
| ../SpiralPluginGUI.h | |||||
| ../../ChannelHandler.o: ../../ChannelHandler.C \ | |||||
| ../../ChannelHandler.h | |||||
| @@ -0,0 +1,163 @@ | |||||
| /* XPM */ | |||||
| static char * SpiralIcon_xpm[] = { | |||||
| "36 36 124 2", | |||||
| " c None", | |||||
| ". c #E98A06", | |||||
| "+ c #E88700", | |||||
| "@ c #814E07", | |||||
| "# c #8A550B", | |||||
| "$ c #E88905", | |||||
| "% c #7A4803", | |||||
| "& c #070603", | |||||
| "* c #1C1103", | |||||
| "= c #090704", | |||||
| "- c #B96C02", | |||||
| "; c #6C4105", | |||||
| "> c #E88803", | |||||
| ", c #D07A03", | |||||
| "' c #000000", | |||||
| ") c #E88701", | |||||
| "! c #E78702", | |||||
| "~ c #4F330B", | |||||
| "{ c #E68602", | |||||
| "] c #442A07", | |||||
| "^ c #E38501", | |||||
| "/ c #935703", | |||||
| "( c #E88802", | |||||
| "_ c #CA7602", | |||||
| ": c #0A0601", | |||||
| "< c #150F07", | |||||
| "[ c #D07A02", | |||||
| "} c #D27B02", | |||||
| "| c #462A03", | |||||
| "1 c #020101", | |||||
| "2 c #E78700", | |||||
| "3 c #653C04", | |||||
| "4 c #0D0A05", | |||||
| "5 c #E88904", | |||||
| "6 c #8F5607", | |||||
| "7 c #E78905", | |||||
| "8 c #CA7805", | |||||
| "9 c #E98B09", | |||||
| "0 c #C97602", | |||||
| "a c #0C0802", | |||||
| "b c #E88801", | |||||
| "c c #B56A03", | |||||
| "d c #140C02", | |||||
| "e c #040301", | |||||
| "f c #834D03", | |||||
| "g c #060402", | |||||
| "h c #E88A05", | |||||
| "i c #D37B00", | |||||
| "j c #191003", | |||||
| "k c #E58807", | |||||
| "l c #E98A07", | |||||
| "m c #DF8201", | |||||
| "n c #C37304", | |||||
| "o c #090603", | |||||
| "p c #E58501", | |||||
| "q c #E28400", | |||||
| "r c #CF7A04", | |||||
| "s c #B76C03", | |||||
| "t c #915500", | |||||
| "u c #040303", | |||||
| "v c #9F5C00", | |||||
| "w c #C77400", | |||||
| "x c #633B03", | |||||
| "y c #693F04", | |||||
| "z c #C37200", | |||||
| "A c #CC7804", | |||||
| "B c #0C0905", | |||||
| "C c #C17101", | |||||
| "D c #AF6701", | |||||
| "E c #DA7F02", | |||||
| "F c #945703", | |||||
| "G c #271700", | |||||
| "H c #160E02", | |||||
| "I c #4F3209", | |||||
| "J c #040302", | |||||
| "K c #CD7800", | |||||
| "L c #080500", | |||||
| "M c #9B5C03", | |||||
| "N c #C07205", | |||||
| "O c #E08302", | |||||
| "P c #613A03", | |||||
| "Q c #915603", | |||||
| "R c #E78600", | |||||
| "S c #915502", | |||||
| "T c #E18301", | |||||
| "U c #331F03", | |||||
| "V c #030201", | |||||
| "W c #0F0B05", | |||||
| "X c #E48501", | |||||
| "Y c #603800", | |||||
| "Z c #492C04", | |||||
| "` c #8A5307", | |||||
| " . c #161008", | |||||
| ".. c #DF8200", | |||||
| "+. c #1C1102", | |||||
| "@. c #090500", | |||||
| "#. c #E58500", | |||||
| "$. c #D77D00", | |||||
| "%. c #A05E03", | |||||
| "&. c #100B05", | |||||
| "*. c #E58601", | |||||
| "=. c #2F1D02", | |||||
| "-. c #5B3500", | |||||
| ";. c #CB7600", | |||||
| ">. c #D47B01", | |||||
| ",. c #502E00", | |||||
| "'. c #764604", | |||||
| "). c #603904", | |||||
| "!. c #905606", | |||||
| "~. c #CE7801", | |||||
| "{. c #5E3700", | |||||
| "]. c #512F00", | |||||
| "^. c #A86302", | |||||
| "/. c #E28401", | |||||
| "(. c #0E0902", | |||||
| "_. c #070502", | |||||
| ":. c #965803", | |||||
| "<. c #E68601", | |||||
| "[. c #452A04", | |||||
| "}. c #804D07", | |||||
| "|. c #4A2D03", | |||||
| "1. c #1A1207", | |||||
| "2. c #050402", | |||||
| "3. c #120D07", | |||||
| " ", | |||||
| " ", | |||||
| " ", | |||||
| " . + + @ + + # ", | |||||
| " $ + + % & + + * = ", | |||||
| " . + + - ; > + , ' ) ! ~ ", | |||||
| " + { ] $ + + + + + + + ^ / ( + _ : < ", | |||||
| " . + + [ } + + + + + + + + + + + + + | 1 ", | |||||
| " > + + + + + + + + + + + + + + + 2 3 4 ", | |||||
| " 5 + + + + + + + + + + + + + + + + + 6 7 + 8 ", | |||||
| " 9 $ + + + + + + + + + + + + + + + + + + + + + 0 a ", | |||||
| " ) + b + + + + + + + + + + + + + + + + + + + + + c d e ", | |||||
| " + + + + + + + ' + + + + + + + ' + + + + + + + + f g ", | |||||
| " h + + + + + ' + ' + + + + + ' + ' + + + + + + + i j k l ", | |||||
| " + + + + ' + ' + + + + + ' + ' + + + + + + + + m + n o ", | |||||
| " p + + + ' + + + ' + + + ' + + + ' + + + + + + + q r s ' ", | |||||
| " ( + + + ' + + + ' + + + ' + + + ' + + + + + + + t ' = u ", | |||||
| " + + + + + + ' + + + ' + + + ' + + + ' + + + + + + + v ' ", | |||||
| " + + + + + + + + + + ' + + + ' + + + ' + + + ' + + + w x ", | |||||
| " $ y z + + + + + + + ' + + + ' + + + ' + + + ' + + + + + A B ", | |||||
| " C + + + + + + + ' + + + ' + + + ' + + + ' + + + D E F ' ", | |||||
| " + + + + + + + + ' + ' + + + + + ' + ' + + + + G H I J ", | |||||
| " + + + + + + + + ' + ' + + + + + ' + ' + + + K ' L ", | |||||
| " 5 + + + + + + + + + + ' + + + + + + + ' + + + + + M ", | |||||
| " > + + + + + + + + + + + + + + + + + + + + + + + + + N ", | |||||
| " O P Q + + + + + + + + + + + + + + + + + + R S T p U V ", | |||||
| " W X + + + + + + + + + + + + + + + + R Y ' Z ` ' . ", | |||||
| " ) + + + + + + + + + + + + + + + ..+.@. ", | |||||
| " > + + #.+ + + + + + + + + + + $.R + %.&. ", | |||||
| " ) *.=.-.;.+ + + + + + + >.,.L '.2 ).1 ", | |||||
| " !.' + + ~.{.].^.+ /.(. _.W ", | |||||
| " + + :.' + <.[. ", | |||||
| " }.|.V 1.2.3. ", | |||||
| " ", | |||||
| " ", | |||||
| " "}; | |||||
| @@ -0,0 +1,128 @@ | |||||
| /* SpiralSound | |||||
| * Copyleft (C) 2001 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 "TrigPlugin.h" | |||||
| #include "TrigPluginGUI.h" | |||||
| #include <FL/Fl_Button.h> | |||||
| #include "SpiralIcon.xpm" | |||||
| #include "../../NoteTable.h" | |||||
| static const float PI=3.141592654; | |||||
| static const float RAD=(PI/180)*360; | |||||
| extern "C" { | |||||
| SpiralPlugin* CreateInstance() | |||||
| { | |||||
| return new TrigPlugin; | |||||
| } | |||||
| char** GetIcon() | |||||
| { | |||||
| return SpiralIcon_xpm; | |||||
| } | |||||
| int GetID() | |||||
| { | |||||
| return 53; | |||||
| } | |||||
| string GetGroupName() | |||||
| { | |||||
| return "Maths/Logic"; | |||||
| } | |||||
| } | |||||
| /////////////////////////////////////////////////////// | |||||
| TrigPlugin::TrigPlugin() : | |||||
| m_Operator(SIN) | |||||
| { | |||||
| m_Version=1; | |||||
| m_PluginInfo.Name="Trig"; | |||||
| m_PluginInfo.Width=60; | |||||
| m_PluginInfo.Height=70; | |||||
| m_PluginInfo.NumInputs=1; | |||||
| m_PluginInfo.NumOutputs=1; | |||||
| m_PluginInfo.PortTips.push_back("Input"); | |||||
| m_PluginInfo.PortTips.push_back("Output"); | |||||
| m_AudioCH->Register("Operator",(int*)&m_Operator); | |||||
| } | |||||
| TrigPlugin::~TrigPlugin() | |||||
| { | |||||
| } | |||||
| PluginInfo &TrigPlugin::Initialise(const HostInfo *Host) | |||||
| { | |||||
| return SpiralPlugin::Initialise(Host); | |||||
| } | |||||
| SpiralGUIType *TrigPlugin::CreateGUI() | |||||
| { | |||||
| return new TrigPluginGUI(m_PluginInfo.Width, | |||||
| m_PluginInfo.Height, | |||||
| this,m_AudioCH,m_HostInfo); | |||||
| } | |||||
| void TrigPlugin::Execute() | |||||
| { | |||||
| float Freq=0, OldFreq=0; | |||||
| switch (m_Operator) | |||||
| { | |||||
| case SIN : | |||||
| for (int n=0; n<m_HostInfo->BUFSIZE; n++) | |||||
| { | |||||
| SetOutput(0,n,sin(GetInput(0,n)*RAD)); | |||||
| } | |||||
| break; | |||||
| case COS : | |||||
| for (int n=0; n<m_HostInfo->BUFSIZE; n++) | |||||
| { | |||||
| SetOutput(0,n,cos(GetInput(0,n)*RAD)); | |||||
| } | |||||
| break; | |||||
| case TAN : | |||||
| for (int n=0; n<m_HostInfo->BUFSIZE; n++) | |||||
| { | |||||
| SetOutput(0,n,tan(GetInput(0,n)*RAD)); | |||||
| } | |||||
| break; | |||||
| } | |||||
| } | |||||
| void TrigPlugin::ExecuteCommands() | |||||
| { | |||||
| } | |||||
| void TrigPlugin::StreamOut(ostream &s) | |||||
| { | |||||
| s<<m_Version<<endl; | |||||
| s<<(int)m_Operator<<" "; | |||||
| } | |||||
| void TrigPlugin::StreamIn(istream &s) | |||||
| { | |||||
| int version; | |||||
| s>>version; | |||||
| int t; | |||||
| s>>t; | |||||
| m_Operator=(OperatorType)t; | |||||
| } | |||||
| @@ -0,0 +1,46 @@ | |||||
| /* SpiralSound | |||||
| * Copyleft (C) 2001 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 "../SpiralPlugin.h" | |||||
| #include <FL/Fl_Pixmap.H> | |||||
| #ifndef PLUGIN | |||||
| #define PLUGIN | |||||
| class TrigPlugin : public SpiralPlugin | |||||
| { | |||||
| public: | |||||
| TrigPlugin(); | |||||
| virtual ~TrigPlugin(); | |||||
| 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); | |||||
| enum OperatorType{NONE,SIN,COS,TAN}; | |||||
| OperatorType GetOperator() { return m_Operator; } | |||||
| private: | |||||
| OperatorType m_Operator; | |||||
| }; | |||||
| #endif | |||||
| @@ -0,0 +1,125 @@ | |||||
| /* SpiralPlugin | |||||
| * Copyleft (C) 2000 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 "TrigPluginGUI.h" | |||||
| #include <FL/fl_draw.h> | |||||
| #include <FL/fl_draw.H> | |||||
| #include <stdio.h> | |||||
| static const int GUI_COLOUR = 179; | |||||
| static const int GUIBG_COLOUR = 144; | |||||
| static const int GUIBG2_COLOUR = 145; | |||||
| //////////////////////////////////////////// | |||||
| TrigPluginGUI::TrigPluginGUI(int w, int h,TrigPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | |||||
| SpiralPluginGUI(w,h,o,ch) | |||||
| { | |||||
| int KeyWidth=10,Note,Pos=0,Count=0; | |||||
| m_Sin = new Fl_Button(5, 15, 50, 15,"Sin"); | |||||
| m_Sin->labelsize(8); | |||||
| m_Sin->type(1); | |||||
| m_Sin->value(1); | |||||
| m_Sin->selection_color(GUI_COLOUR); | |||||
| m_Sin->callback((Fl_Callback*)cb_Sin); | |||||
| m_Cos = new Fl_Button(5, 30, 50, 15,"Cos"); | |||||
| m_Cos->labelsize(8); | |||||
| m_Cos->type(1); | |||||
| m_Cos->selection_color(GUI_COLOUR); | |||||
| m_Cos->callback((Fl_Callback*)cb_Cos); | |||||
| m_Tan = new Fl_Button(5, 45, 50, 15,"Tan"); | |||||
| m_Tan->labelsize(8); | |||||
| m_Tan->type(1); | |||||
| m_Tan->selection_color(GUI_COLOUR); | |||||
| m_Tan->callback((Fl_Callback*)cb_Tan); | |||||
| end(); | |||||
| } | |||||
| void TrigPluginGUI::UpdateValues(SpiralPlugin *o) | |||||
| { | |||||
| TrigPlugin* Plugin = (TrigPlugin*)o; | |||||
| m_Sin->value(false); | |||||
| m_Cos->value(false); | |||||
| m_Tan->value(false); | |||||
| switch (Plugin->GetOperator()) | |||||
| { | |||||
| case TrigPlugin::SIN : m_Sin->value(true); break; | |||||
| case TrigPlugin::COS : m_Cos->value(true); break; | |||||
| case TrigPlugin::TAN : m_Tan->value(true); break; | |||||
| } | |||||
| } | |||||
| //// Callbacks //// | |||||
| inline void TrigPluginGUI::cb_Sin_i(Fl_Button* o, void* v) | |||||
| { | |||||
| if (o->value()) | |||||
| { | |||||
| m_Cos->value(false); | |||||
| m_Tan->value(false); | |||||
| m_GUICH->Set("Operator",(int)TrigPlugin::SIN); | |||||
| } | |||||
| else | |||||
| { | |||||
| o->value(true); | |||||
| } | |||||
| } | |||||
| void TrigPluginGUI::cb_Sin(Fl_Button* o, void* v) | |||||
| { ((TrigPluginGUI*)(o->parent()))->cb_Sin_i(o,v);} | |||||
| inline void TrigPluginGUI::cb_Cos_i(Fl_Button* o, void* v) | |||||
| { | |||||
| if (o->value()) | |||||
| { | |||||
| m_Sin->value(false); | |||||
| m_Tan->value(false); | |||||
| m_GUICH->Set("Operator",(int)TrigPlugin::COS); | |||||
| } | |||||
| else | |||||
| { | |||||
| o->value(true); | |||||
| } | |||||
| } | |||||
| void TrigPluginGUI::cb_Cos(Fl_Button* o, void* v) | |||||
| { ((TrigPluginGUI*)(o->parent()))->cb_Cos_i(o,v);} | |||||
| inline void TrigPluginGUI::cb_Tan_i(Fl_Button* o, void* v) | |||||
| { | |||||
| if (o->value()) | |||||
| { | |||||
| m_Sin->value(false); | |||||
| m_Cos->value(false); | |||||
| m_GUICH->Set("Operator",(int)TrigPlugin::TAN); | |||||
| } | |||||
| else | |||||
| { | |||||
| o->value(true); | |||||
| } | |||||
| } | |||||
| void TrigPluginGUI::cb_Tan(Fl_Button* o, void* v) | |||||
| { ((TrigPluginGUI*)(o->parent()))->cb_Tan_i(o,v);} | |||||
| const string TrigPluginGUI::GetHelpText(const string &loc){ | |||||
| return string("") | |||||
| + "Calculates the sin/cos/tan of the input value, 1.0=360 degrees."; | |||||
| } | |||||
| @@ -0,0 +1,56 @@ | |||||
| /* SpiralPlugin | |||||
| * Copyleft (C) 2000 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 <FL/Fl.H> | |||||
| #include <FL/Fl_Window.H> | |||||
| #include <FL/Fl_Group.H> | |||||
| #include <FL/Fl_Button.H> | |||||
| #include <FL/Fl_Button.H> | |||||
| #include <FL/Fl_Input.H> | |||||
| #include "../Widgets/Fl_Knob.H" | |||||
| #include "../Widgets/Fl_DragBar.H" | |||||
| #include "TrigPlugin.h" | |||||
| #include "../SpiralPluginGUI.h" | |||||
| #ifndef PluginGUI | |||||
| #define PluginGUI | |||||
| class TrigPluginGUI : public SpiralPluginGUI | |||||
| { | |||||
| public: | |||||
| TrigPluginGUI(int w, int h, TrigPlugin *o,ChannelHandler *ch,const HostInfo *Info); | |||||
| virtual void UpdateValues(SpiralPlugin *o); | |||||
| protected: | |||||
| const string GetHelpText(const string &loc); | |||||
| private: | |||||
| Fl_Button *m_Sin,*m_Cos,*m_Tan; | |||||
| //// Callbacks //// | |||||
| inline void cb_Sin_i(Fl_Button* o, void* v); | |||||
| static void cb_Sin(Fl_Button* o, void* v); | |||||
| inline void cb_Cos_i(Fl_Button* o, void* v); | |||||
| static void cb_Cos(Fl_Button* o, void* v); | |||||
| inline void cb_Tan_i(Fl_Button* o, void* v); | |||||
| static void cb_Tan(Fl_Button* o, void* v); | |||||
| }; | |||||
| #endif | |||||
| @@ -40,7 +40,7 @@ | |||||
| #include "SpiralSound/ChannelHandler.h" | #include "SpiralSound/ChannelHandler.h" | ||||
| #include "SettingsWindow.h" | #include "SettingsWindow.h" | ||||
| const static string VER_STRING = "0.2.0"; | |||||
| const static string VER_STRING = "0.2.1"; | |||||
| typedef Fl_Double_Window SpiralWindowType; | typedef Fl_Double_Window SpiralWindowType; | ||||
| // typedef Fl_Window SpiralWindowType; | // typedef Fl_Window SpiralWindowType; | ||||
| @@ -42,7 +42,7 @@ int SpiralSynthModularInfo::GUICOL_Tool=179; | |||||
| int SpiralSynthModularInfo::GUICOL_Button=181; | int SpiralSynthModularInfo::GUICOL_Button=181; | ||||
| int SpiralSynthModularInfo::GUICOL_Canvas=181; | int SpiralSynthModularInfo::GUICOL_Canvas=181; | ||||
| int SpiralSynthModularInfo::GUICOL_Device=181; | int SpiralSynthModularInfo::GUICOL_Device=181; | ||||
| string SpiralSynthModularInfo::BGIMG; | |||||
| int SpiralSynthModularInfo::GUIDEVICE_Box=30; | |||||
| vector<string> SpiralSynthModularInfo::PLUGINVEC; | vector<string> SpiralSynthModularInfo::PLUGINVEC; | ||||
| string SpiralSynthModularInfo::PLUGIN_PATH; | string SpiralSynthModularInfo::PLUGIN_PATH; | ||||
| @@ -61,7 +61,6 @@ SpiralSynthModularInfo* SpiralSynthModularInfo::Get() | |||||
| SpiralSynthModularInfo::SpiralSynthModularInfo() | SpiralSynthModularInfo::SpiralSynthModularInfo() | ||||
| { | { | ||||
| BGIMG="None"; | |||||
| PLUGIN_PATH = PLUGIN_PATH_LOCATION; | PLUGIN_PATH = PLUGIN_PATH_LOCATION; | ||||
| } | } | ||||
| @@ -76,7 +75,7 @@ void SpiralSynthModularInfo::StreamInPrefs(istream &s) | |||||
| s>>temp>>temp>>GUICOL_Button; | s>>temp>>temp>>GUICOL_Button; | ||||
| s>>temp>>temp>>GUICOL_Canvas; | s>>temp>>temp>>GUICOL_Canvas; | ||||
| s>>temp>>temp>>GUICOL_Device; | s>>temp>>temp>>GUICOL_Device; | ||||
| s>>temp>>temp>>BGIMG; | |||||
| s>>temp>>temp>>GUIDEVICE_Box; | |||||
| s>>temp>>temp>>PLUGIN_PATH; | s>>temp>>temp>>PLUGIN_PATH; | ||||
| s>>temp>>temp; | s>>temp>>temp; | ||||
| string st; | string st; | ||||
| @@ -109,7 +108,7 @@ void SpiralSynthModularInfo::StreamOutPrefs(ostream &s) | |||||
| s<<"ButtonColour = "<<GUICOL_Button<<endl; | s<<"ButtonColour = "<<GUICOL_Button<<endl; | ||||
| s<<"CanvasColour = "<<GUICOL_Canvas<<endl; | s<<"CanvasColour = "<<GUICOL_Canvas<<endl; | ||||
| s<<"DeviceColour = "<<GUICOL_Device<<endl; | s<<"DeviceColour = "<<GUICOL_Device<<endl; | ||||
| s<<"BGImagePNG = "<<BGIMG<<endl<<endl; | |||||
| s<<"DeviceBoxType = "<<GUIDEVICE_Box<<endl<<endl; | |||||
| s<<"PluginPath = "<<PLUGIN_PATH<<endl<<endl; | s<<"PluginPath = "<<PLUGIN_PATH<<endl<<endl; | ||||
| @@ -35,7 +35,7 @@ public: | |||||
| static int GUICOL_Button; | static int GUICOL_Button; | ||||
| static int GUICOL_Canvas; | static int GUICOL_Canvas; | ||||
| static int GUICOL_Device; | static int GUICOL_Device; | ||||
| static string BGIMG; | |||||
| static int GUIDEVICE_Box; | |||||
| protected: | protected: | ||||
| SpiralSynthModularInfo(); | SpiralSynthModularInfo(); | ||||
| @@ -46,7 +46,8 @@ if test $ac_arg_jack = "Y" ; then | |||||
| DistributorPlugin LFOPlugin KeyboardPlugin DiskWriterPlugin FormantFilterPlugin \ | DistributorPlugin LFOPlugin KeyboardPlugin DiskWriterPlugin FormantFilterPlugin \ | ||||
| AnotherFilterPlugin OperatorPlugin CounterPlugin FlipflopPlugin SwitchPlugin \ | AnotherFilterPlugin OperatorPlugin CounterPlugin FlipflopPlugin SwitchPlugin \ | ||||
| BeatMatchPlugin NoisePlugin SequencerPlugin LogicPlugin SplitSwitchPlugin \ | BeatMatchPlugin NoisePlugin SequencerPlugin LogicPlugin SplitSwitchPlugin \ | ||||
| MixSwitchPlugin MeterPlugin WaveShaperPlugin JackPlugin" | |||||
| MixSwitchPlugin MeterPlugin WaveShaperPlugin TrigPlugin SpiralLoopPlugin \ | |||||
| JackPlugin" | |||||
| else | else | ||||
| PLUGINLIST="AmpPlugin ControllerPlugin DelayPlugin EchoPlugin EnvFollowerPlugin \ | PLUGINLIST="AmpPlugin ControllerPlugin DelayPlugin EchoPlugin EnvFollowerPlugin \ | ||||
| EnvelopePlugin FilterPlugin MatrixPlugin MidiPlugin MixerPlugin MoogFilterPlugin \ | EnvelopePlugin FilterPlugin MatrixPlugin MidiPlugin MixerPlugin MoogFilterPlugin \ | ||||
| @@ -56,7 +57,7 @@ else | |||||
| DistributorPlugin LFOPlugin KeyboardPlugin DiskWriterPlugin FormantFilterPlugin \ | DistributorPlugin LFOPlugin KeyboardPlugin DiskWriterPlugin FormantFilterPlugin \ | ||||
| AnotherFilterPlugin OperatorPlugin CounterPlugin FlipflopPlugin SwitchPlugin \ | AnotherFilterPlugin OperatorPlugin CounterPlugin FlipflopPlugin SwitchPlugin \ | ||||
| BeatMatchPlugin NoisePlugin SequencerPlugin LogicPlugin SplitSwitchPlugin \ | BeatMatchPlugin NoisePlugin SequencerPlugin LogicPlugin SplitSwitchPlugin \ | ||||
| MixSwitchPlugin MeterPlugin WaveShaperPlugin " | |||||
| MixSwitchPlugin MeterPlugin WaveShaperPlugin TrigPlugin SpiralLoopPlugin" | |||||
| fi | fi | ||||
| echo "$PLUGINLIST" > SpiralSound/PluginList.txt | echo "$PLUGINLIST" > SpiralSound/PluginList.txt | ||||
| @@ -170,6 +171,8 @@ SpiralSound/Plugins/SequencerPlugin/Makefile | |||||
| SpiralSound/Plugins/LogicPlugin/Makefile | SpiralSound/Plugins/LogicPlugin/Makefile | ||||
| SpiralSound/Plugins/SplitSwitchPlugin/Makefile | SpiralSound/Plugins/SplitSwitchPlugin/Makefile | ||||
| SpiralSound/Plugins/MixSwitchPlugin/Makefile | SpiralSound/Plugins/MixSwitchPlugin/Makefile | ||||
| SpiralSound/Plugins/TrigPlugin/Makefile | |||||
| SpiralSound/Plugins/SpiralLoopPlugin/Makefile | |||||
| SpiralSynthPluginLocation.h | SpiralSynthPluginLocation.h | ||||
| Makefile | Makefile | ||||
| ) | ) | ||||