--- linuxsampler/trunk/src/engines/gig/Engine.cpp 2004/05/06 20:06:20 64 +++ linuxsampler/trunk/src/engines/gig/Engine.cpp 2004/06/18 14:29:02 133 @@ -59,6 +59,11 @@ pVoicePool->clear(); pSynthesisParameters[0] = NULL; // we allocate when an audio device is connected + pBasicFilterParameters = NULL; + pMainFilterParameters = NULL; + + InstrumentIdx = -1; + InstrumentStat = -1; ResetInternal(); } @@ -85,6 +90,8 @@ if (pVoicePool) delete pVoicePool; if (pActiveKeys) delete pActiveKeys; if (pEventGenerator) delete pEventGenerator; + if (pMainFilterParameters) delete[] pMainFilterParameters; + if (pBasicFilterParameters) delete[] pBasicFilterParameters; if (pSynthesisParameters[0]) delete[] pSynthesisParameters[0]; } @@ -191,6 +198,10 @@ Instruments.HandBack(pInstrument, this); } + InstrumentFile = FileName; + InstrumentIdx = Instrument; + InstrumentStat = 0; + // request gig instrument from instrument manager try { instrument_id_t instrid; @@ -198,22 +209,28 @@ instrid.iInstrument = Instrument; pInstrument = Instruments.Borrow(instrid, this); if (!pInstrument) { + InstrumentStat = -1; dmsg(1,("no instrument loaded!!!\n")); exit(EXIT_FAILURE); } } catch (RIFF::Exception e) { + InstrumentStat = -2; String msg = "gig::Engine error: Failed to load instrument, cause: " + e.Message; throw LinuxSamplerException(msg); } catch (InstrumentResourceManagerException e) { + InstrumentStat = -3; String msg = "gig::Engine error: Failed to load instrument, cause: " + e.Message(); throw LinuxSamplerException(msg); } catch (...) { + InstrumentStat = -4; throw LinuxSamplerException("gig::Engine error: Failed to load instrument, cause: Unknown exception while trying to parse gig file."); } + InstrumentStat = 100; + // inform audio driver for the need of two channels try { if (pAudioOutputDevice) pAudioOutputDevice->AcquireChannels(2); // gig Engine only stereo @@ -289,6 +306,12 @@ for (int dst = 1; dst < Event::destination_count; dst++) pSynthesisParameters[dst] = pSynthesisParameters[dst - 1] + pAudioOut->MaxSamplesPerCycle(); + // (re)allocate biquad filter parameter sequence + if (pBasicFilterParameters) delete[] pBasicFilterParameters; + if (pMainFilterParameters) delete[] pMainFilterParameters; + pBasicFilterParameters = new biquad_param_t[pAudioOut->MaxSamplesPerCycle()]; + pMainFilterParameters = new biquad_param_t[pAudioOut->MaxSamplesPerCycle()]; + dmsg(1,("Starting disk thread...")); pDiskThread->StartThread(); dmsg(1,("OK\n")); @@ -635,7 +658,13 @@ */ void Engine::ResetSynthesisParameters(Event::destination_t dst, float val) { int maxsamples = pAudioOutputDevice->MaxSamplesPerCycle(); - for (int i = 0; i < maxsamples; i++) pSynthesisParameters[dst][i] = val; + float* m = &pSynthesisParameters[dst][0]; + for (int i = 0; i < maxsamples; i += 4) { + m[i] = val; + m[i+1] = val; + m[i+2] = val; + m[i+3] = val; + } } float Engine::Volume() { @@ -674,12 +703,29 @@ return pDiskThread->GetBufferFillPercentage(); } + String Engine::EngineName() { + return "GigEngine"; + } + + String Engine::InstrumentFileName() { + return InstrumentFile; + } + + int Engine::InstrumentIndex() { + return InstrumentIdx; + } + + int Engine::InstrumentStatus() { + return InstrumentStat; + } + String Engine::Description() { return "Gigasampler Engine"; } String Engine::Version() { - return "0.0.1-0cvs20040423"; + String s = "$Revision: 1.7 $"; + return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword } }} // namespace LinuxSampler::gig