Skip to content

Commit

Permalink
Never commited this
Browse files Browse the repository at this point in the history
  • Loading branch information
reduz committed Nov 17, 2018
1 parent 88f4a8f commit afeec67
Show file tree
Hide file tree
Showing 15 changed files with 317 additions and 39 deletions.
8 changes: 4 additions & 4 deletions SConstruct
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

import os
EnsureSConsVersion(0,14);

env = Environment(CPPPATH=['#/globals','#gui','#.'])
env = Environment(CPPPATH=['#/globals','#gui','#.'],ENV=os.environ)

env.ParseConfig("pkg-config gtkmm-3.0 --libs --cflags")
env.ParseConfig("pkg-config lilv-0 --libs --cflags")
env.ParseConfig("pkg-config suil-0 --libs --cflags")
#env.ParseConfig("pkg-config lilv-0 --libs --cflags")
#env.ParseConfig("pkg-config suil-0 --libs --cflags")
env.Append(CXXFLAGS=["-g3"])

def add_sources(self, sources, filetype, lib_env = None, shared = False):
Expand Down
10 changes: 9 additions & 1 deletion bin/sytrax.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
#include <gtkmm.h>

#include "drivers/audio_effect_factory_lv2.h"
#include "drivers/audio_effect_factory_vst.h"
#include "gui/interface.h"

