0
0

I want to use 3d Sound in my game, but it doesn’t work well. There are two problems.
First, I’ve adjusted every signle things just like 3D sound tutorial, but oddly, when I move z-axis of my game character, the sound changed into weird high pith(frequency? I don’t what to say, it herard like flute blew with really powerful breath) sound. when I move x-axis or y-axis it is working fine. but I don’t know why these problem is happening on my project….
Second my monster doesn’t growl when it has to. plz notice what I shoud do.
p.s tutorial is working well, but it doesn’t functioning only in my project. plz help me.. (sorry for my bad ENGLISH)

[code:12qyngqq]

include "Sound_Manager.h"

void Sound_Manager::initFmod()
{
result = FMOD::System_Create(&m_pFmod);
ErrorCheck(result);

//result = m_pFmod->init(100, FMOD_INIT_NORMAL, NULL);
//ErrorCheck(result);

 result = m_pFmod->getVersion(&version);
ErrorCheck(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;
}

result = m_pFmod->getNumDrivers(&numdrivers);
ErrorCheck(result);

if (numdrivers == 0)
{
    result = m_pFmod->setOutput(FMOD_OUTPUTTYPE_NOSOUND);
    ErrorCheck(result);
}
else
{
    result = m_pFmod->getDriverCaps(0, &caps, 0, &speakermode);
    ErrorCheck(result);

    result = m_pFmod->setSpeakerMode(speakermode);       /* Set the user selected speaker mode. */
    ErrorCheck(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 = m_pFmod->setDSPBufferSize(1024, 10);
        ErrorCheck(result);
    }

    result = m_pFmod->getDriverInfo(0, name, 256, 0);
    ErrorCheck(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 = m_pFmod->setSoftwareFormat(48000, FMOD_SOUND_FORMAT_PCMFLOAT, 0,0, FMOD_DSP_RESAMPLER_LINEAR);
        ErrorCheck(result);
    }
}

result = m_pFmod->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 = m_pFmod->setSpeakerMode(FMOD_SPEAKERMODE_STEREO);
    ErrorCheck(result);

    result = m_pFmod->init(100, FMOD_INIT_NORMAL, 0);/* ... and re-init. */
    ErrorCheck(result);
}

m_pFmod->set3DSettings(1.f,DISTANCEFACTOR,1.f);
ErrorCheck(result);

m_SoundPos.x = 500.f*DISTANCEFACTOR;
m_SoundPos.y = 0.f;
m_SoundPos.z = 500.f*DISTANCEFACTOR;

}

void Sound_Manager::loadFile()
{
result = m_pFmod->createSound("BGA.mp3", FMOD_LOOP_NORMAL, NULL, &m_pBga);
ErrorCheck(result);

result = m_pFmod->createSound("Hurt.wav", FMOD_DEFAULT, NULL, &m_pHurt);
ErrorCheck(result); 

result = m_pFmod->createSound("Monster.wav", FMOD_3D | FMOD_SOFTWARE ,NULL , &m_Monster);
ErrorCheck(result);

m_Monster->set3DMinMaxDistance(0.5f*DISTANCEFACTOR, 5000.f*DISTANCEFACTOR); 
ErrorCheck(result);

result = m_pFmod->createSound("SensorBeep.wav",FMOD_DEFAULT,NULL, &m_pSensor);
ErrorCheck(result);

result = m_pFmod->createSound("FootStep.wav",FMOD_3D  , NULL, &m_pFootStep);
ErrorCheck(result);

result = m_pFootStep->set3DMinMaxDistance(2.f*DISTANCEFACTOR, 10000.f*DISTANCEFACTOR);
ErrorCheck(result);

result = m_pFmod->createSound("Charge.wav",FMOD_LOOP_NORMAL| FMOD_3D  | FMOD_SOFTWARE  ,NULL, &m_pCharge);
ErrorCheck(result);

result = m_pCharge->set3DMinMaxDistance(2.f*DISTANCEFACTOR, 10000.f*DISTANCEFACTOR);
ErrorCheck(result);


result =m_pFmod->createReverb(&Reverb);
FMOD_REVERB_PROPERTIES prop = FMOD_PRESET_PARKINGLOT;
Reverb->setProperties(&prop);    

}

void Sound_Manager::play(int _kind)
{
switch( _kind)
{
case 0 :
result = m_pFmod->playSound(FMOD_CHANNEL_FREE,m_pBga,false, &m_pBgaCH);
ErrorCheck(result);
break;
case 1 :
result = m_pFmod->playSound(FMOD_CHANNEL_FREE,m_pHurt,false, &m_pHurtCH);
ErrorCheck(result);
break;
case 2:
{
result = m_pFmod->playSound(FMOD_CHANNEL_FREE,m_Monster, true, &m_MonsterCH);
ErrorCheck(result);
m_MonsterCH->set3DAttributes(&AlienPos,NULL);
m_MonsterCH->setPaused(false);
break;
}
case 3:
result = m_pFmod->playSound(FMOD_CHANNEL_FREE,m_pSensor,false,&m_pSensorCH);
ErrorCheck(result);
break;
case 4:
{
FMOD_VECTOR pos = {ListenerPos.x, ListenerPos.y, ListenerPos.z};
result = m_pFmod->playSound(FMOD_CHANNEL_FREE,m_pFootStep, true, &m_pFootStepCH);
ErrorCheck(result);

        if(m_ListenerDirection == L_UP) pos.z += 100.f*DISTANCEFACTOR;
        else if(m_ListenerDirection == L_DOWN)pos.z -=100.f*DISTANCEFACTOR;
        else if(m_ListenerDirection == L_LEFT)pos.x -= 100.f*DISTANCEFACTOR;
        else if(m_ListenerDirection == L_RIGHT)pos.x +=100.f*DISTANCEFACTOR;

        m_pFootStepCH->set3DAttributes(&pos,NULL);
        Reverb->set3DAttributes(&pos,2.f*DISTANCEFACTOR, 10000.f*DISTANCEFACTOR);
        Reverb->setActive(true);
        m_pFootStepCH->setPaused(false);
    break;
    }
case 5:
    {
        result = m_pFmod->playSound(FMOD_CHANNEL_FREE,m_pCharge,true,&m_pChargeCH);
        ErrorCheck(result);
        result = m_pChargeCH->set3DAttributes(&m_SoundPos, NULL);
        ErrorCheck(result);
        result = m_pChargeCH->setPaused(false);
        ErrorCheck(result);
        break;
    }
}

}
[/code:12qyngqq]

  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.