commit f1c67f0f87d9a16122f937f0355daf65b652da33
parent b81fda75bee3fed43a0ac388561a5b745a372e52
Author: fundamental <[email protected]>
Date: Sat, 6 Aug 2011 00:06:38 -0400
Pruning: Removing dead/out-of-scope code
- Large chunks of code have existed in non active pathways for the code.
- Removing them makes it easier to see what is used.
- As windows support has not been active in a considerable amount of time, it is
removed [Only unix support will be made from now on]
- This does indicate documentation needs to be altered
- This also removes out-of-scope code like the sequencer, which although
interesting is out of place
- Please report any compile errors from this patch to zyn ML or sourceforge
tracker, as this does strip out a significant amount of code
Diffstat:
25 files changed, 2 insertions(+), 1961 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
@@ -104,13 +104,7 @@ add_definitions(
)
#set os flag
-if(CYGWIN)
- add_definitions(-DOS_CYGWIN=1)
- set(OS_LIBRARIES "-Wl,--enable-auto-import")
-elseif(WINDOWS)
- add_definitions(-DOS_WINDOWS=1)
- set(OS_LIBRARIES "")
-elseif(UNIX)
+if(UNIX)
add_definitions(-DOS_LINUX=1)
set(OS_LIBRARIES "-lpthread")
else()
@@ -199,7 +193,6 @@ endmacro(unit_test)
set(NONGUI_LIBRARIES
zynaddsubfx_misc
zynaddsubfx_synth
- zynaddsubfx_seq
zynaddsubfx_effect
zynaddsubfx_params
zynaddsubfx_dsp
@@ -211,7 +204,6 @@ set(CXXTEST_LINK_LIBS ${NONGUI_LIBRARIES})
add_subdirectory(Misc)
add_subdirectory(Synth)
-add_subdirectory(Seq)
add_subdirectory(Effects)
add_subdirectory(Params)
add_subdirectory(DSP)
diff --git a/src/Input/MidiIn.cpp b/src/Input/MidiIn.cpp
@@ -1,96 +0,0 @@
-/*
- ZynAddSubFX - a software synthesizer
-
- MidiIn.cpp - This class is inherited by all the Midi input classes
- Copyright (C) 2002-2005 Nasca Octavian Paul
- Author: Nasca Octavian Paul
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License
- as published by the Free Software Foundation.
-
- 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 (version 2 or later) for more details.
-
- You should have received a copy of the GNU General Public License (version 2)
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-#include "../globals.h"
-#include "MidiIn.h"
-
-int MidiIn::getcontroller(unsigned char b)
-{
- /**\todo there might be a better way to do this*/
- int ctl = C_NULL;
- switch(b) {
- case 1:
- ctl = C_modwheel; //Modulation Wheel
- break;
- case 7:
- ctl = C_volume; //Volume
- break;
- case 10:
- ctl = C_panning; //Panning
- break;
- case 11:
- ctl = C_expression; //Expression
- break;
- case 64:
- ctl = C_sustain; //Sustain pedal
- break;
- case 65:
- ctl = C_portamento; //Portamento
- break;
- case 71:
- ctl = C_filterq; //Filter Q (Sound Timbre)
- break;
- case 74:
- ctl = C_filtercutoff; //Filter Cutoff (Brightness)
- break;
- case 75:
- ctl = C_bandwidth; //BandWidth
- break;
- case 76:
- ctl = C_fmamp; //FM amplitude
- break;
- case 77:
- ctl = C_resonance_center; //Resonance Center Frequency
- break;
- case 78:
- ctl = C_resonance_bandwidth; //Resonance Bandwith
- break;
- case 120:
- ctl = C_allsoundsoff; //All Sounds OFF
- break;
- case 121:
- ctl = C_resetallcontrollers; //Reset All Controllers
- break;
- case 123:
- ctl = C_allnotesoff; //All Notes OFF
- break;
- //RPN and NRPN
- case 0x06:
- ctl = C_dataentryhi; //Data Entry (Coarse)
- break;
- case 0x26:
- ctl = C_dataentrylo; //Data Entry (Fine)
- break;
- case 99:
- ctl = C_nrpnhi; //NRPN (Coarse)
- break;
- case 98:
- ctl = C_nrpnlo; //NRPN (Fine)
- break;
- default:
- ctl = C_NULL; //unknown controller
- //fprintf(stderr,"Controller=%d , par=%d\n",midievent->data.control.param,cmdparams[1]);
- break;
- }
- return ctl;
-}
-
diff --git a/src/Input/MidiIn.h b/src/Input/MidiIn.h
@@ -1,52 +0,0 @@
-/*
- ZynAddSubFX - a software synthesizer
-
- MidiIn.h - This class is inherited by all the Midi input classes
- Copyright (C) 2002-2005 Nasca Octavian Paul
- Author: Nasca Octavian Paul
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License
- as published by the Free Software Foundation.
-
- 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 (version 2 or later) for more details.
-
- You should have received a copy of the GNU General Public License (version 2)
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-#ifndef MIDI_IN_H
-#define MIDI_IN_H
-
-#include "../globals.h"
-
-enum MidiCmdType {
- MidiNull, MidiNoteOFF, MidiNoteON, MidiController
-};
-#define MP_MAX_BYTES 4000 //in case of loooong SYS_EXes
-
-/**This class is inherited by all the Midi input classes*/
-class MidiIn
-{
- public:
- /**Get the command,channel and parameters of the MIDI
- *
- * \todo make pure virtual
- * @param cmdtype the referece to the variable that will store the type
- * @param cmdchan the channel for the event
- * @param parameters for the event*/
- virtual void getmidicmd(MidiCmdType &cmdtype,
- unsigned char &cmdchan,
- int *cmdparams) = 0;
- int getcontroller(unsigned char b);
- protected:
- bool inputok; /**<1 if I can read midi bytes from input ports*/
-};
-
-#endif
-
diff --git a/src/Input/WINMidiIn.cpp b/src/Input/WINMidiIn.cpp
@@ -1,94 +0,0 @@
-/*
- ZynAddSubFX - a software synthesizer
-
- WINMidiIn.cpp - Midi input for Windows
- Copyright (C) 2002-2005 Nasca Octavian Paul
- Author: Nasca Octavian Paul
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License
- as published by the Free Software Foundation.
-
- 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 (version 2 or later) for more details.
-
- You should have received a copy of the GNU General Public License (version 2)
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <windows.h>
-#include <mmsystem.h>
-#include <pthread.h>
-
-#include "WINMidiIn.h"
-#include "MidiIn.h"
-#include "../Misc/Util.h"
-
-Master *winmaster;
-HMIDIIN winmidiinhandle;
-MidiIn midictl; //used to convert the controllers to ZynAddSubFX controllers
-
-void CALLBACK WinMidiInProc(HMIDIIN hMidiIn, UINT wMsg, DWORD dwInstance,
- DWORD dwParam1, DWORD dwParam2)
-{
- int midicommand = MidiNull;
- if(wMsg == MIM_DATA) {
- int cmd, par1, par2;
- cmd = dwParam1 & 0xff;
- if(cmd == 0xfe)
- return;
- par1 = (dwParam1 >> 8) & 0xff;
- par2 = dwParam1 >> 16;
- //printf("%x %x %x\n",cmd,par1,par2);fflush(stdout);
- int cmdchan = cmd & 0x0f;
- int cmdtype = (cmd >> 4) & 0x0f;
-
- int tmp = 0;
- pthread_mutex_lock(&winmaster->mutex);
- switch(cmdtype) {
- case (0x8): //noteon
- winmaster->NoteOff(cmdchan, par1);
- break;
- case (0x9): //noteoff
- winmaster->NoteOn(cmdchan, par1, par2 & 0xff);
- break;
- case (0xb): //controller
- winmaster->SetController(cmdchan, midictl.getcontroller(
- par1), par2 & 0xff);
- break;
- case (0xe): //pitch wheel
- tmp = (par1 + par2 * (long int) 128) - 8192;
- winmaster->SetController(cmdchan, C_pitchwheel, tmp);
- break;
- default:
- break;
- }
- pthread_mutex_unlock(&winmaster->mutex);
- }
-}
-
-void InitWinMidi(Master *master_)
-{
- winmaster = master_;
-
- long int result =
- midiInOpen(&winmidiinhandle,
- config.cfg.WindowsMidiInId,
- (DWORD)WinMidiInProc,
- 0,
- CALLBACK_FUNCTION);
- result = midiInStart(winmidiinhandle);
-}
-
-void StopWinMidi()
-{
- midiInStop(winmidiinhandle);
- midiInClose(winmidiinhandle);
-}
-
diff --git a/src/Input/WINMidiIn.h b/src/Input/WINMidiIn.h
@@ -1,34 +0,0 @@
-/*
- ZynAddSubFX - a software synthesizer
-
- WINMidiIn.h - Midi input for Windows
- Copyright (C) 2002-2005 Nasca Octavian Paul
- Author: Nasca Octavian Paul
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License
- as published by the Free Software Foundation.
-
- 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 (version 2 or later) for more details.
-
- You should have received a copy of the GNU General Public License (version 2)
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-#ifndef WIN_MIDI_IN_H
-#define WIN_MIDI_IN_H
-
-
-#include "../Misc/Master.h"
-
-void InitWinMidi(Master *master_);
-void StopWinMidi();
-
-
-#endif
-
diff --git a/src/Misc/Bank.cpp b/src/Misc/Bank.cpp
@@ -256,15 +256,8 @@ int Bank::newbank(string newbankdirname)
bankdir += "/";
bankdir += newbankdirname;
-#if OS_WINDOWS
- if(mkdir(bankdir.c_str()) < 0)
- return -1;
-#elif OS_LINUX || OS_CYGWIN
if(mkdir(bankdir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0)
return -1;
-#else
-#warning Undefined OS
-#endif
const string tmpfilename = bankdir + '/' + FORCE_BANK_DIR_FILE;
diff --git a/src/Misc/Config.cpp b/src/Misc/Config.cpp
@@ -24,10 +24,6 @@
#include <stdlib.h>
#include <string.h>
-#if OS_WINDOWS
-#include <windows.h>
-#include <mmsystem.h>
-#endif
#include "Config.h"
#include "XMLwrapper.h"
@@ -68,12 +64,7 @@ void Config::init()
cfg.VirKeybLayout = 1;
winwavemax = 1;
winmidimax = 1;
-//try to find out how many input midi devices are there
-#ifdef WINMIDIIN
- winmidimax = midiInGetNumDevs();
- if(winmidimax == 0)
- winmidimax = 1;
-#endif
+ //try to find out how many input midi devices are there
winmididevices = new winmidionedevice[winmidimax];
for(int i = 0; i < winmidimax; i++) {
winmididevices[i].name = new char[MAX_STRING_SIZE];
@@ -83,16 +74,6 @@ void Config::init()
//get the midi input devices name
-#ifdef WINMIDIIN
- MIDIINCAPS midiincaps;
- for(int i = 0; i < winmidimax; i++)
- if(!midiInGetDevCaps(i, &midiincaps, sizeof(MIDIINCAPS)))
- snprintf(winmididevices[i].name,
- MAX_STRING_SIZE,
- "%s",
- midiincaps.szPname);
- ;
-#endif
cfg.currentBankDir = "./testbnk";
char filename[MAX_STRING_SIZE];
@@ -100,7 +81,6 @@ void Config::init()
readConfig(filename);
if(cfg.bankRootDirList[0].empty()) {
-#if OS_LINUX
//banks
cfg.bankRootDirList[0] = "~/banks";
cfg.bankRootDirList[1] = "./";
@@ -108,44 +88,15 @@ void Config::init()
cfg.bankRootDirList[3] = "/usr/local/share/zynaddsubfx/banks";
cfg.bankRootDirList[4] = "../banks";
cfg.bankRootDirList[5] = "banks";
-
-#else
- //banks
- cfg.bankRootDirList[0] = "./";
-
-#ifdef VSTAUDIOOUT
- cfg.bankRootDirList[1] = "c:/Program Files/ZynAddSubFX/banks";
-#else
- cfg.bankRootDirList[1] = "../banks";
-#endif
- cfg.bankRootDirList[2] = "banks";
-
-#endif
}
if(cfg.presetsDirList[0].empty()) {
-#if OS_LINUX || OS_CYGWIN
//presets
cfg.presetsDirList[0] = "./";
cfg.presetsDirList[1] = "../presets";
cfg.presetsDirList[2] = "presets";
cfg.presetsDirList[3] = "/usr/share/zynaddsubfx/presets";
cfg.presetsDirList[4] = "/usr/local/share/zynaddsubfx/presets";
-
-#elif OS_WINDOWS
- //presets
- cfg.presetsDirList[0] = "./";
-
-#ifdef VSTAUDIOOUT
- cfg.presetsDirList[1] = "c:/Program Files/ZynAddSubFX/presets";
-#else
- cfg.presetsDirList[1] = "../presets";
-#endif //end vst
-
- cfg.presetsDirList[2] = "presets";
-#else
-#error Undefined OS
-#endif //end OS
}
cfg.LinuxALSAaudioDev = "default";
cfg.nameTag = "";
@@ -347,12 +298,6 @@ void Config::saveConfig(const char *filename)
void Config::getConfigFileName(char *name, int namesize)
{
name[0] = 0;
-#ifdef OS_LINUX
snprintf(name, namesize, "%s%s", getenv("HOME"), "/.zynaddsubfxXML.cfg");
-#elif OS_WINDOWS || OS_CYGWIN
- snprintf(name, namesize, "%s", "zynaddsubfxXML.cfg");
-#else
-#error Undefined OS
-#endif
}
diff --git a/src/Misc/Master.h b/src/Misc/Master.h
@@ -31,7 +31,6 @@
#include "Recorder.h"
#include "Part.h"
#include "Dump.h"
-#include "../Seq/Sequencer.h"
#include "XMLwrapper.h"
typedef enum { MUTEX_TRYLOCK, MUTEX_LOCK, MUTEX_UNLOCK } lockset;
@@ -149,9 +148,6 @@ class Master
Controller ctl;
bool swaplr; //if L and R are swapped
- //Sequencer
- Sequencer seq;
-
//other objects
Microtonal microtonal;
Bank bank;
diff --git a/src/Misc/Util.cpp b/src/Misc/Util.cpp
@@ -32,11 +32,6 @@
#include <errno.h>
#include <string.h>
#include <sched.h>
-#if OS_WINDOWS
-//used for the sleep func
-#include <winbase.h>
-#include <windows.h>
-#endif
int SAMPLE_RATE = 44100;
@@ -123,25 +118,17 @@ bool fileexists(const char *filename)
void set_realtime()
{
-#if OS_LINUX || OS_CYGWIN
sched_param sc;
sc.sched_priority = 60;
//if you want get "sched_setscheduler undeclared" from compilation,
//you can safely remove the folowing line:
sched_setscheduler(0, SCHED_FIFO, &sc);
//if (err==0) printf("Real-time");
-#else
-#warning set_realtime() undefined for your opperating system
-#endif
}
void os_sleep(long length)
{
-#if OS_LINUX || OS_CYGWIN
usleep(length);
-#elif OS_WINDOWS
- Sleep((long)length/1000);
-#endif
}
std::string legalizeFilename(std::string filename)
diff --git a/src/Output/PAaudiooutput.cpp b/src/Output/PAaudiooutput.cpp
@@ -1,80 +0,0 @@
-/*
- ZynAddSubFX - a software synthesizer
-
- PAaudiooutput.cpp - Audio output for PortAudio
- Copyright (C) 2002 Nasca Octavian Paul
- Author: Nasca Octavian Paul
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License
- as published by the Free Software Foundation.
-
- 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 (version 2 or later) for more details.
-
- You should have received a copy of the GNU General Public License (version 2)
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-#include "PAaudiooutput.h"
-
-Master *PAmaster;
-PaStream *stream;
-REALTYPE *outl, *outr;
-
-int PAprocess(void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData)
-{
- if(framesPerBuffer != SOUND_BUFFER_SIZE) {
- fprintf(
- stderr,
- "Bug: PAudioOutput::PAprocess SOUND_BUFFER_SIZE!=framesPerBuffer");
- fprintf(stderr, "%d %d\n", framesPerBuffer, SOUND_BUFFER_SIZE);
- }
-
- pthread_mutex_lock(&PAmaster->mutex);
- PAmaster->GetAudioOutSamples(SOUND_BUFFER_SIZE, SAMPLE_RATE, outl, outr);
- pthread_mutex_unlock(&PAmaster->mutex);
-
- float *out = (float *)outputBuffer;
-
- for(int i = 0; i < framesPerBuffer; i++) {
- if(i >= SOUND_BUFFER_SIZE)
- break; //this should never happens, except only when framesPerBuffer!>SOUND_BUFFER_SIZE
- out[i * 2] = outl[i];
- out[i * 2 + 1] = outr[i];
- }
-
- return 0;
-}
-
-void PAaudiooutputinit(Master *master_)
-{
- PAmaster = master_;
- outl = new REALTYPE [SOUND_BUFFER_SIZE];
- outr = new REALTYPE [SOUND_BUFFER_SIZE];
- Pa_Initialize();
- Pa_OpenDefaultStream(&stream,
- 0,
- 2,
- paFloat32,
- SAMPLE_RATE,
- SOUND_BUFFER_SIZE,
- 0,
- PAprocess,
- NULL);
- Pa_StartStream(stream);
-}
-
-void PAfinish()
-{
- Pa_StopStream(stream);
- delete (outl);
- delete (outr);
-}
-
diff --git a/src/Output/PAaudiooutput.h b/src/Output/PAaudiooutput.h
@@ -1,34 +0,0 @@
-/*
- ZynAddSubFX - a software synthesizer
-
- PAaudiooutput.h - Audio output for PortAudio
- Copyright (C) 2002 Nasca Octavian Paul
- Author: Nasca Octavian Paul
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License
- as published by the Free Software Foundation.
-
- 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 (version 2 or later) for more details.
-
- You should have received a copy of the GNU General Public License (version 2)
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-#ifndef PA_AUDIO_OUTPUT_H
-#define PA_AUDIO_OUTPUT_H
-
-#include <portaudio.h>
-
-#include "../globals.h"
-#include "../Misc/Master.h"
-
-void PAaudiooutputinit(Master *master_);
-void PAfinish();
-
-#endif
-
diff --git a/src/Output/VSTaudiooutput.cpp b/src/Output/VSTaudiooutput.cpp
@@ -1,68 +0,0 @@
-/*
- ZynAddSubFX - a software synthesizer
-
- VSTaudiooutput.cpp - Audio output for VST
- Copyright (C) 2002 Nasca Octavian Paul
- Author: Nasca Octavian Paul
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License
- as published by the Free Software Foundation.
-
- 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 (version 2 or later) for more details.
-
- You should have received a copy of the GNU General Public License (version 2)
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-#include <string.h>
-#include "VSTaudiooutput.h"
-
-//the constructor and the destructor are defined in main.cpp
-
-void VSTSynth::process(float **inputs, float **outputs, long sampleframes)
-{
- float *outl = outputs[0];
- float *outr = outputs[1];
- pthread_mutex_lock(&vmaster->mutex);
- vmaster->GetAudioOutSamples(sampleframes, (int) getSampleRate(), outl, outr);
- pthread_mutex_unlock(&vmaster->mutex);
-}
-
-void VSTSynth::processReplacing(float **inputs,
- float **outputs,
- long sampleframes)
-{
- process(inputs, outputs, sampleframes);
-}
-
-long int VSTSynth::canDo(char *txt)
-{
- if(strcmp(txt, "receiveVstEvents") == 0)
- return 1;
- if(strcmp(txt, "receiveVstMidiEvent") == 0)
- return 1;
- return -1;
-}
-
-bool VSTSynth::getVendorString(char *txt)
-{
- strcpy(txt, "Nasca O. Paul");
- return true;
-}
-
-bool VSTSynth::getProductString(char *txt)
-{
- strcpy(txt, "ZynAddSubFX");
- return true;
-}
-
-void VSTSynth::resume()
-{
- wantEvents();
-}
-
diff --git a/src/Output/VSTaudiooutput.h b/src/Output/VSTaudiooutput.h
@@ -1,60 +0,0 @@
-/*
- ZynAddSubFX - a software synthesizer
-
- VSTaudiooutput.h - Audio output for VST
- Copyright (C) 2002 Nasca Octavian Paul
- Author: Nasca Octavian Paul
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License
- as published by the Free Software Foundation.
-
- 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 (version 2 or later) for more details.
-
- You should have received a copy of the GNU General Public License (version 2)
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-#ifndef VST_AUDIO_OUTPUT_H
-#define VST_AUDIO_OUTPUT_H
-
-#include <pthread.h>
-
-#include "../globals.h"
-#include "../Misc/Master.h"
-#include "../UI/MasterUI.h"
-
-#include "../../../vstsdk2/source/common/audioeffectx.h"
-
-class VSTSynth:public AudioEffectX
-{
- public:
- VSTSynth(audioMasterCallback audioMaster);
- ~VSTSynth();
-
- virtual void process(float **inputs, float **outputs, long sampleframes);
- virtual void processReplacing(float **inputs,
- float **outputs,
- long sampleframes);
- virtual long processEvents(VstEvents *events); //this is used for Midi input
- virtual long int canDo(char *txt);
- virtual bool getVendorString(char *txt);
- virtual bool getProductString(char *txt);
- virtual void resume();
-
- virtual long getChunk(void **data, bool isPreset = false);
- virtual long setChunk(void *data, long size, bool isPreset = false);
-
- MasterUI *ui;
- int Pexitprogram;
-
- Master *vmaster;
- pthread_t thr;
-};
-
-#endif
-
diff --git a/src/Seq/CMakeLists.txt b/src/Seq/CMakeLists.txt
@@ -1,11 +0,0 @@
-set(zynaddsubfx_seq_SRCS
- MIDIEvents.cpp
- MIDIFile.cpp
- Sequencer.cpp
-)
-
-add_library(zynaddsubfx_seq STATIC
- ${zynaddsubfx_seq_SRCS}
- )
-
-target_link_libraries(zynaddsubfx_seq)
diff --git a/src/Seq/MIDIEvents.cpp b/src/Seq/MIDIEvents.cpp
@@ -1,93 +0,0 @@
-/*
- ZynAddSubFX - a software synthesizer
-
- MIDIEvents.cpp - It stores the midi events from midi file or sequencer
- Copyright (C) 2003-2005 Nasca Octavian Paul
- Author: Nasca Octavian Paul
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License
- as published by the Free Software Foundation.
-
- 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 (version 2 or later) for more details.
-
- You should have received a copy of the GNU General Public License (version 2)
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-#include "MIDIEvents.h"
-#include <stdlib.h>
-#include <stdio.h>
-
-MIDIEvents::MIDIEvents()
-{}
-
-MIDIEvents::~MIDIEvents()
-{}
-
-
-/************** Track stuff ***************/
-void MIDIEvents::writeevent(list *l, event *ev)
-{
- listpos *tmp = new listpos;
- tmp->next = NULL;
- tmp->ev = *ev;
- if(l->current != NULL)
- l->current->next = tmp;
- else
- l->first = tmp;
- l->current = tmp;
-// printf("Wx%x ",(int) l->current);
-// printf("-> %d \n",l->current->ev.deltatime);
- l->size++;
-}
-
-void MIDIEvents::readevent(list *l, event *ev)
-{
- if(l->current == NULL) {
- ev->type = -1;
- return;
- }
- *ev = l->current->ev;
- l->current = l->current->next;
-
- //test
- if(l->current != NULL) {
-// ev->deltatime=10000;
-// printf("Rx%d\n",l->current->ev.deltatime);
-// printf("Rx%x ",(int) l->current);
-// printf("-> %d (next=%x) \n",(int)l->current->ev.deltatime,(int)l->current->next);
- }
-}
-
-
-void MIDIEvents::rewindlist(list *l)
-{
- l->current = l->first;
-}
-
-void MIDIEvents::deletelist(list *l)
-{
- l->current = l->first;
- if(l->current == NULL)
- return;
- while(l->current->next != NULL) {
- listpos *tmp = l->current;
- l->current = l->current->next;
- delete (tmp);
- }
- deletelistreference(l);
-}
-
-void MIDIEvents::deletelistreference(list *l)
-{
- l->current = l->first = NULL;
- l->size = 0;
- l->length = 0.0;
-}
-
diff --git a/src/Seq/MIDIEvents.h b/src/Seq/MIDIEvents.h
@@ -1,69 +0,0 @@
-/*
- ZynAddSubFX - a software synthesizer
-
- MIDIEvents.h - It stores the midi events from midi file or sequencer
- Copyright (C) 2003-2005 Nasca Octavian Paul
- Author: Nasca Octavian Paul
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License
- as published by the Free Software Foundation.
-
- 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 (version 2 or later) for more details.
-
- You should have received a copy of the GNU General Public License (version 2)
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-#ifndef MIDI_EVENTS_H
-#define MIDI_EVENTS_H
-
-#include "../globals.h"
-#define NUM_MIDI_TRACKS NUM_MIDI_CHANNELS
-
-/**storage the midi events from midi file or sequencer
- * \todo this looks quite like a remake of a linked list
- * if it is, then it should be rewritten to use <list>*/
-class MIDIEvents
-{
- friend class MIDIFile;
- public:
- MIDIEvents();
- ~MIDIEvents();
-
- protected:
-
- /* Events */
- struct event {
- int deltatime;
- int channel; //on what midi channel is
- int type, par1, par2; //type=1 for note, type=2 for controller, type=255 for time messages
- } tmpevent;
- struct listpos {
- event ev;
- struct listpos *next;
- };
- struct list {
- listpos *first, *current;
- int size; //how many events are
- double length; //in seconds
- };
- struct {
- list track; //the stored track
- list record; //the track being "recorded" from midi
- } miditrack[NUM_MIDI_TRACKS];
-
- void writeevent(list *l, event *ev);
- void readevent(list *l, event *ev);
-
- void rewindlist(list *l);
- void deletelist(list *l);
- void deletelistreference(list *l);
-};
-
-#endif
-
diff --git a/src/Seq/MIDIFile.cpp b/src/Seq/MIDIFile.cpp
@@ -1,419 +0,0 @@
-/*
- ZynAddSubFX - a software synthesizer
-
- MIDIFile.cpp - MIDI file loader
- Copyright (C) 2003-2005 Nasca Octavian Paul
- Author: Nasca Octavian Paul
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License
- as published by the Free Software Foundation.
-
- 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 (version 2 or later) for more details.
-
- You should have received a copy of the GNU General Public License (version 2)
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-#include "MIDIFile.h"
-
-
-MIDIFile::MIDIFile()
-{
- midifile = NULL;
- midifilesize = 0;
- midifilek = 0;
- midieof = false;
- me = NULL;
-}
-
-MIDIFile::~MIDIFile()
-{
- clearmidifile();
-}
-
-int MIDIFile::loadfile(const char *filename)
-{
- clearmidifile();
-
- FILE *file = fopen(filename, "r");
- if(file == NULL)
- return -1;
-
- char header[4];
- ZERO(header, 4);
- fread(header, 4, 1, file);
-
- //test to see if this a midi file
- if((header[0] != 'M') || (header[1] != 'T') || (header[2] != 'h')
- || (header[3] != 'd')) {
- fclose(file);
- return -1;
- }
-
- //get the filesize
- fseek(file, 0, SEEK_END);
- midifilesize = ftell(file);
- rewind(file);
-
- midifile = new unsigned char[midifilesize];
- ZERO(midifile, midifilesize);
- fread(midifile, midifilesize, 1, file);
- fclose(file);
-
-// for (int i=0;i<midifilesize;i++) printf("%2x ",midifile[i]);
-// printf("\n");
-
-
- return 0;
-}
-
-int MIDIFile::parsemidifile(MIDIEvents *me_)
-{
- this->me = me_;
-
- //read the header
- int chunk = getint32(); //MThd
- if(chunk != 0x4d546864)
- return -1;
- int size = getint32();
- if(size != 6)
- return -1; //header is always 6 bytes long
-
-
- int format = getint16();
- printf("format %d\n", format);
-
- int ntracks = getint16(); //this is always 1 if the format is "0"
- printf("ntracks %d\n", ntracks);
-
- int division = getint16();
- printf("division %d\n", division);
- if(division >= 0) { //delta time units in each a quater note
-// tick=???;
- }
- else //SMPTE (frames/second and ticks/frame)
- printf(
- "ERROR:in MIDIFile.cpp::parsemidifile() - SMPTE not implemented yet.");
- ;
-
- if(ntracks >= NUM_MIDI_TRACKS)
- ntracks = NUM_MIDI_TRACKS - 1;
-
- for(int n = 0; n < ntracks; n++) {
- if(parsetrack(n) < 0) {
- clearmidifile();
- return -1;
- }
- }
-
- printf("\n\nCURRENT File position is = 0x%x\n", midifilek);
- printf("\nMIDI file succesfully parsed.\n");
-// printf("\n0x%x\n",getbyte());
-
- this->me = NULL;
- return 0;
-}
-
-//private members
-
-
-int MIDIFile::parsetrack(int ntrack)
-{
- printf("\n--==*Reading track %d **==--\n", ntrack);
-
- int chunk = getint32(); //MTrk
- if(chunk != 0x4d54726b)
- return -1;
-
- int size = getint32();
- printf("size = %d\n", size);
-
- int oldmidifilek = midifilek;
-
- unsigned char lastmsg = 0;
- unsigned int dt = 0;
-
- while(!midieof) {
- unsigned int msgdeltatime = getvarint32();
-
-/// printf("MSGDELTATIME = %d\n",msgdeltatime);
-
-// dt+=msgdeltatime;
-
- int msg = peekbyte();
-/// printf("raw msg=0x%x ",msg);
- if(msg < 0x80)
- msg = lastmsg;
- else {
- lastmsg = msg;
- getbyte();
- }
-/// printf("msg=0x%x\n",msg);
-
-// dt+=msgdeltatime;
- add_dt(ntrack, msgdeltatime);
-
- unsigned int mtype, mlength;
-
- switch(msg) {
- case 0x80 ... 0x8f: //note on off
- parsenoteoff(ntrack, msg & 0x0f, dt);
- dt = 0;
- break;
- case 0x90 ... 0x9f: //note on (or note off)
- parsenoteon(ntrack, msg & 0x0f, dt);
- dt = 0;
- break;
- case 0xa0 ... 0xaf: //aftertouch - ignored
- skipnbytes(2);
- break;
- case 0xb0 ... 0xbf: //control change
- parsecontrolchange(ntrack, msg & 0x0f, dt);
- dt = 0;
- break;
- case 0xc0 ... 0xcf: //program change - ignored
- skipnbytes(1);
- break;
- case 0xd0 ... 0xdf: //channel pressure - ignored
- skipnbytes(1);
- break;
- case 0xe0 ... 0xef: //channel mode messages
- skipnbytes(2);
- break;
- case 0xf0: //sysex - ignored
- while(getbyte() != 0xf7) {
- if(midieof)
- break;
- }
- break;
- case 0xf7: //sysex (another type) - ignored
- skipnbytes(getvarint32());
- break;
-
- case 0xff: //meta-event
- mtype = getbyte();
- mlength = getbyte();
- parsemetaevent(mtype, mlength);
- break;
-
- default:
- getbyte();
- printf("UNKNOWN message! 0x%x\n", msg);
- return -1;
- break;
- }
-
-
-
- if(midieof)
- return -1;
-
- if((midifilek - oldmidifilek) == size)
- break;
- else
- if((midifilek - oldmidifilek) > size)
- return -1;
-// if (size!=6) return(-1);//header is always 6 bytes long
- }
-
- printf("End Track\n\n");
-
- return 0;
-}
-
-
-void MIDIFile::parsenoteoff(char ntrack, char chan, unsigned int dt)
-{
- unsigned char note;
- note = getbyte();
-
- (void) getbyte(); //Read in unused noteoff_velocity
- if(chan >= NUM_MIDI_CHANNELS)
- return;
-
- me->tmpevent.deltatime = convertdt(dt);
- me->tmpevent.type = 1;
- me->tmpevent.par1 = note;
- me->tmpevent.par2 = 0;
- me->tmpevent.channel = chan;
-
- printf("Note off:%d \n", note);
-
- ///test
-// ntrack=0;
-
- me->writeevent(&me->miditrack[(int)ntrack].record, &me->tmpevent);
-}
-
-
-void MIDIFile::parsenoteon(char ntrack, char chan, unsigned int dt)
-{
- unsigned char note, vel;
- note = getbyte();
- vel = getbyte();
-
-// printf("ntrack=%d\n",ntrack);
- printf("[dt %d ] Note on:%d %d\n", dt, note, vel);
-
- if(chan >= NUM_MIDI_CHANNELS)
- return;
-
- me->tmpevent.deltatime = convertdt(dt);
- me->tmpevent.type = 1;
- me->tmpevent.par1 = note;
- me->tmpevent.par2 = vel;
- me->tmpevent.channel = chan;
- me->writeevent(&me->miditrack[(int)ntrack].record, &me->tmpevent);
-}
-
-void MIDIFile::parsecontrolchange(char ntrack, char chan, unsigned int dt)
-{
- unsigned char control, value;
- control = getbyte();
- value = getbyte();
-
- if(chan >= NUM_MIDI_CHANNELS)
- return;
-
- printf("[dt %d] Control change:%d %d\n", dt, control, value);
-
- me->tmpevent.deltatime = convertdt(dt);
- me->tmpevent.type = 2;
- me->tmpevent.par1 = control; //???????????? ma uit la Sequencer::recordnote() din varianele vechi de zyn
- me->tmpevent.par2 = value;
- me->tmpevent.channel = chan;
- me->writeevent(&me->miditrack[(int)ntrack].record, &me->tmpevent);
-}
-
-void MIDIFile::parsepitchwheel(char ntrack, char chan, unsigned int dt)
-{
- unsigned char valhi, vallo;
- vallo = getbyte();
- valhi = getbyte();
-
- if(chan >= NUM_MIDI_CHANNELS)
- return;
-
- int value = (int)valhi * 128 + vallo;
-
- printf("[dt %d] Pitch wheel:%d\n", dt, value);
-}
-
-void MIDIFile::parsemetaevent(unsigned char mtype, unsigned char mlength)
-{
- int oldmidifilek = midifilek;
- printf("meta-event type=0x%x length=%d\n", mtype, mlength);
-
-
-
- midifilek = oldmidifilek + mlength;
-}
-
-void MIDIFile::add_dt(char ntrack, unsigned int dt)
-{
- me->tmpevent.deltatime = convertdt(dt);
- me->tmpevent.type = 255;
- me->tmpevent.par1 = 0;
- me->tmpevent.par2 = 0;
- me->tmpevent.channel = 0;
- me->writeevent(&me->miditrack[(int)ntrack].record, &me->tmpevent);
-}
-
-
-unsigned int MIDIFile::convertdt(unsigned int dt)
-{
- double result = dt;
- printf("DT=%d\n", dt);
-
- return (int) (result * 15.0);
-}
-
-
-void MIDIFile::clearmidifile()
-{
- if(midifile != NULL)
- delete (midifile);
- midifile = NULL;
- midifilesize = 0;
- midifilek = 0;
- midieof = false;
-}
-
-unsigned char MIDIFile::getbyte()
-{
- if(midifilek >= midifilesize) {
- midieof = true;
- return 0;
- }
-
-/// printf("(%d) ",midifile[midifilek]);
- return midifile[midifilek++];
-}
-
-unsigned char MIDIFile::peekbyte()
-{
- if(midifilek >= midifilesize) {
- midieof = true;
- return 0;
- }
- return midifile[midifilek];
-}
-
-unsigned int MIDIFile::getint32()
-{
- unsigned int result = 0;
- for(int i = 0; i < 4; i++)
- result = result * 256 + getbyte();
- ;
- if(midieof)
- result = 0;
- return result;
-}
-
-unsigned short int MIDIFile::getint16()
-{
- unsigned short int result = 0;
- for(int i = 0; i < 2; i++)
- result = result * 256 + getbyte();
- ;
- if(midieof)
- result = 0;
- return result;
-}
-
-unsigned int MIDIFile::getvarint32()
-{
- unsigned long result = 0;
-/// printf("\n[start]");
-
- if((result = getbyte()) & 0x80) {
- result &= 0x7f;
- uint8_t b;
- do {
- b = getbyte();
- result = (result << 7) + (b & 0x7f);
- } while(b & 0x80);
- }
-/// printf("[end - result= %d]\n",result);
- return result;
-}
-
-
-void MIDIFile::skipnbytes(int n)
-{
- midifilek += n;
- if(midifilek >= midifilesize) {
- midifilek = midifilesize - 1;
- midieof = true;
- }
-}
-
diff --git a/src/Seq/MIDIFile.h b/src/Seq/MIDIFile.h
@@ -1,89 +0,0 @@
-/*
- ZynAddSubFX - a software synthesizer
-
- MIDIFile.h - MIDI file loader
- Copyright (C) 2003-2005 Nasca Octavian Paul
- Author: Nasca Octavian Paul
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License
- as published by the Free Software Foundation.
-
- 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 (version 2 or later) for more details.
-
- You should have received a copy of the GNU General Public License (version 2)
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-#ifndef MIDIFILE_H
-#define MIDIFILE_H
-
-#include "../globals.h"
-#include "MIDIEvents.h"
-
-/**MIDI file loader*/
-class MIDIFile
-{
- public:
- MIDIFile();
- ~MIDIFile();
-
- /**Loads the given file
- * @param filename The name of the file to load
- * @return -1 if there is an error, otherwise 0*/
- int loadfile(const char *filename);
-
- //returns -1 if there is an error, otherwise 0
- int parsemidifile(MIDIEvents *me_);
-
- private:
- MIDIEvents *me;
-
- unsigned char *midifile;
- int midifilesize, midifilek;
- bool midieof;
-
- //returns -1 if there is an error, otherwise 0
- int parsetrack(int ntrack);
-
- void parsenoteoff(char ntrack, char chan, unsigned int dt);
- void parsenoteon(char ntrack, char chan, unsigned int dt);
- void parsecontrolchange(char ntrack, char chan, unsigned int dt);
- void parsepitchwheel(char ntrack, char chan, unsigned int dt);
- void parsemetaevent(unsigned char mtype, unsigned char mlength);
-
- void add_dt(char ntrack, unsigned int dt);
-
- void clearmidifile();
-
- //convert the delta-time to internal format
- unsigned int convertdt(unsigned int dt);
-
- /* Low Level MIDIfile functions */
-
- //get a byte from the midifile
- unsigned char getbyte();
-
- //peek the current byte from the midifile
- unsigned char peekbyte();
-
- //get a set of 4 bytes from the midifile
- unsigned int getint32();
-
- //get a word of 2 bytes from the midifile
- unsigned short int getint16();
-
- //read a variable length quantity
- unsigned int getvarint32();
-
- //skip some bytes
- void skipnbytes(int n);
-};
-
-#endif
-
diff --git a/src/Seq/Sequencer.cpp b/src/Seq/Sequencer.cpp
@@ -1,190 +0,0 @@
-/*
- ZynAddSubFX - a software synthesizer
-
- Sequencer.cpp - The Sequencer
- Copyright (C) 2003-2005 Nasca Octavian Paul
- Author: Nasca Octavian Paul
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License
- as published by the Free Software Foundation.
-
- 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 (version 2 or later) for more details.
-
- You should have received a copy of the GNU General Public License (version 2)
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-*/
-
-#include <math.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <sys/time.h>
-#include <time.h>
-
-#include "Sequencer.h"
-
-
-
-Sequencer::Sequencer()
-{
- play = 0;
- for(int i = 0; i < NUM_MIDI_TRACKS; i++) {
- miditrack[i].track.first = NULL;
- miditrack[i].track.current = NULL;
- miditrack[i].track.size = 0;
- miditrack[i].track.length = 0.0;
- miditrack[i].record.first = NULL;
- miditrack[i].record.current = NULL;
- miditrack[i].record.size = 0;
- miditrack[i].record.length = 0.0;
-
- nextevent[i].time = 0.0;
- resettime(&playtime[i]);
- }
-
- setplayspeed(0);
-}
-
-Sequencer::~Sequencer()
-{
- for(int i = 0; i < NUM_MIDI_TRACKS; i++) {
- deletelist(&miditrack[i].track);
- deletelist(&miditrack[i].record);
- }
-}
-
-
-int Sequencer::importmidifile(const char *filename)
-{
- if(midifile.loadfile(filename) < 0)
- return -1;
-
- for(int i = 0; i < NUM_MIDI_TRACKS; i++)
- deletelist(&miditrack[i].record);
- ;
- if(midifile.parsemidifile(this) < 0)
- return -1;
-
- //copy the "record" track to the main track
- for(int i = 0; i < NUM_MIDI_TRACKS; i++) {
- deletelist(&miditrack[i].track);
- miditrack[i].track = miditrack[i].record;
- deletelistreference(&miditrack[i].record);
- }
- return 0;
-}
-
-
-
-void Sequencer::startplay()
-{
- if(play != 0)
- return;
- for(int i = 0; i < NUM_MIDI_TRACKS; i++)
- resettime(&playtime[i]);
-
- for(int i = 0; i < NUM_MIDI_TRACKS; i++)
- rewindlist(&miditrack[i].track);
- ;
- play = 1;
-}
-void Sequencer::stopplay()
-{
- if(play == 0)
- return;
- play = 0;
-}
-
-// ************ Player stuff ***************
-
-int Sequencer::getevent(char ntrack,
- int *midich,
- int *type,
- int *par1,
- int *par2)
-{
- *type = 0;
- if(play == 0)
- return -1;
-
- //test
-// if (ntrack!=0) return(-1);
-
- updatecounter(&playtime[(int)ntrack]);
-
-// printf("%g %g\n",nextevent[ntrack].time,playtime[ntrack].abs);
-
- if(nextevent[(int)ntrack].time < playtime[(int)ntrack].abs)
- readevent(&miditrack[(int)ntrack].track, &nextevent[(int)ntrack].ev);
- else
- return -1;
- if(nextevent[(int)ntrack].ev.type == -1)
- return -1;
-// printf("********************************\n");
-
- //sa pun aici o protectie. a.i. daca distanta dintre timpul curent si eveliment e prea mare (>1sec) sa elimin nota
-
- if(ntrack == 1)
- printf("_ %f %.2f (%d)\n", nextevent[(int)ntrack].time,
- playtime[(int)ntrack].abs, nextevent[(int)ntrack].ev.par2);
-
- *type = nextevent[(int)ntrack].ev.type;
- *par1 = nextevent[(int)ntrack].ev.par1;
- *par2 = nextevent[(int)ntrack].ev.par2;
- *midich = nextevent[(int)ntrack].ev.channel;
-
-
- double dt = nextevent[(int)ntrack].ev.deltatime * 0.0001 * realplayspeed;
- printf("zzzzzzzzzzzzzz[%d] %d\n",
- ntrack,
- nextevent[(int)ntrack].ev.deltatime);
- nextevent[(int)ntrack].time += dt;
-
-// printf("%f - %d %d \n",nextevent[ntrack].time,par1,par2);
- return 0; //?? sau 1
-}
-
-/************** Timer stuff ***************/
-
-void Sequencer::resettime(timestruct *t)
-{
- t->abs = 0.0;
- t->rel = 0.0;
-
- timeval tval;
-
- t->last = 0.0;
-#ifndef OS_WINDOWS
- if(gettimeofday(&tval, NULL) == 0)
- t->last = tval.tv_sec + tval.tv_usec * 0.000001;
-#endif
-}
-
-void Sequencer::updatecounter(timestruct *t)
-{
- timeval tval;
- double current = 0.0;
-#ifndef OS_WINDOWS
- if(gettimeofday(&tval, NULL) == 0)
- current = tval.tv_sec + tval.tv_usec * 0.000001;
-#endif
-
- t->rel = current - t->last;
- t->abs += t->rel;
- t->last = current;
-
-// printf("%f %f %f\n",t->last,t->abs,t->rel);
-}
-
-void Sequencer::setplayspeed(int speed)
-{
- playspeed = speed;
- realplayspeed = pow(10.0, speed / 128.0);
-}
-
diff --git a/src/Seq/Sequencer.h b/src/Seq/Sequencer.h
@@ -1,90 +0,0 @@
-/*
- ZynAddSubFX - a software synthesizer
-
- Sequencer.h - The Sequencer
- Copyright (C) 2003-2005 Nasca Octavian Paul
- Author: Nasca Octavian Paul
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of version 2 of the GNU General Public License
- as published by the Free Software Foundation.
-
- 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 (version 2 or later) for more details.
-
- You should have received a copy of the GNU General Public License (version 2)
- along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-#ifndef SEQUENCER_H
-#define SEQUENCER_H
-
-#include "../globals.h"
-#include "MIDIEvents.h"
-#include "MIDIFile.h"
-
-/**The Sequencer
- * \todo restructure some of this code*/
-class Sequencer:public MIDIEvents
-{
- public:
- /**Constructor*/
- Sequencer();
- /**Destructor*/
- ~Sequencer();
-
- //these functions are called by the master and are ignored if the recorder/player are stopped
- void recordnote(char chan, char note, char vel);
- void recordcontroller(char chan, unsigned int type, int par);
-
- /**Gets an event \todo better description
- *
- * this is only for player
- * @return 1 if this must be called at least once more
- * 0 if there are no more notes for the current time
- * -1 if there are no notes*/
- int getevent(char ntrack, int *midich, int *type, int *par1, int *par2);
-
- /**Imports a given midifile
- * @return 0 if ok or -1 if there is a error loading file*/
- int importmidifile(const char *filename);
-
- void startplay();
- void stopplay();
-
-
- int play;
- int playspeed; //viteza de rulare (0.1x-10x), 0=1.0x, 128=10x
- void setplayspeed(int speed);
-
- private:
-
- MIDIFile midifile;
-
- /* Timer */
- struct timestruct {
- double abs; //the time from the begining of the track
- double rel; //the time difference between the last and the current event
- double last; //the time of the last event (absolute, since 1 Jan 1970)
- //these must be double, because the float's precision is too low
- //and all these represent the time in seconds
- } playtime[NUM_MIDI_TRACKS];
-
- void resettime(timestruct *t);
- void updatecounter(timestruct *t); //this updates the timer values
-
- /* Player only*/
-
- struct {
- event ev;
- double time;
- } nextevent[NUM_MIDI_TRACKS];
-
- double realplayspeed;
-};
-
-#endif
-
diff --git a/src/UI/CMakeLists.txt b/src/UI/CMakeLists.txt
@@ -13,7 +13,6 @@ set(UI_fl_files
PartUI.fl
PresetsUI.fl
ResonanceUI.fl
- SeqUI.fl
SUBnoteUI.fl
VirKeyboard.fl
)
diff --git a/src/UI/MasterUI.fl b/src/UI/MasterUI.fl
@@ -42,9 +42,6 @@ decl {\#include "PartUI.h"} {public
decl {\#include "MicrotonalUI.h"} {public
}
-decl {\#include "SeqUI.h"} {public
-}
-
decl {\#include "PresetsUI.h"} {public
}
@@ -638,16 +635,6 @@ if (result!=0) fl_alert("Error: Could not save the file.");}
}
}
Submenu {} {
- label {&Sequencer}
- xywh {0 0 100 20} hide
- } {
- MenuItem {} {
- label {Show &Sequencer...}
- callback {sequi->show();}
- xywh {0 0 100 20}
- }
- }
- Submenu {} {
label Misc
xywh {10 10 100 20}
} {
@@ -1643,7 +1630,6 @@ microtonalui=new MicrotonalUI(&master->microtonal);
virkeyboard=new VirKeyboard(master);
bankui=new BankUI(master,&npart);
configui=new ConfigUI();
-sequi=new SeqUI(master);
make_window();
presetsui=new PresetsUI();
@@ -1665,7 +1651,6 @@ delete virkeyboard;
delete microtonalui;
delete bankui;
delete configui;
-delete sequi;
delete presetsui;
delete panelwindow;
@@ -1810,7 +1795,6 @@ bankui->hide();} {}
}
decl {Master *master;} {}
decl {MicrotonalUI *microtonalui;} {}
- decl {SeqUI *sequi;} {}
decl {BankUI *bankui;} {}
decl {int ninseff,npart;} {}
decl {int nsyseff;} {}
diff --git a/src/UI/SeqUI.fl b/src/UI/SeqUI.fl
@@ -1,73 +0,0 @@
-# data file for the Fltk User Interface Designer (fluid)
-version 1.0105
-header_name {.h}
-code_name {.cc}
-decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {}
-
-decl {//License: GNU GPL version 2 or later} {}
-
-decl {\#include "../globals.h"} {public
-}
-
-decl {\#include "../Misc/Master.h"} {public
-}
-
-decl {\#include "WidgetPDial.h"} {public
-}
-
-class SeqUI {} {
- Function {make_window()} {} {
- Fl_Window seqwin {
- label {Sequencer - ZynAddSubFX}
- xywh {104 235 280 265} type Double hide
- } {
- Fl_Group {} {
- label Player
- xywh {120 20 100 65} box ENGRAVED_BOX labelfont 1
- } {
- Fl_Button playbutton {
- label Play
- callback {o->deactivate();
-stopbutton_play->activate();
-
-master->seq.startplay();}
- tooltip {Start Playing} xywh {130 30 30 30} box DIAMOND_UP_BOX color 79 labelfont 1 labelsize 13 align 2
- }
- Fl_Button stopbutton_play {
- label Stop
- callback {o->deactivate();
-playbutton->activate();
-
-master->seq.stopplay();}
- tooltip {Stop Playing} xywh {175 29 30 31} box THIN_UP_BOX color 4 labelfont 1 labelsize 13 align 2 deactivate
- }
- }
- Fl_Button {} {
- label {Open test.mid}
- callback {master->seq.importmidifile("test.mid");}
- xywh {20 25 75 55} align 128
- }
- Fl_Value_Slider {} {
- label {Play speed}
- callback {master->seq.setplayspeed((int) o->value());}
- xywh {15 105 190 20} type {Horz Knob} minimum -128 maximum 128 step 1
- code0 {o->value(master->seq.playspeed);}
- }
- Fl_Box {} {
- label {This is not finished} selected
- xywh {25 155 225 90} labelfont 1 labelsize 22 align 128
- }
- }
- }
- Function {SeqUI(Master *master_)} {open
- } {
- code {master=master_;
-
-make_window();} {}
- }
- decl {Master *master} {}
- Function {show()} {open
- } {
- code {seqwin->show();} {}
- }
-}
diff --git a/src/UI/VirKeyboard.fl b/src/UI/VirKeyboard.fl
@@ -21,9 +21,6 @@ decl {\#include "../globals.h"} {public
decl {\#include "../Misc/Master.h"} {public
}
-decl {\#include "../Input/MidiIn.h"} {public
-}
-
decl {\#include "WidgetPDial.h"} {public
}
diff --git a/src/main.cpp b/src/main.cpp
@@ -29,12 +29,7 @@
#include <unistd.h>
#include <pthread.h>
-#if OS_LINUX || OS_CYGWIN
#include <getopt.h>
-#elif OS_WINDOWS
-#include <winbase.h>
-#include <windows.h>
-#endif
#include "Misc/Master.h"
#include "Misc/Util.h"
@@ -119,53 +114,6 @@ void *thread3(void *v)
return 0;
}
-//this code is disabled for Nio testing
-//it should get moved out of here into the nio system soon
-#if 0
-/*
- * Sequencer thread (test)
- */
-void *thread4(void *arg)
-{
- while(Pexitprogram == 0) {
- int type, par1, par2, again, midichan;
- for(int ntrack = 0; ntrack < NUM_MIDI_TRACKS; ntrack++) {
- if(master->seq.play == 0)
- break;
- do {
- again = master->seq.getevent(ntrack,
- &midichan,
- &type,
- &par1,
- &par2);
-// printf("ntrack=%d again=%d\n",ntrack,again);
- if(type > 0) {
-// printf("%d %d %d %d %d\n",type,midichan,chan,par1,par2);
-
-// if (cmdtype==MidiController) master->SetController(cmdchan,cmdparams[0],cmdparams[1]);
-
-
-
- pthread_mutex_lock(&master->mutex);
- if(type == 1) { //note_on or note_off
- if(par2 != 0)
- master->NoteOn(midichan, par1, par2);
- else
- master->NoteOff(midichan, par1);
- }
- pthread_mutex_unlock(&master->mutex);
- }
- } while(again > 0);
- }
-//if (!realtime player) atunci fac asta
-//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- os_sleep(1000);
- }
-
- return 0;
-}
-#endif
-
void exitprogram();
//cleanup on signaled exit
@@ -225,32 +173,6 @@ void exitprogram()
delete [] denormalkillbuf;
}
-#if OS_WINDOWS
-#define ARGSIZE 100
-char winoptarguments[ARGSIZE];
-char getopt(int argc, char *argv[], const char *shortopts, int *index)
-{
- winoptarguments[0] = 0;
- char result = 0;
-
- if(*index >= argc)
- return -1;
-
- if(strlen(argv[*index]) == 2)
- if(argv[*index][0] == '-') {
- result = argv[*index][1];
- if(*index + 1 < argc)
- snprintf(winoptarguments, ARGSIZE, "%s", argv[*index + 1]);
- }
- (*index)++;
- return result;
-}
-int opterr = 0;
-#undef ARGSIZE
-
-#endif
-
-#ifndef VSTAUDIOOUT
int main(int argc, char *argv[])
{
@@ -264,11 +186,7 @@ int main(int argc, char *argv[])
cerr << "This program is free software (GNU GPL v.2 or later) and \n";
cerr << "it comes with ABSOLUTELY NO WARRANTY.\n" << endl;
if(argc == 1)
-#if OS_LINUX || OS_CYGWIN
cerr << "Try 'zynaddsubfx --help' for command-line options." << endl;
-#else //assuming windows
- cerr << "Try 'zynaddsubfx -h' for command-line options.\n" << endl;
-#endif
/* Get the settings from the Config*/
SAMPLE_RATE = config.cfg.SampleRate;
@@ -283,7 +201,6 @@ int main(int argc, char *argv[])
denormalkillbuf[i] = (RND - 0.5) * 1e-16;
/* Parse command-line options */
-#if OS_LINUX || OS_CYGWIN
struct option opts[] = {
{"load", 2, NULL, 'l'},
{"load-instrument", 2, NULL, 'L'},
@@ -301,7 +218,6 @@ int main(int argc, char *argv[])
{"input", 1, NULL, 'I'},
{0, 0, 0, 0}
};
-#endif
opterr = 0;
int option_index = 0, opt, exitwithhelp = 0;
@@ -309,16 +225,8 @@ int main(int argc, char *argv[])
while(1) {
/**\todo check this process for a small memory leak*/
-#if OS_LINUX || OS_CYGWIN
opt = getopt_long(argc, argv, "l:L:r:b:o:I:O:N:haSDUY", opts, &option_index);
char *optarguments = optarg;
-#elif OS_WINDOWS
- opt = getopt(argc, argv, "l:L:r:b:o:I:O:N:haSDUY", &option_index);
- char *optarguments = &winoptarguments[0];
-#else
- char *optarguments = NULL;
-#error Undefined OS
-#endif
#define GETOP(x) if(optarguments) x = optarguments
#define GETOPNUM(x) if(optarguments) x = atoi(optarguments)
@@ -420,10 +328,6 @@ int main(int argc, char *argv[])
<< " -O , --output\t\t\t\t Set Output Engine\n"
<< " -I , --input\t\t\t\t Set Input Engine" << endl;
-#if OS_WINDOWS
- cout << "nWARNING: On Windows systems, only short comandline parameters works.\n"
- << " eg. instead '--buffer-size=512' use '-b 512'" << endl;
-#endif
return 0;
}
@@ -482,215 +386,11 @@ int main(int argc, char *argv[])
pthread_create(&thr3, NULL, thread3, (void*)!ioGood);
#endif
-// pthread_create(&thr4, NULL, thread4, NULL);
-#ifdef WINMIDIIN
- InitWinMidi(master);
-#endif
-
//TODO look into a conditional variable here, it seems to match usage
while(Pexitprogram == 0) {
-#ifdef OS_LINUX
usleep(100000);
-#elif OS_WINDOWS
- Sleep(100);
-#endif
}
-#ifdef WINMIDIIN
- StopWinMidi();
-#endif
-
exitprogram();
return 0;
}
-
-
-#else
-
-#include "Output/VSTaudiooutput.h"
-
-#define main main_plugin
-extern "C" __declspec(dllexport) AEffect * main_plugin(
- audioMasterCallback audioMaster);
-
-int instances = -1;
-
-AEffect *main(audioMasterCallback audioMaster)
-{
-// if (audioMaster(0,audioMasterVersion,0,0,0,0)!=0) {
-// return(0);
-// };
-
- if(instances == -1) {
- Midi = new NULLMidiIn();
- denormalkillbuf = new REALTYPE [SOUND_BUFFER_SIZE];
- for(int i = 0; i < SOUND_BUFFER_SIZE; i++)
- denormalkillbuf[i] = (RND - 0.5) * 1e-16;
- instances = 0;
- }
-
- if(instances != 0)
- return 0; //don't allow multiple instances
-
- AudioEffect *sintetizator = new VSTSynth(audioMaster);
-
- return sintetizator->getAeffect();
-}
-
-void *hInstance;
-BOOL WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID lpvReserved)
-{
- hInstance = hInst;
- return 1;
-}
-
-void *thread(void *arg)
-{
- VSTSynth *vs = (VSTSynth *) arg;
-
- /* FILE *a=fopen("aaaa1","a");
- fprintf(a,"%lx %lx %lx -i=%d\n",vs,0,vs->vmaster,instances);
- fflush(a);fclose(a);
- */
-
- vs->ui = new MasterUI(vs->vmaster, &vs->Pexitprogram);
-
- /* a=fopen("aaaa1","a");
- fprintf(a,"%lx %lx %lx\n",vs,vs->ui->master,vs->vmaster);
- fflush(a);fclose(a);
- */
-
- vs->ui->showUI();
-
- /* a=fopen("aaaa1","a");
- fprintf(a,"%lx %lx %lx\n",vs,vs->ui,vs->vmaster);
- fflush(a);fclose(a);
- */
-
- while(vs->Pexitprogram == 0)
- Fl::wait(0.01);
-
- delete (vs->ui);
- Fl::wait(0.01);
-
- /* a=fopen("aaaa1","a");
- fprintf(a,"EXIT\n");
- fflush(a);fclose(a);
- */
-
-
- pthread_exit(0);
- return 0;
-}
-
-//Parts of the VSTSynth class
-VSTSynth::VSTSynth(audioMasterCallback audioMaster):AudioEffectX(audioMaster, 1,
- 0)
-{
- instances++;
-
- if(audioMaster) {
- setNumInputs(0);
- setNumOutputs(2);
- setUniqueID('ZASF');
- canProcessReplacing();
-// hasVu(false);
-// hasClip(false);
-
- isSynth(true);
-
- programsAreChunks(true);
- }
-
-
- SAMPLE_RATE = config.cfg.SampleRate;
- SOUND_BUFFER_SIZE = config.cfg.SoundBufferSize;
- OSCIL_SIZE = config.cfg.OscilSize;
- swaplr = config.cfg.SwapStereo;
- this->Pexitprogram = 0;
-
- this->vmaster = new Master();
- this->vmaster->swaplr = swaplr;
-
-
-// FILE *a=fopen("aaaa0","a");
-// fprintf(a,"%lx %lx %lx\n",this,this->ui,this->ui->masterwindow);
-// fflush(a);fclose(a);
-
- pthread_create(&this->thr, NULL, thread, this);
-
-// suspend();
-}
-
-
-
-VSTSynth::~VSTSynth()
-{
- this->Pexitprogram = 1;
-
- Sleep(200); //wait the thread to finish
-
-// pthread_mutex_lock(&vmaster->mutex);
-
-
- delete (this->vmaster);
-
- instances--;
-}
-
-long VSTSynth::processEvents(VstEvents *events)
-{
- for(int i = 0; i < events->numEvents; i++) {
- //debug stuff
-// FILE *a=fopen("events","a");
-// fprintf(a,"%lx\n",events->events[i]->type);
-// fflush(a);fclose(a);
-
- if((events->events[i])->type != kVstMidiType)
- continue;
- VstMidiEvent *ev = (VstMidiEvent *) events->events[i];
- unsigned char *data = (unsigned char *)ev->midiData;
- int status = data[0] / 16;
- int cmdchan = data[0] & 0x0f;
- int cntl;
-
- pthread_mutex_lock(&vmaster->mutex);
- switch(status) {
- case 0x8:
- vmaster->NoteOff(cmdchan, data[1] & 0x7f);
- break;
- case 0x9:
- if(data[2] == 0)
- vmaster->NoteOff(cmdchan, data[1] & 0x7f);
- else
- vmaster->NoteOn(cmdchan, data[1] & 0x7f, data[2] & 0x7f);
- break;
- case 0xB:
- cntl = Midi->getcontroller(data[1] & 0x7f);
- vmaster->SetController(cmdchan, cntl, data[2] & 0x7f);
- break;
- case 0xE:
- vmaster->SetController(cmdchan, C_pitchwheel, data[1] + data[2]
- * (long int) 128 - 8192);
- break;
- }
- pthread_mutex_unlock(&vmaster->mutex);
- }
-
- return 1;
-}
-
-long VSTSynth::getChunk(void **data, bool isPreset)
-{
- int size = 0;
- size = vmaster->getalldata((char **)data);
- return (long)size;
-}
-
-long VSTSynth::setChunk(void *data, long size, bool isPreset)
-{
- vmaster->putalldata((char *)data, size);
- return 0;
-}
-#endif
-