;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; LUSH Lisp Universal Shell
;;;   Copyright (C) 2002 Leon Bottou, Yann Le Cun, AT&T Corp, NECI.
;;; Includes parts of TL3:
;;;   Copyright (C) 1987-1999 Leon Bottou and Neuristique.
;;; Includes selected parts of SN3.2:
;;;   Copyright (C) 1991-2001 AT&T Corp.
;;;
;;; Includes information derived from the GSL (Gnu Scientific Library)
;;;   header files which are copyrighted and distributed under the GPL
;;;   by their respective authors.
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(libload "alsa/alsa-config")



#? *** rawmidi

;; dummy function that adds Alsa C header files in C file
(eval `(de dummy_rawmidi () ,alsa-cpheader-cmd ()))

#? * (dummy_rawmidi)
#? * (snd_rawmidi_open <inrmidi> <outrmidi> <name> <mode>)
#? * (snd_rawmidi_open_lconf <inrmidi> <outrmidi> <name> <mode> <lconf>)
#? * (snd_rawmidi_close <rmidi>)
#? * (snd_rawmidi_poll_descriptors_count <rmidi>)
#? * (snd_rawmidi_poll_descriptors <rmidi> <pfds> <space>)
#? * (snd_rawmidi_poll_descriptors_revents <rawmidi> <pfds> <nfds> <revent>)
#? * (snd_rawmidi_nonblock <rmidi> <nonblock>)
#? * (snd_rawmidi_info_sizeof)
#? * (snd_rawmidi_info_alloca <s>)
#? * (snd_rawmidi_info_malloc <s>)
#? * (snd_rawmidi_info_free <obj>)
#? * (snd_rawmidi_info_copy <dst> <src>)
#? * (snd_rawmidi_info_get_device <obj>)
#? * (snd_rawmidi_info_get_subdevice <obj>)
#? * (snd_rawmidi_info_get_stream <obj>)
#? * (snd_rawmidi_info_get_card <obj>)
#? * (snd_rawmidi_info_get_flags <obj>)
#? * (snd_rawmidi_info_get_id <obj>)
#? * (snd_rawmidi_info_get_name <obj>)
#? * (snd_rawmidi_info_get_subdevice_name <obj>)
#? * (snd_rawmidi_info_get_subdevices_count <obj>)
#? * (snd_rawmidi_info_get_subdevices_avail <obj>)
#? * (snd_rawmidi_info_set_device <obj> <val>)
#? * (snd_rawmidi_info_set_subdevice <obj> <val>)
#? * (snd_rawmidi_info_set_stream <obj> <val>)
#? * (snd_rawmidi_info <rmidi> <info>)
#? * (snd_rawmidi_params_sizeof)
#? * (snd_rawmidi_params_alloca <s>)
#? * (snd_rawmidi_params_malloc <s>)
#? * (snd_rawmidi_params_free <obj>)
#? * (snd_rawmidi_params_copy <dst> <src>)
#? * (snd_rawmidi_params_set_buffer_size <rmidi> <params> <val>)
#? * (snd_rawmidi_params_get_buffer_size <params>)
#? * (snd_rawmidi_params_set_avail_min <rmidi> <params> <val>)
#? * (snd_rawmidi_params_get_avail_min <params>)
#? * (snd_rawmidi_params_set_no_active_sensing <rmidi> <params> <val>)
#? * (snd_rawmidi_params_get_no_active_sensing <params>)
#? * (snd_rawmidi_params <rmidi> <params>)
#? * (snd_rawmidi_params_current <rmidi> <params>)
#? * (snd_rawmidi_status_sizeof)
#? * (snd_rawmidi_status_alloca <s>)
#? * (snd_rawmidi_status_malloc <s>)
#? * (snd_rawmidi_status_free <obj>)
#? * (snd_rawmidi_status_copy <dst> <src>)
#? * (snd_rawmidi_status_get_tstamp <obj> <s>)
#? * (snd_rawmidi_status_get_avail <obj>)
#? * (snd_rawmidi_status_get_xruns <obj>)
#? * (snd_rawmidi_status <rmidi> <status>)
#? * (snd_rawmidi_drain <rmidi>)
#? * (snd_rawmidi_drop <rmidi>)
#? * (snd_rawmidi_write <rmidi> <buffer> <size>)
#? * (snd_rawmidi_read <rmidi> <buffer> <size>)
#? * (snd_rawmidi_name <rmidi>)
#? * (snd_rawmidi_type <rmidi>)
#? * (snd_rawmidi_stream <rawmidi>)

;; ********************************************************


(setq SND_RAWMIDI_STREAM_OUTPUT                       0)
(setq SND_RAWMIDI_STREAM_INPUT                        1)
(setq SND_RAWMIDI_STREAM_LAST  SND_RAWMIDI_STREAM_INPUT)

(setq SND_RAWMIDI_APPEND	0x0001)
(setq SND_RAWMIDI_NONBLOCK	0x0002)
(setq SND_RAWMIDI_SYNC	        0x0004)


(setq SND_RAWMIDI_TYPE_HW            0)
(setq SND_RAWMIDI_TYPE_SHM           1)
(setq SND_RAWMIDI_TYPE_INET          2)



(de snd_rawmidi_open (   inrmidi  outrmidi  name  mode  )
    ((-gptr- "snd_rawmidi_t **") inrmidi )
    ((-gptr- "snd_rawmidi_t **") outrmidi )
    ((-str-) name )
    ((-int-)  mode  )
    (int #{ snd_rawmidi_open(  $inrmidi  ,$outrmidi  ,$name->data  ,$mode  ) #} )
    )

(de snd_rawmidi_open_lconf (   inrmidi  outrmidi  name  mode  lconf  )
    ((-gptr- "snd_rawmidi_t **") inrmidi )
    ((-gptr- "snd_rawmidi_t **") outrmidi )
    ((-str-) name )
    ((-int-)  mode )
    ((-gptr- "snd_config_t *") lconf  )
    (int #{ snd_rawmidi_open_lconf(  $inrmidi  ,$outrmidi  ,$name->data  ,$mode  ,$lconf  ) #} )
    )

(de snd_rawmidi_close (   rmidi  )
    ((-gptr- "snd_rawmidi_t *") rmidi  )
    (int #{ snd_rawmidi_close(  $rmidi  ) #} )
    )

(de snd_rawmidi_poll_descriptors_count (   rmidi  )
    ((-gptr- "snd_rawmidi_t *") rmidi  )
    (int #{ snd_rawmidi_poll_descriptors_count(  $rmidi  ) #} )
    )

(de snd_rawmidi_poll_descriptors (   rmidi  pfds  space  )
    ((-gptr- "snd_rawmidi_t *") rmidi )
    ((-gptr- "struct pollfd *") pfds )
    ((-int-)  space  )                              ;; unsigned int -> int
    (int #{ snd_rawmidi_poll_descriptors(  $rmidi  ,$pfds  ,$space  ) #} )
    )

(de snd_rawmidi_poll_descriptors_revents (   rawmidi  pfds  nfds  revent  )
    ((-gptr- "snd_rawmidi_t *") rawmidi )
    ((-gptr- "struct pollfd *") pfds )
    ((-int-)  nfds )                                   ;; unsigned int -> int
    ((-gptr- "unsigned short *") revent  )
    (int #{ snd_rawmidi_poll_descriptors_revents(  $rawmidi  ,$pfds  ,$nfds  ,$revent  ) #} )
    )

(de snd_rawmidi_nonblock (   rmidi  nonblock  )
    ((-gptr- "snd_rawmidi_t *") rmidi )
    ((-int-)  nonblock  )
    (int #{ snd_rawmidi_nonblock(  $rmidi  ,$nonblock  ) #} )
    )

(de snd_rawmidi_info_sizeof (  )
    (int #{ snd_rawmidi_info_sizeof( ) #} )                  ;; size_t -> int
    )

(de snd_rawmidi_info_alloca (s) 
    ((-gptr- "snd_rawmidi_info_t **") s)
    #{ snd_rawmidi_info_alloca($s); #}
    ()
    )

(de snd_rawmidi_info_malloc ( s )
    ((-gptr- "snd_rawmidi_info_t **") s )
    (int #{ snd_rawmidi_info_malloc( $s ) #} )
    )

(de snd_rawmidi_info_free (   obj  )
    ((-gptr- "snd_rawmidi_info_t *") obj  )
    #{ snd_rawmidi_info_free(  $obj  ); #} 
    ()
    )

(de snd_rawmidi_info_copy (   dst  src  )
    ((-gptr- "snd_rawmidi_info_t *") dst )
    ((-gptr- "const snd_rawmidi_info_t *") src  )
    #{ snd_rawmidi_info_copy(  $dst  ,$src  ); #} 
    ()
    )

(de snd_rawmidi_info_get_device (   obj  )
    ((-gptr- "const snd_rawmidi_info_t *") obj  )
    (int #{ snd_rawmidi_info_get_device(  $obj  ) #} )         ;; unsigned int -> int
    )

(de snd_rawmidi_info_get_subdevice (   obj  )
    ((-gptr- "const snd_rawmidi_info_t *") obj  )
    (int #{ snd_rawmidi_info_get_subdevice(  $obj  ) #} )    ;; unsigned int -> int
    )

(de snd_rawmidi_info_get_stream (   obj  )
    ((-gptr- "const snd_rawmidi_info_t *") obj  )
    (int #{  snd_rawmidi_info_get_stream(  $obj  ) #} )       ;; snd_rawmidi_stream_t ->int
    )

(de snd_rawmidi_info_get_card (   obj  )
    ((-gptr- "const snd_rawmidi_info_t *") obj  )
    (int #{ snd_rawmidi_info_get_card(  $obj  ) #} )
    )

(de snd_rawmidi_info_get_flags (   obj  )
    ((-gptr- "const snd_rawmidi_info_t *") obj  )
    (int #{ snd_rawmidi_info_get_flags(  $obj  ) #} )          ;; unsigned int -> int
    )

(de snd_rawmidi_info_get_id (   obj  )
    ((-gptr- "const snd_rawmidi_info_t *") obj  )
    (gptr #{ snd_rawmidi_info_get_id(  $obj  ) #} )             ;; const char * -> gptr
)

(de snd_rawmidi_info_get_name (   obj  )
    ((-gptr- "const snd_rawmidi_info_t *") obj  )
    (gptr #{ snd_rawmidi_info_get_name(  $obj  ) #} )           ;; const char * -> gptr
)

(de snd_rawmidi_info_get_subdevice_name (   obj  )
    ((-gptr- "const snd_rawmidi_info_t *") obj  )
    (gptr #{ snd_rawmidi_info_get_subdevice_name(  $obj  ) #} )       ;; const char * -> gptr
)

(de snd_rawmidi_info_get_subdevices_count (   obj  )
    ((-gptr- "const snd_rawmidi_info_t *") obj  )
    (int #{ snd_rawmidi_info_get_subdevices_count(  $obj  ) #} )       ;; unsigned int -> int
    )

(de snd_rawmidi_info_get_subdevices_avail (   obj  )
    ((-gptr- "const snd_rawmidi_info_t *") obj  )
    (int #{ snd_rawmidi_info_get_subdevices_avail(  $obj  ) #} )          ;; unsigned int -> int
    )

(de snd_rawmidi_info_set_device (   obj  val  )
    ((-gptr- "snd_rawmidi_info_t *") obj )
    ((-int-)  val  )                    ;; unsigned int -> int
    #{ snd_rawmidi_info_set_device(  $obj  ,$val  ); #} 
    ()
    )

(de snd_rawmidi_info_set_subdevice (   obj  val  )
    ((-gptr- "snd_rawmidi_info_t *") obj )
    ((-int-)  val  )                            ;; unsigned int -> int
    #{ snd_rawmidi_info_set_subdevice(  $obj  ,$val  ); #} 
    ()
    )

(de snd_rawmidi_info_set_stream (   obj  val  )
    ((-gptr- "snd_rawmidi_info_t *") obj )
    ((-int-)  val  )                                  ;; snd_rawmidi_stream_t -> int
    #{ snd_rawmidi_info_set_stream(  $obj  ,$val  ); #} 
    ()
    )

(de snd_rawmidi_info (   rmidi  info  )
    ((-gptr- "snd_rawmidi_t *") rmidi )
    ((-gptr- "snd_rawmidi_info_t * ") info  )
    (int #{ snd_rawmidi_info(  $rmidi  ,$info  ) #} )
    )

(de snd_rawmidi_params_sizeof (  )
    (int #{ snd_rawmidi_params_sizeof( ) #} )                  ;; size_t -> int
    )

(de snd_rawmidi_params_alloca (s) 
    ((-gptr- "snd_rawmidi_params_t **") s)
    #{ snd_rawmidi_params_alloca($s); #}
    ()
    )

(de snd_rawmidi_params_malloc ( s )
    ((-gptr- "snd_rawmidi_params_t **") s )
    (int #{ snd_rawmidi_params_malloc(  $s ) #} )
    )

(de snd_rawmidi_params_free (   obj  )
    ((-gptr- "snd_rawmidi_params_t *") obj  )
    #{ snd_rawmidi_params_free(  $obj  ); #} 
    ()
    )

(de snd_rawmidi_params_copy (   dst  src  )
    ((-gptr- "snd_rawmidi_params_t *") dst )
    ((-gptr- "const snd_rawmidi_params_t *") src  )
    #{ snd_rawmidi_params_copy(  $dst  ,$src  ); #} 
    ()
    )

(de snd_rawmidi_params_set_buffer_size (   rmidi  params  val  )
    ((-gptr- "snd_rawmidi_t *") rmidi )
    ((-gptr- "snd_rawmidi_params_t *") params )
    ((-int-) val )                   ;; size_t -> int
    (int #{ snd_rawmidi_params_set_buffer_size(  $rmidi  ,$params  ,$val  ) #} )
    )

(de snd_rawmidi_params_get_buffer_size (   params  )
    ((-gptr- "const snd_rawmidi_params_t *") params  )
    (int #{ snd_rawmidi_params_get_buffer_size(  $params  ) #} )                  ;; size_t -> int
    )

(de snd_rawmidi_params_set_avail_min (   rmidi  params  val  )
    ((-gptr- "snd_rawmidi_t *") rmidi )
    ((-gptr- "snd_rawmidi_params_t *") params )
    ((-int-) val )                   ;; size_t -> int
    (int #{ snd_rawmidi_params_set_avail_min(  $rmidi  ,$params  ,$val  ) #} )
    )

(de snd_rawmidi_params_get_avail_min (   params  )
    ((-gptr- "const snd_rawmidi_params_t *") params  )
    (int #{ snd_rawmidi_params_get_avail_min(  $params  ) #} )                  ;; size_t -> int
    )

(de snd_rawmidi_params_set_no_active_sensing (   rmidi  params  val  )
    ((-gptr- "snd_rawmidi_t *") rmidi )
    ((-gptr- "snd_rawmidi_params_t *") params )
    ((-int-)  val  )
    (int #{ snd_rawmidi_params_set_no_active_sensing(  $rmidi  ,$params  ,$val  ) #} )
    )

(de snd_rawmidi_params_get_no_active_sensing (   params  )
    ((-gptr- "const snd_rawmidi_params_t *") params  )
    (int #{ snd_rawmidi_params_get_no_active_sensing(  $params  ) #} )
    )

(de snd_rawmidi_params (   rmidi  params  )
    ((-gptr- "snd_rawmidi_t *") rmidi )
    ((-gptr- "snd_rawmidi_params_t * ") params  )
    (int #{ snd_rawmidi_params(  $rmidi  ,$params  ) #} )
    )

(de snd_rawmidi_params_current (   rmidi  params  )
    ((-gptr- "snd_rawmidi_t *") rmidi )
    ((-gptr- "snd_rawmidi_params_t *") params  )
    (int #{ snd_rawmidi_params_current(  $rmidi  ,$params  ) #} )
    )

(de snd_rawmidi_status_sizeof (  )
    (int #{ snd_rawmidi_status_sizeof(  ) #} )                  ;; size_t -> int
    )

(de  snd_rawmidi_status_alloca (s)
    ((-gptr- "snd_rawmidi_status_t **") s)
    #{ snd_rawmidi_status_alloca($s); #}
    ()
    )

(de snd_rawmidi_status_malloc ( s )
    ((-gptr- "snd_rawmidi_status_t **") s )
    (int #{ snd_rawmidi_status_malloc(  $s ) #} )
    )

(de snd_rawmidi_status_free (   obj  )
    ((-gptr- "snd_rawmidi_status_t *") obj  )
    #{ snd_rawmidi_status_free(  $obj  ); #} 
    ()
    )

(de snd_rawmidi_status_copy (   dst  src  )
    ((-gptr- "snd_rawmidi_status_t *") dst )
    ((-gptr- "const snd_rawmidi_status_t *") src  )
    #{ snd_rawmidi_status_copy(  $dst  ,$src  ); #} 
    ()
    )

(de snd_rawmidi_status_get_tstamp (   obj  s  )
    ((-gptr- "const snd_rawmidi_status_t *") obj )
    ((-gptr- "snd_timestamp_t *") s )
    #{ snd_rawmidi_status_get_tstamp(  $obj  ,$s ); #} 
    ()
    )

(de snd_rawmidi_status_get_avail (   obj  )
    ((-gptr- "const snd_rawmidi_status_t *") obj  )
    (int #{ snd_rawmidi_status_get_avail(  $obj  ) #} )                  ;; size_t -> int
    )

(de snd_rawmidi_status_get_xruns (   obj  )
    ((-gptr- "const snd_rawmidi_status_t *") obj  )
    (int #{ snd_rawmidi_status_get_xruns(  $obj  ) #} )                  ;; size_t -> int
    )

(de snd_rawmidi_status (   rmidi  status  )
    ((-gptr- "snd_rawmidi_t *") rmidi )
    ((-gptr- "snd_rawmidi_status_t * ") status  )
    (int #{ snd_rawmidi_status(  $rmidi  ,$status  ) #} )
    )

(de snd_rawmidi_drain (   rmidi  )
    ((-gptr- "snd_rawmidi_t *") rmidi  )
    (int #{ snd_rawmidi_drain(  $rmidi  ) #} )
    )

(de snd_rawmidi_drop (   rmidi  )
    ((-gptr- "snd_rawmidi_t *") rmidi  )
    (int #{ snd_rawmidi_drop(  $rmidi  ) #} )
    )

(de snd_rawmidi_write (   rmidi  buffer  size  )
    ((-gptr- "snd_rawmidi_t *") rmidi )
    ((-gptr-) buffer )
    ((-int-) size )                   ;; size_t -> int
    (int #{ snd_rawmidi_write(  $rmidi  ,$buffer  ,$size  ) #} )                  ;; ssize_t -> int
    )

(de snd_rawmidi_read (   rmidi  buffer  size  )
    ((-gptr- "snd_rawmidi_t *") rmidi )
    ((-gptr-) buffer )
    ((-int-) size )                   ;; size_t -> int
    (int #{ snd_rawmidi_read(  $rmidi  ,$buffer  ,$size  ) #} )                  ;; ssize_t -> int
    )

(de snd_rawmidi_name (   rmidi  )
    ((-gptr- "snd_rawmidi_t *") rmidi  )
    (gptr #{ snd_rawmidi_name(  $rmidi  ) #} )           ;; const char * -> gptr
    )

(de snd_rawmidi_type (   rmidi  )
    ((-gptr- "snd_rawmidi_t *") rmidi  )
    (int #{  snd_rawmidi_type(  $rmidi  ) #} )              ;; snd_rawmidi_type_t -> int
    )

(de snd_rawmidi_stream (   rawmidi  )
    ((-gptr- "snd_rawmidi_t *") rawmidi  )
    (int #{  snd_rawmidi_stream(  $rawmidi  ) #} )        ;; snd_rawmidi_stream_t -> int
    )


;; ********************************************************

(dhc-make ()
  dummy_rawmidi
  snd_rawmidi_open
  snd_rawmidi_open_lconf
  snd_rawmidi_close
  snd_rawmidi_poll_descriptors_count
  snd_rawmidi_poll_descriptors
  snd_rawmidi_poll_descriptors_revents
  snd_rawmidi_nonblock
  snd_rawmidi_info_sizeof
  snd_rawmidi_info_alloca
  snd_rawmidi_info_malloc
  snd_rawmidi_info_free
  snd_rawmidi_info_copy
  snd_rawmidi_info_get_device
  snd_rawmidi_info_get_subdevice
  snd_rawmidi_info_get_stream
  snd_rawmidi_info_get_card
  snd_rawmidi_info_get_flags
  snd_rawmidi_info_get_id
  snd_rawmidi_info_get_name
  snd_rawmidi_info_get_subdevice_name
  snd_rawmidi_info_get_subdevices_count
  snd_rawmidi_info_get_subdevices_avail
  snd_rawmidi_info_set_device
  snd_rawmidi_info_set_subdevice
  snd_rawmidi_info_set_stream
  snd_rawmidi_info
  snd_rawmidi_params_sizeof
  snd_rawmidi_params_alloca
  snd_rawmidi_params_malloc
  snd_rawmidi_params_free
  snd_rawmidi_params_copy
  snd_rawmidi_params_set_buffer_size
  snd_rawmidi_params_get_buffer_size
  snd_rawmidi_params_set_avail_min
  snd_rawmidi_params_get_avail_min
  snd_rawmidi_params_set_no_active_sensing
  snd_rawmidi_params_get_no_active_sensing
  snd_rawmidi_params
  snd_rawmidi_params_current
  snd_rawmidi_status_sizeof
  snd_rawmidi_status_alloca
  snd_rawmidi_status_malloc
  snd_rawmidi_status_free
  snd_rawmidi_status_copy
  snd_rawmidi_status_get_tstamp
  snd_rawmidi_status_get_avail
  snd_rawmidi_status_get_xruns
  snd_rawmidi_status
  snd_rawmidi_drain
  snd_rawmidi_drop
  snd_rawmidi_write
  snd_rawmidi_read
  snd_rawmidi_name
  snd_rawmidi_type
  snd_rawmidi_stream
)
