void Formant_drawSpeckles_inside (Formant me, Graphics g, double tmin, double tmax, double fmin, double fmax, double suppress_dB, double dotSize) { long itmin, itmax; double maximumIntensity = 0.0, minimumIntensity; if (tmax <= tmin) { tmin = my xmin; tmax = my xmax; } if (! Sampled_getWindowSamples (me, tmin, tmax, & itmin, & itmax)) return; Graphics_setWindow (g, tmin, tmax, fmin, fmax); for (long iframe = itmin; iframe <= itmax; iframe ++) { Formant_Frame frame = & my d_frames [iframe]; if (frame -> intensity > maximumIntensity) maximumIntensity = frame -> intensity; } if (maximumIntensity == 0.0 || suppress_dB <= 0.0) minimumIntensity = 0.0; /* Ignore. */ else minimumIntensity = maximumIntensity / pow (10.0, suppress_dB / 10.0); for (long iframe = itmin; iframe <= itmax; iframe ++) { Formant_Frame frame = & my d_frames [iframe]; double x = Sampled_indexToX (me, iframe); if (frame -> intensity < minimumIntensity) continue; for (long iformant = 1; iformant <= frame -> nFormants; iformant ++) { double frequency = frame -> formant [iformant]. frequency; if (frequency >= fmin && frequency <= fmax) Graphics_fillCircle_mm (g, x, frequency, dotSize); } } }
void Polygon_paintCircles (Polygon me, Graphics g, double xmin, double xmax, double ymin, double ymax, double diameter) { Graphics_setInner (g); setWindow (me, g, xmin, xmax, ymin, ymax); for (long i = 1; i <= my numberOfPoints; i ++) Graphics_fillCircle_mm (g, my x [i], my y [i], diameter); Graphics_unsetInner (g); }
void PitchTier_Pitch_draw (PitchTier me, Pitch uv, Graphics g, double tmin, double tmax, double fmin, double fmax, int nonPeriodicLineType, int garnish, const wchar *method) { long n = my points -> size, imin, imax, i; if (nonPeriodicLineType == 0) { PitchTier_draw (me, g, tmin, tmax, fmin, fmax, garnish, method); return; } if (tmax <= tmin) { tmin = my xmin; tmax = my xmax; } Graphics_setWindow (g, tmin, tmax, fmin, fmax); Graphics_setInner (g); imin = AnyTier_timeToHighIndex (me, tmin); imax = AnyTier_timeToLowIndex (me, tmax); if (n == 0) { } else if (imax < imin) { double fleft = RealTier_getValueAtTime (me, tmin); double fright = RealTier_getValueAtTime (me, tmax); Pitch_line (uv, g, tmin, fleft, tmax, fright, nonPeriodicLineType); } else for (i = imin; i <= imax; i ++) { RealPoint point = (RealPoint) my points -> item [i]; double t = point -> number, f = point -> value; Graphics_fillCircle_mm (g, t, f, 1); if (i == 1) Pitch_line (uv, g, tmin, f, t, f, nonPeriodicLineType); else if (i == imin) Pitch_line (uv, g, t, f, tmin, RealTier_getValueAtTime (me, tmin), nonPeriodicLineType); if (i == n) Pitch_line (uv, g, t, f, tmax, f, nonPeriodicLineType); else if (i == imax) Pitch_line (uv, g, t, f, tmax, RealTier_getValueAtTime (me, tmax), nonPeriodicLineType); else { RealPoint pointRight = (RealPoint) my points -> item [i + 1]; Pitch_line (uv, g, t, f, pointRight -> number, pointRight -> value, nonPeriodicLineType); } } Graphics_unsetInner (g); if (garnish) { Graphics_drawInnerBox (g); Graphics_textBottom (g, 1, L"Time (s)"); Graphics_marksBottom (g, 2, 1, 1, 0); Graphics_marksLeft (g, 2, 1, 1, 0); Graphics_textLeft (g, 1, L"Frequency (Hz)"); } }
static void Sampled_speckleInside (Sampled me, Graphics g, double xmin, double xmax, double ymin, double ymax, double speckle_mm, long ilevel, int unit) { Function_unidirectionalAutowindow (me, & xmin, & xmax); long ixmin, ixmax; Sampled_getWindowSamples (me, xmin, xmax, & ixmin, & ixmax); if (Function_isUnitLogarithmic (me, ilevel, unit)) { ymin = Function_convertStandardToSpecialUnit (me, ymin, ilevel, unit); ymax = Function_convertStandardToSpecialUnit (me, ymax, ilevel, unit); } if (ymax <= ymin) return; Graphics_setWindow (g, xmin, xmax, ymin, ymax); for (long ix = ixmin; ix <= ixmax; ix ++) { double value = Sampled_getValueAtSample (me, ix, ilevel, unit); if (NUMdefined (value)) { double x = Sampled_indexToX (me, ix); if (value >= ymin && value <= ymax) { Graphics_fillCircle_mm (g, x, value, speckle_mm); } } } }
void structFormantGridEditor :: v_draw () { FormantGrid grid = (FormantGrid) our data; Ordered tiers = our editingBandwidths ? grid -> bandwidths : grid -> formants; RealTier selectedTier = (RealTier) tiers -> item [selectedFormant]; double ymin = our editingBandwidths ? our p_bandwidthFloor : our p_formantFloor; double ymax = our editingBandwidths ? our p_bandwidthCeiling : our p_formantCeiling; Graphics_setColour (our d_graphics, Graphics_WHITE); Graphics_setWindow (our d_graphics, 0, 1, 0, 1); Graphics_fillRectangle (our d_graphics, 0, 1, 0, 1); Graphics_setWindow (our d_graphics, our d_startWindow, our d_endWindow, ymin, ymax); Graphics_setColour (our d_graphics, Graphics_RED); Graphics_line (our d_graphics, our d_startWindow, our ycursor, our d_endWindow, our ycursor); Graphics_setTextAlignment (our d_graphics, Graphics_RIGHT, Graphics_HALF); Graphics_text (our d_graphics, our d_startWindow, our ycursor, Melder_float (Melder_half (our ycursor))); Graphics_setColour (our d_graphics, Graphics_BLUE); Graphics_setTextAlignment (our d_graphics, Graphics_LEFT, Graphics_TOP); Graphics_text (our d_graphics, our d_endWindow, ymax, Melder_float (Melder_half (ymax)), U" Hz"); Graphics_setTextAlignment (our d_graphics, Graphics_LEFT, Graphics_HALF); Graphics_text (our d_graphics, our d_endWindow, ymin, Melder_float (Melder_half (ymin)), U" Hz"); Graphics_setLineWidth (our d_graphics, 1); Graphics_setColour (our d_graphics, Graphics_GREY); for (long iformant = 1; iformant <= grid -> formants -> size; iformant ++) if (iformant != our selectedFormant) { RealTier tier = (RealTier) tiers -> item [iformant]; long imin = AnyTier_timeToHighIndex (tier, our d_startWindow); long imax = AnyTier_timeToLowIndex (tier, our d_endWindow); long n = tier -> points -> size; if (n == 0) { } else if (imax < imin) { double yleft = RealTier_getValueAtTime (tier, our d_startWindow); double yright = RealTier_getValueAtTime (tier, our d_endWindow); Graphics_line (our d_graphics, our d_startWindow, yleft, our d_endWindow, yright); } else for (long i = imin; i <= imax; i ++) { RealPoint point = (RealPoint) tier -> points -> item [i]; double t = point -> number, y = point -> value; Graphics_fillCircle_mm (our d_graphics, t, y, 2); if (i == 1) Graphics_line (our d_graphics, our d_startWindow, y, t, y); else if (i == imin) Graphics_line (our d_graphics, t, y, our d_startWindow, RealTier_getValueAtTime (tier, our d_startWindow)); if (i == n) Graphics_line (our d_graphics, t, y, our d_endWindow, y); else if (i == imax) Graphics_line (our d_graphics, t, y, our d_endWindow, RealTier_getValueAtTime (tier, our d_endWindow)); else { RealPoint pointRight = (RealPoint) tier -> points -> item [i + 1]; Graphics_line (our d_graphics, t, y, pointRight -> number, pointRight -> value); } } } Graphics_setColour (our d_graphics, Graphics_BLUE); long ifirstSelected = AnyTier_timeToHighIndex (selectedTier, our d_startSelection); long ilastSelected = AnyTier_timeToLowIndex (selectedTier, our d_endSelection); long n = selectedTier -> points -> size; long imin = AnyTier_timeToHighIndex (selectedTier, our d_startWindow); long imax = AnyTier_timeToLowIndex (selectedTier, our d_endWindow); Graphics_setLineWidth (our d_graphics, 2); if (n == 0) { Graphics_setTextAlignment (our d_graphics, Graphics_CENTRE, Graphics_HALF); Graphics_text (our d_graphics, 0.5 * (our d_startWindow + our d_endWindow), 0.5 * (ymin + ymax), U"(no points in selected formant tier)"); } else if (imax < imin) { double yleft = RealTier_getValueAtTime (selectedTier, our d_startWindow); double yright = RealTier_getValueAtTime (selectedTier, our d_endWindow); Graphics_line (our d_graphics, our d_startWindow, yleft, our d_endWindow, yright); } else for (long i = imin; i <= imax; i ++) { RealPoint point = (RealPoint) selectedTier -> points -> item [i]; double t = point -> number, y = point -> value; if (i >= ifirstSelected && i <= ilastSelected) Graphics_setColour (our d_graphics, Graphics_RED); Graphics_fillCircle_mm (our d_graphics, t, y, 3); Graphics_setColour (our d_graphics, Graphics_BLUE); if (i == 1) Graphics_line (our d_graphics, our d_startWindow, y, t, y); else if (i == imin) Graphics_line (our d_graphics, t, y, our d_startWindow, RealTier_getValueAtTime (selectedTier, our d_startWindow)); if (i == n) Graphics_line (our d_graphics, t, y, our d_endWindow, y); else if (i == imax) Graphics_line (our d_graphics, t, y, our d_endWindow, RealTier_getValueAtTime (selectedTier, our d_endWindow)); else { RealPoint pointRight = (RealPoint) selectedTier -> points -> item [i + 1]; Graphics_line (our d_graphics, t, y, pointRight -> number, pointRight -> value); } } Graphics_setLineWidth (our d_graphics, 1); Graphics_setColour (our d_graphics, Graphics_BLACK); }
void structPitchEditor :: v_draw () { Pitch pitch = (Pitch) our data; long it, it1, it2; double dyUnv, dyIntens; Graphics_setWindow (our d_graphics, 0, 1, 0, 1); Graphics_setColour (our d_graphics, Graphics_WHITE); Graphics_fillRectangle (our d_graphics, 0, 1, 0, 1); Graphics_setColour (our d_graphics, Graphics_BLACK); Graphics_rectangle (our d_graphics, 0, 1, 0, 1); dyUnv = Graphics_dyMMtoWC (our d_graphics, HEIGHT_UNV); dyIntens = Graphics_dyMMtoWC (our d_graphics, HEIGHT_INTENS); Sampled_getWindowSamples (pitch, our d_startWindow, our d_endWindow, & it1, & it2); /* * Show pitch. */ { long df = pitch -> ceiling > 10000 ? 2000 : pitch -> ceiling > 5000 ? 1000 : pitch -> ceiling > 2000 ? 500 : pitch -> ceiling > 800 ? 200 : pitch -> ceiling > 400 ? 100 : 50; double radius; Graphics_Viewport previous; previous = Graphics_insetViewport (our d_graphics, 0, 1, dyUnv, 1 - dyIntens); Graphics_setWindow (our d_graphics, our d_startWindow, our d_endWindow, 0, pitch -> ceiling); radius = Graphics_dxMMtoWC (our d_graphics, RADIUS); /* Horizontal hair at current pitch. */ if (our d_startSelection == our d_endSelection && our d_startSelection >= our d_startWindow && our d_startSelection <= our d_endWindow) { double f = Pitch_getValueAtTime (pitch, our d_startSelection, kPitch_unit_HERTZ, Pitch_LINEAR); if (NUMdefined (f)) { Graphics_setColour (our d_graphics, Graphics_RED); Graphics_line (our d_graphics, our d_startWindow - radius, f, our d_endWindow, f); Graphics_setTextAlignment (our d_graphics, Graphics_RIGHT, Graphics_HALF); Graphics_text1 (our d_graphics, our d_startWindow - radius, f, Melder_fixed (f, 2)); } } /* Horizontal scaling lines. */ Graphics_setColour (our d_graphics, Graphics_BLUE); Graphics_setLineType (our d_graphics, Graphics_DOTTED); Graphics_setTextAlignment (our d_graphics, Graphics_LEFT, Graphics_HALF); for (long f = df; f <= pitch -> ceiling; f += df) { Graphics_line (our d_graphics, our d_startWindow, f, our d_endWindow, f); Graphics_text2 (our d_graphics, our d_endWindow + radius/2, f, Melder_integer (f), L" Hz"); } Graphics_setLineType (our d_graphics, Graphics_DRAWN); /* Show candidates. */ for (it = it1; it <= it2; it ++) { Pitch_Frame frame = & pitch -> frame [it]; double t = Sampled_indexToX (pitch, it); double f = frame -> candidate [1]. frequency; if (f > 0.0 && f < pitch -> ceiling) { Graphics_setColour (our d_graphics, Graphics_MAGENTA); Graphics_fillCircle_mm (our d_graphics, t, f, RADIUS * 2); } Graphics_setColour (our d_graphics, Graphics_BLACK); Graphics_setTextAlignment (our d_graphics, Graphics_CENTRE, Graphics_HALF); for (int icand = 1; icand <= frame -> nCandidates; icand ++) { int strength = (int) floor (10 * frame -> candidate [icand]. strength + 0.5); f = frame -> candidate [icand]. frequency; if (strength > 9) strength = 9; if (f > 0 && f <= pitch -> ceiling) Graphics_text1 (our d_graphics, t, f, Melder_integer (strength)); } } Graphics_resetViewport (our d_graphics, previous); } /* * Show intensity. */ { Graphics_Viewport previous = Graphics_insetViewport (our d_graphics, 0, 1, 1 - dyIntens, 1); Graphics_setWindow (our d_graphics, our d_startWindow, our d_endWindow, 0, 1); Graphics_setColour (our d_graphics, Graphics_BLACK); Graphics_setTextAlignment (our d_graphics, Graphics_RIGHT, Graphics_HALF); Graphics_text (our d_graphics, our d_startWindow, 0.5, L"intens"); Graphics_setTextAlignment (our d_graphics, Graphics_LEFT, Graphics_HALF); Graphics_text (our d_graphics, our d_endWindow, 0.5, L"intens"); Graphics_setTextAlignment (our d_graphics, Graphics_CENTRE, Graphics_HALF); for (it = it1; it <= it2; it ++) { Pitch_Frame frame = & pitch -> frame [it]; double t = Sampled_indexToX (pitch, it); int strength = (int) floor (10 * frame -> intensity + 0.5); // map 0.0-1.0 to 0-9 if (strength > 9) strength = 9; Graphics_text1 (our d_graphics, t, 0.5, Melder_integer (strength)); } Graphics_resetViewport (our d_graphics, previous); } if (it1 > 1) it1 -= 1; if (it2 < pitch -> nx) it2 += 1; /* * Show voicelessness. */ { Graphics_Viewport previous = Graphics_insetViewport (our d_graphics, 0, 1, 0, dyUnv); Graphics_setColour (our d_graphics, Graphics_BLUE); Graphics_line (our d_graphics, our d_startWindow, 1, our d_endWindow, 1); Graphics_setTextAlignment (our d_graphics, Graphics_RIGHT, Graphics_HALF); Graphics_text (our d_graphics, our d_startWindow, 0.5, L"Unv"); Graphics_setTextAlignment (our d_graphics, Graphics_LEFT, Graphics_HALF); Graphics_text (our d_graphics, our d_endWindow, 0.5, L"Unv"); for (it = it1; it <= it2; it ++) { Pitch_Frame frame = & pitch -> frame [it]; double t = Sampled_indexToX (pitch, it), tleft = t - 0.5 * pitch -> dx, tright = t + 0.5 * pitch -> dx; double f = frame -> candidate [1]. frequency; if ((f > 0.0 && f < pitch -> ceiling) || tright <= our d_startWindow || tleft >= our d_endWindow) continue; if (tleft < our d_startWindow) tleft = our d_startWindow; if (tright > our d_endWindow) tright = our d_endWindow; Graphics_fillRectangle (our d_graphics, tleft, tright, 0, 1); } Graphics_setColour (our d_graphics, Graphics_BLACK); Graphics_resetViewport (our d_graphics, previous); } }
void Vector_draw (Vector me, Graphics g, double *pxmin, double *pxmax, double *pymin, double *pymax, double defaultDy, const wchar_t *method) { bool xreversed = *pxmin > *pxmax, yreversed = *pymin > *pymax; if (xreversed) { double temp = *pxmin; *pxmin = *pxmax; *pxmax = temp; } if (yreversed) { double temp = *pymin; *pymin = *pymax; *pymax = temp; } long ixmin, ixmax, ix; /* * Automatic domain. */ if (*pxmin == *pxmax) { *pxmin = my xmin; *pxmax = my xmax; } /* * Domain expressed in sample numbers. */ Matrix_getWindowSamplesX (me, *pxmin, *pxmax, & ixmin, & ixmax); /* * Automatic vertical range. */ if (*pymin == *pymax) { Matrix_getWindowExtrema (me, ixmin, ixmax, 1, 1, pymin, pymax); if (*pymin == *pymax) { *pymin -= defaultDy; *pymax += defaultDy; } } /* * Set coordinates for drawing. */ Graphics_setInner (g); Graphics_setWindow (g, xreversed ? *pxmax : *pxmin, xreversed ? *pxmin : *pxmax, yreversed ? *pymax : *pymin, yreversed ? *pymin : *pymax); if (wcsstr (method, L"bars") || wcsstr (method, L"Bars")) { for (ix = ixmin; ix <= ixmax; ix ++) { double x = Sampled_indexToX (me, ix); double y = my z [1] [ix]; double left = x - 0.5 * my dx, right = x + 0.5 * my dx; if (y > *pymax) y = *pymax; if (left < *pxmin) left = *pxmin; if (right > *pxmax) right = *pxmax; Graphics_line (g, left, y, right, y); Graphics_line (g, left, y, left, *pymin); Graphics_line (g, right, y, right, *pymin); } } else if (wcsstr (method, L"poles") || wcsstr (method, L"Poles")) { for (ix = ixmin; ix <= ixmax; ix ++) { double x = Sampled_indexToX (me, ix); Graphics_line (g, x, 0, x, my z [1] [ix]); } } else if (wcsstr (method, L"speckles") || wcsstr (method, L"Speckles")) { for (ix = ixmin; ix <= ixmax; ix ++) { double x = Sampled_indexToX (me, ix); Graphics_fillCircle_mm (g, x, my z [1] [ix], 1.0); } } else { /* * The default: draw as a curve. */ Graphics_function (g, my z [1], ixmin, ixmax, Matrix_columnToX (me, ixmin), Matrix_columnToX (me, ixmax)); } Graphics_unsetInner (g); }