Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (523)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (591)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  About 16 sounds limitation, buffers vs sources  (Read 4212 times)
0 Members and 1 Guest are viewing this topic.
Offline xmariachi

Senior Newbie





« Posted 2005-09-28 09:14:04 »

Hi!
Hello everybody, this is my very first post here in JOAL.

I happened to have my thinkings about that limitation problem. Before I read a post before about the 16 sounds limitation, I was thinking of a dynamic or simulated dynamic way of loading sounds.

After I read that nice post, my first question is:
- Is the limitation on the number of sources or in the number of buffers?

As in that post, I have to deal with many more than 16 sounds - but i would like to have the game compatible with any sound card, and I dont think I'll need more than 16 sounds at the same time. My idea is to implement some kind of replacing algorithm, taking into consideration the PRIORITIES of the sounds (i.e. I should not replace the Background sound, for example). But then, I found myself unable to fully understand the next question...

- how should I manage a buffer, that is currently connected to a source (either playing or stopped) to load another sound on it, then link the source to the buffer and play the sound after? What happens with the data that was in the buffer and in the source before?

- I see in the other post that it is recommended to load ALL SOUNDS on the buffers, but... if there are kind of 100 sounds, may it work?

Even if i have went through the tutorials  and played with JOAL a fair bit, it may happen that I am confused about the entities in JOAL... please, could somebody help me?
Thank you very much!
Offline xmariachi

Senior Newbie





« Reply #1 - Posted 2005-09-28 09:42:44 »

Here is the other post about the 16 sounds limitation, sorry. It may be handy to have the link:

http://192.18.37.44/forums/index.php?topic=9968.0

... thanks tom for the "recommendation" for how to use buffers and sources in a real game... but, does that mean ALL the sounds have to be loaded at startup in the buffers? ALL are a lot of sounds... Smiley
Thanks again
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 836
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #2 - Posted 2005-09-28 11:14:44 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
         try
         {
            AL.create();
         }
         catch (LWJGLException exc)
         {
            exc.printStackTrace();
         }

         IntBuffer address = BufferUtils.createIntBuffer(1);

         int i;

         for (i = 0; i < 1024; i++)
         {
            try
            {
               AL10.alGenSources(address);
            }
            catch (OpenALException exc)
            {
               break;
            }
         }

         System.out.println("Max Sources: " + i);

         for (i = 0; i < 1024; i++)
         {
            try
            {
               AL10.alGenBuffers(address);
            }
            catch (OpenALException exc)
            {
               break;
            }
         }

         System.out.println("Max Buffers: " + i);




I get:

Max Sources: 256
Max Buffers: 1024 (this is where the loop terminates)

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline xmariachi

Senior Newbie





« Reply #3 - Posted 2005-09-28 12:02:04 »

Nice! Thank you very much for your answer!
But that is dependent from the sound card you are using, isn't it? Which one is it, btw?

