本文整理汇总了C++中fmod::System::setStreamBufferSize方法的典型用法代码示例。如果您正苦于以下问题:C++ System::setStreamBufferSize方法的具体用法?C++ System::setStreamBufferSize怎么用?C++ System::setStreamBufferSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fmod::System
的用法示例。
在下文中一共展示了System::setStreamBufferSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
HANDLE threadhandle;
InitializeCriticalSection(&gCrit);
threadhandle = (HANDLE)_beginthreadex(NULL, 0, ProcessQueue, 0, 0, 0);
if (!threadhandle)
{
printf("Failed to create file thread.\n");
return 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(1, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);
result = system->setStreamBufferSize(32768, FMOD_TIMEUNIT_RAWBYTES);
ERRCHECK(result);
result = system->setFileSystem(myopen, myclose, myread, myseek, myasyncread, myasynccancel, 2048);
ERRCHECK(result);
printf("====================================================================\n");
printf("Stream IO Example. Copyright (c) Firelight Technologies 2004-2014.\n");
printf("====================================================================\n");
printf("\n");
printf("\n");
printf("====================== CALLING CREATESOUND ON MP3 =======================\n");
result = system->createStream("../media/wave.mp3", FMOD_SOFTWARE | FMOD_LOOP_NORMAL | FMOD_2D | FMOD_IGNORETAGS, 0, &sound);
ERRCHECK(result);
printf("====================== CALLING PLAYSOUND ON MP3 =======================\n");
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
ERRCHECK(result);
/*
Main loop.
*/
do
{
if (sound)
{
FMOD_OPENSTATE openstate;
bool starving;
sound->getOpenState(&openstate, 0, &starving, 0);
if (starving)
{
printf("Starving\n");
result = channel->setMute(true);
}
else
{
result = channel->setMute(false);
ERRCHECK(result);
}
}
if (_kbhit())
{
key = _getch();
switch (key)
{
case ' ' :
{
result = sound->release();
if (result == FMOD_OK)
{
sound = 0;
printf("Released sound.\n");
}
break;
}
}
//.........这里部分代码省略.........
示例2: 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();
//.........这里部分代码省略.........
示例3: 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())
//.........这里部分代码省略.........
示例4: FMOD_Main
int FMOD_Main()
{
FMOD::System *system = 0;
FMOD::Sound *sound = 0;
FMOD::Channel *channel = 0;
FMOD_RESULT result = FMOD_OK;
FMOD_OPENSTATE openstate = FMOD_OPENSTATE_READY;
unsigned int version = 0;
void *extradriverdata = 0;
const int tagcount = 4;
int tagindex = 0;
char tagstring[tagcount][128] = { 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(1, FMOD_INIT_NORMAL, extradriverdata);
ERRCHECK(result);
/* Increase the file buffer size a little bit to account for Internet lag. */
result = system->setStreamBufferSize(64*1024, FMOD_TIMEUNIT_RAWBYTES);
ERRCHECK(result);
result = system->createSound("http://shoutmedia.abc.net.au:10426", FMOD_CREATESTREAM | FMOD_NONBLOCKING, 0, &sound);
ERRCHECK(result);
/*
Main loop
*/
do
{
unsigned int pos = 0;
unsigned int percent = 0;
bool playing = false;
bool paused = false;
bool starving = false;
const char *state = "Stopped";
Common_Update();
if (Common_BtnPress(BTN_ACTION1))
{
if (channel)
{
bool paused = false;
result = channel->getPaused(&paused);
ERRCHECK(result);
result = channel->setPaused(!paused);
ERRCHECK(result);
}
}
result = system->update();
ERRCHECK(result);
result = sound->getOpenState(&openstate, &percent, &starving, 0);
ERRCHECK(result);
if (channel)
{
FMOD_TAG tag;
/*
Read any tags that have arrived, this could happen if a radio station switches
to a new song.
*/
while (sound->getTag(0, -1, &tag) == FMOD_OK)
{
if (tag.datatype == FMOD_TAGDATATYPE_STRING)
{
sprintf(tagstring[tagindex], "%s = '%s' (%d bytes)", tag.name, (char *)tag.data, tag.datalen);
tagindex = (tagindex + 1) % tagcount;
}
else if (tag.type == FMOD_TAGTYPE_FMOD)
{
/* When a song changes, the sample rate may also change, so compensate here. */
if (!strcmp(tag.name, "Sample Rate Change"))
{
float frequency = *((float *)tag.data);
result = channel->setFrequency(frequency);
ERRCHECK(result);
}
}
}
//.........这里部分代码省略.........