Sign in to follow this  
BennettSteele

OpenAL Sound Playing Issues

Recommended Posts

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:

[code]
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;
}
}}
}

[/code]

Share this post


Link to post
Share on other sites
i have a this to hold sounds:

[code]
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())
);
}

[/code]



i didnt know you can change frequency...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this