1 |
/*************************************************************************** |
/*************************************************************************** |
2 |
* * |
* * |
3 |
* Copyright (C) 2008 Andreas Persson * |
* Copyright (C) 2008 - 2009 Andreas Persson * |
4 |
* * |
* * |
5 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
6 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
28 |
|
|
29 |
#include "PluginVst.h" |
#include "PluginVst.h" |
30 |
|
|
31 |
|
#ifndef CHANNELS |
32 |
|
#define CHANNELS 2 |
33 |
|
#endif |
34 |
|
|
35 |
namespace { |
namespace { |
36 |
|
|
37 |
#if defined(WIN32) && CONFIG_DEBUG_LEVEL >= 2 |
#if defined(WIN32) && CONFIG_DEBUG_LEVEL >= 2 |
86 |
#ifdef WIN32 |
#ifdef WIN32 |
87 |
// try to start the JSample Fantasia GUI as a separate process |
// try to start the JSample Fantasia GUI as a separate process |
88 |
|
|
89 |
ProcessHandle = INVALID_HANDLE_VALUE; |
// first check if it's already running |
90 |
|
if (ProcessHandle != INVALID_HANDLE_VALUE) { |
91 |
|
DWORD exitCode; |
92 |
|
if (GetExitCodeProcess(ProcessHandle, &exitCode)) { |
93 |
|
if (exitCode == STILL_ACTIVE) return true; |
94 |
|
} |
95 |
|
free(Command); |
96 |
|
CloseHandle(ProcessHandle); |
97 |
|
ProcessHandle = INVALID_HANDLE_VALUE; |
98 |
|
} |
99 |
|
|
100 |
// assume Fantasia is in the same directory as the |
// assume Fantasia is in the same directory as the |
101 |
// liblinuxsampler dll |
// liblinuxsampler dll |
118 |
Command = _tcsdup(TEXT((String("javaw -jar \"") + lspath + fantasia + "\" &").c_str())); |
Command = _tcsdup(TEXT((String("javaw -jar \"") + lspath + fantasia + "\" &").c_str())); |
119 |
CreateProcess(NULL, Command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); |
CreateProcess(NULL, Command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); |
120 |
ProcessHandle = pi.hProcess; |
ProcessHandle = pi.hProcess; |
121 |
|
CloseHandle(pi.hThread); |
122 |
} |
} |
123 |
} |
} |
124 |
#endif |
#endif |
132 |
if (ProcessHandle != INVALID_HANDLE_VALUE) { |
if (ProcessHandle != INVALID_HANDLE_VALUE) { |
133 |
TerminateProcess(ProcessHandle, 0); |
TerminateProcess(ProcessHandle, 0); |
134 |
free(Command); |
free(Command); |
135 |
|
CloseHandle(ProcessHandle); |
136 |
ProcessHandle = INVALID_HANDLE_VALUE; |
ProcessHandle = INVALID_HANDLE_VALUE; |
137 |
} |
} |
138 |
#endif |
#endif |
161 |
Programs = new LinuxSamplerVstProgram[NbPrograms]; |
Programs = new LinuxSamplerVstProgram[NbPrograms]; |
162 |
setProgram(0); |
setProgram(0); |
163 |
setNumInputs(0); |
setNumInputs(0); |
164 |
setNumOutputs(2); |
setNumOutputs(CHANNELS); |
165 |
canProcessReplacing(); |
canProcessReplacing(); |
166 |
isSynth(); |
isSynth(); |
167 |
programsAreChunks(); |
programsAreChunks(); |
176 |
void LinuxSamplerVst::resume() { |
void LinuxSamplerVst::resume() { |
177 |
dmsg(2, ("-->resume\n")); |
dmsg(2, ("-->resume\n")); |
178 |
if (!pAudioDevice) { |
if (!pAudioDevice) { |
179 |
Init(int(sampleRate), blockSize); |
Init(int(sampleRate), blockSize, CHANNELS); |
180 |
|
|
181 |
if (!SavedChunk.empty()) { |
if (!SavedChunk.empty()) { |
182 |
SetState(SavedChunk); |
SetState(SavedChunk); |
217 |
|
|
218 |
bool LinuxSamplerVst::getOutputProperties(VstInt32 index, |
bool LinuxSamplerVst::getOutputProperties(VstInt32 index, |
219 |
VstPinProperties* properties) { |
VstPinProperties* properties) { |
220 |
if (index < 2) { |
if (index < CHANNELS) { |
221 |
sprintf(properties->label, "LS %d", index + 1); |
sprintf(properties->label, "LS %d", index + 1); |
222 |
properties->flags = kVstPinIsActive | kVstPinIsStereo; |
properties->flags = kVstPinIsActive | kVstPinIsStereo; |
223 |
return true; |
return true; |
280 |
void LinuxSamplerVst::processReplacing(float** inputs, float** outputs, |
void LinuxSamplerVst::processReplacing(float** inputs, float** outputs, |
281 |
VstInt32 sampleFrames) { |
VstInt32 sampleFrames) { |
282 |
if (pAudioDevice) { |
if (pAudioDevice) { |
283 |
pAudioDevice->Channel(0)->SetBuffer(outputs[0]); |
for (int i = 0 ; i < CHANNELS ; i++) { |
284 |
pAudioDevice->Channel(1)->SetBuffer(outputs[1]); |
pAudioDevice->Channel(i)->SetBuffer(outputs[i]); |
285 |
|
} |
286 |
pAudioDevice->Render(sampleFrames); |
pAudioDevice->Render(sampleFrames); |
287 |
} else { |
} else { |
288 |
memset(outputs[0], 0, sampleFrames * sizeof(float)); |
for (int i = 0 ; i < CHANNELS ; i++) { |
289 |
memset(outputs[1], 0, sampleFrames * sizeof(float)); |
memset(outputs[i], 0, sampleFrames * sizeof(float)); |
290 |
|
} |
291 |
} |
} |
292 |
} |
} |
293 |
|
|