Get current volume for a source

View: New views
7 Messages — Rating Filter:   Alert me  

Get current volume for a source

by The Big Uno :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello all,

I am trying to implement a VU Meter style widget by pulling the
currently playing volume of a given source.  Note that this is not the
gain of the source; I want the number to be either the raw value of the
sound frame at the time I call the function, or the raw value * current
gain set for the source.  Does anyone have an idea on what function I
could call for this?

I would like to get this value for just a certain source, not the entire
OpenAL environment.  The VU meters I am making are going to be on a
per-channel level, with each source logically mapped to a certain
channel.  Think of the giant mixing boards with a VU meter for each
input source for an idea of what I am trying to do here.

(On a side note, I am actually using JOAL - Java wrappers for the OpenAL
functions - which I believe is currently using the OpenAL 1.0
specification.  The JOAL methods map quite closely to the underlying
OpenAL API, which is why I am asking here and not on the JOAL forums.  
If you can get me the OpenAL function, that would be good enough for me.)

Thank you!
_______________________________________________
Openal mailing list
Openal@...
http://opensource.creative.com/mailman/listinfo/openal

Re: Get current volume for a source

by Jason Daly :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The Big Uno wrote:

> Hello all,
>
> I am trying to implement a VU Meter style widget by pulling the
> currently playing volume of a given source.  Note that this is not the
> gain of the source; I want the number to be either the raw value of the
> sound frame at the time I call the function, or the raw value * current
> gain set for the source.  Does anyone have an idea on what function I
> could call for this?
>
> I would like to get this value for just a certain source, not the entire
> OpenAL environment.  The VU meters I am making are going to be on a
> per-channel level, with each source logically mapped to a certain
> channel.  Think of the giant mixing boards with a VU meter for each
> input source for an idea of what I am trying to do here.
>  

The only way to do this is to retain your own copy of each source's
buffer data after you pass it to OpenAL, and then get the current
position of each source as you update your meter.  You can either call
alGetIntegerv with AL_SAMPLE_OFFSET or AL_BYTE_OFFSET, or you can call
alGetFloatv or alGetDoublev with AL_SEC_OFFSET, whichever you prefer.


> (On a side note, I am actually using JOAL - Java wrappers for the OpenAL
> functions - which I believe is currently using the OpenAL 1.0
> specification.  The JOAL methods map quite closely to the underlying
> OpenAL API, which is why I am asking here and not on the JOAL forums.  
> If you can get me the OpenAL function, that would be good enough for me.)
>  

Oh, then you're out of luck.  The AL_*_OFFSET queries are 1.1 features.  
As far as I know, there isn't any reliable way to do what you want in
OpenAL 1.0.

--"J"

_______________________________________________
Openal mailing list
Openal@...
http://opensource.creative.com/mailman/listinfo/openal

Re: Get current volume for a source

by The Big Uno :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Jason Daly wrote:

> The Big Uno wrote:
>> Hello all,
>>
>> I am trying to implement a VU Meter style widget by pulling the
>> currently playing volume of a given source.  Note that this is not
>> the gain of the source; I want the number to be either the raw value
>> of the sound frame at the time I call the function, or the raw value
>> * current gain set for the source.  Does anyone have an idea on what
>> function I could call for this?
>>
>> I would like to get this value for just a certain source, not the
>> entire OpenAL environment.  The VU meters I am making are going to be
>> on a per-channel level, with each source logically mapped to a
>> certain channel.  Think of the giant mixing boards with a VU meter
>> for each input source for an idea of what I am trying to do here.
>>  
>
> The only way to do this is to retain your own copy of each source's
> buffer data after you pass it to OpenAL, and then get the current
> position of each source as you update your meter.  You can either call
> alGetIntegerv with AL_SAMPLE_OFFSET or AL_BYTE_OFFSET, or you can call
> alGetFloatv or alGetDoublev with AL_SEC_OFFSET, whichever you prefer.
>
>
>> (On a side note, I am actually using JOAL - Java wrappers for the
>> OpenAL functions - which I believe is currently using the OpenAL 1.0
>> specification.  The JOAL methods map quite closely to the underlying
>> OpenAL API, which is why I am asking here and not on the JOAL
>> forums.  If you can get me the OpenAL function, that would be good
>> enough for me.)
>>  
>
> Oh, then you're out of luck.  The AL_*_OFFSET queries are 1.1
> features.  As far as I know, there isn't any reliable way to do what
> you want in OpenAL 1.0.
>
> --"J"
>

Thanks for your help, I guess I will have to wait for Joal to get to 1.1
(or find another wrapper library).

