;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; 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")



#? *** htk_parm

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

#? * (dummy_htk_parm)
#? * (initparm)
#? * (setchannel <channame>)
#? * (resetchannelsession <channame>)
#? * (setnewconfig <libmod>)
#? * (resetcurcepmean)
#? * (openbuffer <x> <fn> <maxobs> <ff> <enspeechdet> <silmeasure>)
#? * (bufferstatus <pbuf>)
#? * (obsinbuffer <pbuf>)
#? * (startbuffer <pbuf>)
#? * (stopbuffer <pbuf>)
#? * (closebuffer <pbuf>)
#? * (readasbuffer <pbuf> <o>)
#? * (readastable <pbuf> <index> <o>)
#? * (getbufferinfo <pbuf> <info>)
#? * (emptybuffer <x> <size> <o> <info>)
#? * (savebuffer <pbuf> <fname> <ff>)
#? * (addtobuffer <pbuf> <o>)
#? * (makeobservation <x> <swidth> <pkind> <forcedisc> <esep> <result>)
#? * (explainobservation <o> <itemsperline>)
#? * (printobservation <i> <o> <itemsperline>)
#? * (zerostreamwidths <nums> <swidth>)
#? * (setstreamwidths <pk> <size> <swidth> <esep>)
#? * (parmkind2str <kind> <buf>)
#? * (str2parmkind <str>)
#? * (baseparmkind <kind>)
#? * (hasenergy <kind>)
#? * (hasdelta <kind>)
#? * (hasnulle <kind>)
#? * (hasaccs <kind>)
#? * (hascompx <kind>)
#? * (hascrcc <kind>)
#? * (haszerom <kind>)
#? * (haszeroc <kind>)
#? * (hasvq <kind>)
#? * (validconversion <src> <tgt>)

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


