Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

  1. Outdated egg!
  2. openal
    1. al
    2. alc
    3. openal
    4. Examples
    5. Author
    6. License
  3. Version History

openal

This extension provides bindings for the OpenAL sound API, version 1.1.

See alut for a binding for ALUT, a utility library for OpenAL.

Currently this has only been tested on Mac OS X with the binary release and with Linux. Windows support should be trivial, but needs modification of the openal.setup script.

Functionality is split into several sub-extensions:

al

Usage: (require-extension al)

[constant] al:BITS -> INT
[constant] al:BUFFER -> INT
[constant] al:BUFFERS_PROCESSED -> INT
[constant] al:BUFFERS_QUEUED -> INT
[constant] al:CHANNELS -> INT
[constant] al:CONE_INNER_ANGLE -> INT
[constant] al:CONE_OUTER_ANGLE -> INT
[constant] al:CONE_OUTER_GAIN -> INT
[constant] al:DATA -> INT
[constant] al:DIRECTION -> INT
[constant] al:DISTANCE_MODEL -> INT
[constant] al:DOPPLER_FACTOR -> INT
[constant] al:DOPPLER_VELOCITY -> INT
[constant] al:EXTENSIONS -> INT
[constant] al:FALSE -> INT
[constant] al:FORMAT_MONO16 -> INT
[constant] al:FORMAT_MONO8 -> INT
[constant] al:FORMAT_STEREO16 -> INT
[constant] al:FORMAT_STEREO8 -> INT
[constant] al:FREQUENCY -> INT
[constant] al:GAIN -> INT
[constant] al:INITIAL -> INT
[constant] al:INVALID -> INT
[constant] al:INVALID_ENUM -> INT
[constant] al:INVALID_NAME -> INT
[constant] al:INVALID_OPERATION -> INT
[constant] al:INVALID_VALUE -> INT
[constant] al:INVERSE_DISTANCE -> INT
[constant] al:INVERSE_DISTANCE_CLAMPED -> INT
[constant] al:LOOPING -> INT
[constant] al:MAX_DISTANCE -> INT
[constant] al:MAX_GAIN -> INT
[constant] al:MIN_GAIN -> INT
[constant] al:NO_ERROR -> INT
[constant] al:NONE -> INT
[constant] al:ORIENTATION -> INT
[constant] al:OUT_OF_MEMORY -> INT
[constant] al:PAUSED -> INT
[constant] al:PENDING -> INT
[constant] al:PITCH -> INT
[constant] al:PLAYING -> INT
[constant] al:POSITION -> INT
[constant] al:PROCESSED -> INT
[constant] al:REFERENCE_DISTANCE -> INT
[constant] al:RENDERER -> INT
[constant] al:ROLLOFF_FACTOR -> INT
[constant] al:SIZE -> INT
[constant] al:SOURCE_ABSOLUTE -> INT
[constant] al:SOURCE_RELATIVE -> INT
[constant] al:SOURCE_STATE -> INT
[constant] al:SOURCE_TYPE -> INT
[constant] al:STOPPED -> INT
[constant] al:TRUE -> INT
[constant] al:UNUSED -> INT
[constant] al:VELOCITY -> INT
[constant] al:VENDOR -> INT
[constant] al:VERSION -> INT
[procedure] (al:BufferData INT INT C-POINTER INT INT)
[procedure] (al:DeleteBuffers INT U32VECTOR)
[procedure] (al:DeleteSources INT U32VECTOR)
[procedure] (al:Disable INT)
[procedure] (al:DistanceModel INT)
[procedure] (al:DopplerFactor FLOAT)
[procedure] (al:DopplerVelocity FLOAT)
[procedure] (al:Enable INT)
[procedure] (al:GenBuffers INT U32VECTOR)
[procedure] (al:GenSources INT U32VECTOR)
[procedure] (al:GetBoolean INT) -> BOOL
[procedure] (al:GetBooleanv INT U8VECTOR)
[procedure] (al:GetBufferf INT INT S32VECTOR)
[procedure] (al:GetBufferi INT INT F32VECTOR)
[procedure] (al:GetDouble INT) -> FLOAT
[procedure] (al:GetDoublev INT F64VECTOR)
[procedure] (al:GetEnumValue STRING) -> INT
[procedure] (al:GetError) -> INT
[procedure] (al:GetFloat INT) -> FLOAT
[procedure] (al:GetFloatv INT F32VECTOR)
[procedure] (al:GetInteger INT) -> INT
[procedure] (al:GetIntegerv INT S32VECTOR)
[procedure] (al:GetListener3f INT) -> FLOAT FLOAT FLOAT
[procedure] (al:GetListenerf INT) -> FLOAT
[procedure] (al:GetListenerfv INT F32VECTOR)
[procedure] (al:GetListeneri INT) -> INT
[procedure] (al:GetProcAddress STRING) -> C-POINTER
[procedure] (al:GetSource3f INT INT) -> FLLOAT FLOAT FLOAT
[procedure] (al:GetSourcef INT INT) -> FLOAT
[procedure] (al:GetSourcefv INT INT F32VECTOR)
[procedure] (al:GetSourcei INT INT) -> INT
[procedure] (al:GetString INT) -> STRING
[procedure] (al:IsBuffer INT) -> BOOL
[procedure] (al:IsEnabled INT) -> BOOL
[procedure] (al:IsExtensionPresent STRING) -> BOOL
[procedure] (al:IsSource INT) -> BOOL
[procedure] (al:Listener3f INT FLOAT FLOAT FLOAT)
[procedure] (al:Listenerf INT FLOAT)
[procedure] (al:Listenerfv INT F32VECTOR)
[procedure] (al:Listeneri INT INT)
[procedure] (al:SetDouble INT DOUBLE)
[procedure] (al:SetInteger INT INT)
[procedure] (al:Source3f INT INT FLOAT FLOAT FLLOAT)
[procedure] (al:Sourcef INT INT FLOAT)
[procedure] (al:Sourcefv INT INT F32VECTOR)
[procedure] (al:Sourcei INT INT INT)
[procedure] (al:SourcePause INT)
[procedure] (al:SourcePausev INT U32VECTOR)
[procedure] (al:SourcePlay INT)
[procedure] (al:SourcePlayv INT U32VECTOR)
[procedure] (al:SourceQueueBuffers INT INT U32VECTOR)
[procedure] (al:SourceRewind INT)
[procedure] (al:SourceRewindv INT U32VECTOR)
[procedure] (al:SourceStop INT)
[procedure] (al:SourceStopv INT U32VECTOR)
[procedure] (al:SourceUnqueueBuffers INT INT U32VECTOR)

