InstrumentResourceManager::instrument_info_t InstrumentResourceManager::GetInstrumentInfo(instrument_id_t ID) throw (InstrumentManagerException) { Lock(); ::sf2::Preset* pInstrument = Resource(ID, false); bool loaded = (pInstrument != NULL); if (!loaded) Unlock(); ::RIFF::File* riff = NULL; ::sf2::File* sf2 = NULL; try { if (!loaded) { riff = new ::RIFF::File(ID.FileName); sf2 = new ::sf2::File(riff); pInstrument = GetSfInstrument(sf2, ID.Index); } instrument_info_t info; for (int i = 0; i < 128; i++) { info.KeyBindings[i] = info.KeySwitchBindings[i] = 0; } ::sf2::File* pFile = pInstrument->GetFile(); info.FormatVersion = ToString(pFile->pInfo->pVer->Major); info.Product = pFile->pInfo->Product; info.Artists = pFile->pInfo->Engineers; info.InstrumentName = pInstrument->Name; for (int i = 0; i < pInstrument->GetRegionCount(); i++) { int low = pInstrument->GetRegion(i)->loKey; int high = pInstrument->GetRegion(i)->hiKey; if (low == ::sf2::NONE || high == ::sf2::NONE) { ::sf2::Instrument* layer = pInstrument->GetRegion(i)->pInstrument; for (int j = 0; j < layer->GetRegionCount(); j++) { int lo = layer->GetRegion(j)->loKey; int hi = layer->GetRegion(j)->hiKey; SetKeyBindings(info.KeyBindings, lo, hi, ::sf2::NONE); } } else { SetKeyBindings(info.KeyBindings, low, high, ::sf2::NONE); } } if (loaded) Unlock(); if (sf2) delete sf2; if (riff) delete riff; return info; } catch (::sf2::Exception e) { if (loaded) Unlock(); if (sf2) delete sf2; if (riff) delete riff; throw InstrumentManagerException(e.Message); } catch (...) { if (loaded) Unlock(); if (sf2) delete sf2; if (riff) delete riff; throw InstrumentManagerException("Unknown exception while trying to parse '" + ID.FileName + "'"); } }
WiiFishController::WiiFishController(FishMaster* fm, Camera* cam, SimpleSetup* setup, PropertyTree& ptree, StereoCamera* sc) : fm(fm) , cam(cam) , stereoCam(sc) , setup(setup) , ptree(ptree) , curCamIdx(-1) , speed(0) , direction(0) , jaw(0) , up(false) , down(false) , left(false) , right(false) , forward(false) , back(false) { ptree.PropertiesChangedEvent().Attach(*this); ReloadConfig(); SetKeyBindings(); }