/* push a sample into an allpass filter and return the sample falling out */ rev_t allp_run(rev_t insample, ALLP_FILTER * allp) { rev_t outsample; rev_t pushin; pushin = allp->in_gain * allp->fb_gain * insample + allp->fb_gain * allp->last_out; #ifdef REVERB_CALC_FLOAT pushin = DENORM(pushin); #endif outsample = push_buffer(pushin, allp->ringbuffer, allp->buflen, allp->buffer_pos); #ifdef REVERB_CALC_FLOAT outsample = DENORM(outsample); #endif allp->last_out = outsample; return outsample; }
/* push a sample into a comb filter and return the sample falling out */ rev_t comb_run(rev_t insample, COMB_FILTER * comb) { rev_t outsample; rev_t pushin; pushin = comb->fb_gain * insample + biquad_run(comb->filter, comb->fb_gain * comb->last_out); #ifdef REVERB_CALC_FLOAT pushin = DENORM(pushin); #endif outsample = push_buffer(pushin, comb->ringbuffer, comb->buflen, comb->buffer_pos); #ifdef REVERB_CALC_FLOAT outsample = DENORM(outsample); #endif comb->last_out = outsample; return outsample; }
PBLOB *PBLOB::baseline_normalise( //normalize blob ROW *row, //row it came from DENORM *denorm //inverse mapping ) { TBOX blob_box = bounding_box (); float x_centre = (blob_box.left () + blob_box.right ()) / 2.0; PBLOB *bn_blob; //copied blob *denorm = DENORM (x_centre, bln_x_height / row->x_height (), row); bn_blob = new PBLOB; //get one *bn_blob = *this; //deep copy bn_blob->move (FCOORD (-denorm->origin (), -row->base_line (x_centre))); bn_blob->scale (denorm->scale ()); bn_blob->move (FCOORD (0.0, bln_baseline_offset)); return bn_blob; }
// Normalize in-place and record the normalization in the DENORM. void TWERD::Normalize(ROW* row, float x_height, bool numeric_mode, DENORM* denorm) { TBOX word_box = bounding_box(); DENORM antidote((word_box.left() + word_box.right()) / 2.0, kBlnXHeight / x_height, row); if (row == NULL) { antidote = DENORM(antidote.origin(), antidote.scale(), 0.0, word_box.bottom(), 0, NULL, false, NULL); } int num_segments = 0; DENORM_SEG *segs = new DENORM_SEG[NumBlobs()]; for (TBLOB* blob = blobs; blob != NULL; blob = blob->next) { TBOX blob_box = blob->bounding_box(); ICOORD translation(-static_cast<int>(floor(antidote.origin() + 0.5)), -blob_box.bottom()); float factor = antidote.scale(); if (numeric_mode) { factor = ClipToRange(kBlnXHeight * 4.0f / (3 * blob_box.height()), factor, factor * 1.5f); segs[num_segments].xstart = blob->bounding_box().left(); segs[num_segments].ycoord = blob_box.bottom(); segs[num_segments++].scale_factor = factor; } else { float blob_x_center = (blob_box.left() + blob_box.right()) / 2.0; float y_shift = antidote.yshift_at_orig_x(blob_x_center); translation.set_y(-static_cast<int>(floor(y_shift + 0.5))); } blob->Move(translation); blob->Scale(factor); blob->Move(ICOORD(0, kBlnBaselineOffset)); } if (num_segments > 0) { antidote.set_segments(segs, num_segments); } delete [] segs; if (denorm != NULL) *denorm = antidote; }