| OpenAL Specification and Reference | ||
|---|---|---|
| <<< Previous | Listener and Sources | Next >>> |
Sources specify attributes like position, velocity, and a buffer with sample data. By controlling a Source's attributes the application can modify and parameterize the static sample data provided by the Buffer referenced by the Source. Sources define a localized sound, and encapsulate a set of attributes applied to a sound at its origin, i.e. in the very first stage of the processing on the way to the listener. Source related effects have to be applied before Listener related effects unless the output is invariant to any collapse or reversal of order.
AL also provides additional functions to manipulate and query the execution state of Sources: the current playing status of a source (started, stopped, paused), including access to the current sampling position within the associated Buffer.
AL provides calls to request and release Source Names handles. Calls to control Source Execution State are also provided.
The application requests a number of Sources using GenSources.
sizei GenSources ( sizei n , uint * sources );
The application requests deletion of a number of Sources by DeleteSources.
void DeleteSources ( sizei n , uint * sources );
The application can verify whether a source name is valid using the IsSource query.
boolean IsSource ( uint sourceName );
This section lists the attributes that are set per Source, affecting the processing of the current buffer. Some of these attributes can also be set for buffer queue entries.
Table 5. SOURCE_RELATIVE Attribute
| Name | Signature | Values | Default |
|---|---|---|---|
| SOURCE_RELATIVE | boolean | FALSE, TRUE | FALSE |
Table 6. Source LOOPING Attribute
| Name | Signature | Values | Default |
|---|---|---|---|
| LOOPING | uint | TURE, FALSE | FALSE |
Table 7. Source BUFFER Attribute
| Name | Signature | Values | Default |
|---|---|---|---|
| BUFFER | ui | any valid bufferName | NONE |
For a PLAYING or PAUSED Source, using the Source command with BUFFER is an INVALID_OPERATION. It can be applied to INITIAL and STOPPED Sources only. Specifying an invalid bufferName will result in an INVALID_VALUE error while specifying an invalid sourceName results in an INVALID_NAME error.
NONE, i.e. 0, is a valid buffer Name. Source( sName, BUFFER, 0 ) is a legal way to release the current buffer queue on an INITIAL or STOPPED Source, whether it has just one entry (current buffer) or more. The Source( sName, BUFFER, NONE) call still causes an INVALID_OPERATION for any source PLAYING or PAUSED, consequently it can not be abused to mute or stop a source.
Table 8. BUFFERS_QUEUED Attribute
| Name | Signature | Values | Default |
|---|---|---|---|
| BUFFERS_QUEUED | uint | [0, any] | none |
Table 9. BUFFERS_PROCESSED Attribute
| Name | Signature | Values | Default |
|---|---|---|---|
| BUFFERS_PROCESSED | uint | [0, any] | none |
Table 10. Source Minimal Gain
| Name | Signature | Values | Default |
|---|---|---|---|
| MIN_GAIN | f | 0.0f, (0.0f, 1.0f] | 0.0f |
Table 11. Source Maximal Gain (logarithmic)
| Name | Signature | Values | Default |
|---|---|---|---|
| MAX_GAIN | f | 0.0f, (0.0f, 1.0f] | 1.0f |
Table 12. REFERENCE_DISTANCE Attribute
| Name | Signature | Values | Default |
|---|---|---|---|
| REFERENCE_DISTANCE | float | [0, any] | 1.0f |
Table 13. ROLLOFF_FACTOR Attribute
| Name | Signature | Values | Default |
|---|---|---|---|
| ROLLOFF_FACTOR | float | [0, any] | 1.0f |
In particular, ROLLOFF_FACTOR can be set to zero for those Sources which are supposed to be exempt from distance attenuation. The implementation is encouraged to optimize this case, bypassing distance attenuation calculation entirely on a per-Source basis.
Table 14. MAX_DISTANCE Attribute
| Name | Signature | Values | Default |
|---|---|---|---|
| MAX_DISTANCE | float | [0, any] | MAX_FLOAT |
Table 15. Source PITCH Attribute
| Name | Signature | Values | Default |
|---|---|---|---|
| PITCH | f | (0.0f, 1.0f] | 1.0f |
Each Source can be directional, depending on the settings for CONE_INNER_ANGLE and CONE_OUTER_ANGLE. There are three zones defined: the inner cone, the outside zone, and the transitional zone in between. The angle-dependent gain for a directional source is constant inside the inner cone, and changes over the transitional zone to the value specified outside the outer cone. Source GAIN is applied for the inner cone, with an application selectable CONE_OUTER_GAIN factor to define the gain in the outer zone. In the transitional zone implementation-dependent interpolation between GAIN and GAIN times CONE_OUTER_GAIN is applied.
Table 16. Source DIRECTION Attribute
| Name | Signature | Values | Default |
|---|---|---|---|
| DIRECTION | 3fv, 3f | any except NaN | { 0.0f, 0.0f, 0.0f } |
The zero vector is default, indicating that a Source is not directional. Specifying a non-zero vector will make the Source directional. Specifying a zero vector for a directional Source will effectively mark it as nondirectional.
Table 17. Source CONE_INNER_ANGLE Attribute
| Name | Signature | Values | Default |
|---|---|---|---|
| CONE_INNER_ANGLE | i,f | any except NaN | 360.0f |
Table 18. Source CONE_OUTER_ANGLE Attribute
| Name | Signature | Values | Default |
|---|---|---|---|
| CONE_OUTER_ANGLE | i,f | any except NaN | 360.0f |
Table 19. Source CONE_OUTER_GAIN Attribute
| Name | Signature | Values | Default |
|---|---|---|---|
| CONE_OUTER_GAIN | i,f | [0.0f, 1.0f] | 0.0f |
The Source specifies the position and other properties as taken into account during sound processing.
void Source{n}{sifd} ( uint sourceName , enum paramName , T value );
void Source{n}{sifd}v ( uint sourceName , enum paramName , T * values );
Source state is maintained inside the AL implementation, and the current attributes can be queried. The performance of such queries is implementation dependent, no performance guarantees are made. The valid values for the paramName parameter are identical to the ones for Source*.
void GetSource{n}{sifd}{v} ( uint sourceName , enum paramName , T * values );
AL does not specify a built-in streaming mechanism. There is no mechanism to stream data e.g. into a Buffer object. Instead, the API introduces a more flexible and versatile mechanism to queue Buffers for Sources.
There are many ways to use this feature, with streaming being only one of them.
Streaming is replaced by queuing static buffers. This effectively moves any multi-buffer caching into the application and allows the application to select how many buffers it wants to use, whether these are re-used in cycle, pooled, or thrown away.
Looping (over a finite number of repititions) can be implemented by explicitely repeating buffers in the queue. Infinite loops can (theoretically) be accomplished by sufficiently large repetition counters. If only a single buffer is supposed to be repeated infinitely, using the respective Source attribute is recommended.
Loop Points for restricted looping inside a buffer can in many cases be replaced by splitting the sample into several buffers, queueing the sample fragments (including repetitions) accordingly.
The application can queue up one or multiple buffer names using SourceQueueBuffers. The buffers will be queued in the sequence in which they appear in the array.
void alSourceQueueBuffers ( uint sourceName , sizei numBuffers , uint * bufferNames );
Once a queue entry for a buffer has been appended to a queue and is pending processing, it should not be changed. Removal of a given queue entry is not possible unless either the Source is STOPPED (in which case then entire queue is considered processed), or if the queue entry has already been processed (PLAYING or PAUSED Source).
The Unqueue command removes a number of buffers entries that have finished processing, in the order of appearance, from the queue. The operation will fail if more buffers are requested than available, leaving the destination arguments unchanged. An INVALID_VALUE error will be thrown. If no error, the destination argument will have been updated accordingly.
void SourceUnqueueBuffers ( uint sourceName , sizei numEntries , uint * bufferNames );
The execution state of a source can be queried. AL provides a set of functions that initiate state transitions causing Sources to start and stop execution.
TBA: State Transition Diagram.
The application can query the current state of any Source using GetSource with the parameter Name SOURCE_STATE. Each Source can be in one of four possible execution states: INITIAL, PLAYING, PAUSED, STOPPED. Sources that are either PLAYING or PAUSED are considered active. Sources that are STOPPED or INITIAL are considered inactive. Only PLAYING Sources are included in the processing. The implementation is free to skip those processing stages for Sources that have no effect on the output (e.g. mixing for a Source muted by zero GAIN, but not sample offset increments). Depending on the current state of a Source certain (e.g. repeated) state transition commands are legal NOPs: they will be ignored, no error is generated.
The default state of any Source is INITIAL. From this state it can be propagated to any other state by appropriate use of the commands below. There are no irreversible state transitions.
void SourcePlay ( uint sName );
void SourcePause ( uint sName );
void SourceStop ( uint sName );
void SourceRewind ( uint sName );
The functions are also available as a vector variant, which guarantees synchronized operation on a set of Sources.
void SourcePlayv ( sizei n , uint * sNames );
void SourcePausev ( sizei n , uint * sNames );
void SourceStopv ( sizei n , uint * sNames );
void SourceRewindv ( sizei n , uint * sNames );
The following state/command/state transitions are defined:
Play() applied to an INITIAL Source will promote the Source to PLAYING, thus the data found in the Buffer will be fed into the processing, starting at the beginning. Play() applied to a PLAYING Source will restart the Source from the beginning. It will not affect the configuration, and will leave the Source in PLAYING state, but reset the sampling offset to the beginning. Play() applied to a PAUSED Source will resume processing using the Source state as preserved at the Pause() operation. Play() applied to a STOPPED Source will propagate it to INITIAL then to PLAYING immediately.
Pause() applied to an INITIAL Source is a legal NOP. Pause() applied to a PLAYING Source will change its state to PAUSED. The Source is exempt from processing, its current state is preserved. Pause() applied to a PAUSED Source is a legal NOP. Pause() applied to a STOPPED Source is a legal NOP.
Stop() applied to an INITIAL Source is a legal NOP. Stop() applied to a PLAYING Source will change its state to STOPPED. The Source is exempt from processing, its current state is preserved. Stop() applied to a PAUSED Source will change its state to STOPPED, with the same consequences as on a PLAYING Source. Stop() applied to a STOPPED Source is a legal NOP.
Rewind() applied to an INITIAL Source is a legal NOP. Rewind() applied to a PLAYING Source will change its state to STOPPED then INITIAL. The Source is exempt from processing, its current state is preserved, with the exception of the sampling offset which is reset to the beginning. Rewind() applied to a PAUSED Source will change its state to INITIAL, with the same consequences as on a PLAYING Source. Rewind() applied to a STOPPED Source promotes the Source to INITIAL, resetting the sampling offset to the beginning.
The INITIAL state is not necessarily identical to the default state in which Source is created. INITIAL merely indicates that the Source can be executed using the SourcePlay command. A STOPPED or INITIAL Source can be reset into the default configuration by using a sequence Source commands as necessary. As the application has to specify all relevant state anyway to create a useful Source configuration, no reset command is provided.
| <<< Previous | Home | Next >>> |
| Listener Object | Up | Buffers |