alc

Usage: (require-extension alc)

[constant] alc:ALL_ATTRIBUTES -> INT
[constant] alc:ATTRIBUTES_SIZE -> INT
[constant] alc:CONVERT_DATA_UPON_LOADING -> INT
[constant] alc:DEFAULT_DEVICE_SPECIFIER -> INT
[constant] alc:DEVICE_SPECIFIER -> INT
[constant] alc:EXTENSIONS -> INT
[constant] alc:FALSE -> INT
[constant] alc:FREQUENCY -> INT
[constant] alc:INVALID -> INT
[constant] alc:INVALID_CONTEXT -> INT
[constant] alc:INVALID_DEVICE -> INT
[constant] alc:INVALID_ENUM -> INT
[constant] alc:INVALID_VALUE -> INT
[constant] alc:MAJOR_VERSION -> INT
[constant] alc:MINOR_VERSION -> INT
[constant] alc:MIXER_MAXIMUM_BUSSES -> INT
[constant] alc:MIXER_OUTPUT_RATE -> INT
[constant] alc:NO_ERROR -> INT
[constant] alc:OUT_OF_MEMORY -> INT
[constant] alc:REFRESH -> INT
[constant] alc:RENDER_CHANNEL_COUNT -> INT
[constant] alc:SPATIAL_RENDERING_QUALITY -> INT
[constant] alc:SYNC -> INT
[constant] alc:TRUE -> INT
[procedure] (alc:CloseDevice C-POINTER)
[procedure] (alc:CreateContext C-POINTER S32VECTOR) -> C-POINTER
[procedure] (alc:DestroyContext C-POINTER)
[procedure] (alc:GetContextsDevice C-POINTER) -> C-POINTER
[procedure] (alc:GetCurrentContext) -> C-POINTER
[procedure] (alc:GetEnumValue C-POINTER STRING) -> INT
[procedure] (alc:GetError C-POINTER) -> INT
[procedure] (alc:GetIntegerv C-POINTER INT INT S32VECTOR)
[procedure] (alc:GetProcAddress C-POINTER STRING) -> C-POINTER
[procedure] (alc:GetString C-POINTER INT) -> STRING
[procedure] (alc:IsExtensionPresent C-POINTER STRING) -> BOOL
[procedure] (alc:MakeContextCurrent C-POINTER) -> BOOL
[procedure] (alc:OpenDevice STRING) -> C-POINTER
[procedure] (alc:ProcessContext C-POINTER)
[procedure] (alc:SuspendContext C-POINTER)

openal

Usage: (require-extension openal)

This extension loads al, alc and alut and provides few higher-level operations. Note that loading this unit automatically calls alut:Init.

[procedure] (openal:make-source INT) -> INT

Creates a source from a given buffer identifier and returns the source identifier.

[procedure] (openal:device-list) -> (STRING ...)

Returns a list of available device names.

[procedure] (openal:make-buffer DATA STEREO? FREQ)

Creates a buffer from sound data (either a u8vector, a s16vector or a foreign pointer object. Returns a buffer identifier.

Examples

Generating a triangle wave:

(use openal al alc srfi-4 extras)

(define device (alc:OpenDevice #f))
(define context (alc:CreateContext device #f))
(define data (make-u8vector 600000))

(define (sound i)
  (/ (modulo i 60) 60))

(let loop ((i 0))
  (unless (>= i 600000)
  (u8vector-set! data i (inexact->exact (floor (max 0 (min 256 (* 256 (sound i)))))))
  (loop (+ 1 i))))

(alc:MakeContextCurrent context)
(define buffer (openal:make-buffer data #f 44100))
(define source (openal:make-source buffer))
(al:Sourcei source al:LOOPING 1)
(al:SourcePlay source)
(read-line)
(alc:MakeContextCurrent #f)
(alc:DestroyContext context)
(alc:CloseDevice device)

Author

felix winkelmann

License

Copyright (c) 2006-2015, Felix L. Winkelmann
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
conditions are met:

  Redistributions of source code must retain the above copyright notice, this list of conditions and the following
    disclaimer. 
  Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
    disclaimer in the documentation and/or other materials provided with the distribution. 
  Neither the name of the author nor the names of its contributors may be used to endorse or promote
    products derived from this software without specific prior written permission. 

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

Version History

0.9
moved alut stuff into a separate egg (alut)
0.7
test runs only for limited time when invoked over chicken-install
0.6
fixed missing libraries for non-Mac platforms
0.5
ported to CHICKEN 4
0.3
fixed easyffi requirement in meta file (thanks to mario domenech goulart)
0.2
fixed invalid references to obsolete openal-check procedure
0.1
initial release