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-sig.sml
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 898 - (download) (annotate)
Fri May 14 16:55:13 2010 UTC (9 years, 5 months ago) by jhr
File size: 7745 byte(s)
  Adding missing operations on sources to OpenAL library.
(* al-sig.sml
 *
 * COPYRIGHT (c) 2010 John Reppy (http://www.cs.uchicago.edu/~jhr)
 * All rights reserved.
 *
 * An SML API for the OpenAL library (Version 1.1).  See openal.org for
 * documentation.  This interface combines the al.h and alc.h C APIs.
 *)

signature AL =
  sig

  (* common types *)
    type float = Real32.real
    type vec3f = {x : float, y : float, z : float}

  (* basic OpenAL types *)
    eqtype device
    eqtype context
    eqtype source
    eqtype buffer
    eqtype capture_device

  (*
   * State retrieval
   *)
    val vendorString : unit -> string
    val rendererString : unit -> string
    val versionString : unit -> string
    val extensionsString : unit -> string
    val extensions : unit -> string list

  (*
   * Global Parameters
   *)
    val dopplerFactor   : float -> unit
    val dopplerVelocity : float -> unit
    val speedOfSound    : float -> unit

  (* distance model *)
    eqtype distance_model
    val INVERSE_DISTANCE		: distance_model
    val INVERSE_DISTANCE_CLAMPED	: distance_model
    val LINEAR_DISTANCE			: distance_model
    val LINEAR_DISTANCE_CLAMPED		: distance_model
    val EXPONENT_DISTANCE		: distance_model
    val EXPONENT_DISTANCE_CLAMPED	: distance_model
    val distanceModel : distance_model option -> unit

  (*
   * Error support.
   * Obtain the most recent error generated in the AL state machine.
   *)
    structure Error : sig
	datatype error
	  = NO_ERROR
      (* global errors *)
	  | INVALID_NAME
	  | INVALID_OPERATION
      (* device errors *)
	  | INVALID_DEVICE
	  | INVALID_CONTEXT
      (* general errors *)
	  | INVALID_ENUM
	  | INVALID_VALUE
	  | OUT_OF_MEMORY

	val getError : unit -> error
	val getDevError : device -> error

	val toString : error -> string

      end

    structure Format : sig
	eqtype format

	val MONO8 : format
	val MONO16 : format
	val STEREO8 : format
	val STEREO16 : format

	val isMono : format -> bool
	val channels : format -> int
	val bytesPerChannel : format -> int
	val bytesPerSample : format -> int
      end

  (**
   * BUFFER
   * Buffer objects are storage space for sample data.
   * Buffers are referred to by Sources. One Buffer can be used
   * by multiple Sources.
   *)
    structure Buffer : sig
	val gen : unit -> buffer
	val genList : int -> buffer list
	val delete : buffer list -> unit

      (* Get Buffer parameters *)
	val frequency : buffer -> int
	val bitsPerSample : buffer -> int
	val channels : buffer -> int
	val size : buffer -> int

	val loadFromVector : (buffer * Word8Vector.vector * Format.format * int) -> unit
	val loadFromArray : (buffer * Word8Array.array * Format.format * int) -> unit
      end

    structure Source : sig
      (* the type *)
	datatype mode = UNDETERMINED | STATIC | STREAMING

	eqtype state
	val INITIAL : state
	val PLAYING : state
	val PAUSED : state
	val STOPPED : state

	val gen : unit -> source
	val genList : int -> source list
	val delete : source list -> unit

      (* playback controls *)
	val play : source -> unit
	val playList : source list -> unit
	val stop : source -> unit
	val stopList : source list -> unit
	val pause : source -> unit
	val pauseList : source list -> unit
	val rewind : source -> unit
	val rewindList : source list -> unit

      (* get the current mode of the source *)
	val mode : source -> mode

      (* get current state *)
	val state : source -> state

      (* source position *)
	val position : source -> vec3f
	val setPosition : (source * vec3f) -> unit

      (* is position relative to listener? *)
	val relative : source -> bool
	val setRelative : source * bool -> unit

      (* source velocity *)
	val velocity : source -> vec3f
	val setVelocity : (source * vec3f) -> unit

      (* source direction and cone *)
	val direction : source -> vec3f
	val setDirection : (source * vec3f) -> unit
	val coneInnerAngle : source -> float
	val setConeInnerAngle : source * float -> unit
	val coneOuterAngle : source -> float
	val setConeOuterAngle : source * float -> unit
	val coneOuterGain : source -> float
	val setConeOuterGain : source * float -> unit

      (* frequency shift *)
	val pitch : source -> float
	val setPitch : source * float -> unit

      (* looping playback *)
	val looping : source -> bool
	val setLooping : source * bool -> unit

      (* gain bounds *)
	val minGain : source -> float
	val setMinGain : source -> float
	val maxGain : source -> float
	val setMaxGain : source -> float

      (* distance-model attributes *)
	val referenceDistance : source -> float
	val setReferenceDistance : source * float -> unit
	val rolloffFactor : source -> float
	val setRolloffFactor : source * float -> unit
	val maxDistance : source -> float
	val setMaxDistance : source * float -> unit

      (* offset into the curent audio data *)
	val offset : source -> Time.time
	val setOffset : source * Time.time -> unit
	val sampleOffset : source -> int
	val setSampleOffset : source * int -> unit
	val byteOffset : source -> int
	val setByteOffset : source * int -> unit

      (* get the current buffer attached to the source, or NONE if there is no buffer *)
	val buffer : source -> buffer option
      (* set the given buffer to be the head of the source's queue *)
	val setBuffer : source * buffer -> unit
      (* clear all of the buffers from the source's queue *)
	val clrBuffer : source -> unit

      (* return the number of buffers in the source's queue *)
	val buffersQueued : source -> int
      (* return the number of buffers that have been completely played *)
	val buffersProcessed : source -> int
      (* add buffers to the end of the source's queue *)
	val queueBuffers : source * buffer list -> unit
      (* remove processed buffers from the front of the queue *)
	val unqueueBuffers : source * int -> buffer list

      end

    structure Listener : sig
      (* gain of listener for current context *)
	val gain : unit -> float
	val setGain : float -> unit
    
      (* listener position *)
	val position : unit -> vec3f
	val setPosition : vec3f -> unit
    
      (* listener velocity *)
	val velocity : unit -> vec3f
	val setVelocity : vec3f -> unit
    
      (* listener orientation *)
	val orientation : unit -> {dir : vec3f, up : vec3f}
	val setOrientation : {dir : vec3f, up : vec3f} -> unit
      end

    structure Context : sig
	datatype context_attr
	  = FREQUENCY of int		(* Frequency for mixing output buffer (Hz) *)
	  | REFRESH of int		(* Refresh intervals (Hz) *)
	  | SYNC of bool		(* Indicating a synchronous context *)
	  | MONO_SOURCES of int		(* Number of requested mono sources *)
	  | STEREO_SOURCES of int	(* Number of requested stereo sources *)
    
	val create : device * context_attr list -> context option
	val makeCurrent : context -> bool
	val process : context -> unit
	val suspend : context -> unit
	val destroy : context -> unit
	val getCurrent : unit -> context option
	val getDevice : context -> device option
      end

    structure Device : sig
      (* Device initialization *)
	val openDev : string option -> device option
	val close : device -> bool

      (** Query functions **)
	val defaultSpecifier : unit -> string		(* specifier string for default device *)
	val specifier : device -> string		(* name of device *)
	val specifiers : unit -> string list		(* names of all devices *)
	val attributes : device -> Context.context_attr list	(* context attributes for device *)
      end

  (* Audio-file I/O *)
    structure IO : sig
	type buffer_info = {
	    frequency : int,		(* frequency *)
	    format : Format.format,	(* number of channels and bytes per sample *)
	    size : int			(* number of samples (not bytes!) *)
	  }
	val loadFile : string -> buffer * buffer_info
	val loadFileIntoBuffer : string * buffer -> buffer_info
      end

  end

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