int AudioEngine::addRecordingDevice(int pID){ int returnval = 0; AudioDeviceRef newDevice = AudioDevice::create(pID); returnval = newDevice->setup(); mRecordDeviceMap[pID] = newDevice; return returnval; }
int AudioEngine::addPlaybackDevice(int pID, Vec3f playerPos, Vec3f playerLookAt){ int returnval = 0; AudioDeviceRef newDevice = AudioDevice::create(pID); newDevice->setListenerPos(playerPos,playerLookAt); returnval = newDevice->setup(); mDeviceMap[pID] = newDevice; mDeviceIDs.push_back(pID); newDevice->registerEventListener( this, &AudioEngine::onSoundEvent ); return returnval; }
void LookAroundYouApp::update() { float deltaTime = mTimer.getSeconds(); mTimer.start(); gl::color(Color::white()); for(int i=0; i<mBoids.size(); i++) { mBoids[i]->update(deltaTime); } mAudioDevice->setVolume(mVolume); mAudioDevice->update(); mFrameRate = getAverageFps(); }
vector<std::string> AudioEngine::getRecordingDeviceList(int pID) { vector<std::string> returnList; int numdrivers; AudioDeviceRef newDevice = AudioDevice::create(); newDevice->setup(); int res = newDevice->getSystem()->getRecordNumDrivers(&numdrivers); //initalize recording device for (int count=0; count < numdrivers; count++) { char name[256]; newDevice->getSystem()->getRecordDriverInfo(count, name, 256, 0); returnList.push_back(string(name)); console() <<"rec driver " +toString(count) + " name " + string(name) << endl; } return returnList; }
void LookAroundYouApp::setup() { Rand::randomize(); mVolume = 1.0; // Setup GUI getWindow()->setTitle("MPCDigital App"); mParams = params::InterfaceGl( "Settings", Vec2i( 300, 200 ) ); mParams.addParam( "Framerate", &mFrameRate, "", true ); mParams.addSeparator(); mParams.addParam("Speed", &Boid::speedMultiplier, "min=0.5 max=5.0 step=0.01"); mParams.addParam("Radius", &Boid::radiusMultiplier, "min=0.5 max=5.0 step=0.01"); mParams.addParam("Range", &Boid::range, "min=10.0 max=100 step=0.1"); mParams.addSeparator(); mParams.addParam("Master Volume", &mVolume, "min=0 max=1.0 step=0.01"); // Setup Audio AudioDevice::printDeviceMap(); mAudioDevice = make_shared<AudioDevice>(); mAudioDevice->setup(0); mAudioDevice->setAmbientReverb(FMOD_PRESET_UNDERWATER); console() << "Channels Available: " << mAudioDevice->getNumRemainingChannels() << endl; DataSourceRef data = loadAsset("music/Music For Airports - 1 1.mp3"); string musicName = mAudioDevice->registerSound(data, true, false, true); music = mAudioDevice->getSoundInstance(musicName, 1.0); music->pause(); fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/blue.aif"), true, true)); fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/fliup.aif"), true, true)); fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/green.aif"), true, true)); fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/howl.wav"), true, true)); fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/orange.aif"), true, true)); fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/red.aif"), true, true)); fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/white.aif"), true, true)); fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/yellow.aif"), true, true)); // Setup noise generator to drive Boid motion mPerlin = new Perlin(); mPerlin->setSeed(clock()); mPerlin->setOctaves(1); // Construct Boids for(int i=0; i<10; i++) { int n = Rand::randInt(0, fxnames.size()); SoundInstanceRef fx = mAudioDevice->getSoundInstance(fxnames[n], 1.0); BoidRef boid = make_shared<Boid>(mPerlin, fx); mBoids.push_back(boid); } // enable the depth buffer (for 3D) gl::enableDepthRead(); gl::enableDepthWrite(); gl::enableAlphaBlending(); }