Skip to content

Commit

Permalink
Fixes #1. Now master builds on 32 and 64 bits
Browse files Browse the repository at this point in the history
  • Loading branch information
zeehio committed Aug 1, 2014
1 parent dbcdd5d commit 62f99ec
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 124 deletions.
2 changes: 1 addition & 1 deletion base_class/EST_features_aux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ using namespace std;
defineGetFunction(EST_Features, val, EST_Val, getVal)
defineGetFunction(EST_Features, val, EST_String, getString)
defineGetFunction(EST_Features, val, float, getFloat)
defineGetFunction(EST_Features, val, int, getInteger)
defineGetFunction(EST_Features, val, ssize_t, getInteger)
VAL_REGISTER_FUNCPTR(pointer, void *)


Expand Down
68 changes: 34 additions & 34 deletions include/EST_Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class EST_Track : public EST_Featured {
void pad_breaks(); // put in extra breaks

int interp_value(float x, float f);
float interp_amp(float x, ssize_t c, float f);
float interp_amp(float x, int c, float f);
float estimate_shift(float x);
void copy(const EST_Track& a);

Expand All @@ -131,7 +131,7 @@ class EST_Track : public EST_Featured {
EST_Track(const EST_Track &a);

/// resizing constructor
EST_Track(ssize_t num_frames, ssize_t num_channels);
EST_Track(ssize_t num_frames, int num_channels);

/// resizing constructor
EST_Track(ssize_t num_frames, EST_StrList &map);
Expand All @@ -149,7 +149,7 @@ class EST_Track : public EST_Featured {
are kept, up to the limits imposed by the new number of frames
and channels. If the new track size is bigger, new positions
are filled with 0 */
void resize(ssize_t num_frames, ssize_t num_channels, bool preserve = 1);
void resize(ssize_t num_frames, int num_channels, bool preserve = 1);

/** resize the track to have `num_frames` and `num_channels`.
if `preserve` is set to 1, any existing values in the track
Expand Down Expand Up @@ -179,10 +179,10 @@ class EST_Track : public EST_Featured {
{ resize(n, EST_CURRENT, preserve); }

/// set the name of the channel.
void set_channel_name(const EST_String &name, ssize_t channel);
void set_channel_name(const EST_String &name, int channel);

/// set the name of the auxiliary channel.
void set_aux_channel_name(const EST_String &name, ssize_t channel);
void set_aux_channel_name(const EST_String &name, int channel);

/// copy everything but data

Expand Down Expand Up @@ -336,7 +336,7 @@ class EST_Track : public EST_Featured {
{ p_values.set_column(n, f, offset, num); }

/** copy channel buf into pre-allocated channel n of track */
void copy_channel_in(ssize_t c,
void copy_channel_in(int c,
const EST_Track &from, int from_c, int from_offset=0,
int offset=0, int num=EST_ALL)
{ p_values.set_column(c, from.p_values, from_c,
Expand Down Expand Up @@ -369,12 +369,12 @@ class EST_Track : public EST_Featured {
/** Return the position of channel `name` if it exists,
otherwise return -1.
*/
ssize_t channel_position(const char *name, int offset=0) const;
int channel_position(const char *name, int offset=0) const;

/** Return the position of channel `name` if it exists,
otherwise return -1.
*/
ssize_t channel_position(EST_String name, int offset=0) const
int channel_position(EST_String name, int offset=0) const
{ return channel_position((const char *)name, offset); }


Expand Down Expand Up @@ -412,13 +412,13 @@ class EST_Track : public EST_Featured {
//@{

/** return amplitude of frame i, channel c.*/
float &a(ssize_t i, ssize_t c=0L);
float a(ssize_t i, ssize_t c=0L) const;
float &a(ssize_t i, int c=0);
float a(ssize_t i, int c=0) const;

/** return amplitude of frame i, channel c with no bounds
checking. */
float &a_no_check(ssize_t i, ssize_t c=0) { return p_values.a_no_check(i,c); }
float a_no_check(ssize_t i, ssize_t c=0) const {return p_values.a_no_check(i,c);}
float &a_no_check(ssize_t i, int c=0) { return p_values.a_no_check(i,c); }
float a_no_check(ssize_t i, int c=0) const {return p_values.a_no_check(i,c);}

/** return amplitude of point i, in the channel named name plus
offset. If you have a track with say channels called F0 and
Expand All @@ -427,13 +427,13 @@ class EST_Track : public EST_Featured {
be accessed as t.a(45, "cepstrum", 5);
*/

float &a(ssize_t i, const char *name, int offset=0L);
float &a(ssize_t i, const char *name, int offset=0);

float a(ssize_t i, const char *name, int offset=0L) const
float a(ssize_t i, const char *name, int offset=0) const
{ return ((EST_Track *)this)->a(i, name, offset); }
float &a(ssize_t i, EST_String name, int offset=0L)
float &a(ssize_t i, EST_String name, int offset=0)
{ return a(i, (const char *)name, offset); }
float a(ssize_t i, EST_String name, int offset=0L) const
float a(ssize_t i, EST_String name, int offset=0) const
{ return ((EST_Track *)this)->a(i, (const char *)name, offset); }

/** return amplitude of time t, channel c. This can be used for
Expand All @@ -447,24 +447,24 @@ class EST_Track : public EST_Featured {
the end of a portion of track in which case the nearest
amplitude is returned.
*/
float &a(float t, ssize_t c=0L, EST_InterpType interp=it_nearest);
float a(float t, ssize_t c=0L, EST_InterpType interp=it_nearest) const
float &a(float t, int c=0, EST_InterpType interp=it_nearest);
float a(float t, int c=0, EST_InterpType interp=it_nearest) const
{ return ((EST_Track *)this)->a(t, c, interp); }


/** return amplitude of frame i, channel c. */
float &operator() (ssize_t i, ssize_t c) { return a(i,c); }
float &operator() (ssize_t i, int c) { return a(i,c); }
/** return amplitude of frame i, channel 0. */
float &operator() (ssize_t i) { return a(i,0L); }
float operator() (ssize_t i, ssize_t c) const { return a(i,c); }
float operator() (ssize_t i) const { return a(i,0L); }
float &operator() (ssize_t i) { return a(i,0); }
float operator() (ssize_t i, int c) const { return a(i,c); }
float operator() (ssize_t i) const { return a(i,0); }

/** return amplitude of frame nearest time t, channel c. */
float &operator() (float t, ssize_t c) {return a(t,c); }
float &operator() (float t, int c) {return a(t,c); }
/** return amplitude of frame nearest time t, channel 0. */
float &operator() (float t) {return a(t,0L); }
float operator() (float t, ssize_t c) const {return a(t,c); }
float operator() (float t) const {return a(t,0L); }
float &operator() (float t) {return a(t,0); }
float operator() (float t, int c) const {return a(t,c); }
float operator() (float t) const {return a(t,0); }

//@}

Expand Down Expand Up @@ -548,8 +548,8 @@ class EST_Track : public EST_Featured {

//@{

EST_Val &aux(ssize_t i, ssize_t c);
EST_Val &aux(ssize_t i, ssize_t c) const;
EST_Val &aux(ssize_t i, int c);
EST_Val &aux(ssize_t i, int c) const;

EST_Val &aux(ssize_t i, const char *name);
EST_Val aux(ssize_t i, const char *name) const
Expand Down Expand Up @@ -654,10 +654,10 @@ class EST_Track : public EST_Featured {
ssize_t length() const { return num_frames(); }

/// return number of channels in track
ssize_t num_channels() const {return p_values.num_columns();}
int num_channels() const {return p_values.num_columns();}

/// return number of auxiliary channels in track
ssize_t num_aux_channels() const {return p_aux.num_columns();}
int num_aux_channels() const {return p_aux.num_columns();}

void add_trailing_breaks();
void rm_trailing_breaks();
Expand Down Expand Up @@ -697,7 +697,7 @@ class EST_Track : public EST_Featured {

EST_TrackMap::P map() const { return p_map; }

ssize_t channel_position(EST_ChannelType type, int offset=0) const;
int channel_position(EST_ChannelType type, int offset=0) const;



Expand All @@ -721,11 +721,11 @@ class EST_Track : public EST_Featured {
EST_read_status load_channel_names(const EST_String name);
EST_write_status save_channel_names(const EST_String name);

const EST_String channel_name(ssize_t channel, const EST_ChannelNameMap &map, int strings_override=1) const;
const EST_String channel_name(ssize_t channel, int strings_override=1) const
const EST_String channel_name(int channel, const EST_ChannelNameMap &map, int strings_override=1) const;
const EST_String channel_name(int channel, int strings_override=1) const
{ return channel_name(channel, EST_default_channel_names, strings_override); }

const EST_String aux_channel_name(ssize_t channel) const
const EST_String aux_channel_name(int channel) const
{ return p_aux_names(channel);}

void resize(ssize_t num_frames, EST_TrackMap &map);
Expand Down
6 changes: 6 additions & 0 deletions include/EST_Val.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ class EST_Val {
/** Copy constructor for another EST_Val*/
EST_Val(const EST_Val &val);

#if (SSIZE_MAX != INT_MAX)
/** Copy constructor for an int*/
EST_Val(const int i)
{t=val_int; v.ival=i;}
#endif

/** Copy constructor for an ssize_t*/
EST_Val(const ssize_t i)
Expand Down Expand Up @@ -177,8 +179,10 @@ class EST_Val {

///@{

#if (SSIZE_MAX != INT_MAX)
/** Assignment of val to an int */
EST_Val &operator=(const int i) { t=val_int; v.ival=i; return *this;}
#endif

/** Assignment of val to an ssize_t */
EST_Val &operator=(ssize_t i) { t=val_int; v.ival=i; return *this;}
Expand Down Expand Up @@ -246,8 +250,10 @@ class EST_Val {
///@{
/** Automatically cast val as an ssize_t*/
operator ssize_t() const { return Int(); }
#if (SSIZE_MAX != INT_MAX)
/** Automatically cast val as an int*/
operator int() const { return Int(); }
#endif
/** Automatically cast val as an float*/
operator float() const { return Float(); }
/** Automatically cast val as an string*/
Expand Down
3 changes: 2 additions & 1 deletion include/ling_class/EST_Item.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,11 @@ class EST_Item
A separate function is provided for each permissible value type
*/
///@{
#if (SSIZE_MAX != INT_MAX)
/** set feature `name` to `val` */
void set(const EST_String &name, int ival)
{ EST_Val pv(ival);features().set_path(name, pv); }

#endif
/** set feature `name` to `val` */
void set(const EST_String &name, ssize_t ival)
{ EST_Val pv(ival);features().set_path(name, pv); }
Expand Down
4 changes: 2 additions & 2 deletions ling_class/EST_relation_compare.cc
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ void print_matrix_scores(EST_Relation &ref, EST_Relation &test, EST_FMatrix &a)
}
}

long int row_hit(EST_FMatrix &m, ssize_t r)
ssize_t row_hit(EST_FMatrix &m, ssize_t r)
{
ssize_t i;
for (i = 0; i < m.num_columns(); ++i)
Expand All @@ -883,7 +883,7 @@ long int row_hit(EST_FMatrix &m, ssize_t r)
}

// return the row index of the first positive entry in column c
long int column_hit(EST_FMatrix &m, ssize_t c)
ssize_t column_hit(EST_FMatrix &m, ssize_t c)
{
ssize_t i;
for (i = 0; i < m.num_rows(); ++i)
Expand Down
26 changes: 13 additions & 13 deletions main/wagon_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static int set_Vertex_Feats(EST_Track &wgn_VertexFeats,
EST_TokenStream ts;

for (i=0; i<wgn_VertexFeats.num_channels(); i++)
wgn_VertexFeats.a(0L,i) = 0.0;
wgn_VertexFeats.a(static_cast<ssize_t>(0),i) = 0.0;

ts.open_string(wagon_track_features);
ts.set_WhiteSpaceChars(",- ");
Expand All @@ -89,25 +89,25 @@ static int set_Vertex_Feats(EST_Track &wgn_VertexFeats,
if (token == "all")
{
for (i=0; i<wgn_VertexFeats.num_channels(); i++)
wgn_VertexFeats.a(0L,i) = 1.0;
wgn_VertexFeats.a(static_cast<ssize_t>(0),i) = 1.0;
break;
} else if ((ws == ",") || (ws == ""))
{
s = atoi(token.string());
wgn_VertexFeats.a(0L,s) = 1.0;
wgn_VertexFeats.a(static_cast<ssize_t>(0),s) = 1.0;
} else if (ws == "-")
{
if (token == "")
e = wgn_VertexFeats.num_channels()-1;
else
e = atoi(token.string());
for (i=s; i<=e && i<wgn_VertexFeats.num_channels(); i++)
wgn_VertexFeats.a(0L,i) = 1.0;
wgn_VertexFeats.a(static_cast<ssize_t>(0),i) = 1.0;
} else
{
printf("wagon: track_feats invalid: %s at position %ld\n",
printf("wagon: track_feats invalid: %s at position %lld\n",
(const char *)wagon_track_features,
ts.filepos());
(long long int) ts.filepos());
exit(-1);
}
}
Expand All @@ -123,7 +123,7 @@ static int wagon_main(int argc, char **argv)
EST_String wgn_oname;
ostream *wgn_coutput = 0;
float stepwise_limit = 0;
ssize_t feats_start=0, feats_end=0;
int feats_start=0, feats_end=0;
int i;

parse_command_line
Expand Down Expand Up @@ -268,7 +268,7 @@ static int wagon_main(int argc, char **argv)
wgn_VertexTrack.load(al.val("-track"));
wgn_VertexFeats.resize(1,wgn_VertexTrack.num_channels());
for (i=0; i<wgn_VertexFeats.num_channels(); i++)
wgn_VertexFeats.a(0L,i) = 1.0;
wgn_VertexFeats.a(static_cast<ssize_t>(0),i) = 1.0;
}

if (al.present("-track_start"))
Expand All @@ -277,13 +277,13 @@ static int wagon_main(int argc, char **argv)
if ((feats_start < 0) ||
(feats_start > wgn_VertexTrack.num_channels()))
{
printf("wagon: track_start invalid: %ld out of %ld channels\n",
printf("wagon: track_start invalid: %d out of %d channels\n",
feats_start,
wgn_VertexTrack.num_channels());
exit(-1);
}
for (i=0; i<feats_start; i++)
wgn_VertexFeats.a(0L,i) = 0.0; /* don't do feats up to start */
wgn_VertexFeats.a(static_cast<ssize_t>(0),i) = 0.0; /* don't do feats up to start */

}

Expand All @@ -293,14 +293,14 @@ static int wagon_main(int argc, char **argv)
if ((feats_end < feats_start) ||
(feats_end > wgn_VertexTrack.num_channels()))
{
printf("wagon: track_end invalid: %ld between start %ld out of %ld channels\n",
printf("wagon: track_end invalid: %d between start %d out of %d channels\n",
feats_end,
feats_start,
wgn_VertexTrack.num_channels());
exit(-1);
}
for (i=feats_end+1; i<wgn_VertexTrack.num_channels(); i++)
wgn_VertexFeats.a(0L,i) = 0.0; /* don't do feats after end */
wgn_VertexFeats.a(static_cast<ssize_t>(0),i) = 0.0; /* don't do feats after end */
}
if (al.present("-track_feats"))
{ /* overrides start and end numbers */
Expand All @@ -310,7 +310,7 @@ static int wagon_main(int argc, char **argv)

// printf("Track feats\n");
// for (i=0; i<wgn_VertexTrack.num_channels(); i++)
// if (wgn_VertexFeats.a(0L,i) > 0.0)
// if (wgn_VertexFeats.a(static_cast<ssize_t>(0),i) > 0.0)
// printf("%d ",i);
// printf("\n");

Expand Down
2 changes: 1 addition & 1 deletion sigpr/pitchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ void pm_to_f0(EST_Track &pm, EST_Track &f0)

for (ssize_t i = 0; i < f0.num_frames(); ++i)
{
f0.a(i, 0L) = 1.0 / (f0.t(i) - prev_pm);
f0.a(i, 0) = 1.0 / (f0.t(i) - prev_pm);
prev_pm = f0.t(i);
}
}
Expand Down
Loading

0 comments on commit 62f99ec

Please sign in to comment.