Home My Page Projects Code Snippets Project Openings 3D graphics for Standard ML
Summary Activity SCM

SCM Repository

[sml3d] View of /trunk/sml3d/src/openal/al-funcs.sml
ViewVC logotype

View of /trunk/sml3d/src/openal/al-funcs.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 898 - (download) (annotate)
Fri May 14 16:55:13 2010 UTC (9 years, 6 months ago) by jhr
File size: 15340 byte(s)
  Adding missing operations on sources to OpenAL library.
(* al-funcs.sml
 *
 * COPYRIGHT (c) 2010 John Reppy (http://cs.uchicago.edu/~jhr)
 * All rights reserved.
 *
 * These are the OpenAL function prototypes taken from the al.h and alc.h header files.
 *)

structure ALFuncs =
  struct

    local
      open ALTypes
    in

  (********** from al.h **********)

  (*
   * Renderer State management
   * NOTE: OpenAL 1.1 does not have any defined capabilities, so these functions
   * are not used.
   *)
    val alEnable = _import "alEnable" stdcall : al_enum -> unit;
    val alDisable = _import "alDisable" stdcall : al_enum -> unit; 
    val alIsEnabled = _import "alIsEnabled" stdcall : al_enum -> al_boolean; 

  (*
   * State retrieval
   *)
    val alGetString = _import "alGetString" stdcall : al_enum -> CString.c_string;
(* Currently, all state is scalar, so we don't need the vector forms
    val alGetBooleanv = _import "alGetBooleanv" stdcall : (al_enum * al_boolean array) -> unit;
    val alGetIntegerv = _import "alGetIntegerv" stdcall : (al_enum * al_int array) -> unit;
    val alGetFloatv = _import "alGetFloatv" stdcall : (al_enum * float array) -> unit;
    val alGetDoublev = _import "alGetDoublev" stdcall : (al_enum * double array) -> unit;
*)
    val alGetBoolean = _import "alGetBoolean" stdcall : al_enum -> al_boolean;
    val alGetInteger = _import "alGetInteger" stdcall : al_enum -> al_int;
    val alGetFloat = _import "alGetFloat" stdcall : al_enum -> float;
    val alGetDouble = _import "alGetDouble" stdcall : al_enum -> double;

  (*
   * Error support.
   * Obtain the most recent error generated in the AL state machine.
   *)
    val alGetError = _import "alGetError" stdcall : unit -> al_enum;

  (* 
   * Extension support.
   * Query for the presence of an extension, and obtain any appropriate
   * function pointers and al_enum values.
   *)
    val alIsExtensionPresent = _import "alIsExtensionPresent" stdcall : string -> al_boolean;

(*
AL_API unit* AL_APIENTRY alGetProcAddress( const ALchar* fname );
*)

    val alGetEnumValue = _import "alGetEnumValue" stdcall : string -> al_enum;


  (*
   * LISTENER
   * Listener represents the location and orientation of the
   * 'user' in 3D-space.
   *
   * Properties include: -
   *
   * Gain         AL_GAIN         ALfloat
   * Position     AL_POSITION     ALfloat[3]
   * Velocity     AL_VELOCITY     ALfloat[3]
   * Orientation  AL_ORIENTATION  ALfloat[6] (Forward then Up vectors)
   *)

  (*
   * Set Listener parameters
   *)
    val alListenerf = _import "alListenerf" stdcall : (al_enum * float) -> unit;
    val alListener3f = _import "alListener3f" stdcall : (al_enum * float * float * float) -> unit;
    val alListenerfv = _import "alListenerfv" stdcall : (al_enum * float vector) -> unit; 
    val alListeneri = _import "alListeneri" stdcall : (al_enum * al_int) -> unit;
    val alListener3i = _import "alListener3i" stdcall : (al_enum * al_int * al_int * al_int) -> unit;
    val alListeneriv = _import "alListeneriv" stdcall : (al_enum * al_int vector) -> unit;

  (*
   * Get Listener parameters
   *)
    val alGetListenerf = _import "alGetListenerf" stdcall : (al_enum * float ref) -> unit;
    val alGetListener3f = _import "alGetListener3f" stdcall : (al_enum * float ref * float ref * float ref) -> unit;
    val alGetListenerfv = _import "alGetListenerfv" stdcall : (al_enum * float array) -> unit;
    val alGetListeneri = _import "alGetListeneri" stdcall : (al_enum * al_int ref) -> unit;
    val alGetListener3i = _import "alGetListener3i" stdcall : (al_enum * al_int ref * al_int ref * al_int ref) -> unit;
    val alGetListeneriv = _import "alGetListeneriv" stdcall : (al_enum * al_int array) -> unit;

  (**
   * SOURCE
   * Sources represent individual sound objects in 3D-space.
   * Sources take the PCM data provided in the specified Buffer,
   * apply Source-specific modifications, and then
   * submit them to be mixed according to spatial arrangement etc.
   * 
   * Properties include:
   *
   * Gain                              AL_GAIN                 ALfloat
   * Min Gain                          AL_MIN_GAIN             ALfloat
   * Max Gain                          AL_MAX_GAIN             ALfloat
   * Position                          AL_POSITION             ALfloat[3]
   * Velocity                          AL_VELOCITY             ALfloat[3]
   * Direction                         AL_DIRECTION            ALfloat[3]
   * Head Relative Mode                AL_SOURCE_RELATIVE      ALint (AL_TRUE or AL_FALSE)
   * Reference Distance                AL_REFERENCE_DISTANCE   ALfloat
   * Max Distance                      AL_MAX_DISTANCE         ALfloat
   * RollOff Factor                    AL_ROLLOFF_FACTOR       ALfloat
   * Inner Angle                       AL_CONE_INNER_ANGLE     ALint or ALfloat
   * Outer Angle                       AL_CONE_OUTER_ANGLE     ALint or ALfloat
   * Cone Outer Gain                   AL_CONE_OUTER_GAIN      ALint or ALfloat
   * Pitch                             AL_PITCH                ALfloat
   * Looping                           AL_LOOPING              ALint (AL_TRUE or AL_FALSE)
   * MS Offset                         AL_MSEC_OFFSET          ALint or ALfloat
   * Byte Offset                       AL_BYTE_OFFSET          ALint or ALfloat
   * Sample Offset                     AL_SAMPLE_OFFSET        ALint or ALfloat
   * Attached Buffer                   AL_BUFFER               ALint
   * State (Query only)                AL_SOURCE_STATE         ALint
   * Buffers Queued (Query only)       AL_BUFFERS_QUEUED       ALint
   * Buffers Processed (Query only)    AL_BUFFERS_PROCESSED    ALint
   *)

  (* Create Source objects *)
    val alGenSource = _import "alGenSources" stdcall : (al_sizei * al_uint ref) -> unit;
    val alGenSources = _import "alGenSources" stdcall : (al_sizei * al_uint array) -> unit;

  (* Delete Source objects *)
    val alDeleteSources = _import "alDeleteSources" stdcall : (al_sizei * al_uint vector) -> unit;

  (* Verify a handle is a valid Source *)
    val alIsSource = _import "alIsSource" stdcall : al_uint -> al_boolean; 

  (*
   * Set Source parameters
   *)
    val alSourcef = _import "alSourcef" stdcall : (al_uint * al_enum * float) -> unit; 
    val alSource3f = _import "alSource3f" stdcall : (al_uint * al_enum * float * float * float) -> unit;
    val alSourcefv = _import "alSourcefv" stdcall : (al_uint * al_enum * float vector) -> unit; 
    val alSourcei = _import "alSourcei" stdcall : (al_uint * al_enum * al_int) -> unit; 
    val alSource3i = _import "alSource3i" stdcall : (al_uint * al_enum * al_int * al_int * al_int) -> unit;
    val alSourceiv = _import "alSourceiv" stdcall : (al_uint * al_enum * al_int vector) -> unit;
    val alSourceui = _import "alSourcei" stdcall : (al_uint * al_enum * al_uint) -> unit; 

  (*
   * Get Source parameters
   *)
    val alGetSourcef = _import "alGetSourcef" stdcall : (al_uint * al_enum * float ref) -> unit;
    val alGetSource3f = _import "alGetSource3f" stdcall : (al_uint * al_enum * float ref * float ref * float ref) -> unit;
    val alGetSourcefv = _import "alGetSourcefv" stdcall : (al_uint * al_enum * float array) -> unit;
    val alGetSourcei = _import "alGetSourcei" stdcall : (al_uint * al_enum * al_int ref) -> unit;
    val alGetSource3i = _import "alGetSource3i" stdcall : (al_uint * al_enum * al_int ref * al_int ref * al_int ref) -> unit;
    val alGetSourceiv = _import "alGetSourceiv" stdcall : (al_uint * al_enum * al_int array) -> unit;
    val alGetSourceui = _import "alGetSourcei" stdcall : (al_uint * al_enum * al_uint ref) -> unit;


  (*
   * Source vector based playback calls
   *)

  (* Play, replay, or resume (if paused) a list of Sources *)
    val alSourcePlayv = _import "alSourcePlayv" stdcall : (al_sizei * al_uint vector) -> unit;

  (* Stop a list of Sources *)
    val alSourceStopv = _import "alSourceStopv" stdcall : (al_sizei * al_uint vector) -> unit;

  (* Rewind a list of Sources *)
    val alSourceRewindv = _import "alSourceRewindv" stdcall : (al_sizei * al_uint vector) -> unit;

  (* Pause a list of Sources *)
    val alSourcePausev = _import "alSourcePausev" stdcall : (al_sizei * al_uint vector) -> unit;

  (*
   * Source based playback calls
   *)

  (* Play, replay, or resume a Source *)
    val alSourcePlay = _import "alSourcePlay" stdcall : al_uint -> unit;

  (* Stop a Source *)
    val alSourceStop = _import "alSourceStop" stdcall : al_uint -> unit;

  (* Rewind a Source (set playback postiton to beginning) *)
    val alSourceRewind = _import "alSourceRewind" stdcall : al_uint -> unit;

  (* Pause a Source *)
    val alSourcePause = _import "alSourcePause" stdcall : al_uint -> unit;

  (*
   * Source Queuing 
   *)
    val alSourceQueueBuffers = _import "alSourceQueueBuffers" stdcall : (al_uint * al_sizei * al_uint vector) -> unit;
    val alSourceUnqueueBuffers = _import "alSourceUnqueueBuffers" stdcall : (al_uint * al_sizei * al_uint array) -> unit;

  (**
   * BUFFER
   * Buffer objects are storage space for sample data.
   * Buffers are referred to by Sources. One Buffer can be used
   * by multiple Sources.
   *
   * Properties include: -
   *
   * Frequency (Query only)    AL_FREQUENCY      ALint
   * Size (Query only)         AL_SIZE           ALint
   * Bits (Query only)         AL_BITS           ALint
   * Channels (Query only)     AL_CHANNELS       ALint
   *)

  (* Create Buffer objects *)
    val alGenBuffer = _import "alGenBuffers" stdcall : (al_sizei * al_uint ref) -> unit;
    val alGenBuffers = _import "alGenBuffers" stdcall : (al_sizei * al_uint array) -> unit;

  (* Delete Buffer objects *)
    val alDeleteBuffers = _import "alDeleteBuffers" stdcall : (al_sizei * al_uint vector) -> unit;

  (* Verify a handle is a valid Buffer *)
    val alIsBuffer = _import "alIsBuffer" stdcall : al_uint -> al_boolean;

  (* Specify the data to be copied into a buffer *)
    val alBufferData =
	  _import "alBufferData" stdcall
	    : al_uint	(* buffer ID *)
	    * al_enum	(* format *)
	    * CPtr.t	(* data *)
	    * al_sizei	(* size *)
	    * al_sizei	(* frequency *)
	    -> unit;
    val alBufferData_vec =
	  _import "alBufferData" stdcall
	    : al_uint			(* buffer ID *)
	    * al_enum			(* format *)
	    * Word8Vector.vector	(* data *)
	    * al_sizei			(* size *)
	    * al_sizei			(* frequency *)
	    -> unit;
    val alBufferData_arr =
	  _import "alBufferData" stdcall
	    : al_uint			(* buffer ID *)
	    * al_enum			(* format *)
	    * Word8Array.array		(* data *)
	    * al_sizei			(* size *)
	    * al_sizei			(* frequency *)
	    -> unit;

  (*
   * Set Buffer parameters
   *)
    val alBufferf = _import "alBufferf" stdcall : (al_uint * al_enum * float) -> unit;
    val alBuffer3f = _import "alBuffer3f" stdcall : (al_uint * al_enum * float * float * float)-> unit;
    val alBufferfv = _import "alBufferfv" stdcall : (al_uint * al_enum * float vector) -> unit;
    val alBufferi = _import "alBufferi" stdcall : (al_uint * al_enum * al_int) -> unit;
    val alBuffer3i = _import "alBuffer3i" stdcall : (al_uint * al_enum * al_int * al_int * al_int) -> unit;
    val alBufferiv = _import "alBufferiv" stdcall : (al_uint * al_enum * al_int vector) -> unit;

  (*
   * Get Buffer parameters
   *)
    val alGetBufferf = _import "alGetBufferf" stdcall : (al_uint * al_enum * float ref) -> unit;
    val alGetBuffer3f = _import "alGetBuffer3f" stdcall : (al_uint * al_enum * float ref * float ref * float ref) -> unit;
    val alGetBufferfv = _import "alGetBufferfv" stdcall : (al_uint * al_enum * float array) -> unit;
    val alGetBufferi = _import "alGetBufferi" stdcall : (al_uint * al_enum * al_int ref) -> unit;
    val alGetBuffer3i = _import "alGetBuffer3i" stdcall : (al_uint * al_enum * al_int ref * al_int ref * al_int ref) -> unit;
    val alGetBufferiv = _import "alGetBufferiv" stdcall : (al_uint * al_enum * al_int array) -> unit;
    val alGetBufferui = _import "alGetBufferi" stdcall : (al_uint * al_enum * al_uint ref) -> unit;

  (*
   * Global Parameters
   *)
    val alDopplerFactor = _import "alDopplerFactor" stdcall : float -> unit;
    val alDopplerVelocity = _import "alDopplerVelocity" stdcall : float -> unit;
    val alSpeedOfSound = _import "alSpeedOfSound" stdcall : float -> unit;
    val alDistanceModel = _import "alDistanceModel" stdcall : al_enum -> unit;

  (********** from alc.h **********)

  (*
   * Context Management
   *)
    val alcCreateContext = _import "alcCreateContext" stdcall : (alc_device * al_int vector) -> alc_context;
    val alcCreateContext_np = _import "alcCreateContext" stdcall : (alc_device * CPtr.t) -> alc_context;
    val alcMakeContextCurrent = _import "alcMakeContextCurrent" stdcall : alc_context -> al_boolean;
    val alcProcessContext = _import "alcProcessContext" stdcall : alc_context -> unit;
    val alcSuspendContext = _import "alcSuspendContext" stdcall : alc_context -> unit;
    val alcDestroyContext = _import "alcDestroyContext" stdcall : alc_context -> unit;
    val alcGetCurrentContext = _import "alcGetCurrentContext" stdcall : unit -> alc_context;
    val alcGetContextsDevice = _import "alcGetContextsDevice" stdcall : alc_context -> alc_device;

  (*
   * Device Management
   *)
    val alcOpenDevice = _import "alcOpenDevice" stdcall : string -> alc_device;
    val alcOpenDevice_np = _import "alcOpenDevice" stdcall : CPtr.t -> alc_device;
    val alcCloseDevice = _import "alcCloseDevice" stdcall : alc_device -> al_boolean;

  (*
   * Error support.
   * Obtain the most recent Context error
   *)
    val alcGetError = _import "alcGetError" stdcall : alc_device -> al_enum;

  (* 
   * Extension support.
   * Query for the presence of an extension, and obtain any appropriate
   * function pointers and al_enum values.
   *)
    val alcIsExtensionPresent = _import "alcIsExtensionPresent" stdcall : (alc_device * string) -> al_boolean;
(*
ALC_API unit *ALC_APIENTRY alcGetProcAddress( ALCdevice *device, const ALCchar *funcname );
*)
    val alcGetEnumValue = _import "alcGetEnumValue" stdcall : (alc_device * string) -> al_enum;

  (*
   * Query functions
   *)
    val alcGetString = _import "alcGetString" stdcall : (alc_device * al_enum) -> CString.c_string;
    val alcGetInteger = _import "alcGetIntegerv" stdcall : (alc_device * al_enum * al_sizei * al_int ref) -> unit;
    val alcGetIntegerv = _import "alcGetIntegerv" stdcall : (alc_device * al_enum * al_sizei * al_int array) -> unit;

  (*
   * Capture functions
   *)
    val alcCaptureOpenDevice =
	  _import "alcCaptureOpenDevice" stdcall
	    : string	(* device name *)
	    * al_uint	(* frequency *)
	    * al_enum	(* format *)
	    * al_sizei	(* buffer size *)
	    -> alc_device;
    val alcCaptureOpenDevice_np =
	  _import "alcCaptureOpenDevice" stdcall
	    : CPtr.t	(* null pointer for default device name *)
	    * al_uint	(* frequency *)
	    * al_enum	(* format *)
	    * al_sizei	(* buffer size *)
	    -> alc_device;
    val alcCaptureCloseDevice = _import "alcCaptureCloseDevice" stdcall : alc_device -> al_boolean;
    val alcCaptureStart = _import "alcCaptureStart" stdcall : alc_device -> unit;
    val alcCaptureStop = _import "alcCaptureStop" stdcall : alc_device -> unit;
    val alcCaptureSamples = _import "alcCaptureSamples" stdcall : (alc_device * CPtr.t * al_sizei) -> unit;

    end (* local *)

  end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0