本文整理汇总了C++中fmod::System::createSound方法的典型用法代码示例。如果您正苦于以下问题:C++ System::createSound方法的具体用法?C++ System::createSound怎么用?C++ System::createSound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fmod::System
的用法示例。
在下文中一共展示了System::createSound方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateSounds
void FMOD_System::CreateSounds( const SoundFilenameMap& soundFilenames )
{
auto isPresent = [=]( const std::string& key ) -> bool
{
return ( soundFilenames.find( key ) != soundFilenames.end() ) ? true : false;
};
if( isPresent( "bgmusic" ) )
{
ErrorCheck( system->createStream( soundFilenames.at("bgmusic").c_str(), FMOD_LOOP_NORMAL | FMOD_CREATESTREAM,
nullptr, &bgmusic ) );
bgmusic->setDefaults( 44100, 0.025f, 0.f, 128 );
}
if( isPresent( "jet" ) )
{
ErrorCheck( system->createSound( soundFilenames.at( "jet" ).c_str(), FMOD_3D, nullptr, &jet ) );
jet->setDefaults( 44100, 0.75f, 0.f, 128 );
}
if( isPresent( "vent" ) )
{
ErrorCheck( system->createSound( soundFilenames.at( "vent" ).c_str(), FMOD_3D | FMOD_LOOP_NORMAL,
nullptr, &ventSound ) );
ventSound->setDefaults( 44100, 0.3f, 0.f, 128 );
}
if( isPresent( "collision" ) )
{
ErrorCheck( system->createSound( soundFilenames.at( "collision" ).c_str(), FMOD_3D, nullptr, &collision ) );
collision->setDefaults( 44100, 5.f, 0.f, 128 );
}
if( isPresent( "roll" ) )
{
ErrorCheck( system->createSound( soundFilenames.at( "roll" ).c_str(), FMOD_3D, nullptr, &roll ) );
roll->setDefaults( 44100, 2.f, 0.f, 128 );
}
}
示例2:
void loadSounds(void)
{
FMOD::System * Syst;
FMOD::Sound * sound;
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/laser.mp3", FMOD_CREATESAMPLE, 0, &sound) != FMOD_OK)
fmod_exit();
getSoundData(sound, SOUND_LASER);
if (Syst->createSound("mp3/explosion.mp3", FMOD_CREATESAMPLE, 0, &sound) != FMOD_OK)
fmod_exit();
getSoundData(sound, SOUND_EXPLOSION);
}
示例3:
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);
}
示例4: 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;
}
示例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: 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;
}
示例8: initializeSound
void initializeSound()
{
FMOD::System *system;
unsigned int version;
result = FMOD::System_Create(&system);
ERRCHECK(result);
result = system->getVersion(&version);
ERRCHECK(result);
if (version < FMOD_VERSION)
{
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
exit(-3);
}
result = system->init(32, FMOD_INIT_NORMAL, NULL);
ERRCHECK(result);
result = system->createSound("/Users/adrtwin/Music/What You Know (Mustang Remix).mp3", FMOD_SOFTWARE, 0, &sound1);
ERRCHECK(result);
/*
result = system->createSound("CALIBRATING", FMOD_SOFTWARE, 0, &sound2);
ERRCHECK(result);
result = system->createSound("SHOT", FMOD_SOFTWARE, 0, &sound3);
ERRCHECK(result);
result = system->createSound("SHOT_NO_AMMO", FMOD_SOFTWARE, 0, &sound4);
ERRCHECK(result);
result = system->createSound("RELOADING", FMOD_SOFTWARE, 0, &sound5);
ERRCHECK(result);
*/
globalSystem = system;
}
示例9: createStreamingSound
FMOD::Sound* FMODAudioClip::createStreamingSound() const
{
if(getReadMode() != AudioReadMode::Stream || mStreamData == nullptr)
{
LOGERR("Invalid audio stream data.");
return nullptr;
}
FMOD_MODE flags = FMOD_CREATESTREAM;
FMOD_CREATESOUNDEXINFO exInfo;
memset(&exInfo, 0, sizeof(exInfo));
exInfo.cbsize = sizeof(exInfo);
// Streaming from memory not supported.
assert(mStreamData->isFile());
exInfo.length = mStreamSize;
exInfo.fileoffset = mStreamOffset;
SPtr<FileDataStream> fileStream = std::static_pointer_cast<FileDataStream>(mStreamData);
String pathStr = fileStream->getPath().toString();
if (is3D())
flags |= FMOD_3D;
else
flags |= FMOD_2D;
FMOD::Sound* sound = nullptr;
FMOD::System* fmod = gFMODAudio()._getFMOD();
if (fmod->createSound(pathStr.c_str(), flags, &exInfo, &sound) != FMOD_OK)
{
LOGERR("Failed creating a streaming sound.");
return nullptr;
}
sound->setMode(FMOD_LOOP_OFF);
return sound;
}
示例10: switch
MicrophoneRecorder::MicrophoneRecorder(int frequency, int channels, FMOD_SOUND_FORMAT format)
: m_fmodsnd(nullptr)
, m_fmodsys(nullptr)
, m_dataLength(0)
, m_byteSize(0)
, m_frequency(frequency)
, m_channels(channels)
{
switch (format)
{
case FMOD_SOUND_FORMAT_PCM8: m_byteSize = 1; break;
case FMOD_SOUND_FORMAT_PCM16: m_byteSize = 2; break;
case FMOD_SOUND_FORMAT_PCM24: m_byteSize = 3; break;
case FMOD_SOUND_FORMAT_PCM32: m_byteSize = 4; break;
case FMOD_SOUND_FORMAT_PCMFLOAT: m_byteSize = 4; break;
}
CHECK(m_byteSize > 0);
FMOD::System * fmodSys = SoundMngr::Get()->GetSys();
FMOD_CREATESOUNDEXINFO exinfo;
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.numchannels = channels;
exinfo.format = format;
exinfo.defaultfrequency = frequency;
exinfo.length = exinfo.defaultfrequency * m_byteSize * exinfo.numchannels * 2;
unsigned int flags = FMOD_SOFTWARE | FMOD_2D | FMOD_OPENUSER;
FMOD_ERRCHECK(fmodSys->createSound(0, flags, &exinfo, &m_fmodsnd));
m_fmodsys = fmodSys;
m_data.resize(channels);
}
示例11: setup
void StepTwoApp::setup()
{
FMODListDevices();
FMODErrorCheck(FMOD::System_Create( &mSystem ));
FMODErrorCheck(mSystem->setDriver(0));
FMOD_INITFLAGS flags = FMOD_INIT_NORMAL; // right-click, Go To Definition
FMODErrorCheck(mSystem->init( 32, flags, NULL ));
vector<fs::path> paths;
paths.push_back( getAssetPath("gong-loud-hit.mp3") );
paths.push_back( getAssetPath("orch-hit.wav") );
paths.push_back( getAssetPath("trumpethit07.wav") );
for(auto& path: paths) {
FMOD::Sound* sound;
mSystem->createSound( path.string().c_str(), FMOD_SOFTWARE, NULL, &sound );
// You can change the mode of sounds at any time.
FMOD_MODE mode = FMOD_SOFTWARE | FMOD_2D | FMOD_LOOP_OFF;
FMODErrorCheck( sound->setMode( mode ) );
mSounds.push_back(sound);
}
}
示例12: main
int main(int argc, char *argv[])
{
FMOD::System *system;
FMOD::Sound *sound;
FMOD::Channel *channel = 0;
FMOD_RESULT result;
FMOD_MODE mode = FMOD_2D | FMOD_OPENUSER | FMOD_LOOP_NORMAL | FMOD_HARDWARE;
int key;
int channels = 2;
FMOD_CREATESOUNDEXINFO createsoundexinfo;
unsigned int version;
/*
Create a System object and initialize.
*/
result = FMOD::System_Create(&system);
ERRCHECK(result);
result = system->getVersion(&version);
ERRCHECK(result);
if (version < FMOD_VERSION)
{
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
return 0;
}
result = system->init(32, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);
printf("============================================================================\n");
printf("User Created Sound Example. Copyright (c) Firelight Technologies 2004-2014.\n");
printf("============================================================================\n");
printf("Sound played here is generated in realtime. It will either play as a stream\n");
printf("which means it is continually filled as it is playing, or it will play as a \n");
printf("static sample, which means it is filled once as the sound is created, then \n");
printf("when played it will just play that short loop of data. \n");
printf("============================================================================\n");
printf("\n");
do
{
printf("Press 1 to play as a runtime decoded stream. (will carry on infinitely)\n");
printf("Press 2 to play as a static in memory sample. (loops a short block of data)\n");
printf("Press Esc to quit.\n\n");
key = _getch();
} while (key != 27 && key != '1' && key != '2');
if (key == 27)
{
return 0;
}
else if (key == '1')
{
mode |= FMOD_CREATESTREAM;
}
memset(&createsoundexinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
createsoundexinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO); /* required. */
createsoundexinfo.decodebuffersize = 44100; /* Chunk size of stream update in samples. This will be the amount of data passed to the user callback. */
createsoundexinfo.length = 44100 * channels * sizeof(signed short) * 5; /* Length of PCM data in bytes of whole song (for Sound::getLength) */
createsoundexinfo.numchannels = channels; /* Number of channels in the sound. */
createsoundexinfo.defaultfrequency = 44100; /* Default playback rate of sound. */
createsoundexinfo.format = FMOD_SOUND_FORMAT_PCM16; /* Data format of sound. */
createsoundexinfo.pcmreadcallback = pcmreadcallback; /* User callback for reading. */
createsoundexinfo.pcmsetposcallback = pcmsetposcallback; /* User callback for seeking. */
result = system->createSound(0, mode, &createsoundexinfo, &sound);
ERRCHECK(result);
printf("Press space to pause, Esc to quit\n");
printf("\n");
/*
Play the sound.
*/
result = system->playSound(FMOD_CHANNEL_FREE, sound, 0, &channel);
ERRCHECK(result);
/*
Main loop.
*/
do
{
if (_kbhit())
{
key = _getch();
switch (key)
{
case ' ' :
{
bool paused;
channel->getPaused(&paused);
channel->setPaused(!paused);
break;
}
}
//.........这里部分代码省略.........
示例13: main
int main(int argc, char *argv[])
{
int numSounds = 1;
FMOD::System *system;
FMOD::Sound *sound[numSounds];
FMOD::Sound *applause;
FMOD::Channel *channel[numSounds];
FMOD::Channel *applauseChannel;
FMOD::DSP *dsppitch;
FMOD::DSP *dsplowpass = 0;
FMOD::DSP *dsphighpass = 0;
FMOD::DSP *dspecho = 0;
FMOD::DSP *dspflange = 0;
FMOD::DSP *dspdistortion = 0;
FMOD::DSP *dspchorus = 0;
FMOD::DSP *dspparameq = 0;
FMOD_RESULT result;
int key;
unsigned int version;
float pan = 0;
float volume;
float frequency;
int tempFrequency = 0;
int tempPitch = 0;
int frequencyCount = 0;
int pitchCount = 0;
int tempoChange = 0;
float speed;
float pitch = 1;
float originalFrequency;
string line;
int lineCount = 0;
int inc = 0;
int count;
float frequencyArray[numSounds];
float frequencyCountArray[numSounds];
float pitchfArray[numSounds];
float volumeArray[numSounds];
float panArray[numSounds];
float pitchf = 1.0f;
/*
Create a System object and initialize.
*/
result = FMOD::System_Create(&system);
ERRCHECK(result);
result = system->getVersion(&version);
ERRCHECK(result);
if (version < FMOD_VERSION)
{
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
return 0;
}
result = system->init(32, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);
result = system->createSound("../Config/Seven Nation Army Drum.mp3", FMOD_SOFTWARE | FMOD_LOOP_NORMAL | FMOD_2D, 0, &sound[0]);
ERRCHECK(result);
printf("===============================================================================\n");
printf(" Maestro \n");
printf("===============================================================================\n");
printf("Press '1' to play left speaker only\n");
printf("Press '2' to play right speaker only\n");
printf("Press '3' to play from both speakers\n");
printf("Press '[' to pan sound left\n");
printf("Press ']' to pan sound right\n");
printf("Press 'v/V' to increase volume\n");
printf("Press 'd/D' to decrease volume\n");
printf("Press '6' pitch octave down\n");
printf("Press '7' pitch semitone down\n");
printf("Press '8' pitch semitone up\n");
printf("Press '9' pitch octave up\n");
printf("Press 'Esc' to quit\n");
printf("Press 'n' pitch scale down\n");
printf("Press 'm' pitch scale up\n");
printf("\n");
for (count = 0; count < numSounds; count++)
{
result = system->playSound(FMOD_CHANNEL_FREE, sound[count], false, &channel[count]);
ERRCHECK(result);
bool paused;
channel[0]->getPaused(&paused);
ERRCHECK(result);
paused = !paused;
result = channel[0]->setPaused(paused);
ERRCHECK(result);
}
//.........这里部分代码省略.........
示例14: main
int main(int argc, char *argv[])
{
FMOD::System *system;
FMOD::Sound *sound1, *sound2, *sound3;
FMOD::Channel *channel = 0;
FMOD_RESULT result;
int key;
unsigned int version;
/*
Global Settings
*/
result = FMOD::System_Create(&system);
ERRCHECK(result);
result = system->getVersion(&version);
ERRCHECK(result);
if (version < FMOD_VERSION)
{
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
getch();
return 0;
}
result = system->init(32, FMOD_INIT_NORMAL, NULL);
ERRCHECK(result);
result = system->createSound("../media/drumloop.wav", FMOD_SOFTWARE, 0, &sound1);
ERRCHECK(result);
result = sound1->setMode(FMOD_LOOP_OFF);
ERRCHECK(result);
result = system->createSound("../media/jaguar.wav", FMOD_SOFTWARE, 0, &sound2);
ERRCHECK(result);
result = system->createSound("../media/swish.wav", FMOD_SOFTWARE, 0, &sound3);
ERRCHECK(result);
printf("===================================================================\n");
printf("PlaySound Example. Copyright (c) Firelight Technologies 2004-2011.\n");
printf("===================================================================\n");
printf("\n");
printf("Press '1' to Play a mono sound using software mixing\n");
printf("Press '2' to Play a mono sound using software mixing\n");
printf("Press '3' to Play a stereo sound using software mixing\n");
printf("Press 'Esc' to quit\n");
printf("\n");
/*
Main loop.
*/
do
{
if (kbhit())
{
key = getch();
switch (key)
{
case '1' :
{
result = system->playSound(FMOD_CHANNEL_FREE, sound1, 0, &channel);
ERRCHECK(result);
break;
}
case '2' :
{
result = system->playSound(FMOD_CHANNEL_FREE, sound2, 0, &channel);
ERRCHECK(result);
break;
}
case '3' :
{
result = system->playSound(FMOD_CHANNEL_FREE, sound3, 0, &channel);
ERRCHECK(result);
break;
}
}
}
system->update();
{
unsigned int ms = 0;
unsigned int lenms = 0;
bool playing = 0;
bool paused = 0;
int channelsplaying = 0;
if (channel)
{
FMOD::Sound *currentsound = 0;
result = channel->isPlaying(&playing);
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
{
ERRCHECK(result);
}
//.........这里部分代码省略.........
示例15: main
int main(int argc, char *argv[])
{
FMOD::System *system;
FMOD::Sound *sound[6];
FMOD::Channel *channel[6];
FMOD::ChannelGroup *groupA, *groupB, *masterGroup;
FMOD_RESULT result;
int key, count;
unsigned int version;
/*
Create a System object and initialize.
*/
result = FMOD::System_Create(&system);
ERRCHECK(result);
result = system->getVersion(&version);
ERRCHECK(result);
if (version < FMOD_VERSION)
{
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
return 0;
}
result = system->init(32, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);
result = system->createSound("../media/drumloop.wav", FMOD_LOOP_NORMAL, 0, &sound[0]);
ERRCHECK(result);
result = system->createSound("../media/jaguar.wav", FMOD_LOOP_NORMAL, 0, &sound[1]);
ERRCHECK(result);
result = system->createSound("../media/swish.wav", FMOD_LOOP_NORMAL, 0, &sound[2]);
ERRCHECK(result);
result = system->createSound("../media/c.ogg", FMOD_LOOP_NORMAL, 0, &sound[3]);
ERRCHECK(result);
result = system->createSound("../media/d.ogg", FMOD_LOOP_NORMAL, 0, &sound[4]);
ERRCHECK(result);
result = system->createSound("../media/e.ogg", FMOD_LOOP_NORMAL, 0, &sound[5]);
ERRCHECK(result);
result = system->createChannelGroup("Group A", &groupA);
ERRCHECK(result);
result = system->createChannelGroup("Group B", &groupB);
ERRCHECK(result);
result = system->getMasterChannelGroup(&masterGroup);
ERRCHECK(result);
printf("=======================================================================\n");
printf("ChannelGroups Example. Copyright (c) Firelight Technologies 2004-2014.\n");
printf("=======================================================================\n");
printf("\n");
printf("Group A : drumloop.wav, jaguar.wav, swish.wav\n");
printf("Group B : c.ogg, d.ogg, e.ogg\n");
printf("\n");
printf("Press 'A' to mute/unmute group A\n");
printf("Press 'B' to mute/unmute group B\n");
printf("Press 'C' to mute/unmute group A and B (master group)\n");
printf("Press 'Esc' to quit\n");
printf("\n");
/*
Instead of being independent, set the group A and B to be children of the master group.
*/
result = masterGroup->addGroup(groupA);
ERRCHECK(result);
result = masterGroup->addGroup(groupB);
ERRCHECK(result);
/*
Start all the sounds!
*/
for (count = 0; count < 6; count++)
{
result = system->playSound(FMOD_CHANNEL_FREE, sound[count], true, &channel[count]);
ERRCHECK(result);
if (count < 3)
{
result = channel[count]->setChannelGroup(groupA);
}
else
{
result = channel[count]->setChannelGroup(groupB);
}
ERRCHECK(result);
result = channel[count]->setPaused(false);
ERRCHECK(result);
}
/*
Change the volume of each group, just because we can! (And makes it less noise).
*/
result = groupA->setVolume(0.5f);
ERRCHECK(result);
result = groupB->setVolume(0.5f);
ERRCHECK(result);
//.........这里部分代码省略.........