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

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

#? * (dummy_htk_adapt)
#? * (initadapt)
#? * (initialisetransform <hset> <x> <rt> <adapt>)
#? * (initialiseadapt <hset> <x> <rt>)
#? * (savetransformset <hset> <rt> <savefile> <transpath> <uid> <uname> <chan> <desc> <savestats> <global> <savebinary>)
#? * (loadtransformset <hset> <tfile> <uid> <rt> <usestats>)
#? * (accadaptframe <lr> <speechvec> <mp> <rt>)
#? * (clearregcompstats <hset> <rt>)
#? * (clearbaseclassstats <rt>)
#? * (applymeantransforms <rt> <s>)
#? * (applycovartransforms <rt> <s>)
#? * (applymeanglobaltransform <rt>)
#? * (applycovarglobaltransform <rt>)
#? * (applytransforms <rt>)
#? * (applybackwardglobaltransform <rt>)
#? * (applybackwardtransforms <rt>)
#? * (calcmeantransforms <rt>)
#? * (calccovartransforms <rt>)
#? * (getbackwardtransforms <rt>)
#? * (updatemap <rt> <tau>)
#? * (doadaptation <rt> <global>)

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


(de InitAdapt (  )
    #{ InitAdapt(  );  #} 
    ()
)


(de InitialiseTransform (  hset  x  rt  adapt )
    ((-gptr- "HMMSet *") hset) 
    ((-gptr- "MemHeap *") x) 
    ((-gptr- "RegTransInfo *") rt) 
    ((-int-) adapt)  
    #{ InitialiseTransform(  $hset   ,$x   ,$rt   ,$adapt  );  #} 
    ()
)


(de InitialiseAdapt (  hset  x  rt )
    ((-gptr- "HMMSet *") hset) 
    ((-gptr- "MemHeap *") x) 
    ((-gptr- "RegTransInfo *") rt)  
    #{ InitialiseAdapt(  $hset   ,$x   ,$rt  );  #} 
    ()
)


(de SaveTransformSet (  hset  rt  savefile  transpath  uid  uname  chan  desc  savestats  global  savebinary )
    ((-gptr- "HMMSet *") hset) 
    ((-gptr- "RegTransInfo *") rt) 
    ((-gptr- "char *") savefile) 
    ((-gptr- "char *") transpath) 
    ((-gptr- "char *") uid) 
    ((-gptr- "char *") uname) 
    ((-gptr- "char *") chan) 
    ((-gptr- "char *") desc) 
    ((-int-) savestats) 
    ((-int-) global) 
    ((-int-) savebinary)  
    #{ SaveTransformSet(  $hset   ,$rt   ,$savefile   ,$transpath   ,$uid   ,$uname   ,$chan   ,$desc   ,$savestats   ,$global   ,$savebinary  );  #} 
    ()
)


(de LoadTransformSet (  hset  tfile  uid  rt  usestats )
    ((-gptr- "HMMSet *") hset) 
    ((-gptr- "char *") tfile) 
    ((-gptr- "char *") uid) 
    ((-gptr- "RegTransInfo *") rt) 
    ((-gptr- "Boolean *") usestats)  
    (int   #{ LoadTransformSet(  $hset   ,$tfile   ,$uid   ,$rt   ,$usestats  )  #} )
)


(de AccAdaptFrame (  lr  speechvec  mp  rt )
    ((-double-) lr) 
    ((-gptr- "float *") speechvec) 
    ((-gptr- "MixPDF *") mp) 
    ((-gptr- "RegTransInfo *") rt)  
    #{ AccAdaptFrame(  $lr   ,$speechvec   ,$mp   ,$rt  );  #} 
    ()
)


(de ClearRegCompStats (  hset  rt )
    ((-gptr- "HMMSet *") hset) 
    ((-gptr- "RegTransInfo *") rt)  
    #{ ClearRegCompStats(  $hset   ,$rt  );  #} 
    ()
)


(de ClearBaseClassStats (  rt )
    ((-gptr- "RegTransInfo *") rt)  
    #{ ClearBaseClassStats(  $rt  );  #} 
    ()
)


(de ApplyMeanTransforms (  rt  s )
    ((-gptr- "RegTransInfo *") rt) 
    ((-gptr- "RegTree *") s)  
    #{ ApplyMeanTransforms(  $rt   ,$s  );  #} 
    ()
)


(de ApplyCovarTransforms (  rt  s )
    ((-gptr- "RegTransInfo *") rt) 
    ((-gptr- "RegTree *") s)  
    #{ ApplyCovarTransforms(  $rt   ,$s  );  #} 
    ()
)


(de ApplyMeanGlobalTransform (  rt )
    ((-gptr- "RegTransInfo *") rt)  
    (int   #{ ApplyMeanGlobalTransform(  $rt  )  #} )
)


(de ApplyCovarGlobalTransform (  rt )
    ((-gptr- "RegTransInfo *") rt)  
    (int   #{ ApplyCovarGlobalTransform(  $rt  )  #} )
)


(de ApplyTransforms (  rt )
    ((-gptr- "RegTransInfo *") rt)  
    #{ ApplyTransforms(  $rt  );  #} 
    ()
)


(de ApplyBackwardGlobalTransform (  rt )
    ((-gptr- "RegTransInfo *") rt)  
    (int   #{ ApplyBackwardGlobalTransform(  $rt  )  #} )
)


(de ApplyBackwardTransforms (  rt )
    ((-gptr- "RegTransInfo *") rt)  
    #{ ApplyBackwardTransforms(  $rt  );  #} 
    ()
)


(de CalcMeanTransforms (  rt )
    ((-gptr- "RegTransInfo *") rt)  
    #{ CalcMeanTransforms(  $rt  );  #} 
    ()
)


(de CalcCovarTransforms (  rt )
    ((-gptr- "RegTransInfo *") rt)  
    #{ CalcCovarTransforms(  $rt  );  #} 
    ()
)


(de GetBackwardTransforms (  rt )
    ((-gptr- "RegTransInfo *") rt)  
    #{ GetBackwardTransforms(  $rt  );  #} 
    ()
)


(de UpdateMAP (  rt  tau )
    ((-gptr- "RegTransInfo *") rt) 
    ((-float-) tau)  
    #{ UpdateMAP(  $rt   ,$tau  );  #} 
    ()
)


(de DoAdaptation (  rt  global )
    ((-gptr- "RegTransInfo *") rt) 
    ((-int-) global)  
    #{ DoAdaptation(  $rt   ,$global  );  #} 
    ()
)

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

(dhc-make-with-libs () (list htk-libhtk)
  dummy_htk_adapt
  initadapt
  initialisetransform
  initialiseadapt
  savetransformset
  loadtransformset
  accadaptframe
  clearregcompstats
  clearbaseclassstats
  applymeantransforms
  applycovartransforms
  applymeanglobaltransform
  applycovarglobaltransform
  applytransforms
  applybackwardglobaltransform
  applybackwardtransforms
  calcmeantransforms
  calccovartransforms
  updatemap
  doadaptation
)

;;  getbackwardtransforms