(de InitParm (  )
    (int   #{ InitParm(  )  #} )       ;; ReturnStatus -> int
)


(de SetChannel (  channame )
    ((-gptr- "char *") channame)  
    (int   #{ SetChannel(  $channame  )  #} )       ;; ReturnStatus -> int
)


(de ResetChannelSession (  channame )
    ((-gptr- "char *") channame)  
    #{ ResetChannelSession(  $channame  );  #} 
    ()
)


(de SetNewConfig (  libmod )
    ((-gptr- "char *") libmod)  
    #{ SetNewConfig(  $libmod  );  #} 
    ()
)


(de ResetCurCepMean (  )
    #{ ResetCurCepMean(  );  #} 
    ()
)


(de OpenBuffer (  x  fn  maxobs  ff  enspeechdet  silmeasure )
    ((-gptr- "MemHeap *") x) 
    ((-gptr- "char *") fn) 
    ((-int-) maxobs) 
    ((-int-) ff)                 ;; FileFormat (enum) -> int
    ((-int-) enspeechdet)       ;; TriState (enum ) -> int
    ((-int-) silmeasure)        ;; TriState (enum ) -> int
    (gptr   #{ OpenBuffer(  $x   ,$fn   ,$maxobs   ,$ff   ,$enspeechdet   ,$silmeasure  )  #} )      ;; ParmBuf -> gptr
)


(de BufferStatus (  pbuf )
    ((-gptr- "struct _ParmBuf *") pbuf)  
    (int   #{ BufferStatus(  $pbuf  )  #} )                ;; PBStatus -> int
)


(de ObsInBuffer (  pbuf )
    ((-gptr- "struct _ParmBuf *") pbuf)  
    (int   #{ ObsInBuffer(  $pbuf  )  #} )
)


(de StartBuffer (  pbuf )
    ((-gptr- "struct _ParmBuf *") pbuf)  
    #{ StartBuffer(  $pbuf  );  #} 
    ()
)


(de StopBuffer (  pbuf )
    ((-gptr- "struct _ParmBuf *") pbuf)  
    #{ StopBuffer(  $pbuf  );  #} 
    ()
)


(de CloseBuffer (  pbuf )
    ((-gptr- "struct _ParmBuf *") pbuf)  
    #{ CloseBuffer(  $pbuf  );  #} 
    ()
)


(de ReadAsBuffer (  pbuf  o )
    ((-gptr- "struct _ParmBuf *") pbuf) 
    ((-gptr- "Observation *") o)  
    (int   #{ ReadAsBuffer(  $pbuf   ,$o  )  #} )
)


(de ReadAsTable ( pbuf  index  o )
    ((-gptr- "struct _ParmBuf *") pbuf) 
    ((-int-) index) 
    ((-gptr- "Observation *") o)  
    #{ ReadAsTable (  $pbuf   ,$index   ,$o  );  #} 
    ()
)


(de GetBufferInfo (  pbuf  info )
    ((-gptr- "struct _ParmBuf *") pbuf) 
    ((-gptr- "BufferInfo *") info)  
    #{ GetBufferInfo(  $pbuf   ,$info  );  #} 
    ()
)


(de EmptyBuffer (  x  size  o  info )
    ((-gptr- "MemHeap *") x) 
    ((-int-) size) 
    ((-gptr- "Observation *") o)                            ;; struct -> pointer
    ((-gptr- "BufferInfo *") info)                         ;; struct -> pointer
    (gptr   #{ EmptyBuffer(  $x   ,$size   ,*$o   ,*$info  )  #} )         ;; ParmBuf -> gptr
)


(de SaveBuffer (  pbuf  fname  ff )
    ((-gptr- "struct _ParmBuf *") pbuf) 
    ((-gptr- "char *") fname) 
    ((-int-) ff)                  ;; FileFormat (enum) -> int
    (int   #{ SaveBuffer(  $pbuf   ,$fname   ,$ff  )  #} )       ;; ReturnStatus -> int
)


(de AddToBuffer (  pbuf  o )
    ((-gptr- "struct _ParmBuf *") pbuf) 
    ((-gptr- "Observation *") o)                ;; struct -> pointer
    #{ AddToBuffer(  $pbuf   ,*$o  );  #} 
    ()
)


(de MakeObservation (  x  swidth  pkind  forcedisc  esep  result)
    ((-gptr- "MemHeap *") x) 
    ((-gptr- "short *") swidth) 
    ((-int-) pkind)                       ;; ParmKind (short ) -> int
    ((-int-) forcedisc) 
    ((-int-) esep)  
    ((-gptr- "Observation *") result)                             ;; return struct -> pointer
    #{ { 
    Observation tmp;
    tmp = MakeObservation(  $x   ,$swidth   ,$pkind   ,$forcedisc   ,$esep  );
    memcpy($result, &tmp, sizeof(Observation));
    } #}
    ()
)


(de ExplainObservation (  o  itemsperline )
    ((-gptr- "Observation *") o) 
    ((-int-) itemsperline)  
    #{ ExplainObservation(  $o   ,$itemsperline  );  #} 
    ()
)


(de PrintObservation (  i  o  itemsperline )
    ((-int-) i) 
    ((-gptr- "Observation *") o) 
    ((-int-) itemsperline)  
    #{ PrintObservation(  $i   ,$o   ,$itemsperline  );  #} 
    ()
)


(de ZeroStreamWidths (  nums  swidth )
    ((-int-) nums) 
    ((-gptr- "short *") swidth)  
    #{ ZeroStreamWidths(  $nums   ,$swidth  );  #} 
    ()
)


(de SetStreamWidths (  pk  size  swidth  esep )
    ((-int-) pk)                       ;; ParmKind (short ) -> int
    ((-int-) size) 
    ((-gptr- "short *") swidth) 
    ((-gptr- "Boolean *") esep)  
    #{ SetStreamWidths(  $pk   ,$size   ,$swidth   ,$esep  );  #} 
    ()
)


(de ParmKind2Str (  kind  buf )
    ((-int-) kind)                       ;; ParmKind (short ) -> int
    ((-gptr- "char *") buf)  
    (gptr #{ ParmKind2Str(  $kind   ,$buf  )  #} )            ;; char *   -> gptr
)


(de Str2ParmKind (  str )
    ((-gptr- "char *") str)  
    (int   #{ Str2ParmKind(  $str  )  #} )                 ;; ParmKind (short ) -> int
)


(de BaseParmKind (  kind )
    ((-int-) kind)                        ;; ParmKind (short ) -> int
    (int   #{ BaseParmKind(  $kind  )  #} )                  ;; ParmKind (short) -> int
)


(de HasEnergy (  kind )
    ((-int-) kind)                        ;; ParmKind (short ) -> int
    (int   #{ HasEnergy(  $kind  )  #} )
)


(de HasDelta (  kind )
    ((-int-) kind)                        ;; ParmKind (short ) -> int
    (int   #{ HasDelta(  $kind  )  #} )
)


(de HasNulle (  kind )
    ((-int-) kind)                        ;; ParmKind (short ) -> int
    (int   #{ HasNulle(  $kind  )  #} )
)


(de HasAccs (  kind )
    ((-int-) kind)                        ;; ParmKind (short ) -> int
    (int   #{ HasAccs(  $kind  )  #} )
)


(de HasCompx (  kind )
    ((-int-) kind)                        ;; ParmKind (short ) -> int
    (int   #{ HasCompx(  $kind  )  #} )
)


(de HasCrcc (  kind )
    ((-int-) kind)                        ;; ParmKind (short ) -> int
    (int   #{ HasCrcc(  $kind  )  #} )
)


(de HasZerom (  kind )
    ((-int-) kind)                        ;; ParmKind (short ) -> int
    (int   #{ HasZerom(  $kind  )  #} )
)


(de HasZeroc (  kind )
    ((-int-) kind)                        ;; ParmKind (short ) -> int
    (int   #{ HasZeroc(  $kind  )  #} )
)


(de HasVQ (  kind )
    ((-int-) kind)                        ;; ParmKind (short ) -> int
    (int   #{ HasVQ(  $kind  )  #} )
)


(de ValidConversion (  src  tgt )
    ((-int-) src)                       ;; ParmKind (short ) -> int
    ((-int-) tgt)                        ;; ParmKind (short ) -> int
    (int   #{ ValidConversion(  $src   ,$tgt  )  #} )
)


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

(dhc-make-with-libs () (list htk-libhtk)
  dummy_htk_parm
  initparm
  setchannel
  resetchannelsession
  setnewconfig
  openbuffer
  bufferstatus
  obsinbuffer
  startbuffer
  stopbuffer
  closebuffer
  readasbuffer
  readastable
  getbufferinfo
  emptybuffer
  savebuffer
  addtobuffer
  makeobservation
  explainobservation
  printobservation
  zerostreamwidths
  setstreamwidths
  parmkind2str
  str2parmkind
  baseparmkind
  hasenergy
  hasdelta
  hasnulle
  hasaccs
  hascompx
  hascrcc
  haszerom
  haszeroc
  hasvq
  validconversion
)


;;  resetcurcepmean