~ubuntu-branches/ubuntu/jaunty/speech-tools/jaunty

« back to all changes in this revision

Viewing changes to speech_class/EST_TrackFile.cc

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Urlichs
  • Date: 2004-07-16 09:25:39 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040716092539-5p1tzif55b8j924e
Tags: 1:1.2.3-8
Added alaw processing code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
/*                   File I/O functions for EST_Track class              */
37
37
/*                                                                       */
38
38
/*=======================================================================*/
39
 
#include <fstream.h>
40
 
#include <iostream.h>
 
39
#include <fstream>
 
40
#include <iostream>
41
41
#include <stdlib.h>
42
42
#include <math.h>
43
43
#include <time.h>
170
170
    if (ishift < NEARLY_ZERO)
171
171
    {
172
172
      cerr<<
173
 
        "Error: Frame spacing must be specified for ascii track input\n";
 
173
        "Error: Frame spacing must be specified (or apparent frame shift nearly zero)\n";
174
174
      return misc_read_error;
175
175
    }
176
176
    // first read in as list
345
345
                                        EST_Track &tr, float ishift)
346
346
{
347
347
    EST_TokenStream ts;
 
348
    EST_read_status r;
348
349
    
349
350
    if (((filename == "-") ? ts.open(cin) : ts.open(filename)) != 0)
350
351
    {
354
355
    // set up the character constant values for this stream
355
356
    ts.set_SingleCharSymbols(";");
356
357
    tr.set_name(filename);
357
 
    return load_est_ts(ts, tr, ishift);
 
358
    r = load_est_ts(ts, tr, ishift);
 
359
 
 
360
    if ((r == format_ok) && (!ts.eof()))
 
361
    {
 
362
        cerr << "Not end of file, but expected it\n";
 
363
        return misc_read_error;
 
364
    }
 
365
    else
 
366
        return r;
358
367
}
359
368
 
360
369
static float get_float(EST_TokenStream &ts,int swap)
445
454
    for (i = 0; i < num_frames; ++i)
446
455
    {
447
456
        bool ok;
 
457
 
448
458
        // Read Times
449
459
        if (ascii)
450
 
          {
 
460
        {
 
461
            if (ts.eof())
 
462
            {
 
463
                cerr << "unexpected end of file when looking for " << num_frames-i << " more frame(s)" << endl;
 
464
                return misc_read_error;
 
465
            }
451
466
            tr.t(i) = ts.get().Float(ok);
452
467
            if (!ok)
453
468
                return misc_read_error;
454
 
          }
 
469
        }
455
470
        else
456
471
            tr.t(i) = get_float(ts,swap);
457
472
 
532
547
    if (ishift < NEARLY_ZERO)
533
548
    {
534
549
        cerr<<
535
 
            "Error: Frame spacing must be specified for ascii track input\n";
 
550
            "Error: Frame spacing must be specified (or apparent frame shift nearly zero)\n";
536
551
        return misc_read_error;
537
552
    }
538
553
    
555
570
    
556
571
    while (1)
557
572
    {
558
 
        t = ts.get_upto_eoln();
 
573
        t = EST_String(ts.get_upto_eoln());
559
574
        //      cout << "t=" << t << endl;
560
575
        if (t.contains("teaching output included"))
561
576
            teaching = 1;
562
577
        if (!t.contains(":"))
563
578
            break;
564
579
        str.open_string(t);
565
 
        k = str.get_upto(":");
566
 
        v = str.get_upto_eoln();
 
580
        k = EST_String(str.get_upto(":"));
 
581
        v = EST_String(str.get_upto_eoln());
567
582
        if (k == "No. of output units")
568
583
            num_channels = v.Int();
569
584
        if (k == "No. of patterns")