Jump to content
  • Advertisement
Sign in to follow this  
BennettSteele

OpenAL Sound Playing Issues

This topic is 2533 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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:


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;
}
}}
}

Share this post


Link to post
Share on other sites
Advertisement
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?

Share this post


Link to post
Share on other sites
Yeah - how do you load your audio file and set up the buffer? The frequency is set here - do you use alutLoadWAVFile?

Share this post


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


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...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!