;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; 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 "htk/htk-config")



#? *** esignal

;; dummy function that adds HTK C header files in C file
(eval `(de dummy_esignal () ,htk-cpheader-cmd ()))

#? * (dummy_esignal)
#? * (strdup <str>)
#? * (longprod <n> <arr>)
#? * (debugprint <msg>)
#? * (validtype <type>)
#? * (typename <type>)
#? * (typecode <name>)
#? * (interntypesize <type>)
#? * (externtypesize <type> <arch>)
#? * (newfieldspec <type> <rank>)
#? * (freefieldspec <spec>)
#? * (freefieldlist <list>)
#? * (freeaxisnames <axis_names> <rank>)
#? * (fieldlength <field>)
#? * (fieldlistlength <list>)
#? * (findfield <list> <name>)
#? * (addfield <list> <field>)
#? * (addsubfield <field> <subfield>)
#? * (fieldorder <list>)
#? * (typeorder <list>)
#? * (getfieldordering <list> <order>)
#? * (setfieldordering <list> <order>)
#? * (readpreamble <version> <arch> <pre_size> <hdr_size> <rec_size> <file>)
#? * (readfieldlist <list> <arch> <file>)
#? * (readheader <version> <arch> <pre_size> <hdr_size> <rec_size> <file>)
#? * (openin <filename> <version> <arch> <pre_size> <hdr_size> <rec_size> <file>)
#? * (writepreamble <arch> <fld_size> <rec_size> <file>)
#? * (writefieldlist <list> <arch> <file> <annotate>)
#? * (writeheader <list> <arch> <file> <annotate>)
#? * (openout <filename> <list> <arch> <file> <annotate>)
#? * (recordsize <list> <arch>)
#? * (readrecord <fields> <arch> <file>)
#? * (writerecord <fields> <arch> <file> <annotate>)
#? * (readsamples <data> <nrec> <fields> <arch> <file>)
#? * (writesamples <data> <nrec> <fields> <arch> <file> <annotate>)
#? * (allocsamples <nrec> <fields>)
#? * (nativetypesize <type>)
#? * (readnativefieldlist <list> <file>)
#? * (writenativefieldlist <list> <file>)
#? * (nativerecordsize <list>)
#? * (readnativerecord <fields> <file>)
#? * (writenativerecord <fields> <file>)
#? * (readnativesamples <data> <nrec> <fields> <file>)
#? * (writenativesamples <data> <nrec> <fields> <file>)
#? * (edrtypesize <type> <longlong>)
#? * (readedrfieldlist <list> <file> <longlong>)
#? * (writeedrfieldlist <list> <file> <longlong>)
#? * (edrrecordsize <list> <longlong>)
#? * (readedrrecord <fields> <file> <longlong>)
#? * (writeedrrecord <fields> <file> <longlong>)
#? * (readedrsamples <data> <nrec> <fields> <file> <longlong>)
#? * (writeedrsamples <data> <nrec> <fields> <file> <longlong>)
#? * (readasciifieldlist <list> <file>)
#? * (writeasciifieldlist <list> <file> <annotate>)
#? * (readasciirecord <fields> <file>)
#? * (writeasciirecord <fields> <file> <annotate>)
#? * (readasciisamples <data> <nrec> <fields> <file>)
#? * (writeasciisamples <data> <nrec> <fields> <file> <annotate>)

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


(de StrDup (  str )
    ((-gptr- "char *") str)  
    (gptr #{ StrDup(  $str  )  #} )            ;; char  *   -> gptr
    )

(de LongProd (  n  arr )
    ((-int-) n) 
    ((-gptr- "long *") arr)  
    (int     #{ LongProd(  $n   ,$arr  )  #} )        ;; long -> int
    )


(de DebugPrint (  msg )
    ((-gptr- "char *") msg)  
    #{ DebugPrint(  $msg  );  #} 
    ()
    )


(de ValidType (  type )
    ((-int-) type)  
    (int    #{ ValidType(  $type  )  #} )
)


(de TypeName (  type )
    ((-int-) type)  
    (gptr #{ TypeName(  $type  )  #} )            ;; char *   -> gptr
)


(de TypeCode (  name )
    ((-gptr- "char *") name)  
    (int   #{ TypeCode(  $name  )  #} )
)


(de InternTypeSize (  type )
    ((-int-) type)  
    (int    #{ InternTypeSize(  $type  )  #} )        ;; long -> int
)


(de ExternTypeSize (  type  arch )
    ((-int-) type) 
    ((-int-) arch)  
    (int     #{ ExternTypeSize(  $type   ,$arch  )  #} )        ;; long -> int
)


(de NewFieldSpec (  type  rank )
    ((-int-) type) 
    ((-int-) rank)  
    (gptr #{ NewFieldSpec(  $type   ,$rank  )  #} )            ;; FieldSpec   *   -> gptr
)


(de FreeFieldSpec (  spec )
    ((-gptr- "FieldSpec *") spec)  
    #{ FreeFieldSpec(  $spec  );  #} 
    ()
)


(de FreeFieldList (  list )
    ((-gptr- "FieldSpec **") list)  
    #{ FreeFieldList(  $list  );  #} 
    ()
)


(de FreeAxisNames (  axis_names  rank )
    ((-gptr- "char **") axis_names) 
    ((-int-) rank)  
    #{ FreeAxisNames(  $axis_names   ,$rank  );  #} 
    ()
)


(de FieldLength (  field )
    ((-gptr- "FieldSpec *") field)  
    (int	      #{ FieldLength(  $field  )  #} )        ;; long -> int
)


(de FieldListLength (  list )
    ((-gptr- "FieldSpec **") list)  
    (int	      #{ FieldListLength(  $list  )  #} )
)


(de FindField (  list  name )
    ((-gptr- "FieldSpec **") list) 
    ((-gptr- "char *") name)  
    (gptr #{ FindField(  $list   ,$name  )  #} )            ;; FieldSpec   *   -> gptr
)


(de AddField (  list  field )
    ((-gptr- "FieldSpec ***") list) 
    ((-gptr- "FieldSpec *") field)  
    (int	      #{ AddField(  $list   ,$field  )  #} )
)


(de AddSubfield (  field  subfield )
    ((-gptr- "FieldSpec *") field) 
    ((-gptr- "FieldSpec *") subfield)  
    (int	      #{ AddSubfield(  $field   ,$subfield  )  #} )
)


(de FieldOrder (  list )
    ((-gptr- "FieldSpec **") list)  
    (gptr #{ FieldOrder(  $list  )  #} )            ;; FieldSpec   **   -> gptr
)


(de TypeOrder (  list )
    ((-gptr- "FieldSpec **") list)  
    (gptr #{ TypeOrder(  $list  )  #} )            ;; FieldSpec   **   -> gptr
)


(de GetFieldOrdering (  list  order )
    ((-gptr- "FieldSpec **") list) 
    ((-gptr- "int *") order)  
    (int      #{ GetFieldOrdering(  $list   ,$order  )  #} )
)


(de SetFieldOrdering (  list  order )
    ((-gptr- "FieldSpec ***") list) 
    ((-int-) order)  
    (int      #{ SetFieldOrdering(  $list   ,$order  )  #} )
)


(de ReadPreamble (  version  arch  pre_size  hdr_size  rec_size  file )
    ((-gptr- "char **") version) 
    ((-gptr- "char **") arch) 
    ((-gptr- "long *") pre_size) 
    ((-gptr- "long *") hdr_size) 
    ((-gptr- "long *") rec_size) 
    ((-gptr- "FILE *") file)  
    (int      #{ ReadPreamble(  $version   ,$arch   ,$pre_size   ,$hdr_size   ,$rec_size   ,$file  )  #} )
)


(de ReadFieldList (  list  arch  file )
    ((-gptr- "FieldSpec ***") list) 
    ((-int-) arch) 
    ((-gptr- "FILE *") file)  
    (int      #{ ReadFieldList(  $list   ,$arch   ,$file  )  #} )
)


(de ReadHeader (  version  arch  pre_size  hdr_size  rec_size  file )
    ((-gptr- "char **") version) 
    ((-gptr- "int *") arch) 
    ((-gptr- "long *") pre_size) 
    ((-gptr- "long *") hdr_size) 
    ((-gptr- "long *") rec_size) 
    ((-gptr- "FILE *") file)  
    (gptr     #{ ReadHeader(  $version   ,$arch   ,$pre_size   ,$hdr_size   ,$rec_size   ,$file  )  #} )  ;;; FieldList (FieldSpec **) -> gptr
)


(de OpenIn (  filename  version  arch  pre_size  hdr_size  rec_size  file )
    ((-gptr- "char *") filename) 
    ((-gptr- "char **") version) 
    ((-gptr- "int *") arch) 
    ((-gptr- "long *") pre_size) 
    ((-gptr- "long *") hdr_size) 
    ((-gptr- "long *") rec_size) 
    ((-gptr- "FILE **") file)  
    (gptr     #{ OpenIn(  $filename   ,$version   ,$arch   ,$pre_size   ,$hdr_size   ,$rec_size   ,$file  )  #} )  ;;; FieldList (FieldSpec **) -> gptr
)


(de WritePreamble (  arch  fld_size  rec_size  file )
    ((-gptr- "char *") arch) 
    ((-int-) fld_size)                   ;; long -> int
    ((-int-) rec_size)                   ;; long -> int
    ((-gptr- "FILE *") file)  
    (int      #{ WritePreamble(  $arch   ,$fld_size   ,$rec_size   ,$file  )  #} )
)


(de WriteFieldList (  list  arch  file  annotate )
    ((-gptr- "FieldSpec **") list) 
    ((-int-) arch) 
    ((-gptr- "FILE *") file) 
    ((-gptr- "Annot *") annotate)  
    (int      #{ WriteFieldList(  $list   ,$arch   ,$file   ,$annotate  )  #} )
)


(de WriteHeader (  list  arch  file  annotate )
    ((-gptr- "FieldSpec **") list) 
    ((-int-) arch) 
    ((-gptr- "FILE *") file) 
    ((-gptr- "Annot *") annotate)  
    (int      #{ WriteHeader(  $list   ,$arch   ,$file   ,$annotate  )  #} )
)


(de OpenOut (  filename  list  arch  file  annotate )
    ((-gptr- "char *") filename) 
    ((-gptr- "FieldSpec **") list) 
    ((-int-) arch) 
    ((-gptr- "FILE **") file) 
    ((-gptr- "Annot *") annotate)  
    (int      #{ OpenOut(  $filename   ,$list   ,$arch   ,$file   ,$annotate  )  #} )
)


(de RecordSize (  list  arch )
    ((-gptr- "FieldSpec **") list) 
    ((-int-) arch)  
    (int      #{ RecordSize(  $list   ,$arch  )  #} )        ;; long -> int
)


(de ReadRecord (  fields  arch  file )
    ((-gptr- "FieldSpec **") fields) 
    ((-int-) arch) 
    ((-gptr- "FILE *") file)  
    (int      #{ ReadRecord(  $fields   ,$arch   ,$file  )  #} )
)


(de WriteRecord (  fields  arch  file  annotate )
    ((-gptr- "FieldSpec **") fields) 
    ((-int-) arch) 
    ((-gptr- "FILE *") file) 
    ((-gptr- "Annot *") annotate)  
    (int      #{ WriteRecord(  $fields   ,$arch   ,$file   ,$annotate  )  #} )
)


(de ReadSamples (  data  nrec  fields  arch  file )
    ((-gptr- "void *") data) 
    ((-int-) nrec)                   ;; long -> int
    ((-gptr- "FieldSpec **") fields) 
    ((-int-) arch) 
    ((-gptr- "FILE *") file)  
    (int      #{ ReadSamples(  $data   ,$nrec   ,$fields   ,$arch   ,$file  )  #} )        ;; long -> int
)


(de WriteSamples (  data  nrec  fields  arch  file  annotate )
    ((-gptr- "void *") data) 
    ((-int-) nrec)                   ;; long -> int
    ((-gptr- "FieldSpec **") fields) 
    ((-int-) arch) 
    ((-gptr- "FILE *") file) 
    ((-gptr- "Annot *") annotate)  
    (int      #{ WriteSamples(  $data   ,$nrec   ,$fields   ,$arch   ,$file   ,$annotate  )  #} )        ;; long -> int
)


(de AllocSamples (  nrec  fields )
    ((-int-) nrec)                   ;; long -> int
    ((-gptr- "FieldSpec **") fields)  
    (gptr  #{ AllocSamples(  $nrec   ,$fields  )  #} )
)


(de NativeTypeSize (  type )
    ((-int-) type)  
    (int     #{ NativeTypeSize(  $type  )  #} )        ;; long -> int
)


(de ReadNativeFieldList (  list  file )
    ((-gptr- "FieldSpec ***") list) 
    ((-gptr- "FILE *") file)  
    (int     #{ ReadNativeFieldList(  $list   ,$file  )  #} )
)


(de WriteNativeFieldList (  list  file )
    ((-gptr- "FieldSpec **") list) 
    ((-gptr- "FILE *") file)  
    (int     #{ WriteNativeFieldList(  $list   ,$file  )  #} )
)


(de NativeRecordSize (  list )
    ((-gptr- "FieldSpec **") list)  
    (int	      #{ NativeRecordSize(  $list  )  #} )        ;; long -> int
)


(de ReadNativeRecord (  fields  file )
    ((-gptr- "FieldSpec **") fields) 
    ((-gptr- "FILE *") file)  
    (int	      #{ ReadNativeRecord(  $fields   ,$file  )  #} )
)


(de WriteNativeRecord (  fields  file )
    ((-gptr- "FieldSpec **") fields) 
    ((-gptr- "FILE *") file)  
    (int	      #{ WriteNativeRecord(  $fields   ,$file  )  #} )
)


(de ReadNativeSamples (  data  nrec  fields  file )
    ((-gptr- "void *") data) 
    ((-int-) nrec)                   ;; long -> int
    ((-gptr- "FieldSpec **") fields) 
    ((-gptr- "FILE *") file)  
    (int          #{ ReadNativeSamples(  $data   ,$nrec   ,$fields   ,$file  )  #} )        ;; long -> int
)


(de WriteNativeSamples (  data  nrec  fields  file )
    ((-gptr- "void *") data) 
    ((-int-) nrec)                   ;; long -> int
    ((-gptr- "FieldSpec **") fields) 
    ((-gptr- "FILE *") file)  
    (int          #{ WriteNativeSamples(  $data   ,$nrec   ,$fields   ,$file  )  #} )        ;; long -> int
)


(de EdrTypeSize (  type  longlong )
    ((-int-) type) 
    ((-int-) longlong)  
    (int	      #{ EdrTypeSize(  $type   ,$longlong  )  #} )        ;; long -> int
)


(de ReadEdrFieldList (  list  file  longlong )
    ((-gptr- "FieldSpec ***") list) 
    ((-gptr- "FILE *") file) 
    ((-int-) longlong)  
    (int	      #{ ReadEdrFieldList(  $list   ,$file   ,$longlong  )  #} )
)


(de WriteEdrFieldList (  list  file  longlong )
    ((-gptr- "FieldSpec **") list) 
    ((-gptr- "FILE *") file) 
    ((-int-) longlong)  
    (int	      #{ WriteEdrFieldList(  $list   ,$file   ,$longlong  )  #} )
)


(de EdrRecordSize (  list  longlong )
    ((-gptr- "FieldSpec **") list) 
    ((-int-) longlong)  
    (int	      #{ EdrRecordSize(  $list   ,$longlong  )  #} )        ;; long -> int
)


(de ReadEdrRecord (  fields  file  longlong )
    ((-gptr- "FieldSpec **") fields) 
    ((-gptr- "FILE *") file) 
    ((-int-) longlong)  
    (int	      #{ ReadEdrRecord(  $fields   ,$file   ,$longlong  )  #} )
)


(de WriteEdrRecord (  fields  file  longlong )
    ((-gptr- "FieldSpec **") fields) 
    ((-gptr- "FILE *") file) 
    ((-int-) longlong)  
    (int	      #{ WriteEdrRecord(  $fields   ,$file   ,$longlong  )  #} )
)


(de ReadEdrSamples (  data  nrec  fields  file  longlong )
    ((-gptr- "void *") data) 
    ((-int-) nrec)                   ;; long -> int
    ((-gptr- "FieldSpec **") fields) 
    ((-gptr- "FILE *") file) 
    ((-int-) longlong)  
    (int          #{ ReadEdrSamples(  $data   ,$nrec   ,$fields   ,$file   ,$longlong  )  #} )        ;; long -> int
)


(de WriteEdrSamples (  data  nrec  fields  file  longlong )
    ((-gptr- "void *") data) 
    ((-int-) nrec)                   ;; long -> int
    ((-gptr- "FieldSpec **") fields) 
    ((-gptr- "FILE *") file) 
    ((-int-) longlong)  
    (int          #{ WriteEdrSamples(  $data   ,$nrec   ,$fields   ,$file   ,$longlong  )  #} )        ;; long -> int
)


(de ReadAsciiFieldList (  list  file )
    ((-gptr- "FieldSpec ***") list) 
    ((-gptr- "FILE *") file)  
    (int	      #{ ReadAsciiFieldList(  $list   ,$file  )  #} )
)


(de WriteAsciiFieldList (  list  file  annotate )
    ((-gptr- "FieldSpec **") list) 
    ((-gptr- "FILE *") file) 
    ((-gptr- "Annot *") annotate)  
    (int	      #{ WriteAsciiFieldList(  $list   ,$file   ,$annotate  )  #} )
)


(de ReadAsciiRecord (  fields  file )
    ((-gptr- "FieldSpec **") fields) 
    ((-gptr- "FILE *") file)  
    (int	      #{ ReadAsciiRecord(  $fields   ,$file  )  #} )
)


(de WriteAsciiRecord (  fields  file  annotate )
    ((-gptr- "FieldSpec **") fields) 
    ((-gptr- "FILE *") file) 
    ((-gptr- "Annot *") annotate)  
    (int	      #{ WriteAsciiRecord(  $fields   ,$file   ,$annotate  )  #} )
)




(de ReadAsciiSamples (  data  nrec  fields  file )
    ((-gptr- "void *") data) 
    ((-int-) nrec)                   ;; long -> int
    ((-gptr- "FieldSpec **") fields) 
    ((-gptr- "FILE *") file)  
    (int          #{ ReadAsciiSamples(  $data   ,$nrec   ,$fields   ,$file  )  #} )        ;; long -> int
)


(de WriteAsciiSamples (  data  nrec  fields  file  annotate )
    ((-gptr- "void *") data) 
    ((-int-) nrec)                   ;; long -> int
    ((-gptr- "FieldSpec **") fields) 
    ((-gptr- "FILE *") file) 
    ((-gptr- "Annot *") annotate)  
    (int          #{ WriteAsciiSamples(  $data   ,$nrec   ,$fields   ,$file   ,$annotate  )  #} )        ;; long -> int
)

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

(dhc-make-with-libs () (list htk-libhtk)
  dummy_esignal
  strdup
  longprod
  debugprint
  validtype
  typename
  typecode
  interntypesize
  externtypesize
  newfieldspec
  freefieldspec
  freefieldlist
  freeaxisnames
  fieldlength
  fieldlistlength
  findfield
  addfield
  addsubfield
  fieldorder
  typeorder
  getfieldordering
  setfieldordering
  readpreamble
  readfieldlist
  readheader
  openin
  writepreamble
  writefieldlist
  writeheader
  openout
  recordsize
  readrecord
  writerecord
  readsamples
  writesamples
  allocsamples
  nativetypesize
  readnativefieldlist
  writenativefieldlist
  nativerecordsize
  readnativerecord
  writenativerecord
  readnativesamples
  writenativesamples
  edrtypesize
  readedrfieldlist
  writeedrfieldlist
  edrrecordsize
  readedrrecord
  writeedrrecord
  readedrsamples
  writeedrsamples
  readasciifieldlist
  writeasciifieldlist
  readasciirecord
  writeasciirecord
  readasciisamples
  writeasciisamples
)
