;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; 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_label

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

#? * (dummy_htk_label)
#? * (initlabel)
#? * (getlabid <name> <insert>)
#? * (printnametabstats)
#? * (readlabel <f> <buf>)
#? * (createtranscription <x>)
#? * (copytranscription <x> <s>)
#? * (printtranscription <s> <title>)
#? * (createlabellist <x> <maxauxlab>)
#? * (addlabellist <ll> <s>)
#? * (getlabellist <s> <n>)
#? * (copylabellist <x> <ll>)
#? * (createlabel <x> <maxaux>)
#? * (addlabel <x> <ll> <id> <st> <en> <score>)
#? * (addauxlab <lab> <n> <auxlab> <auxscore>)
#? * (deletelabel <item>)
#? * (numcases <ll> <id>)
#? * (numauxcases <ll> <id> <i>)
#? * (getcase <ll> <id> <n>)
#? * (getauxcase <ll> <id> <n> <i>)
#? * (getlabn <ll> <n>)
#? * (getauxlabn <ll> <n> <i>)
#? * (countlabs <ll>)
#? * (countauxlabs <ll> <i>)
#? * (auxlabendtime <p> <i>)
#? * (lopen <x> <fname> <fmt>)
#? * (savetomasterfile <fname>)
#? * (closemlfsavefile)
#? * (lsave <fname> <s> <fmt>)
#? * (tristrip <s>)
#? * (ltristrip <enab>)
#? * (loadmasterfile <fname>)
#? * (nummlffiles)
#? * (nummlfentries)
#? * (getmlffile <fidx>)
#? * (ismlffile <fn>)
#? * (getmlftable)

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



(de InitLabel (  )
    #{ InitLabel(  );  #} 
    ()
)


