--- linuxsampler/trunk/src/engines/gig/Engine.cpp 2004/06/14 19:33:16 123 +++ linuxsampler/trunk/src/engines/gig/Engine.cpp 2004/08/22 14:46:47 225 @@ -63,6 +63,10 @@ pMainFilterParameters = NULL; InstrumentIdx = -1; + InstrumentStat = -1; + + AudioDeviceChannelLeft = -1; + AudioDeviceChannelRight = -1; ResetInternal(); } @@ -148,6 +152,7 @@ SustainPedal = false; ActiveVoiceCount = 0; ActiveVoiceCountMax = 0; + GlobalVolume = 1.0; // set all MIDI controller values to zero memset(ControllerTable, 0x00, 128); @@ -197,7 +202,9 @@ Instruments.HandBack(pInstrument, this); } - InstrumentIdx = -1; + InstrumentFile = FileName; + InstrumentIdx = Instrument; + InstrumentStat = 0; // request gig instrument from instrument manager try { @@ -206,24 +213,27 @@ 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."); } - InstrumentFile = FileName; - InstrumentIdx = Instrument; + InstrumentStat = 100; // inform audio driver for the need of two channels try { @@ -272,6 +282,13 @@ throw LinuxSamplerException(msg); } + this->AudioDeviceChannelLeft = 0; + this->AudioDeviceChannelRight = 1; + this->pOutputLeft = pAudioOutputDevice->Channel(0)->Buffer(); + this->pOutputRight = pAudioOutputDevice->Channel(1)->Buffer(); + this->MaxSamplesPerCycle = pAudioOutputDevice->MaxSamplesPerCycle(); + this->SampleRate = pAudioOutputDevice->SampleRate(); + // (re)create disk thread if (this->pDiskThread) { this->pDiskThread->StopThread(); @@ -285,7 +302,6 @@ for (Voice* pVoice = pVoicePool->alloc(); pVoice; pVoice = pVoicePool->alloc()) { pVoice->pDiskThread = this->pDiskThread; - pVoice->SetOutput(pAudioOut); dmsg(3,("d")); } pVoicePool->clear(); @@ -323,6 +339,8 @@ AudioOutputDevice* olddevice = pAudioOutputDevice; pAudioOutputDevice = NULL; olddevice->Disconnect(this); + AudioDeviceChannelLeft = -1; + AudioDeviceChannelRight = -1; } } @@ -669,6 +687,38 @@ GlobalVolume = f; } + uint Engine::Channels() { + return 2; + } + + void Engine::SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel) { + AudioChannel* pChannel = pAudioOutputDevice->Channel(AudioDeviceChannel); + if (!pChannel) throw AudioOutputException("Invalid audio output device channel " + ToString(AudioDeviceChannel)); + switch (EngineAudioChannel) { + case 0: // left output channel + pOutputLeft = pChannel->Buffer(); + AudioDeviceChannelLeft = AudioDeviceChannel; + break; + case 1: // right output channel + pOutputRight = pChannel->Buffer(); + AudioDeviceChannelRight = AudioDeviceChannel; + break; + default: + throw AudioOutputException("Invalid engine audio channel " + ToString(EngineAudioChannel)); + } + } + + int Engine::OutputChannel(uint EngineAudioChannel) { + switch (EngineAudioChannel) { + case 0: // left channel + return AudioDeviceChannelLeft; + case 1: // right channel + return AudioDeviceChannelRight; + default: + throw AudioOutputException("Invalid engine audio channel " + ToString(EngineAudioChannel)); + } + } + uint Engine::VoiceCount() { return ActiveVoiceCount; } @@ -709,12 +759,16 @@ return InstrumentIdx; } + int Engine::InstrumentStatus() { + return InstrumentStat; + } + String Engine::Description() { return "Gigasampler Engine"; } String Engine::Version() { - String s = "$Revision: 1.6 $"; + String s = "$Revision: 1.8 $"; return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword }