All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
FPCUTPT Class Reference

#include <pithsync.h>

Public Member Functions

 FPCUTPT ()
 
void setup (FPCUTPT cutpts[], inT16 array_origin, STATS *projection, inT16 zero_count, inT16 pitch, inT16 x, inT16 offset)
 
void assign (FPCUTPT cutpts[], inT16 array_origin, inT16 x, BOOL8 faking, BOOL8 mid_cut, inT16 offset, STATS *projection, float projection_scale, inT16 zero_count, inT16 pitch, inT16 pitch_error)
 
void assign_cheap (FPCUTPT cutpts[], inT16 array_origin, inT16 x, BOOL8 faking, BOOL8 mid_cut, inT16 offset, STATS *projection, float projection_scale, inT16 zero_count, inT16 pitch, inT16 pitch_error)
 
inT32 position ()
 
double cost_function ()
 
double squares ()
 
double sum ()
 
FPCUTPTprevious ()
 
inT16 cheap_cuts () const
 
inT16 index () const
 

Public Attributes

BOOL8 faked
 
BOOL8 terminal
 
inT16 fake_count
 

Detailed Description

Definition at line 29 of file pithsync.h.

Constructor & Destructor Documentation

FPCUTPT::FPCUTPT ( )
inline

Definition at line 32 of file pithsync.h.

32  { //empty
33  }

Member Function Documentation

void FPCUTPT::assign ( FPCUTPT  cutpts[],
inT16  array_origin,
inT16  x,
BOOL8  faking,
BOOL8  mid_cut,
inT16  offset,
STATS projection,
float  projection_scale,
inT16  zero_count,
inT16  pitch,
inT16  pitch_error 
)

Definition at line 98 of file pithsync.cpp.

110  {
111  int index; //test index
112  int balance_index; //for balance factor
113  inT16 balance_count; //ding factor
114  inT16 r_index; //test cut number
115  FPCUTPT *segpt; //segment point
116  inT32 dist; //from prev segment
117  double sq_dist; //squared distance
118  double mean; //mean pitch
119  double total; //total dists
120  double factor; //cost function
121  //half of pitch
122  inT16 half_pitch = pitch / 2 - 1;
123  uinT32 lead_flag; //new flag
124 
125  if (half_pitch > 31)
126  half_pitch = 31;
127  else if (half_pitch < 0)
128  half_pitch = 0;
129  lead_flag = 1 << half_pitch;
130 
131  back_balance = cutpts[x - 1 - array_origin].back_balance << 1;
132  back_balance &= lead_flag + lead_flag - 1;
133  if (projection->pile_count (x) > zero_count)
134  back_balance |= 1;
135  fwd_balance = cutpts[x - 1 - array_origin].fwd_balance >> 1;
136  if (projection->pile_count (x + half_pitch) > zero_count)
137  fwd_balance |= lead_flag;
138 
139  xpos = x;
140  cost = MAX_FLOAT32;
141  pred = NULL;
142  faked = faking;
143  terminal = FALSE;
144  region_index = 0;
146  for (index = x - pitch - pitch_error; index <= x - pitch + pitch_error;
147  index++) {
148  if (index >= array_origin) {
149  segpt = &cutpts[index - array_origin];
150  dist = x - segpt->xpos;
151  if (!segpt->terminal && segpt->fake_count < MAX_INT16) {
152  balance_count = 0;
153  if (textord_balance_factor > 0) {
155  lead_flag = back_balance ^ segpt->fwd_balance;
156  balance_count = 0;
157  while (lead_flag != 0) {
158  balance_count++;
159  lead_flag &= lead_flag - 1;
160  }
161  }
162  else {
163  for (balance_index = 0;
164  index + balance_index < x - balance_index;
165  balance_index++)
166  balance_count +=
167  (projection->pile_count (index + balance_index) <=
168  zero_count) ^ (projection->pile_count (x -
169  balance_index)
170  <= zero_count);
171  }
172  balance_count =
173  (inT16) (balance_count * textord_balance_factor /
174  projection_scale);
175  }
176  r_index = segpt->region_index + 1;
177  total = segpt->mean_sum + dist;
178  balance_count += offset;
179  sq_dist =
180  dist * dist + segpt->sq_sum + balance_count * balance_count;
181  mean = total / r_index;
182  factor = mean - pitch;
183  factor *= factor;
184  factor += sq_dist / (r_index) - mean * mean;
185  if (factor < cost && segpt->fake_count + faked <= fake_count) {
186  cost = factor; //find least cost
187  pred = segpt; //save path
188  mean_sum = total;
189  sq_sum = sq_dist;
190  fake_count = segpt->fake_count + faked;
191  mid_cuts = segpt->mid_cuts + mid_cut;
192  region_index = r_index;
193  }
194  }
195  }
196  }
197 }
inT16 index() const
Definition: pithsync.h:87
BOOL8 faked
Definition: pithsync.h:91
unsigned int uinT32
Definition: host.h:103
inT16 fake_count
Definition: pithsync.h:93
EXTERN bool textord_fast_pitch_test
Definition: topitch.cpp:48
EXTERN double textord_balance_factor
Definition: topitch.cpp:59
#define FALSE
Definition: capi.h:29
#define MAX_INT16
Definition: host.h:119
BOOL8 terminal
Definition: pithsync.h:92
#define MAX_FLOAT32
Definition: host.h:124
inT32 pile_count(inT32 value) const
Definition: statistc.h:78
#define NULL
Definition: host.h:144
short inT16
Definition: host.h:100
int inT32
Definition: host.h:102
void FPCUTPT::assign_cheap ( FPCUTPT  cutpts[],
inT16  array_origin,
inT16  x,
BOOL8  faking,
BOOL8  mid_cut,
inT16  offset,
STATS projection,
float  projection_scale,
inT16  zero_count,
inT16  pitch,
inT16  pitch_error 
)

Definition at line 206 of file pithsync.cpp.

218  {
219  int index; //test index
220  inT16 balance_count; //ding factor
221  inT16 r_index; //test cut number
222  FPCUTPT *segpt; //segment point
223  inT32 dist; //from prev segment
224  double sq_dist; //squared distance
225  double mean; //mean pitch
226  double total; //total dists
227  double factor; //cost function
228  //half of pitch
229  inT16 half_pitch = pitch / 2 - 1;
230  uinT32 lead_flag; //new flag
231 
232  if (half_pitch > 31)
233  half_pitch = 31;
234  else if (half_pitch < 0)
235  half_pitch = 0;
236  lead_flag = 1 << half_pitch;
237 
238  back_balance = cutpts[x - 1 - array_origin].back_balance << 1;
239  back_balance &= lead_flag + lead_flag - 1;
240  if (projection->pile_count (x) > zero_count)
241  back_balance |= 1;
242  fwd_balance = cutpts[x - 1 - array_origin].fwd_balance >> 1;
243  if (projection->pile_count (x + half_pitch) > zero_count)
244  fwd_balance |= lead_flag;
245 
246  xpos = x;
247  cost = MAX_FLOAT32;
248  pred = NULL;
249  faked = faking;
250  terminal = FALSE;
251  region_index = 0;
253  index = x - pitch;
254  if (index >= array_origin) {
255  segpt = &cutpts[index - array_origin];
256  dist = x - segpt->xpos;
257  if (!segpt->terminal && segpt->fake_count < MAX_INT16) {
258  balance_count = 0;
259  if (textord_balance_factor > 0) {
260  lead_flag = back_balance ^ segpt->fwd_balance;
261  balance_count = 0;
262  while (lead_flag != 0) {
263  balance_count++;
264  lead_flag &= lead_flag - 1;
265  }
266  balance_count = (inT16) (balance_count * textord_balance_factor
267  / projection_scale);
268  }
269  r_index = segpt->region_index + 1;
270  total = segpt->mean_sum + dist;
271  balance_count += offset;
272  sq_dist =
273  dist * dist + segpt->sq_sum + balance_count * balance_count;
274  mean = total / r_index;
275  factor = mean - pitch;
276  factor *= factor;
277  factor += sq_dist / (r_index) - mean * mean;
278  cost = factor; //find least cost
279  pred = segpt; //save path
280  mean_sum = total;
281  sq_sum = sq_dist;
282  fake_count = segpt->fake_count + faked;
283  mid_cuts = segpt->mid_cuts + mid_cut;
284  region_index = r_index;
285  }
286  }
287 }
inT16 index() const
Definition: pithsync.h:87
BOOL8 faked
Definition: pithsync.h:91
unsigned int uinT32
Definition: host.h:103
inT16 fake_count
Definition: pithsync.h:93
EXTERN double textord_balance_factor
Definition: topitch.cpp:59
#define FALSE
Definition: capi.h:29
#define MAX_INT16
Definition: host.h:119
BOOL8 terminal
Definition: pithsync.h:92
#define MAX_FLOAT32
Definition: host.h:124
inT32 pile_count(inT32 value) const
Definition: statistc.h:78
#define NULL
Definition: host.h:144
short inT16
Definition: host.h:100
int inT32
Definition: host.h:102
inT16 FPCUTPT::cheap_cuts ( ) const
inline