As you may imagine I am coding a game to use in the net. Since there are battles and stuff, it is likely that will be maybe 100 sounds (actually i dont know, it will depend on another people rather than me Smiley and well, if I have more sound files than buffers then I have to implement a circulating algorithm for the buffers... which is the thing I have done now (circulating through an array of 16 buffers, and saving like from 0-2 for the background sounds, from 3-6 to other looped sounds, etc.). And it works, but with some limitations. i have to admit it's not nice at all to have to deal with that algorithm...
Anyway it seems to be needed to circulate through the sounds... isn't it?

do you think of another (better) way to do that?
Thank you very much

Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 836
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #4 - Posted 2005-09-28 12:13:18 »

As you can read in the other thread Buffers are not really limited. So you only have to manage your Sources.

My card is a stone-age one: Montego A3D by Turtle Beach (8 years old!)



It kinds sucks as there are only drivers for Win98 and running I'm WinXP, so all my 3D sound is just plain stereo ATM. Maybe that's why it supports so much sources Wink

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline tom
« Reply #5 - Posted 2005-09-28 12:19:29 »

There should be no limit on the number of buffers OpenAL can handle. I don't know what rinschwinders problem was in the other thread. May have been a bug in his hardware or driver. So load as many buffers as you like. The limit is the amount of ram you are willing to spend on having the sounds in memory. Large sounds and/or rarly used sounds can be streamed from ogg files. This is commonly used on background music.

There is a limit on the number of sources available. This depends on the sound card, and 16 is the minimum (wich is what I have on my computer).

When implementing a priority based engine, you can just stop the sound with the lowest priority and start a new sound on the same source. The only problem is that this may cause a "clicking" sound wich is quite anoying. Have found no way around this far from implementing a software mixer.

Offline xmariachi

Senior Newbie





« Reply #6 - Posted 2005-09-28 12:41:21 »

Many thanks to both.

Apparently, my implementation is doing a stupid kind of thing:
- Array of buffers [16]
- Array of sources [16]
- An undefined number of source files (this implementation is independent from that, because there are only 16 at a time).

- Make correspond source with buffer. this way, when we want to load a sound, we load the buffer and then load the source. If there was an existing buffer/source; then stop the sound, delete previous buffer/source, and gen a new buffer with the new sound file, gen a new source, bind them and play.
Well, it does work... but reading what you said, it seems to be kind of nonsensical thing with the buffers... isn't it?
Should it be just terms of performance or do you think this can issue another kind of errors?
(Bear in mind that, if a sound is requested twice(or n times), there will be two (or n) buffers loaded with the same sound... what seems to be possible anyway, since this is working - on the small, so far)

Thank you very much for your answers, you are saving my day Smiley please continue doing it  Tongue

Offline xmariachi

Senior Newbie





« Reply #7 - Posted 2005-09-28 13:29:34 »

Actually - and surprisingly though - , my approach is working fine, so I can hear at the same time a lot of guns (the infamous sound from the tutorials Wink  )
Each time a sound is loaded both in the buffer and in the source... circulating in a buffer of 17, and beginning again dispatching the first one that was used, and creating the new one there.

OK, it looks bad... but it works. At least in my computer Smiley
Any suggestions, improvements or nagging welcome...

Thanks to all!
Offline xmariachi

Senior Newbie





« Reply #8 - Posted 2005-09-28 13:47:12 »

Incredible.... look at this:

Max Sources: 102400
Max Buffers: 102400

// --
                        al = ALFactory.getAL();
              ALut.alutInit();
             al.alGetError();

            int[] address = new int[1];
            int i;
            for (i = 0; i < 102400; i++)
            {
               al.alGenSources(1,address);
            }
            System.out.println("Max Sources: " + i);
            for (i = 0; i < 102400; i++)
            {
               al.alGenBuffers(1,address);
            }
            System.out.println("Max Buffers: " + i);
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 836
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #9 - Posted 2005-09-28 13:54:41 »

Yeah yeah... guess what...

AL is making a zillion errors, and you just ignore them.

check al.alGetError() after every alGen{XYZ} and you'll see the true numbers.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline tom
« Reply #10 - Posted 2005-09-28 19:13:10 »

Many thanks to both.

Apparently, my implementation is doing a stupid kind of thing:
- Array of buffers [16]
- Array of sources [16]
- An undefined number of source files (this implementation is independent from that, because there are only 16 at a time).

- Make correspond source with buffer. this way, when we want to load a sound, we load the buffer and then load the source. If there was an existing buffer/source; then stop the sound, delete previous buffer/source, and gen a new buffer with the new sound file, gen a new source, bind them and play.
Well, it does work... but reading what you said, it seems to be kind of nonsensical thing with the buffers... isn't it?
Should it be just terms of performance or do you think this can issue another kind of errors?
(Bear in mind that, if a sound is requested twice(or n times), there will be two (or n) buffers loaded with the same sound... what seems to be possible anyway, since this is working - on the small, so far)

Thank you very much for your answers, you are saving my day Smiley please continue doing it  Tongue

Why the 1:1 mapping between source and buffer. A buffer is a sound loaded into memory that OpenAL can play. A source can play one buffer at a time. So load all your sounds into buffers at startup and forget about the source files. Then grab as many sources as you need or can get. Then manage what buffer to play with what source. To play a new buffer on a already playing source, stop the source, bind the new buffer and press play.

Offline xmariachi

Senior Newbie





« Reply #11 - Posted 2005-09-29 07:45:57 »

Sure it makes more sense.

But I have already implemented the other version, and it is working fine...
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Gibbo3771 (10 views)
2014-11-24 19:59:16

trollwarrior1 (35 views)
2014-11-22 12:13:56

xFryIx (73 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (40 views)
2014-11-12 21:09:33

kovacsa (66 views)
2014-11-07 19:57:14

TehJavaDev (70 views)
2014-11-03 22:04:50

BurntPizza (68 views)
2014-11-03 18:54:52

moogie (83 views)
2014-11-03 06:22:04
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!