Loading...
Searching...
No Matches
track_regression.cc
/************************************************************************/
/* */
/* Centre for Speech Technology Research */
/* University of Edinburgh, UK */
/* Copyright (c) 1996,1997 */
/* All Rights Reserved. */
/* */
/* Permission is hereby granted, free of charge, to use and distribute */
/* this software and its documentation without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of this work, and to */
/* permit persons to whom this work is furnished to do so, subject to */
/* the following conditions: */
/* 1. The code must retain the above copyright notice, this list of */
/* conditions and the following disclaimer. */
/* 2. Any modifications must be clearly marked as such. */
/* 3. Original authors' names are not deleted. */
/* 4. The authors' names are not used to endorse or promote products */
/* derived from this software without specific prior written */
/* permission. */
/* */
/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
/* THIS SOFTWARE. */
/* */
/*************************************************************************/
/* */
/* Author: Richard Caley (rjc@cstr.ed.ac.uk) */
/* Date: Fri May 9 1997 */
/* ------------------------------------------------------------------- */
/* Example of declaration and use of tracks. */
/* */
/*************************************************************************/
#include <iostream>
#include <cstdlib>
#include "EST_TrackMap.h"
#include "EST_Track.h"
void dump_track(EST_Track &tr, EST_String comment)
{
printf("[ Track %s\n", (const char *)comment);
for (int f=0; f<tr.num_frames(); f++)
if (tr.val(f))
{
printf(" %3d:\t%3.3f", f, tr.t(f));
for(int c=0; c<tr.num_channels(); c++)
printf("\t%3.3f", tr.a(f,c));
printf("\n");
}
else
printf(" BREAK\n");
printf("]\n");
}
int main(void)
{
EST_Track tr(20,2);
EST_Track pm(20,0);
// This is different on different architectures (of course)
// cout << "EST_Track size = " << sizeof(EST_Track) << " bytes.\n";
for(int i1=0; i1<tr.num_frames(); i1++)
for(int j1=0; j1<tr.num_channels(); j1++)
{
tr.a(i1,j1) = i1 + j1/100.0;
tr.t(i1) = i1*0.5;
pm.t(i1) = i1*1.5;
}
dump_track(tr, "Original track");
tr.rm_trailing_breaks();
dump_track(tr, "Breaks Trimmed");
for(int b=0; b<3; b++)
{
tr.set_break(b);
tr.set_break(10+b);
tr.set_break(tr.num_frames()-b-1);
}
dump_track(tr, "Breaks");
tr.rm_trailing_breaks();
dump_track(tr, "Breaks Trimmed");
tr.resize(tr.num_frames(), tr.num_channels());
dump_track(tr, "resized to same size");
EST_Track st, cpy, cpy2;
tr.sub_track(st, 3, 7, 0, EST_ALL);
dump_track(st, "Sub Track");
cpy = st;
dump_track(cpy, "Copied");
tr.copy_sub_track(cpy2 , 3, 7, 0, EST_ALL);
dump_track(cpy2, "Copied Directly");
dump_track(pm, "Pitch Marks");
pm.resize(10,EST_CURRENT);
dump_track(pm, "Resized Pitch Marks");
return(0);
}
EST_String
Definition EST_String.h:70
EST_Track
Definition EST_Track.h:89
EST_Track::copy_sub_track
void copy_sub_track(EST_Track &st, int start_frame=0, int nframes=EST_ALL, int start_chan=0, int nchans=EST_ALL) const
Definition EST_Track.cc:1136
EST_Track::t
float & t(int i=0)
return time position of frame i
Definition EST_Track.h:477
EST_Track::val
int val(int i) const
return true if frame i is a value
Definition EST_Track.cc:539
EST_Track::a
float & a(int i, int c=0)
Definition EST_Track.cc:1022
EST_Track::sub_track
void sub_track(EST_Track &st, int start_frame=0, int nframes=EST_ALL, int start_chan=0, int nchans=EST_ALL)
Definition EST_Track.cc:1097
EST_Track::num_channels
int num_channels() const
return number of channels in track
Definition EST_Track.h:656
EST_Track::num_frames
int num_frames() const
return number of frames in track
Definition EST_Track.h:650
EST_Track::resize
void resize(int num_frames, int num_channels, bool preserve=1)
Definition EST_Track.cc:211
EST_Track::set_break
void set_break(int i)
set frame i to be a break
Definition EST_Track.cc:122