本文整理汇总了C++中fmod::System::playSound方法的典型用法代码示例。如果您正苦于以下问题:C++ System::playSound方法的具体用法?C++ System::playSound怎么用?C++ System::playSound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fmod::System
的用法示例。
在下文中一共展示了System::playSound方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Sound::Sound(std::string filename, glm::vec3 position, bool loop)
{
FMOD_VECTOR velocity = { 0, 0, 0 };
FMOD_VECTOR pos = { position.x, position.y, position.z };
FMOD::System *system = AudioSystem::GetFMODSystem();
FMOD_RESULT result;
mFilepath = kSoundDir + filename;
mPosition = pos;
mVelocity = velocity;
result = system->createSound(mFilepath.c_str(), FMOD_3D, 0, &mSound);
if (result != FMOD_OK) {
//TODO: Error handling
}
result = system->playSound(FMOD_CHANNEL_FREE, mSound, true, &mChannel);
if (result != FMOD_OK) {
//TODO: Error handling
}
Update();
SetLooping(loop);
}
示例2: OnMouseDown
void DuckHuntMain::OnMouseDown(WPARAM btnState, int x, int y)
{
mLastMousePos.x = x;
mLastMousePos.y = y;
if ((btnState & MK_RBUTTON) != 0)
{
mZoomed = true;
zoom = 1;
mCam.Zoom(AspectRatio());
}
if ((btnState & MK_LBUTTON) != 0)
{
result = mSystem->playSound(mGunFire, 0, false, &channel);
pickedModel = pick(mScreenViewport.Width / 2, mScreenViewport.Height / 2, mModelInstances);
if (pickedModel != -1)
{
score++;
mModelInstances.erase(mModelInstances.begin() + pickedModel);
}
}
SetCapture(mhMainWnd);
}
示例3: playEnvironment
int Game::playEnvironment()
{
bool soundDone=false;
FMOD::System* system;
FMOD_RESULT result = FMOD::System_Create(&system);
system->init(32, FMOD_INIT_NORMAL, NULL);
FMOD::Sound* sound;
result = system->createSound("Ocean.WAV",FMOD_LOOP_NORMAL,NULL, &sound);
FMOD::Channel* channel = 0;
bool pauseSound = false;
channel->isPlaying(&pauseSound);
result = system->playSound(FMOD_CHANNEL_FREE, sound,false, &channel);
soundDone=true;
while (soundDone!=true)
{
channel->setPaused(false);
system->update();
result = sound->release();
result = system->close();
result = system->release();
}
return 0;
}
示例4: playAudio
void AudioVisualizerApp::playAudio( const fs::path& file )
{
FMOD_RESULT err;
// ignore if this is not a file
if( file.empty() || !fs::is_regular_file( file ) )
return;
// if audio is already playing, stop it first
stopAudio();
// stream the audio
err = mFMODSystem->createStream( file.string().c_str(), FMOD_SOFTWARE, NULL, &mFMODSound );
err = mFMODSystem->playSound( FMOD_CHANNEL_FREE, mFMODSound, false, &mFMODChannel );
// we want to be notified of channel events
err = mFMODChannel->setCallback( channelCallback );
// keep track of the audio file
mAudioPath = file;
mIsAudioPlaying = true;
//
console() << "Now playing:" << mAudioPath.filename() << std::endl;
}
示例5: setup
void _TBOX_PREFIX_App::setup()
{
FMOD::System_Create( &mSystem );
mSystem->init( 32, FMOD_INIT_NORMAL | FMOD_INIT_ENABLE_PROFILE, NULL );
mSystem->createSound( getAssetPath( "Blank__Kytt_-_08_-_RSPN.mp3" ).string().c_str(), FMOD_SOFTWARE, NULL, &mSound );
mSound->setMode( FMOD_LOOP_NORMAL );
mSystem->playSound( FMOD_CHANNEL_FREE, mSound, false, &mChannel );
}
示例6: initSound
void Game::initSound()
{
FMOD::System *system = NULL;
FMOD::Sound *sound = NULL;
FMOD::Channel *channel;
FMOD::System_Create(&system);
system->init(32, FMOD_INIT_NORMAL, 0);
system->createSound("data/drumloop.wav", FMOD_SOFTWARE, 0, &sound);
system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
}
示例7: PlayRollSound
void FMOD_System::PlayRollSound()
{
if( roll != nullptr )
{
if( !IsPlaying( rollChannel ) && !IsPlaying( collisionChannel ) )
{
system->playSound( FMOD_CHANNEL_FREE, roll, true, &rollChannel );
rollChannel->set3DAttributes( &ballPosition, nullptr );
rollChannel->setPaused( false );
}
}
}
示例8: PlayJetSound
void FMOD_System::PlayJetSound()
{
if( jet != nullptr )
{
if( !IsPlaying( jetChannel ) )
{
system->playSound( FMOD_CHANNEL_FREE, jet, true, &jetChannel );
jetChannel->set3DAttributes( &ballPosition, nullptr );
jetChannel->setPaused( false );
}
}
}
示例9: PlayCollisionSound
void FMOD_System::PlayCollisionSound()
{
if( collision != nullptr )
{
if( !IsPlaying( collisionChannel ) )
{
system->playSound( FMOD_CHANNEL_FREE, collision, true, &collisionChannel );
collisionChannel->set3DAttributes( &ballPosition, nullptr );
collisionChannel->setPaused( false );
}
}
}
示例10: mouseDown
void StepTwoApp::mouseDown( MouseEvent event )
{
int n;
FMODErrorCheck( mSystem->getChannelsPlaying(&n) );
if(n>=32) {
console() << "Too many sounds playing!" << endl;
return;
}
FMOD::Sound* sound = mSounds[Rand::randInt(mSounds.size())];
// Channels inherit the modes of sounds.
FMOD::Channel* channel;
mSystem->playSound( FMOD_CHANNEL_FREE, sound, false, &channel );
}
示例11: StartPlayingLoopingSounds
void FMOD_System::StartPlayingLoopingSounds()
{
if( bgmusic != nullptr )
{
system->playSound( FMOD_CHANNEL_FREE, bgmusic, false, nullptr );
}
if( ventSound != nullptr )
{
std::for_each( vents.begin(), vents.end(), [&]( VentPoint v )
{
FMOD::Channel *vent_channel;
FMOD_System::system->playSound( FMOD_CHANNEL_FREE, ventSound, true, &vent_channel );
FMOD_VECTOR position = { v.x, v.y, v.z };
vent_channel->set3DAttributes( &position, nullptr );
vent_channel->setPaused( false );
});
}
}
示例12:
void playBackground(void)
{
FMOD::System * Syst = NULL;
FMOD::Channel * Chan = NULL;
FMOD::Sound * s;
if (Syst == NULL)
{
if (FMOD::System_Create(&Syst) != FMOD_OK)
fmod_exit();
if (Syst->init(32, FMOD_INIT_NORMAL, 0) != FMOD_OK)
fmod_exit();
}
if (Syst->createSound("mp3/background.mp3", FMOD_LOOP_NORMAL, 0, &s) != FMOD_OK)
fmod_exit();
if (Syst->playSound(s, NULL, false, &Chan) != FMOD_OK)
fmod_exit();
Syst->update();
}
示例13: setup
void cinderFFmpegApp::setup()
{
m_Font = ci::Font("Consolas", 48);
setupGui();
gl::enableAlphaBlending();
std::shared_ptr<_2RealFFmpegWrapper::FFmpegWrapper> testFile = std::shared_ptr<_2RealFFmpegWrapper::FFmpegWrapper>(new _2RealFFmpegWrapper::FFmpegWrapper());
testFile->dumpFFmpegInfo();
//if(testFile->open(".\\data\\morph.avi"))
if(testFile->open("d:\\vjing\\Wildlife.wmv"))
{
m_Players.push_back(testFile);
m_VideoTextures.push_back(gl::Texture());
m_Players.back()->play();
}
m_dLastTime = 0;
m_iCurrentVideo = 0;
m_fSpeed = 1;
m_iLoopMode = _2RealFFmpegWrapper::eLoop;
m_iTilesDivisor = 1;
m_fSeekPos = m_fOldSeekPos = 0;
//setup fmod
FMOD::System_Create(&m_pSystem);
m_pSystem->init(32, FMOD_INIT_NORMAL, 0);
memset(&createsoundexinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
createsoundexinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO); /* required. */
createsoundexinfo.decodebuffersize = 1024; /* Chunk size of stream update in samples. This will be the amount of data passed to the user callback. */
createsoundexinfo.numchannels = 2; /* Number of channels in the sound. */
createsoundexinfo.length = -1; /* Length of PCM data in bytes of whole song. -1 = infinite. */
createsoundexinfo.defaultfrequency = (int)44100; /* Default playback rate of sound. */
createsoundexinfo.format = FMOD_SOUND_FORMAT_PCM16; /* Data format of sound. */
createsoundexinfo.pcmreadcallback = pcmreadcallback; /* User callback for reading. */
result = m_pSystem->createStream(0, FMOD_2D | FMOD_OPENUSER | FMOD_LOOP_OFF, &createsoundexinfo, &m_pSound);
result = m_pSystem->playSound(FMOD_CHANNEL_FREE, m_pSound, 0, &m_pChannel);
//std::shared_ptr<audio::Callback<cinderFFmpegApp,unsigned short>> audioCallback = audio::createCallback( this, &cinderFFmpegApp::audioCallback );
//audio::Output::play( audioCallback );
}
示例14: playSound
int Game::playSound(bool Sound)
{
bool soundDone= false;
//declare variable for FMOD system object
FMOD::System* system;
//allocate memory for the FMOD system object
FMOD_RESULT result = FMOD::System_Create(&system);
//initialize the FMOD system object
system->init(32, FMOD_INIT_NORMAL, NULL);
//declare variable for the sound object
FMOD::Sound* sound;
//created sound object and specify the sound
result = system->createSound("Cathedral_of_Light.mp3",FMOD_LOOP_NORMAL,NULL, &sound);
// play sound - 1st parameter can be combined flags (| separator)
FMOD::Channel* channel = 0;
//start sound
bool pauseSound=false;
channel->isPlaying(&pauseSound);
result = system->playSound(FMOD_CHANNEL_FREE, sound, Sound, &channel);
soundDone=true;
while (soundDone!=true)
{
channel->setPaused(false);
system->update();
//}
// release resources
result = sound->release();
result = system->close();
result = system->release();
}
return 0;
}
示例15: FMOD_Main
int FMOD_Main()
{
FMOD::System *system;
FMOD::Sound *sound;
FMOD::Channel *channel;
FMOD::DSP *mydsp;
FMOD::ChannelGroup *mastergroup;
FMOD_RESULT result;
unsigned int version;
void *extradriverdata = 0;
Common_Init(&extradriverdata);
/*
Create a System object and initialize.
*/
result = FMOD::System_Create(&system);
ERRCHECK(result);
result = system->getVersion(&version);
ERRCHECK(result);
if (version < FMOD_VERSION)
{
Common_Fatal("FMOD lib version %08x doesn't match header version %08x", version, FMOD_VERSION);
}
result = system->init(32, FMOD_INIT_NORMAL, extradriverdata);
ERRCHECK(result);
result = system->createSound(Common_MediaPath("drumloop.wav"), FMOD_SOFTWARE | FMOD_LOOP_NORMAL, 0, &sound);
ERRCHECK(result);
result = system->playSound(sound, 0, false, &channel);
ERRCHECK(result);
/*
Create the DSP effect.
*/
{
FMOD_DSP_DESCRIPTION dspdesc;
memset(&dspdesc, 0, sizeof(dspdesc));
strncpy(dspdesc.name, "My first DSP unit", sizeof(dspdesc.name));
dspdesc.version = 0x00010000;
dspdesc.numinputbuffers = 1;
dspdesc.numoutputbuffers = 1;
dspdesc.read = myDSPCallback;
dspdesc.userdata = (void *)0x12345678;
result = system->createDSP(&dspdesc, &mydsp);
ERRCHECK(result);
}
/*
Attach the DSP, inactive by default.
*/
result = mydsp->setBypass(true);
ERRCHECK(result);
result = system->getMasterChannelGroup(&mastergroup);
ERRCHECK(result);
result = mastergroup->addDSP(0, mydsp, 0);
ERRCHECK(result);
/*
Main loop.
*/
do
{
bool bypass;
Common_Update();
result = mydsp->getBypass(&bypass);
ERRCHECK(result);
if (Common_BtnPress(BTN_ACTION1))
{
bypass = !bypass;
result = mydsp->setBypass(bypass);
ERRCHECK(result);
}
result = system->update();
ERRCHECK(result);
Common_Draw("==================================================");
Common_Draw("Custom DSP Example.");
Common_Draw("Copyright (c) Firelight Technologies 2004-2014.");
Common_Draw("==================================================");
Common_Draw("");
Common_Draw("Press %s to toggle filter bypass", Common_BtnStr(BTN_ACTION1));
Common_Draw("Press %s to quit", Common_BtnStr(BTN_QUIT));
Common_Draw("");
Common_Draw("Filter is %s", bypass ? "inactive" : "active");
Common_Sleep(50);
//.........这里部分代码省略.........