Ejemplo n.º 1
0
void structPointEditor :: v_draw () {
	PointProcess point = (PointProcess) data;
	Sound sound = d_sound.data;
	Graphics_setColour (d_graphics, Graphics_WHITE);
	Graphics_setWindow (d_graphics, 0, 1, 0, 1);
	Graphics_fillRectangle (d_graphics, 0, 1, 0, 1);
	double minimum = -1.0, maximum = +1.0;
	if (sound != NULL && (d_sound.scalingStrategy == kTimeSoundEditor_scalingStrategy_BY_WINDOW || d_sound.scalingStrategy == kTimeSoundEditor_scalingStrategy_BY_WINDOW_AND_CHANNEL)) {
		long first, last;
		if (Sampled_getWindowSamples (sound, d_startWindow, d_endWindow, & first, & last) >= 1) {
			Matrix_getWindowExtrema (sound, first, last, 1, 1, & minimum, & maximum);
		}
	}
	Graphics_setWindow (d_graphics, d_startWindow, d_endWindow, minimum, maximum);
	Graphics_setColour (d_graphics, Graphics_BLACK);
	if (sound != NULL) {
		long first, last;
		if (Sampled_getWindowSamples (sound, d_startWindow, d_endWindow, & first, & last) > 1) {
			Graphics_setLineType (d_graphics, Graphics_DOTTED);
			Graphics_line (d_graphics, d_startWindow, 0.0, d_endWindow, 0.0);
			Graphics_setLineType (d_graphics, Graphics_DRAWN);      
			Graphics_function (d_graphics, sound -> z [1], first, last,
				Sampled_indexToX (sound, first), Sampled_indexToX (sound, last));
		}
	}
	Graphics_setColour (d_graphics, Graphics_BLUE);
	Graphics_setWindow (d_graphics, d_startWindow, d_endWindow, -1.0, +1.0);
	for (long i = 1; i <= point -> nt; i ++) {
		double t = point -> t [i];
		if (t >= d_startWindow && t <= d_endWindow)
			Graphics_line (d_graphics, t, -0.9, t, +0.9);
	}
	Graphics_setColour (d_graphics, Graphics_BLACK);
	v_updateMenuItems_file ();
}
Ejemplo n.º 2
0
void structPointEditor :: v_draw () {
	PointProcess point = static_cast <PointProcess> (our data);
	Sound sound = d_sound.data;
	Graphics_setColour (our graphics.get(), Graphics_WHITE);
	Graphics_setWindow (our graphics.get(), 0.0, 1.0, 0.0, 1.0);
	Graphics_fillRectangle (our graphics.get(), 0.0, 1.0, 0.0, 1.0);
	double minimum = -1.0, maximum = +1.0;
	if (sound && (p_sound_scalingStrategy == kTimeSoundEditor_scalingStrategy_BY_WINDOW || p_sound_scalingStrategy == kTimeSoundEditor_scalingStrategy_BY_WINDOW_AND_CHANNEL)) {
		long first, last;
		if (Sampled_getWindowSamples (sound, our startWindow, our endWindow, & first, & last) >= 1) {
			Matrix_getWindowExtrema (sound, first, last, 1, 1, & minimum, & maximum);
			if (minimum == maximum) minimum -= 1.0, maximum += 1.0;
		}
	}
	Graphics_setWindow (our graphics.get(), our startWindow, our endWindow, minimum, maximum);
	Graphics_setColour (our graphics.get(), Graphics_BLACK);
	if (sound) {
		long first, last;
		if (Sampled_getWindowSamples (sound, our startWindow, our endWindow, & first, & last) > 1) {
			Graphics_setLineType (our graphics.get(), Graphics_DOTTED);
			Graphics_line (our graphics.get(), our startWindow, 0.0, our endWindow, 0.0);
			Graphics_setLineType (our graphics.get(), Graphics_DRAWN);
			Graphics_function (our graphics.get(), sound -> z [1], first, last,
				Sampled_indexToX (sound, first), Sampled_indexToX (sound, last));
		}
	}
	Graphics_setColour (our graphics.get(), Graphics_BLUE);
	Graphics_setWindow (our graphics.get(), our startWindow, our endWindow, -1.0, +1.0);
	for (long i = 1; i <= point -> nt; i ++) {
		double t = point -> t [i];
		if (t >= our startWindow && t <= our endWindow)
			Graphics_line (our graphics.get(), t, -0.9, t, +0.9);
	}
	Graphics_setColour (our graphics.get(), Graphics_BLACK);
	v_updateMenuItems_file ();
}
Ejemplo n.º 3
0
void structSoundEditor :: v_draw () {
	Sampled data = (Sampled) this -> data;
	Graphics_Viewport viewport;
	bool showAnalysis = p_spectrogram_show || p_pitch_show || p_intensity_show || p_formant_show;
	Melder_assert (data);
	Melder_assert (d_sound.data || d_longSound.data);

	/*
	 * We check beforehand whether the window fits the LongSound buffer.
	 */
	if (d_longSound.data && d_endWindow - d_startWindow > d_longSound.data -> bufferLength) {
		Graphics_setColour (d_graphics.get(), Graphics_WHITE);
		Graphics_setWindow (d_graphics.get(), 0.0, 1.0, 0.0, 1.0);
		Graphics_fillRectangle (d_graphics.get(), 0.0, 1.0, 0.0, 1.0);
		Graphics_setColour (d_graphics.get(), Graphics_BLACK);
		Graphics_setTextAlignment (d_graphics.get(), Graphics_CENTRE, Graphics_BOTTOM);
		Graphics_text (d_graphics.get(), 0.5, 0.5,   U"(window longer than ", Melder_float (Melder_single (d_longSound.data -> bufferLength)), U" seconds)");
		Graphics_setTextAlignment (d_graphics.get(), Graphics_CENTRE, Graphics_TOP);
		Graphics_text (d_graphics.get(), 0.5, 0.5, U"(zoom in to see the samples)");
		return;
	}

	/* Draw sound. */

	if (showAnalysis)
		viewport = Graphics_insetViewport (d_graphics.get(), 0.0, 1.0, 0.5, 1.0);
	Graphics_setColour (d_graphics.get(), Graphics_WHITE);
	Graphics_setWindow (d_graphics.get(), 0.0, 1.0, 0.0, 1.0);
	Graphics_fillRectangle (d_graphics.get(), 0.0, 1.0, 0.0, 1.0);
	TimeSoundEditor_drawSound (this, d_sound.minimum, d_sound.maximum);
	Graphics_flushWs (d_graphics.get());
	if (showAnalysis)
		Graphics_resetViewport (d_graphics.get(), viewport);

	/* Draw analyses. */

	if (showAnalysis) {
		/* Draw spectrogram, pitch, formants. */
		viewport = Graphics_insetViewport (d_graphics.get(), 0.0, 1.0, 0.0, 0.5);
		v_draw_analysis ();
		Graphics_flushWs (d_graphics.get());
		Graphics_resetViewport (d_graphics.get(), viewport);
	}

	/* Draw pulses. */

	if (p_pulses_show) {
		if (showAnalysis)
			viewport = Graphics_insetViewport (d_graphics.get(), 0.0, 1.0, 0.5, 1.0);
		v_draw_analysis_pulses ();
		TimeSoundEditor_drawSound (this, d_sound.minimum, d_sound.maximum);   // second time, partially across the pulses
		Graphics_flushWs (d_graphics.get());
		if (showAnalysis)
			Graphics_resetViewport (d_graphics.get(), viewport);
	}

	/* Update buttons. */

	long first, last;
	long selectedSamples = Sampled_getWindowSamples (data, d_startSelection, d_endSelection, & first, & last);
	v_updateMenuItems_file ();
	if (d_sound.data) {
		GuiThing_setSensitive (cutButton     , selectedSamples != 0 && selectedSamples < d_sound.data -> nx);
		GuiThing_setSensitive (copyButton    , selectedSamples != 0);
		GuiThing_setSensitive (zeroButton    , selectedSamples != 0);
		GuiThing_setSensitive (reverseButton , selectedSamples != 0);
	}
}