127 cerr <<
"Requested setting of break value of the end of the array\n";
141 (void)strings_override;
186 s <<
"\t" << tr(i, j);
188 s <<
"\t" << tr.
aux(i, j);
218 if (new_num_frames<0)
221 if (new_num_channels<0)
243 static void map_to_channels(
EST_StrList &channel_map,
250 for (p = channel_map.
head(); p; p = p->
next())
259 cerr<<
"Ill formed coefficient range in map: " << b <<
"\n";
263 first = b.
after(
"-");
267 cerr<<
"Ill formed coefficient range in map: "<<first<<
"\n";
271 last = first.
after(
"+");
272 first = first.
before(
"+");
277 for (
ssize_t i = n_f; i < n_l; ++i)
279 channel_names.
append(type +
"_N");
289 map_to_channels(new_channels, x);
293 int new_num_channels;
294 new_num_channels = x.
length();
296 if (new_num_frames<0)
303 for (i = 0, p = x.
head(); p ; p = p->
next(), ++i)
319 int new_num_channels;
320 new_num_channels = new_aux_channels.
length();
325 for (i = 0, p = new_aux_channels.
head(); p ; p = p->
next(), ++i)
344 " channel EST_Track to "<<
num_channels() <<
" channel EST_Track\n";
349 float old_end =
end();
351 for (i = 0, j = old_num; i < a.
num_frames(); ++i, ++j)
374 cerr <<
"Error: Tried to add " << a.
num_frames() <<
375 " channel EST_Track to "<<
num_frames()<<
" channel EST_Track\n";
381 for (i = 0, j = old_num; i < a.
num_channels(); ++i, ++j)
414 cerr <<
"no channel '" << name <<
"'\n";
424 cerr <<
"no auxiliary channel '" << name <<
"' found\n";
438 #define EPSILON (0.0001) 442 static float ia = 0.0;
450 return a(static_cast<ssize_t>(0),c);
452 float n =
a(i,c), n1 =
a(i+1,c);
454 ia = n + (n1-n)*(t-tn)/(tn1-tn);
461 return a(static_cast<ssize_t>(0),c);
463 float n =
a(i,c), n1 =
a(i+1,c);
467 ia = n + (n1-n)*(t-tn)/(tn1-tn);
498 bmid = bst + (bend-bst)/2;
608 EST_error(
"Tried to take shift from non-fixed contour\n");
616 while ((j2 != 0) && (j2 != (j1 +1)));
623 EST_error(
"Couldn't determine shift size\n");
650 for (--i; i >= 0 ; --i)
681 n = (
int) rint(((
end())/ f_interval));
688 for (i = 0; i < n; ++i)
689 new_times[i] = (
float) ((i + 1) * f_interval);
691 for (i = 0; i < n; ++i)
693 new_is_break[i] = !
interp_value(new_times(i), f_interval);
695 new_values(i, j) = !new_is_break(i) ?
interp_amp(new_times(i), j, f_interval): 0.0;
708 float x1, x2, y1, y2, m;
711 if ((
p_times(i) + (fl / 2.0))> x)
733 m = (y2 - y1) / (x2 -x1);
734 return ((x - x1) * m) + y1;
749 if ((
p_times(i) + (fl / 2.0))> x)
765 if ((x <
p_times(p) + (cf / 2.0)) || (x >
p_times(n) - (cf / 2.0)))
778 for (i = j; i > 0; --i)
793 for(
ssize_t i=0; i<nframes; ++i )
801 for(
ssize_t i=0; i<nframes; ++i )
809 for(
ssize_t i=0; i<nframes; ++i )
832 while ((!new_is_break(j)) && (!
val(i + 1)))
864 for (
ssize_t i=start, j = 0; i <
end; ++i, ++j)
893 new_times.
resize(new_num);
922 EST_error(
"pad_breaks: Can only operate on fixed data\n");
932 for (i = 0; i < n; ++i)
934 new_times[i] = (float) (i *
shift());
936 new_values(k, i) = 0.0;
940 for (i = 0, j = s; j < n; ++i, ++j)
944 for (; new_times(j) <
p_times(i + 1); ++j);
969 static bool bounds_check(
const EST_Track &
t,
int f,
int c,
int set)
971 const char *what =
set?
"set" :
"access";
975 cerr <<
"Attempt to " << what <<
" frame " <<
f <<
" of " << t.
num_frames() <<
" frame track\n";
980 cerr <<
"Attempt to " << what <<
" channel " << c <<
" of " << t.
num_channels() <<
" channel track\n";
987 static bool bounds_check(
const EST_Track &t,
992 const char *what =
set?
"set" :
"access";
998 cerr <<
"Attempt to " << what <<
" frame " <<
f <<
" of " << t.
num_frames() <<
" frame track\n";
1003 cerr <<
"Attempt to " << what <<
" frame " <<
f+nf-1 <<
" of " << t.
num_frames() <<
" frame track\n";
1012 cerr <<
"Attempt to " << what <<
" channel " << c <<
" of " << t.
num_channels() <<
" channel track\n";
1017 cerr <<
"Attempt to " << what <<
" channel " << c+nc-1 <<
" of " << t.
num_channels() <<
" channel track\n";
1027 if (!bounds_check(*
this, i,c,0))
1054 cerr <<
"No such channel " << name << endl;
1061 int start_frame,
int nframes,
1062 const EST_String &start_chan_name,
int nchans)
1065 if (start_chan_name ==
"")
1069 EST_error(
"sub_track: No such channel %s\n",
1070 (
const char *)start_chan_name);
1072 sub_track(st, start_frame, nframes, start_chan, nchans);
1076 int start_frame,
int nframes,
1080 int start_chan, end_chan, nchans=0;
1083 EST_error(
"sub_track: No such channel %s\n",
1084 (
const char *)start_chan_name);
1086 if (end_chan_name ==
"")
1091 EST_error(
"sub_track: No such channel %s\n",
1092 (
const char*)end_chan_name);
1094 nchans = end_chan - start_chan + 1;
1097 sub_track(st, start_frame, nframes, start_chan, nchans);
1101 int start_frame,
int nframes,
1102 int start_chan,
int nchans)
1109 if (!bounds_check(*
this, start_frame, nframes, start_chan, nchans, 0))
1140 int start_frame,
int nframes,
1141 int start_chan,
int nchans)
const 1148 if (!bounds_check(*
this, start_frame, nframes, start_chan, nchans, 0))
1151 st.
resize(nframes, nchans);
1153 for (
int ff=0; ff<nframes; ff++)
1157 for (
int c=0; c<nchans; c++)
1161 for (
int c=0; c<nchans; c++)
1180 int f_len = frame_times.
length();
1182 st.
resize( f_len, nchans );
1184 for(
int i=0; i<f_len; ++i ){
1186 int source_index =
index(frame_times(i));
1191 for(
int c=0; c<nchans; c++ )
1204 int f_len = frame_indices.
length();
1206 st.
resize( f_len, nchans );
1210 for(
int i=0; i<f_len; ++i ){
1212 int source_index = frame_indices(i);
1214 if( source_index <= last_index ){
1219 for(
int c=0; c<nchans; c++ )
1236 EST_String save_type = (type ==
"") ? DEF_FILE_TYPE : type;
1242 cerr <<
"Unknown Track file type " << save_type << endl;
1250 cerr <<
"Can't save tracks to files type " << save_type << endl;
1254 return (*s_fun)(filename, *
this);
1263 cerr <<
"Unknown Track file type " << type << endl;
1272 cerr <<
"Can't save tracks to files type " << type << endl;
1275 return (*s_fun)(
fp, *
this);
1291 if (! info->recognise)
1299 stat = (*l_fun)(ts, *
this, ishift, startt);
1326 if (! info->recognise)
1334 stat = (*l_fun)(filename, *
this, ishift, startt);
1354 cerr <<
"Unknown Track file type " << type << endl;
1362 cerr <<
"Can't load tracks from file type" << type << endl;
1367 return (*l_fun)(filename, *
this, ishift, startt);
1374 if ((file=fopen(filename,
"wb"))==
NULL)
1388 static const int buffer_length = 100;
1389 char buffer[buffer_length];
1391 if ((file=fopen(filename,
"rb"))==
NULL)
1396 if (!fgets(buffer, buffer_length, file))
1399 buffer[strlen(buffer)-1] =
'\0';
1417 return a(t, c, interp);
1501 #if defined(INSTANTIATE_TEMPLATES) void default_channel_names()
bool single_break() const
short get(EST_ChannelType type) const
Get the position of a channel.
int num_aux_channels() const
return number of auxiliary channels in track
short last_channel(void) const
Returns the index of the last known channel.
int contains(const char *s, ssize_t pos=-1) const
Does it contain this substring?
EST_Track & operator+=(const EST_Track &a)
void copy_features(const EST_Featured &f)
ssize_t prev_non_break(ssize_t i) const
static EST_TNamedEnumI< EST_TrackFileType, TS_Info > ts_map
float end() const
return time of last value in track
The file was read in successfully.
A vector class for floating point numbers. EST_FVector x should be used instead of float *x wherever ...
void set_value(ssize_t i)
set frame i to be a value
void set_channel_name(const EST_String &name, int channel)
set the name of the channel.
EST_Track & operator=(const EST_Track &a)
void set_break(ssize_t i)
set frame i to be a break
EST_String name() const
name of track - redundant use access to features
int num_channels() const
return number of channels in track
void fill(const T &v)
Fill entire array will value v.
#define EST_TM_REFCOUNTED
Pass to creation function to turn on refcounting.
INLINE const T & a_no_check(ssize_t n) const
read-only const access operator: without bounds checking
EST_read_status Load_File(LoadTrackFileArgs)
ssize_t index_below(float x) const
return the frame index before time t
EST_String itoString(int n)
Make a EST_String object from an integer.
const T & a(ssize_t row, ssize_t col) const
void resize(ssize_t num_frames, int num_channels, bool preserve=1)
float & a_no_check(ssize_t i, int c=0)
const T & a(ssize_t n) const
ssize_t index(float t) const
return the frame index nearest time t
float & a(float t, int c=0, EST_InterpType interp=it_nearest)
EST_write_status Save_TokenStream(SaveTrac_TokenStreamArgs)
static const float default_frame_shift
ENUM token(VAL value) const
const EST_String DEF_FILE_TYPE
void sub_track(EST_Track &st, int start_frame=0, int nframes=EST_ALL, int start_chan=0, int nchans=EST_ALL)
EST_read_status load_channel_names(const EST_String name)
float interp_amp(float x, int c, float f)
An error occurred while reading.
void copy(const EST_Track &a)
int track_break(ssize_t i) const
return true if frame i is a break
int channel_position(const char *name, int offset=0) const
void assign_map(EST_TrackMap::P map)
EST_read_status load(const EST_String name, float ishift=0.0, float startt=0.0)
bool equal_space() const
return true if track has equal (i.e. fixed) frame spacing */
void resize(ssize_t n, int set=1)
float & t(ssize_t i=0)
return time position of frame i
void set(EST_ChannelType type, short pos)
Record the position of a channel.
float & a(ssize_t i, int c=0)
const char * name(ENUM tok, int n=0) const
INLINE ssize_t length() const
number of items in vector.
void copy_setup(const EST_Track &a)
copy everything but data
int Stringtoi(EST_String s)
Make an int from a EST_String. EST_String equivalent of atoi()
ssize_t next_non_break(ssize_t i) const
~EST_Track()
default destructor
static const int default_sample_rate
void set_file_type(EST_TrackFileType t)
The file was written successfully.
friend std::ostream & operator<<(std::ostream &s, const EST_Track &tr)
EST_write_status save(const EST_String name, const EST_String EST_filetype="")
void change_type(float nshift, bool single_break)
REDO.
void sub_matrix(EST_TMatrix< T > &sm, ssize_t r=0, ptrdiff_t numr=EST_ALL, ssize_t c=0, ptrdiff_t numc=EST_ALL)
Make the matrix sm a window into this matrix.
void resize_aux(EST_StrList &map, bool preserve=1)
The file exists but is not in the format specified.
void channel(EST_FVector &cv, ssize_t n, int startf=0, int nf=EST_ALL)
#define Instantiate_TIterator_T(CONTAINER, IP, ENTRY, TAG)
static EST_TNamedEnumI< EST_TrackFileType, Info > map
ssize_t num_frames() const
return number of frames in track
int matches(const char *e, ssize_t pos=0) const
Exactly match this string?
The file was not written successfully.
EST_Track()
Default constructor.
float start() const
return time of first value in track
EST_read_status Load_TokenStream(LoadTrack_TokenStreamArgs)
void append(const T &item)
add item onto end of list
void sub_vector(EST_TVector< T > &sv, int start_c=0, int len=-1)
Create a sub vector.
void add_trailing_breaks()
const EST_String channel_name(int channel, const EST_ChannelNameMap &map, int strings_override=1) const
float estimate_shift(float x)
EST_ChannelNameMap EST_default_channel_names
Definition of standard names we use for channels.
INFO & info(ENUM token) const
EST_write_status save_channel_names(const EST_String name)
EST_write_status Save_File(SaveTrackFileArgs)
void set_aux_channel_name(const EST_String &name, int channel)
set the name of the auxiliary channel.
void copy_sub_track_out(EST_Track &st, const EST_FVector &frame_times) const
EST_Val & aux(ssize_t i, int c)
EST_StrVector p_aux_names
int interp_value(float x, float f)
void rm_trailing_breaks()
int val(ssize_t i) const
return true if frame i is a value
void resize(ssize_t rows, ssize_t cols, ssize_t set=1)
INLINE const T & a_no_check(ssize_t row, ssize_t col) const
const access with no bounds check, care recommend
void resize(int rows, int cols, int set=1)
resize matrix
EST_String after(int pos, int len=1) const
Part after pos+len.
EST_String before(int pos, int len=0) const
Part before position.
int empty() const
returns true if no values are set in the frame
void frame(EST_FVector &fv, int n, int startf=0, int nf=EST_ALL)
void set_equal_space(bool t)
EST_Track & operator|=(const EST_Track &a)
EST_StrVector p_channel_names
void fill_time(float t, int start=1)
void copy_sub_track(EST_Track &st, int start_frame=0, int nframes=EST_ALL, int start_chan=0, int nchans=EST_ALL) const
void resize(int n, int set=1)
resize vector
const EST_String aux_channel_name(int channel) const
#define NO_SUCH_CHANNEL
Returned if we ask for a channel not in the map.
EST_TrackMap::P map() const
Value to return for errors, never occurs in TrackMaps.
Utility EST_String Functions header file.