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

SCM Repository

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

View of /src/openal/al-capture.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 149 - (download) (annotate)
Sat May 31 19:07:07 2008 UTC (11 years, 4 months ago) by jhr
File size: 2484 byte(s)
  More work on OpenAL; split capture operations into their own module.
(* al-capture.sml
 *
 * COPYRIGHT (c) 2008 John Reppy (http://cs.uchicago.edu/~jhr)
 * All rights reserved.
 *)

structure ALCapture :> AL_CAPTURE =
  sig

(*
 * Capture functions
 *)

ALC_API ALCboolean      ALC_APIENTRY alcCaptureCloseDevice( ALCdevice *device );

ALC_API void            ALC_APIENTRY alcCaptureStart( ALCdevice *device );

ALC_API void            ALC_APIENTRY alcCaptureStop( ALCdevice *device );

ALC_API void            ALC_APIENTRY alcCaptureSamples( ALCdevice *device, ALCvoid *buffer, ALCsizei samples );

  (** Capture functions **)

    type format = alenum
    val FORMAT_MONO8 : format = AL_FORMAT_MONO8
    val FORMAT_STEREO8 : format = AL_FORMAT_STEREO8
    val FORMAT_MONO16 : format = AL_FORMAT_MONO16
    val FORMAT_STEREO8 : format = AL_FORMAT_STEREO8

    local
      val alcCaptureOpenDefaultDevice =
	    _import "alcCaptureOpenDevice" stdcall : (Ptr.t * Word32.word * alenum * Int32.int) -> capture_devicep;
      val alcCaptureOpenDevice =
	    _import "alcCaptureOpenDevice" stdcall : (string * Word32.word * alenum * Int32.int) -> capture_devicep;
      val alcCaptureStart = _import "alcCaptureStart" stdcall : capture_devicep -> unit
      val alcCaptureStop = _import "alcCaptureStop" stdcall : capture_devicep -> unit
      val alcCaptureSamples = _import "alcCaptureSamples" stdcall : capture_devicep * Word8Vector.array
    in
    fun captureOpenDevice {name, freq, format, bufSz} = (case name
	   of NONE => alcCaptureOpenDefaultDevice (Ptr.null, freq, format, bufSz)
	    | SOME name => alcCaptureOpenDevice (name^"\000", freq, format, bufSz)
	  (* end case *))
    val captureCloseDevice : capture_device -> bool
    val captureStart : capture_device -> unit
    val captureStop : capture_device -> unit
    val captureSample : capture_device -> Word8Vector.vector option
    val captureSamples : capture_device * int -> Word8Vector.vector list
    end (* local *)

    fun defaultCaptureDeviceSpecifier () = CString.toML(alcGetString(Ptr.null, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER))

    fun captureDeviceSpecifier dev = (case CString.toML(withPtr (dev, fn dev => alcGetString(dev, ALC_CAPTURE_DEVICE_SPECIFIER)))
	   of SOME s => s
	    | NONE => raise Fail "captureDeviceSpecifier: invalid device"
	  (* end case *))

    fun captureDeviceSpecifiers () = CString.cstringsToML(alcGetString(Ptr.null, ALC_CAPTURE_DEVICE_SPECIFIER))

    val captureSamples : capture_device -> int			(* number of available capture samples *)

  end


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