SoundPlayer::SoundPlayer(EventListener *g) { sound->system->createChannelGroup(NULL, &cg); sound->system->createDSPByType(FMOD_DSP_TYPE_LOWPASS, &lowpass); sound->system->createDSPByType(FMOD_DSP_TYPE_HIGHPASS, &hipass); sound->system->createDSPByType(FMOD_DSP_TYPE_ECHO, &echo); sound->system->createDSPByType(FMOD_DSP_TYPE_REVERB, &reverb); vc = PLAYER_DEFAULT_DISTORTION; vol = PLAYER_DEFAULT_VOLUME; cg->setVolume(PLAYER_DEFAULT_VOLUME); distortion = getDistortion(); slicer = getSlicer(); amp = getAmp(); pan = getPanner(); cg->addDSP(amp); cg->addDSP(reverb); cg->addDSP(echo); cg->addDSP(pan); cg->addDSP(lowpass); cg->addDSP(hipass); ERRCHECK(cg->addDSP(distortion)); ERRCHECK(cg->addDSP(slicer)); slicer->setBypass(true); echo->setBypass(true); reverb->setBypass(true); echo->setParameter(FMOD_DSP_ECHO_DELAY, 60.0 / (float)sound->getTempo() * 1000 / 2); echo->setParameter(FMOD_DSP_ECHO_MAXCHANNELS, 2); echo->setParameter(FMOD_DSP_ECHO_WETMIX, 0.4); echo->setParameter(FMOD_DSP_ECHO_DRYMIX, 1); lowpass->setParameter(FMOD_DSP_LOWPASS_CUTOFF, OPTLPFCO(PLAYER_LPF_DEFAULT_CUTOFF)); lowpass->setParameter(FMOD_DSP_LOWPASS_RESONANCE, OPTLPFRE(PLAYER_LPF_DEFAULT_RESONANCE)); hipass->setParameter(FMOD_DSP_HIGHPASS_CUTOFF, OPTLPFCO(PLAYER_HPF_DEFAULT_CUTOFF)); distortion->setParameter(0, PLAYER_DEFAULT_DISTORTION); amp->setParameter(0, PLAYER_DEFAULT_VOLUME); pan->setParameter(0, PLAYER_DEFAULT_PAN * 2 - 1); this->gui = g; }
float Distortion_get(void* ctx) { return getDistortion(); }
DisplayConfigPtr DisplayConfigFactory::create(OSVR_ClientContext ctx) { DisplayConfigPtr cfg(new DisplayConfig); try { auto const descriptorString = ctx->getStringParameter("/display"); auto desc = display_schema_1::DisplayDescriptor(descriptorString); cfg->m_viewers.container().emplace_back(Viewer(ctx, HEAD_PATH)); auto &viewer = cfg->m_viewers.container().front(); auto eyesDesc = desc.getEyes(); /// Set up stereo vs mono std::vector<uint8_t> eyeIndices; Eigen::Vector3d offset; if (eyesDesc.size() == 2) { // stereo offset = desc.getIPDMeters() / 2. * Eigen::Vector3d::UnitX(); eyeIndices = {0, 1}; } else { // if (eyesDesc.size() == 1) // mono offset = Eigen::Vector3d::Zero(); eyeIndices = {0}; } /// Handle radial distortion parameters boost::optional<OSVR_RadialDistortionParameters> distort; auto k1 = desc.getDistortion(); if (k1.k1_red != 0 || k1.k1_green != 0 || k1.k1_blue != 0) { OSVR_RadialDistortionParameters params; params.k1.data[0] = k1.k1_red; params.k1.data[1] = k1.k1_green; params.k1.data[2] = k1.k1_blue; distort = params; } /// Compute angular offset about Y of the optical (view) axis util::Angle axisOffset = 0. * util::radians; { auto overlapPct = desc.getOverlapPercent(); if (overlapPct < 1.) { const auto hfov = desc.getHorizontalFOV(); const auto angularOverlap = hfov * overlapPct; axisOffset = (hfov - angularOverlap) / 2.; } } /// Infer the number of display inputs and their association with /// eyes (actually surfaces) based on the descriptor. std::vector<OSVR_DisplayInputCount> displayInputIndices; if (eyesDesc.size() == 2 && display_schema_1::DisplayDescriptor::FULL_SCREEN == desc.getDisplayMode()) { // two eyes, full screen - that means two screens. displayInputIndices = {0, 1}; cfg->m_displayInputs.push_back(DisplayInput( desc.getDisplayWidth(), desc.getDisplayHeight())); cfg->m_displayInputs.push_back(DisplayInput( desc.getDisplayWidth(), desc.getDisplayHeight())); } else { // everything else, assume 1 screen. // Note that it's OK that displayInputIndices.size() >= // eyesDesc.size(), we'll just not end up using the second // entry. displayInputIndices = {0, 0}; cfg->m_displayInputs.push_back(DisplayInput( desc.getDisplayWidth(), desc.getDisplayHeight())); } BOOST_ASSERT_MSG(displayInputIndices.size() >= eyesDesc.size(), "Must have at least as many indices as eyes"); /// Create the actual eye (with implied surface) objects for (auto eye : eyeIndices) { // This little computation turns 0 into -1 and 1 into 1, used as // a coefficient to make the two eyes do opposite things. // Doesn't affect mono, which has a zero offset vector. double offsetFactor = (2. * eye) - 1.; // Set up per-eye distortion parameters, if needed boost::optional<OSVR_RadialDistortionParameters> distortEye( distort); if (distortEye) { distortEye->centerOfProjection.data[0] = eyesDesc[eye].m_CenterProjX; distortEye->centerOfProjection.data[1] = eyesDesc[eye].m_CenterProjY; } // precompute translation offset for this eye auto xlateOffset = (offsetFactor * offset).eval(); // precompute the optical axis rotation for this eye // here, the left eye should get a positive offset since it's a // positive rotation about y, hence the -1 factor. auto eyeAxisOffset = axisOffset * -1. * offsetFactor; // Look up the display index for this eye. auto displayInputIdx = displayInputIndices[eye]; /// Create the ViewerEye[Surface] and add it to the container. viewer.container().emplace_back(ViewerEye( ctx, xlateOffset, HEAD_PATH, computeViewport(eye, desc), computeRect(desc), eyesDesc[eye].m_rotate180, desc.getPitchTilt().value(), distortEye, displayInputIdx, eyeAxisOffset)); } OSVR_DEV_VERBOSE("Display: " << desc.getHumanReadableDescription()); return cfg; } catch (std::exception const &e) { OSVR_DEV_VERBOSE( "Couldn't create a display config internally! Exception: " << e.what()); return DisplayConfigPtr{}; } catch (...) { OSVR_DEV_VERBOSE("Couldn't create a display config internally! " "Unknown exception!"); return DisplayConfigPtr{}; } }