Skip to content

Commit

Permalink
Adding Vestige header.
Browse files Browse the repository at this point in the history
  • Loading branch information
reduz committed Jun 5, 2019
1 parent 157e084 commit ba1e934
Show file tree
Hide file tree
Showing 8 changed files with 318 additions and 1,704 deletions.
4 changes: 2 additions & 2 deletions drivers/vst2/audio_effect_provider_vst2.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "audio_effect_provider_vst2.h"
#include "drivers/vst2/vst/aeffectx.h"
#include "vestige.h"
#include <dirent.h>
/////////////////////////////////////////////

Expand Down Expand Up @@ -134,7 +134,7 @@ void AudioEffectProviderVST2::scan_effects(AudioEffectFactory *p_factory, ScanCa
}
}

VstIntPtr VSTCALLBACK AudioEffectProviderVST2::host(AEffect *effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void *ptr, float opt) {
intptr_t VESTIGECALLBACK AudioEffectProviderVST2::host(AEffect *effect, int32_t opcode, int32_t index, intptr_t value, void *ptr, float opt) {
long retval = 0;
//simple host for exploring plugin
switch (opcode) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/vst2/audio_effect_provider_vst2.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class AudioEffectProviderVST2 : public AudioEffectProvider {

static VstIntPtr VSTCALLBACK host(AEffect *effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void *ptr, float opt);
static intptr_t VESTIGECALLBACK host(AEffect *effect, int32_t opcode, int32_t index, intptr_t value, void *ptr, float opt);
friend class AudioEffectVST2;

static AEffect *open_vst_from_lib_handle(HINSTANCE libhandle, audioMasterCallback p_master_callback);
Expand Down
10 changes: 5 additions & 5 deletions drivers/vst2/audio_effect_vst2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ void AudioEffectVST2::close_user_interface() {
#define DEBUG_CALLBACK(m_text) printf("VST Callback: %s\n", m_text)
#endif

VstIntPtr VSTCALLBACK AudioEffectVST2::host(AEffect *effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void *ptr, float opt) {
intptr_t VESTIGECALLBACK AudioEffectVST2::host(AEffect *effect, int32_t opcode, int32_t index, intptr_t value, void *ptr, float opt) {

//simple host for exploring plugin
AudioEffectVST2 *vst_effect = effect ? (AudioEffectVST2 *)effect->resvd1 : 0;
Expand Down Expand Up @@ -338,7 +338,7 @@ VstIntPtr VSTCALLBACK AudioEffectVST2::host(AEffect *effect, VstInt32 opcode, Vs
}
return 0;

case DECLARE_VST_DEPRECATED(audioMasterWantMidi):
case audioMasterWantMidi:
DEBUG_CALLBACK("audioMasterWantMidi");
return 1;

Expand Down Expand Up @@ -806,7 +806,7 @@ Error AudioEffectVST2::open(const String &p_path, const String &p_unique_id, con
if (!effect) {
return ERR_CANT_OPEN;
}
effect->resvd1 = (VstIntPtr)this;
effect->resvd1 = this;
effect->dispatcher(effect, effOpen, 0, 0, NULL, 0.0f);
vst_version = effect->dispatcher(effect, effGetVstVersion, 0, 0, NULL, 0.0f);
effect->dispatcher(effect, effMainsChanged, 0, 0, NULL, 0.0f);
Expand Down Expand Up @@ -836,7 +836,7 @@ Error AudioEffectVST2::open(const String &p_path, const String &p_unique_id, con
effect->dispatcher(effect, effSetSampleRate, 0, 0, NULL, sampling_rate);
effect->dispatcher(effect, effSetBlockSize, 0, process_block_size, NULL, 0.0f);
_update_buffers();
effect->dispatcher(effect, effSetProcessPrecision, 0, kVstProcessPrecision32, NULL, 0.0f);
effect->dispatcher(effect, effSetProcessPrecision, 0, 0, NULL, 0.0f);
effect->dispatcher(effect, effMainsChanged, 0, 1, NULL, 0.0f);
effect->dispatcher(effect, effStartProcess, 0, 0, NULL, 0.0f);
return OK;
Expand All @@ -856,7 +856,7 @@ AudioEffectVST2::AudioEffectVST2() {
sampling_rate = 44100;
has_side_input = false;
stop_all_notes = false;
event_pointer_data = new unsigned char[sizeof(VstInt32) + sizeof(VstIntPtr) + sizeof(VstEvent *) * MAX_INPUT_EVENTS];
event_pointer_data = new unsigned char[sizeof(int32_t) + sizeof(intptr_t) + sizeof(VstEvent *) * MAX_INPUT_EVENTS];
event_pointers = (VstEvents *)event_pointer_data;
last_midi_channel = 0;

Expand Down
4 changes: 2 additions & 2 deletions drivers/vst2/audio_effect_vst2.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "engine/audio_effect_midi.h"
#include "globals/map.h"
#include "vst/aeffectx.h"
#include "vestige.h"

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
Expand Down Expand Up @@ -32,7 +32,7 @@ class AudioEffectVST2 : public AudioEffectMIDI {
String provider_id;
AEffect *effect;
HINSTANCE libhandle;
static VstIntPtr VSTCALLBACK host(AEffect *effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void *ptr, float opt);
static intptr_t VESTIGECALLBACK host(AEffect *effect, int32_t opcode, int32_t index, intptr_t value, void *ptr, float opt);

ResizeCallback resize_callback;
void *resize_userdata;
Expand Down
308 changes: 308 additions & 0 deletions drivers/vst2/vestige.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,308 @@
/*
* aeffectx.h - simple header to allow VeSTige compilation and eventually work
*
* Copyright (c) 2006 Javier Serrano Polo <jasp00/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* 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 (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/

#ifndef _AEFFECTX_H
#define _AEFFECTX_H

#include <stdint.h>
#include <stdio.h>
#include <string.h>

#define VESTIGECALLBACK __cdecl

#define CCONST(a, b, c, d) ((((int)a) << 24) | \
(((int)b) << 16) | \
(((int)c) << 8) | \
(((int)d) << 0))

const int audioMasterAutomate = 0;
const int audioMasterVersion = 1;
const int audioMasterCurrentId = 2;
const int audioMasterIdle = 3;
const int audioMasterPinConnected = 4;
// unsupported? 5
const int audioMasterWantMidi = 6;
const int audioMasterGetTime = 7;
const int audioMasterProcessEvents = 8;
const int audioMasterSetTime = 9;
const int audioMasterTempoAt = 10;
const int audioMasterGetNumAutomatableParameters = 11;
const int audioMasterGetParameterQuantization = 12;
const int audioMasterIOChanged = 13;
const int audioMasterNeedIdle = 14;
const int audioMasterSizeWindow = 15;
const int audioMasterGetSampleRate = 16;
const int audioMasterGetBlockSize = 17;
const int audioMasterGetInputLatency = 18;
const int audioMasterGetOutputLatency = 19;
const int audioMasterGetPreviousPlug = 20;
const int audioMasterGetNextPlug = 21;
const int audioMasterWillReplaceOrAccumulate = 22;
const int audioMasterGetCurrentProcessLevel = 23;
const int audioMasterGetAutomationState = 24;
const int audioMasterOfflineStart = 25;
const int audioMasterOfflineRead = 26;
const int audioMasterOfflineWrite = 27;
const int audioMasterOfflineGetCurrentPass = 28;
const int audioMasterOfflineGetCurrentMetaPass = 29;
const int audioMasterSetOutputSampleRate = 30;
// unsupported? 31
const int audioMasterGetSpeakerArrangement = 31; // deprecated in 2.4?
const int audioMasterGetVendorString = 32;
const int audioMasterGetProductString = 33;
const int audioMasterGetVendorVersion = 34;
const int audioMasterVendorSpecific = 35;
const int audioMasterSetIcon = 36;
const int audioMasterCanDo = 37;
const int audioMasterGetLanguage = 38;
const int audioMasterOpenWindow = 39;
const int audioMasterCloseWindow = 40;
const int audioMasterGetDirectory = 41;
const int audioMasterUpdateDisplay = 42;
const int audioMasterBeginEdit = 43;
const int audioMasterEndEdit = 44;
const int audioMasterOpenFileSelector = 45;
const int audioMasterCloseFileSelector = 46; // currently unused
const int audioMasterEditFile = 47; // currently unused
const int audioMasterGetChunkFile = 48; // currently unused
const int audioMasterGetInputSpeakerArrangement = 49; // currently unused

const int effFlagsHasEditor = 1;
const int effFlagsCanReplacing = 1 << 4; // very likely
const int effFlagsProgramChunks = 1 << 5; // from Ardour
const int effFlagsIsSynth = 1 << 8; // currently unused

const int effFlagsCanDoubleReplacing = 1 << 12;

const int effOpen = 0;
const int effClose = 1; // currently unused
const int effSetProgram = 2; // currently unused
const int effGetProgram = 3; // currently unused
// The next one was gleaned from http://www.kvraudio.com/forum/viewtopic.php?p=1905347
const int effSetProgramName = 4;
const int effGetProgramName = 5; // currently unused
// The next two were gleaned from http://www.kvraudio.com/forum/viewtopic.php?p=1905347
const int effGetParamLabel = 6;
const int effGetParamDisplay = 7;
const int effGetParamName = 8; // currently unused
const int effSetSampleRate = 10;
const int effSetBlockSize = 11;
const int effMainsChanged = 12;
const int effEditGetRect = 13;
const int effEditOpen = 14;
const int effEditClose = 15;
const int effEditIdle = 19;
const int effEditTop = 20;
const int effIdentify = 22; // from http://www.asseca.org/vst-24-specs/efIdentify.html
const int effGetChunk = 23; // from Ardour
const int effSetChunk = 24; // from Ardour
const int effProcessEvents = 25;
// The next one was gleaned from http://www.asseca.org/vst-24-specs/efCanBeAutomated.html
const int effCanBeAutomated = 26;
// The next one was gleaned from http://www.kvraudio.com/forum/viewtopic.php?p=1905347
const int effGetProgramNameIndexed = 29;
// The next one was gleaned from http://www.asseca.org/vst-24-specs/efGetPlugCategory.html
const int effGetPlugCategory = 35;
const int effGetEffectName = 45;
const int effGetParameterProperties = 56; // missing
const int effGetVendorString = 47;
const int effGetProductString = 48;
const int effGetVendorVersion = 49;
const int effCanDo = 51; // currently unused
// The next one was gleaned from http://www.asseca.org/vst-24-specs/efIdle.html
const int effIdle = 53;
const int effGetVstVersion = 58; // currently unused
// The next one was gleaned from http://www.asseca.org/vst-24-specs/efBeginSetProgram.html
const int effBeginSetProgram = 67;
// The next one was gleaned from http://www.asseca.org/vst-24-specs/efEndSetProgram.html
const int effEndSetProgram = 68;
// The next one was gleaned from http://www.asseca.org/vst-24-specs/efShellGetNextPlugin.html
const int effShellGetNextPlugin = 70;
// The next two were gleaned from http://www.kvraudio.com/forum/printview.php?t=143587&start=0
const int effStartProcess = 71;
const int effStopProcess = 72;
// The next one was gleaned from http://www.asseca.org/vst-24-specs/efBeginLoadBank.html
const int effBeginLoadBank = 75;
// The next one was gleaned from http://www.asseca.org/vst-24-specs/efBeginLoadProgram.html
const int effBeginLoadProgram = 76;
const int effSetProcessPrecision = 77;

const int kEffectMagic = CCONST('V', 's', 't', 'P');
const int kVstLangEnglish = 1;
const int kVstMidiType = 1;

const int kVstNanosValid = 1 << 8;
const int kVstPpqPosValid = 1 << 9;
const int kVstTempoValid = 1 << 10;
const int kVstBarsValid = 1 << 11;
const int kVstCyclePosValid = 1 << 12;
const int kVstTimeSigValid = 1 << 13;
const int kVstSmpteValid = 1 << 14; // from Ardour
const int kVstClockValid = 1 << 15; // from Ardour

const int kVstTransportPlaying = 1 << 1;
const int kVstTransportCycleActive = 1 << 2;
const int kVstTransportChanged = 1;

const int kVstSysExType = 6;
const int kVstMaxVendorStrLen = 64;
const int kVstMaxEffectNameLen = 32;
const int kVstMaxProgNameLen = 24;
const int kVstVersion = 2400;
const int kVstMaxLabelLen = 64;

class VstMidiEvent {
public:
// 00
int type;
// 04
int byteSize;
// 08
int deltaFrames;
// 0c?
int flags;
// 10?
int noteLength;
// 14?
int noteOffset;
// 18
char midiData[4];
// 1c?
char detune;
// 1d?
char noteOffVelocity;
// 1e?
char reserved1;
// 1f?
char reserved2;
};

class VstEvent {
public:
// 00
int type;
// 04
int byteSize;
// 08
int deltaFrames;
// 0c
int flags;
// 10
char empty5[16];
};

class VstEvents {
public:
// 00
int numEvents;
// 04
void *reserved;
// 08
VstEvent *events[2];
};

class AEffect {
public:
// Never use virtual functions!!!
// 00-03
int magic;
// dispatcher 04-07
intptr_t VESTIGECALLBACK (*dispatcher)(AEffect *, int, int, intptr_t, void *, float);
// process, quite sure 08-0b
void VESTIGECALLBACK (*process)(AEffect *, float **, float **, int);
// setParameter 0c-0f
void VESTIGECALLBACK (*setParameter)(AEffect *, int, float);
// getParameter 10-13
float VESTIGECALLBACK (*getParameter)(AEffect *, int);
// programs 14-17
int numPrograms;
// Params 18-1b
int numParams;
// Input 1c-1f
int numInputs;
// Output 20-23
int numOutputs;
// flags 24-27
int flags;
// Fill somewhere 28-2b
void *resvd1;
void *resvd2;
int initialDelay;
// Zeroes 34-37 38-3b
int empty3a;
int empty3b;
// 1.0f 3c-3f
float unkown_float;
// An object? pointer 40-43
void *object;
// Zeroes 44-47
void *user;
// Id 48-4b
int32_t uniqueID;
int32_t version;
// processReplacing 50-53
void VESTIGECALLBACK (*processReplacing)(AEffect *, float **, float **, int);
void VESTIGECALLBACK (*processDoubleReplacing)(AEffect *, double **, double **, int);
char empty6[56];
};

class VstTimeInfo {
public:
// 00
double samplePos;
// 08
double sampleRate;
// 10
double nanoSeconds;
// 18
double ppqPos;
// 20?
double tempo;
// 28
double barStartPos;
// 30?
double cycleStartPos;
// 38?
double cycleEndPos;
// 40?
int timeSigNumerator;
// 44?
int timeSigDenominator;
// unconfirmed 48 4c 50
char empty3[4 + 4 + 4];
// 54
int flags;
};

typedef intptr_t VESTIGECALLBACK (*audioMasterCallback)(AEffect *, int32_t, int32_t, intptr_t, void *, float);

class ERect {
public:
short top;
short left;
short bottom;
short right;
};

#endif
Loading

0 comments on commit ba1e934

Please sign in to comment.