static void menu_cb_ReverseSelection (SoundEditor me, EDITOR_ARGS_DIRECT) { Editor_save (me, U"Reverse selection"); Sound_reverse ((Sound) my data, my d_startSelection, my d_endSelection); my v_reset_analysis (); FunctionEditor_redraw (me); Editor_broadcastDataChanged (me); }
static void menu_cb_addPointAtCursor (EDITOR_ARGS) { EDITOR_IAM (PointEditor); Editor_save (me, L"Add point"); PointProcess_addPoint ((PointProcess) my data, 0.5 * (my d_startSelection + my d_endSelection)); FunctionEditor_redraw (me); my broadcastDataChanged (); }
static void menu_cb_octaveUp (EDITOR_ARGS) { EDITOR_IAM (PitchEditor); Pitch pitch = (Pitch) my data; Editor_save (me, L"Octave up"); Pitch_step (pitch, 2.0, 0.1, my d_startSelection, my d_endSelection); FunctionEditor_redraw (me); my broadcastDataChanged (); }
static void menu_cb_ReverseSelection (EDITOR_ARGS) { EDITOR_IAM (SoundEditor); Editor_save (me, L"Reverse selection"); Sound_reverse ((Sound) my data, my d_startSelection, my d_endSelection); my v_destroy_analysis (); FunctionEditor_redraw (me); Editor_broadcastDataChanged (me); }
static void menu_cb_octaveDown (EDITOR_ARGS) { EDITOR_IAM (PitchEditor); Pitch pitch = (Pitch) my data; Editor_save (me, U"Octave down"); Pitch_step (pitch, 0.5, 0.1, my d_startSelection, my d_endSelection); FunctionEditor_redraw (me); Editor_broadcastDataChanged (me); }
static void menu_cb_fifthDown (EDITOR_ARGS) { EDITOR_IAM (PitchEditor); Pitch pitch = (Pitch) my data; Editor_save (me, L"Fifth down"); Pitch_step (pitch, 1 / 1.5, 0.1, my d_startSelection, my d_endSelection); FunctionEditor_redraw (me); my broadcastDataChanged (); }
static void selectFormantOrBandwidth (FormantGridEditor me, long iformant) { FormantGrid grid = (FormantGrid) my data; long numberOfFormants = grid -> formants -> size; if (iformant > numberOfFormants) Melder_throw (U"Cannot select formant ", iformant, U", because the FormantGrid has only ", numberOfFormants, U" formants."); my selectedFormant = iformant; FunctionEditor_redraw (me); }
static void menu_cb_addPointAtCursor (FormantGridEditor me, EDITOR_ARGS_DIRECT) { Editor_save (me, U"Add point"); FormantGrid grid = (FormantGrid) my data; Ordered tiers = my editingBandwidths ? grid -> bandwidths.get() : grid -> formants.get(); RealTier tier = (RealTier) tiers -> item [my selectedFormant]; RealTier_addPoint (tier, 0.5 * (my d_startSelection + my d_endSelection), my ycursor); FunctionEditor_redraw (me); Editor_broadcastDataChanged (me); }
static void menu_cb_removePoints (PointEditor me, EDITOR_ARGS_DIRECT) { Editor_save (me, U"Remove point(s)"); if (my startSelection == my endSelection) PointProcess_removePointNear ((PointProcess) my data, my startSelection); else PointProcess_removePointsBetween ((PointProcess) my data, my startSelection, my endSelection); FunctionEditor_redraw (me); Editor_broadcastDataChanged (me); }
static void menu_cb_selectFormantOrBandwidth (FormantGridEditor me, EDITOR_ARGS_FORM) { EDITOR_FORM (U"Select formant or bandwidth", nullptr) NATURAL (U"Formant number", U"1") EDITOR_OK SET_INTEGER (U"Formant number", my selectedFormant) EDITOR_DO selectFormantOrBandwidth (me, GET_INTEGER (U"Formant number")); FunctionEditor_redraw (me); EDITOR_END }
static void menu_cb_removePoints (RealTierEditor me, EDITOR_ARGS_DIRECT) { Editor_save (me, U"Remove point(s)"); if (my d_startSelection == my d_endSelection) AnyTier_removePointNear (my data, my d_startSelection); else AnyTier_removePointsBetween (my data, my d_startSelection, my d_endSelection); RealTierEditor_updateScaling (me); FunctionEditor_redraw (me); Editor_broadcastDataChanged (me); }
static void menu_cb_removePoints (EDITOR_ARGS) { EDITOR_IAM (PointEditor); Editor_save (me, L"Remove point(s)"); if (my d_startSelection == my d_endSelection) PointProcess_removePointNear ((PointProcess) my data, my d_startSelection); else PointProcess_removePointsBetween ((PointProcess) my data, my d_startSelection, my d_endSelection); FunctionEditor_redraw (me); my broadcastDataChanged (); }
static void menu_cb_addPointAtCursor (RealTierEditor me, EDITOR_ARGS_DIRECT) { if (NUMdefined (my v_minimumLegalValue ()) && my ycursor < my v_minimumLegalValue ()) Melder_throw (U"Cannot add a point below ", my v_minimumLegalValue (), my v_rightTickUnits (), U"."); if (NUMdefined (my v_maximumLegalValue ()) && my ycursor > my v_maximumLegalValue ()) Melder_throw (U"Cannot add a point above ", my v_maximumLegalValue (), my v_rightTickUnits (), U"."); Editor_save (me, U"Add point"); RealTier_addPoint ((RealTier) my data, 0.5 * (my d_startSelection + my d_endSelection), my ycursor); RealTierEditor_updateScaling (me); FunctionEditor_redraw (me); Editor_broadcastDataChanged (me); }
static void menu_cb_selectFormantOrBandwidth (EDITOR_ARGS) { EDITOR_IAM (FormantGridEditor); EDITOR_FORM (L"Select formant or bandwidth", 0) NATURAL (L"Formant number", L"1") EDITOR_OK SET_INTEGER (L"Formant number", my selectedFormant) EDITOR_DO selectFormantOrBandwidth (me, GET_INTEGER (L"Formant number")); FunctionEditor_redraw (me); EDITOR_END }
static void menu_cb_setDynamicRange (EDITOR_ARGS) { EDITOR_IAM (SpectrumEditor); EDITOR_FORM (L"Set dynamic range", 0) POSITIVE (L"Dynamic range (dB)", my default_dynamicRange ()) EDITOR_OK SET_REAL (L"Dynamic range", my p_dynamicRange) EDITOR_DO my pref_dynamicRange () = my p_dynamicRange = GET_REAL (L"Dynamic range"); updateRange (me); FunctionEditor_redraw (me); EDITOR_END }
static void menu_cb_addPointAt (PointEditor me, EDITOR_ARGS_FORM) { EDITOR_FORM (U"Add point", nullptr) REAL (U"Position", U"0.0"); EDITOR_OK SET_REAL (U"Position", 0.5 * (my startSelection + my endSelection)); EDITOR_DO Editor_save (me, U"Add point"); PointProcess_addPoint ((PointProcess) my data, GET_REAL (U"Position")); FunctionEditor_redraw (me); Editor_broadcastDataChanged (me); EDITOR_END }
static void menu_cb_removePoints (FormantGridEditor me, EDITOR_ARGS_DIRECT) { Editor_save (me, U"Remove point(s)"); FormantGrid grid = (FormantGrid) my data; Ordered tiers = my editingBandwidths ? grid -> bandwidths.get() : grid -> formants.get(); RealTier tier = (RealTier) tiers -> item [my selectedFormant]; if (my d_startSelection == my d_endSelection) AnyTier_removePointNear (tier, my d_startSelection); else AnyTier_removePointsBetween (tier, my d_startSelection, my d_endSelection); FunctionEditor_redraw (me); Editor_broadcastDataChanged (me); }
static void menu_cb_setFormantRange (FormantGridEditor me, EDITOR_ARGS_FORM) { EDITOR_FORM (U"Set formant range", nullptr) REAL (U"Minimum formant (Hz)", my default_formantFloor ()) REAL (U"Maximum formant (Hz)", my default_formantCeiling ()) EDITOR_OK SET_REAL (U"Minimum formant", my p_formantFloor) SET_REAL (U"Maximum formant", my p_formantCeiling) EDITOR_DO my pref_formantFloor () = my p_formantFloor = GET_REAL (U"Minimum formant"); my pref_formantCeiling () = my p_formantCeiling = GET_REAL (U"Maximum formant"); FunctionEditor_redraw (me); EDITOR_END }
static void menu_cb_setBandwidthRange (FormantGridEditor me, EDITOR_ARGS_FORM) { EDITOR_FORM (U"Set bandwidth range", nullptr) REAL (U"Minimum bandwidth (Hz)", my default_bandwidthFloor ()) REAL (U"Maximum bandwidth (Hz)", my default_bandwidthCeiling ()) EDITOR_OK SET_REAL (U"Minimum bandwidth", my p_bandwidthFloor) SET_REAL (U"Maximum bandwidth", my p_bandwidthCeiling) EDITOR_DO my pref_bandwidthFloor () = my p_bandwidthFloor = GET_REAL (U"Minimum bandwidth"); my pref_bandwidthCeiling () = my p_bandwidthCeiling = GET_REAL (U"Maximum bandwidth"); FunctionEditor_redraw (me); EDITOR_END }
static void menu_cb_addPointAt (EDITOR_ARGS) { EDITOR_IAM (PointEditor); EDITOR_FORM (L"Add point", 0) REAL (L"Position", L"0.0"); EDITOR_OK SET_REAL (L"Position", 0.5 * (my d_startSelection + my d_endSelection)); EDITOR_DO Editor_save (me, L"Add point"); PointProcess_addPoint ((PointProcess) my data, GET_REAL (L"Position")); FunctionEditor_redraw (me); my broadcastDataChanged (); EDITOR_END }
static void menu_cb_SetSelectionToZero (SoundEditor me, EDITOR_ARGS_DIRECT) { Sound sound = (Sound) my data; long first, last; Sampled_getWindowSamples (sound, my d_startSelection, my d_endSelection, & first, & last); Editor_save (me, U"Set to zero"); for (long channel = 1; channel <= sound -> ny; channel ++) { for (long i = first; i <= last; i ++) { sound -> z [channel] [i] = 0.0; } } my v_reset_analysis (); FunctionEditor_redraw (me); Editor_broadcastDataChanged (me); }
static void menu_cb_setBandwidthRange (EDITOR_ARGS) { EDITOR_IAM (FormantGridEditor); EDITOR_FORM (L"Set bandwidth range", 0) REAL (L"Minimum bandwidth (Hz)", L"0.0") REAL (L"Maximum bandwidth (Hz)", L"1000.0") EDITOR_OK SET_REAL (L"Minimum bandwidth", my bandwidthFloor) SET_REAL (L"Maximum bandwidth", my bandwidthCeiling) EDITOR_DO preferences.bandwidthFloor = my bandwidthFloor = GET_REAL (L"Minimum bandwidth"); preferences.bandwidthCeiling = my bandwidthCeiling = GET_REAL (L"Maximum bandwidth"); FunctionEditor_redraw (me); EDITOR_END }
static void menu_cb_setFormantRange (EDITOR_ARGS) { EDITOR_IAM (FormantGridEditor); EDITOR_FORM (L"Set formant range", 0) REAL (L"Minimum formant (Hz)", L"0.0") REAL (L"Maximum formant (Hz)", L"11000.0") EDITOR_OK SET_REAL (L"Minimum formant", my formantFloor) SET_REAL (L"Maximum formant", my formantCeiling) EDITOR_DO preferences.formantFloor = my formantFloor = GET_REAL (L"Minimum formant"); preferences.formantCeiling = my formantCeiling = GET_REAL (L"Maximum formant"); FunctionEditor_redraw (me); EDITOR_END }
static void menu_cb_stopBand (EDITOR_ARGS) { EDITOR_IAM (SpectrumEditor); EDITOR_FORM (L"Filter (stop Hann band)", 0) REAL (L"Band smoothing (Hz)", my default_bandSmoothing ()) EDITOR_OK SET_REAL (L"Band smoothing", my p_bandSmoothing) EDITOR_DO my pref_bandSmoothing () = my p_bandSmoothing = GET_REAL (L"Band smoothing"); if (my d_endSelection <= my d_startSelection) Melder_throw (L"To apply a band-stop filter, first make a selection."); Editor_save (me, L"Stop band"); Spectrum_stopHannBand ((Spectrum) my data, my d_startSelection, my d_endSelection, my p_bandSmoothing); FunctionEditor_redraw (me); my broadcastDataChanged (); EDITOR_END }
static void menu_cb_setCeiling (EDITOR_ARGS) { EDITOR_IAM (PitchEditor); EDITOR_FORM (L"Change ceiling", 0) POSITIVE (L"Ceiling (Hz)", L"600") EDITOR_OK Pitch pitch = (Pitch) my data; SET_REAL (L"Ceiling", pitch -> ceiling) EDITOR_DO Pitch pitch = (Pitch) my data; Editor_save (me, L"Change ceiling"); Pitch_setCeiling (pitch, GET_REAL (L"Ceiling")); FunctionEditor_redraw (me); my broadcastDataChanged (); EDITOR_END }
static void menu_cb_addPointAt (FormantGridEditor me, EDITOR_ARGS_FORM) { EDITOR_FORM (U"Add point", nullptr) REAL (U"Time (s)", U"0.0") POSITIVE (U"Frequency (Hz)", U"200.0") EDITOR_OK SET_REAL (U"Time", 0.5 * (my d_startSelection + my d_endSelection)) SET_REAL (U"Frequency", my ycursor) EDITOR_DO Editor_save (me, U"Add point"); FormantGrid grid = (FormantGrid) my data; Ordered tiers = my editingBandwidths ? grid -> bandwidths.get() : grid -> formants.get(); RealTier tier = (RealTier) tiers -> item [my selectedFormant]; RealTier_addPoint (tier, GET_REAL (U"Time"), GET_REAL (U"Frequency")); FunctionEditor_redraw (me); Editor_broadcastDataChanged (me); EDITOR_END }
int structPitchEditor :: v_click (double xWC, double yWC, bool dummy) { Pitch pitch = (Pitch) our data; double dyUnv = Graphics_dyMMtoWC (d_graphics, HEIGHT_UNV); double dyIntens = Graphics_dyMMtoWC (d_graphics, HEIGHT_INTENS); double frequency = (yWC - dyUnv) / (1 - dyIntens - dyUnv) * pitch -> ceiling, tmid; double minimumDf = 1e30; int cand, bestCandidate = -1; long ibestFrame; Pitch_Frame bestFrame; ibestFrame = Sampled_xToNearestIndex (pitch, xWC); if (ibestFrame < 1) ibestFrame = 1; if (ibestFrame > pitch -> nx) ibestFrame = pitch -> nx; bestFrame = & pitch -> frame [ibestFrame]; tmid = Sampled_indexToX (pitch, ibestFrame); for (cand = 1; cand <= bestFrame -> nCandidates; cand ++) { double df = frequency - bestFrame -> candidate [cand]. frequency; if (fabs (df) < minimumDf) { minimumDf = fabs (df); bestCandidate = cand; } } if (bestCandidate != -1) { double bestFrequency = bestFrame -> candidate [bestCandidate]. frequency; double distanceWC = (frequency - bestFrequency) / pitch -> ceiling * (1 - dyIntens - dyUnv); double dx_mm = Graphics_dxWCtoMM (our d_graphics, xWC - tmid), dy_mm = Graphics_dyWCtoMM (our d_graphics, distanceWC); if (bestFrequency < pitch -> ceiling && // above ceiling: ignore ((bestFrequency <= 0.0 && fabs (xWC - tmid) <= 0.5 * pitch -> dx && frequency <= 0.0) || // voiceless: click within frame (bestFrequency > 0.0 && dx_mm * dx_mm + dy_mm * dy_mm <= RADIUS * RADIUS))) // voiced: click within circle { struct structPitch_Candidate help = bestFrame -> candidate [1]; Editor_save (this, L"Change path"); bestFrame -> candidate [1] = bestFrame -> candidate [bestCandidate]; bestFrame -> candidate [bestCandidate] = help; FunctionEditor_redraw (this); our broadcastDataChanged (); our d_startSelection = our d_endSelection = tmid; // cursor will snap to candidate return 1; } else { return PitchEditor_Parent :: v_click (xWC, yWC, dummy); // move cursor or drag selection } } return PitchEditor_Parent :: v_click (xWC, yWC, dummy); // move cursor or drag selection }
static void menu_cb_addPointAt (EDITOR_ARGS) { EDITOR_IAM (FormantGridEditor); EDITOR_FORM (L"Add point", 0) REAL (L"Time (s)", L"0.0") POSITIVE (L"Frequency (Hz)", L"200.0") EDITOR_OK SET_REAL (L"Time", 0.5 * (my startSelection + my endSelection)) SET_REAL (L"Frequency", my ycursor) EDITOR_DO Editor_save (me, L"Add point"); FormantGrid grid = (FormantGrid) my data; Ordered tiers = my editingBandwidths ? grid -> bandwidths : grid -> formants; RealTier tier = (RealTier) tiers -> item [my selectedFormant]; RealTier_addPoint (tier, GET_REAL (L"Time"), GET_REAL (L"Frequency")); FunctionEditor_redraw (me); my broadcastDataChanged (); EDITOR_END }
static void menu_cb_soundScaling (TimeSoundEditor me, EDITOR_ARGS_FORM) { EDITOR_FORM (U"Sound scaling", nullptr) OPTIONMENU_ENUM (U"Scaling strategy", kTimeSoundEditor_scalingStrategy, my default_sound_scalingStrategy ()) LABEL (U"", U"For \"fixed height\":"); POSITIVE (U"Height", my default_sound_scaling_height ()) LABEL (U"", U"For \"fixed range\":"); REAL (U"Minimum", my default_sound_scaling_minimum ()) REAL (U"Maximum", my default_sound_scaling_maximum ()) EDITOR_OK SET_ENUM (U"Scaling strategy", kTimeSoundEditor_scalingStrategy, my p_sound_scalingStrategy) SET_REAL (U"Height", my p_sound_scaling_height) SET_REAL (U"Minimum", my p_sound_scaling_minimum) SET_REAL (U"Maximum", my p_sound_scaling_maximum) EDITOR_DO my pref_sound_scalingStrategy () = my p_sound_scalingStrategy = GET_ENUM (kTimeSoundEditor_scalingStrategy, U"Scaling strategy"); my pref_sound_scaling_height () = my p_sound_scaling_height = GET_REAL (U"Height"); my pref_sound_scaling_minimum () = my p_sound_scaling_minimum = GET_REAL (U"Minimum"); my pref_sound_scaling_maximum () = my p_sound_scaling_maximum = GET_REAL (U"Maximum"); FunctionEditor_redraw (me); EDITOR_END }
static void menu_cb_voiceless (EDITOR_ARGS) { EDITOR_IAM (PitchEditor); Pitch pitch = (Pitch) my data; long ileft = Sampled_xToHighIndex (pitch, my d_startSelection); long iright = Sampled_xToLowIndex (pitch, my d_endSelection); if (ileft < 1) ileft = 1; if (iright > pitch -> nx) iright = pitch -> nx; Editor_save (me, L"Unvoice"); for (long i = ileft; i <= iright; i ++) { Pitch_Frame frame = & pitch -> frame [i]; for (long cand = 1; cand <= frame -> nCandidates; cand ++) { if (frame -> candidate [cand]. frequency == 0.0) { struct structPitch_Candidate help = frame -> candidate [1]; frame -> candidate [1] = frame -> candidate [cand]; frame -> candidate [cand] = help; } } } FunctionEditor_redraw (me); my broadcastDataChanged (); }