Cheers
_______________________________________________
Openal mailing list
Openal@...
http://opensource.creative.com/mailman/listinfo/openal

Re: Get current volume for a source

by The Big Uno :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


>> (On a side note, I am actually using JOAL - Java wrappers for the
>> OpenAL functions - which I believe is currently using the OpenAL 1.0
>> specification.  The JOAL methods map quite closely to the underlying
>> OpenAL API, which is why I am asking here and not on the JOAL
>> forums.  If you can get me the OpenAL function, that would be good
>> enough for me.)
>>  
>
> Oh, then you're out of luck.  The AL_*_OFFSET queries are 1.1
> features.  As far as I know, there isn't any reliable way to do what
> you want in OpenAL 1.0.
>
> --"J"
>
Hmm, please disregard my previous comment - it appears that JOAL has
AL_*_OFFSET queries defined, so it must be using 1.1.  I must have been
looking at outdated documentation when I read that it was 1.0 only.

I am not sure about the methods alGet*v, though - from the documentation
it appears that these are for querying global parameters, as they don't
appear to accept a source pointer as a parameter (page 22, OpenAL 1.1
Specification).  alGetSourcei seems to be more suited to this, and
appears to work from my initial tests.  For anyone reading this list who
may be using JOAL, below is my code:

        int[] position = new int[1];
        al.alGetSourcei(sources[0], AL.AL_BYTE_OFFSET, position, 0);
        System.out.println(position[0]);

This returns an ever- increasing number as it is queried every 100ms.  
 From here, it should be possible to find the current value in the buffer.

Thank you again Jason for putting me on the right track!

Cheers
_______________________________________________
Openal mailing list
Openal@...
http://opensource.creative.com/mailman/listinfo/openal

Re: Get current volume for a source

by Jason Daly :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The Big Uno wrote:
> Hmm, please disregard my previous comment - it appears that JOAL has
> AL_*_OFFSET queries defined, so it must be using 1.1.  I must have been
> looking at outdated documentation when I read that it was 1.0 only.
>  

Glad you've got something that works  :-)


> I am not sure about the methods alGet*v, though - from the documentation
> it appears that these are for querying global parameters, as they don't
> appear to accept a source pointer as a parameter (page 22, OpenAL 1.1
> Specification).  alGetSourcei seems to be more suited to this, and
> appears to work from my initial tests.

Sorry, you're absolutely right.  Those values are source queries, not
global queries.  My mistake.

--"J"
_______________________________________________
Openal mailing list
Openal@...
http://opensource.creative.com/mailman/listinfo/openal

Re: Get current volume for a source

by The Big Uno :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

One final question - I have not been able to find the query / function to grab the actual raw buffer data at a given point.  I assume it will be one of the alGetBuffer[i|f][v?] functions, but I can't figure out what the query parameter should be.  Not knowing what the OpenAL terminology for this is, I have not been able to find the right parameter.  Any suggestions would be most welcome.

Thanks again for all your help!

Cheers



On Mon, Jun 8, 2009 at 12:03 PM, Jason Daly <jdaly@...> wrote:
The Big Uno wrote:
Hmm, please disregard my previous comment - it appears that JOAL has AL_*_OFFSET queries defined, so it must be using 1.1.  I must have been looking at outdated documentation when I read that it was 1.0 only.
 

Glad you've got something that works  :-)



I am not sure about the methods alGet*v, though - from the documentation it appears that these are for querying global parameters, as they don't appear to accept a source pointer as a parameter (page 22, OpenAL 1.1 Specification).  alGetSourcei seems to be more suited to this, and appears to work from my initial tests.

Sorry, you're absolutely right.  Those values are source queries, not global queries.  My mistake.

--"J"


_______________________________________________
Openal mailing list
Openal@...
http://opensource.creative.com/mailman/listinfo/openal

Re: Get current volume for a source

by Jason Daly :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The Big One wrote:
> One final question - I have not been able to find the query / function
> to grab the actual raw buffer data at a given point.

And you won't.  By design, there is no way to query buffer data from OpenAL.

OpenAL was designed to support hardware accelerated sound.  Once you
give the buffer data to OpenAL, it can do whatever it wants with it,
including converting it to a better format for whatever hardware is
running.  That data might reside in on-board memory, which would make it
practically impossible to return a meaningful value (by the time all the
DMA's and bus transfers were done, you'd be off by a few thousand samples).

This is why I said you have to keep your own copy of the buffer data.  
You can query the current source position, then look up the value at
that position in your own copy of the data.

--"J"

_______________________________________________
Openal mailing list
Openal@...
http://opensource.creative.com/mailman/listinfo/openal