Skip to content

Commit

Permalink
Completed
Browse files Browse the repository at this point in the history
  • Loading branch information
reduz committed May 17, 2019
1 parent 352bc00 commit 1ec7455
Show file tree
Hide file tree
Showing 47 changed files with 5,301 additions and 720 deletions.
8 changes: 6 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ opts.Add(BoolVariable("use_jack","Use Jack with RtAudio",False))
opts.Add(BoolVariable("use_pulseaudio","Use Pulseaudio with RtAudio",True))
opts.Add(BoolVariable("use_alsa","Use Alsa with RtAudio",True))
opts.Add(BoolVariable("enable_vst2","Enable VST2",True))
opts.Add(BoolVariable("use_wasapi","Enable Wasapi",True))
opts.Add(BoolVariable("use_directsound","Enable Wasapi",True))

opts.Update(env) # update environment
Help(opts.GenerateHelpText(env)) # generate help
Expand All @@ -36,8 +38,10 @@ if (env["enable_rtaudio"]):

env.Append(CXXFLAGS=["-DRTAUDIO_ENABLED"])
if (env["platform"]=="windows"):
env.Append(CXXFLAGS=["-D__WINDOWS_WASAPI__"])
env.Append(CXXFLAGS=["-D__WINDOWS_DS__"])
if (env["use_wasapi"]):
env.Append(CXXFLAGS=["-D__WINDOWS_WASAPI__"])
if (env["use_directsound"]):
env.Append(CXXFLAGS=["-D__WINDOWS_DS__"])
#env.Append(CXXFLAGS=["-D__WINDOWS_ASIO__"])
env.Append(LIBS=["dsound","mfplat","mfuuid","wmcodecdspuuid","ksuser"])

Expand Down
24 changes: 23 additions & 1 deletion bin/zytrax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
int main(int argc, char *argv[]) {

AudioEffectFactory effect_factory;

#ifdef VST2_ENABLED
AudioEffectProvider *provider_vst2 = create_vst2_provider();
effect_factory.add_provider(provider_vst2);
Expand Down Expand Up @@ -136,7 +137,26 @@ int main(int argc, char *argv[]) {
}
}
}

if (node.has("default_commands")) { //default commands

JSON::Node def_commands = node.get("default_commands");

for (int i = 0; i < def_commands.getCount(); i++) {

JSON::Node command = def_commands.get(i);

int index = command.get("index").toInt();
String name;
name.parse_utf8(command.get("identifier").toString().c_str());
char c = char(command.get("command").toInt());

SettingsDialog::set_default_command(index, name, c);
}
}
}

SoundDriverManager::init_driver(use_driver_index);
}

/* make it dark */
Expand Down Expand Up @@ -185,12 +205,14 @@ int main(int argc, char *argv[]) {
/* Initialize the UI */

Interface window(app.operator->(), &effect_factory, &theme, &key_bindings);
window.set_default_size(800, 600);
window.set_default_size(1280, 720);
#ifdef VST2_ENABLED
window.add_editor_plugin_function(get_vst2_editor_function());
#endif
int ret = app->run(window);

SoundDriverManager::finish_driver();

#ifdef VST2_ENABLED
delete provider_vst2;
#endif
Expand Down
7 changes: 6 additions & 1 deletion drivers/rtaudio/sound_driver_rtaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Vector<RtAudio *> rt_audios;
class SoundDriverRTAudio : public SoundDriver {
public:
RtAudio *rt_audio;
std::mutex mutex;
std::recursive_mutex mutex;
int device;
int mix_rate;
RtAudio::DeviceInfo info;
Expand Down Expand Up @@ -43,6 +43,11 @@ class SoundDriverRTAudio : public SoundDriver {
unsigned int nFrames,
double streamTime,
RtAudioStreamStatus status) {

if (mutex.try_lock()) {
mix((AudioFrame *)outputBuffer, nFrames);
mutex.unlock();
}
return 0;
}

Expand Down
73 changes: 39 additions & 34 deletions drivers/vst2/audio_effect_provider_vst2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ void AudioEffectProviderVST2::scan_effects(AudioEffectFactory *p_factory, ScanCa

String lib_name = p + "/" + String(dirent->d_name);

if (lib_name.get_extension() != "dll") {
continue;
}
printf("opening plugin: %s\n", lib_name.utf8().get_data());

HINSTANCE libhandle = LoadLibraryW(lib_name.c_str());

AEffect *ptrPlug = open_vst_from_lib_handle(libhandle, &host);
Expand All @@ -78,53 +83,54 @@ void AudioEffectProviderVST2::scan_effects(AudioEffectFactory *p_factory, ScanCa
FreeLibrary(libhandle);
continue;
}

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

AudioEffectInfo info;
if (ptrPlug->numOutputs >= 2) { //needs to have at least 2 outputs
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);
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_caption = "VST2";
info.version = String::num(ptrPlug->version);
info.provider_caption = "VST2";
info.version = String::num(ptrPlug->version);

info.provider_id = get_id();
info.path = lib_name;
info.provider_id = get_id();
info.path = lib_name;

if (ptrPlug->flags & effFlagsProgramChunks) {
if (ptrPlug->flags & effFlagsProgramChunks) {

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

/* Perform the "write only" test */
/* 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) {
//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)
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)
}
} */
p_factory->add_audio_effect(info);
if (p_callback) {
p_callback(info.caption, p_userdata);
}
} */
p_factory->add_audio_effect(info);

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

if (p_callback) {
p_callback(info.caption, p_userdata);
}
}
}
}
Expand Down Expand Up @@ -208,7 +214,7 @@ VstIntPtr VSTCALLBACK AudioEffectProviderVST2::host(AEffect *effect, VstInt32 op
retval = kVstLangEnglish;
break;
}
return retval; //stupid plugin, i'm just reading stuff, dont annoy me with questions!
return retval;
}

String AudioEffectProviderVST2::get_name() const {
Expand All @@ -225,5 +231,4 @@ AudioEffectProviderVST2::AudioEffectProviderVST2() {
}

AudioEffectProviderVST2::~AudioEffectProviderVST2() {
printf("erased provider\n");
}
Loading

0 comments on commit 1ec7455

Please sign in to comment.