Hi guys,
Playing with Fmod again, after a while, because someone asked me about it. Said she'd release a tutorial if I helped her... we'll see if it happens XD.
I've been especially playing with the 3D audio features... finally, after some messing around, I've got this:
I call it "Futari no mojipittan to headache" just because I don't know the japanese word for headache XD
It's futari no mojipittan playing in a circle around your head. Those with surround sound will experience it best... listen to it for a few hours and you'll see what I mean - ugh at debugging (and tinkering!)
Here's a download to it:
http://www.mediafire.com/?jnpp10djodm(too lazy to put it on my webserver XD)
and here's the code, written in Microsoft Visual Studio 2005. I will share the entire project with those who would want to see, but this is the vast majority of it.
Code:
int _tmain(int argc, _TCHAR* argv[])
{
FMOD_RESULT result;
FMOD::System *system;
result = FMOD::System_Create(&system); // Create the main system object.
if (result != FMOD_OK)
{
//printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
return -1;
}
result = system->init(100, FMOD_INIT_NORMAL, 0); // Initialize FMOD.
if (result != FMOD_OK)
{
//printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
return -1;
}
FMOD::Sound* sound;
result = system->createSound("mojipittan.mp3", FMOD_3D, 0, &sound);
if (result != FMOD_OK)
{
std::cout << "Error loading file" << std::endl;
if( result == FMOD_ERR_FILE_NOTFOUND ) std::cout << "File not found" << std::endl;
return -1;
}
FMOD::Channel *channel;
system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
FMOD_VECTOR listener_pos;
listener_pos.x = 0;
listener_pos.y = 0;
listener_pos.z = 0;
FMOD_VECTOR listener_vel;
listener_pos.x = 0;
listener_pos.y = 0;
listener_pos.z = 0;
FMOD_VECTOR listener_forward;
listener_forward.x = 0;
listener_forward.y = 0;
listener_forward.z = 1;
FMOD_VECTOR listener_up;
listener_up.x = 0;
listener_up.y = 1;
listener_up.z = 0;
FMOD_VECTOR sound_pos;
sound_pos.x = 0;
sound_pos.y = 0;
sound_pos.z = 0;
FMOD_VECTOR sound_vel;
sound_vel.x = 0;
sound_vel.y = 0;
sound_vel.z = 0;
channel->set3DDopplerLevel(0); // since im not setting the velocity, this does not give nice results, so it's off :D
float freq;
channel->getFrequency(&freq);
channel->setFrequency( freq * 1); // multiply to speed up, slow down, or reverse (negative
// reverse can only be done in software, it's configured to use hardware now... so no negatives! kkthx
bool isPlaying;
float i = 0;
do {
sound_pos.z = sin(i) * 1;
sound_pos.x = cos(i) * 1;
sound_pos.y = 0;
channel->set3DAttributes(&sound_pos, &sound_vel);
system->update(); // needed to update 3d engine, once per frame
// output status:
if(sound_pos.z > 0)
if(sound_pos.x > 0) {
std::cout << "Playing in quadrant 1" << std::endl;
} else {
std::cout << "Playing in quadrant 2" << std::endl;
}
if(sound_pos.z < 0)
if(sound_pos.x > 0) {
std::cout << "Playing in quadrant 4" << std::endl;
} else {
std::cout << "Playing in quadrant 3" << std::endl;
}
channel->isPlaying(&isPlaying);
i = i + .0005; // that's a small increment :D this sets the speed of the rotation. Smaller number makes it slower.
} while(isPlaying);
system->release(); // close FMod
return 0; // exit
}
Let me know what you think <3