/[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 1942 by senoner, Tue Jul 14 18:20:41 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 or one directory above
101          if (const char* programfiles = getenv("PROGRAMFILES")) {          // the 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) {
108                    lspath += "..\\";
109                    hFind = FindFirstFile((lspath + "Fantasia*.jar").c_str(), &fd);
110                }
111              if (hFind != INVALID_HANDLE_VALUE) {              if (hFind != INVALID_HANDLE_VALUE) {
112                  String fantasia(fd.cFileName);                  String fantasia(fd.cFileName);
113                  FindClose(hFind);                  FindClose(hFind);
# Line 93  namespace { Line 119  namespace {
119                  si.cb = sizeof(si);                  si.cb = sizeof(si);
120                  ZeroMemory(&pi, sizeof(pi));                  ZeroMemory(&pi, sizeof(pi));
121    
122                  Command = _tcsdup(TEXT((String("javaw -jar \"") + lspath + fantasia + "\" &").c_str()));                  Command = _tcsdup(TEXT((String("javaw -jar \"") + lspath + fantasia + "\"").c_str()));
123                  CreateProcess(NULL, Command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);                  CreateProcess(NULL, Command, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
124                  ProcessHandle = pi.hProcess;                  ProcessHandle = pi.hProcess;
125                    CloseHandle(pi.hThread);
126              }              }
127          }          }
128  #endif  #endif
# Line 109  namespace { Line 136  namespace {
136          if (ProcessHandle != INVALID_HANDLE_VALUE) {          if (ProcessHandle != INVALID_HANDLE_VALUE) {
137              TerminateProcess(ProcessHandle, 0);              TerminateProcess(ProcessHandle, 0);
138              free(Command);              free(Command);
139                CloseHandle(ProcessHandle);
140                ProcessHandle = INVALID_HANDLE_VALUE;
141          }          }
142  #endif  #endif
143      }      }
# Line 136  namespace { Line 165  namespace {
165          Programs = new LinuxSamplerVstProgram[NbPrograms];          Programs = new LinuxSamplerVstProgram[NbPrograms];
166          setProgram(0);          setProgram(0);
167          setNumInputs(0);          setNumInputs(0);
168          setNumOutputs(2);          setNumOutputs(CHANNELS);
169          canProcessReplacing();          canProcessReplacing();
170          isSynth();          isSynth();
171          programsAreChunks();          programsAreChunks();
# Line 151  namespace { Line 180  namespace {
180      void LinuxSamplerVst::resume() {      void LinuxSamplerVst::resume() {
181          dmsg(2, ("-->resume\n"));          dmsg(2, ("-->resume\n"));
182          if (!pAudioDevice) {          if (!pAudioDevice) {
183              Init(int(sampleRate), blockSize);              Init(int(sampleRate), blockSize, CHANNELS);
184    
185              if (SavedChunk.length()) {              if (!SavedChunk.empty()) {
186                  SetState(SavedChunk);                  SetState(SavedChunk);
187                  SavedChunk = "";                  SavedChunk.clear();
188              } else {              } else {
189                  InitState();                  InitState();
190              }              }
191            } else {
192                Init(int(sampleRate), blockSize);
193          }          }
194            AudioEffectX::resume();
195          dmsg(2, ("<--resume\n"));          dmsg(2, ("<--resume\n"));
196      }      }
197    
# Line 190  namespace { Line 222  namespace {
222    
223      bool LinuxSamplerVst::getOutputProperties(VstInt32 index,      bool LinuxSamplerVst::getOutputProperties(VstInt32 index,
224                                                VstPinProperties* properties) {                                                VstPinProperties* properties) {
225          if (index < 2) {          if (index < CHANNELS) {
226              sprintf(properties->label, "LS %d", index + 1);              sprintf(properties->label, "LS %d", index + 1);
227              properties->flags = kVstPinIsActive | kVstPinIsStereo;              properties->flags = kVstPinIsActive | kVstPinIsStereo;
228              return true;              return true;
# Line 253  namespace { Line 285  namespace {
285      void LinuxSamplerVst::processReplacing(float** inputs, float** outputs,      void LinuxSamplerVst::processReplacing(float** inputs, float** outputs,
286                                             VstInt32 sampleFrames) {                                             VstInt32 sampleFrames) {
287          if (pAudioDevice) {          if (pAudioDevice) {
288              pAudioDevice->Channel(0)->SetBuffer(outputs[0]);              for (int i = 0 ; i < CHANNELS ; i++) {
289              pAudioDevice->Channel(1)->SetBuffer(outputs[1]);                  pAudioDevice->Channel(i)->SetBuffer(outputs[i]);
290                }
291              pAudioDevice->Render(sampleFrames);              pAudioDevice->Render(sampleFrames);
292          } else {          } else {
293              memset(outputs[0], 0, sampleFrames * sizeof(float));              for (int i = 0 ; i < CHANNELS ; i++) {
294              memset(outputs[1], 0, sampleFrames * sizeof(float));                  memset(outputs[i], 0, sampleFrames * sizeof(float));
295                }
296          }          }
297      }      }
298    

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

  ViewVC Help
Powered by ViewVC