本文整理汇总了C++中fmod::System::getNumDrivers方法的典型用法代码示例。如果您正苦于以下问题:C++ System::getNumDrivers方法的具体用法?C++ System::getNumDrivers怎么用?C++ System::getNumDrivers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fmod::System
的用法示例。
在下文中一共展示了System::getNumDrivers方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FMODErrorCheck
/**
* Create a map where the keys are the names of the devices
* and the values are the id (0-x where x = num of devices)
*/
map<string,int> AudioDevice::getDeviceMap()
{
FMOD_RESULT result;
FMOD::System* sys;
result = FMOD::System_Create( &sys );
FMODErrorCheck(result);
int numDrivers;
result = sys->getNumDrivers(&numDrivers);
FMODErrorCheck(result);
map<string,int> deviceMap;
//app::console() << "===========================" << endl;
//app::console() << "Listing audio devices:" << endl;
for(int i=0; i<numDrivers; i++)
{
FMOD_GUID guid;
char deviceName[256];
sys->getDriverInfo(i, deviceName, 256, &guid);
//app::console() << "(" << i << ") " << deviceName << endl;
deviceMap[string(deviceName)] = i;
}
//app::console() << "===========================" << endl;
FMODErrorCheck( sys->close() );
FMODErrorCheck( sys->release() );
return deviceMap;
}
示例2: 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;
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");
//.........这里部分代码省略.........
示例3: 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");
//.........这里部分代码省略.........
示例4: 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, numdrivers;
bool listenerflag = true;
FMOD_VECTOR listenerpos = { 0.0f, 0.0f, -1.0f * DISTANCEFACTOR };
unsigned int version;
FMOD_SPEAKERMODE speakermode;
FMOD_CAPS caps;
char name[256];
printf("===============================================================\n");
printf("3d Example. Copyright (c) Firelight Technologies 2004-2015.\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->getNumDrivers(&numdrivers);
ERRCHECK(result);
if (numdrivers == 0)
{
result = system->setOutput(FMOD_OUTPUTTYPE_NOSOUND);
ERRCHECK(result);
}
else
{
result = system->getDriverCaps(0, &caps, 0, &speakermode);
ERRCHECK(result);
result = system->setSpeakerMode(speakermode); /* Set the user selected speaker mode. */
ERRCHECK(result);
if (caps & FMOD_CAPS_HARDWARE_EMULATED) /* The user has the 'Acceleration' slider set to off! This is really bad for latency!. */
{ /* You might want to warn the user about this. */
result = system->setDSPBufferSize(1024, 10);
ERRCHECK(result);
}
result = system->getDriverInfo(0, name, 256, 0);
ERRCHECK(result);
if (strstr(name, "SigmaTel")) /* Sigmatel sound devices crackle for some reason if the format is PCM 16bit. PCM floating point output seems to solve it. */
{
result = system->setSoftwareFormat(48000, FMOD_SOUND_FORMAT_PCMFLOAT, 0,0, FMOD_DSP_RESAMPLER_LINEAR);
ERRCHECK(result);
}
}
result = system->init(100, FMOD_INIT_NORMAL, 0);
if (result == FMOD_ERR_OUTPUT_CREATEBUFFER) /* Ok, the speaker mode selected isn't supported by this soundcard. Switch it back to stereo... */
{
result = system->setSpeakerMode(FMOD_SPEAKERMODE_STEREO);
ERRCHECK(result);
result = system->init(100, FMOD_INIT_NORMAL, 0);/* ... and re-init. */
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_3D, 0, &sound1);
ERRCHECK(result);
result = sound1->set3DMinMaxDistance(0.5f * DISTANCEFACTOR, 5000.0f * DISTANCEFACTOR);
ERRCHECK(result);
result = sound1->setMode(FMOD_LOOP_NORMAL);
ERRCHECK(result);
result = system->createSound("../media/jaguar.wav", FMOD_3D, 0, &sound2);
ERRCHECK(result);
result = sound2->set3DMinMaxDistance(0.5f * DISTANCEFACTOR, 5000.0f * DISTANCEFACTOR);
ERRCHECK(result);
result = sound2->setMode(FMOD_LOOP_NORMAL);
//.........这里部分代码省略.........
示例5: DetectPitch
int PitchDetector::DetectPitch()
{
FMOD::System *system = 0;
FMOD::Sound *sound = 0;
FMOD::Channel *channel = 0;
FMOD_RESULT result;
FMOD_CREATESOUNDEXINFO exinfo;
int key, driver, recorddriver, numdrivers, count, 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(-1);
}
/*
System initialization
*/
printf("---------------------------------------------------------\n");
printf("Select OUTPUT type\n");
printf("---------------------------------------------------------\n");
printf("1 : DirectSound\n");
printf("2 : Windows Multimedia WaveOut\n");
printf("3 : ASIO\n");
printf("---------------------------------------------------------\n");
printf("Press a corresponding number or ESC to quit\n");
do
{
//key = _getch();
key = '1'; //TODO: this uses the default io device rather than using user input
} while (key != 27 && key < '1' && key > '5');
switch (key)
{
case '1' : result = system->setOutput(FMOD_OUTPUTTYPE_DSOUND);
break;
case '2' : result = system->setOutput(FMOD_OUTPUTTYPE_WINMM);
break;
case '3' : result = system->setOutput(FMOD_OUTPUTTYPE_ASIO);
break;
default : return(0);
}
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();
key = '1'; //TODO: io devices
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");
printf("Choose a RECORD driver\n");
//.........这里部分代码省略.........
示例6: main
int main()
{
// ================================================================================================
// Application-independent initialization
// ================================================================================================
FMOD::System *system;
FMOD_RESULT result;
unsigned int version;
int numDrivers;
FMOD_SPEAKERMODE speakerMode;
FMOD_CAPS caps;
char name[256];
// Create FMOD interface object
result = FMOD::System_Create(&system);
FMODErrorCheck(result);
// Check version
result = system->getVersion(&version);
FMODErrorCheck(result);
if (version < FMOD_VERSION)
{
std::cout << "Error! You are using an old version of FMOD " << version << ". This program requires " << FMOD_VERSION << std::endl;
return 0;
}
// Get number of sound cards
result = system->getNumDrivers(&numDrivers);
FMODErrorCheck(result);
// No sound cards (disable sound)
if (numDrivers == 0)
{
result = system->setOutput(FMOD_OUTPUTTYPE_NOSOUND);
FMODErrorCheck(result);
}
// At least one sound card
else
{
// Get the capabilities of the default (0) sound card
result = system->getDriverCaps(0, &caps, 0, &speakerMode);
FMODErrorCheck(result);
// Set the speaker mode to match that in Control Panel
result = system->setSpeakerMode(speakerMode);
FMODErrorCheck(result);
// Increase buffer size if user has Acceleration slider set to off
if (caps & FMOD_CAPS_HARDWARE_EMULATED)
{
result = system->setDSPBufferSize(1024, 10);
FMODErrorCheck(result);
}
// Get name of driver
result = system->getDriverInfo(0, name, 256, 0);
FMODErrorCheck(result);
// SigmaTel sound devices crackle for some reason if the format is PCM 16-bit.
// PCM floating point output seems to solve it.
if (strstr(name, "SigmaTel"))
{
result = system->setSoftwareFormat(48000, FMOD_SOUND_FORMAT_PCMFLOAT, 0, 0, FMOD_DSP_RESAMPLER_LINEAR);
FMODErrorCheck(result);
}
}
// Initialise FMOD
result = system->init(100, FMOD_INIT_NORMAL, 0);
// If the selected speaker mode isn't supported by this sound card, switch it back to stereo
if (result == FMOD_ERR_OUTPUT_CREATEBUFFER)
{
result = system->setSpeakerMode(FMOD_SPEAKERMODE_STEREO);
FMODErrorCheck(result);
result = system->init(100, FMOD_INIT_NORMAL, 0);
}
FMODErrorCheck(result);
// ================================================================================================
// Application-specific code
// ================================================================================================
bool quit = false;
bool fading = false;
int fadeLength = 3000;
int fadeStartTick;
// Open music as a stream
FMOD::Sound *song1, *song2, *effect;
result = system->createStream("Song1.mp3", FMOD_DEFAULT, 0, &song1);
FMODErrorCheck(result);
result = system->createStream("Song2.mp3", FMOD_DEFAULT, 0, &song2);
FMODErrorCheck(result);
// Load sound effects into memory (not streaming)
//.........这里部分代码省略.........
示例7: main
int main(int argc, char *argv[])
{
FMOD::System *system = 0;
FMOD::Sound *sound = 0;
FMOD::Channel *channel = 0;
FMOD::DSP *dsp = 0;
FMOD_RESULT result;
FMOD_CREATESOUNDEXINFO exinfo;
FMOD_SPEAKERMODE speakermode;
FMOD_CAPS caps;
int key, numdrivers;
unsigned int version;
unsigned int datalength = 0, soundlength;
char name[256];
unsigned int adjustedlatency;
/*
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 (recommended startup sequence)
*/
result = system->getNumDrivers(&numdrivers);
ERRCHECK(result);
if (numdrivers == 0)
{
result = system->setOutput(FMOD_OUTPUTTYPE_NOSOUND);
ERRCHECK(result);
}
else
{
result = system->getDriverCaps(0, &caps, 0, &speakermode);
ERRCHECK(result);
result = system->setSpeakerMode(speakermode); /* Set the user selected speaker mode. */
ERRCHECK(result);
if (caps & FMOD_CAPS_HARDWARE_EMULATED) /* The user has the 'Acceleration' slider set to off! This is really bad for latency!. */
{ /* You might want to warn the user about this. */
result = system->setDSPBufferSize(1024, 10);
ERRCHECK(result);
}
#ifdef LOWLATENCY
else
{
result = system->setDSPBufferSize(256, 4);
}
#endif
result = system->getDriverInfo(0, name, 256, 0);
ERRCHECK(result);
if (strstr(name, "SigmaTel")) /* Sigmatel sound devices crackle for some reason if the format is PCM 16bit. PCM floating point output seems to solve it. */
{
result = system->setSoftwareFormat(48000, FMOD_SOUND_FORMAT_PCMFLOAT, 0,0, FMOD_DSP_RESAMPLER_LINEAR);
ERRCHECK(result);
}
}
result = system->init(100, FMOD_INIT_NORMAL, 0);
if (result == FMOD_ERR_OUTPUT_CREATEBUFFER) /* Ok, the speaker mode selected isn't supported by this soundcard. Switch it back to stereo... */
{
result = system->setSpeakerMode(FMOD_SPEAKERMODE_STEREO);
ERRCHECK(result);
result = system->init(100, FMOD_INIT_NORMAL, 0);/* ... and re-init. */
ERRCHECK(result);
}
/*
System initialization complete (recommended startup sequence)
*/
/*
Create user sound to record into. Set it to loop for playback.
*/
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.numchannels = 1;
exinfo.format = FMOD_SOUND_FORMAT_PCM16;
exinfo.defaultfrequency = RECORDRATE;
exinfo.length = exinfo.defaultfrequency * sizeof(short) * exinfo.numchannels * 5; /* 5 second buffer, doesnt really matter how big this is, but not too small of course. */
result = system->createSound(0, FMOD_2D | FMOD_SOFTWARE | FMOD_LOOP_NORMAL | FMOD_OPENUSER, &exinfo, &sound);
ERRCHECK(result);
printf("========================================================================\n");
printf("Record with realtime playback example.\n");
//.........这里部分代码省略.........