(de GetLabId (  name  insert )
    ((-gptr- "char *") name) 
    ((-int-) insert)  
    (gptr   #{ GetLabId(  $name   ,$insert  )  #} )         ;; LabId (NameCell *) -> gptr
)


(de PrintNameTabStats (  )
    #{ PrintNameTabStats(  );  #} 
    ()
)


(de ReadLabel (  f  buf )
    ((-gptr- "FILE *") f) 
    ((-gptr- "char *") buf)  
    (int   #{ ReadLabel(  $f   ,$buf  )  #} )
)


(de CreateTranscription (  x )
    ((-gptr- "MemHeap *") x)  
    (gptr #{ CreateTranscription(  $x  )  #} )            ;; Transcription *   -> gptr
)


(de CopyTranscription (  x  s )
    ((-gptr- "MemHeap *") x) 
    ((-gptr- "Transcription *") s)  
    (gptr #{ CopyTranscription(  $x   ,$s  )  #} )            ;; Transcription *   -> gptr
)


(de PrintTranscription (  s  title )
    ((-gptr- "Transcription *") s) 
    ((-gptr- "char *") title)  
    #{ PrintTranscription(  $s   ,$title  );  #} 
    ()
)


(de CreateLabelList (  x  maxauxlab )
    ((-gptr- "MemHeap *") x) 
    ((-int-) maxauxlab)  
    (gptr  #{ CreateLabelList(  $x   ,$maxauxlab  )  #} )         ;; LabList *  -> gptr 
)


(de AddLabelList (  ll  s )
    ((-gptr- "LabList *") ll) 
    ((-gptr- "Transcription *") s)  
    #{ AddLabelList(  $ll   ,$s  );  #} 
    ()
)


(de GetLabelList (  s  n )
    ((-gptr- "Transcription *") s) 
    ((-int-) n)  
    (gptr  #{ GetLabelList(  $s   ,$n  )  #} )              ;; LabList*  -> gptr
)


(de CopyLabelList (  x  ll )
    ((-gptr- "MemHeap *") x) 
    ((-gptr- "LabList*") ll)  
    (gptr  #{ CopyLabelList(  $x   ,$ll  )  #} )            ;; LabList*  -> gptr
)


(de CreateLabel (  x  maxaux )
    ((-gptr- "MemHeap *") x) 
    ((-int-) maxaux)  
    (gptr   #{ CreateLabel(  $x   ,$maxaux  )  #} )           ;; LLink -> gptr
)


(de AddLabel (  x  ll  id  st  en  score )
    ((-gptr- "MemHeap *") x) 
    ((-gptr- "LabList *") ll) 
    ((-gptr- "NameCell *") id) 
    ((-double-) st) 
    ((-double-) en) 
    ((-float-) score)  
    (gptr   #{ AddLabel(  $x   ,$ll   ,$id   ,$st   ,$en   ,$score  )  #} )         ;; LLink -> gptr
)


(de AddAuxLab (  lab  n  auxlab  auxscore )
    ((-gptr- "Label *") lab)                 ;; LLink -> gptr
    ((-int-) n) 
    ((-gptr- "LabId *") auxlab) 
    ((-gptr- "float *") auxscore)  
    #{ AddAuxLab(  $lab   ,$n   ,$auxlab   ,$auxscore  );  #} 
    ()
)


(de DeleteLabel (  item )
    ((-gptr- "Label *") item)                 ;; LLink -> gptr
    #{ DeleteLabel(  $item  );  #} 
    ()
)


(de NumCases (  ll  id )
    ((-gptr- "LabList *") ll) 
    ((-gptr- "NameCell *") id)  
    (int   #{ NumCases(  $ll   ,$id  )  #} )
)


(de NumAuxCases (  ll  id  i )
    ((-gptr- "LabList *") ll) 
    ((-gptr- "NameCell *") id) 
    ((-int-) i)  
    (int   #{ NumAuxCases(  $ll   ,$id   ,$i  )  #} )
)


(de GetCase (  ll  id  n )
    ((-gptr- "LabList *") ll) 
    ((-gptr- "NameCell *") id) 
    ((-int-) n)  
    (gptr   #{ GetCase(  $ll   ,$id   ,$n  )  #} )                   ;; LLink -> gptr
)


(de GetAuxCase (  ll  id  n  i )
    ((-gptr- "LabList *") ll) 
    ((-gptr- "NameCell *") id) 
    ((-int-) n) 
    ((-int-) i)  
    (gptr   #{ GetAuxCase(  $ll   ,$id   ,$n   ,$i  )  #} )              ;; LLink -> gptr
)


(de GetLabN (  ll  n )
    ((-gptr- "LabList *") ll) 
    ((-int-) n)  
    (gptr   #{ GetLabN(  $ll   ,$n  )  #} )                       ;; LLink -> gptr
)


(de GetAuxLabN (  ll  n  i )
    ((-gptr- "LabList *") ll) 
    ((-int-) n) 
    ((-int-) i)  
    (gptr   #{ GetAuxLabN(  $ll   ,$n   ,$i  )  #} )                      ;; LLink -> gptr
)


(de CountLabs (  ll )
    ((-gptr- "LabList *") ll)  
    (int   #{ CountLabs(  $ll  )  #} )
)


(de CountAuxLabs (  ll  i )
    ((-gptr- "LabList *") ll) 
    ((-int-) i)  
    (int   #{ CountAuxLabs(  $ll   ,$i  )  #} )
)


(de AuxLabEndTime (  p  i )
    ((-gptr- "Label *") p)                ;; LLink -> gptr
    ((-int-) i)  
    (double   #{ AuxLabEndTime(  $p   ,$i  )  #} )
)


(de LOpen (  x  fname  fmt )
    ((-gptr- "MemHeap *") x) 
    ((-gptr- "char *") fname) 
    ((-int-) fmt)                  ;; FileFormat (enum) -> int
    (gptr #{ LOpen(  $x   ,$fname   ,$fmt  )  #} )            ;; Transcription *   -> gptr
)


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


(de CloseMLFSaveFile (  )
    #{ CloseMLFSaveFile(  );  #} 
    ()
)


(de LSave (  fname  s  fmt )
    ((-gptr- "char *") fname) 
    ((-gptr- "Transcription *") s) 
    ((-int-) fmt)                  ;; FileFormat (enum) -> int
    (int   #{ LSave(  $fname   ,$s   ,$fmt  )  #} )       ;; ReturnStatus -> int
)


(de TriStrip (  s )
    ((-gptr- "char *") s)  
    #{ TriStrip(  $s  );  #} 
    ()
)


(de LTriStrip (  enab )
    ((-int-) enab)  
    #{ LTriStrip(  $enab  );  #} 
    ()
)


(de LoadMasterFile (  fname )
    ((-gptr- "char *") fname)  
    #{ LoadMasterFile(  $fname  );  #} 
    ()
)


(de NumMLFFiles (  )
    (int   #{ NumMLFFiles(  )  #} )
)


(de NumMLFEntries (  )
    (int   #{ NumMLFEntries(  )  #} )
)


(de GetMLFFile (  fidx )
    ((-int-) fidx)  
    (gptr #{ GetMLFFile(  $fidx  )  #} )            ;; FILE *   -> gptr
)


(de IsMLFFile (  fn )
    ((-gptr- "char *") fn)  
    (int   #{ IsMLFFile(  $fn  )  #} )
)


(de GetMLFTable (  )
    (gptr #{ GetMLFTable(  )  #} )            ;; MLFEntry *   -> gptr
)

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

(dhc-make-with-libs () (list htk-libhtk)
  dummy_htk_label
  initlabel
  getlabid
  printnametabstats
  readlabel
  createtranscription
  copytranscription
  printtranscription
  createlabellist
  addlabellist
  getlabellist
  copylabellist
  createlabel
  addlabel
  addauxlab
  deletelabel
  numcases
  numauxcases
  getcase
  getauxcase
  getlabn
  getauxlabn
  countlabs
  countauxlabs
  auxlabendtime
  lopen
  savetomasterfile
  closemlfsavefile
  lsave
  tristrip
  ltristrip
  loadmasterfile
  nummlffiles
  nummlfentries
  getmlffile
  ismlffile
  getmlftable
)
