本文整理汇总了C++中fmod::System::init方法的典型用法代码示例。如果您正苦于以下问题:C++ System::init方法的具体用法?C++ System::init怎么用?C++ System::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fmod::System
的用法示例。
在下文中一共展示了System::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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_HARDWARE | FMOD_CREATESTREAM ;
int key;
int channels = 2;
FMOD_CREATESOUNDEXINFO createsoundexinfo;
unsigned int version;
/* Initialisation du moteur audio */
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);
/* Choix de la question */
printf("Numéro de question (ou toute autre touche pour quitter) : \n");
key = getch();
if (key != '1' && key !='6')
{
return 0 ;
}
printf("%d\n",key-48) ;
/* Création d'un buffer circulaire */
memset(&createsoundexinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
createsoundexinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
createsoundexinfo.decodebuffersize = 3000;
createsoundexinfo.length = 44100 * channels * sizeof(signed short) * 5;
createsoundexinfo.numchannels = channels;
createsoundexinfo.defaultfrequency = 44100;
createsoundexinfo.format = FMOD_SOUND_FORMAT_PCM16;
createsoundexinfo.pcmsetposcallback = pcmsetposcallback;
if (key == '1')
{
mode |= FMOD_LOOP_NORMAL ;
createsoundexinfo.pcmreadcallback = cb_question1;
}
else if (key == '6')
{
mode |= FMOD_LOOP_OFF ;
createsoundexinfo.pcmreadcallback = cb_globale;
}
result = system->createSound(0, mode, &createsoundexinfo, &sound);
ERRCHECK(result);
/* Lecture du buffer */
printf("Espace = pause, Echap = quitter\n");
result = system->playSound(FMOD_CHANNEL_FREE, sound, 0, &channel);
ERRCHECK(result);
/* Boucle principale */
do
{
/* Lecture des commandes de l'utilisateur pendant la lecture
et définition des changements à appliquer */
if (kbhit())
{
key = getch();
switch (key)
{
case ' ' :
{
bool paused;
channel->getPaused(&paused);
channel->setPaused(!paused);
break;
}
/* QUESTION 2 */
case '*' :
{
ampGauche /= 2.0f;
ampDroite /= 2.0f;
//.........这里部分代码省略.........
示例2: 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-2014.\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);
//.........这里部分代码省略.........
示例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: FMOD_Main
int FMOD_Main()
{
FMOD::System *system = 0;
FMOD::Sound *sound = 0;
FMOD::Channel *channel = 0;
FMOD::ChannelGroup *mastergroup = 0;
FMOD::DSP *dsplowpass = 0;
FMOD::DSP *dsphighpass = 0;
FMOD::DSP *dspecho = 0;
FMOD::DSP *dspflange = 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->getMasterChannelGroup(&mastergroup);
ERRCHECK(result);
result = system->createSound(Common_MediaPath("drumloop.wav"), FMOD_DEFAULT, 0, &sound);
ERRCHECK(result);
result = system->playSound(sound, 0, false, &channel);
ERRCHECK(result);
/*
Create some effects to play with
*/
result = system->createDSPByType(FMOD_DSP_TYPE_LOWPASS, &dsplowpass);
ERRCHECK(result);
result = system->createDSPByType(FMOD_DSP_TYPE_HIGHPASS, &dsphighpass);
ERRCHECK(result);
result = system->createDSPByType(FMOD_DSP_TYPE_ECHO, &dspecho);
ERRCHECK(result);
result = system->createDSPByType(FMOD_DSP_TYPE_FLANGE, &dspflange);
ERRCHECK(result);
/*
Add them to the master channel group. Each time an effect is added (to position 0) it pushes the others down the list.
*/
result = mastergroup->addDSP(0, dsplowpass);
ERRCHECK(result);
result = mastergroup->addDSP(0, dsphighpass);
ERRCHECK(result);
result = mastergroup->addDSP(0, dspecho);
ERRCHECK(result);
result = mastergroup->addDSP(0, dspflange);
ERRCHECK(result);
/*
By default, bypass all effects. This means let the original signal go through without processing.
It will sound 'dry' until effects are enabled by the user.
*/
result = dsplowpass->setBypass(true);
ERRCHECK(result);
result = dsphighpass->setBypass(true);
ERRCHECK(result);
result = dspecho->setBypass(true);
ERRCHECK(result);
result = dspflange->setBypass(true);
ERRCHECK(result);
/*
Main loop
*/
do
{
Common_Update();
if (Common_BtnPress(BTN_MORE))
{
bool paused;
result = channel->getPaused(&paused);
ERRCHECK(result);
paused = !paused;
result = channel->setPaused(paused);
ERRCHECK(result);
}
if (Common_BtnPress(BTN_ACTION1))
//.........这里部分代码省略.........
示例5: main
int main(int ac, const char **av)
{
// Create application window
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, LoadCursor(NULL, IDC_ARROW), NULL, NULL, _T("Douceur"), NULL };
RegisterClassEx(&wc);
HWND hwnd = CreateWindow(_T("Douceur"), _T("Douceur"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);
// Initialize Direct3D
if (CreateDeviceD3D(hwnd) < 0)
{
CleanupDeviceD3D();
UnregisterClass(_T("Douceur"), wc.hInstance);
return 1;
}
// Show the window
ShowWindow(hwnd, SW_SHOWDEFAULT);
UpdateWindow(hwnd);
// Setup ImGui binding
ImGui_ImplDX11_Init(hwnd, g_pd3dDevice, g_pd3dDeviceContext);
// Load Fonts
// (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
//ImGuiIO& io = ImGui::GetIO();
//io.Fonts->AddFontDefault();
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
bool show_test_window = true;
ImVec4 clear_col = ImColor(114, 144, 154);
// Main loop
MSG msg;
ZeroMemory(&msg, sizeof(msg));
std::string arduinoMsg;
std::string arduinoDisplayMsg;
bool messageEnded = true;
FMOD::System *fmodSystem;
FMOD::System_Create(&fmodSystem);
FMOD::Sound *sound = 0;
FMOD::Channel *channel = 0;
FMOD::ChannelGroup *mastergroup = 0;
fmodSystem->init(128, FMOD_INIT_NORMAL, 0);
fmodSystem->getMasterChannelGroup(&mastergroup);
fmodSystem->createSound("../DouceurExternal/audio-samples/Yamaha-1.wav", FMOD_LOOP_NORMAL, 0, &sound);
unsigned int soundLength = 0;
sound->getLength(&soundLength, FMOD_TIMEUNIT_MS);
Serial arduino("COM6");
Board board(fmodSystem);
while (msg.message != WM_QUIT)
{
fmodSystem->update();
if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
continue;
}
ImGui_ImplDX11_NewFrame();
static bool first = true;
static int from = 0;
static int to = 400;
static float freq = 1.f;
static float pan = 0.f;
static float pitch = 0.f;
if (!first)
{
fmodSystem->playSound(sound, mastergroup, false, &channel);
first = true;
to = soundLength;
channel->getFrequency(&freq);
channel->getPitch(&pitch);
}
{
ImGui::SetNextWindowPos(ImVec2(10, 10));
ImGui::Begin("FPS", nullptr, ImVec2(0, 0), 0.3f, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings);
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
ImGui::End();
}
if (false)
{
ImGui::Begin("SoloudTest");
bool changed = ImGui::SliderInt("from", (int*)&from, 0, soundLength - 1);
//.........这里部分代码省略.........
示例6: 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);
//.........这里部分代码省略.........
示例7: 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);
}
//.........这里部分代码省略.........
示例8: main
int main(int argc, char *argv[])
{
FMOD::System *system = 0;
FMOD::Sound *sound = 0;
FMOD_RESULT result;
FMOD_CREATESOUNDEXINFO exinfo;
int key, recorddriver, numdrivers, count;
unsigned int version;
FILE *fp;
unsigned int datalength = 0, soundlength;
bool iscoreaudio = false;
/*
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->setOutput(FMOD_OUTPUTTYPE_COREAUDIO);
ERRCHECK(result);
/*
Enumerate record devices
*/
result = system->getRecordNumDrivers(&numdrivers);
ERRCHECK(result);
printf("---------------------------------------------------------\n");
printf("Choose a RECORD driver\n");
printf("---------------------------------------------------------\n");
for (count=0; count < numdrivers; count++)
{
char name[256];
result = system->getRecordDriverInfo(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");
recorddriver = 0;
do
{
key = getch();
if (key == 27)
{
return 0;
}
recorddriver = key - '1';
} while (recorddriver < 0 || recorddriver >= numdrivers);
printf("\n");
result = system->init(32, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.numchannels = 2;
exinfo.defaultfrequency = 44100;
if (iscoreaudio)
{
exinfo.format = FMOD_SOUND_FORMAT_PCMFLOAT;
exinfo.length = exinfo.defaultfrequency * sizeof(float) * exinfo.numchannels * 2;
}
else
{
exinfo.format = FMOD_SOUND_FORMAT_PCM16;
exinfo.length = exinfo.defaultfrequency * sizeof(short) * exinfo.numchannels * 2;
}
result = system->createSound(0, FMOD_2D | FMOD_SOFTWARE | FMOD_OPENUSER, &exinfo, &sound);
ERRCHECK(result);
printf("========================================================================\n");
printf("Record to disk example. Copyright (c) Firelight Technologies 2004-2014.\n");
printf("========================================================================\n");
printf("\n");
printf("Press a key to start recording to record.wav\n");
printf("\n");
getch();
result = system->recordStart(recorddriver, sound, true);
ERRCHECK(result);
//.........这里部分代码省略.........
示例9: 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);
}
}
}
//.........这里部分代码省略.........
示例10: main
int main(int argc, char *argv[])
{
FMOD::System *system;
FMOD::Sound *sound1, *sound2;
FMOD::Channel *channel = 0;
FMOD_RESULT result;
FMOD_SPEAKERMODE speakermode;
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;
}
/*
Choose the speaker mode selected by the Windows control panel.
*/
result = system->getDriverCaps(0, 0, 0, &speakermode);
ERRCHECK(result);
result = system->setSpeakerMode(speakermode);
ERRCHECK(result);
result = system->init(32, FMOD_INIT_NORMAL, 0);
ERRCHECK(result);
result = system->createSound("../media/drumloop.wav", FMOD_SOFTWARE | FMOD_2D, 0, &sound1);
ERRCHECK(result);
result = sound1->setMode(FMOD_LOOP_OFF);
ERRCHECK(result);
result = system->createSound("../media/stereo.ogg", FMOD_SOFTWARE | FMOD_2D, 0, &sound2);
ERRCHECK(result);
printf("==============================================================================\n");
printf("Multi Speaker Output Example. Copyright (c) Firelight Technologies 2004-2014.\n");
printf("==============================================================================\n");
printf("\n");
switch (speakermode)
{
case FMOD_SPEAKERMODE_MONO :
{
printf("Using control panel speaker mode : MONO.\n");
printf("\n");
printf("Note! This output mode is very limited in its capability.\n");
printf("Most functionality of this demo is only realized with at least FMOD_SPEAKERMODE_QUAD\n");
printf("and above.\n");
break;
}
case FMOD_SPEAKERMODE_STEREO :
{
printf("Using control panel speaker mode : STEREO.\n");
printf("\n");
printf("Note! This output mode is very limited in its capability.\n");
printf("Most functionality of this demo is only realized with FMOD_SPEAKERMODE_QUAD\n");
printf("and above.\n");
break;
}
case FMOD_SPEAKERMODE_QUAD :
{
printf("Using control panel speaker mode : QUAD.\n");
printf("Side left, side right, center and subwoofer mix will be disabled.\n");
break;
}
case FMOD_SPEAKERMODE_SURROUND :
{
printf("Using control panel speaker mode : SURROUND.\n");
printf("Side left, side right and subwoofer mix will be disabled.\n");
break;
}
case FMOD_SPEAKERMODE_5POINT1 :
{
printf("Using control panel speaker mode : 5.1 surround.\n");
printf("Side left and right mix will be disabled..\n");
break;
}
case FMOD_SPEAKERMODE_7POINT1 :
{
printf("Using control panel speaker mode : 7.1 surround.\n");
printf("Full capability.\n");
break;
}
};
printf("\n");
printf("Press '1' to play a mono sound on the FRONT LEFT speaker.\n");
printf("Press '2' to play a mono sound on the FRONT RIGHT speaker.\n");
if (speakermode >= FMOD_SPEAKERMODE_SURROUND)
//.........这里部分代码省略.........
示例11: FMOD_Main
int FMOD_Main()
{
FMOD::System *system;
FMOD::Sound *sound1, *sound2, *sound3;
FMOD::Channel *channel = 0;
FMOD_RESULT result;
unsigned int version;
void *extradriverdata = 0;
void *buff = 0;
int length = 0;
FMOD_CREATESOUNDEXINFO exinfo;
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);
Common_LoadFileMemory(Common_MediaPath("drumloop.wav"), &buff, &length);
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.length = length;
result = system->createSound((const char *)buff, FMOD_HARDWARE | FMOD_OPENMEMORY | FMOD_LOOP_OFF, &exinfo, &sound1);
ERRCHECK(result);
Common_UnloadFileMemory(buff); // don't need the original memory any more. Note! If loading as a stream, the memory must stay active so do not free it!
Common_LoadFileMemory(Common_MediaPath("jaguar.wav"), &buff, &length);
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.length = length;
result = system->createSound((const char *)buff, FMOD_SOFTWARE | FMOD_OPENMEMORY, &exinfo, &sound2);
ERRCHECK(result);
Common_UnloadFileMemory(buff); // don't need the original memory any more. Note! If loading as a stream, the memory must stay active so do not free it!
Common_LoadFileMemory(Common_MediaPath("swish.wav"), &buff, &length);
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.length = length;
result = system->createSound((const char *)buff, FMOD_HARDWARE | FMOD_OPENMEMORY, &exinfo, &sound3);
ERRCHECK(result);
Common_UnloadFileMemory(buff); // don't need the original memory any more. Note! If loading as a stream, the memory must stay active so do not free it!
/*
Main loop
*/
do
{
Common_Update();
if (Common_BtnPress(BTN_ACTION1))
{
result = system->playSound(sound1, 0, false, &channel);
ERRCHECK(result);
}
if (Common_BtnPress(BTN_ACTION2))
{
result = system->playSound(sound2, 0, false, &channel);
ERRCHECK(result);
}
if (Common_BtnPress(BTN_ACTION3))
{
result = system->playSound(sound3, 0, false, &channel);
ERRCHECK(result);
}
result = system->update();
ERRCHECK(result);
{
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))
{
//.........这里部分代码省略.........
示例12: 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;
//.........这里部分代码省略.........
示例13: 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");
}
//.........这里部分代码省略.........
示例14: 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);
//.........这里部分代码省略.........
示例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;
}