[Openal] sounds openAL can play

Garin Hiebert garinh at cheesetoast.net
Thu Jun 16 08:17:40 PDT 2005


Here's a scheme which should work:

- set up a WAV-file directory with a specific pattern, perhaps the 
names "note<num>.wav"
- in your app, generate 88 buffers (exit with an error if that fails, 
but it shouldn't happen)
- for each buffer, alutLoadWAVFile to grab the appropriate data and 
then dump it in the appropriate buffer using alBufferData
- generate as many sources as you can, up to 88 maximum -- you should 
end up with at least 16
- on every play event:
	- find a source which is not playing anything, attach the appropriate 
buffer to it, and play that source
	- if all sources are playing, then stop the source which played first 
(is oldest), attach the appropriate buffer to it, and play the source.

This scheme will allow you to play a large number (whatever number of 
sources you get) of notes at the same time with very low latency.

Garin



On Jun 16, 2005, at 6:52 AM, toby z wrote:

> thans for the reply Dan,
>
> I need to play a different file (0-87) for piano
> notes, when u click on a note, or move mouse over, it
> should play, but they need to be played in succession,
> there cant be any gaps between them playing, so i
> thought i could
> a. fill in 88 buffers, one for every note file,
> b. link buffer to sources
> c. play source
> d. unlink
> loop b,c,d
>
> but i dont want to give it wave-file-names to laod
> them one by one, i was thinking about keeping them all
> in a directory and reading them in one after another
>
> and since I'm going to move my mouse over the notes to
> play, so if i go from playing note0 to note22, play
> all notes between them and then back to note13 from
> note22, play all the notes, all the way
>
> and so far, looping is the only thing I have thought
> of
>
> plseae tell me if its still not clear and I'll try to
> repharase it
>
> thanks a mill,
>
> Toby
>
> --- dpeacock at creativelabs.com wrote:
>
>>
>>
>>
>>
>> Hi Toby,
>>
>> Could you give us some more information about what
>> you are trying to
>> achieve ?  I think this will help us to give you
>> better answers to your
>> questions.  Specifically are your 88 wavefiles
>> different sound-effects that
>> need to played based on certain events, or are they
>> chunks of audio that
>> need to be played back one after another ?   Why are
>> you concerned about
>> loading 88 samples, and why do you think you need to
>> loop them ?
>>
>> Just to clarify a point from your previous mail -
>> once a wavefile has been
>> loaded into an AL Buffer it will stay there until
>> you choose to delete the
>> buffer.   While the buffer exists it can be attached
>> to as many Sources as
>> you like and played.
>>
>> Thanks,
>>
>> Dan
>>
>> Notice
>> The information in this message is confidential and
>> may be legally
>> privileged.  It is intended solely for the
>> addressee.  Access to this
>> message by anyone else is unauthorized.  If you are
>> not the intended
>> recipient,  any disclosure,  copying or distribution
>> of the message,  or
>> any action taken by you in reliance on it,  is
>> prohibited and may be
>> unlawful.  If you have received this message in
>> error,  please delete it
>> and contact the sender immediately.  Thank you.
>>
>>
>>
>>
>>
>>              toby z
>>
>>              <dyavolo_blu at yaho
>>
>>              o.co.uk>
>>                    To
>>              Sent by:                  Jason Daly
>> <jdaly at ist.ucf.edu>
>>              openal-admin at open
>>                    cc
>>              source.creative.c         openAl
>>
>>              om
>> <openal at opensource.creative.com>
>>
>>               Subject
>>                                        Re: [Openal]
>> sounds openAL can play
>>              06/15/2005 05:07
>>
>>              PM
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Hi again Jason,
>>
>> I'm afraid I am asking this again,
>>
>> my sources are limited, but I can have as muny
>> buffers
>> as I want, so to play 88 wav files, I could load
>> them
>> into 88 buffers and keep 4 sources in the
>> application,
>>
>>
>> que the buffer on the sources and play the file
>> associated to it when it finds a free source to bind
>> the file to ?
>>
>> or am I still far from sanity ?
>>
>> I tried to do something yesterday about the sources
>> my
>> system supports and it didnt work very well, so I'm
>> out flapping again
>>
>> I cant really load 88 different files into an
>> application without looping them, besides I dont
>> want
>> to give the alLoadWAFfile names of those files, I am
>> thinking about letting it get the files from a
>> directory (a pool of wave files even), load them and
>> then bind them with the 4 sources I generate
>>
>> ok now I think I'm loosing it, or am I ?
>>
>> I am going to write a little program today to try
>> this
>> out, but please do tell me what you think of it
>>
>> Thanks a lot,
>>
>> Toby
>>
>>
>>
>> --- Jason Daly <jdaly at ist.ucf.edu> wrote:
>>
>>> toby z wrote:
>>>
>>>> hi guys,
>>>>
>>>> im looking up the archives but i cant really find
>>> this
>>>> bit which im sure must have already been answered
>> a
>>>> million times or something,
>>>>
>>>> q1. how many sounds can OpenAL play at a time ?
>>>>
>>>> i know OpenAL supports 32 buffers, which play
>>> sources
>>>> loaded into them, if i am recalling it right,
>> that
>>>> would mean it can play 32 sounds at a time, from
>> 32
>>>> different sources
>>>>
>>>>
>>> Close, but you've got it backwards.  You can have
>> as
>>> many buffers as you
>>> want (only limited by system memory), but sources
>>> are the limited
>>> resource.  Data is loaded into buffers, and
>> buffers
>>> are assigned (or
>>> queued) on sources.  The number of sources you can
>>> have allocated at one
>>> time depends on which implementation you're using,
>>> and possibly what
>>> sound hardware you have.  With an SB Live!, using
>>> the native Creative
>>> driver, you'll typically have 30 or so sources
>>> available, while with an
>>> Audigy, you may have 62.  If you're using the
>>> DirectSound or MMSYSTEM
>>> implementation, I think these are limited to 32
>>> sources, just to keep
>>> CPU usage down.
>>>
>>> With most back-ends of the current Linux
>>> implementation, you can
>>> generate as many sources as your system can
>> handle.
>>>
>>>> q2. so if i have 88 different sounds that i wanna
>>>> play, i will need to que them up to take buffer
>>> which
>>>> get freed or realeased after a source is done
>> with
>>> it,
>>>> but what if i need to play sound 22 again, after
>>> its
>>>> buffer was freed and in use by another sound,
>> mmmm,
>>> 79
>>>> ?
>>>>
>>>>
>>>>
>>> Most audio engines that use OpenAL have some kind
>> of
>>> source allocation
>>> scheme, so that the most "important" sounds get
>>> played when they need to
>>> be, while the less important sounds are pre-empted
>>> to make sure there
>>> are enough sources available.  In my case, I use
>> the
>>> effective gain of
>>> the sound (accounting for how loud the sound is
>>> originally, and how
>>> quiet it gets based on distance), along with an
>>> application-assigned
>>> priority.  This is pretty easy to implement, and
>> it
>>> ends up sounding
>>> pretty good in most cases.
>>>
>>> Other schemes can get a lot more complex.  For
>>> example, if you really
>>> need to play 88 sounds at the same time, you can
>>> look into clustering
>>> (exercise left for the reader :-) ).
>>>
>>> --
>>>
>>> --"J"
>>>
>>> "I'm a castaway stranded in a desolate land,
>>>  I can see the footprints in the virtual sand."
>>>            --Neil Peart
>>>
>>>
>>
>>
>>
>>
>>
>>
>>
> ___________________________________________________________
>> Yahoo! Messenger - NEW crystal clear PC to PC
>> calling worldwide with
>> voicemail http://uk.messenger.yahoo.com
>> _______________________________________________
>> openal mailing list
>> openal at opensource.creative.com
>>
> http://opensource.creative.com/mailman/listinfo/openal
>>
>> ForwardSourceID:NT000225AA
>>
>> _______________________________________________
>> openal mailing list
>> openal at opensource.creative.com
>>
> http://opensource.creative.com/mailman/listinfo/openal
>>
>
>
>
> 		
> ___________________________________________________________
> How much free photo storage do you get? Store your holiday
> snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
> _______________________________________________
> openal mailing list
> openal at opensource.creative.com
> http://opensource.creative.com/mailman/listinfo/openal
>




More information about the Openal mailing list