48 |
} |
} |
49 |
} |
} |
50 |
|
|
51 |
void SamplerChannel::LoadEngine(engine_type_t EngineType) { |
void SamplerChannel::LoadEngine(Engine::type_t EngineType) { |
52 |
dmsg(1,("SamplerChannel: Loading engine\n")); |
dmsg(2,("SamplerChannel: Loading engine...")); |
53 |
|
|
54 |
// create new engine |
// create new engine |
55 |
Engine* pNewEngine = NULL; |
Engine* pNewEngine = NULL; |
56 |
switch (EngineType) { |
switch (EngineType) { |
57 |
case engine_type_gig: |
case Engine::type_gig: |
58 |
pNewEngine = new gig::Engine; |
pNewEngine = new gig::Engine; |
59 |
break; |
break; |
60 |
default: |
default: |
72 |
pEngine = pNewEngine; |
pEngine = pNewEngine; |
73 |
if (pMidiInputDevice) pMidiInputDevice->Connect(pNewEngine, (MidiInputDevice::midi_chan_t) Index()); |
if (pMidiInputDevice) pMidiInputDevice->Connect(pNewEngine, (MidiInputDevice::midi_chan_t) Index()); |
74 |
if (pAudioOutputDevice) pAudioOutputDevice->Connect(pNewEngine); |
if (pAudioOutputDevice) pAudioOutputDevice->Connect(pNewEngine); |
75 |
dmsg(1,("SamplerChannel: Engine loaded.\n")); |
dmsg(2,("OK\n")); |
76 |
} |
} |
77 |
|
|
78 |
void SamplerChannel::SetAudioOutputDevice(audio_output_type_t AudioType) { |
void SamplerChannel::SetAudioOutputDevice(AudioOutputDevice::type_t AudioType) { |
79 |
// get / create desired audio device |
// get / create desired audio device |
80 |
AudioOutputDevice* pDevice = pSampler->GetAudioOutputDevice(AudioType); |
AudioOutputDevice* pDevice = pSampler->GetAudioOutputDevice(AudioType); |
81 |
if (!pDevice) pDevice = pSampler->CreateAudioOutputDevice(AudioType); |
if (!pDevice) pDevice = pSampler->CreateAudioOutputDevice(AudioType); |
88 |
if (pEngine) pAudioOutputDevice->Connect(pEngine); |
if (pEngine) pAudioOutputDevice->Connect(pEngine); |
89 |
} |
} |
90 |
|
|
91 |
void SamplerChannel::SetMidiInputDevice(midi_input_type_t MidiType, MidiInputDevice::midi_chan_t MidiChannel) { |
void SamplerChannel::SetMidiInputDevice(MidiInputDevice::type_t MidiType, MidiInputDevice::midi_chan_t MidiChannel) { |
92 |
// get / create desired midi device |
// get / create desired midi device |
93 |
MidiInputDevice* pDevice = pSampler->GetMidiInputDevice(MidiType); |
MidiInputDevice* pDevice = pSampler->GetMidiInputDevice(MidiType); |
94 |
if (!pDevice) pDevice = pSampler->CreateMidiInputDevice(MidiType); |
if (!pDevice) pDevice = pSampler->CreateMidiInputDevice(MidiType); |
163 |
} |
} |
164 |
|
|
165 |
uint Sampler::SamplerChannels() { |
uint Sampler::SamplerChannels() { |
166 |
vSamplerChannels.size(); |
return vSamplerChannels.size(); |
167 |
} |
} |
168 |
|
|
169 |
SamplerChannel* Sampler::AddSamplerChannel() { |
SamplerChannel* Sampler::AddSamplerChannel() { |
194 |
RemoveSamplerChannel(pChannel); |
RemoveSamplerChannel(pChannel); |
195 |
} |
} |
196 |
|
|
197 |
AudioOutputDevice* Sampler::CreateAudioOutputDevice(audio_output_type_t AudioType) { |
AudioOutputDevice* Sampler::CreateAudioOutputDevice(AudioOutputDevice::type_t AudioType) { |
198 |
// check if device already created |
// check if device already created |
199 |
AudioOutputDevice* pDevice = GetAudioOutputDevice(AudioType); |
AudioOutputDevice* pDevice = GetAudioOutputDevice(AudioType); |
200 |
if (pDevice) return pDevice; |
if (pDevice) return pDevice; |
201 |
|
|
202 |
// create new device |
// create new device |
203 |
switch (AudioType) { |
switch (AudioType) { |
204 |
case audio_output_type_alsa: |
case AudioOutputDevice::type_alsa: |
205 |
pDevice = new AudioOutputDeviceAlsa; |
pDevice = new AudioOutputDeviceAlsa; |
206 |
break; |
break; |
207 |
case audio_output_type_jack: |
case AudioOutputDevice::type_jack: |
208 |
pDevice = new AudioOutputDeviceJack; |
pDevice = new AudioOutputDeviceJack; |
209 |
break; |
break; |
210 |
default: |
default: |
214 |
// activate device |
// activate device |
215 |
pDevice->Play(); |
pDevice->Play(); |
216 |
|
|
217 |
|
// add new audio device to the audio device list |
218 |
|
AudioOutputDevices[AudioType] = pDevice; |
219 |
|
|
220 |
return pDevice; |
return pDevice; |
221 |
} |
} |
222 |
|
|
223 |
AudioOutputDevice* Sampler::GetAudioOutputDevice(audio_output_type_t AudioType) { |
AudioOutputDevice* Sampler::GetAudioOutputDevice(AudioOutputDevice::type_t AudioType) { |
224 |
AudioOutputDeviceMap::iterator iter = AudioOutputDevices.find(AudioType); |
AudioOutputDeviceMap::iterator iter = AudioOutputDevices.find(AudioType); |
225 |
return (iter != AudioOutputDevices.end()) ? iter->second : NULL; |
return (iter != AudioOutputDevices.end()) ? iter->second : NULL; |
226 |
} |
} |
227 |
|
|
228 |
MidiInputDevice* Sampler::CreateMidiInputDevice(midi_input_type_t MidiType) { |
MidiInputDevice* Sampler::CreateMidiInputDevice(MidiInputDevice::type_t MidiType) { |
229 |
// check if device already created |
// check if device already created |
230 |
MidiInputDevice* pDevice = GetMidiInputDevice(MidiType); |
MidiInputDevice* pDevice = GetMidiInputDevice(MidiType); |
231 |
if (pDevice) return pDevice; |
if (pDevice) return pDevice; |
232 |
|
|
233 |
// create new device |
// create new device |
234 |
switch (MidiType) { |
switch (MidiType) { |
235 |
case midi_input_type_alsa: |
case MidiInputDevice::type_alsa: |
236 |
pDevice = new MidiInputDeviceAlsa; |
pDevice = new MidiInputDeviceAlsa; |
237 |
break; |
break; |
238 |
default: |
default: |
242 |
// activate device |
// activate device |
243 |
pDevice->Listen(); |
pDevice->Listen(); |
244 |
|
|
245 |
|
// add new MIDI device to the MIDI device list |
246 |
|
MidiInputDevices[MidiType] = pDevice; |
247 |
|
|
248 |
return pDevice; |
return pDevice; |
249 |
} |
} |
250 |
|
|
251 |
MidiInputDevice* Sampler::GetMidiInputDevice(midi_input_type_t MidiType) { |
MidiInputDevice* Sampler::GetMidiInputDevice(MidiInputDevice::type_t MidiType) { |
252 |
MidiInputDeviceMap::iterator iter = MidiInputDevices.find(MidiType); |
MidiInputDeviceMap::iterator iter = MidiInputDevices.find(MidiType); |
253 |
return (iter != MidiInputDevices.end()) ? iter->second : NULL; |
return (iter != MidiInputDevices.end()) ? iter->second : NULL; |
254 |
} |
} |