David Zeuthen 17c4cc
diff -ur festival/speech_tools.old/grammar/ngram/EST_Ngrammar.cc festival/speech_tools/grammar/ngram/EST_Ngrammar.cc
David Zeuthen 17c4cc
--- festival/speech_tools.old/grammar/ngram/EST_Ngrammar.cc	2004-09-30 08:53:36.000000000 -0400
David Zeuthen 17c4cc
+++ festival/speech_tools/grammar/ngram/EST_Ngrammar.cc	2006-12-11 17:36:10.000000000 -0500
David Zeuthen 17c4cc
@@ -306,7 +306,7 @@
David Zeuthen 17c4cc
     // not right - just print out, then recurse through children
David Zeuthen 17c4cc
     // change to use 'backoff_traverse'
David Zeuthen 17c4cc
     
David Zeuthen 17c4cc
-    int k;
David Zeuthen 17c4cc
+    EST_Litem *k;
David Zeuthen 17c4cc
     double freq;
David Zeuthen 17c4cc
     EST_String name;
David Zeuthen 17c4cc
     for (k=p_pdf.item_start();
David Zeuthen 17c4cc
@@ -373,7 +373,7 @@
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
     // recursively delete this state and all its children
David Zeuthen 17c4cc
-    int k;
David Zeuthen 17c4cc
+    EST_Litem *k;
David Zeuthen 17c4cc
     double freq;
David Zeuthen 17c4cc
     EST_String name;
David Zeuthen 17c4cc
     for (k=p_pdf.item_start();
David Zeuthen 17c4cc
@@ -456,7 +456,8 @@
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
 void EST_BackoffNgrammarState::frequency_of_frequencies(EST_DVector &ff)
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
-    int k,max=ff.n();
David Zeuthen 17c4cc
+    int max=ff.n();
David Zeuthen 17c4cc
+    EST_Litem *k;
David Zeuthen 17c4cc
     double freq;
David Zeuthen 17c4cc
     EST_String name;
David Zeuthen 17c4cc
     for (k=p_pdf.item_start();
David Zeuthen 17c4cc
@@ -1585,7 +1586,7 @@
David Zeuthen 17c4cc
     // remove any branches with zero frequency count
David Zeuthen 17c4cc
     
David Zeuthen 17c4cc
     // find children of this state with zero freq and zap them
David Zeuthen 17c4cc
-    int k;
David Zeuthen 17c4cc
+    EST_Litem *k;
David Zeuthen 17c4cc
     double freq;
David Zeuthen 17c4cc
     EST_String name;
David Zeuthen 17c4cc
     for (k=start_state->pdf_const().item_start();
David Zeuthen 17c4cc
@@ -2324,7 +2325,8 @@
David Zeuthen 17c4cc
 	backoff_representation->print_freqs(os,p_order);
David Zeuthen 17c4cc
     else
David Zeuthen 17c4cc
     {
David Zeuthen 17c4cc
-	int i,j,k;
David Zeuthen 17c4cc
+	int i,j;
David Zeuthen 17c4cc
+        EST_Litem *k;
David Zeuthen 17c4cc
 	EST_IVector window(p_order-1);
David Zeuthen 17c4cc
 	
David Zeuthen 17c4cc
 	for (i=0; i < p_num_states; i++)
David Zeuthen 17c4cc
@@ -2665,7 +2667,7 @@
David Zeuthen 17c4cc
     function(start_state,params);
David Zeuthen 17c4cc
     
David Zeuthen 17c4cc
     // and recurse down the tree
David Zeuthen 17c4cc
-    int k;
David Zeuthen 17c4cc
+    EST_Litem *k;
David Zeuthen 17c4cc
     double freq;
David Zeuthen 17c4cc
     EST_String name;
David Zeuthen 17c4cc
     for (k=start_state->pdf_const().item_start();
David Zeuthen 17c4cc
@@ -2696,7 +2698,7 @@
David Zeuthen 17c4cc
     {
David Zeuthen 17c4cc
 	// and recurse down the tree if we haven't
David Zeuthen 17c4cc
 	// reached the level yet
David Zeuthen 17c4cc
-	int k;
David Zeuthen 17c4cc
+	EST_Litem *k;
David Zeuthen 17c4cc
 	double freq;
David Zeuthen 17c4cc
 	EST_String name;
David Zeuthen 17c4cc
 	
David Zeuthen 17c4cc
diff -ur festival/speech_tools.old/grammar/ngram/EST_PST.cc festival/speech_tools/grammar/ngram/EST_PST.cc
David Zeuthen 17c4cc
--- festival/speech_tools.old/grammar/ngram/EST_PST.cc	2004-09-30 08:53:36.000000000 -0400
David Zeuthen 17c4cc
+++ festival/speech_tools/grammar/ngram/EST_PST.cc	2006-12-11 17:36:10.000000000 -0500
David Zeuthen 17c4cc
@@ -71,7 +71,8 @@
David Zeuthen 17c4cc
 	// Base -- print from pd 
David Zeuthen 17c4cc
 	EST_String s;
David Zeuthen 17c4cc
 	double freq;
David Zeuthen 17c4cc
-	for (int i = pd.item_start(); 
David Zeuthen 17c4cc
+        EST_Litem *i;
David Zeuthen 17c4cc
+	for (i = pd.item_start(); 
David Zeuthen 17c4cc
 	     !pd.item_end(i); 
David Zeuthen 17c4cc
 	     i=pd.item_next(i))
David Zeuthen 17c4cc
 	{
David Zeuthen 17c4cc
@@ -98,7 +99,7 @@
David Zeuthen 17c4cc
 	EST_String s;
David Zeuthen 17c4cc
 	double prob;
David Zeuthen 17c4cc
 	os << get_path() << " :";
David Zeuthen 17c4cc
-	for (int i = pd.item_start(); !pd.item_end(i) ; i=pd.item_next(i))
David Zeuthen 17c4cc
+	for (EST_Litem *i = pd.item_start(); !pd.item_end(i) ; i=pd.item_next(i))
David Zeuthen 17c4cc
 	{
David Zeuthen 17c4cc
 	    pd.item_prob(i,s,prob);
David Zeuthen 17c4cc
 	    os << " " << s << " " << prob;
David Zeuthen 17c4cc
diff -ur festival/speech_tools.old/grammar/ngram/freqsmooth.cc festival/speech_tools/grammar/ngram/freqsmooth.cc
David Zeuthen 17c4cc
--- festival/speech_tools.old/grammar/ngram/freqsmooth.cc	2004-09-30 08:53:36.000000000 -0400
David Zeuthen 17c4cc
+++ festival/speech_tools/grammar/ngram/freqsmooth.cc	2006-12-11 17:36:10.000000000 -0500
David Zeuthen 17c4cc
@@ -74,7 +74,8 @@
David Zeuthen 17c4cc
 				 EST_Ngrammar &ngram)
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
     // Build all the backoff grammars back to uni-grams
David Zeuthen 17c4cc
-    int i,j,k,l;
David Zeuthen 17c4cc
+    int i,j,l;
David Zeuthen 17c4cc
+    EST_Litem *k;
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
     for (i=0; i < ngram.order()-1; i++)
David Zeuthen 17c4cc
 	backoff_ngrams[i].init(i+1,EST_Ngrammar::dense,
David Zeuthen 17c4cc
@@ -110,7 +111,8 @@
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
     // For all ngrams which are too infrequent, adjust their
David Zeuthen 17c4cc
     // frequencies based on their backoff probabilities
David Zeuthen 17c4cc
-    int i,j;
David Zeuthen 17c4cc
+    int i;
David Zeuthen 17c4cc
+    EST_Litem *j;
David Zeuthen 17c4cc
     double occurs;
David Zeuthen 17c4cc
     double backoff_prob;
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
diff -ur festival/speech_tools.old/grammar/ngram/ngrammar_aux.cc festival/speech_tools/grammar/ngram/ngrammar_aux.cc
David Zeuthen 17c4cc
--- festival/speech_tools.old/grammar/ngram/ngrammar_aux.cc	2004-09-30 08:53:36.000000000 -0400
David Zeuthen 17c4cc
+++ festival/speech_tools/grammar/ngram/ngrammar_aux.cc	2006-12-11 17:36:10.000000000 -0500
David Zeuthen 17c4cc
@@ -117,7 +117,7 @@
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
 void make_f_of_f(EST_BackoffNgrammarState *s,void *params)
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
-    int k;
David Zeuthen 17c4cc
+    EST_Litem *k;
David Zeuthen 17c4cc
     double freq;
David Zeuthen 17c4cc
     EST_String name;
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
@@ -138,7 +138,7 @@
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
 void get_max_f(EST_BackoffNgrammarState *s,void *params)
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
-    int k;
David Zeuthen 17c4cc
+    EST_Litem *k;
David Zeuthen 17c4cc
     double freq;
David Zeuthen 17c4cc
     EST_String name;
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
@@ -158,7 +158,7 @@
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
 void map_f_of_f(EST_BackoffNgrammarState *s,void *params)
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
-    int k;
David Zeuthen 17c4cc
+    EST_Litem *k;
David Zeuthen 17c4cc
     double freq;
David Zeuthen 17c4cc
     EST_String name;
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
@@ -184,7 +184,7 @@
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
 void zero_small_f(EST_BackoffNgrammarState *s,void *params)
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
-    int k;
David Zeuthen 17c4cc
+    EST_Litem *k;
David Zeuthen 17c4cc
     double freq;
David Zeuthen 17c4cc
     EST_String name;
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
@@ -204,7 +204,8 @@
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
 void frequency_of_frequencies(EST_DVector &ff, EST_Ngrammar &n,int this_order)
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
-  int i,k,size;
David Zeuthen 17c4cc
+  int i,size;
David Zeuthen 17c4cc
+  EST_Litem *k;
David Zeuthen 17c4cc
   double max=0.0;
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
   // if ff has zero size, do complete frequency of frequencies
David Zeuthen 17c4cc
@@ -302,8 +303,8 @@
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
 void map_frequencies(EST_Ngrammar &n, const EST_DVector &map, const int this_order)
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
-  int i,k;
David Zeuthen 17c4cc
-
David Zeuthen 17c4cc
+    int i;
David Zeuthen 17c4cc
+    EST_Litem *k;
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
   switch(n.representation())
David Zeuthen 17c4cc
     {
David Zeuthen 17c4cc
diff -ur festival/speech_tools.old/grammar/ngram/ngrammar_io.cc festival/speech_tools/grammar/ngram/ngrammar_io.cc
David Zeuthen 17c4cc
--- festival/speech_tools.old/grammar/ngram/ngrammar_io.cc	2004-09-30 08:53:36.000000000 -0400
David Zeuthen 17c4cc
+++ festival/speech_tools/grammar/ngram/ngrammar_io.cc	2006-12-11 17:36:10.000000000 -0500
David Zeuthen 17c4cc
@@ -281,7 +281,8 @@
David Zeuthen 17c4cc
 load_ngram_cstr_bin(const EST_String filename, EST_Ngrammar &n)
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
     EST_TokenStream ts;
David Zeuthen 17c4cc
-    int i,j,k,order;
David Zeuthen 17c4cc
+    int i,j,order;
David Zeuthen 17c4cc
+    EST_Litem *k;
David Zeuthen 17c4cc
     int num_entries;
David Zeuthen 17c4cc
     double approx_num_samples = 0.0;
David Zeuthen 17c4cc
     long freq_data_start, freq_data_end;
David Zeuthen 17c4cc
@@ -407,7 +408,7 @@
David Zeuthen 17c4cc
 save_ngram_htk_ascii_sub(const EST_String &word, ostream *ost, 
David Zeuthen 17c4cc
 			 EST_Ngrammar &n, double floor)
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
-    int k;
David Zeuthen 17c4cc
+    EST_Litem *k;
David Zeuthen 17c4cc
     EST_String name;
David Zeuthen 17c4cc
     double freq;
David Zeuthen 17c4cc
     EST_StrVector this_ngram(2); // assumes bigram
David Zeuthen 17c4cc
@@ -734,7 +735,8 @@
David Zeuthen 17c4cc
     // awb's format
David Zeuthen 17c4cc
     (void)trace;
David Zeuthen 17c4cc
     ostream *ost;
David Zeuthen 17c4cc
-    int i,k;
David Zeuthen 17c4cc
+    int i;
David Zeuthen 17c4cc
+    EST_Litem *k;
David Zeuthen 17c4cc
     
David Zeuthen 17c4cc
     if (filename == "-")
David Zeuthen 17c4cc
 	ost = &cout;
David Zeuthen 17c4cc
@@ -831,7 +833,8 @@
David Zeuthen 17c4cc
     if (n.representation() == EST_Ngrammar::sparse)
David Zeuthen 17c4cc
 	return misc_write_error;
David Zeuthen 17c4cc
     
David Zeuthen 17c4cc
-    int i,k;
David Zeuthen 17c4cc
+    int i;
David Zeuthen 17c4cc
+    EST_Litem *k;
David Zeuthen 17c4cc
     FILE *ofd;
David Zeuthen 17c4cc
     double lfreq = -1;
David Zeuthen 17c4cc
     double count = -1;
David Zeuthen 17c4cc
diff -ur festival/speech_tools.old/grammar/wfst/wfst_train.cc festival/speech_tools/grammar/wfst/wfst_train.cc
David Zeuthen 17c4cc
--- festival/speech_tools.old/grammar/wfst/wfst_train.cc	2005-07-26 18:37:36.000000000 -0400
David Zeuthen 17c4cc
+++ festival/speech_tools/grammar/wfst/wfst_train.cc	2006-12-11 17:36:10.000000000 -0500
David Zeuthen 17c4cc
@@ -315,7 +315,8 @@
David Zeuthen 17c4cc
     LISP *ssplits;
David Zeuthen 17c4cc
     gc_protect(&splits);
David Zeuthen 17c4cc
     EST_String sname;
David Zeuthen 17c4cc
-    int b,best_b,i;
David Zeuthen 17c4cc
+    int b,best_b;
David Zeuthen 17c4cc
+    EST_Litem *i;
David Zeuthen 17c4cc
     int num_pdfs;
David Zeuthen 17c4cc
     double best_score, score, sfreq;
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
@@ -390,7 +391,7 @@
David Zeuthen 17c4cc
     // Find score of (a+b) vs (all-(a+b))
David Zeuthen 17c4cc
     EST_DiscreteProbDistribution ab(a);
David Zeuthen 17c4cc
     EST_DiscreteProbDistribution all_but_ab(all);
David Zeuthen 17c4cc
-    int i;
David Zeuthen 17c4cc
+    EST_Litem *i;
David Zeuthen 17c4cc
     EST_String sname;
David Zeuthen 17c4cc
     double sfreq, score;
David Zeuthen 17c4cc
     for (i=b.item_start(); !b.item_end(i);
David Zeuthen 17c4cc
@@ -522,7 +523,7 @@
David Zeuthen 17c4cc
     EST_DiscreteProbDistribution pdf_split(&wfst.in_symbols());
David Zeuthen 17c4cc
     EST_DiscreteProbDistribution pdf_remain(&wfst.in_symbols());
David Zeuthen 17c4cc
     int in, tostate, id;
David Zeuthen 17c4cc
-    int i;
David Zeuthen 17c4cc
+    EST_Litem *i;
David Zeuthen 17c4cc
     double sfreq;
David Zeuthen 17c4cc
     EST_String sname;
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
diff -ur festival/speech_tools.old/include/EST_simplestats.h festival/speech_tools/include/EST_simplestats.h
David Zeuthen 17c4cc
--- festival/speech_tools.old/include/EST_simplestats.h	2004-04-30 12:56:49.000000000 -0400
David Zeuthen 17c4cc
+++ festival/speech_tools/include/EST_simplestats.h	2006-12-11 17:36:10.000000000 -0500
David Zeuthen 17c4cc
@@ -47,6 +47,8 @@
David Zeuthen 17c4cc
 #include "EST_TKVL.h"
David Zeuthen 17c4cc
 #include "EST_types.h"
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
+typedef size_t int_iter; 
David Zeuthen 17c4cc
+
David Zeuthen 17c4cc
 /** A class for managing mapping string names to integers and back again,
David Zeuthen 17c4cc
     mainly used for representing alphabets in n-grams and grammars etc.
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
@@ -249,7 +251,8 @@
David Zeuthen 17c4cc
     /// Add this observation, may specify number of occurrences
David Zeuthen 17c4cc
     void cumulate(const EST_String &s,double count=1);
David Zeuthen 17c4cc
     /// Add this observation, i must be with in EST\_Discrete range
David Zeuthen 17c4cc
-    void cumulate(const int i,double count=1);
David Zeuthen 17c4cc
+    void cumulate(EST_Litem *i,double count=1);
David Zeuthen 17c4cc
+    void cumulate(int i,double count=1);
David Zeuthen 17c4cc
     /// Return the most probable member of the distribution
David Zeuthen 17c4cc
     const EST_String &most_probable(double *prob = NULL) const;
David Zeuthen 17c4cc
     /** Return the entropy of the distribution
David Zeuthen 17c4cc
@@ -265,17 +268,18 @@
David Zeuthen 17c4cc
     /// 
David Zeuthen 17c4cc
     double frequency(const int i) const; 
David Zeuthen 17c4cc
     /// Used for iterating through members of the distribution
David Zeuthen 17c4cc
-    int item_start() const;
David Zeuthen 17c4cc
+    EST_Litem *item_start() const;
David Zeuthen 17c4cc
     /// Used for iterating through members of the distribution
David Zeuthen 17c4cc
-    int item_next(int idx) const;
David Zeuthen 17c4cc
+    EST_Litem *item_next(EST_Litem *idx) const;
David Zeuthen 17c4cc
     /// Used for iterating through members of the distribution
David Zeuthen 17c4cc
-    int item_end(int idx) const;
David Zeuthen 17c4cc
+    int item_end(EST_Litem *idx) const;
David Zeuthen 17c4cc
+
David Zeuthen 17c4cc
     /// During iteration returns name given index 
David Zeuthen 17c4cc
-    const EST_String &item_name(int idx) const;
David Zeuthen 17c4cc
+    const EST_String &item_name(EST_Litem *idx) const;
David Zeuthen 17c4cc
     /// During iteration returns name and frequency given index  
David Zeuthen 17c4cc
-    void item_freq(int idx,EST_String &s,double &freq) const;
David Zeuthen 17c4cc
+    void item_freq(EST_Litem *idx,EST_String &s,double &freq) const;
David Zeuthen 17c4cc
     /// During iteration returns name and probability given index
David Zeuthen 17c4cc
-    void item_prob(int idx,EST_String &s,double &prob) const;
David Zeuthen 17c4cc
+    void item_prob(EST_Litem *idx,EST_String &s,double &prob) const;
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
     /// Returns discrete vocabulary of distribution
David Zeuthen 17c4cc
     inline const EST_Discrete *const get_discrete() const { return discrete; };
David Zeuthen 17c4cc
@@ -288,11 +292,13 @@
David Zeuthen 17c4cc
         accordingly.  This is used when smoothing frequencies.
David Zeuthen 17c4cc
     */
David Zeuthen 17c4cc
     void set_frequency(int i,double c); 
David Zeuthen 17c4cc
+    void set_frequency(EST_Litem *i,double c); 
David Zeuthen 17c4cc
     
David Zeuthen 17c4cc
     /// Sets the frequency of named item, without modifying {\tt num\_samples}.
David Zeuthen 17c4cc
     void override_frequency(const EST_String &s,double c);
David Zeuthen 17c4cc
     /// Sets the frequency of named item, without modifying {\tt num\_samples}.
David Zeuthen 17c4cc
     void override_frequency(int i,double c); 
David Zeuthen 17c4cc
+    void override_frequency(EST_Litem *i,double c); 
David Zeuthen 17c4cc
     
David Zeuthen 17c4cc
     /** Sets the number of samples.  Care should be taken on setting this
David Zeuthen 17c4cc
         as it will affect how probabilities are calculated.
David Zeuthen 17c4cc
diff -ur festival/speech_tools.old/include/EST_Track.h festival/speech_tools/include/EST_Track.h
David Zeuthen 17c4cc
--- festival/speech_tools.old/include/EST_Track.h	2004-05-29 14:34:40.000000000 -0400
David Zeuthen 17c4cc
+++ festival/speech_tools/include/EST_Track.h	2007-02-13 00:12:53.000000000 -0500
David Zeuthen 17c4cc
@@ -61,6 +61,7 @@
David Zeuthen 17c4cc
   tff_htk,
David Zeuthen 17c4cc
   tff_htk_fbank,
David Zeuthen 17c4cc
   tff_htk_mfcc,
David Zeuthen 17c4cc
+  tff_htk_mfcc_e,
David Zeuthen 17c4cc
   tff_htk_user,
David Zeuthen 17c4cc
   tff_htk_discrete,
David Zeuthen 17c4cc
   tff_xmg,
David Zeuthen 17c4cc
diff -ur festival/speech_tools.old/include/EST_TSimpleVector.h festival/speech_tools/include/EST_TSimpleVector.h
David Zeuthen 17c4cc
--- festival/speech_tools.old/include/EST_TSimpleVector.h	2006-07-06 08:57:24.000000000 -0400
David Zeuthen 17c4cc
+++ festival/speech_tools/include/EST_TSimpleVector.h	2006-09-27 09:19:35.000000000 -0400
David Zeuthen 17c4cc
@@ -60,6 +60,9 @@
David Zeuthen 17c4cc
     EST_TSimpleVector(const EST_TSimpleVector<t> &v);
David Zeuthen 17c4cc
     /// "size" constructor
David Zeuthen 17c4cc
     EST_TSimpleVector(int n): EST_TVector<t>(n) {}; 
David Zeuthen 17c4cc
+    /// memory constructor
David Zeuthen 17c4cc
+    EST_TSimpleVector(int n, T* memory, int offset=0, 
David Zeuthen 17c4cc
+		      int free_when_destroyed=0): EST_TVector<t>(n,memory) {}; 
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
     /// resize vector
David Zeuthen 17c4cc
     void resize(int n, int set=1); 
David Zeuthen 17c4cc
diff -ur festival/speech_tools.old/include/EST_Wagon.h festival/speech_tools/include/EST_Wagon.h
David Zeuthen 17c4cc
--- festival/speech_tools.old/include/EST_Wagon.h	2006-08-11 18:39:02.000000000 -0400
David Zeuthen 17c4cc
+++ festival/speech_tools/include/EST_Wagon.h	2006-12-02 11:44:48.000000000 -0500
David Zeuthen 17c4cc
@@ -239,8 +239,7 @@
David Zeuthen 17c4cc
 extern EST_FMatrix wgn_DistMatrix;
David Zeuthen 17c4cc
 extern EST_Track wgn_VertexTrack;
David Zeuthen 17c4cc
 extern EST_Track wgn_UnitTrack;
David Zeuthen 17c4cc
-extern int wgn_VertexTrack_start;
David Zeuthen 17c4cc
-extern int wgn_VertexTrack_end;
David Zeuthen 17c4cc
+extern EST_Track wgn_VertexFeats;
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
 void wgn_load_datadescription(EST_String fname,LISP ignores);
David Zeuthen 17c4cc
 void wgn_load_dataset(WDataSet &ds,EST_String fname);
David Zeuthen 17c4cc
diff -ur festival/speech_tools.old/lib/siod/siod.scm festival/speech_tools/lib/siod/siod.scm
David Zeuthen 17c4cc
--- festival/speech_tools.old/lib/siod/siod.scm	2003-03-31 09:28:24.000000000 -0500
David Zeuthen 17c4cc
+++ festival/speech_tools/lib/siod/siod.scm	2006-12-11 17:36:10.000000000 -0500
David Zeuthen 17c4cc
@@ -209,7 +209,13 @@
David Zeuthen 17c4cc
 (defun append2 (a b)
David Zeuthen 17c4cc
   (if (null a)
David Zeuthen 17c4cc
       b
David Zeuthen 17c4cc
-    (cons (car a) (append2 (cdr a) b))))
David Zeuthen 17c4cc
+      (begin
David Zeuthen 17c4cc
+        (let ((x (reverse a))
David Zeuthen 17c4cc
+              (y b))
David Zeuthen 17c4cc
+          (while x
David Zeuthen 17c4cc
+            (set! y (cons (car x) y))
David Zeuthen 17c4cc
+            (set! x (cdr x)))
David Zeuthen 17c4cc
+          y))))
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
 (defun rplacd (a b)
David Zeuthen 17c4cc
 "(replacd A B)
David Zeuthen 17c4cc
diff -ur festival/speech_tools.old/main/wagon_main.cc festival/speech_tools/main/wagon_main.cc
David Zeuthen 17c4cc
--- festival/speech_tools.old/main/wagon_main.cc	2006-09-10 17:33:18.000000000 -0400
David Zeuthen 17c4cc
+++ festival/speech_tools/main/wagon_main.cc	2006-12-02 14:46:44.000000000 -0500
David Zeuthen 17c4cc
@@ -2,7 +2,7 @@
David Zeuthen 17c4cc
 /*                                                                       */
David Zeuthen 17c4cc
 /*                Centre for Speech Technology Research                  */
David Zeuthen 17c4cc
 /*                     University of Edinburgh, UK                       */
David Zeuthen 17c4cc
-/*                     Copyright (c) 1996-2005                           */
David Zeuthen 17c4cc
+/*                     Copyright (c) 1996-2006                           */
David Zeuthen 17c4cc
 /*                        All Rights Reserved.                           */
David Zeuthen 17c4cc
 /*                                                                       */
David Zeuthen 17c4cc
 /*  Permission is hereby granted, free of charge, to use and distribute  */
David Zeuthen 17c4cc
@@ -39,6 +39,8 @@
David Zeuthen 17c4cc
 /*                                                                       */
David Zeuthen 17c4cc
 /*  Added decision list support, Feb 1997                                */
David Zeuthen 17c4cc
 /*                                                                       */
David Zeuthen 17c4cc
+/*  Added vector support for Clustergen 2005/2006                        */
David Zeuthen 17c4cc
+/*                                                                       */
David Zeuthen 17c4cc
 /*=======================================================================*/
David Zeuthen 17c4cc
 #include <cstdlib>
David Zeuthen 17c4cc
 #include <iostream>
David Zeuthen 17c4cc
@@ -111,6 +113,54 @@
David Zeuthen 17c4cc
     return 0;
David Zeuthen 17c4cc
 }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
+static int set_Vertex_Feats(EST_Track &wgn_VertexFeats,
David Zeuthen 17c4cc
+                            EST_String &wagon_track_features)
David Zeuthen 17c4cc
+{
David Zeuthen 17c4cc
+    int i,s=0,e;
David Zeuthen 17c4cc
+    EST_TokenStream ts;
David Zeuthen 17c4cc
+
David Zeuthen 17c4cc
+    for (i=0; i
David Zeuthen 17c4cc
+        wgn_VertexFeats.a(0,i) = 0.0;
David Zeuthen 17c4cc
+
David Zeuthen 17c4cc
+    ts.open_string(wagon_track_features);
David Zeuthen 17c4cc
+    ts.set_WhiteSpaceChars(",- ");
David Zeuthen 17c4cc
+    ts.set_PunctuationSymbols("");
David Zeuthen 17c4cc
+    ts.set_PrePunctuationSymbols("");
David Zeuthen 17c4cc
+    ts.set_SingleCharSymbols("");
David Zeuthen 17c4cc
+
David Zeuthen 17c4cc
+    while (!ts.eof())
David Zeuthen 17c4cc
+    {
David Zeuthen 17c4cc
+        EST_Token &token = ts.get();
David Zeuthen 17c4cc
+        const EST_String ws = (const char *)token.whitespace();
David Zeuthen 17c4cc
+        if (token == "all")
David Zeuthen 17c4cc
+        {
David Zeuthen 17c4cc
+            for (i=0; i
David Zeuthen 17c4cc
+                wgn_VertexFeats.a(0,i) = 1.0;
David Zeuthen 17c4cc
+            break;
David Zeuthen 17c4cc
+        } else if ((ws == ",") || (ws == ""))
David Zeuthen 17c4cc
+        {
David Zeuthen 17c4cc
+            s = atoi(token.string());
David Zeuthen 17c4cc
+            wgn_VertexFeats.a(0,s) = 1.0;
David Zeuthen 17c4cc
+        } else if (ws == "-")
David Zeuthen 17c4cc
+        {
David Zeuthen 17c4cc
+            if (token == "")
David Zeuthen 17c4cc
+                e = wgn_VertexFeats.num_channels()-1;
David Zeuthen 17c4cc
+            else
David Zeuthen 17c4cc
+                e = atoi(token.string());
David Zeuthen 17c4cc
+            for (i=s; i<=e && i
David Zeuthen 17c4cc
+                wgn_VertexFeats.a(0,i) = 1.0;
David Zeuthen 17c4cc
+        } else
David Zeuthen 17c4cc
+        {
David Zeuthen 17c4cc
+            printf("wagon: track_feats invalid: %s at position %d\n",
David Zeuthen 17c4cc
+                   (const char *)wagon_track_features,
David Zeuthen 17c4cc
+                   ts.filepos());
David Zeuthen 17c4cc
+            exit(-1);
David Zeuthen 17c4cc
+        }
David Zeuthen 17c4cc
+    }
David Zeuthen 17c4cc
+
David Zeuthen 17c4cc
+    return 0;
David Zeuthen 17c4cc
+}
David Zeuthen 17c4cc
+
David Zeuthen 17c4cc
 static int wagon_main(int argc, char **argv)
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
     // Top level function sets up data and creates a tree
David Zeuthen 17c4cc
@@ -119,6 +169,8 @@
David Zeuthen 17c4cc
     EST_String wgn_oname;
David Zeuthen 17c4cc
     ostream *wgn_coutput = 0;
David Zeuthen 17c4cc
     float stepwise_limit = 0;
David Zeuthen 17c4cc
+    int feats_start=0, feats_end=0;
David Zeuthen 17c4cc
+    int i;
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
     parse_command_line
David Zeuthen 17c4cc
 	(argc, argv,
David Zeuthen 17c4cc
@@ -142,6 +194,9 @@
David Zeuthen 17c4cc
          "                  start channel vertex indices\n"+
David Zeuthen 17c4cc
 	 "-track_end <int>\n"+
David Zeuthen 17c4cc
          "                  end (inclusive) channel for vertex indices\n"+
David Zeuthen 17c4cc
+	 "-track_feats <string>\n"+
David Zeuthen 17c4cc
+         "                  Track features to use, comma separated list\n"+
David Zeuthen 17c4cc
+         "                  with feature numbers and/or ranges, 0 start\n"+
David Zeuthen 17c4cc
 	 "-unittrack <ifile>\n"+
David Zeuthen 17c4cc
          "                  track for unit start and length in vertex track\n"+
David Zeuthen 17c4cc
 	 "-quiet            No questions printed during building\n"+
David Zeuthen 17c4cc
@@ -256,36 +311,53 @@
David Zeuthen 17c4cc
     else if (al.present("-track"))
David Zeuthen 17c4cc
     {
David Zeuthen 17c4cc
         wgn_VertexTrack.load(al.val("-track"));
David Zeuthen 17c4cc
-        wgn_VertexTrack_start = 0;
David Zeuthen 17c4cc
-        wgn_VertexTrack_end = wgn_VertexTrack.num_channels()-1;
David Zeuthen 17c4cc
+        wgn_VertexFeats.resize(1,wgn_VertexTrack.num_channels());
David Zeuthen 17c4cc
+        for (i=0; i
David Zeuthen 17c4cc
+            wgn_VertexFeats.a(0,i) = 1.0;
David Zeuthen 17c4cc
     }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
     if (al.present("-track_start"))
David Zeuthen 17c4cc
     {
David Zeuthen 17c4cc
-        wgn_VertexTrack_start = al.ival("-track_start");
David Zeuthen 17c4cc
-        if ((wgn_VertexTrack_start < 0) ||
David Zeuthen 17c4cc
-            (wgn_VertexTrack_start > wgn_VertexTrack.num_channels()))
David Zeuthen 17c4cc
+        feats_start = al.ival("-track_start");
David Zeuthen 17c4cc
+        if ((feats_start < 0) ||
David Zeuthen 17c4cc
+            (feats_start > wgn_VertexTrack.num_channels()))
David Zeuthen 17c4cc
         {
David Zeuthen 17c4cc
             printf("wagon: track_start invalid: %d out of %d channels\n",
David Zeuthen 17c4cc
-                   wgn_VertexTrack_start,
David Zeuthen 17c4cc
+                   feats_start,
David Zeuthen 17c4cc
                    wgn_VertexTrack.num_channels());
David Zeuthen 17c4cc
             exit(-1);
David Zeuthen 17c4cc
         }
David Zeuthen 17c4cc
+        for (i=0; i
David Zeuthen 17c4cc
+            wgn_VertexFeats.a(0,i) = 0.0; /* don't do feats up to start */
David Zeuthen 17c4cc
+            
David Zeuthen 17c4cc
     }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
     if (al.present("-track_end"))
David Zeuthen 17c4cc
     {
David Zeuthen 17c4cc
-        wgn_VertexTrack_end = al.ival("-track_end");
David Zeuthen 17c4cc
-        if ((wgn_VertexTrack_end < wgn_VertexTrack_start) ||
David Zeuthen 17c4cc
-            (wgn_VertexTrack_end > wgn_VertexTrack.num_channels()))
David Zeuthen 17c4cc
+        feats_end = al.ival("-track_end");
David Zeuthen 17c4cc
+        if ((feats_end < feats_start) ||
David Zeuthen 17c4cc
+            (feats_end > wgn_VertexTrack.num_channels()))
David Zeuthen 17c4cc
         {
David Zeuthen 17c4cc
             printf("wagon: track_end invalid: %d between start %d out of %d channels\n",
David Zeuthen 17c4cc
-                   wgn_VertexTrack_end,
David Zeuthen 17c4cc
-                   wgn_VertexTrack_start,
David Zeuthen 17c4cc
+                   feats_end,
David Zeuthen 17c4cc
+                   feats_start,
David Zeuthen 17c4cc
                    wgn_VertexTrack.num_channels());
David Zeuthen 17c4cc
             exit(-1);
David Zeuthen 17c4cc
         }
David Zeuthen 17c4cc
+        for (i=feats_end+1; i
David Zeuthen 17c4cc
+            wgn_VertexFeats.a(0,i) = 0.0; /* don't do feats after end */
David Zeuthen 17c4cc
     }
David Zeuthen 17c4cc
+    if (al.present("-track_feats"))
David Zeuthen 17c4cc
+    {   /* overrides start and end numbers */
David Zeuthen 17c4cc
+        EST_String wagon_track_features = al.val("-track_feats");
David Zeuthen 17c4cc
+        set_Vertex_Feats(wgn_VertexFeats,wagon_track_features);
David Zeuthen 17c4cc
+    }
David Zeuthen 17c4cc
+
David Zeuthen 17c4cc
+    //    printf("Track feats\n");
David Zeuthen 17c4cc
+    //    for (i=0; i
David Zeuthen 17c4cc
+    //        if (wgn_VertexFeats.a(0,i) > 0.0)
David Zeuthen 17c4cc
+    //            printf("%d ",i);
David Zeuthen 17c4cc
+    //    printf("\n");
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
     if (al.present("-unittrack"))
David Zeuthen 17c4cc
     {   /* contains two features, a start and length.  start indexes */
David Zeuthen 17c4cc
diff -ur festival/speech_tools.old/siod/slib_str.cc festival/speech_tools/siod/slib_str.cc
David Zeuthen 17c4cc
--- festival/speech_tools.old/siod/slib_str.cc	2004-09-30 08:53:36.000000000 -0400
David Zeuthen 17c4cc
+++ festival/speech_tools/siod/slib_str.cc	2006-09-27 11:54:29.000000000 -0400
David Zeuthen 17c4cc
@@ -268,7 +268,7 @@
David Zeuthen 17c4cc
 LISP l_matches(LISP atom, LISP regex)
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
     // t if printname of atom matches regex, nil otherwise
David Zeuthen 17c4cc
-    EST_String pname = get_c_string(atom);
David Zeuthen 17c4cc
+    const EST_String pname = get_c_string(atom);
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
     if (pname.matches(make_regex(get_c_string(regex))) == TRUE)
David Zeuthen 17c4cc
 	return truth;
David Zeuthen 17c4cc
diff -ur festival/speech_tools.old/speech_class/EST_TrackFile.cc festival/speech_tools/speech_class/EST_TrackFile.cc
David Zeuthen 17c4cc
--- festival/speech_tools.old/speech_class/EST_TrackFile.cc	2006-09-10 16:32:14.000000000 -0400
David Zeuthen 17c4cc
+++ festival/speech_tools/speech_class/EST_TrackFile.cc	2007-02-13 00:12:53.000000000 -0500
David Zeuthen 17c4cc
@@ -522,7 +522,6 @@
David Zeuthen 17c4cc
 // 	}
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
 	if( ascii ){
David Zeuthen 17c4cc
-
David Zeuthen 17c4cc
 	  for (j = 0; j < num_channels; ++j){
David Zeuthen 17c4cc
 	    tr.a(i, j) = ts.get().Float(ok);
David Zeuthen 17c4cc
 	    if (!ok)
David Zeuthen 17c4cc
@@ -1254,6 +1253,11 @@
David Zeuthen 17c4cc
     return save_htk_as(filename, tmp, HTK_MFCC);
David Zeuthen 17c4cc
 }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
+EST_write_status EST_TrackFile::save_htk_mfcc_e(const EST_String filename, EST_Track tmp)
David Zeuthen 17c4cc
+{
David Zeuthen 17c4cc
+    return save_htk_as(filename, tmp, HTK_MFCC | HTK_ENERGY);
David Zeuthen 17c4cc
+}
David Zeuthen 17c4cc
+
David Zeuthen 17c4cc
 EST_write_status EST_TrackFile::save_htk_user(const EST_String filename, EST_Track tmp)
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
     return save_htk_as(filename, tmp, HTK_USER);
David Zeuthen 17c4cc
@@ -2097,14 +2101,14 @@
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
 EST_String EST_TrackFile::options_supported(void)
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
-    EST_String s("Available track file formats:\n");
David Zeuthen 17c4cc
+    EST_String s("AvailablE track file formats:\n");
David Zeuthen 17c4cc
     
David Zeuthen 17c4cc
     for(int n=0; n< EST_TrackFile::map.n() ; n++)
David Zeuthen 17c4cc
     {
David Zeuthen 17c4cc
 	const char *nm = EST_TrackFile::map.name(EST_TrackFile::map.token(n));
David Zeuthen 17c4cc
 	const char *d = EST_TrackFile::map.info(EST_TrackFile::map.token(n)).description;
David Zeuthen 17c4cc
 	
David Zeuthen 17c4cc
-	s += EST_String::cat("        ", nm, EST_String(" ")*(12-strlen(nm)), d, "\n");
David Zeuthen 17c4cc
+	s += EST_String::cat("        ", nm, EST_String(" ")*(13-strlen(nm)), d, "\n");
David Zeuthen 17c4cc
     }
David Zeuthen 17c4cc
     return s;
David Zeuthen 17c4cc
 }
David Zeuthen 17c4cc
@@ -2137,6 +2141,9 @@
David Zeuthen 17c4cc
 {tff_htk_mfcc,	{ "htk_mfcc" }, 
David Zeuthen 17c4cc
 {FALSE, EST_TrackFile::load_htk, EST_TrackFile::save_htk_mfcc,
David Zeuthen 17c4cc
  "htk file (as MFCC)"}},
David Zeuthen 17c4cc
+{tff_htk_mfcc_e,	{ "htk_mfcc_e" }, 
David Zeuthen 17c4cc
+{FALSE, EST_TrackFile::load_htk, EST_TrackFile::save_htk_mfcc_e,
David Zeuthen 17c4cc
+ "htk file (as MFCC_E)"}},
David Zeuthen 17c4cc
 {tff_htk_user,	{ "htk_user" }, 
David Zeuthen 17c4cc
 {FALSE, EST_TrackFile::load_htk, EST_TrackFile::save_htk_user,
David Zeuthen 17c4cc
  "htk file (as USER)"}},
David Zeuthen 17c4cc
diff -ur festival/speech_tools.old/speech_class/EST_TrackFile.h festival/speech_tools/speech_class/EST_TrackFile.h
David Zeuthen 17c4cc
--- festival/speech_tools.old/speech_class/EST_TrackFile.h	2004-05-29 14:34:42.000000000 -0400
David Zeuthen 17c4cc
+++ festival/speech_tools/speech_class/EST_TrackFile.h	2007-02-13 00:12:53.000000000 -0500
David Zeuthen 17c4cc
@@ -111,6 +111,8 @@
David Zeuthen 17c4cc
   static EST_write_status save_htk_fbank(SaveTrackFileArgs);
David Zeuthen 17c4cc
   static EST_read_status load_htk_fbank(LoadTrackFileArgs);
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
+  static EST_write_status save_htk_mfcc_e(SaveTrackFileArgs);
David Zeuthen 17c4cc
+
David Zeuthen 17c4cc
   static EST_write_status save_htk_mfcc(SaveTrackFileArgs);
David Zeuthen 17c4cc
   static EST_read_status load_htk_mfcc(LoadTrackFileArgs);
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
diff -ur festival/speech_tools.old/speech_class/EST_wave_io.cc festival/speech_tools/speech_class/EST_wave_io.cc
David Zeuthen 17c4cc
--- festival/speech_tools.old/speech_class/EST_wave_io.cc	2006-01-12 10:37:51.000000000 -0500
David Zeuthen 17c4cc
+++ festival/speech_tools/speech_class/EST_wave_io.cc	2007-02-13 00:12:53.000000000 -0500
David Zeuthen 17c4cc
@@ -173,7 +173,7 @@
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
     current_pos = ts.tell();
David Zeuthen 17c4cc
     if (ts.fread(header,NIST_HDR_SIZE,1) != 1)
David Zeuthen 17c4cc
-	return misc_read_error;
David Zeuthen 17c4cc
+	return wrong_format;
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
     if (strncmp(header,NIST_SIG,sizeof(NIST_SIG)) != 0)
David Zeuthen 17c4cc
 	return wrong_format;
David Zeuthen 17c4cc
diff -ur festival/speech_tools.old/stats/EST_DProbDist.cc festival/speech_tools/stats/EST_DProbDist.cc
David Zeuthen 17c4cc
--- festival/speech_tools.old/stats/EST_DProbDist.cc	2004-09-30 08:53:36.000000000 -0400
David Zeuthen 17c4cc
+++ festival/speech_tools/stats/EST_DProbDist.cc	2006-12-11 17:36:12.000000000 -0500
David Zeuthen 17c4cc
@@ -46,6 +46,39 @@
David Zeuthen 17c4cc
 #include "EST_TKVL.h"
David Zeuthen 17c4cc
 #include "EST_simplestats.h"
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
+/* We share ints and pointers for two types of probability distributions */
David Zeuthen 17c4cc
+/* The know discrete sets can be indexed by ints which is *much* faster  */
David Zeuthen 17c4cc
+/* the indices pass around a pointers but the lower part contain ints in */
David Zeuthen 17c4cc
+/* the discrete case                                                     */
David Zeuthen 17c4cc
+/* On 64bit architectures this is a issue so we need have some macros    */
David Zeuthen 17c4cc
+/* to help us here.                                                      */
David Zeuthen 17c4cc
+
David Zeuthen 17c4cc
+const int est_64to32(void *c)
David Zeuthen 17c4cc
+{   /* this returns the bottom end of the pointer as an unsigned int */
David Zeuthen 17c4cc
+    /* I believe this is a safe way to do it, we check the bits in the */
David Zeuthen 17c4cc
+    /* 64 bit int and multiply them out in the 32 bit one              */
David Zeuthen 17c4cc
+    /* there might be better ways, but I think you'd need to think about */
David Zeuthen 17c4cc
+    /* byte order then                                                 */
David Zeuthen 17c4cc
+    long long l;
David Zeuthen 17c4cc
+    int d;
David Zeuthen 17c4cc
+    int i,x;
David Zeuthen 17c4cc
+
David Zeuthen 17c4cc
+    l = (long long)c;
David Zeuthen 17c4cc
+
David Zeuthen 17c4cc
+    for (i=0,d=0,x=1; i<24; i++)
David Zeuthen 17c4cc
+    {
David Zeuthen 17c4cc
+        if (l & 1)
David Zeuthen 17c4cc
+            d += x;
David Zeuthen 17c4cc
+        l = l >> 1;
David Zeuthen 17c4cc
+        x += x;
David Zeuthen 17c4cc
+    }
David Zeuthen 17c4cc
+
David Zeuthen 17c4cc
+    return d;
David Zeuthen 17c4cc
+}
David Zeuthen 17c4cc
+/* #define tprob_int(X) ((sizeof(void *) != 8) ? est_64to32(X) : (int)X) */
David Zeuthen 17c4cc
+#define tprob_int(X) (est_64to32(X))
David Zeuthen 17c4cc
+
David Zeuthen 17c4cc
+
David Zeuthen 17c4cc
 EST_DiscreteProbDistribution::EST_DiscreteProbDistribution(const EST_Discrete *d,
David Zeuthen 17c4cc
 		 const double n_samples, const EST_DVector &counts)
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
@@ -109,7 +142,13 @@
David Zeuthen 17c4cc
 	icounts.a_no_check(i) = 0;
David Zeuthen 17c4cc
 }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
-void EST_DiscreteProbDistribution::cumulate(const int i,double count)
David Zeuthen 17c4cc
+void EST_DiscreteProbDistribution::cumulate(EST_Litem *i,double count)
David Zeuthen 17c4cc
+{
David Zeuthen 17c4cc
+    icounts[tprob_int(i)] += count;
David Zeuthen 17c4cc
+    num_samples += count;
David Zeuthen 17c4cc
+}
David Zeuthen 17c4cc
+
David Zeuthen 17c4cc
+void EST_DiscreteProbDistribution::cumulate(int i,double count)
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
     icounts[i] += count;
David Zeuthen 17c4cc
     num_samples += count;
David Zeuthen 17c4cc
@@ -257,6 +296,21 @@
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
 }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
+void EST_DiscreteProbDistribution::set_frequency(EST_Litem *i,double c)
David Zeuthen 17c4cc
+{
David Zeuthen 17c4cc
+    if (type == tprob_discrete)
David Zeuthen 17c4cc
+    {
David Zeuthen 17c4cc
+	num_samples -= icounts[tprob_int(i)];
David Zeuthen 17c4cc
+	num_samples += c;
David Zeuthen 17c4cc
+	icounts[tprob_int(i)] = c;
David Zeuthen 17c4cc
+    }
David Zeuthen 17c4cc
+    else
David Zeuthen 17c4cc
+    {
David Zeuthen 17c4cc
+	cerr << "ProbDistribution: can't access string type pd with int\n";
David Zeuthen 17c4cc
+    }
David Zeuthen 17c4cc
+
David Zeuthen 17c4cc
+}
David Zeuthen 17c4cc
+
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
 void EST_DiscreteProbDistribution::override_frequency(const EST_String &s,double c)
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
@@ -274,6 +328,14 @@
David Zeuthen 17c4cc
 	cerr << "ProbDistribution: can't access string type pd with int\n";
David Zeuthen 17c4cc
 }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
+void EST_DiscreteProbDistribution::override_frequency(EST_Litem *i,double c)
David Zeuthen 17c4cc
+{
David Zeuthen 17c4cc
+    if (type == tprob_discrete)
David Zeuthen 17c4cc
+	icounts[tprob_int(i)] = c;
David Zeuthen 17c4cc
+    else
David Zeuthen 17c4cc
+	cerr << "ProbDistribution: can't access string type pd with int\n";
David Zeuthen 17c4cc
+}
David Zeuthen 17c4cc
+
David Zeuthen 17c4cc
 double EST_DiscreteProbDistribution::entropy() const
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
     // Returns the entropy of the current distribution
David Zeuthen 17c4cc
@@ -305,70 +367,70 @@
David Zeuthen 17c4cc
 }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
 //  For iterating through members of a probability distribution
David Zeuthen 17c4cc
-int EST_DiscreteProbDistribution::item_start(void) const
David Zeuthen 17c4cc
+EST_Litem *EST_DiscreteProbDistribution::item_start(void) const
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
     if (type == tprob_discrete)
David Zeuthen 17c4cc
-	return 0;
David Zeuthen 17c4cc
+	return NULL;
David Zeuthen 17c4cc
     else
David Zeuthen 17c4cc
-	return (int)scounts.list.head();
David Zeuthen 17c4cc
+	return scounts.list.head();
David Zeuthen 17c4cc
 }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
-int EST_DiscreteProbDistribution::item_end(int idx) const
David Zeuthen 17c4cc
+int EST_DiscreteProbDistribution::item_end(EST_Litem *idx) const
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
     if (type == tprob_discrete)
David Zeuthen 17c4cc
-	return (idx >= icounts.length());
David Zeuthen 17c4cc
+	return (tprob_int(idx) >= icounts.length());
David Zeuthen 17c4cc
     else
David Zeuthen 17c4cc
-	return ((EST_Litem *)idx == 0);
David Zeuthen 17c4cc
+	return (idx == 0);
David Zeuthen 17c4cc
 }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
-int EST_DiscreteProbDistribution::item_next(int idx) const
David Zeuthen 17c4cc
+EST_Litem *EST_DiscreteProbDistribution::item_next(EST_Litem *idx) const
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
     if (type == tprob_discrete)
David Zeuthen 17c4cc
-	return ++idx;
David Zeuthen 17c4cc
+	return (EST_Litem *)(((unsigned char *)idx)+1);
David Zeuthen 17c4cc
     else
David Zeuthen 17c4cc
-	return (int)next((EST_Litem *)idx);
David Zeuthen 17c4cc
+	return next(idx);
David Zeuthen 17c4cc
 }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
-const EST_String &EST_DiscreteProbDistribution::item_name(int idx) const
David Zeuthen 17c4cc
+const EST_String &EST_DiscreteProbDistribution::item_name(EST_Litem *idx) const
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
     if (type == tprob_discrete)
David Zeuthen 17c4cc
-	return discrete->name(idx);
David Zeuthen 17c4cc
+	return discrete->name(tprob_int(idx));
David Zeuthen 17c4cc
     else
David Zeuthen 17c4cc
-	return scounts.list((EST_Litem *)idx).k;
David Zeuthen 17c4cc
+	return scounts.list(idx).k;
David Zeuthen 17c4cc
 }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
-void EST_DiscreteProbDistribution::item_freq(int idx,EST_String &s,double &freq) const
David Zeuthen 17c4cc
+void EST_DiscreteProbDistribution::item_freq(EST_Litem *idx,EST_String &s,double &freq) const
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
     if (type == tprob_discrete)
David Zeuthen 17c4cc
     {
David Zeuthen 17c4cc
-	s = discrete->name(idx);
David Zeuthen 17c4cc
-	freq = icounts(idx);
David Zeuthen 17c4cc
+	s = discrete->name(tprob_int(idx));
David Zeuthen 17c4cc
+	freq = icounts(tprob_int(idx));
David Zeuthen 17c4cc
     }
David Zeuthen 17c4cc
     else
David Zeuthen 17c4cc
     {
David Zeuthen 17c4cc
-	s = scounts.list((EST_Litem *)idx).k;
David Zeuthen 17c4cc
-	freq = scounts.list((EST_Litem *)idx).v;
David Zeuthen 17c4cc
+	s = scounts.list(idx).k;
David Zeuthen 17c4cc
+	freq = scounts.list(idx).v;
David Zeuthen 17c4cc
     }
David Zeuthen 17c4cc
 }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
-void EST_DiscreteProbDistribution::item_prob(int idx,EST_String &s,double &prob) const
David Zeuthen 17c4cc
+void EST_DiscreteProbDistribution::item_prob(EST_Litem *idx,EST_String &s,double &prob) const
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
     if (type == tprob_discrete)
David Zeuthen 17c4cc
     {
David Zeuthen 17c4cc
-	prob = probability(idx);
David Zeuthen 17c4cc
-	s = discrete->name(idx);
David Zeuthen 17c4cc
+	prob = probability(tprob_int(idx));
David Zeuthen 17c4cc
+	s = discrete->name(tprob_int(idx));
David Zeuthen 17c4cc
     }
David Zeuthen 17c4cc
     else
David Zeuthen 17c4cc
     {
David Zeuthen 17c4cc
-	s = scounts.list((EST_Litem *)idx).k;
David Zeuthen 17c4cc
-	prob = (double)scounts.list((EST_Litem *)idx).v/num_samples;
David Zeuthen 17c4cc
+	s = scounts.list(idx).k;
David Zeuthen 17c4cc
+	prob = (double)scounts.list(idx).v/num_samples;
David Zeuthen 17c4cc
     }
David Zeuthen 17c4cc
 }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
 ostream & operator<<(ostream &s, const EST_DiscreteProbDistribution &pd)
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
     // Output best with probabilities
David Zeuthen 17c4cc
-    int i;
David Zeuthen 17c4cc
+    EST_Litem *i;
David Zeuthen 17c4cc
     double prob;
David Zeuthen 17c4cc
     double sum=0;
David Zeuthen 17c4cc
     EST_String name;
David Zeuthen 17c4cc
diff -ur festival/speech_tools.old/stats/EST_viterbi.cc festival/speech_tools/stats/EST_viterbi.cc
David Zeuthen 17c4cc
--- festival/speech_tools.old/stats/EST_viterbi.cc	2006-07-07 17:26:11.000000000 -0400
David Zeuthen 17c4cc
+++ festival/speech_tools/stats/EST_viterbi.cc	2006-09-27 09:19:35.000000000 -0400
David Zeuthen 17c4cc
@@ -165,7 +165,7 @@
David Zeuthen 17c4cc
 	return (a < b);
David Zeuthen 17c4cc
 }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
-static void init_dynamic_states(EST_VTPoint *p, EST_VTCandidate *cands)
David Zeuthen 17c4cc
+static int init_dynamic_states(EST_VTPoint *p, EST_VTCandidate *cands)
David Zeuthen 17c4cc
 {
David Zeuthen 17c4cc
     // In a special (hmm maybe not so special), the number of "states"
David Zeuthen 17c4cc
     // is the number of candidates
David Zeuthen 17c4cc
@@ -175,6 +175,8 @@
David Zeuthen 17c4cc
     for (i=0, c=cands; c != 0; c=c->next,i++)
David Zeuthen 17c4cc
 	c->pos = i;
David Zeuthen 17c4cc
     init_paths_array(p,i);
David Zeuthen 17c4cc
+    
David Zeuthen 17c4cc
+    return i;
David Zeuthen 17c4cc
 }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
 void EST_Viterbi_Decoder::set_pruning_parameters(float beam, float
David Zeuthen 17c4cc
diff -ur festival/speech_tools.old/stats/wagon/wagon_aux.cc festival/speech_tools/stats/wagon/wagon_aux.cc
David Zeuthen 17c4cc
--- festival/speech_tools.old/stats/wagon/wagon_aux.cc	2006-08-20 13:02:39.000000000 -0400
David Zeuthen 17c4cc
+++ festival/speech_tools/stats/wagon/wagon_aux.cc	2006-12-12 10:45:19.000000000 -0500
David Zeuthen 17c4cc
@@ -422,16 +422,19 @@
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
 #if 1
David Zeuthen 17c4cc
     /* simple distance */
David Zeuthen 17c4cc
-    for (j=wgn_VertexTrack_start; j<=wgn_VertexTrack_end; j++)
David Zeuthen 17c4cc
+    for (j=0; j
David Zeuthen 17c4cc
     {
David Zeuthen 17c4cc
-        b.reset();
David Zeuthen 17c4cc
-        for (pp=members.head(); pp != 0; pp=next(pp))
David Zeuthen 17c4cc
+        if (wgn_VertexFeats.a(0,j) > 0.0)
David Zeuthen 17c4cc
         {
David Zeuthen 17c4cc
-            i = members.item(pp);
David Zeuthen 17c4cc
-            b += wgn_VertexTrack.a(i,j);
David Zeuthen 17c4cc
+            b.reset();
David Zeuthen 17c4cc
+            for (pp=members.head(); pp != 0; pp=next(pp))
David Zeuthen 17c4cc
+            {
David Zeuthen 17c4cc
+                i = members.item(pp);
David Zeuthen 17c4cc
+                b += wgn_VertexTrack.a(i,j);
David Zeuthen 17c4cc
+            }
David Zeuthen 17c4cc
+            a += b.stddev();
David Zeuthen 17c4cc
+            count = b.samples();
David Zeuthen 17c4cc
         }
David Zeuthen 17c4cc
-        a += b.stddev();
David Zeuthen 17c4cc
-        count = b.samples();
David Zeuthen 17c4cc
     }
David Zeuthen 17c4cc
 #endif
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
@@ -440,26 +443,37 @@
David Zeuthen 17c4cc
     /* worse in listening experiments */
David Zeuthen 17c4cc
     EST_SuffStats **cs;
David Zeuthen 17c4cc
     int mmm;
David Zeuthen 17c4cc
-    cs = new EST_SuffStats *[wgn_VertexTrack_end+1];
David Zeuthen 17c4cc
-    for (j=0; j<=wgn_VertexTrack_end; j++)
David Zeuthen 17c4cc
-        cs[j] = new EST_SuffStats[wgn_VertexTrack_end+1];
David Zeuthen 17c4cc
+    cs = new EST_SuffStats *[wgn_VertexTrack.num_channels()+1];
David Zeuthen 17c4cc
+    for (j=0; j<=wgn_VertexTrack.num_channels(); j++)
David Zeuthen 17c4cc
+        cs[j] = new EST_SuffStats[wgn_VertexTrack.num_channels()+1];
David Zeuthen 17c4cc
     /* Find means for diagonal */
David Zeuthen 17c4cc
-    for (j=wgn_VertexTrack_start; j<=wgn_VertexTrack_end; j++)
David Zeuthen 17c4cc
+    for (j=0; j
David Zeuthen 17c4cc
     {
David Zeuthen 17c4cc
-        for (pp=members.head(); pp != 0; pp=next(pp))
David Zeuthen 17c4cc
-            cs[j][j] += wgn_VertexTrack.a(members.item(pp),j);
David Zeuthen 17c4cc
-    }
David Zeuthen 17c4cc
-    for (j=wgn_VertexTrack_start; j<=wgn_VertexTrack_end; j++)
David Zeuthen 17c4cc
-        for (i=j+1; i
David Zeuthen 17c4cc
+        if (wgn_VertexFeats.a(0,j) > 0.0)
David Zeuthen 17c4cc
+        {
David Zeuthen 17c4cc
             for (pp=members.head(); pp != 0; pp=next(pp))
David Zeuthen 17c4cc
+                cs[j][j] += wgn_VertexTrack.a(members.item(pp),j);
David Zeuthen 17c4cc
+        }
David Zeuthen 17c4cc
+    }
David Zeuthen 17c4cc
+    for (j=0; j
David Zeuthen 17c4cc
+    {
David Zeuthen 17c4cc
+        for (i=j+1; i
David Zeuthen 17c4cc
+            if (wgn_VertexFeats.a(0,j) > 0.0)
David Zeuthen 17c4cc
             {
David Zeuthen 17c4cc
-                mmm = members.item(pp);
David Zeuthen 17c4cc
-                cs[i][j] += (wgn_VertexTrack.a(mmm,i)-cs[j][j].mean())*
David Zeuthen 17c4cc
-                    (wgn_VertexTrack.a(mmm,j)-cs[j][j].mean());
David Zeuthen 17c4cc
-            }
David Zeuthen 17c4cc
-    for (j=wgn_VertexTrack_start; j<=wgn_VertexTrack_end; j++)
David Zeuthen 17c4cc
-        for (i=j+1; i
David Zeuthen 17c4cc
-            a += cs[i][j].stddev();
David Zeuthen 17c4cc
+                for (pp=members.head(); pp != 0; pp=next(pp))
David Zeuthen 17c4cc
+                {
David Zeuthen 17c4cc
+                    mmm = members.item(pp);
David Zeuthen 17c4cc
+                    cs[i][j] += (wgn_VertexTrack.a(mmm,i)-cs[j][j].mean())*
David Zeuthen 17c4cc
+                        (wgn_VertexTrack.a(mmm,j)-cs[j][j].mean());
David Zeuthen 17c4cc
+                }
David Zeuthen 17c4cc
+            }
David Zeuthen 17c4cc
+    }
David Zeuthen 17c4cc
+    for (j=0; j
David Zeuthen 17c4cc
+    {
David Zeuthen 17c4cc
+        for (i=j+1; i
David Zeuthen 17c4cc
+            if (wgn_VertexFeats.a(0,j) > 0.0)
David Zeuthen 17c4cc
+                a += cs[i][j].stddev();
David Zeuthen 17c4cc
+    }
David Zeuthen 17c4cc
     count = cs[0][0].samples();
David Zeuthen 17c4cc
 #endif
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
@@ -476,11 +490,12 @@
David Zeuthen 17c4cc
         for (qq=next(pp); qq != 0; qq=next(qq))
David Zeuthen 17c4cc
         {
David Zeuthen 17c4cc
             y = members.item(qq);
David Zeuthen 17c4cc
-            for (q=0.0,j=wgn_VertexTrack_start; j<=wgn_VertexTrack_end; j++)
David Zeuthen 17c4cc
-            {
David Zeuthen 17c4cc
-                d = wgn_VertexTrack(x,j)-wgn_VertexTrack(y,j);
David Zeuthen 17c4cc
-                q += d*d;
David Zeuthen 17c4cc
-            }
David Zeuthen 17c4cc
+            for (q=0.0,j=0; j
David Zeuthen 17c4cc
+                if (wgn_VertexFeats.a(0,j) > 0.0)
David Zeuthen 17c4cc
+                {
David Zeuthen 17c4cc
+                    d = wgn_VertexTrack(x,j)-wgn_VertexTrack(y,j);
David Zeuthen 17c4cc
+                    q += d*d;
David Zeuthen 17c4cc
+                }
David Zeuthen 17c4cc
             a += sqrt(q);
David Zeuthen 17c4cc
         }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
@@ -562,7 +577,7 @@
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
         /* a list of SuffStats on for each point in the trajectory */
David Zeuthen 17c4cc
         trajectory = new EST_SuffStats *[l];
David Zeuthen 17c4cc
-        width = wgn_VertexTrack_end+1;
David Zeuthen 17c4cc
+        width = wgn_VertexTrack.num_channels()+1;
David Zeuthen 17c4cc
         for (j=0; j
David Zeuthen 17c4cc
             trajectory[j] = new EST_SuffStats[width];
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
@@ -574,16 +589,22 @@
David Zeuthen 17c4cc
             for (ti=0,n=0.0; ti
David Zeuthen 17c4cc
             {
David Zeuthen 17c4cc
                 ni = (int)n;  // hmm floor or nint ??
David Zeuthen 17c4cc
-                for (j=wgn_VertexTrack_start; j<=wgn_VertexTrack_end; j++)
David Zeuthen 17c4cc
-                    trajectory[ti][j] += wgn_VertexTrack.a(s+ni,j);
David Zeuthen 17c4cc
+                for (j=0; j
David Zeuthen 17c4cc
+                {
David Zeuthen 17c4cc
+                    if (wgn_VertexFeats.a(0,j) > 0.0)
David Zeuthen 17c4cc
+                        trajectory[ti][j] += wgn_VertexTrack.a(s+ni,j);
David Zeuthen 17c4cc
+                }
David Zeuthen 17c4cc
             }
David Zeuthen 17c4cc
         }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
         /* find sum of sum of stddev for all coefs of all traj points */
David Zeuthen 17c4cc
         stdss.reset();
David Zeuthen 17c4cc
         for (ti=0; ti
David Zeuthen 17c4cc
-            for (j=wgn_VertexTrack_start+1; j<=wgn_VertexTrack_end; j++)
David Zeuthen 17c4cc
-                stdss += trajectory[ti][j].stddev();
David Zeuthen 17c4cc
+            for (j=0; j
David Zeuthen 17c4cc
+            {
David Zeuthen 17c4cc
+                if (wgn_VertexFeats.a(0,j) > 0.0)
David Zeuthen 17c4cc
+                    stdss += trajectory[ti][j].stddev();
David Zeuthen 17c4cc
+            }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
         // This is sum of all stddev * samples
David Zeuthen 17c4cc
         score = stdss.mean() * members.length();
David Zeuthen 17c4cc
@@ -597,7 +618,7 @@
David Zeuthen 17c4cc
         /* a list of SuffStats on for each point in the trajectory */
David Zeuthen 17c4cc
         trajectory = new EST_SuffStats *[l];
David Zeuthen 17c4cc
         for (j=0; j
David Zeuthen 17c4cc
-            trajectory[j] = new EST_SuffStats[wgn_VertexTrack_end+1];
David Zeuthen 17c4cc
+            trajectory[j] = new EST_SuffStats[wgn_VertexTrack.num_channels()+1];
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
         for (pp=members.head(); pp != 0; pp=next(pp))
David Zeuthen 17c4cc
         {   /* for each unit */
David Zeuthen 17c4cc
@@ -617,22 +638,26 @@
David Zeuthen 17c4cc
             for (ti=0,n=0.0; s1l > 0 && ti
David Zeuthen 17c4cc
             {
David Zeuthen 17c4cc
                 ni = s + (((int)n < s1l) ? (int)n : s1l - 1);
David Zeuthen 17c4cc
-                for (j=wgn_VertexTrack_start; j<=wgn_VertexTrack_end; j++)
David Zeuthen 17c4cc
-                    trajectory[ti][j] += wgn_VertexTrack.a(ni,j);
David Zeuthen 17c4cc
+                for (j=0; j
David Zeuthen 17c4cc
+                    if (wgn_VertexFeats.a(0,j) > 0.0)
David Zeuthen 17c4cc
+                        trajectory[ti][j] += wgn_VertexTrack.a(ni,j);
David Zeuthen 17c4cc
             }
David Zeuthen 17c4cc
             ti = l1; /* do it explicitly in case s1l < 1 */
David Zeuthen 17c4cc
-            for (j=wgn_VertexTrack_start; j<=wgn_VertexTrack_end; j++)
David Zeuthen 17c4cc
-                trajectory[ti][j] += -1;
David Zeuthen 17c4cc
+            for (j=0; j
David Zeuthen 17c4cc
+                if (wgn_VertexFeats.a(0,j) > 0.0)
David Zeuthen 17c4cc
+                    trajectory[ti][j] += -1;
David Zeuthen 17c4cc
             /* Second half */
David Zeuthen 17c4cc
             s += s1l+1;
David Zeuthen 17c4cc
             for (ti++,n=0.0; s2l > 0 && ti
David Zeuthen 17c4cc
             {
David Zeuthen 17c4cc
                 ni = s + (((int)n < s2l) ? (int)n : s2l - 1);
David Zeuthen 17c4cc
-                for (j=wgn_VertexTrack_start; j<=wgn_VertexTrack_end; j++)
David Zeuthen 17c4cc
-                    trajectory[ti][j] += wgn_VertexTrack.a(ni,j);
David Zeuthen 17c4cc
-            }
David Zeuthen 17c4cc
-            for (j=wgn_VertexTrack_start; j<=wgn_VertexTrack_end; j++)
David Zeuthen 17c4cc
-                trajectory[ti][j] += -2;
David Zeuthen 17c4cc
+                for (j=0; j
David Zeuthen 17c4cc
+                    if (wgn_VertexFeats.a(0,j) > 0.0)
David Zeuthen 17c4cc
+                        trajectory[ti][j] += wgn_VertexTrack.a(ni,j);
David Zeuthen 17c4cc
+            }
David Zeuthen 17c4cc
+            for (j=0; j
David Zeuthen 17c4cc
+                if (wgn_VertexFeats.a(0,j) > 0.0)
David Zeuthen 17c4cc
+                    trajectory[ti][j] += -2;
David Zeuthen 17c4cc
         }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
         /* find sum of sum of stddev for all coefs of all traj points */
David Zeuthen 17c4cc
@@ -640,12 +665,14 @@
David Zeuthen 17c4cc
         stdss.reset();
David Zeuthen 17c4cc
         m = 1.0/(float)l1;
David Zeuthen 17c4cc
         for (w=0.0,ti=0; ti
David Zeuthen 17c4cc
-            for (j=wgn_VertexTrack_start+1; j<=wgn_VertexTrack_end; j++)
David Zeuthen 17c4cc
+            for (j=0; j
David Zeuthen 17c4cc
+                if (wgn_VertexFeats.a(0,j) > 0.0)
David Zeuthen 17c4cc
                 stdss += trajectory[ti][j].stddev() * w;
David Zeuthen 17c4cc
         m = 1.0/(float)l2;
David Zeuthen 17c4cc
         for (w=1.0,ti++; ti
David Zeuthen 17c4cc
-            for (j=wgn_VertexTrack_start+1; j<=wgn_VertexTrack_end; j++)
David Zeuthen 17c4cc
-                stdss += trajectory[ti][j].stddev() * w;
David Zeuthen 17c4cc
+            for (j=0; j
David Zeuthen 17c4cc
+                if (wgn_VertexFeats.a(0,j) > 0.0)
David Zeuthen 17c4cc
+                    stdss += trajectory[ti][j].stddev() * w;
David Zeuthen 17c4cc
     
David Zeuthen 17c4cc
         // This is sum of all stddev * samples
David Zeuthen 17c4cc
         score = stdss.mean() * members.length();
David Zeuthen 17c4cc
@@ -824,25 +851,27 @@
David Zeuthen 17c4cc
             int bestp = 0;
David Zeuthen 17c4cc
             EST_SuffStats *cs;
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
-            cs = new EST_SuffStats [wgn_VertexTrack_end+1];
David Zeuthen 17c4cc
+            cs = new EST_SuffStats [wgn_VertexTrack.num_channels()+1];
David Zeuthen 17c4cc
             
David Zeuthen 17c4cc
-            for (j=wgn_VertexTrack_start; j<=wgn_VertexTrack_end; j++)
David Zeuthen 17c4cc
-            {
David Zeuthen 17c4cc
-                cs[j].reset();
David Zeuthen 17c4cc
-                for (p=imp.members.head(); p != 0; p=next(p))
David Zeuthen 17c4cc
+            for (j=0; j
David Zeuthen 17c4cc
+                if (wgn_VertexFeats.a(0,j) > 0.0)
David Zeuthen 17c4cc
                 {
David Zeuthen 17c4cc
-                    cs[j] += wgn_VertexTrack.a(imp.members.item(p),j);
David Zeuthen 17c4cc
+                    cs[j].reset();
David Zeuthen 17c4cc
+                    for (p=imp.members.head(); p != 0; p=next(p))
David Zeuthen 17c4cc
+                    {
David Zeuthen 17c4cc
+                        cs[j] += wgn_VertexTrack.a(imp.members.item(p),j);
David Zeuthen 17c4cc
+                    }
David Zeuthen 17c4cc
                 }
David Zeuthen 17c4cc
-            }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
             for (p=imp.members.head(); p != 0; p=next(p))
David Zeuthen 17c4cc
             {
David Zeuthen 17c4cc
-                for (x=0,j=wgn_VertexTrack_start; j<=wgn_VertexTrack_end; j++)
David Zeuthen 17c4cc
-                {
David Zeuthen 17c4cc
-                    d = (wgn_VertexTrack.a(imp.members.item(p),j)-cs[j].mean())
David Zeuthen 17c4cc
-                        /* / b.stddev() */ ;
David Zeuthen 17c4cc
-                    x += d*d;
David Zeuthen 17c4cc
-                }
David Zeuthen 17c4cc
+                for (x=0.0,j=0; j
David Zeuthen 17c4cc
+                    if (wgn_VertexFeats.a(0,j) > 0.0)
David Zeuthen 17c4cc
+                    {
David Zeuthen 17c4cc
+                        d = (wgn_VertexTrack.a(imp.members.item(p),j)-cs[j].mean())
David Zeuthen 17c4cc
+                        /* / cs[j].stddev() */ ;
David Zeuthen 17c4cc
+                        x += d*d;
David Zeuthen 17c4cc
+                    }
David Zeuthen 17c4cc
                 if (x < best)
David Zeuthen 17c4cc
                 {
David Zeuthen 17c4cc
                     bestp = imp.members.item(p);
David Zeuthen 17c4cc
@@ -853,7 +882,12 @@
David Zeuthen 17c4cc
             {
David Zeuthen 17c4cc
                 s << "( ";
David Zeuthen 17c4cc
                 s << wgn_VertexTrack.a(bestp,j);
David Zeuthen 17c4cc
-                s << " 0 "; // fake stddev
David Zeuthen 17c4cc
+                //                s << " 0 "; // fake stddev
David Zeuthen 17c4cc
+                s << " ";
David Zeuthen 17c4cc
+                if (finite(cs[j].stddev()))
David Zeuthen 17c4cc
+                    s << cs[j].stddev();
David Zeuthen 17c4cc
+                else
David Zeuthen 17c4cc
+                    s << "0";
David Zeuthen 17c4cc
                 s << " ) ";
David Zeuthen 17c4cc
                 if (j+1
David Zeuthen 17c4cc
                     s << " ";
David Zeuthen 17c4cc
@@ -900,7 +934,7 @@
David Zeuthen 17c4cc
     }
David Zeuthen 17c4cc
     else if (imp.t == wnim_class)
David Zeuthen 17c4cc
     {
David Zeuthen 17c4cc
-	int i;
David Zeuthen 17c4cc
+	EST_Litem *i;
David Zeuthen 17c4cc
 	EST_String name;
David Zeuthen 17c4cc
 	double prob;
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
diff -ur festival/speech_tools.old/stats/wagon/wagon.cc festival/speech_tools/stats/wagon/wagon.cc
David Zeuthen 17c4cc
--- festival/speech_tools.old/stats/wagon/wagon.cc	2006-08-11 18:35:19.000000000 -0400
David Zeuthen 17c4cc
+++ festival/speech_tools/stats/wagon/wagon.cc	2006-12-02 13:13:43.000000000 -0500
David Zeuthen 17c4cc
@@ -58,8 +58,7 @@
David Zeuthen 17c4cc
 WDataSet wgn_test_dataset;
David Zeuthen 17c4cc
 EST_FMatrix wgn_DistMatrix;
David Zeuthen 17c4cc
 EST_Track wgn_VertexTrack;
David Zeuthen 17c4cc
-int wgn_VertexTrack_start=0;
David Zeuthen 17c4cc
-int wgn_VertexTrack_end=24;
David Zeuthen 17c4cc
+EST_Track wgn_VertexFeats;
David Zeuthen 17c4cc
 EST_Track wgn_UnitTrack;
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
 int wgn_min_cluster_size = 50;
David Zeuthen 17c4cc
@@ -349,34 +348,35 @@
David Zeuthen 17c4cc
     {
David Zeuthen 17c4cc
 	leaf = tree.predict_node((*dataset(p)));
David Zeuthen 17c4cc
 	pos = dataset(p)->get_int_val(wgn_predictee);
David Zeuthen 17c4cc
-        for (j=wgn_VertexTrack_start; j<=wgn_VertexTrack_end; j++)
David Zeuthen 17c4cc
-        {
David Zeuthen 17c4cc
-            b.reset();
David Zeuthen 17c4cc
-            for (pp=leaf->get_impurity().members.head(); pp != 0; pp=next(pp))
David Zeuthen 17c4cc
+        for (j=0; j
David Zeuthen 17c4cc
+            if (wgn_VertexFeats.a(0,j) > 0.0)
David Zeuthen 17c4cc
             {
David Zeuthen 17c4cc
-                i = leaf->get_impurity().members.item(pp);
David Zeuthen 17c4cc
-                b += wgn_VertexTrack.a(i,j);
David Zeuthen 17c4cc
+                b.reset();
David Zeuthen 17c4cc
+                for (pp=leaf->get_impurity().members.head(); pp != 0; pp=next(pp))
David Zeuthen 17c4cc
+                {
David Zeuthen 17c4cc
+                    i = leaf->get_impurity().members.item(pp);
David Zeuthen 17c4cc
+                    b += wgn_VertexTrack.a(i,j);
David Zeuthen 17c4cc
+                }
David Zeuthen 17c4cc
+                predict = b.mean();
David Zeuthen 17c4cc
+                actual = wgn_VertexTrack.a(pos,j);
David Zeuthen 17c4cc
+                if (wgn_count_field == -1)
David Zeuthen 17c4cc
+                    count = 1.0;
David Zeuthen 17c4cc
+                else
David Zeuthen 17c4cc
+                    count = dataset(p)->get_flt_val(wgn_count_field);
David Zeuthen 17c4cc
+                x.cumulate(predict,count);
David Zeuthen 17c4cc
+                y.cumulate(actual,count);
David Zeuthen 17c4cc
+                /* Normalized the error by the standard deviation */
David Zeuthen 17c4cc
+                if (b.stddev() == 0)
David Zeuthen 17c4cc
+                    error = predict-actual;
David Zeuthen 17c4cc
+                else
David Zeuthen 17c4cc
+                    error = (predict-actual)/b.stddev();
David Zeuthen 17c4cc
+                error = predict-actual; /* awb_debug */
David Zeuthen 17c4cc
+                se.cumulate((error*error),count);
David Zeuthen 17c4cc
+                e.cumulate(fabs(error),count);
David Zeuthen 17c4cc
+                xx.cumulate(predict*predict,count);
David Zeuthen 17c4cc
+                yy.cumulate(actual*actual,count);
David Zeuthen 17c4cc
+                xy.cumulate(predict*actual,count);
David Zeuthen 17c4cc
             }
David Zeuthen 17c4cc
-            predict = b.mean();
David Zeuthen 17c4cc
-            actual = wgn_VertexTrack.a(pos,j);
David Zeuthen 17c4cc
-            if (wgn_count_field == -1)
David Zeuthen 17c4cc
-                count = 1.0;
David Zeuthen 17c4cc
-            else
David Zeuthen 17c4cc
-                count = dataset(p)->get_flt_val(wgn_count_field);
David Zeuthen 17c4cc
-            x.cumulate(predict,count);
David Zeuthen 17c4cc
-            y.cumulate(actual,count);
David Zeuthen 17c4cc
-            /* Normalized the error by the standard deviation */
David Zeuthen 17c4cc
-            if (b.stddev() == 0)
David Zeuthen 17c4cc
-                error = predict-actual;
David Zeuthen 17c4cc
-            else
David Zeuthen 17c4cc
-                error = (predict-actual)/b.stddev();
David Zeuthen 17c4cc
-            error = predict-actual; /* awb_debug */
David Zeuthen 17c4cc
-            se.cumulate((error*error),count);
David Zeuthen 17c4cc
-            e.cumulate(fabs(error),count);
David Zeuthen 17c4cc
-            xx.cumulate(predict*predict,count);
David Zeuthen 17c4cc
-            yy.cumulate(actual*actual,count);
David Zeuthen 17c4cc
-            xy.cumulate(predict*actual,count);
David Zeuthen 17c4cc
-        }
David Zeuthen 17c4cc
     }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
     // Pearson's product moment correlation coefficient
David Zeuthen 17c4cc
@@ -437,34 +437,35 @@
David Zeuthen 17c4cc
     {
David Zeuthen 17c4cc
 	leaf = tree.predict_node((*dataset(p)));
David Zeuthen 17c4cc
 	pos = dataset(p)->get_int_val(wgn_predictee);
David Zeuthen 17c4cc
-        for (j=wgn_VertexTrack_start; j<=wgn_VertexTrack_end; j++)
David Zeuthen 17c4cc
-        {
David Zeuthen 17c4cc
-            b.reset();
David Zeuthen 17c4cc
-            for (pp=leaf->get_impurity().members.head(); pp != 0; pp=next(pp))
David Zeuthen 17c4cc
+        for (j=0; j
David Zeuthen 17c4cc
+            if (wgn_VertexFeats.a(0,j) > 0.0)
David Zeuthen 17c4cc
             {
David Zeuthen 17c4cc
-                i = leaf->get_impurity().members.item(pp);
David Zeuthen 17c4cc
-                b += wgn_VertexTrack.a(i,j);
David Zeuthen 17c4cc
+                b.reset();
David Zeuthen 17c4cc
+                for (pp=leaf->get_impurity().members.head(); pp != 0; pp=next(pp))
David Zeuthen 17c4cc
+                {
David Zeuthen 17c4cc
+                    i = leaf->get_impurity().members.item(pp);
David Zeuthen 17c4cc
+                    b += wgn_VertexTrack.a(i,j);
David Zeuthen 17c4cc
+                }
David Zeuthen 17c4cc
+                predict = b.mean();
David Zeuthen 17c4cc
+                actual = wgn_VertexTrack.a(pos,j);
David Zeuthen 17c4cc
+                if (wgn_count_field == -1)
David Zeuthen 17c4cc
+                    count = 1.0;
David Zeuthen 17c4cc
+                else
David Zeuthen 17c4cc
+                    count = dataset(p)->get_flt_val(wgn_count_field);
David Zeuthen 17c4cc
+                x.cumulate(predict,count);
David Zeuthen 17c4cc
+                y.cumulate(actual,count);
David Zeuthen 17c4cc
+                /* Normalized the error by the standard deviation */
David Zeuthen 17c4cc
+                if (b.stddev() == 0)
David Zeuthen 17c4cc
+                    error = predict-actual;
David Zeuthen 17c4cc
+                else
David Zeuthen 17c4cc
+                    error = (predict-actual)/b.stddev();
David Zeuthen 17c4cc
+                error = predict-actual; /* awb_debug */
David Zeuthen 17c4cc
+                se.cumulate((error*error),count);
David Zeuthen 17c4cc
+                e.cumulate(fabs(error),count);
David Zeuthen 17c4cc
+                xx.cumulate(predict*predict,count);
David Zeuthen 17c4cc
+                yy.cumulate(actual*actual,count);
David Zeuthen 17c4cc
+                xy.cumulate(predict*actual,count);
David Zeuthen 17c4cc
             }
David Zeuthen 17c4cc
-            predict = b.mean();
David Zeuthen 17c4cc
-            actual = wgn_VertexTrack.a(pos,j);
David Zeuthen 17c4cc
-            if (wgn_count_field == -1)
David Zeuthen 17c4cc
-                count = 1.0;
David Zeuthen 17c4cc
-            else
David Zeuthen 17c4cc
-                count = dataset(p)->get_flt_val(wgn_count_field);
David Zeuthen 17c4cc
-            x.cumulate(predict,count);
David Zeuthen 17c4cc
-            y.cumulate(actual,count);
David Zeuthen 17c4cc
-            /* Normalized the error by the standard deviation */
David Zeuthen 17c4cc
-            if (b.stddev() == 0)
David Zeuthen 17c4cc
-                error = predict-actual;
David Zeuthen 17c4cc
-            else
David Zeuthen 17c4cc
-                error = (predict-actual)/b.stddev();
David Zeuthen 17c4cc
-            error = predict-actual; /* awb_debug */
David Zeuthen 17c4cc
-            se.cumulate((error*error),count);
David Zeuthen 17c4cc
-            e.cumulate(fabs(error),count);
David Zeuthen 17c4cc
-            xx.cumulate(predict*predict,count);
David Zeuthen 17c4cc
-            yy.cumulate(actual*actual,count);
David Zeuthen 17c4cc
-            xy.cumulate(predict*actual,count);
David Zeuthen 17c4cc
-        }
David Zeuthen 17c4cc
     }
David Zeuthen 17c4cc
 
David Zeuthen 17c4cc
     // Pearson's product moment correlation coefficient
David Zeuthen 17c4cc
diff -ur festival/speech_tools.old/.time-stamp festival/speech_tools/.time-stamp
David Zeuthen 17c4cc
--- festival/speech_tools.old/.time-stamp	2006-09-27 10:59:11.000000000 -0400
David Zeuthen 17c4cc
+++ festival/speech_tools/.time-stamp	2007-03-14 11:18:07.000000000 -0400
David Zeuthen 17c4cc
@@ -1,2 +1,2 @@
David Zeuthen 17c4cc
 speech_tools 1.2.96
David Zeuthen 17c4cc
-Wed Sep 27 10:59:11 EDT 2006
David Zeuthen 17c4cc
+Wed Mar 14 11:18:07 EDT 2007