本文整理汇总了C++中fmod::System::getVersion方法的典型用法代码示例。如果您正苦于以下问题:C++ System::getVersion方法的具体用法?C++ System::getVersion怎么用?C++ System::getVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fmod::System
的用法示例。
在下文中一共展示了System::getVersion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: FMOD_Main
int FMOD_Main()
{
FMOD::System *system;
FMOD::Sound *sound, *sound_to_play;
FMOD::Channel *channel = 0;
FMOD_RESULT result;
unsigned int version;
void *extradriverdata = 0;
int numsubsounds;
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);
/*
This example uses an FSB file, which is a preferred pack format for fmod containing multiple sounds.
This could just as easily be exchanged with a wav/mp3/ogg file for example, but in this case you wouldnt need to call getSubSound.
Because getNumSubSounds is called here the example would work with both types of sound file (packed vs single).
*/
result = system->createSound(Common_MediaPath("wave_vorbis.fsb"), FMOD_LOOP_NORMAL | FMOD_2D, 0, &sound);
ERRCHECK(result);
result = sound->getNumSubSounds(&numsubsounds);
ERRCHECK(result);
if (numsubsounds)
{
sound->getSubSound(0, &sound_to_play);
ERRCHECK(result);
}
else
{
sound_to_play = sound;
}
/*
Play the sound.
*/
result = system->playSound(sound_to_play, 0, false, &channel);
ERRCHECK(result);
/*
Main loop.
*/
do
{
Common_Update();
if (Common_BtnPress(BTN_ACTION1))
{
bool paused;
result = channel->getPaused(&paused);
ERRCHECK(result);
result = channel->setPaused(!paused);
ERRCHECK(result);
}
result = system->update();
ERRCHECK(result);
{
unsigned int ms = 0;
unsigned int lenms = 0;
bool playing = false;
bool paused = false;
if (channel)
{
result = channel->isPlaying(&playing);
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
{
ERRCHECK(result);
}
result = channel->getPaused(&paused);
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
{
ERRCHECK(result);
}
result = channel->getPosition(&ms, FMOD_TIMEUNIT_MS);
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
{
ERRCHECK(result);
}
//.........这里部分代码省略.........
示例3: main
int main(int argc, char *argv[])
{
FMOD::System *system;
FMOD::Sound *sound;
FMOD::Channel *channel;
FMOD::DSP *mydsp;
FMOD_RESULT result;
int key;
unsigned int version;
float pan = 0;
/*
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_SOFTWARE | FMOD_LOOP_NORMAL, 0, &sound);
ERRCHECK(result);
printf("===============================================================================\n");
printf("Custom DSP example. Copyright (c) Firelight Technologies 2004-2011.\n");
printf("===============================================================================\n");
printf("Press 'f' to activate, deactivate user filter\n");
printf("Press 'Esc' to quit\n");
printf("\n");
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
ERRCHECK(result);
/*
Create the DSP effects.
*/
{
FMOD_DSP_DESCRIPTION dspdesc;
memset(&dspdesc, 0, sizeof(FMOD_DSP_DESCRIPTION));
strcpy(dspdesc.name, "My first DSP unit");
dspdesc.channels = 0; // 0 = whatever comes in, else specify.
dspdesc.read = myDSPCallback;
dspdesc.userdata = (void *)0x12345678;
result = system->createDSP(&dspdesc, &mydsp);
ERRCHECK(result);
}
/*
Inactive by default.
*/
mydsp->setBypass(true);
/*
Main loop.
*/
result = system->addDSP(mydsp, 0);
/*
Main loop.
*/
do
{
if (kbhit())
{
key = getch();
switch (key)
{
case 'f' :
case 'F' :
{
static bool active = false;
mydsp->setBypass(active);
active = !active;
break;
}
}
}
system->update();
Sleep(10);
} while (key != 27);
//.........这里部分代码省略.........
示例4: 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;
}
}
//.........这里部分代码省略.........
示例5: main
int main(int argc, char *argv[])
{
FMOD::System *system;
FMOD::Sound *sound;
FMOD_RESULT result;
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(1, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);
result = system->createStream("../media/wave.mp3", FMOD_OPENONLY | FMOD_ACCURATETIME, 0, &sound);
ERRCHECK(result);
printf("==========================================================================\n");
printf("Offline Decoding Example. Copyright (c) Firelight Technologies 2004-2011.\n");
printf("==========================================================================\n");
printf("\n");
printf("This program will open wave.mp3 and decode it into wave.raw using the\n");
printf("Sound::readData function.\n");
printf("\n");
/*
Decode the sound and write it to a .raw file.
*/
{
void *data;
unsigned int length = 0, read;
unsigned int bytesread;
FILE *outfp;
#define CHUNKSIZE 4096
result = sound->getLength(&length, FMOD_TIMEUNIT_PCMBYTES);
ERRCHECK(result);
outfp = fopen("output.raw", "wb");
if (!outfp)
{
printf("Error! Could not open output.raw output file.\n");
return 0;
}
data = malloc(CHUNKSIZE);
if (!data)
{
printf("Error! Failed to allocate %d bytes.\n", CHUNKSIZE);
return 0;
}
bytesread = 0;
do
{
result = sound->readData((char *)data, CHUNKSIZE, &read);
fwrite((char *)data, read, 1, outfp);
bytesread += read;
printf("writing %d bytes of %d to output.raw\r", bytesread, length);
}
while (result == FMOD_OK && read == CHUNKSIZE);
/*
Loop terminates when either
1. the read function returns an error. (ie FMOD_ERR_FILE_EOF etc).
2. the amount requested was different to the amount returned. (somehow got an EOF without the file error, maybe a non stream file format like mod/s3m/xm/it/midi).
If 'bytesread' is bigger than 'length' then it just means that FMOD miscalculated the size,
but this will not usually happen if FMOD_ACCURATETIME is used. (this will give the correct length for VBR formats)
*/
printf("\n");
if (outfp)
{
fclose(outfp);
}
}
printf("\n");
/*
Shut down
*/
//.........这里部分代码省略.........
示例6: main
int main(int argc, char *argv[])
{
FMOD::System *system;
FMOD::Sound *sound;
FMOD::Channel *channel = 0;
FMOD_RESULT result;
int key;
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(1, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);
result = system->setFileSystem(myopen, myclose, myread, myseek, 0, 0, 2048);
ERRCHECK(result);
result = system->createStream("../media/wave.mp3", FMOD_HARDWARE | FMOD_LOOP_NORMAL | FMOD_2D, 0, &sound);
ERRCHECK(result);
printf("========================================================================\n");
printf("File Callbacks Example. Copyright (c) Firelight Technologies 2004-2015.\n");
printf("========================================================================\n");
printf("\n");
printf("Press space to pause, Esc to quit\n");
printf("\n");
/*
Play the sound.
*/
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
ERRCHECK(result);
/*
Main loop.
*/
do
{
if (kbhit())
{
key = getch();
switch (key)
{
case ' ' :
{
bool paused;
channel->getPaused(&paused);
channel->setPaused(!paused);
break;
}
}
}
system->update();
if (channel)
{
unsigned int ms;
unsigned int lenms;
bool playing;
bool paused;
channel->isPlaying(&playing);
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
{
ERRCHECK(result);
}
result = channel->getPaused(&paused);
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
{
ERRCHECK(result);
}
result = channel->getPosition(&ms, FMOD_TIMEUNIT_MS);
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
{
ERRCHECK(result);
}
result = sound->getLength(&lenms, FMOD_TIMEUNIT_MS);
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
{
ERRCHECK(result);
}
//.........这里部分代码省略.........
示例7: main
int main(int argc, char *argv[])
{
FMOD::System *system;
FMOD::Sound *sound;
FMOD::Channel *channel = 0;
FMOD_RESULT result;
int key;
unsigned int version;
memset(gCurrentTrackArtist, 0, 256);
memset(gCurrentTrackTitle, 0, 256);
strcpy(gOutputFileName, "output.mp3"); /* Start off like this then rename if a title tag comes along */
printf("======================================================================\n");
printf("RipNetStream Example. Copyright (c) Firelight Technologies 2004-2014.\n");
printf("======================================================================\n\n");
if (argc < 2)
{
printf("Usage: ripnetstream <url>\n");
return -1;
}
/*
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(100, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);
result = system->setStreamBufferSize(gFileBufferSize, FMOD_TIMEUNIT_RAWBYTES);
ERRCHECK(result);
result = system->attachFileSystem(myopen, myclose, myread, 0);
ERRCHECK(result);
printf("Buffering...\n\n");
result = system->createSound(argv[1], FMOD_HARDWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_NONBLOCKING, 0, &sound);
ERRCHECK(result);
/*
Main loop
*/
do
{
static bool mute = false;
if (sound && !channel)
{
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
}
if (_kbhit())
{
key = _getch();
switch (key)
{
case ' ' :
{
if (channel)
{
bool paused;
channel->getPaused(&paused);
channel->setPaused(!paused);
}
break;
}
case 'm' :
case 'M' :
{
if (channel)
{
channel->getMute(&mute);
channel->setMute(!mute);
}
break;
}
}
}
system->update();
if (channel)
{
bool playing = false;
int tagsupdated = 0;
//.........这里部分代码省略.........
示例8: FMOD_Main
int FMOD_Main()
{
FMOD::Channel *channel = NULL;
unsigned int samplesRecorded = 0;
unsigned int samplesPlayed = 0;
bool dspEnabled = false;
void *extraDriverData = NULL;
Common_Init(&extraDriverData);
/*
Create a System object and initialize.
*/
FMOD::System *system = NULL;
FMOD_RESULT result = FMOD::System_Create(&system);
ERRCHECK(result);
unsigned int version = 0;
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(100, FMOD_INIT_NORMAL, extraDriverData);
ERRCHECK(result);
int numDrivers = 0;
result = system->getRecordNumDrivers(NULL, &numDrivers);
ERRCHECK(result);
if (numDrivers == 0)
{
Common_Fatal("No recording devices found/plugged in! Aborting.");
}
/*
Determine latency in samples.
*/
int nativeRate = 0;
int nativeChannels = 0;
result = system->getRecordDriverInfo(DEVICE_INDEX, NULL, 0, NULL, &nativeRate, NULL, &nativeChannels, NULL);
ERRCHECK(result);
unsigned int driftThreshold = (nativeRate * DRIFT_MS) / 1000; /* The point where we start compensating for drift */
unsigned int desiredLatency = (nativeRate * LATENCY_MS) / 1000; /* User specified latency */
unsigned int adjustedLatency = desiredLatency; /* User specified latency adjusted for driver update granularity */
int actualLatency = desiredLatency; /* Latency measured once playback begins (smoothened for jitter) */
/*
Create user sound to record into, then start recording.
*/
FMOD_CREATESOUNDEXINFO exinfo = {0};
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.numchannels = nativeChannels;
exinfo.format = FMOD_SOUND_FORMAT_PCM16;
exinfo.defaultfrequency = nativeRate;
exinfo.length = nativeRate * sizeof(short) * nativeChannels; /* 1 second buffer, size here doesn't change latency */
FMOD::Sound *sound = NULL;
result = system->createSound(0, FMOD_LOOP_NORMAL | FMOD_OPENUSER, &exinfo, &sound);
ERRCHECK(result);
result = system->recordStart(DEVICE_INDEX, sound, true);
ERRCHECK(result);
unsigned int soundLength = 0;
result = sound->getLength(&soundLength, FMOD_TIMEUNIT_PCM);
ERRCHECK(result);
/*
Main loop
*/
do
{
Common_Update();
/*
Add a DSP effect -- just for fun
*/
if (Common_BtnPress(BTN_ACTION1))
{
FMOD_REVERB_PROPERTIES propOn = FMOD_PRESET_CONCERTHALL;
FMOD_REVERB_PROPERTIES propOff = FMOD_PRESET_OFF;
dspEnabled = !dspEnabled;
result = system->setReverbProperties(0, dspEnabled ? &propOn : &propOff);
ERRCHECK(result);
}
result = system->update();
ERRCHECK(result);
/*
Determine how much has been recorded since we last checked
*/
unsigned int recordPos = 0;
//.........这里部分代码省略.........
示例9: main
int main(int argc, char *argv[])
{
FMOD::System *system;
FMOD::Sound *cdsound;
FMOD::Sound *sound;
FMOD::Channel *channel = 0;
FMOD_RESULT result;
int key, numtracks, currenttrack = 0;
unsigned int version;
if (argc < 2)
{
printf("Usage: cdplayer <drivepath>\n");
printf("Example: cdplayer /dev/cdrom\n");
exit(-1);
}
printf("==================================================================\n");
printf("CDPlayer Example. Copyright (c) Firelight Technologies 2004-2011.\n");
printf("==================================================================\n\n");
/*
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(1, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);
/*
Bump up the file buffer size a bit from the 16k default for CDDA, because it is a slower medium.
*/
result = system->setStreamBufferSize(64*1024, FMOD_TIMEUNIT_RAWBYTES);
ERRCHECK(result);
result = system->createStream(argv[1], FMOD_OPENONLY, 0, &cdsound);
ERRCHECK(result);
result = cdsound->getNumSubSounds(&numtracks);
ERRCHECK(result);
result = cdsound->getSubSound(currenttrack, &sound);
ERRCHECK(result);
for (;;)
{
FMOD_TAG tag;
if (cdsound->getTag(0, -1, &tag) != FMOD_OK)
{
break;
}
if (tag.datatype == FMOD_TAGDATATYPE_CDTOC)
{
dump_cddb_query((FMOD_CDTOC *)tag.data);
}
}
printf("\n========================================\n");
printf("Press SPACE to pause\n");
printf(" n to skip to next track\n");
printf(" ESC to exit\n");
printf("========================================\n\n");
/*
Print out length of entire CD. Did you know you can also play 'cdsound' and it will play the whole CD without gaps?
*/
{
unsigned int lenms;
result = cdsound->getLength(&lenms, FMOD_TIMEUNIT_MS);
ERRCHECK(result);
printf("Total CD length %02d:%02d\n\n", lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100);
}
/*
Play a CD track
*/
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
ERRCHECK(result);
/*
Main loop
*/
do
{
if (kbhit())
{
key = getch();
//.........这里部分代码省略.........
示例10: main
int main(int argc, char *argv[])
{
FMOD::System *system;
FMOD::Sound *cdsound;
FMOD::Channel *channel = 0;
FMOD_RESULT result;
int key;
unsigned int currenttrack = 0, numtracks;
unsigned int version;
printf("==================================================================\n");
printf("CDPlayer Example. Copyright (c) Firelight Technologies 2004-2011.\n");
printf("==================================================================\n\n");
/*
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(1, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);
/*
Bump up the file buffer size a bit from the 16k default for CDDA, because it is a slower medium.
*/
result = system->setStreamBufferSize(64*1024, FMOD_TIMEUNIT_RAWBYTES);
ERRCHECK(result);
/*
Try a few drive letters.
*/
result = system->createStream("d:", FMOD_OPENONLY, 0, &cdsound);
if (result != FMOD_OK)
{
result = system->createStream("e:", FMOD_OPENONLY, 0, &cdsound);
if (result != FMOD_OK)
{
result = system->createStream("f:", FMOD_OPENONLY, 0, &cdsound);
ERRCHECK(result);
}
}
result = cdsound->getNumSubSounds((int *)&numtracks);
ERRCHECK(result);
for (;;)
{
FMOD_TAG tag;
if (cdsound->getTag(0, -1, &tag) != FMOD_OK)
{
break;
}
if (tag.datatype == FMOD_TAGDATATYPE_CDTOC)
{
dump_cddb_query((FMOD_CDTOC *)tag.data);
}
}
printf("\n========================================\n");
printf("Press SPACE to pause\n");
printf(" n to skip to next track\n");
printf(" < re-wind 10 seconds\n");
printf(" > fast-forward 10 seconds\n");
printf(" ESC to exit\n");
printf("========================================\n\n");
/*
Print out length of entire CD. Did you know you can also play 'cdsound' and it will play the whole CD without gaps?
*/
{
unsigned int lenms;
result = cdsound->getLength(&lenms, FMOD_TIMEUNIT_MS);
ERRCHECK(result);
printf("Total CD length %02d:%02d\n\n", lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100);
}
/*
Play whole CD
*/
result = system->playSound(FMOD_CHANNEL_FREE, cdsound, false, &channel);
ERRCHECK(result);
/*
Main loop
*/
do
{
if (_kbhit())
//.........这里部分代码省略.........
示例11: main
int main(int argc, char *argv[])
{
FMOD::System *system;
FMOD::Sound *sound1, *sound2, *sound3;
FMOD::Channel *channel1 = 0, *channel2 = 0, *channel3 = 0;
FMOD_RESULT result;
int key;
bool listenerflag = true;
FMOD_VECTOR listenerpos = { 0.0f, 0.0f, -1.0f * DISTANCEFACTOR };
unsigned int version;
printf("===============================================================\n");
printf("3d Example. Copyright (c) Firelight Technologies 2004-2005.\n");
printf("===============================================================\n");
printf("This example plays 2 3D sounds in hardware. Optionally you can\n");
printf("play a 2D hardware sound as well.\n");
printf("===============================================================\n\n");
/*
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(100, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);
/*
Set the distance units. (meters/feet etc).
*/
result = system->set3DSettings(1.0, DISTANCEFACTOR, 1.0f);
ERRCHECK(result);
/*
Load some sounds
*/
result = system->createSound("../media/drumloop.wav", FMOD_HARDWARE | FMOD_3D, 0, &sound1);
ERRCHECK(result);
result = sound1->set3DMinMaxDistance(2.0f * DISTANCEFACTOR, 10000.0f * DISTANCEFACTOR);
ERRCHECK(result);
result = sound1->setMode(FMOD_LOOP_NORMAL);
ERRCHECK(result);
result = system->createSound("../media/jaguar.wav", FMOD_HARDWARE | FMOD_3D, 0, &sound2);
ERRCHECK(result);
result = sound2->set3DMinMaxDistance(2.0f * DISTANCEFACTOR, 10000.0f * DISTANCEFACTOR);
ERRCHECK(result);
result = sound2->setMode(FMOD_LOOP_NORMAL);
ERRCHECK(result);
result = system->createSound("../media/swish.wav", FMOD_HARDWARE | FMOD_2D, 0, &sound3);
ERRCHECK(result);
/*
Play sounds at certain positions
*/
{
FMOD_VECTOR pos = { -10.0f * DISTANCEFACTOR, 0.0f, 0.0f };
FMOD_VECTOR vel = { 0.0f, 0.0f, 0.0f };
result = system->playSound(FMOD_CHANNEL_FREE, sound1, true, &channel1);
ERRCHECK(result);
result = channel1->set3DAttributes(&pos, &vel);
ERRCHECK(result);
result = channel1->setPaused(false);
ERRCHECK(result);
}
{
FMOD_VECTOR pos = { 15.0f * DISTANCEFACTOR, 0.0f, 0.0f };
FMOD_VECTOR vel = { 0.0f, 0.0f, 0.0f };
result = system->playSound(FMOD_CHANNEL_FREE, sound2, true, &channel2);
ERRCHECK(result);
result = channel2->set3DAttributes(&pos, &vel);
ERRCHECK(result);
result = channel2->setPaused(false);
ERRCHECK(result);
}
/*
Display help
*/
{
int num3d = 0, num2d = 0;
result = system->getHardwareChannels(&num2d, &num3d, 0);
ERRCHECK(result);
printf("Hardware 2D channels : %d\n", num2d);
printf("Hardware 3D channels : %d\n", num3d);
//.........这里部分代码省略.........
示例12: FMOD_Main
int FMOD_Main()
{
FMOD::System *system;
FMOD::Sound *sound;
FMOD::Channel *channel = 0;
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("wave.mp3"), FMOD_HARDWARE | FMOD_LOOP_NORMAL | FMOD_2D, 0, &sound);
ERRCHECK(result);
/*
Play the sound.
*/
result = system->playSound(sound, 0, false, &channel);
ERRCHECK(result);
/*
Main loop.
*/
do
{
Common_Update();
if (Common_BtnPress(BTN_ACTION1))
{
bool paused;
result = channel->getPaused(&paused);
ERRCHECK(result);
result = channel->setPaused(!paused);
ERRCHECK(result);
}
result = system->update();
ERRCHECK(result);
{
unsigned int ms = 0;
unsigned int lenms = 0;
bool playing = false;
bool paused = false;
if (channel)
{
result = channel->isPlaying(&playing);
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
{
ERRCHECK(result);
}
result = channel->getPaused(&paused);
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
{
ERRCHECK(result);
}
result = channel->getPosition(&ms, FMOD_TIMEUNIT_MS);
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
{
ERRCHECK(result);
}
result = sound->getLength(&lenms, FMOD_TIMEUNIT_MS);
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
{
ERRCHECK(result);
}
}
Common_Draw("==================================================");
Common_Draw("Play Stream Example.");
Common_Draw("Copyright (c) Firelight Technologies 2004-2013.");
Common_Draw("==================================================");
Common_Draw("");
Common_Draw("Press %s to toggle pause", Common_BtnStr(BTN_ACTION1));
Common_Draw("Press %s to quit", Common_BtnStr(BTN_QUIT));
Common_Draw("");
Common_Draw("Time %02d:%02d:%02d/%02d:%02d:%02d : %s", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : playing ? "Playing" : "Stopped");
}
//.........这里部分代码省略.........
示例13: FMOD_Main
int FMOD_Main()
{
FMOD::System *system;
FMOD::Sound *sound[3];
FMOD::Channel *channel = 0;
FMOD::ChannelGroup *channelgroup = 0;
FMOD_RESULT result;
unsigned int version, dsp_block_len, count;
int outputrate = 0;
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(100, FMOD_INIT_NORMAL, extradriverdata);
ERRCHECK(result);
/*
Get information needed later for scheduling. The mixer block size, and the output rate of the mixer.
*/
result = system->getDSPBufferSize(&dsp_block_len, 0);
ERRCHECK(result);
result = system->getSoftwareFormat(&outputrate, 0, 0);
ERRCHECK(result);
/*
Load 3 sounds - these are just sine wave tones at different frequencies. C, D and E on the musical scale.
*/
result = system->createSound(Common_MediaPath("c.ogg"), FMOD_DEFAULT, 0, &sound[NOTE_C]);
ERRCHECK(result);
result = system->createSound(Common_MediaPath("d.ogg"), FMOD_DEFAULT, 0, &sound[NOTE_D]);
ERRCHECK(result);
result = system->createSound(Common_MediaPath("e.ogg"), FMOD_DEFAULT, 0, &sound[NOTE_E]);
ERRCHECK(result);
/*
Create a channelgroup that the channels will play on. We can use this channelgroup as our clock reference.
It also means we can pause and pitch bend the channelgroup, without affecting the offsets of the delays, because the channelgroup clock
which the channels feed off, will be pausing and speeding up/slowing down and still keeping the children in sync.
*/
result = system->createChannelGroup("Parent", &channelgroup);
ERRCHECK(result);
unsigned int numsounds = sizeof(note) / sizeof(note[0]);
/*
Play all the sounds at once! Space them apart with set delay though so that they sound like they play in order.
*/
for (count = 0; count < numsounds; count++)
{
static unsigned long long clock_start = 0;
unsigned int slen;
FMOD::Sound *s = sound[note[count]]; /* Pick a note from our tune. */
result = system->playSound(s, channelgroup, true, &channel); /* Play the sound on the channelgroup we want to use as the parent clock reference (for setDelay further down) */
ERRCHECK(result);
if (!clock_start)
{
result = channel->getDSPClock(0, &clock_start);
ERRCHECK(result);
clock_start += (dsp_block_len * 2); /* Start the sound into the future, by 2 mixer blocks worth. */
/* Should be enough to avoid the mixer catching up and hitting the clock value before we've finished setting up everything. */
/* Alternatively the channelgroup we're basing the clock on could be paused to stop it ticking. */
}
else
{
float freq;
result = s->getLength(&slen, FMOD_TIMEUNIT_PCM); /* Get the length of the sound in samples. */
ERRCHECK(result);
result = s->getDefaults(&freq, 0); /* Get the default frequency that the sound was recorded at. */
ERRCHECK(result);
slen = (unsigned int)((float)slen / freq * outputrate); /* Convert the length of the sound to 'output samples' for the output timeline. */
clock_start += slen; /* Place the sound clock start time to this value after the last one. */
}
result = channel->setDelay(clock_start, 0, false); /* Schedule the channel to start in the future at the newly calculated channelgroup clock value. */
ERRCHECK(result);
result = channel->setPaused(false); /* Unpause the sound. Note that you won't hear the sounds, they are scheduled into the future. */
ERRCHECK(result);
//.........这里部分代码省略.........
示例14: main
int main(int argc, char *argv[])
{
FMOD::System *system = 0;
FMOD::Sound *sound = 0;
FMOD::Channel *channel = 0;
FMOD_RESULT result;
FMOD_CREATESOUNDEXINFO exinfo;
int key, driver, recorddriver, numdrivers, count, outputfreq, bin;
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;
}
/*
System initialization
*/
printf("---------------------------------------------------------\n");
printf("Select OUTPUT type\n");
printf("---------------------------------------------------------\n");
printf("1 : OSS - Open Sound System\n");
printf("2 : ALSA - Advanced Linux Sound Architecture\n");
printf("3 : ESD - Enlightenment Sound Daemon\n");
printf("4 : PULSEAUDIO - Pulse Audio Sound Server\n");
printf("---------------------------------------------------------\n");
printf("Press a corresponding number or ESC to quit\n");
do
{
key = getch();
} while (key != 27 && key < '1' && key > '5');
switch (key)
{
case '1' : result = system->setOutput(FMOD_OUTPUTTYPE_OSS);
break;
case '2' : result = system->setOutput(FMOD_OUTPUTTYPE_ALSA);
break;
case '3' : result = system->setOutput(FMOD_OUTPUTTYPE_ESD);
break;
case '4' : result = system->setOutput(FMOD_OUTPUTTYPE_PULSEAUDIO);
break;
default : return 1;
}
ERRCHECK(result);
/*
Enumerate playback devices
*/
result = system->getNumDrivers(&numdrivers);
ERRCHECK(result);
printf("---------------------------------------------------------\n");
printf("Choose a PLAYBACK driver\n");
printf("---------------------------------------------------------\n");
for (count=0; count < numdrivers; count++)
{
char name[256];
result = system->getDriverInfo(count, name, 256, 0);
ERRCHECK(result);
printf("%d : %s\n", count + 1, name);
}
printf("---------------------------------------------------------\n");
printf("Press a corresponding number or ESC to quit\n");
do
{
key = getch();
if (key == 27)
{
return 0;
}
driver = key - '1';
} while (driver < 0 || driver >= numdrivers);
result = system->setDriver(driver);
ERRCHECK(result);
/*
Enumerate record devices
*/
result = system->getRecordNumDrivers(&numdrivers);
ERRCHECK(result);
printf("---------------------------------------------------------\n");
//.........这里部分代码省略.........
示例15: FMOD_Main
int FMOD_Main()
{
FMOD::System *system = 0;
FMOD_RESULT result;
unsigned int version;
void *extradriverdata = 0;
unsigned int pluginhandle;
InspectorState state = PLUGIN_SELECTOR;
PluginSelectorState pluginselector = { 0 };
ParameterViewerState parameterviewer = { 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->getNumPlugins(FMOD_PLUGINTYPE_DSP, &pluginselector.numplugins);
ERRCHECK(result);
pluginselector.system = system;
do
{
Common_Update();
if (state == PLUGIN_SELECTOR)
{
state = pluginSelectorDo(&pluginselector);
if (state == PARAMETER_VIEWER)
{
result = pluginselector.system->getPluginHandle(FMOD_PLUGINTYPE_DSP, pluginselector.cursor, &pluginhandle);
ERRCHECK(result);
result = pluginselector.system->createDSPByPlugin(pluginhandle, ¶meterviewer.dsp);
ERRCHECK(result);
FMOD_RESULT result = parameterviewer.dsp->getNumParameters(¶meterviewer.numparams);
ERRCHECK(result);
parameterviewer.scroll = 0;
}
}
else if (state == PARAMETER_VIEWER)
{
state = parameterViewerDo(¶meterviewer);
if (state == PLUGIN_SELECTOR)
{
result = parameterviewer.dsp->release();
ERRCHECK(result);
parameterviewer.dsp = 0;
}
}
result = system->update();
ERRCHECK(result);
Common_Sleep(INTERFACE_UPDATETIME - 1);
} while (!Common_BtnPress(BTN_QUIT));
if (parameterviewer.dsp)
{
result = parameterviewer.dsp->release();
ERRCHECK(result);
}
result = system->close();
ERRCHECK(result);
result = system->release();
ERRCHECK(result);
Common_Close();
return 0;
}