59 |
pVoicePool->clear(); |
pVoicePool->clear(); |
60 |
|
|
61 |
pSynthesisParameters[0] = NULL; // we allocate when an audio device is connected |
pSynthesisParameters[0] = NULL; // we allocate when an audio device is connected |
62 |
|
pBasicFilterParameters = NULL; |
63 |
|
pMainFilterParameters = NULL; |
64 |
|
|
65 |
|
InstrumentIdx = -1; |
66 |
|
InstrumentStat = -1; |
67 |
|
|
68 |
ResetInternal(); |
ResetInternal(); |
69 |
} |
} |
90 |
if (pVoicePool) delete pVoicePool; |
if (pVoicePool) delete pVoicePool; |
91 |
if (pActiveKeys) delete pActiveKeys; |
if (pActiveKeys) delete pActiveKeys; |
92 |
if (pEventGenerator) delete pEventGenerator; |
if (pEventGenerator) delete pEventGenerator; |
93 |
|
if (pMainFilterParameters) delete[] pMainFilterParameters; |
94 |
|
if (pBasicFilterParameters) delete[] pBasicFilterParameters; |
95 |
if (pSynthesisParameters[0]) delete[] pSynthesisParameters[0]; |
if (pSynthesisParameters[0]) delete[] pSynthesisParameters[0]; |
96 |
} |
} |
97 |
|
|
198 |
Instruments.HandBack(pInstrument, this); |
Instruments.HandBack(pInstrument, this); |
199 |
} |
} |
200 |
|
|
201 |
|
InstrumentFile = FileName; |
202 |
|
InstrumentIdx = Instrument; |
203 |
|
InstrumentStat = 0; |
204 |
|
|
205 |
// request gig instrument from instrument manager |
// request gig instrument from instrument manager |
206 |
try { |
try { |
207 |
instrument_id_t instrid; |
instrument_id_t instrid; |
209 |
instrid.iInstrument = Instrument; |
instrid.iInstrument = Instrument; |
210 |
pInstrument = Instruments.Borrow(instrid, this); |
pInstrument = Instruments.Borrow(instrid, this); |
211 |
if (!pInstrument) { |
if (!pInstrument) { |
212 |
|
InstrumentStat = -1; |
213 |
dmsg(1,("no instrument loaded!!!\n")); |
dmsg(1,("no instrument loaded!!!\n")); |
214 |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
215 |
} |
} |
216 |
} |
} |
217 |
catch (RIFF::Exception e) { |
catch (RIFF::Exception e) { |
218 |
|
InstrumentStat = -2; |
219 |
String msg = "gig::Engine error: Failed to load instrument, cause: " + e.Message; |
String msg = "gig::Engine error: Failed to load instrument, cause: " + e.Message; |
220 |
throw LinuxSamplerException(msg); |
throw LinuxSamplerException(msg); |
221 |
} |
} |
222 |
catch (InstrumentResourceManagerException e) { |
catch (InstrumentResourceManagerException e) { |
223 |
|
InstrumentStat = -3; |
224 |
String msg = "gig::Engine error: Failed to load instrument, cause: " + e.Message(); |
String msg = "gig::Engine error: Failed to load instrument, cause: " + e.Message(); |
225 |
throw LinuxSamplerException(msg); |
throw LinuxSamplerException(msg); |
226 |
} |
} |
227 |
catch (...) { |
catch (...) { |
228 |
|
InstrumentStat = -4; |
229 |
throw LinuxSamplerException("gig::Engine error: Failed to load instrument, cause: Unknown exception while trying to parse gig file."); |
throw LinuxSamplerException("gig::Engine error: Failed to load instrument, cause: Unknown exception while trying to parse gig file."); |
230 |
} |
} |
231 |
|
|
232 |
|
InstrumentStat = 100; |
233 |
|
|
234 |
// inform audio driver for the need of two channels |
// inform audio driver for the need of two channels |
235 |
try { |
try { |
236 |
if (pAudioOutputDevice) pAudioOutputDevice->AcquireChannels(2); // gig Engine only stereo |
if (pAudioOutputDevice) pAudioOutputDevice->AcquireChannels(2); // gig Engine only stereo |
306 |
for (int dst = 1; dst < Event::destination_count; dst++) |
for (int dst = 1; dst < Event::destination_count; dst++) |
307 |
pSynthesisParameters[dst] = pSynthesisParameters[dst - 1] + pAudioOut->MaxSamplesPerCycle(); |
pSynthesisParameters[dst] = pSynthesisParameters[dst - 1] + pAudioOut->MaxSamplesPerCycle(); |
308 |
|
|
309 |
|
// (re)allocate biquad filter parameter sequence |
310 |
|
if (pBasicFilterParameters) delete[] pBasicFilterParameters; |
311 |
|
if (pMainFilterParameters) delete[] pMainFilterParameters; |
312 |
|
pBasicFilterParameters = new biquad_param_t[pAudioOut->MaxSamplesPerCycle()]; |
313 |
|
pMainFilterParameters = new biquad_param_t[pAudioOut->MaxSamplesPerCycle()]; |
314 |
|
|
315 |
dmsg(1,("Starting disk thread...")); |
dmsg(1,("Starting disk thread...")); |
316 |
pDiskThread->StartThread(); |
pDiskThread->StartThread(); |
317 |
dmsg(1,("OK\n")); |
dmsg(1,("OK\n")); |
658 |
*/ |
*/ |
659 |
void Engine::ResetSynthesisParameters(Event::destination_t dst, float val) { |
void Engine::ResetSynthesisParameters(Event::destination_t dst, float val) { |
660 |
int maxsamples = pAudioOutputDevice->MaxSamplesPerCycle(); |
int maxsamples = pAudioOutputDevice->MaxSamplesPerCycle(); |
661 |
for (int i = 0; i < maxsamples; i++) pSynthesisParameters[dst][i] = val; |
float* m = &pSynthesisParameters[dst][0]; |
662 |
|
for (int i = 0; i < maxsamples; i += 4) { |
663 |
|
m[i] = val; |
664 |
|
m[i+1] = val; |
665 |
|
m[i+2] = val; |
666 |
|
m[i+3] = val; |
667 |
|
} |
668 |
} |
} |
669 |
|
|
670 |
float Engine::Volume() { |
float Engine::Volume() { |
703 |
return pDiskThread->GetBufferFillPercentage(); |
return pDiskThread->GetBufferFillPercentage(); |
704 |
} |
} |
705 |
|
|
706 |
|
String Engine::EngineName() { |
707 |
|
return "GigEngine"; |
708 |
|
} |
709 |
|
|
710 |
|
String Engine::InstrumentFileName() { |
711 |
|
return InstrumentFile; |
712 |
|
} |
713 |
|
|
714 |
|
int Engine::InstrumentIndex() { |
715 |
|
return InstrumentIdx; |
716 |
|
} |
717 |
|
|
718 |
|
int Engine::InstrumentStatus() { |
719 |
|
return InstrumentStat; |
720 |
|
} |
721 |
|
|
722 |
String Engine::Description() { |
String Engine::Description() { |
723 |
return "Gigasampler Engine"; |
return "Gigasampler Engine"; |
724 |
} |
} |
725 |
|
|
726 |
String Engine::Version() { |
String Engine::Version() { |
727 |
return "0.0.1-0cvs20040423"; |
String s = "$Revision: 1.7 $"; |
728 |
|
return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword |
729 |
} |
} |
730 |
|
|
731 |
}} // namespace LinuxSampler::gig |
}} // namespace LinuxSampler::gig |