Definition at line 84 of file pithsync.h.

84  { //no of mi cuts
85  return mid_cuts;
86  }
double FPCUTPT::cost_function ( )
inline

Definition at line 72 of file pithsync.h.

72  {
73  return cost;
74  }
inT16 FPCUTPT::index ( ) const
inline

Definition at line 87 of file pithsync.h.

87  {
88  return region_index;
89  }
inT32 FPCUTPT::position ( )
inline

Definition at line 69 of file pithsync.h.

69  { //acces func
70  return xpos;
71  }
FPCUTPT* FPCUTPT::previous ( )
inline

Definition at line 81 of file pithsync.h.

81  {
82  return pred;
83  }
void FPCUTPT::setup ( FPCUTPT  cutpts[],
inT16  array_origin,
STATS projection,
inT16  zero_count,
inT16  pitch,
inT16  x,
inT16  offset 
)

Definition at line 41 of file pithsync.cpp.

49  {
50  //half of pitch
51  inT16 half_pitch = pitch / 2 - 1;
52  uinT32 lead_flag; //new flag
53  inT32 ind; //current position
54 
55  if (half_pitch > 31)
56  half_pitch = 31;
57  else if (half_pitch < 0)
58  half_pitch = 0;
59  lead_flag = 1 << half_pitch;
60 
61  pred = NULL;
62  mean_sum = 0;
63  sq_sum = offset * offset;
64  cost = sq_sum;
65  faked = FALSE;
66  terminal = FALSE;
67  fake_count = 0;
68  xpos = x;
69  region_index = 0;
70  mid_cuts = 0;
71  if (x == array_origin) {
72  back_balance = 0;
73  fwd_balance = 0;
74  for (ind = 0; ind <= half_pitch; ind++) {
75  fwd_balance >>= 1;
76  if (projection->pile_count (ind) > zero_count)
77  fwd_balance |= lead_flag;
78  }
79  }
80  else {
81  back_balance = cutpts[x - 1 - array_origin].back_balance << 1;
82  back_balance &= lead_flag + lead_flag - 1;
83  if (projection->pile_count (x) > zero_count)
84  back_balance |= 1;
85  fwd_balance = cutpts[x - 1 - array_origin].fwd_balance >> 1;
86  if (projection->pile_count (x + half_pitch) > zero_count)
87  fwd_balance |= lead_flag;
88  }
89 }
BOOL8 faked
Definition: pithsync.h:91
unsigned int uinT32
Definition: host.h:103
inT16 fake_count
Definition: pithsync.h:93
#define FALSE
Definition: capi.h:29
BOOL8 terminal
Definition: pithsync.h:92
inT32 pile_count(inT32 value) const
Definition: statistc.h:78
#define NULL
Definition: host.h:144
short inT16
Definition: host.h:100
int inT32
Definition: host.h:102
double FPCUTPT::squares ( )
inline

Definition at line 75 of file pithsync.h.

75  {
76  return sq_sum;
77  }
double FPCUTPT::sum ( )
inline

Definition at line 78 of file pithsync.h.

78  {
79  return mean_sum;
80  }

Member Data Documentation

inT16 FPCUTPT::fake_count

Definition at line 93 of file pithsync.h.

BOOL8 FPCUTPT::faked

Definition at line 91 of file pithsync.h.

BOOL8 FPCUTPT::terminal

Definition at line 92 of file pithsync.h.


The documentation for this class was generated from the following files: