/[svn]/linuxsampler/trunk/src/hostplugins/vst/PluginVst.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/hostplugins/vst/PluginVst.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1777 by persson, Mon Sep 15 16:58:10 2008 UTC revision 1920 by senoner, Sun Jun 21 15:19:06 2009 UTC
# Line 1  Line 1 
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  *
# Line 28  Line 28 
28    
29  #include "PluginVst.h"  #include "PluginVst.h"
30    
31    #ifndef CHANNELS
32    #define CHANNELS 32
33    #endif
34    
35  namespace {  namespace {
36    
37  #if defined(WIN32) && CONFIG_DEBUG_LEVEL >= 2  #if defined(WIN32) && CONFIG_DEBUG_LEVEL >= 2
# Line 66  namespace { Line 70  namespace {
70      LinuxSamplerEditor::LinuxSamplerEditor(AudioEffect* effect) :      LinuxSamplerEditor::LinuxSamplerEditor(AudioEffect* effect) :
71          AEffEditor(effect) {          AEffEditor(effect) {
72          dmsg(2, ("-->LinuxSamplerEditor constructor\n"));          dmsg(2, ("-->LinuxSamplerEditor constructor\n"));
73    #ifdef WIN32
74            ProcessHandle = INVALID_HANDLE_VALUE;
75    #endif
76        }
77    
78        LinuxSamplerEditor::~LinuxSamplerEditor() {
79            close();
80      }      }
81    
82      bool LinuxSamplerEditor::open(void* ptr) {      bool LinuxSamplerEditor::open(void* ptr) {
# Line 75  namespace { Line 86  namespace {
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          // look for a Fantasia jar file in %programfiles%\LinuxSampler          // assume Fantasia is in the same directory as the
101          if (const char* programfiles = getenv("PROGRAMFILES")) {          // liblinuxsampler dll
102              String lspath = String(programfiles) + "\\LinuxSampler\\";          String lspath = LinuxSampler::Sampler::GetInstallDir();
103            if (!lspath.empty()) {
104                lspath += "\\";
105              WIN32_FIND_DATA fd;              WIN32_FIND_DATA fd;
106              HANDLE hFind = FindFirstFile((lspath + "Fantasia*.jar").c_str(), &fd);              HANDLE hFind = FindFirstFile((lspath + "Fantasia*.jar").c_str(), &fd);
107              if (hFind != INVALID_HANDLE_VALUE) {              if (hFind != INVALID_HANDLE_VALUE) {
# Line 93  namespace { Line 115  namespace {
115                  si.cb = sizeof(si);                  si.cb = sizeof(si);
116                  ZeroMemory(&pi, sizeof(pi));                  ZeroMemory(&pi, sizeof(pi));
117    
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
# Line 109  namespace { Line 132  namespace {
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;
137          }          }
138  #endif  #endif
139      }      }
# Line 136  namespace { Line 161  namespace {
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();
# Line 151  namespace { Line 176  namespace {
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.length()) {              if (!SavedChunk.empty()) {
182                  SetState(SavedChunk);                  SetState(SavedChunk);
183                  SavedChunk = "";                  SavedChunk.clear();
184              } else {              } else {
185                  InitState();                  InitState();
186              }              }
187            } else {
188                Init(int(sampleRate), blockSize);
189          }          }
190          dmsg(2, ("<--resume\n"));          dmsg(2, ("<--resume\n"));
191      }      }
# Line 190  namespace { Line 217  namespace {
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;
# Line 253  namespace { Line 280  namespace {
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    

Legend:
Removed from v.1777  
changed lines
  Added in v.1920

  ViewVC Help
Powered by ViewVC