From 5591f1602e6171492f5e4620e67d3addeacad7aa Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 20 Sep 2011 16:08:52 +0200 Subject: VSTi plugin version. --- vst/Makefile | 43 +++++++ vst/README | 11 ++ vst/constants.h | 32 +++++ vst/drumgizmo_vst.cc | 349 +++++++++++++++++++++++++++++++++++++++++++++++++++ vst/drumgizmo_vst.h | 94 ++++++++++++++ vst/input_vst.cc | 112 +++++++++++++++++ vst/input_vst.h | 60 +++++++++ vst/output_vst.cc | 86 +++++++++++++ vst/output_vst.h | 54 ++++++++ 9 files changed, 841 insertions(+) create mode 100644 vst/Makefile create mode 100644 vst/README create mode 100644 vst/constants.h create mode 100644 vst/drumgizmo_vst.cc create mode 100644 vst/drumgizmo_vst.h create mode 100644 vst/input_vst.cc create mode 100644 vst/input_vst.h create mode 100644 vst/output_vst.cc create mode 100644 vst/output_vst.h (limited to 'vst') diff --git a/vst/Makefile b/vst/Makefile new file mode 100644 index 0000000..5400acd --- /dev/null +++ b/vst/Makefile @@ -0,0 +1,43 @@ +VST_BASE = vstsdk2.4 +VST_SRC_BASE = ${VST_BASE}/public.sdk/source/vst2.x/ +VST_SRC = \ + ${VST_SRC_BASE}/audioeffectx.cpp \ + ${VST_SRC_BASE}/audioeffect.cpp \ + ${VST_SRC_BASE}/vstplugmain.cpp + +DG_BASE = ../ +DG_SRC = \ + ${DG_BASE}/src/audiofile.cc \ + ${DG_BASE}/src/channel.cc \ + ${DG_BASE}/src/channelmixer.cc \ + ${DG_BASE}/src/drumgizmo.cc \ + ${DG_BASE}/src/drumkit.cc \ + ${DG_BASE}/src/drumkitparser.cc \ + ${DG_BASE}/src/events.cc \ + ${DG_BASE}/src/instrument.cc \ + ${DG_BASE}/src/instrumentparser.cc \ + ${DG_BASE}/src/midimapparser.cc \ + ${DG_BASE}/src/midimapper.cc \ + ${DG_BASE}/src/mutex.cc \ + ${DG_BASE}/src/path.cc \ + ${DG_BASE}/src/sample.cc \ + ${DG_BASE}/src/saxparser.cc \ + ${DG_BASE}/src/velocity.cc +DG_FLAGS = -I../include -I../src + +EXPAT_BASE = expat +EXPAT_FLAGS = -I${EXPAT_BASE}/Source/lib -L${EXPAT_BASE}/Bin -lexpat + +SNDFILE_BASE = libsndfile +SNDFILE_FLAGS = -I${SNDFILE_BASE}\include -L${SNDFILE_BASE}/bin -lsndfile-1 + +SRC = \ + drumgizmo_vst.cc \ + input_vst.cc \ + output_vst.cc + +all: + g++ -g -Wall -DWIN32 ${DG_FLAGS} ${EXPAT_FLAGS} ${SNDFILE_FLAGS} -I${VST_BASE} ${DG_SRC} ${VST_SRC} ${SRC} -shared -o drumgizmo_vst.dll -Wl,--out-implib,libdrumgizmo_vst.a + +clean: + rm -f drumgizmo_vst.dll libdrumgizmo_vst.a \ No newline at end of file diff --git a/vst/README b/vst/README new file mode 100644 index 0000000..0d08c94 --- /dev/null +++ b/vst/README @@ -0,0 +1,11 @@ +Get http://expat.sourceforge.net/ and http://www.mega-nerd.com/libsndfile/ + in their win32 binary versions. +Unpack them in the vst/ subfolders: expat and libsndfile. + +Get vstsdk2.4 and unpack it in the vstsdk2.4 subfolder. + +Use mingw and compile with 'make'. + +Copy libexpat.dll and libsndfile-1.dll to the system32 folder. + +Run the DAW with drumgizmo_vst.dll. \ No newline at end of file diff --git a/vst/constants.h b/vst/constants.h new file mode 100644 index 0000000..ff07c54 --- /dev/null +++ b/vst/constants.h @@ -0,0 +1,32 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * constants.h + * + * Tue Sep 20 11:49:29 CEST 2011 + * Copyright 2011 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of DrumGizmo. + * + * DrumGizmo 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. + * + * DrumGizmo 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 DrumGizmo; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#ifndef __DRUMGIZMO_CONSTANTS_H__ +#define __DRUMGIZMO_CONSTANTS_H__ + +#define NUM_OUTPUTS 16 + +#endif/*__DRUMGIZMO_CONSTANTS_H__*/ diff --git a/vst/drumgizmo_vst.cc b/vst/drumgizmo_vst.cc new file mode 100644 index 0000000..8e29f2d --- /dev/null +++ b/vst/drumgizmo_vst.cc @@ -0,0 +1,349 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * drumgizmo_vst.cc + * + * Tue Sep 20 08:22:48 CEST 2011 + * Copyright 2011 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of DrumGizmo. + * + * DrumGizmo 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. + * + * DrumGizmo 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 DrumGizmo; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include "drumgizmo_vst.h" + +#include "constants.h" + +#define NUM_PROGRAMS 0 +#define NUM_PARAMS 0 + +AudioEffect* createEffectInstance(audioMasterCallback audioMaster) +{ + return new DrumGizmoVst(audioMaster); +} + +DrumGizmoVst::DrumGizmoVst(audioMasterCallback audioMaster) + : AudioEffectX(audioMaster, NUM_PROGRAMS, NUM_PARAMS) +{ + pos = 0; + buffer = NULL; + buffer_size = 0; + + output = new OutputVST(); + input = new InputVST(); + drumgizmo = new DrumGizmo(output, input); + + // initialize programs + //programs = new DrumGizmoVstProgram[kNumPrograms]; + //for(VstInt32 i = 0; i < 16; i++) channelPrograms[i] = i; + + //if(programs) setProgram(0); + + if(audioMaster) { + setNumInputs(0); // no audio inputs + setNumOutputs(NUM_OUTPUTS); + canProcessReplacing(); + isSynth(); + char id[] = "DGv1"; // Four bytes typecasted into an unsigned integer + setUniqueID((unsigned int)*id); + } + + initProcess(); + suspend(); +} + +DrumGizmoVst::~DrumGizmoVst() +{ + delete drumgizmo; + delete input; + delete output; +} + +void DrumGizmoVst::setProgram(VstInt32 program) {} +void DrumGizmoVst::setProgramName(char* name) {} +void DrumGizmoVst::getProgramName(char* name) { name[0] = '\0'; } + +void DrumGizmoVst::getParameterLabel(VstInt32 index, char* label) +{ + label[0] = '\0'; + /* + switch(index) + { + case kWaveform1: + case kWaveform2: + vst_strncpy(label, "Shape", kVstMaxParamStrLen); + break; + + case kFreq1: + case kFreq2: + vst_strncpy(label, "Hz", kVstMaxParamStrLen); + break; + + case kVolume1: + case kVolume2: + case kVolume: + vst_strncpy(label, "dB", kVstMaxParamStrLen); + break; + } + */ +} + +void DrumGizmoVst::getParameterDisplay(VstInt32 index, char* text) +{ + text[0] = 0; + /* + switch(index) + { + case kWaveform1: + if(fWaveform1 < .5) + vst_strncpy(text, "Sawtooth", kVstMaxParamStrLen); + else + vst_strncpy(text, "Pulse", kVstMaxParamStrLen); + break; + + case kFreq1: float2string(fFreq1, text, kVstMaxParamStrLen); break; + case kVolume1: dB2string(fVolume1, text, kVstMaxParamStrLen); break; + + case kWaveform2: + if(fWaveform2 < .5) + vst_strncpy(text, "Sawtooth", kVstMaxParamStrLen); + else + vst_strncpy(text, "Pulse", kVstMaxParamStrLen); + break; + + case kFreq2: float2string(fFreq2, text, kVstMaxParamStrLen); break; + case kVolume2: dB2string(fVolume2, text, kVstMaxParamStrLen); break; + case kVolume: dB2string(fVolume, text, kVstMaxParamStrLen); break; + } + */ +} + +void DrumGizmoVst::getParameterName(VstInt32 index, char* label) +{ + /* + switch(index) + { + case kWaveform1: vst_strncpy(label, "Wave 1", kVstMaxParamStrLen); break; + case kFreq1: vst_strncpy(label, "Freq 1", kVstMaxParamStrLen); break; + case kVolume1: vst_strncpy(label, "Levl 1", kVstMaxParamStrLen); break; + case kWaveform2: vst_strncpy(label, "Wave 2", kVstMaxParamStrLen); break; + case kFreq2: vst_strncpy(label, "Freq 2", kVstMaxParamStrLen); break; + case kVolume2: vst_strncpy(label, "Levl 2", kVstMaxParamStrLen); break; + case kVolume: vst_strncpy(label, "Volume", kVstMaxParamStrLen); break; + } + */ +} + +void DrumGizmoVst::setParameter(VstInt32 index, float value) +{ + /* + DrumGizmoVstProgram *ap = &programs[curProgram]; + switch(index) + { + case kWaveform1: fWaveform1 = ap->fWaveform1 = value; break; + case kFreq1: fFreq1 = ap->fFreq1 = value; break; + case kVolume1: fVolume1 = ap->fVolume1 = value; break; + case kWaveform2: fWaveform2 = ap->fWaveform2 = value; break; + case kFreq2: fFreq2 = ap->fFreq2 = value; break; + case kVolume2: fVolume2 = ap->fVolume2 = value; break; + case kVolume: fVolume = ap->fVolume = value; break; + } + */ +} + +float DrumGizmoVst::getParameter(VstInt32 index) +{ + float value = 0; + /* + switch(index) + { + case kWaveform1: value = fWaveform1; break; + case kFreq1: value = fFreq1; break; + case kVolume1: value = fVolume1; break; + case kWaveform2: value = fWaveform2; break; + case kFreq2: value = fFreq2; break; + case kVolume2: value = fVolume2; break; + case kVolume: value = fVolume; break; + } + */ + return value; +} + +bool DrumGizmoVst::getOutputProperties(VstInt32 index, + VstPinProperties* properties) +{ + if(index < NUM_OUTPUTS) + { + vst_strncpy(properties->label, "Channel ", 63); + char temp[11] = {0}; + int2string(index + 1, temp, 10); + vst_strncat(properties->label, temp, 63); + + properties->flags = kVstPinIsActive; + + return true; + } + return false; +} + +bool DrumGizmoVst::getProgramNameIndexed(VstInt32 category, VstInt32 index, + char* text) +{ + return false; +} + +bool DrumGizmoVst::getEffectName(char* name) +{ + vst_strncpy(name, "DrumGizmo", kVstMaxEffectNameLen); + return true; +} + +bool DrumGizmoVst::getVendorString(char* text) +{ + vst_strncpy(text, "Aasimon.org", kVstMaxVendorStrLen); + return true; +} + +bool DrumGizmoVst::getProductString(char* text) +{ + vst_strncpy(text, "Vst Synth", kVstMaxProductStrLen); + return true; +} + +VstInt32 DrumGizmoVst::getVendorVersion() +{ + return 1000; +} + +VstInt32 DrumGizmoVst::canDo(char* text) +{ + if(!strcmp(text, "receiveVstEvents")) return 1; + if(!strcmp(text, "receiveVstMidiEvent")) return 1; + if(!strcmp(text, "midiProgramNames")) return 1; + return -1; // explicitly can't do; 0 => don't know +} + +VstInt32 DrumGizmoVst::getNumMidiInputChannels() +{ + return 1; // we are monophonic +} + +VstInt32 DrumGizmoVst::getNumMidiOutputChannels() +{ + return 0; // no MIDI output back to Host app +} + +VstInt32 DrumGizmoVst::getMidiProgramName(VstInt32 channel, + MidiProgramName* mpn) +{ + VstInt32 prg = mpn->thisProgramIndex; + if(prg < 0 || prg >= 128) + return 0; + fillProgram(channel, prg, mpn); + if(channel == 9) + return 1; + return 128L; +} + +VstInt32 DrumGizmoVst::getCurrentMidiProgram(VstInt32 channel, + MidiProgramName* mpn) +{ + if(channel < 0 || channel >= 16 || !mpn) return -1; + VstInt32 prg = 0; + mpn->thisProgramIndex = prg; + fillProgram(channel, prg, mpn); + return prg; +} + +void DrumGizmoVst::fillProgram(VstInt32 channel, VstInt32 prg, + MidiProgramName* mpn) +{ + mpn->midiBankMsb = mpn->midiBankLsb = -1; + mpn->reserved = 0; + mpn->flags = 0; + + vst_strncpy(mpn->name, "Standard", 63); + mpn->midiProgram = 0; + mpn->parentCategoryIndex = 0; +} + +VstInt32 DrumGizmoVst::getMidiProgramCategory(VstInt32 channel, + MidiProgramCategory* cat) +{ + cat->parentCategoryIndex = -1; // -1:no parent category + cat->flags = 0; // reserved, none defined yet, zero. + VstInt32 category = cat->thisCategoryIndex; + vst_strncpy(cat->name, "Drums", 63); + return 1; +} + +bool DrumGizmoVst::hasMidiProgramsChanged(VstInt32 channel) +{ + return false; // updateDisplay() +} + +bool DrumGizmoVst::getMidiKeyName(VstInt32 channel, MidiKeyName* key) +// struct will be filled with information for 'thisProgramIndex' and +// 'thisKeyNumber' +// if keyName is "" the standard name of the key will be displayed. +// if false is returned, no MidiKeyNames defined for 'thisProgramIndex'. +{ + // key->thisProgramIndex; // >= 0. fill struct for this program index. + // key->thisKeyNumber; // 0 - 127. fill struct for this key number. + key->keyName[0] = 0; + key->reserved = 0; // zero + key->flags = 0; // reserved, none defined yet, zero. + return false; +} + +void DrumGizmoVst::setSampleRate(float sampleRate) +{ + AudioEffectX::setSampleRate(sampleRate); +} + +void DrumGizmoVst::setBlockSize(VstInt32 blockSize) +{ + AudioEffectX::setBlockSize(blockSize); +} + +void DrumGizmoVst::initProcess() +{ + drumgizmo->loadkit(getenv("DRUMGIZMO_DRUMKIT")); + drumgizmo->init(true); +} + +void DrumGizmoVst::processReplacing(float** inputs, float** outputs, + VstInt32 sampleFrames) +{ + output->setOutputs(outputs); + + if(buffer_size != sampleFrames) { + if(buffer) free(buffer); + buffer_size = sampleFrames; + buffer = (sample_t*)malloc(sizeof(sample_t) * buffer_size); + } + + drumgizmo->run(pos, buffer, buffer_size); + + pos += sampleFrames; +} + +VstInt32 DrumGizmoVst::processEvents(VstEvents* ev) +{ + input->processEvents(ev); + return 1; +} diff --git a/vst/drumgizmo_vst.h b/vst/drumgizmo_vst.h new file mode 100644 index 0000000..90c7bfc --- /dev/null +++ b/vst/drumgizmo_vst.h @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * drumgizmo_vst.h + * + * Tue Sep 20 08:22:48 CEST 2011 + * Copyright 2011 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of DrumGizmo. + * + * DrumGizmo 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. + * + * DrumGizmo 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 DrumGizmo; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#ifndef __DRUMGIZMO_DRUMGIZMO_VST_H__ +#define __DRUMGIZMO_DRUMGIZMO_VST_H__ + +#include + +#include + +#include "input_vst.h" +#include "output_vst.h" + +class DrumGizmoVst : public AudioEffectX +{ +public: + DrumGizmoVst(audioMasterCallback audioMaster); + ~DrumGizmoVst(); + + void processReplacing(float** inputs, float** outputs, VstInt32 sampleFrames); + VstInt32 processEvents(VstEvents* events); + + void setProgram(VstInt32 program); + void setProgramName(char* name); + void getProgramName(char* name); + bool getProgramNameIndexed(VstInt32 category, VstInt32 index, char* text); + + void setParameter(VstInt32 index, float value); + float getParameter(VstInt32 index); + void getParameterLabel(VstInt32 index, char* label); + void getParameterDisplay(VstInt32 index, char* text); + void getParameterName(VstInt32 index, char* text); + + void setSampleRate(float sampleRate); + void setBlockSize(VstInt32 blockSize); + + bool getOutputProperties(VstInt32 index, VstPinProperties* properties); + + bool getEffectName(char* name); + bool getVendorString(char* text); + bool getProductString(char* text); + VstInt32 getVendorVersion(); + VstInt32 canDo(char* text); + + VstInt32 getNumMidiInputChannels(); + VstInt32 getNumMidiOutputChannels(); + + VstInt32 getMidiProgramName(VstInt32 channel, + MidiProgramName* midiProgramName); + VstInt32 getCurrentMidiProgram(VstInt32 channel, + MidiProgramName* currentProgram); + VstInt32 getMidiProgramCategory(VstInt32 channel, + MidiProgramCategory* category); + bool hasMidiProgramsChanged(VstInt32 channel); + bool getMidiKeyName(VstInt32 channel, MidiKeyName* keyName); + +private: + void initProcess(); + // void noteOn(VstInt32 note, VstInt32 velocity, VstInt32 delta); + // void noteOff(); + void fillProgram(VstInt32 channel, VstInt32 prg, MidiProgramName* mpn); + + DrumGizmo *drumgizmo; + InputVST *input; + OutputVST *output; + size_t pos; + sample_t *buffer; + size_t buffer_size; +}; + +#endif/*__DRUMGIZMO_DRUMGIZMO_VST_H__*/ diff --git a/vst/input_vst.cc b/vst/input_vst.cc new file mode 100644 index 0000000..52015ad --- /dev/null +++ b/vst/input_vst.cc @@ -0,0 +1,112 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * input_vst.cc + * + * Tue Sep 20 10:40:10 CEST 2011 + * Copyright 2011 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of DrumGizmo. + * + * DrumGizmo 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. + * + * DrumGizmo 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 DrumGizmo; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include "input_vst.h" + +#include + +InputVST::InputVST() +{ + list = NULL; + listsize = 0; +} + +InputVST::~InputVST() +{ +} + +bool InputVST::init(Instruments &instruments) +{ + MidiMapParser p(getenv("DRUMGIZMO_MIDIMAP")); + if(p.parse()) {/*return false;*/} + mmap.midimap = p.midimap; + + for(size_t i = 0; i < instruments.size(); i++) { + mmap.instrmap[instruments[i].name()] = i; + } + + return true; +} + +void InputVST::setParm(std::string parm, std::string value) +{ +} + +bool InputVST::start() +{ + return true; +} + +void InputVST::stop() +{ +} + +void InputVST::pre() +{ +} + +event_t *InputVST::run(size_t pos, size_t len, size_t *nevents) +{ + *nevents = listsize; + return list; +} + +void InputVST::post() +{ + list = NULL; + listsize = 0; +} + +void InputVST::processEvents(VstEvents* ev) +{ + if(list == NULL) { + list = (event_t *)malloc(sizeof(event_t) * 1000); + // listsize = 0; + } + + for(VstInt32 i = 0; i < ev->numEvents; i++) { + if(ev->events[i]->type != kVstMidiType) continue; + + VstMidiEvent* event =(VstMidiEvent*)ev->events[i]; + char* midiData = event->midiData; + VstInt32 status = midiData[0] & 0xf0; // ignoring channel + if(status == 0x90) { // we only look at notes + VstInt32 note = midiData[1] & 0x7f; + VstInt32 velocity = midiData[2] & 0x7f; + + int i = mmap.lookup(note); + if(velocity && i != -1) { + list[listsize].type = TYPE_ONSET; + list[listsize].instrument = i; + list[listsize].velocity = velocity / 127.0; + list[listsize].offset = event->deltaFrames; + listsize++; + } + + } + event++; + } +} diff --git a/vst/input_vst.h b/vst/input_vst.h new file mode 100644 index 0000000..84df91a --- /dev/null +++ b/vst/input_vst.h @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * input_vst.h + * + * Tue Sep 20 10:40:10 CEST 2011 + * Copyright 2011 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of DrumGizmo. + * + * DrumGizmo 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. + * + * DrumGizmo 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 DrumGizmo; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#ifndef __DRUMGIZMO_INPUT_VST_H__ +#define __DRUMGIZMO_INPUT_VST_H__ + +#include +#include + +#include + +class InputVST : public AudioInputEngine { +public: + InputVST(); + ~InputVST(); + + bool init(Instruments &instruments); + + void setParm(std::string parm, std::string value); + + bool start(); + void stop(); + + void pre(); + event_t *run(size_t pos, size_t len, size_t *nevents); + void post(); + + void processEvents(VstEvents* ev); + + MidiMapper mmap; + +private: + event_t *list; + size_t listsize; +}; + +#endif/*__DRUMGIZMO_INPUT_VST_H__*/ diff --git a/vst/output_vst.cc b/vst/output_vst.cc new file mode 100644 index 0000000..5202ce7 --- /dev/null +++ b/vst/output_vst.cc @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * output_vst.cc + * + * Tue Sep 20 10:40:14 CEST 2011 + * Copyright 2011 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of DrumGizmo. + * + * DrumGizmo 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. + * + * DrumGizmo 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 DrumGizmo; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include "output_vst.h" + +#include + +#include "constants.h" + +OutputVST::OutputVST() +{ + outputs = NULL; +} + +OutputVST::~OutputVST() +{ +} + +bool OutputVST::init(Channels channels) +{ + return true; +} + +void OutputVST::setParm(std::string parm, std::string value) +{ +} + +bool OutputVST::start() +{ + return true; +} + +void OutputVST::stop() +{ +} + +void OutputVST::pre(size_t nsamples) +{ + if(!outputs) return; + + for(size_t ch = 0; ch < NUM_OUTPUTS; ch++) { + memset(outputs[ch], 0, nsamples * sizeof(sample_t)); + } +} + +void OutputVST::run(int ch, sample_t *samples, size_t nsamples) +{ + if(!outputs) return; + + if(ch < NUM_OUTPUTS) { + memcpy(outputs[ch], samples, nsamples * sizeof(sample_t)); + } +} + +void OutputVST::post(size_t nsamples) +{ + outputs = NULL; +} + +void OutputVST::setOutputs(float **outputs) +{ + this->outputs = outputs; +} diff --git a/vst/output_vst.h b/vst/output_vst.h new file mode 100644 index 0000000..fb98ad3 --- /dev/null +++ b/vst/output_vst.h @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * output_vst.h + * + * Tue Sep 20 10:40:14 CEST 2011 + * Copyright 2011 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of DrumGizmo. + * + * DrumGizmo 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. + * + * DrumGizmo 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 DrumGizmo; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#ifndef __DRUMGIZMO_OUTPUT_VST_H__ +#define __DRUMGIZMO_OUTPUT_VST_H__ + +#include + +class OutputVST : public AudioOutputEngine { +public: + OutputVST(); + ~OutputVST(); + + bool init(Channels channels); + + void setParm(std::string parm, std::string value); + + bool start(); + void stop(); + + void pre(size_t nsamples); + void run(int ch, sample_t *samples, size_t nsamples); + void post(size_t nsamples); + + void setOutputs(float **outputs); + +private: + sample_t **outputs; +}; + +#endif/*__DRUMGIZMO_OUTPUT_VST_H__*/ -- cgit v1.2.3