Jump to content
• Advertisement

# questions about OpenAL

This topic is 5001 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

hi, ive read a few tutorials and skimmed the docs, but cant find any mention of this. what exactly is 3d sound? does this mean that a sound will be louder if its closer to the listener? if so, how could i accomplish this in 2D? what do i put for orientation, and for the Z part of position? also, what exactly is a "doppler" effect? (i believe this is what velocity is for). last, i cant figure out the formats that OpenAL supports, couldnt find any mention of it in the docs. from searching i know it supports at least WAV, but what about OGG? i saw in an older post that it would be supported soon, so im not sure.. also, does anyone know of a higher level sound API which supports 3d sounds, and is free with an LGPL'ish licence? i couldnt seem to find any like this, ive seen Audiere and a few others, but they are either not free, or do not have 3d sound.. thanks for any help.

#### Share this post

##### Share on other sites
Advertisement
>> what exactly is 3d sound?
*The 'real life' modeling of sound. 3D sound means it can have 3 dimensions of properties.

>> does this mean that a sound will be louder if its closer to the listener?
*Yes sir!

>> if so, how could i accomplish this in 2D?
*Change the 'GAIN' if you are not using positions. (Volume)

>> what do i put for orientation,
*The default values are fine

>> and for the Z part of position?
*The default values are fine as well

>> also, what exactly is a "doppler" effect? (i believe this is what velocity is for).
*See links at bottom.

>> last, i cant figure out the formats that OpenAL supports, couldnt find any mention of it in the docs. from searching i know it supports at least WAV, but what about OGG? i saw in an older post that it would be supported soon, so im not sure..
*OGG and WAV. You must use the static libraries of OGG though. The dynamic libraries will crash and kill your app. I learned this the hard way

>> also, does anyone know of a higher level sound API which supports 3d sounds, and is free with an LGPL'ish licence? i couldnt seem to find any like this, ive seen Audiere and a few others, but they are either not free, or do not have 3d sound..
*Nope, you have to make your own or use someone else's

Here is a lot of good stuff you should read and most of your questions will be answered better here. It is what I used to learn everything I have. If there is anything you can't find from those tutorials, feel free to ask. I've been working with OpenAL for the past 8 weeks, so I can say I'm fairly comfortable with it - even though I have not used a few things in it, such as Doppler.

One last thing is to download the OpenAL SDK and look at the example that comes with it. It has almost every concept you will need to know. If there's anything else feel free to ask [smile].

- Drew

#### Share this post

##### Share on other sites
Just to let you know, Drew, the problem with the dynamic libraries is that the file operations it uses are wrong (how they messed that up, I don't know). Here's the code I use to fix it (it's a good thing you can use your own functions):

#include <stdio.h>//this is the only way I could get the proper functions to be called//(note the lack of formatting) ;)size_t oread(void *ptr, size_t size, size_t nmemb, void *datasource){return fread(ptr,size,nmemb,datasource);}int oseek(void *datasource, ogg_int64_t offset, int whence){return fseek(datasource,offset,whence);}int oclose(void *datasource){return fclose(datasource);}long otell(void *datasource){return ftell(datasource);}  //when you're ready to read the OGG:  FILE* file = fopen("filename","rb");  OggVorbis_File ogg;    ov_callbacks cbs;  cbs.read_func  = &oread;  cbs.seek_func  = &oseek;  cbs.close_func = &oclose;  cbs.tell_func  = &otell;    ov_open_callbacks(file,&ogg,0,0,cbs);

You'll need to add appropriate error checking and so forth, but this should solve your problems.

#### Share this post

##### Share on other sites
ah, cheers Gorax, i've had the same problem and was hoping for an in-source fix, but next time I take a look I'll use that solution [smile]

One note to expand apon what Drew said, techincally speaking OpenAL only suports PCM data, support for other formats requires that you decode the data and send it to OpenAL yourself (as Drew mentions you can use the Ogg libs for Ogg files), while this might seem a pain it does mean the library isnt weighted down with every codec under the sun in it and that you can use it as you see fit (for example, I've got a lot of old style 'chip music' and a decoder for it, so I can just use that to decode the music to PCM and feed it to OpenAL, job done.)

#### Share this post

##### Share on other sites
Quote:
 Original post by GoraxJust to let you know, Drew, the problem with the dynamic libraries is that the file operations it uses are wrong (how they messed that up, I don't know). Here's the code I use to fix it (it's a good thing you can use your own functions):*** Source Snippet Removed ***You'll need to add appropriate error checking and so forth, but this should solve your problems.

I will definitly give that a try and get back to you on if I can get it to work. Thanks!

 Well I'll be. Thank you so much for that [smile] Works like a charm! I would have never figured that one out. How did you know that?

#### Share this post

##### Share on other sites
Quote:
 Original post by GoraxJust to let you know, Drew, the problem with the dynamic libraries is that the file operations it uses are wrong (how they messed that up, I don't know). Here's the code I use to fix it (it's a good thing you can use your own functions):*** Source Snippet Removed ***You'll need to add appropriate error checking and so forth, but this should solve your problems.

You can just assign fread/fseek/etc. directly to the callbacks structure if you only plan on using FILE *.

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5
• Advertisement

• 18
• 19
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633362
• Total Posts
3011531
• ### Who's Online (See full list)

There are no registered users currently online

×

## 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!