int main(int argc, char *argv[]) {

AudioEffectFactory effect_factory;

AudioEffectProviderVST2 provider_vst2;
provider_vst2.scan_effects(&effect_factory);
effect_factory.add_provider(&provider_vst2);

#ifdef UNIX_ENABLED


AudioEffectProviderLV2 provider_lv2(&argc, &argv); //lv2 madness
provider_lv2.scan_effects(&effect_factory);

effect_factory.add_provider(&provider_lv2);
#endif

auto app = Gtk::Application::create(argc, argv, "org.gtkmm.examples.base");

Expand Down
2 changes: 2 additions & 0 deletions drivers/audio_effect_factory_lv2.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "audio_effect_factory_lv2.h"
#include "engine/sound_driver_manager.h"
#ifdef UNIX_ENABLED
//process
bool AudioEffectLV2::process(const AudioFrame2 *p_in, AudioFrame2 *p_out, const Event *p_events, bool p_prev_active) {

Expand Down Expand Up @@ -441,3 +442,4 @@ AudioEffectProviderLV2::AudioEffectProviderLV2(int *argc, char ***argv) {
jalv.control_in = (uint32_t)-1;
#endif
}
#endif
3 changes: 3 additions & 0 deletions drivers/audio_effect_factory_lv2.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef AUDIO_EFFECT_FACTORY_LV2_H
#define AUDIO_EFFECT_FACTORY_LV2_H

#ifdef UNIX_ENABLED

#include "lilv/lilv.h"
#include "suil/suil.h"

Expand Down Expand Up @@ -168,4 +170,5 @@ friend class AudioEffectLV2;
AudioEffectProviderLV2(int *argc, char ***argv);
};

#endif
#endif // AUDIO_EFFECT_FACTORY_LV2_H
234 changes: 234 additions & 0 deletions drivers/audio_effect_factory_vst.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
#include "audio_effect_factory_vst.h"
#include <dirent.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

void AudioEffectProviderVST2::set_paths(const String& p_paths) {
paths=p_paths;
}

String AudioEffectProviderVST2::get_paths() const {
return paths;
}

AudioEffect *AudioEffectProviderVST2::creation_func(const AudioEffectInfo *) {

return NULL;
}

void AudioEffectProviderVST2::scan_effects(AudioEffectFactory *p_factory) {

for(int i=0;i<paths.get_slice_count(",");i++) {

String p = paths.get_slice(",",i).strip_edges();
printf("scanning path: %s\n",p.utf8().get_data());
if (p=="") {
continue;
}

DIR *dir;
struct dirent *dirent;

printf("about to open dir\n");
dir= opendir(p.utf8().get_data());
if (dir == NULL) {
printf("failed?\n");
return;
}

printf("opened dir\n");

while ((dirent= readdir(dir))) {


char lib_name[PATH_MAX];
snprintf(lib_name, PATH_MAX, "%s\\%s", p.utf8().get_data(), dirent->d_name);

printf("trying lib: %s\n",lib_name);

//printf("Scanning %s\n",lib_name);

HINSTANCE libhandle=LoadLibrary(lib_name);

if (libhandle==NULL) {
//printf("invalid file: %s\n",lib_name);
continue;
}

AEffect* (__cdecl* getNewPlugInstance)(audioMasterCallback);

getNewPlugInstance=(AEffect*(__cdecl*)(audioMasterCallback))GetProcAddress(libhandle, "VSTPluginMain");
if (!getNewPlugInstance) {
getNewPlugInstance=(AEffect*(__cdecl*)(audioMasterCallback))GetProcAddress(libhandle, "main");
}

if (getNewPlugInstance==NULL) {
FreeLibrary(libhandle);
WARN_PRINT("Can't find symbol 'main'");
continue;
}
AEffect* ptrPlug=getNewPlugInstance(&host);

if (ptrPlug==NULL) {
WARN_PRINT("Can't instance plugin.");

FreeLibrary(libhandle);
continue;
}

if (ptrPlug->magic!=kEffectMagic) {
WARN_PRINT("Can't instance plugin, corrupted");
FreeLibrary(libhandle);
continue;

}
ptrPlug->dispatcher(ptrPlug,effOpen,0,0,NULL,0.0f);

VST_Struct plugin_data;
plugin_data.path=lib_name;
plugin_data.dir=p;
AudioEffectInfo info;

String name=dirent->d_name;
name=name.substr(0,name.find("."));
info.caption=name;
printf("plugin name: %s\n",info.caption.utf8().get_data());
info.description="VST Plugin";
info.long_description="VST Info:\n Name: "+info.caption +"\n ID: "+ String::num(ptrPlug->uniqueID) + "\n Version: " + String(ptrPlug->version);
info.unique_ID="VST_"+String::num(ptrPlug->uniqueID);
info.synth=/*(ptrPlug->dispatcher(ptrPlug,effGetVstVersion,0,0,NULL,0.0f)==2 */ptrPlug->flags & effFlagsIsSynth;
info.category=info.synth?"VST Instruments":"VST Effects";
info.has_ui=(ptrPlug->flags & effFlagsHasEditor);

info.provider=this;
info.creation_func=creation_func;
info.version=ptrPlug->version;

if (ptrPlug->flags & effFlagsProgramChunks) {

info.description+=" (CS)";
}

/* Perform the "write only" test */

//plugin_data->write_only=true; //i cant really be certain of anything with VST plugins, so this is always true
/*
if (ptrPlug->numParams) {
ptrPlug->setParameter(ptrPlug,0,1.0); //set 1.0
float res=ptrPlug->getParameter(ptrPlug,0);
if (res<0.8) { //try if it's not near 1.0, with some threshold, then no reading (far most of the ones that dont support this will just return 0)
}
} */
plugins[info.unique_ID]=plugin_data;
p_factory->add_audio_effect(info);

ptrPlug->dispatcher(ptrPlug,effClose,0,0,NULL,0.0f);
FreeLibrary(libhandle);

}

}
}


VstIntPtr VSTCALLBACK AudioEffectProviderVST2::host(AEffect *effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void *ptr, float opt) {
long retval=0;

switch (opcode)
{
//VST 1.0 opcodes
case audioMasterVersion:
//Input values:
//none

//Return Value:
//0 or 1 for old version
//2 or higher for VST2.0 host?
retval=2;
break;
case audioMasterGetSampleRate:

effect->dispatcher(effect,effSetSampleRate,0,0,NULL,44100); //just crap
break;
case audioMasterGetBlockSize:
//Input Values:
//None

//Return Value:
//not tested, always return 0

//NB - Host must despatch effSetBlockSize to the plug in response
//to this call
//Check despatcher notes for any return codes from effSetBlockSize
effect->dispatcher(effect,effSetBlockSize,0,1024,NULL,0.0f);

break;
case audioMasterCanDo:
//Input Values:
//<ptr> predefined "canDo" string

//Return Value:
//0 = Not Supported
//non-zero value if host supports that feature

//NB - Possible Can Do strings are:
//"sendVstEvents",
//"sendVstMidiEvent",
//"sendVstTimeInfo",
//"receiveVstEvents",
//"receiveVstMidiEvent",
//"receiveVstTimeInfo",
//"reportConnectionChanges",
//"acceptIOChanges",
//"sizeWindow",
//"asyncProcessing",
//"offline",
//"supplyIdle",
//"supportShell"

if (strcmp((char*)ptr,"sendVstEvents")==0 ||
strcmp((char*)ptr,"sendVstMidiEvent")==0 ||
strcmp((char*)ptr,"supplyIdle")==0)
{
retval=1;
}
else
{
retval=0;
}

break;
case audioMasterGetLanguage:
//Input Values:
//None

//Return Value:
//kVstLangEnglish
//kVstLangGerman
//kVstLangFrench
//kVstLangItalian
//kVstLangSpanish
//kVstLangJapanese

retval=kVstLangEnglish;
break;


}
return retval; //stupid plugin, i'm just reading stuff, dont annoy me with questions!
}

String AudioEffectProviderVST2::get_name() const {
return "VST2";
}

AudioEffectProviderVST2::AudioEffectProviderVST2() {
paths="C:\\Program Files\\Synister64";
}

AudioEffectProviderVST2::~AudioEffectProviderVST2() {
printf("erased provider\n");
}
33 changes: 33 additions & 0 deletions drivers/audio_effect_factory_vst.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef AUDIOEFFECTFACTORYVST_H
#define AUDIOEFFECTFACTORYVST_H

#include "engine/audio_effect.h"
#include "vst/aeffectx.h"
#include "globals/map.h"
class AudioEffectProviderVST2 : public AudioEffectProvider {

struct VST_Struct {

String path;
String dir;
bool write_only;
};

Map<String,VST_Struct> plugins;

String paths;
static VstIntPtr VSTCALLBACK host(AEffect *effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void *ptr, float opt);
static AudioEffect *creation_func(const AudioEffectInfo *); ///< creation function for instancing this node

public:
void set_paths(const String& p_paths);
String get_paths() const;

virtual void scan_effects(AudioEffectFactory *p_factory) ;
virtual String get_name() const;

AudioEffectProviderVST2();
~AudioEffectProviderVST2();
};

#endif // AUDIOEFFECTFACTORYVST_H
36 changes: 18 additions & 18 deletions dsp/frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,40 @@
#include "typedefs.h"
typedef float AudioFrame;

struct AudioFrame2 {
struct Frame {

AudioFrame l,r;
float l,r;


_FORCE_INLINE_ const AudioFrame& operator[](int idx) const { return idx==0?l:r; }
_FORCE_INLINE_ AudioFrame& operator[](int idx) { return idx==0?l:r; }
_FORCE_INLINE_ AudioFrame2 operator+(const AudioFrame2& p_AudioFrame2) const { return AudioFrame2(l+p_AudioFrame2.l,r+p_AudioFrame2.r); }
_FORCE_INLINE_ AudioFrame2 operator-(const AudioFrame2& p_AudioFrame2) const { return AudioFrame2(l-p_AudioFrame2.l,r-p_AudioFrame2.r); }
_FORCE_INLINE_ AudioFrame2 operator*(const AudioFrame2& p_AudioFrame2) const { return AudioFrame2(l*p_AudioFrame2.l,r*p_AudioFrame2.r); }
_FORCE_INLINE_ AudioFrame2 operator/(const AudioFrame2& p_AudioFrame2) const { return AudioFrame2(l/p_AudioFrame2.l,r/p_AudioFrame2.r); }
_FORCE_INLINE_ Frame operator+(const Frame& p_Frame) const { return Frame(l+p_Frame.l,r+p_Frame.r); }
_FORCE_INLINE_ Frame operator-(const Frame& p_Frame) const { return Frame(l-p_Frame.l,r-p_Frame.r); }
_FORCE_INLINE_ Frame operator*(const Frame& p_Frame) const { return Frame(l*p_Frame.l,r*p_Frame.r); }
_FORCE_INLINE_ Frame operator/(const Frame& p_Frame) const { return Frame(l/p_Frame.l,r/p_Frame.r); }

_FORCE_INLINE_ void operator+=(const AudioFrame2& p_AudioFrame2) { l+=p_AudioFrame2.l;r+=p_AudioFrame2.r; }
_FORCE_INLINE_ void operator-=(const AudioFrame2& p_AudioFrame2) { l-=p_AudioFrame2.l;r-=p_AudioFrame2.r; }
_FORCE_INLINE_ void operator*=(const AudioFrame2& p_AudioFrame2) { l*=p_AudioFrame2.l;r*=p_AudioFrame2.r; }
_FORCE_INLINE_ void operator/=(const AudioFrame2& p_AudioFrame2) { l/=p_AudioFrame2.l;r/=p_AudioFrame2.r; }
_FORCE_INLINE_ void operator+=(const Frame& p_Frame) { l+=p_Frame.l;r+=p_Frame.r; }
_FORCE_INLINE_ void operator-=(const Frame& p_Frame) { l-=p_Frame.l;r-=p_Frame.r; }
_FORCE_INLINE_ void operator*=(const Frame& p_Frame) { l*=p_Frame.l;r*=p_Frame.r; }
_FORCE_INLINE_ void operator/=(const Frame& p_Frame) { l/=p_Frame.l;r/=p_Frame.r; }

_FORCE_INLINE_ AudioFrame2 operator+(const AudioFrame& p_AudioFrame) const { return AudioFrame2(l+p_AudioFrame,r+p_AudioFrame); }
_FORCE_INLINE_ AudioFrame2 operator-(const AudioFrame& p_AudioFrame) const { return AudioFrame2(l-p_AudioFrame,r-p_AudioFrame); }
_FORCE_INLINE_ AudioFrame2 operator*(const AudioFrame& p_AudioFrame) const { return AudioFrame2(l*p_AudioFrame,r*p_AudioFrame); }
_FORCE_INLINE_ AudioFrame2 operator/(const AudioFrame& p_AudioFrame) const { return AudioFrame2(l/p_AudioFrame,r/p_AudioFrame); }
_FORCE_INLINE_ Frame operator+(const AudioFrame& p_AudioFrame) const { return Frame(l+p_AudioFrame,r+p_AudioFrame); }
_FORCE_INLINE_ Frame operator-(const AudioFrame& p_AudioFrame) const { return Frame(l-p_AudioFrame,r-p_AudioFrame); }
_FORCE_INLINE_ Frame operator*(const AudioFrame& p_AudioFrame) const { return Frame(l*p_AudioFrame,r*p_AudioFrame); }
_FORCE_INLINE_ Frame operator/(const AudioFrame& p_AudioFrame) const { return Frame(l/p_AudioFrame,r/p_AudioFrame); }

_FORCE_INLINE_ void operator+=(const AudioFrame& p_AudioFrame) { l+=p_AudioFrame; r+=p_AudioFrame; }
_FORCE_INLINE_ void operator-=(const AudioFrame& p_AudioFrame) { l-=p_AudioFrame; r-=p_AudioFrame; }
_FORCE_INLINE_ void operator*=(const AudioFrame& p_AudioFrame) { l*=p_AudioFrame; r*=p_AudioFrame; }
_FORCE_INLINE_ void operator/=(const AudioFrame& p_AudioFrame) { l/=p_AudioFrame; r/=p_AudioFrame; }

_FORCE_INLINE_ AudioFrame2(AudioFrame p_l, AudioFrame p_r) {l=p_l; r=p_r;}
_FORCE_INLINE_ AudioFrame2(AudioFrame p_AudioFrame) {l=p_AudioFrame; r=p_AudioFrame;}
_FORCE_INLINE_ AudioFrame2() {}
_FORCE_INLINE_ Frame(AudioFrame p_l, AudioFrame p_r) {l=p_l; r=p_r;}
_FORCE_INLINE_ Frame(AudioFrame p_AudioFrame) {l=p_AudioFrame; r=p_AudioFrame;}
_FORCE_INLINE_ Frame() {}

} _FORCE_ALIGN_;

typedef AudioFrame2 StereoAudioFrame;
typedef Frame StereoAudioFrame;

enum AudioFrameType {

Expand Down
Loading

0 comments on commit afeec67

Please sign in to comment.