84 |
sleep(1); |
sleep(1); |
85 |
pSampler->fireStatistics(); |
pSampler->fireStatistics(); |
86 |
} |
} |
87 |
|
return 0; |
88 |
} |
} |
89 |
|
|
90 |
|
|
111 |
} |
} |
112 |
|
|
113 |
void Plugin::Init(int SampleRate, int FragmentSize, int Channels) { |
void Plugin::Init(int SampleRate, int FragmentSize, int Channels) { |
114 |
|
if (pAudioDevice && SampleRate == pAudioDevice->SampleRate() && |
115 |
|
FragmentSize == pAudioDevice->MaxSamplesPerCycle()) { |
116 |
|
return; // nothing has changed |
117 |
|
} |
118 |
|
|
119 |
|
String oldState; |
120 |
|
if (pAudioDevice) { |
121 |
|
oldState = GetState(); |
122 |
|
RemoveChannels(); |
123 |
|
global->pSampler->DestroyAudioOutputDevice(pAudioDevice); |
124 |
|
} |
125 |
std::map<String, String> params; |
std::map<String, String> params; |
126 |
params["SAMPLERATE"] = ToString(SampleRate); |
params["SAMPLERATE"] = ToString(SampleRate); |
127 |
params["FRAGMENTSIZE"] = ToString(FragmentSize); |
params["FRAGMENTSIZE"] = ToString(FragmentSize); |
129 |
pAudioDevice = dynamic_cast<AudioOutputDevicePlugin*>( |
pAudioDevice = dynamic_cast<AudioOutputDevicePlugin*>( |
130 |
global->pSampler->CreateAudioOutputDevice(AudioOutputDevicePlugin::Name(), params)); |
global->pSampler->CreateAudioOutputDevice(AudioOutputDevicePlugin::Name(), params)); |
131 |
|
|
132 |
pMidiDevice = dynamic_cast<MidiInputDevicePlugin*>( |
if (!pMidiDevice) { |
133 |
global->pSampler->CreateMidiInputDevice(MidiInputDevicePlugin::Name(), |
pMidiDevice = dynamic_cast<MidiInputDevicePlugin*>( |
134 |
std::map<String,String>())); |
global->pSampler->CreateMidiInputDevice(MidiInputDevicePlugin::Name(), |
135 |
|
std::map<String,String>())); |
136 |
|
} |
137 |
|
|
138 |
|
if (!oldState.empty()) { |
139 |
|
SetState(oldState); |
140 |
|
} |
141 |
} |
} |
142 |
|
|
143 |
Plugin::~Plugin() { |
Plugin::~Plugin() { |