class GameStats
{
//LOTS OF DETAILS REMOVED
ALuint HUDSources[30]; // initialized in different function
bool HUDInUse[30];// initialized in different function
void UseItem();
}
void GameStats::UseItem()
{
GameStats::UseTimer=0;
std::stringstream rep;
//,std::string type can be "none" "ranged" "mellee" "vanity" "ammo" "attribute"
if(GameStats::myStuff.Hotbar[GameStats::ItemHotSel].Type=="ranged")
{
for(int nb=0;nb<GameStats::myStuff.Hotbar[GameStats::ItemHotSel].BulletsPerShot;nb++){for(int b=0;b<APP.BULLETS;b++)
{
int newS=-1;
for(int s=0;s<30;s++)
{
if(!GameStats::HUDInUse[s]){newS=s;s=30;}
}
if(newS!=-1)
{
alGenSources(1,&this->HUDSources[newS]);
alSourcei(GameStats::HUDSources[newS],AL_BUFFER,Sounds.Item_Sounds[GameStats::myStuff.Hotbar[GameStats::ItemHotSel].ID].on_consume);
alSource3f(GameStats::HUDSources[newS],AL_POSITION,0,0,0);
alSourcePlay(GameStats::HUDSources[newS]);
GameStats::HUDInUse[newS]=true;
}
}}
}
OpenAL Sound Playing Issues
So it must be loading the file wrong because when i use the "HelloWorld" noise maker, it works fine, but when i play the file it sounds like a really high pitch version of what i hear when i play it in any other audio manager. Here is the code i am using to play it:
I remember nothing about OpenAL... so maybe I am just talking shit but...
where is the frequency setting?
Maybe you're loading 22khz samples in a 44/48khz buffers?
where is the frequency setting?
Maybe you're loading 22khz samples in a 44/48khz buffers?
Yeah - how do you load your audio file and set up the buffer? The frequency is set here - do you use alutLoadWAVFile?
i have a this to hold sounds:
i didnt know you can change frequency...
class SoundHolder
{
ItemSound Item_Sounds[2];//1=pistol,2=apple just contains 2 ALuint
void Init();
}
//in Init()
for(int is=0;is<2;is++)
{
std::stringstream newName;newName<<"stuff/audio/items/"<<is+1<<"/";
SoundHolder::Item_Sounds[is].Init(
alutCreateBufferFromFile((newName.str()+"consume.wav").c_str()),
alutCreateBufferFromFile((newName.str()+"reload.wav").c_str())
);
}
i didnt know you can change frequency...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement