void CC_drawC0 (I, Graphics g, double xmin, double xmax, double ymin, double ymax, int garnish) { iam (CC); (void) garnish; if (xmin >= xmax) { xmin = my xmin; xmax = my xmax; } long bframe, eframe; (void) Sampled_getWindowSamples (me, xmin, xmax, &bframe, &eframe); autoNUMvector<double> c (bframe, eframe); for (long i = bframe; i <= eframe; i++) { CC_Frame cf = & my frame[i]; c[i] = cf -> c0; } if (ymin >= ymax) { NUMvector_extrema (c.peek(), bframe, eframe, &ymin, &ymax); if (ymax <= ymin) { ymin -= 1.0; ymax += 1.0; } } else { NUMvector_clip (c.peek(), bframe, eframe, ymin, ymax); } Graphics_setInner (g); Graphics_setWindow (g, xmin, xmax, ymin, ymax); Graphics_function (g, c.peek(), bframe, eframe, xmin, xmax); Graphics_unsetInner (g); }
void Minimizer_drawHistory (Minimizer me, Graphics g, long iFrom, long iTo, double hmin, double hmax, int garnish) { if (! my history) { return; } if (iTo <= iFrom) { iFrom = 1; iTo = my iteration; } long itmin = iFrom, itmax = iTo; if (itmin < 1) { itmin = 1; } if (itmax > my iteration) { itmax = my iteration; } if (hmax <= hmin) { NUMvector_extrema (my history, itmin, itmax, & hmin, & hmax); } if (hmax <= hmin) { hmin -= 0.5 * fabs (hmin); hmax += 0.5 * fabs (hmax); } Graphics_setInner (g); Graphics_setWindow (g, iFrom, iTo, hmin, hmax); Graphics_function (g, my history, itmin, itmax, itmin, itmax); Graphics_unsetInner (g); if (garnish) { Graphics_drawInnerBox (g); Graphics_textBottom (g, true, U"Number of iterations"); Graphics_marksBottom (g, 2, true, true, false); Graphics_marksLeft (g, 2, true, true, false); } }
void LineSpectralFrequencies_drawFrequencies (LineSpectralFrequencies me, Graphics g, double tmin, double tmax, double fmin, double fmax, bool garnish) { if (tmax <= tmin) { tmin = my xmin; tmax = my xmax; } long itmin, itmax; if (! Sampled_getWindowSamples (me, tmin, tmax, & itmin, & itmax)) { return; } if (fmax <= fmin) { double f1max, f2min; autoNUMvector<double> f1 (itmin, itmax), f2 (itmin, itmax); for (long iframe = itmin; iframe <= itmax; iframe++) { f1[iframe] = my d_frames[iframe].frequencies[1]; f2[iframe] = my d_frames[iframe].frequencies[my d_frames[iframe].numberOfFrequencies]; } NUMvector_extrema (f1.peek(), itmin, itmax, & fmin, & f1max); NUMvector_extrema (f2.peek(), itmin, itmax, & f2min, & fmax); } if (fmax == fmin) { fmin = 0; fmax += 0.5; } Graphics_setInner (g); Graphics_setWindow (g, tmin, tmax, fmin, fmax); for (long iframe = itmin; iframe <= itmax; iframe++) { LineSpectralFrequencies_Frame lsf = & my d_frames[iframe]; double x = Sampled_indexToX (me, iframe); for (long ifreq = 1; ifreq <= lsf -> numberOfFrequencies; ifreq++) { double y = lsf -> frequencies [ifreq]; if (y >= fmin && y <= fmax) { Graphics_speckle (g, x, y); } } } Graphics_unsetInner (g); if (garnish) { Graphics_drawInnerBox (g); Graphics_textBottom (g, true, U"Time (seconds)"); Graphics_textLeft (g, true, U"Frequency (Hz)"); Graphics_marksBottom (g, 2, true, true, false); Graphics_marksLeft (g, 2, true, true, false); } }
void Polygon_Categories_draw (Polygon me, thou, Graphics graphics, double xmin, double xmax, double ymin, double ymax, int garnish) { thouart (Categories); double min, max, tmp; if (my numberOfPoints != thy size) { return; } if (xmax == xmin) { NUMvector_extrema (my x, 1, my numberOfPoints, & min, & max); tmp = max - min == 0 ? 0.5 : 0.0; xmin = min - tmp; xmax = max + tmp; } if (ymax == ymin) { NUMvector_extrema (my y, 1, my numberOfPoints, & min, & max); tmp = max - min == 0 ? 0.5 : 0.0; ymin = min - tmp; ymax = max + tmp; } Graphics_setInner (graphics); Graphics_setWindow (graphics, xmin, xmax, ymin, ymax); Graphics_setTextAlignment (graphics, Graphics_CENTRE, Graphics_HALF); for (long i = 1; i <= my numberOfPoints; i++) { OrderedOfString_drawItem (thee, graphics, i, my x[i], my y[i]); } Graphics_unsetInner (graphics); if (garnish) { Graphics_drawInnerBox (graphics); Graphics_marksLeft (graphics, 2, 1, 1, 0); if (ymin * ymax < 0.0) { Graphics_markLeft (graphics, 0.0, 1, 1, 1, NULL); } Graphics_marksBottom (graphics, 2, 1, 1, 0); if (xmin * xmax < 0.0) { Graphics_markBottom (graphics, 0.0, 1, 1, 1, NULL); } } }
void Cepstrum_draw (Cepstrum me, Graphics g, double qmin, double qmax, double minimum, double maximum, int garnish) { int autoscaling = minimum >= maximum; Graphics_setInner (g); if (qmax <= qmin) { qmin = my xmin; qmax = my xmax; } long imin, imax; if (! Matrix_getWindowSamplesX (me, qmin, qmax, & imin, & imax)) { return; } autoNUMvector<double> y (imin, imax); double *z = my z[1]; for (long i = imin; i <= imax; i++) { y[i] = z[i]; } if (autoscaling) { NUMvector_extrema (y.peek(), imin, imax, & minimum, & maximum); } for (long i = imin; i <= imax; i ++) { if (y[i] > maximum) { y[i] = maximum; } else if (y[i] < minimum) { y[i] = minimum; } } Graphics_setWindow (g, qmin, qmax, minimum, maximum); Graphics_function (g, y.peek(), imin, imax, Matrix_columnToX (me, imin), Matrix_columnToX (me, imax)); Graphics_unsetInner (g); if (garnish) { Graphics_drawInnerBox (g); Graphics_textBottom (g, 1, L"Quefrency"); Graphics_marksBottom (g, 2, TRUE, TRUE, FALSE); Graphics_textLeft (g, 1, L"Amplitude"); } }
void SPINET_drawSpectrum (SPINET me, Graphics g, double time, double fromErb, double toErb, double minimum, double maximum, int enhanced, int garnish) { long ifmin, ifmax, icol = Sampled2_xToLowColumn (me, time); // ppgb: don't use Sampled2_xToColumn for integer rounding double **z = enhanced ? my s : my y; if (icol < 1 || icol > my nx) { return; } if (toErb <= fromErb) { fromErb = my ymin; toErb = my ymax; } Sampled2_getWindowSamplesY (me, fromErb, toErb, &ifmin, &ifmax); autoNUMvector<double> spec (1, my ny); for (long i = 1; i <= my ny; i++) { spec[i] = z[i][icol]; } if (maximum <= minimum) { NUMvector_extrema (spec.peek(), ifmin, ifmax, &minimum, &maximum); } if (maximum <= minimum) { minimum -= 1; maximum += 1; } for (long i = ifmin; i <= ifmax; i++) { if (spec[i] > maximum) { spec[i] = maximum; } else if (spec[i] < minimum) { spec[i] = minimum; } } Graphics_setInner (g); Graphics_setWindow (g, fromErb, toErb, minimum, maximum); Graphics_function (g, spec.peek(), ifmin, ifmax, Sampled2_rowToY (me, ifmin), Sampled2_rowToY (me, ifmax)); Graphics_unsetInner (g); if (garnish) { Graphics_drawInnerBox (g); Graphics_textBottom (g, 1, U"Frequency (ERB)"); Graphics_marksBottom (g, 2, 1, 1, 0); Graphics_textLeft (g, 1, U"strength"); Graphics_marksLeft (g, 2, 1, 1, 0); } }
static void _Cepstrum_draw (Cepstrum me, Graphics g, double qmin, double qmax, double minimum, double maximum, int power, int garnish) { int autoscaling = minimum >= maximum; Graphics_setInner (g); if (qmax <= qmin) { qmin = my xmin; qmax = my xmax; } long imin, imax; if (! Matrix_getWindowSamplesX (me, qmin, qmax, & imin, & imax)) { return; } autoNUMvector<double> y (imin, imax); for (long i = imin; i <= imax; i++) { y[i] = my v_getValueAtSample (i, (power ? 1 : 0), 0); } if (autoscaling) { NUMvector_extrema (y.peek(), imin, imax, & minimum, & maximum); } else { for (long i = imin; i <= imax; i ++) { if (y[i] > maximum) { y[i] = maximum; } else if (y[i] < minimum) { y[i] = minimum; } } } Graphics_setWindow (g, qmin, qmax, minimum, maximum); Graphics_function (g, y.peek(), imin, imax, Matrix_columnToX (me, imin), Matrix_columnToX (me, imax)); Graphics_unsetInner (g); if (garnish) { Graphics_drawInnerBox (g); Graphics_textBottom (g, true, U"Quefrency (s)"); Graphics_marksBottom (g, 2, true, true, false); Graphics_textLeft (g, true, power ? U"Amplitude (dB)" : U"Amplitude"); Graphics_marksLeft (g, 2, true, true, false); } }
void Minimizer_drawHistory (Minimizer me, Graphics g, long iFrom, long iTo, double hmin, double hmax, int garnish) { if (my history == 0) { return; } autoNUMvector<double> history (1, my iteration); for (long i = 1; i <= my iteration; i++) { history[i] = my history[i]; } if (iTo <= iFrom) { iFrom = 1; iTo = my iteration; } long itmin = iFrom, itmax = iTo; if (itmin < 1) { itmin = 1; } if (itmax > my iteration) { itmax = my iteration; } if (hmax <= hmin) { NUMvector_extrema (history.peek(), itmin, itmax, & hmin, & hmax); } if (hmax <= hmin) { hmin -= 0.5 * fabs (hmin); hmax += 0.5 * fabs (hmax); } Graphics_setInner (g); Graphics_setWindow (g, iFrom, iTo, hmin, hmax); Graphics_function (g, history.peek(), itmin, itmax, itmin, itmax); Graphics_unsetInner (g); if (garnish) { Graphics_drawInnerBox (g); Graphics_textBottom (g, 1, L"Number of iterations"); Graphics_marksBottom (g, 2, 1, 1, 0); Graphics_marksLeft (g, 2, 1, 1, 0); } }
void LPC_drawGain (LPC me, Graphics g, double tmin, double tmax, double gmin, double gmax, int garnish) { if (tmax <= tmin) { tmin = my xmin; tmax = my xmax; } long itmin, itmax; if (! Sampled_getWindowSamples (me, tmin, tmax, & itmin, & itmax)) { return; } autoNUMvector<double> gain (itmin, itmax); for (long iframe = itmin; iframe <= itmax; iframe++) { gain[iframe] = my d_frames[iframe].gain; } if (gmax <= gmin) { NUMvector_extrema (gain.peek(), itmin, itmax, & gmin, & gmax); } if (gmax == gmin) { gmin = 0; gmax += 0.5; } Graphics_setInner (g); Graphics_setWindow (g, tmin, tmax, gmin, gmax); for (long iframe = itmin; iframe <= itmax; iframe++) { double x = Sampled_indexToX (me, iframe); Graphics_speckle (g, x, gain[iframe]); } Graphics_unsetInner (g); if (garnish) { Graphics_drawInnerBox (g); Graphics_textBottom (g, 1, L"Time (seconds)"); Graphics_textLeft (g, 1, L"Gain"); Graphics_marksBottom (g, 2, 1, 1, 0); Graphics_marksLeft (g, 2, 1, 1, 0); } }
void Configuration_draw (Configuration me, Graphics g, int xCoordinate, int yCoordinate, double xmin, double xmax, double ymin, double ymax, int labelSize, int useRowLabels, const char32 *label, int garnish) { long nPoints = my numberOfRows, numberOfDimensions = my numberOfColumns; if (numberOfDimensions > 1 && (xCoordinate > numberOfDimensions || yCoordinate > numberOfDimensions)) { return; } if (numberOfDimensions == 1) { xCoordinate = 1; } int fontSize = Graphics_inqFontSize (g), noLabel = 0; if (labelSize == 0) { labelSize = fontSize; } autoNUMvector<double> x (1, nPoints); autoNUMvector<double> y (1, nPoints); for (long i = 1; i <= nPoints; i++) { x[i] = my data[i][xCoordinate] * my w[xCoordinate]; y[i] = numberOfDimensions > 1 ? my data[i][yCoordinate] * my w[yCoordinate] : 0.0; } if (xmax <= xmin) { NUMvector_extrema (x.peek(), 1, nPoints, &xmin, &xmax); } if (xmax <= xmin) { xmax += 1.0; xmin -= 1.0; } if (ymax <= ymin) { NUMvector_extrema (y.peek(), 1, nPoints, &ymin, &ymax); } if (ymax <= ymin) { ymax += 1.0; ymin -= 1.0; } Graphics_setWindow (g, xmin, xmax, ymin, ymax); Graphics_setInner (g); Graphics_setTextAlignment (g, Graphics_CENTRE, Graphics_HALF); Graphics_setFontSize (g, labelSize); for (long i = 1; i <= my numberOfRows; i++) { if (x[i] >= xmin && x[i] <= xmax && y[i] >= ymin && y[i] <= ymax) { const char32 *plotLabel = useRowLabels ? my rowLabels[i] : label; if (NUMstring_containsPrintableCharacter (plotLabel)) { Graphics_text (g, x[i], y[i], plotLabel); } else { noLabel++; } } } Graphics_setFontSize (g, fontSize); Graphics_setTextAlignment (g, Graphics_LEFT, Graphics_BOTTOM); Graphics_unsetInner (g); if (garnish) { Graphics_drawInnerBox (g); Graphics_marksBottom (g, 2, true, true, false); if (numberOfDimensions > 1) { Graphics_marksLeft (g, 2, true, true, false); if (my columnLabels[xCoordinate]) { Graphics_textBottom (g, true, my columnLabels[xCoordinate]); } if (my columnLabels[yCoordinate]) { Graphics_textLeft (g, true, my columnLabels[yCoordinate]); } } } if (noLabel > 0) { Melder_warning (U"Configuration_draw: ", noLabel, U" from ", my numberOfRows, U" labels are not visible because they are empty or they contain only spaces or they contain only non-printable characters"); } }
void Matrix_drawDistribution (Matrix me, Graphics g, double xmin, double xmax, double ymin, double ymax, double minimum, double maximum, long nBins, double freqMin, double freqMax, bool cumulative, bool garnish) { if (nBins <= 0) { return; } if (xmax <= xmin) { xmin = my xmin; xmax = my xmax; } if (ymax <= ymin) { ymin = my ymin; ymax = my ymax; } long ixmin, ixmax, iymin, iymax; if ((Matrix_getWindowSamplesX (me, xmin, xmax, & ixmin, & ixmax) == 0) || (Matrix_getWindowSamplesY (me, ymin, ymax, & iymin, & iymax) == 0)) { return; } if (maximum <= minimum) { Matrix_getWindowExtrema (me, ixmin, ixmax, iymin, iymax, & minimum, & maximum); } if (maximum <= minimum) { minimum -= 1.0; maximum += 1.0; } // Count the numbers per bin and the total if (nBins < 1) { nBins = 10; } autoNUMvector<long> freq (1, nBins); double binWidth = (maximum - minimum) / nBins; long nxy = 0; for (long i = iymin; i <= iymax; i++) { for (long j = ixmin; j <= ixmax; j++) { long bin = 1 + (long) floor ( (my z[i][j] - minimum) / binWidth); if (bin <= nBins && bin > 0) { freq[bin]++; nxy ++; } } } if (freqMax <= freqMin) { if (cumulative) { freqMin = 0; freqMax = 1.0; } else { NUMvector_extrema (freq.peek(), 1, nBins, & freqMin, & freqMax); if (freqMax <= freqMin) { freqMin = freqMin > 1.0 ? freqMin - 1.0 : 0.0; freqMax += 1.0; } } } Graphics_setInner (g); Graphics_setWindow (g, minimum, maximum, freqMin, freqMax); double fi = 0.0; for (long i = 1; i <= nBins; i++) { double ftmp = freq[i]; fi = cumulative ? fi + freq[i] / nxy : freq[i]; ftmp = fi; if (ftmp > freqMax) { ftmp = freqMax; } if (ftmp > freqMin) { Graphics_rectangle (g, minimum + (i - 1) * binWidth, minimum + i * binWidth, freqMin, ftmp); } } Graphics_unsetInner (g); if (garnish) { Graphics_drawInnerBox (g); Graphics_marksBottom (g, 2, true, true, false); Graphics_marksLeft (g, 2, true, true, false); if (! cumulative) { Graphics_textLeft (g, true, U"Number/bin"); } } }