[med-svn] [praat] 01/03: Imported Upstream version 5.3.84
Rafael Laboissière
rlaboiss-guest at moszumanska.debian.org
Mon Sep 8 13:44:19 UTC 2014
This is an automated email from the git hooks/post-receive script.
rlaboiss-guest pushed a commit to branch master
in repository praat.
commit 2472324a45704dbda75ac1344068601f440fd01f
Author: Rafael Laboissiere <rafael at laboissiere.net>
Date: Mon Sep 8 08:52:28 2014 -0300
Imported Upstream version 5.3.84
---
EEG/ERPTier.cpp | 4 +-
EEG/ERPWindow.cpp | 2 +-
LPC/LPC_and_Tube.cpp | 8 +-
fon/AmplitudeTier.cpp | 2 +-
fon/Formant.cpp | 6 +-
fon/FormantGrid.cpp | 2 +-
fon/FormantTier.cpp | 2 +-
fon/IntensityTierEditor.cpp | 8 +-
fon/Manipulation.cpp | 10 +-
fon/ManipulationEditor.cpp | 82 ++++-----
fon/Matrix.cpp | 84 ++++-----
fon/MovieWindow.cpp | 12 +-
fon/ParamCurve.cpp | 4 +-
fon/Photo.cpp | 233 +++++++++++++------------
fon/Photo.h | 29 ++++
fon/Photo_def.h | 38 ----
fon/Pitch.cpp | 2 +-
fon/PitchEditor.cpp | 126 +++++++-------
fon/Pitch_Intensity.cpp | 2 +-
fon/Pitch_to_PitchTier.cpp | 6 +-
fon/Pitch_to_PointProcess.cpp | 4 +-
fon/PointEditor.cpp | 4 +-
fon/PointProcess_and_Sound.cpp | 2 +-
fon/PointProcess_def.h | 8 +-
fon/RealTier.cpp | 84 ++++-----
fon/RealTierEditor.cpp | 156 ++++++++---------
fon/RealTier_def.h | 14 +-
fon/Sampled.cpp | 23 +--
fon/Sampled.h | 12 +-
fon/SampledXY.cpp | 26 +--
fon/SampledXY.h | 12 ++
fon/SampledXY_def.h | 11 --
fon/Sampled_def.h | 8 -
fon/Sound.cpp | 20 +--
fon/SoundEditor.cpp | 20 +--
fon/SoundEditor.h | 5 +-
fon/SoundRecorder.cpp | 25 +--
fon/Sound_and_Spectrogram.cpp | 8 +-
fon/Sound_to_Cochleagram.cpp | 2 +-
fon/Sound_to_Formant.cpp | 4 +-
fon/Sound_to_Intensity.cpp | 6 +-
fon/Sound_to_Pitch.cpp | 2 +-
fon/Sound_to_PointProcess.cpp | 2 +-
fon/SpectrogramEditor.cpp | 52 +++---
fon/SpectrumEditor.cpp | 44 ++---
fon/Spectrum_and_Spectrogram.cpp | 2 +-
fon/Spectrum_to_Excitation.cpp | 2 +-
fon/TextGridEditor.cpp | 147 ++++++++--------
fon/TextGrid_Sound.cpp | 49 +++++-
fon/TimeSoundAnalysisEditor.cpp | 363 ++++++++++++++++++++-------------------
fon/TimeSoundAnalysisEditor.h | 7 +-
fon/TimeSoundEditor.cpp | 164 +++++++++---------
fon/TimeSoundEditor.h | 12 +-
fon/Vector.cpp | 10 +-
fon/manual_tutorials.cpp | 14 +-
fon/praat_Fon.cpp | 40 ++---
fon/praat_Sound_init.cpp | 8 +-
fon/praat_TextGrid_init.cpp | 18 ++
gram/Network.cpp | 342 ++++++++++++++++++------------------
gram/Network.h | 39 ++++-
gram/Network_def.h | 92 +++-------
gram/OTGrammar.cpp | 34 ++--
gram/OTGrammar.h | 2 +-
gram/praat_gram.cpp | 126 +++++++++++---
stat/Table_def.h | 2 +-
sys/Editor.cpp | 38 ++--
sys/GraphicsScreen.cpp | 9 +-
sys/Graphics_linesAndAreas.cpp | 124 ++++++-------
sys/Thing.cpp | 10 +-
sys/Thing.h | 13 +-
sys/melder_audio.cpp | 2 +-
sys/oo_CAN_WRITE_AS_ENCODING.h | 34 ++--
sys/oo_COPY.h | 50 +++---
sys/oo_DESTROY.h | 42 ++---
sys/oo_EQUAL.h | 64 +++----
sys/oo_READ_BINARY.h | 56 +++---
sys/oo_READ_TEXT.h | 56 +++---
sys/oo_WRITE_BINARY.h | 58 +++----
sys/oo_WRITE_TEXT.h | 56 +++---
sys/praat.cpp | 3 +-
sys/praat_version.h | 6 +-
81 files changed, 1730 insertions(+), 1580 deletions(-)
diff --git a/EEG/ERPTier.cpp b/EEG/ERPTier.cpp
index a12d465..94a3971 100644
--- a/EEG/ERPTier.cpp
+++ b/EEG/ERPTier.cpp
@@ -329,7 +329,7 @@ ERPTier ERPTier_extractEventsWhereColumn_number (ERPTier me, Table table, long c
thy events = SortedSetOfDouble_create ();
for (long ievent = 1; ievent <= my events -> size; ievent ++) {
ERPPoint oldEvent = my event (ievent);
- TableRow row = table -> f_peekRow (ievent);
+ TableRow row = table -> row (ievent);
if (Melder_numberMatchesCriterion (row -> cells [columnNumber]. number, which_Melder_NUMBER, criterion)) {
autoERPPoint newEvent = Data_copy (oldEvent);
Collection_addItem (thy events, newEvent.transfer());
@@ -362,7 +362,7 @@ ERPTier ERPTier_extractEventsWhereColumn_string (ERPTier me, Table table,
thy events = SortedSetOfDouble_create ();
for (long ievent = 1; ievent <= my events -> size; ievent ++) {
ERPPoint oldEvent = my event (ievent);
- TableRow row = table -> f_peekRow (ievent);
+ TableRow row = table -> row (ievent);
if (Melder_stringMatchesCriterion (row -> cells [columnNumber]. string, which_Melder_STRING, criterion)) {
autoERPPoint newEvent = Data_copy (oldEvent);
Collection_addItem (thy events, newEvent.transfer());
diff --git a/EEG/ERPWindow.cpp b/EEG/ERPWindow.cpp
index 1cd35f6..7b35fbf 100644
--- a/EEG/ERPWindow.cpp
+++ b/EEG/ERPWindow.cpp
@@ -406,7 +406,7 @@ ERPWindow ERPWindow_create (const wchar_t *title, ERP data) {
Melder_assert (data != NULL);
try {
autoERPWindow me = Thing_new (ERPWindow);
- my structSoundEditor :: f_init (title, data);
+ SoundEditor_init (me.peek(), title, data);
return me.transfer();
} catch (MelderError) {
Melder_throw ("ERP window not created.");
diff --git a/LPC/LPC_and_Tube.cpp b/LPC/LPC_and_Tube.cpp
index a104a7e..f3db194 100644
--- a/LPC/LPC_and_Tube.cpp
+++ b/LPC/LPC_and_Tube.cpp
@@ -79,10 +79,10 @@ double VocalTract_and_LPC_Frame_getMatchingLength (VocalTract me, LPC_Frame thee
LPC_Frame_into_Spectrum (thee, lps.peek(), 0, 50);
autoSpectrumTier vtst = Spectrum_to_SpectrumTier_peaks (vts.peek());
autoSpectrumTier lpst = Spectrum_to_SpectrumTier_peaks (lps.peek());
- RealPoint point = vtst -> f_peekPoint (1); double vt_f1 = point -> number;
- point = vtst -> f_peekPoint (2); double vt_f2 = point -> number;
- point = lpst -> f_peekPoint (1); double lp_f1 = point -> number;
- point = lpst -> f_peekPoint (2); double lp_f2 = point -> number;
+ RealPoint point = vtst -> point (1); double vt_f1 = point -> number;
+ point = vtst -> point (2); double vt_f2 = point -> number;
+ point = lpst -> point (1); double lp_f1 = point -> number;
+ point = lpst -> point (2); double lp_f2 = point -> number;
double df1 = lp_f1 - vt_f1, df2 = lp_f2 - vt_f2, df = 0.5 * (df1 + df2);
double dl = - df / lp_f2;
return my dx * my nx * (1 + dl);
diff --git a/fon/AmplitudeTier.cpp b/fon/AmplitudeTier.cpp
index 4a7ff79..1183c62 100644
--- a/fon/AmplitudeTier.cpp
+++ b/fon/AmplitudeTier.cpp
@@ -357,7 +357,7 @@ Sound AmplitudeTier_to_Sound (AmplitudeTier me, double samplingFrequency, long i
long begin = mid - interpolationDepth, end = mid + interpolationDepth;
if (begin < 1) begin = 1;
if (end > thy nx) end = thy nx;
- angle = NUMpi * (thy f_indexToX (begin) - t) / thy dx;
+ angle = NUMpi * (Sampled_indexToX (thee.peek(), begin) - t) / thy dx;
halfampsinangle = 0.5 * amplitude * sin (angle);
for (j = begin; j <= end; j ++) {
if (fabs (angle) < 1e-6)
diff --git a/fon/Formant.cpp b/fon/Formant.cpp
index 565fe24..25c400e 100644
--- a/fon/Formant.cpp
+++ b/fon/Formant.cpp
@@ -1,6 +1,6 @@
/* Formant.cpp
*
- * Copyright (C) 1992-2012 Paul Boersma
+ * Copyright (C) 1992-2012,2014 Paul Boersma
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -124,7 +124,7 @@ void Formant_drawTracks (Formant me, Graphics g, double tmin, double tmax, doubl
for (long itrack = 1; itrack <= ntrack; itrack ++) {
for (long iframe = itmin; iframe < itmax; iframe ++) {
Formant_Frame curFrame = & my d_frames [iframe], nextFrame = & my d_frames [iframe + 1];
- double x1 = my f_indexToX (iframe), x2 = my f_indexToX (iframe + 1);
+ double x1 = Sampled_indexToX (me, iframe), x2 = Sampled_indexToX (me, iframe + 1);
double f1 = curFrame -> formant [itrack]. frequency;
double f2 = nextFrame -> formant [itrack]. frequency;
if (NUMdefined (x1) && NUMdefined (f1) && NUMdefined (x2) && NUMdefined (f2))
@@ -162,7 +162,7 @@ void Formant_drawSpeckles_inside (Formant me, Graphics g, double tmin, double tm
for (long iframe = itmin; iframe <= itmax; iframe ++) {
Formant_Frame frame = & my d_frames [iframe];
- double x = my f_indexToX (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;
diff --git a/fon/FormantGrid.cpp b/fon/FormantGrid.cpp
index e184d54..cc54a22 100644
--- a/fon/FormantGrid.cpp
+++ b/fon/FormantGrid.cpp
@@ -294,7 +294,7 @@ FormantGrid Formant_downto_FormantGrid (Formant me) {
autoFormantGrid thee = FormantGrid_createEmpty (my xmin, my xmax, my maxnFormants);
for (long iframe = 1; iframe <= my nx; iframe ++) {
Formant_Frame frame = & my d_frames [iframe];
- double t = my f_indexToX (iframe);
+ double t = Sampled_indexToX (me, iframe);
for (long iformant = 1; iformant <= frame -> nFormants; iformant ++) {
Formant_Formant pair = & frame -> formant [iformant];
FormantGrid_addFormantPoint (thee.peek(), iformant, t, pair -> frequency);
diff --git a/fon/FormantTier.cpp b/fon/FormantTier.cpp
index ccadf98..5d41d95 100644
--- a/fon/FormantTier.cpp
+++ b/fon/FormantTier.cpp
@@ -162,7 +162,7 @@ FormantTier Formant_downto_FormantTier (Formant me) {
autoFormantTier thee = FormantTier_create (my xmin, my xmax);
for (long i = 1; i <= my nx; i ++) {
Formant_Frame frame = & my d_frames [i];
- autoFormantPoint point = FormantPoint_create (my f_indexToX (i));
+ autoFormantPoint point = FormantPoint_create (Sampled_indexToX (me, i));
point -> numberOfFormants = frame -> nFormants > 10 ? 10 : frame -> nFormants;
for (long j = 1; j <= point -> numberOfFormants; j ++) {
Formant_Formant pair = & frame -> formant [j];
diff --git a/fon/IntensityTierEditor.cpp b/fon/IntensityTierEditor.cpp
index 5caf59f..a1d6aa3 100644
--- a/fon/IntensityTierEditor.cpp
+++ b/fon/IntensityTierEditor.cpp
@@ -1,6 +1,6 @@
/* IntensityTierEditor.cpp
*
- * Copyright (C) 1992-2011,2012 Paul Boersma
+ * Copyright (C) 1992-2011,2012,2014 Paul Boersma
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,10 +30,10 @@ void structIntensityTierEditor :: v_createHelpMenuItems (EditorMenu menu) {
}
void structIntensityTierEditor :: v_play (double a_tmin, double a_tmax) {
- if (d_sound.data) {
- Sound_playPart (d_sound.data, a_tmin, a_tmax, theFunctionEditor_playCallback, this);
+ if (our d_sound.data) {
+ Sound_playPart (our d_sound.data, a_tmin, a_tmax, theFunctionEditor_playCallback, this);
} else {
- //IntensityTier_playPart (data, a_tmin, a_tmax, FALSE);
+ //IntensityTier_playPart (our data, a_tmin, a_tmax, FALSE);
}
}
diff --git a/fon/Manipulation.cpp b/fon/Manipulation.cpp
index 440625d..60a143b 100644
--- a/fon/Manipulation.cpp
+++ b/fon/Manipulation.cpp
@@ -276,13 +276,15 @@ static void copyBell2 (Sound me, PointProcess source, long isource, double leftW
}
static void copyFlat (Sound me, double tmin, double tmax, Sound thee, double tminTarget) {
- long imin, imax, iminTarget;
- imin = Sampled_xToHighIndex (me, tmin);
+ long imin = Sampled_xToHighIndex (me, tmin);
if (imin < 1) imin = 1;
- imax = Sampled_xToHighIndex (me, tmax) - 1; /* Not xToLowIndex: ensure separation of subsequent calls. */
+ long imax = Sampled_xToHighIndex (me, tmax) - 1; /* Not xToLowIndex: ensure separation of subsequent calls. */
if (imax > my nx) imax = my nx;
if (imax < imin) return;
- iminTarget = Sampled_xToHighIndex (thee, tminTarget);
+ long iminTarget = Sampled_xToHighIndex (thee, tminTarget);
+ if (iminTarget < 1) iminTarget = 1;
+ trace ("%.17g %.17g %.17g %ld %ld %ld", tmin, tmax, tminTarget, imin, imax, iminTarget);
+ Melder_assert (iminTarget + imax - imin <= thy nx);
NUMvector_copyElements (my z [1] + imin, thy z [1] + iminTarget, 0, imax - imin);
}
diff --git a/fon/ManipulationEditor.cpp b/fon/ManipulationEditor.cpp
index 6dc4006..e49a101 100644
--- a/fon/ManipulationEditor.cpp
+++ b/fon/ManipulationEditor.cpp
@@ -106,9 +106,9 @@ static int getDurationArea (ManipulationEditor me, double *ymin, double *ymax) {
/********** DESTRUCTION **********/
void structManipulationEditor :: v_destroy () {
- forget (previousPulses);
- forget (previousPitch);
- forget (previousDuration);
+ forget (our previousPulses);
+ forget (our previousPitch);
+ forget (our previousDuration);
ManipulationEditor_Parent :: v_destroy ();
}
@@ -158,21 +158,21 @@ static void menu_cb_extractManipulatedSound (EDITOR_ARGS) {
/***** EDIT MENU *****/
void structManipulationEditor :: v_saveData () {
- Manipulation ana = (Manipulation) data;
- forget (previousPulses);
- forget (previousPitch);
- forget (previousDuration);
- if (ana -> pulses) previousPulses = Data_copy (ana -> pulses);
- if (ana -> pitch) previousPitch = Data_copy (ana -> pitch);
- if (ana -> duration) previousDuration = Data_copy (ana -> duration);
+ Manipulation ana = (Manipulation) our data;
+ forget (our previousPulses);
+ forget (our previousPitch);
+ forget (our previousDuration);
+ if (ana -> pulses) our previousPulses = Data_copy (ana -> pulses);
+ if (ana -> pitch) our previousPitch = Data_copy (ana -> pitch);
+ if (ana -> duration) our previousDuration = Data_copy (ana -> duration);
}
void structManipulationEditor :: v_restoreData () {
- Manipulation ana = (Manipulation) data;
+ Manipulation ana = (Manipulation) our data;
Any dummy;
- dummy = ana -> pulses; ana -> pulses = previousPulses; previousPulses = (PointProcess) dummy;
- dummy = ana -> pitch; ana -> pitch = previousPitch; previousPitch = (PitchTier) dummy;
- dummy = ana -> duration; ana -> duration = previousDuration; previousDuration = (DurationTier) dummy;
+ dummy = ana -> pulses; ana -> pulses = our previousPulses; our previousPulses = (PointProcess) dummy;
+ dummy = ana -> pitch; ana -> pitch = our previousPitch; our previousPitch = (PitchTier) dummy;
+ dummy = ana -> duration; ana -> duration = our previousDuration; our previousDuration = (DurationTier) dummy;
}
/***** PULSES MENU *****/
@@ -615,18 +615,18 @@ void structManipulationEditor :: v_createMenus () {
Editor_addCommand (this, L"Dur", L"Forget duration", 0, menu_cb_forgetDuration);
Editor_addMenu (this, L"Synth", 0);
- synthPulsesButton = Editor_addCommand (this, L"Synth", L"Pulses --", GuiMenu_RADIO_FIRST, menu_cb_Synth_Pulses);
- synthPulsesHumButton = Editor_addCommand (this, L"Synth", L"Pulses (hum) --", GuiMenu_RADIO_NEXT, menu_cb_Synth_Pulses_hum);
+ our synthPulsesButton = Editor_addCommand (this, L"Synth", L"Pulses --", GuiMenu_RADIO_FIRST, menu_cb_Synth_Pulses);
+ our synthPulsesHumButton = Editor_addCommand (this, L"Synth", L"Pulses (hum) --", GuiMenu_RADIO_NEXT, menu_cb_Synth_Pulses_hum);
- synthPulsesLpcButton = Editor_addCommand (this, L"Synth", L"Pulses & LPC -- (\"LPC resynthesis\")", GuiMenu_RADIO_NEXT, menu_cb_Synth_Pulses_Lpc);
+ our synthPulsesLpcButton = Editor_addCommand (this, L"Synth", L"Pulses & LPC -- (\"LPC resynthesis\")", GuiMenu_RADIO_NEXT, menu_cb_Synth_Pulses_Lpc);
Editor_addCommand (this, L"Synth", L"-- pitch resynth --", 0, NULL);
- synthPitchButton = Editor_addCommand (this, L"Synth", L" -- Pitch", GuiMenu_RADIO_NEXT, menu_cb_Synth_Pitch);
- synthPitchHumButton = Editor_addCommand (this, L"Synth", L" -- Pitch (hum)", GuiMenu_RADIO_NEXT, menu_cb_Synth_Pitch_hum);
- synthPulsesPitchButton = Editor_addCommand (this, L"Synth", L"Pulses -- Pitch", GuiMenu_RADIO_NEXT, menu_cb_Synth_Pulses_Pitch);
- synthPulsesPitchHumButton = Editor_addCommand (this, L"Synth", L"Pulses -- Pitch (hum)", GuiMenu_RADIO_NEXT, menu_cb_Synth_Pulses_Pitch_hum);
+ our synthPitchButton = Editor_addCommand (this, L"Synth", L" -- Pitch", GuiMenu_RADIO_NEXT, menu_cb_Synth_Pitch);
+ our synthPitchHumButton = Editor_addCommand (this, L"Synth", L" -- Pitch (hum)", GuiMenu_RADIO_NEXT, menu_cb_Synth_Pitch_hum);
+ our synthPulsesPitchButton = Editor_addCommand (this, L"Synth", L"Pulses -- Pitch", GuiMenu_RADIO_NEXT, menu_cb_Synth_Pulses_Pitch);
+ our synthPulsesPitchHumButton = Editor_addCommand (this, L"Synth", L"Pulses -- Pitch (hum)", GuiMenu_RADIO_NEXT, menu_cb_Synth_Pulses_Pitch_hum);
Editor_addCommand (this, L"Synth", L"-- full resynth --", 0, NULL);
- synthOverlapAddButton = Editor_addCommand (this, L"Synth", L"Sound & Pulses -- Pitch & Duration (\"Overlap-add manipulation\")", GuiMenu_RADIO_NEXT | GuiMenu_TOGGLE_ON, menu_cb_Synth_OverlapAdd);
- synthPitchLpcButton = Editor_addCommand (this, L"Synth", L"LPC -- Pitch (\"LPC pitch manipulation\")", GuiMenu_RADIO_NEXT, menu_cb_Synth_Pitch_Lpc);
+ our synthOverlapAddButton = Editor_addCommand (this, L"Synth", L"Sound & Pulses -- Pitch & Duration (\"Overlap-add manipulation\")", GuiMenu_RADIO_NEXT | GuiMenu_TOGGLE_ON, menu_cb_Synth_OverlapAdd);
+ our synthPitchLpcButton = Editor_addCommand (this, L"Synth", L"LPC -- Pitch (\"LPC pitch manipulation\")", GuiMenu_RADIO_NEXT, menu_cb_Synth_Pitch_Lpc);
}
void structManipulationEditor :: v_createHelpMenuItems (EditorMenu menu) {
@@ -700,7 +700,7 @@ static void drawSoundArea (ManipulationEditor me, double ymin, double ymax) {
*/
Graphics_setColour (my d_graphics, Graphics_BLACK);
Graphics_function (my d_graphics, sound -> z [1], first, last,
- sound -> f_indexToX (first), sound -> f_indexToX (last));
+ Sampled_indexToX (sound, first), Sampled_indexToX (sound, last));
}
Graphics_resetViewport (my d_graphics, viewport);
@@ -913,18 +913,18 @@ void structManipulationEditor :: v_draw () {
if (hasPitchArea) drawPitchArea (this, ypitchmin, ypitchmax);
if (hasDurationArea) drawDurationArea (this, ydurationmin, ydurationmax);
- Graphics_setWindow (d_graphics, 0.0, 1.0, 0.0, 1.0);
- Graphics_setGrey (d_graphics, 0.85);
- Graphics_fillRectangle (d_graphics, -0.001, 1.001, ypitchmax, ysoundmin);
- Graphics_setGrey (d_graphics, 0.00);
- Graphics_line (d_graphics, 0, ysoundmin, 1, ysoundmin);
- Graphics_line (d_graphics, 0, ypitchmax, 1, ypitchmax);
+ Graphics_setWindow (our d_graphics, 0.0, 1.0, 0.0, 1.0);
+ Graphics_setGrey (our d_graphics, 0.85);
+ Graphics_fillRectangle (our d_graphics, -0.001, 1.001, ypitchmax, ysoundmin);
+ Graphics_setGrey (our d_graphics, 0.00);
+ Graphics_line (our d_graphics, 0, ysoundmin, 1, ysoundmin);
+ Graphics_line (our d_graphics, 0, ypitchmax, 1, ypitchmax);
if (hasDurationArea) {
- Graphics_setGrey (d_graphics, 0.85);
- Graphics_fillRectangle (d_graphics, -0.001, 1.001, ydurationmax, ypitchmin);
- Graphics_setGrey (d_graphics, 0.00);
- Graphics_line (d_graphics, 0, ypitchmin, 1, ypitchmin);
- Graphics_line (d_graphics, 0, ydurationmax, 1, ydurationmax);
+ Graphics_setGrey (our d_graphics, 0.85);
+ Graphics_fillRectangle (our d_graphics, -0.001, 1.001, ydurationmax, ypitchmin);
+ Graphics_setGrey (our d_graphics, 0.00);
+ Graphics_line (our d_graphics, 0, ypitchmin, 1, ypitchmin);
+ Graphics_line (our d_graphics, 0, ydurationmax, 1, ydurationmax);
}
updateMenus (this);
}
@@ -1234,25 +1234,25 @@ int structManipulationEditor :: v_click (double xWC, double yWC, bool shiftKeyPr
* Dispatch click to clicked area.
*/
if (hasPitchArea && yWC > ypitchmin && yWC < ypitchmax) { // clicked in pitch area?
- inset = Graphics_insetViewport (d_graphics, 0, 1, ypitchmin, ypitchmax);
+ inset = Graphics_insetViewport (our d_graphics, 0, 1, ypitchmin, ypitchmax);
return clickPitch (this, xWC, (yWC - ypitchmin) / (ypitchmax - ypitchmin), shiftKeyPressed);
} else if (hasDurationArea && yWC > ydurationmin && yWC < ydurationmax) { // clicked in duration area?
- inset = Graphics_insetViewport (d_graphics, 0, 1, ydurationmin, ydurationmax);
+ inset = Graphics_insetViewport (our d_graphics, 0, 1, ydurationmin, ydurationmax);
return clickDuration (this, xWC, (yWC - ydurationmin) / (ydurationmax - ydurationmin), shiftKeyPressed);
}
/*
* Perform the default action: move cursor or drag selection.
*/
- return ManipulationEditor_Parent :: v_click (xWC, yWC, shiftKeyPressed);
+ return our ManipulationEditor_Parent :: v_click (xWC, yWC, shiftKeyPressed);
}
void structManipulationEditor :: v_play (double a_tmin, double a_tmax) {
- Manipulation ana = (Manipulation) data;
- if (shiftKeyPressed) {
+ Manipulation ana = (Manipulation) our data;
+ if (our shiftKeyPressed) {
if (ana -> sound)
Sound_playPart (ana -> sound, a_tmin, a_tmax, theFunctionEditor_playCallback, this);
} else {
- Manipulation_playPart (ana, a_tmin, a_tmax, synthesisMethod);
+ Manipulation_playPart (ana, a_tmin, a_tmax, our synthesisMethod);
}
}
diff --git a/fon/Matrix.cpp b/fon/Matrix.cpp
index 0b9ada5..0e6705a 100644
--- a/fon/Matrix.cpp
+++ b/fon/Matrix.cpp
@@ -44,71 +44,71 @@ Thing_implement (Matrix, SampledXY, 2);
void structMatrix :: v_info () {
structData :: v_info ();
double minimum = 0.0, maximum = 0.0;
- Matrix_getWindowExtrema (this, 1, nx, 1, ny, & minimum, & maximum);
- MelderInfo_writeLine (L"xmin: ", Melder_double (xmin));
- MelderInfo_writeLine (L"xmax: ", Melder_double (xmax));
- MelderInfo_writeLine (L"Number of columns: ", Melder_integer (nx));
- MelderInfo_writeLine (L"dx: ", Melder_double (dx), L" (-> sampling rate ", Melder_double (1.0 / dx), L" )");
- MelderInfo_writeLine (L"x1: ", Melder_double (x1));
- MelderInfo_writeLine (L"ymin: ", Melder_double (ymin));
- MelderInfo_writeLine (L"ymax: ", Melder_double (ymax));
- MelderInfo_writeLine (L"Number of rows: ", Melder_integer (ny));
- MelderInfo_writeLine (L"dy: ", Melder_double (dy), L" (-> sampling rate ", Melder_double (1.0 / dy), L" )");
- MelderInfo_writeLine (L"y1: ", Melder_double (y1));
+ Matrix_getWindowExtrema (this, 1, our nx, 1, our ny, & minimum, & maximum);
+ MelderInfo_writeLine (L"xmin: ", Melder_double (our xmin));
+ MelderInfo_writeLine (L"xmax: ", Melder_double (our xmax));
+ MelderInfo_writeLine (L"Number of columns: ", Melder_integer (our nx));
+ MelderInfo_writeLine (L"dx: ", Melder_double (our dx), L" (-> sampling rate ", Melder_double (1.0 / our dx), L" )");
+ MelderInfo_writeLine (L"x1: ", Melder_double (our x1));
+ MelderInfo_writeLine (L"ymin: ", Melder_double (our ymin));
+ MelderInfo_writeLine (L"ymax: ", Melder_double (our ymax));
+ MelderInfo_writeLine (L"Number of rows: ", Melder_integer (our ny));
+ MelderInfo_writeLine (L"dy: ", Melder_double (our dy), L" (-> sampling rate ", Melder_double (1.0 / our dy), L" )");
+ MelderInfo_writeLine (L"y1: ", Melder_double (our y1));
MelderInfo_writeLine (L"Minimum value: ", Melder_single (minimum));
MelderInfo_writeLine (L"Maximum value: ", Melder_single (maximum));
}
void structMatrix :: v_readText (MelderReadText text) {
if (Thing_version < 0) {
- xmin = texgetr8 (text);
- xmax = texgetr8 (text);
- ymin = texgetr8 (text);
- ymax = texgetr8 (text);
- nx = texgeti4 (text);
- ny = texgeti4 (text);
- dx = texgetr8 (text);
- dy = texgetr8 (text);
- x1 = texgetr8 (text);
- y1 = texgetr8 (text);
+ our xmin = texgetr8 (text);
+ our xmax = texgetr8 (text);
+ our ymin = texgetr8 (text);
+ our ymax = texgetr8 (text);
+ our nx = texgeti4 (text);
+ our ny = texgeti4 (text);
+ our dx = texgetr8 (text);
+ our dy = texgetr8 (text);
+ our x1 = texgetr8 (text);
+ our y1 = texgetr8 (text);
} else {
Matrix_Parent :: v_readText (text);
}
- if (xmin > xmax)
+ if (our xmin > our xmax)
Melder_throw ("xmin should be less than or equal to xmax.");
- if (ymin > ymax)
+ if (our ymin > our ymax)
Melder_throw ("ymin should be less than or equal to ymax.");
- if (nx < 1)
+ if (our nx < 1)
Melder_throw ("nx should be at least 1.");
- if (ny < 1)
+ if (our ny < 1)
Melder_throw ("ny should be at least 1.");
- if (dx <= 0.0)
+ if (our dx <= 0.0)
Melder_throw ("dx should be greater than 0.0.");
- if (dy <= 0.0)
+ if (our dy <= 0.0)
Melder_throw ("dy should be greater than 0.0.");
- z = NUMmatrix_readText_r8 (1, ny, 1, nx, text, "z");
+ our z = NUMmatrix_readText_r8 (1, our ny, 1, our nx, text, "z");
}
double structMatrix :: v_getValueAtSample (long isamp, long ilevel, int unit) {
- double value = z [ilevel] [isamp];
- return NUMdefined (value) ? v_convertStandardToSpecialUnit (value, ilevel, unit) : NUMundefined;
+ double value = our z [ilevel] [isamp];
+ return NUMdefined (value) ? our v_convertStandardToSpecialUnit (value, ilevel, unit) : NUMundefined;
}
double structMatrix :: v_getMatrix (long irow, long icol) {
- if (irow < 1 || irow > ny) return 0.0;
- if (icol < 1 || icol > nx) return 0.0;
+ if (irow < 1 || irow > our ny) return 0.0;
+ if (icol < 1 || icol > our nx) return 0.0;
return z [irow] [icol];
}
double structMatrix :: v_getFunction2 (double x, double y) {
- double rrow = (y - y1) / dy + 1.0;
- double rcol = (x - x1) / dx + 1.0;
+ double rrow = (y - our y1) / our dy + 1.0;
+ double rcol = (x - our x1) / our dx + 1.0;
long irow = floor (rrow), icol = floor (rcol);
double drow = rrow - irow, dcol = rcol - icol;
- double z1 = irow < 1 || irow > ny || icol < 1 || icol > nx ? 0.0 : z [irow] [icol];
- double z2 = irow < 0 || irow >= ny || icol < 1 || icol > nx ? 0.0 : z [irow + 1] [icol];
- double z3 = irow < 1 || irow > ny || icol < 0 || icol >= nx ? 0.0 : z [irow] [icol + 1];
- double z4 = irow < 0 || irow >= ny || icol < 0 || icol >= nx ? 0.0 : z [irow + 1] [icol + 1];
+ double z1 = irow < 1 || irow > our ny || icol < 1 || icol > our nx ? 0.0 : z [irow] [icol];
+ double z2 = irow < 0 || irow >= our ny || icol < 1 || icol > our nx ? 0.0 : z [irow + 1] [icol];
+ double z3 = irow < 1 || irow > our ny || icol < 0 || icol >= our nx ? 0.0 : z [irow] [icol + 1];
+ double z4 = irow < 0 || irow >= our ny || icol < 0 || icol >= our nx ? 0.0 : z [irow + 1] [icol + 1];
return (1.0 - drow) * (1.0 - dcol) * z1 + drow * (1.0 - dcol) * z2 + (1.0 - drow) * dcol * z3 + drow * dcol * z4;
}
@@ -374,13 +374,13 @@ static void cellArrayOrImage (Matrix me, Graphics g, double xmin, double xmax, d
Graphics_setWindow (g, xmin, xmax, ymin, ymax);
if (interpolate)
Graphics_image (g, my z,
- ixmin, ixmax, my f_indexToX (ixmin - 0.5), my f_indexToX (ixmax + 0.5),
- iymin, iymax, my f_indexToY (iymin - 0.5), my f_indexToY (iymax + 0.5),
+ ixmin, ixmax, Sampled_indexToX (me, ixmin - 0.5), Sampled_indexToX (me, ixmax + 0.5),
+ iymin, iymax, SampledXY_indexToY (me, iymin - 0.5), SampledXY_indexToY (me, iymax + 0.5),
minimum, maximum);
else
Graphics_cellArray (g, my z,
- ixmin, ixmax, my f_indexToX (ixmin - 0.5), my f_indexToX (ixmax + 0.5),
- iymin, iymax, my f_indexToY (iymin - 0.5), my f_indexToY (iymax + 0.5),
+ ixmin, ixmax, Sampled_indexToX (me, ixmin - 0.5), Sampled_indexToX (me, ixmax + 0.5),
+ iymin, iymax, SampledXY_indexToY (me, iymin - 0.5), SampledXY_indexToY (me, iymax + 0.5),
minimum, maximum);
Graphics_rectangle (g, xmin, xmax, ymin, ymax);
Graphics_unsetInner (g);
diff --git a/fon/MovieWindow.cpp b/fon/MovieWindow.cpp
index 470a98e..4e8be66 100644
--- a/fon/MovieWindow.cpp
+++ b/fon/MovieWindow.cpp
@@ -57,7 +57,7 @@ void structMovieWindow :: v_draw () {
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);
- our f_drawSound (-1.0, 1.0);
+ TimeSoundEditor_drawSound (this, -1.0, 1.0);
Graphics_flushWs (our d_graphics);
Graphics_resetViewport (our d_graphics, viewport);
}
@@ -68,12 +68,12 @@ void structMovieWindow :: v_draw () {
Graphics_fillRectangle (our d_graphics, 0, 1, 0, 1);
Graphics_setColour (our d_graphics, Graphics_BLACK);
Graphics_setWindow (our d_graphics, our d_startWindow, our d_endWindow, 0.0, 1.0);
- long firstFrame = movie -> f_xToNearestIndex (our d_startWindow);
- long lastFrame = movie -> f_xToNearestIndex (our d_endWindow);
+ long firstFrame = Sampled_xToNearestIndex (movie, our d_startWindow);
+ long lastFrame = Sampled_xToNearestIndex (movie, our d_endWindow);
if (firstFrame < 1) firstFrame = 1;
if (lastFrame > movie -> nx) lastFrame = movie -> nx;
for (long iframe = firstFrame; iframe <= lastFrame; iframe ++) {
- double time = movie -> f_indexToX (iframe);
+ double time = Sampled_indexToX (movie, iframe);
double timeLeft = time - 0.5 * movie -> dx, timeRight = time + 0.5 * movie -> dx;
if (timeLeft < our d_startWindow) timeLeft = our d_startWindow;
if (timeRight > our d_endWindow) timeRight = our d_endWindow;
@@ -91,7 +91,7 @@ void structMovieWindow :: v_draw () {
if (our p_pulses_show) {
viewport = Graphics_insetViewport (our d_graphics, 0.0, 1.0, soundY, 1.0);
our v_draw_analysis_pulses ();
- our f_drawSound (-1.0, 1.0); // second time, partially across the pulses
+ TimeSoundEditor_drawSound (this, -1.0, 1.0); // second time, partially across the pulses
Graphics_flushWs (our d_graphics);
Graphics_resetViewport (our d_graphics, viewport);
}
@@ -124,7 +124,7 @@ void structMovieWindow :: v_play (double tmin, double tmax) {
void MovieWindow_init (MovieWindow me, const wchar_t *title, Movie movie) {
Melder_assert (movie != NULL);
- my structTimeSoundAnalysisEditor :: f_init (title, movie, movie -> d_sound, false);
+ TimeSoundAnalysisEditor_init (me, title, movie, movie -> d_sound, false);
}
MovieWindow MovieWindow_create (const wchar_t *title, Movie movie) {
diff --git a/fon/ParamCurve.cpp b/fon/ParamCurve.cpp
index a1dfbe5..88e0fcc 100644
--- a/fon/ParamCurve.cpp
+++ b/fon/ParamCurve.cpp
@@ -137,9 +137,9 @@ void ParamCurve_draw (ParamCurve me, Graphics g, double t1, double t2, double dt
autoNUMvector <double> y (1, numberOfPoints);
for (long i = 1; i <= numberOfPoints; i ++) {
double t = i == numberOfPoints ? t2 : t1 + (i - 1) * dt;
- double index = my x -> f_xToIndex (t);
+ double index = Sampled_xToIndex (my x, t);
x [i] = NUM_interpolate_sinc (my x -> z [1], my x -> nx, index, 50);
- index = my y -> f_xToIndex (t);
+ index = Sampled_xToIndex (my y, t);
y [i] = NUM_interpolate_sinc (my y -> z [1], my y -> nx, index, 50);
}
Graphics_setWindow (g, x1, x2, y1, y2);
diff --git a/fon/Photo.cpp b/fon/Photo.cpp
index 4df5196..fbbf21c 100644
--- a/fon/Photo.cpp
+++ b/fon/Photo.cpp
@@ -69,7 +69,7 @@ void Photo_init (Photo me,
double xmin, double xmax, long nx, double dx, double x1,
double ymin, double ymax, long ny, double dy, double y1)
{
- my structSampledXY :: f_init (xmin, xmax, nx, dx, x1, ymin, ymax, ny, dy, y1);
+ SampledXY_init (me, xmin, xmax, nx, dx, x1, ymin, ymax, ny, dy, y1);
my d_red = Matrix_create (xmin, xmax, nx, dx, x1, ymin, ymax, ny, dy, y1);
my d_green = Matrix_create (xmin, xmax, nx, dx, x1, ymin, ymax, ny, dy, y1);
my d_blue = Matrix_create (xmin, xmax, nx, dx, x1, ymin, ymax, ny, dy, y1);
@@ -219,85 +219,85 @@ Photo Photo_readFromImageFile (MelderFile file) {
#endif
#ifdef linux
- void structPhoto :: _lin_saveAsImageFile (MelderFile file, const wchar_t *which) {
+ static void _lin_saveAsImageFile (Photo me, MelderFile file, const wchar_t *which) {
cairo_format_t format = CAIRO_FORMAT_ARGB32;
- long bytesPerRow = cairo_format_stride_for_width (format, our nx); // likely to be our nx * 4;
- long numberOfRows = our ny;
+ long bytesPerRow = cairo_format_stride_for_width (format, my nx); // likely to be my nx * 4;
+ long numberOfRows = my ny;
unsigned char *imageData = Melder_malloc_f (unsigned char, bytesPerRow * numberOfRows);
- for (long irow = 1; irow <= ny; irow ++) {
- uint8_t *rowAddress = imageData + bytesPerRow * (ny - irow);
- for (long icol = 1; icol <= nx; icol ++) {
- * rowAddress ++ = round (our d_blue -> z [irow] [icol] * 255.0);
- * rowAddress ++ = round (our d_green -> z [irow] [icol] * 255.0);
- * rowAddress ++ = round (our d_red -> z [irow] [icol] * 255.0);
- * rowAddress ++ = 255 - round (our d_transparency -> z [irow] [icol] * 255.0);
+ for (long irow = 1; irow <= my ny; irow ++) {
+ uint8_t *rowAddress = imageData + bytesPerRow * (my ny - irow);
+ for (long icol = 1; icol <= my nx; icol ++) {
+ * rowAddress ++ = round (my d_blue -> z [irow] [icol] * 255.0);
+ * rowAddress ++ = round (my d_green -> z [irow] [icol] * 255.0);
+ * rowAddress ++ = round (my d_red -> z [irow] [icol] * 255.0);
+ * rowAddress ++ = 255 - round (my d_transparency -> z [irow] [icol] * 255.0);
}
}
cairo_surface_t *surface = cairo_image_surface_create_for_data (imageData,
- format, our nx, our ny, bytesPerRow);
+ format, my nx, my ny, bytesPerRow);
cairo_surface_write_to_png (surface, Melder_peekWcsToUtf8 (file -> path));
cairo_surface_destroy (surface);
}
#endif
#ifdef _WIN32
-void structPhoto::_win_saveAsImageFile (MelderFile file, const wchar_t *mimeType) {
- Gdiplus::Bitmap gdiplusBitmap (nx, ny, PixelFormat32bppARGB);
- for (long irow = 1; irow <= ny; irow ++) {
- for (long icol = 1; icol <= nx; icol ++) {
- Gdiplus::Color gdiplusColour (
- 255 - round (our d_transparency -> z [irow] [icol] * 255.0),
- round (our d_red -> z [irow] [icol] * 255.0),
- round (our d_green -> z [irow] [icol] * 255.0),
- round (our d_blue -> z [irow] [icol] * 255.0));
- gdiplusBitmap. SetPixel (icol - 1, ny - irow, gdiplusColour);
+ static void _win_saveAsImageFile (Photo me, MelderFile file, const wchar_t *mimeType) {
+ Gdiplus::Bitmap gdiplusBitmap (my nx, my ny, PixelFormat32bppARGB);
+ for (long irow = 1; irow <= my ny; irow ++) {
+ for (long icol = 1; icol <= my nx; icol ++) {
+ Gdiplus::Color gdiplusColour (
+ 255 - round (my d_transparency -> z [irow] [icol] * 255.0),
+ round (my d_red -> z [irow] [icol] * 255.0),
+ round (my d_green -> z [irow] [icol] * 255.0),
+ round (my d_blue -> z [irow] [icol] * 255.0));
+ gdiplusBitmap. SetPixel (icol - 1, my ny - irow, gdiplusColour);
+ }
}
- }
- /*
- * The 'mimeType' parameter specifies a "class encoder". Look it up.
- */
- UINT numberOfImageEncoders, sizeOfImageEncoderArray;
- Gdiplus::GetImageEncodersSize (& numberOfImageEncoders, & sizeOfImageEncoderArray);
- if (sizeOfImageEncoderArray == 0)
- Melder_throw ("Cannot find image encoders.");
- Gdiplus::ImageCodecInfo *imageEncoderInfos = Melder_malloc (Gdiplus::ImageCodecInfo, sizeOfImageEncoderArray);
- Gdiplus::GetImageEncoders (numberOfImageEncoders, sizeOfImageEncoderArray, imageEncoderInfos);
- for (int iencoder = 0; iencoder < numberOfImageEncoders; iencoder ++) {
- trace ("Supported MIME type: %ls", imageEncoderInfos [iencoder]. MimeType);
- if (Melder_wcsequ (imageEncoderInfos [iencoder]. MimeType, mimeType)) {
- Gdiplus::EncoderParameters *p = NULL;
- Gdiplus::EncoderParameters encoderParameters;
- if (Melder_wcsequ (mimeType, L"image/jpeg")) {
- encoderParameters. Count = 1;
- GUID guid = { 0x1D5BE4B5, 0xFA4A, 0x452D, { 0x9C, 0xDD, 0x5D, 0xB3, 0x51, 0x05, 0xE7, 0xEB }}; // EncoderQuality
- encoderParameters. Parameter [0]. Guid = guid;
- encoderParameters. Parameter [0]. Type = Gdiplus::EncoderParameterValueTypeLong;
- encoderParameters. Parameter [0]. NumberOfValues = 1;
- ULONG quality = 100;
- encoderParameters. Parameter [0]. Value = & quality;
- p = & encoderParameters;
+ /*
+ * The 'mimeType' parameter specifies a "class encoder". Look it up.
+ */
+ UINT numberOfImageEncoders, sizeOfImageEncoderArray;
+ Gdiplus::GetImageEncodersSize (& numberOfImageEncoders, & sizeOfImageEncoderArray);
+ if (sizeOfImageEncoderArray == 0)
+ Melder_throw ("Cannot find image encoders.");
+ Gdiplus::ImageCodecInfo *imageEncoderInfos = Melder_malloc (Gdiplus::ImageCodecInfo, sizeOfImageEncoderArray);
+ Gdiplus::GetImageEncoders (numberOfImageEncoders, sizeOfImageEncoderArray, imageEncoderInfos);
+ for (int iencoder = 0; iencoder < numberOfImageEncoders; iencoder ++) {
+ trace ("Supported MIME type: %ls", imageEncoderInfos [iencoder]. MimeType);
+ if (Melder_wcsequ (imageEncoderInfos [iencoder]. MimeType, mimeType)) {
+ Gdiplus::EncoderParameters *p = NULL;
+ Gdiplus::EncoderParameters encoderParameters;
+ if (Melder_wcsequ (mimeType, L"image/jpeg")) {
+ encoderParameters. Count = 1;
+ GUID guid = { 0x1D5BE4B5, 0xFA4A, 0x452D, { 0x9C, 0xDD, 0x5D, 0xB3, 0x51, 0x05, 0xE7, 0xEB }}; // EncoderQuality
+ encoderParameters. Parameter [0]. Guid = guid;
+ encoderParameters. Parameter [0]. Type = Gdiplus::EncoderParameterValueTypeLong;
+ encoderParameters. Parameter [0]. NumberOfValues = 1;
+ ULONG quality = 100;
+ encoderParameters. Parameter [0]. Value = & quality;
+ p = & encoderParameters;
+ }
+ gdiplusBitmap. Save (file -> path, & imageEncoderInfos [iencoder]. Clsid, p);
+ Melder_free (imageEncoderInfos);
+ return;
}
- gdiplusBitmap. Save (file -> path, & imageEncoderInfos [iencoder]. Clsid, p);
- Melder_free (imageEncoderInfos);
- return;
}
+ Melder_throw ("Unknown MIME type ", mimeType, ".");
}
- Melder_throw ("Unknown MIME type ", mimeType, ".");
-}
#endif
#ifdef macintosh
- void structPhoto :: _mac_saveAsImageFile (MelderFile file, const void *which) {
- long bytesPerRow = our nx * 4;
- long numberOfRows = our ny;
+ static void _mac_saveAsImageFile (Photo me, MelderFile file, const void *which) {
+ long bytesPerRow = my nx * 4;
+ long numberOfRows = my ny;
unsigned char *imageData = Melder_malloc_f (unsigned char, bytesPerRow * numberOfRows);
- for (long irow = 1; irow <= ny; irow ++) {
- uint8_t *rowAddress = imageData + bytesPerRow * (ny - irow);
- for (long icol = 1; icol <= nx; icol ++) {
- * rowAddress ++ = round (our d_red -> z [irow] [icol] * 255.0);
- * rowAddress ++ = round (our d_green -> z [irow] [icol] * 255.0);
- * rowAddress ++ = round (our d_blue -> z [irow] [icol] * 255.0);
- * rowAddress ++ = 255 - round (d_transparency -> z [irow] [icol] * 255.0);
+ for (long irow = 1; irow <= my ny; irow ++) {
+ uint8_t *rowAddress = imageData + bytesPerRow * (my ny - irow);
+ for (long icol = 1; icol <= my nx; icol ++) {
+ * rowAddress ++ = round (my d_red -> z [irow] [icol] * 255.0);
+ * rowAddress ++ = round (my d_green -> z [irow] [icol] * 255.0);
+ * rowAddress ++ = round (my d_blue -> z [irow] [icol] * 255.0);
+ * rowAddress ++ = 255 - round (my d_transparency -> z [irow] [icol] * 255.0);
}
}
static CGColorSpaceRef colourSpace = NULL;
@@ -311,7 +311,7 @@ void structPhoto::_win_saveAsImageFile (MelderFile file, const wchar_t *mimeType
_mac_releaseDataCallback // needed?
);
Melder_assert (dataProvider != NULL);
- CGImageRef image = CGImageCreate (this -> nx, numberOfRows,
+ CGImageRef image = CGImageCreate (my nx, numberOfRows,
8, 32, bytesPerRow, colourSpace, kCGImageAlphaNone, dataProvider, NULL, false, kCGRenderingIntentDefault);
CGDataProviderRelease (dataProvider);
Melder_assert (image != NULL);
@@ -330,116 +330,123 @@ void structPhoto::_win_saveAsImageFile (MelderFile file, const wchar_t *mimeType
}
#endif
-void structPhoto :: f_saveAsPNG (MelderFile file) {
+void Photo_saveAsPNG (Photo me, MelderFile file) {
#if defined (_WIN32)
- _win_saveAsImageFile (file, L"image/png");
+ _win_saveAsImageFile (me, file, L"image/png");
#elif defined (macintosh)
- _mac_saveAsImageFile (file, kUTTypePNG);
+ _mac_saveAsImageFile (me, file, kUTTypePNG);
#elif defined (linux)
- _lin_saveAsImageFile (file, L"image/png");
+ _lin_saveAsImageFile (me, file, L"image/png");
#endif
}
-void structPhoto :: f_saveAsTIFF (MelderFile file) {
+void Photo_saveAsTIFF (Photo me, MelderFile file) {
#if defined (_WIN32)
- _win_saveAsImageFile (file, L"image/tiff");
+ _win_saveAsImageFile (me, file, L"image/tiff");
#elif defined (macintosh)
- _mac_saveAsImageFile (file, kUTTypeTIFF);
+ _mac_saveAsImageFile (me, file, kUTTypeTIFF);
#else
+ (void) me;
(void) file;
#endif
}
-void structPhoto :: f_saveAsGIF (MelderFile file) {
+void Photo_saveAsGIF (Photo me, MelderFile file) {
#if defined (_WIN32)
- _win_saveAsImageFile (file, L"image/gif");
+ _win_saveAsImageFile (me, file, L"image/gif");
#elif defined (macintosh)
- _mac_saveAsImageFile (file, kUTTypeGIF);
+ _mac_saveAsImageFile (me, file, kUTTypeGIF);
#else
+ (void) me;
(void) file;
#endif
}
-void structPhoto :: f_saveAsWindowsBitmapFile (MelderFile file) {
+void Photo_saveAsWindowsBitmapFile (Photo me, MelderFile file) {
#if defined (_WIN32)
- _win_saveAsImageFile (file, L"image/bmp");
+ _win_saveAsImageFile (me, file, L"image/bmp");
#elif defined (macintosh)
- _mac_saveAsImageFile (file, kUTTypeBMP);
+ _mac_saveAsImageFile (me, file, kUTTypeBMP);
#else
+ (void) me;
(void) file;
#endif
}
-void structPhoto :: f_saveAsJPEG (MelderFile file) {
+void Photo_saveAsJPEG (Photo me, MelderFile file) {
#if defined (_WIN32)
- _win_saveAsImageFile (file, L"image/jpeg");
+ _win_saveAsImageFile (me, file, L"image/jpeg");
#elif defined (macintosh)
- _mac_saveAsImageFile (file, kUTTypeJPEG);
+ _mac_saveAsImageFile (me, file, kUTTypeJPEG);
#else
+ (void) me;
(void) file;
#endif
}
-void structPhoto :: f_saveAsJPEG2000 (MelderFile file) {
+void Photo_saveAsJPEG2000 (Photo me, MelderFile file) {
#if defined (_WIN32)
- _win_saveAsImageFile (file, L"image/jpeg2000");
+ _win_saveAsImageFile (me, file, L"image/jpeg2000");
#elif defined (macintosh)
- _mac_saveAsImageFile (file, kUTTypeJPEG2000);
+ _mac_saveAsImageFile (me, file, kUTTypeJPEG2000);
#else
+ (void) me;
(void) file;
#endif
}
-void structPhoto :: f_saveAsAppleIconFile (MelderFile file) {
+void Photo_saveAsAppleIconFile (Photo me, MelderFile file) {
#if defined (_WIN32)
- _win_saveAsImageFile (file, L"image/ICNS");
+ _win_saveAsImageFile (me, file, L"image/ICNS");
#elif defined (macintosh)
- _mac_saveAsImageFile (file, kUTTypeAppleICNS);
+ _mac_saveAsImageFile (me, file, kUTTypeAppleICNS);
#else
+ (void) me;
(void) file;
#endif
}
-void structPhoto :: f_saveAsWindowsIconFile (MelderFile file) {
+void Photo_saveAsWindowsIconFile (Photo me, MelderFile file) {
#if defined (_WIN32)
- _win_saveAsImageFile (file, L"image/icon");
+ _win_saveAsImageFile (me, file, L"image/icon");
#elif defined (macintosh)
- _mac_saveAsImageFile (file, kUTTypeICO);
+ _mac_saveAsImageFile (me, file, kUTTypeICO);
#else
+ (void) me;
(void) file;
#endif
}
-void structPhoto :: f_replaceRed (Matrix a_red) {
- autoMatrix copy = Data_copy (a_red);
- forget (our d_red);
- our d_red = copy.transfer();
+void Photo_replaceRed (Photo me, Matrix red) {
+ autoMatrix copy = Data_copy (red);
+ forget (my d_red);
+ my d_red = copy.transfer();
}
-void structPhoto :: f_replaceGreen (Matrix a_green) {
- autoMatrix copy = Data_copy (a_green);
- forget (our d_green);
- our d_green = copy.transfer();
+void Photo_replaceGreen (Photo me, Matrix green) {
+ autoMatrix copy = Data_copy (green);
+ forget (my d_green);
+ my d_green = copy.transfer();
}
-void structPhoto :: f_replaceBlue (Matrix a_blue) {
- autoMatrix copy = Data_copy (a_blue);
- forget (our d_blue);
- our d_blue = copy.transfer();
+void Photo_replaceBlue (Photo me, Matrix blue) {
+ autoMatrix copy = Data_copy (blue);
+ forget (my d_blue);
+ my d_blue = copy.transfer();
}
-void structPhoto :: f_replaceTransparency (Matrix a_transparency) {
- autoMatrix copy = Data_copy (a_transparency);
- forget (our d_transparency);
- our d_transparency = copy.transfer();
+void Photo_replaceTransparency (Photo me, Matrix transparency) {
+ autoMatrix copy = Data_copy (transparency);
+ forget (my d_transparency);
+ my d_transparency = copy.transfer();
}
static void _Photo_cellArrayOrImage (Photo me, Graphics g, double xmin, double xmax, double ymin, double ymax, bool interpolate) {
if (xmax <= xmin) { xmin = my xmin; xmax = my xmax; }
if (ymax <= ymin) { ymin = my ymin; ymax = my ymax; }
long ixmin, ixmax, iymin, iymax;
- Sampled_getWindowSamples (me, xmin - 0.49999 * my dx, xmax + 0.49999 * my dx, & ixmin, & ixmax);
- my f_getWindowSamplesY (ymin - 0.49999 * my dy, ymax + 0.49999 * my dy, & iymin, & iymax);
+ Sampled_getWindowSamples (me, xmin - 0.49999 * my dx, xmax + 0.49999 * my dx, & ixmin, & ixmax);
+ SampledXY_getWindowSamplesY (me, ymin - 0.49999 * my dy, ymax + 0.49999 * my dy, & iymin, & iymax);
if (ixmin > ixmax || iymin > iymax) {
Melder_fatal ("ixmin %ld ixmax %ld iymin %ld iymax %ld", ixmin, ixmax, iymin, iymax);
return;
@@ -457,22 +464,22 @@ static void _Photo_cellArrayOrImage (Photo me, Graphics g, double xmin, double x
}
if (interpolate)
Graphics_image_colour (g, z.peek(),
- ixmin, ixmax, my f_indexToX (ixmin - 0.5), my f_indexToX (ixmax + 0.5),
- iymin, iymax, my f_indexToY (iymin - 0.5), my f_indexToY (iymax + 0.5), 0.0, 1.0);
+ ixmin, ixmax, Sampled_indexToX (me, ixmin - 0.5), Sampled_indexToX (me, ixmax + 0.5),
+ iymin, iymax, SampledXY_indexToY (me, iymin - 0.5), SampledXY_indexToY (me, iymax + 0.5), 0.0, 1.0);
else
Graphics_cellArray_colour (g, z.peek(),
- ixmin, ixmax, my f_indexToX (ixmin - 0.5), my f_indexToX (ixmax + 0.5),
- iymin, iymax, my f_indexToY (iymin - 0.5), my f_indexToY (iymax + 0.5), 0.0, 1.0);
+ ixmin, ixmax, Sampled_indexToX (me, ixmin - 0.5), Sampled_indexToX (me, ixmax + 0.5),
+ iymin, iymax, SampledXY_indexToY (me, iymin - 0.5), SampledXY_indexToY (me, iymax + 0.5), 0.0, 1.0);
//Graphics_rectangle (g, xmin, xmax, ymin, ymax);
Graphics_unsetInner (g);
}
-void structPhoto :: f_paintImage (Graphics g, double xmin, double xmax, double ymin, double ymax) {
- _Photo_cellArrayOrImage (this, g, xmin, xmax, ymin, ymax, true);
+void Photo_paintImage (Photo me, Graphics g, double xmin, double xmax, double ymin, double ymax) {
+ _Photo_cellArrayOrImage (me, g, xmin, xmax, ymin, ymax, true);
}
-void structPhoto :: f_paintCells (Graphics g, double xmin, double xmax, double ymin, double ymax) {
- _Photo_cellArrayOrImage (this, g, xmin, xmax, ymin, ymax, false);
+void Photo_paintCells (Photo me, Graphics g, double xmin, double xmax, double ymin, double ymax) {
+ _Photo_cellArrayOrImage (me, g, xmin, xmax, ymin, ymax, false);
}
/* End of file Photo.cpp */
diff --git a/fon/Photo.h b/fon/Photo.h
index caeecf0..cabb569 100644
--- a/fon/Photo.h
+++ b/fon/Photo.h
@@ -80,5 +80,34 @@ Photo Photo_createSimple (long numberOfRows, long numberOfColumns);
Photo Photo_readFromImageFile (MelderFile file);
+double_rgbt Photo_getValueAtXY (Photo me, double x, double y);
+/*
+ Linear interpolation between matrix points,
+ constant extrapolation in cells on the edge,
+ NUMundefined outside the union of the unit squares around the points.
+*/
+
+void Photo_replaceRed (Photo me, Matrix red);
+void Photo_replaceGreen (Photo me, Matrix green);
+void Photo_replaceBlue (Photo me, Matrix blue);
+void Photo_replaceTransparency (Photo me, Matrix transparency);
+
+void Photo_paintImage (Photo me, Graphics g, double xmin, double xmax, double ymin, double ymax);
+
+void Photo_paintCells (Photo me, Graphics g, double xmin, double xmax, double ymin, double ymax);
+/*
+ Every sample is drawn as a rectangle.
+*/
+
+void Photo_movie (Photo me, Graphics g);
+void Photo_saveAsPNG (Photo me, MelderFile file);
+void Photo_saveAsTIFF (Photo me, MelderFile file);
+void Photo_saveAsGIF (Photo me, MelderFile file);
+void Photo_saveAsWindowsBitmapFile (Photo me, MelderFile file);
+void Photo_saveAsJPEG (Photo me, MelderFile file);
+void Photo_saveAsJPEG2000 (Photo me, MelderFile file);
+void Photo_saveAsAppleIconFile (Photo me, MelderFile file);
+void Photo_saveAsWindowsIconFile (Photo me, MelderFile file);
+
/* End of file Photo.h */
#endif
diff --git a/fon/Photo_def.h b/fon/Photo_def.h
index ae029eb..7203bf7 100644
--- a/fon/Photo_def.h
+++ b/fon/Photo_def.h
@@ -36,44 +36,6 @@ oo_DEFINE_CLASS (Photo, SampledXY)
virtual bool v_hasGetNy () { return true; } virtual double v_getNy () { return ny; }
virtual bool v_hasGetDy () { return true; } virtual double v_getDy () { return dy; }
virtual bool v_hasGetY () { return true; } virtual double v_getY (long iy) { return y1 + (iy - 1) * dy; }
- // functions:
-
- double_rgbt f_getValueAtXY (double x, double y);
- /*
- Linear interpolation between matrix points,
- constant extrapolation in cells on the edge,
- NUMundefined outside the union of the unit squares around the points.
- */
-
- void f_replaceRed (Matrix red);
- void f_replaceGreen (Matrix green);
- void f_replaceBlue (Matrix blue);
- void f_replaceTransparency (Matrix transparency);
-
- void f_paintImage (Graphics g, double xmin, double xmax, double ymin, double ymax);
-
- void f_paintCells (Graphics g, double xmin, double xmax, double ymin, double ymax);
- /*
- Every sample is drawn as a rectangle.
- */
-
- void f_movie (Graphics g);
- void f_saveAsPNG (MelderFile file);
- void f_saveAsTIFF (MelderFile file);
- void f_saveAsGIF (MelderFile file);
- void f_saveAsWindowsBitmapFile (MelderFile file);
- void f_saveAsJPEG (MelderFile file);
- void f_saveAsJPEG2000 (MelderFile file);
- void f_saveAsAppleIconFile (MelderFile file);
- void f_saveAsWindowsIconFile (MelderFile file);
- // helpers:
- #if defined (_WIN32)
- void _win_saveAsImageFile (MelderFile file, const wchar_t *which);
- #elif defined (macintosh)
- void _mac_saveAsImageFile (MelderFile file, const void *which);
- #elif defined (linux)
- void _lin_saveAsImageFile (MelderFile file, const wchar_t *which);
- #endif
#endif
oo_END_CLASS (Photo)
diff --git a/fon/Pitch.cpp b/fon/Pitch.cpp
index 101afa3..0a3fb9f 100644
--- a/fon/Pitch.cpp
+++ b/fon/Pitch.cpp
@@ -600,7 +600,7 @@ void Pitch_difference (Pitch me, Pitch thee) {
double myf = my frame [i]. candidate [1]. frequency, thyf = thy frame [i]. candidate [1]. frequency;
int myUnvoiced = myf == 0 || myf > my ceiling;
int thyUnvoiced = thyf == 0 || thyf > thy ceiling;
- double t = my f_indexToX (i);
+ double t = Sampled_indexToX (me, i);
if (myUnvoiced && ! thyUnvoiced) {
Melder_casual ("Frame %ld time %f: unvoiced to voiced.", i, t);
nuvtov ++;
diff --git a/fon/PitchEditor.cpp b/fon/PitchEditor.cpp
index 34bd32d..986db89 100644
--- a/fon/PitchEditor.cpp
+++ b/fon/PitchEditor.cpp
@@ -167,20 +167,20 @@ void structPitchEditor :: v_createHelpMenuItems (EditorMenu menu) {
/********** DRAWING AREA **********/
void structPitchEditor :: v_draw () {
- Pitch pitch = (Pitch) data;
+ Pitch pitch = (Pitch) our data;
long it, it1, it2;
double dyUnv, dyIntens;
- Graphics_setWindow (d_graphics, 0, 1, 0, 1);
- Graphics_setColour (d_graphics, Graphics_WHITE);
- Graphics_fillRectangle (d_graphics, 0, 1, 0, 1);
- Graphics_setColour (d_graphics, Graphics_BLACK);
- Graphics_rectangle (d_graphics, 0, 1, 0, 1);
+ 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 (d_graphics, HEIGHT_UNV);
- dyIntens = Graphics_dyMMtoWC (d_graphics, HEIGHT_INTENS);
+ dyUnv = Graphics_dyMMtoWC (our d_graphics, HEIGHT_UNV);
+ dyIntens = Graphics_dyMMtoWC (our d_graphics, HEIGHT_INTENS);
- Sampled_getWindowSamples (pitch, d_startWindow, d_endWindow, & it1, & it2);
+ Sampled_getWindowSamples (pitch, our d_startWindow, our d_endWindow, & it1, & it2);
/*
* Show pitch.
@@ -195,76 +195,75 @@ void structPitchEditor :: v_draw () {
50;
double radius;
Graphics_Viewport previous;
- previous = Graphics_insetViewport (d_graphics, 0, 1, dyUnv, 1 - dyIntens);
- Graphics_setWindow (d_graphics, d_startWindow, d_endWindow, 0, pitch -> ceiling);
- radius = Graphics_dxMMtoWC (d_graphics, RADIUS);
+ 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 (d_startSelection == d_endSelection && d_startSelection >= d_startWindow && d_startSelection <= d_endWindow) {
- double f = Pitch_getValueAtTime (pitch, d_startSelection, kPitch_unit_HERTZ, Pitch_LINEAR);
+ 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 (d_graphics, Graphics_RED);
- Graphics_line (d_graphics, d_startWindow - radius, f, d_endWindow, f);
- Graphics_setTextAlignment (d_graphics, Graphics_RIGHT, Graphics_HALF);
- Graphics_text1 (d_graphics, d_startWindow - radius, f, Melder_fixed (f, 2));
+ 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 (d_graphics, Graphics_BLUE);
- Graphics_setLineType (d_graphics, Graphics_DOTTED);
- Graphics_setTextAlignment (d_graphics, Graphics_LEFT, Graphics_HALF);
+ 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 (d_graphics, d_startWindow, f, d_endWindow, f);
- Graphics_text2 (d_graphics, d_endWindow + radius/2, f, Melder_integer (f), L" Hz");
+ 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 (d_graphics, Graphics_DRAWN);
+ Graphics_setLineType (our d_graphics, Graphics_DRAWN);
/* Show candidates. */
for (it = it1; it <= it2; it ++) {
Pitch_Frame frame = & pitch -> frame [it];
- double t = pitch -> f_indexToX (it);
+ double t = Sampled_indexToX (pitch, it);
double f = frame -> candidate [1]. frequency;
if (f > 0.0 && f < pitch -> ceiling) {
- Graphics_setColour (d_graphics, Graphics_MAGENTA);
- Graphics_fillCircle_mm (d_graphics, t, f, RADIUS * 2);
+ Graphics_setColour (our d_graphics, Graphics_MAGENTA);
+ Graphics_fillCircle_mm (our d_graphics, t, f, RADIUS * 2);
}
- Graphics_setColour (d_graphics, Graphics_BLACK);
- Graphics_setTextAlignment (d_graphics, Graphics_CENTRE, Graphics_HALF);
+ 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 (d_graphics, t, f, Melder_integer (strength));
+ if (f > 0 && f <= pitch -> ceiling) Graphics_text1 (our d_graphics, t, f, Melder_integer (strength));
}
}
- Graphics_resetViewport (d_graphics, previous);
+ Graphics_resetViewport (our d_graphics, previous);
}
/*
* Show intensity.
*/
{
- Graphics_Viewport previous;
- previous = Graphics_insetViewport (d_graphics, 0, 1, 1 - dyIntens, 1);
- Graphics_setWindow (d_graphics, d_startWindow, d_endWindow, 0, 1);
- Graphics_setColour (d_graphics, Graphics_BLACK);
- Graphics_setTextAlignment (d_graphics, Graphics_RIGHT, Graphics_HALF);
- Graphics_text (d_graphics, d_startWindow, 0.5, L"intens");
- Graphics_setTextAlignment (d_graphics, Graphics_LEFT, Graphics_HALF);
- Graphics_text (d_graphics, d_endWindow, 0.5, L"intens");
- Graphics_setTextAlignment (d_graphics, Graphics_CENTRE, Graphics_HALF);
+ 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 = pitch -> f_indexToX (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 (d_graphics, t, 0.5, Melder_integer (strength));
+ Graphics_text1 (our d_graphics, t, 0.5, Melder_integer (strength));
}
- Graphics_resetViewport (d_graphics, previous);
+ Graphics_resetViewport (our d_graphics, previous);
}
if (it1 > 1) it1 -= 1;
@@ -274,34 +273,33 @@ void structPitchEditor :: v_draw () {
* Show voicelessness.
*/
{
- Graphics_Viewport previous;
- previous = Graphics_insetViewport (d_graphics, 0, 1, 0, dyUnv);
- Graphics_setColour (d_graphics, Graphics_BLUE);
- Graphics_line (d_graphics, d_startWindow, 1, d_endWindow, 1);
- Graphics_setTextAlignment (d_graphics, Graphics_RIGHT, Graphics_HALF);
- Graphics_text (d_graphics, d_startWindow, 0.5, L"Unv");
- Graphics_setTextAlignment (d_graphics, Graphics_LEFT, Graphics_HALF);
- Graphics_text (d_graphics, d_endWindow, 0.5, L"Unv");
+ 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 = pitch -> f_indexToX (it), tleft = t - 0.5 * pitch -> dx, tright = t + 0.5 * pitch -> dx;
+ 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 <= d_startWindow || tleft >= d_endWindow) continue;
- if (tleft < d_startWindow) tleft = d_startWindow;
- if (tright > d_endWindow) tright = d_endWindow;
- Graphics_fillRectangle (d_graphics, tleft, tright, 0, 1);
+ 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 (d_graphics, Graphics_BLACK);
- Graphics_resetViewport (d_graphics, previous);
+ Graphics_setColour (our d_graphics, Graphics_BLACK);
+ Graphics_resetViewport (our d_graphics, previous);
}
}
void structPitchEditor :: v_play (double a_tmin, double a_tmax) {
- Pitch_hum ((Pitch) data, a_tmin, a_tmax);
+ Pitch_hum ((Pitch) our data, a_tmin, a_tmax);
}
int structPitchEditor :: v_click (double xWC, double yWC, bool dummy) {
- Pitch pitch = (Pitch) data;
+ 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;
@@ -315,7 +313,7 @@ int structPitchEditor :: v_click (double xWC, double yWC, bool dummy) {
if (ibestFrame > pitch -> nx) ibestFrame = pitch -> nx;
bestFrame = & pitch -> frame [ibestFrame];
- tmid = pitch -> f_indexToX (ibestFrame);
+ tmid = Sampled_indexToX (pitch, ibestFrame);
for (cand = 1; cand <= bestFrame -> nCandidates; cand ++) {
double df = frequency - bestFrame -> candidate [cand]. frequency;
if (fabs (df) < minimumDf) {
@@ -326,7 +324,7 @@ int structPitchEditor :: v_click (double xWC, double yWC, bool dummy) {
if (bestCandidate != -1) {
double bestFrequency = bestFrame -> candidate [bestCandidate]. frequency;
double distanceWC = (frequency - bestFrequency) / pitch -> ceiling * (1 - dyIntens - dyUnv);
- double dx_mm = Graphics_dxWCtoMM (d_graphics, xWC - tmid), dy_mm = Graphics_dyWCtoMM (d_graphics, distanceWC);
+ 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
@@ -336,8 +334,8 @@ int structPitchEditor :: v_click (double xWC, double yWC, bool dummy) {
bestFrame -> candidate [1] = bestFrame -> candidate [bestCandidate];
bestFrame -> candidate [bestCandidate] = help;
FunctionEditor_redraw (this);
- broadcastDataChanged ();
- d_startSelection = d_endSelection = tmid; // cursor will snap to candidate
+ 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
diff --git a/fon/Pitch_Intensity.cpp b/fon/Pitch_Intensity.cpp
index 831a60b..3b97723 100644
--- a/fon/Pitch_Intensity.cpp
+++ b/fon/Pitch_Intensity.cpp
@@ -51,7 +51,7 @@ void Pitch_Intensity_draw (Pitch pitch, Intensity intensity, Graphics g,
long previousI = 0;
double previousX = NUMundefined, previousY = NUMundefined;
for (long i = 1; i <= pitch -> nx; i ++) {
- double t = pitch -> f_indexToX (i);
+ double t = Sampled_indexToX (pitch, i);
double x = pitch -> frame [i]. candidate [1]. frequency;
double y = Sampled_getValueAtX (intensity, t, Pitch_LEVEL_FREQUENCY, kPitch_unit_HERTZ, TRUE);
if (x == 0) {
diff --git a/fon/Pitch_to_PitchTier.cpp b/fon/Pitch_to_PitchTier.cpp
index fb8b0d3..dae2c2e 100644
--- a/fon/Pitch_to_PitchTier.cpp
+++ b/fon/Pitch_to_PitchTier.cpp
@@ -36,7 +36,7 @@ PitchTier Pitch_to_PitchTier (Pitch me) {
* Count only voiced frames.
*/
if (frequency > 0.0 && frequency < my ceiling) {
- double time = my f_indexToX (i);
+ double time = Sampled_indexToX (me, i);
RealTier_addPoint (thee.peek(), time, frequency);
}
}
@@ -68,7 +68,7 @@ static void Pitch_line (Pitch me, Graphics g, double tmin, double fleft, double
} else if (nonPeriodicLineType != 2) {
Graphics_setLineWidth (g, 2 * lineWidth);
}
- tleft = my f_indexToX (i) - 0.5 * my dx, tright = tleft + my dx;
+ tleft = Sampled_indexToX (me, i) - 0.5 * my dx, tright = tleft + my dx;
if (tleft < tmin) tleft = tmin;
if (tright > tmax) tright = tmax;
Graphics_line (g, tleft, fleft + (tleft - tmin) * slope,
@@ -131,7 +131,7 @@ Pitch Pitch_PitchTier_to_Pitch (Pitch me, PitchTier tier) {
Pitch_Frame frame = & thy frame [iframe];
Pitch_Candidate cand = & frame -> candidate [1];
if (cand -> frequency > 0.0 && cand -> frequency <= my ceiling)
- cand -> frequency = RealTier_getValueAtTime (tier, my f_indexToX (iframe));
+ cand -> frequency = RealTier_getValueAtTime (tier, Sampled_indexToX (me, iframe));
cand -> strength = 0.9;
frame -> nCandidates = 1;
}
diff --git a/fon/Pitch_to_PointProcess.cpp b/fon/Pitch_to_PointProcess.cpp
index 4b125cc..59769d6 100644
--- a/fon/Pitch_to_PointProcess.cpp
+++ b/fon/Pitch_to_PointProcess.cpp
@@ -63,8 +63,8 @@ static int Pitch_getVoicedIntervalAfter (Pitch me, double after, double *tleft,
if (! Pitch_isVoiced_i (me, iright)) break;
iright --;
- *tleft = my f_indexToX (ileft) - 0.5 * my dx; /* The whole frame is considered voiced. */
- *tright = my f_indexToX (iright) + 0.5 * my dx;
+ *tleft = Sampled_indexToX (me, ileft) - 0.5 * my dx; // the whole frame is considered voiced
+ *tright = Sampled_indexToX (me, iright) + 0.5 * my dx;
if (*tleft >= my xmax - 0.5 * my dx) return 0;
if (*tleft < my xmin) *tleft = my xmin;
if (*tright > my xmax) *tright = my xmax;
diff --git a/fon/PointEditor.cpp b/fon/PointEditor.cpp
index d76ee92..cbb7c7f 100644
--- a/fon/PointEditor.cpp
+++ b/fon/PointEditor.cpp
@@ -189,7 +189,7 @@ void structPointEditor :: v_draw () {
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,
- sound -> f_indexToX (first), sound -> f_indexToX (last));
+ Sampled_indexToX (sound, first), Sampled_indexToX (sound, last));
}
}
Graphics_setColour (d_graphics, Graphics_BLUE);
@@ -217,7 +217,7 @@ PointEditor PointEditor_create (const wchar_t *title, PointProcess point, Sound
if (sound) {
my monoSound = Sound_convertToMono (sound);
}
- my structTimeSoundEditor :: f_init (title, point, my monoSound, false);
+ TimeSoundEditor_init (me.peek(), title, point, my monoSound, false);
return me.transfer();
} catch (MelderError) {
Melder_throw ("PointProcess window not created.");
diff --git a/fon/PointProcess_and_Sound.cpp b/fon/PointProcess_and_Sound.cpp
index 2d04df6..a74ff63 100644
--- a/fon/PointProcess_and_Sound.cpp
+++ b/fon/PointProcess_and_Sound.cpp
@@ -53,7 +53,7 @@ Sound PointProcess_to_Sound_pulseTrain
long begin = mid - interpolationDepth, end = mid + interpolationDepth;
if (begin < 1) begin = 1;
if (end > thy nx) end = thy nx;
- angle = NUMpi * (thy f_indexToX (begin) - t) / thy dx;
+ angle = NUMpi * (Sampled_indexToX (thee.peek(), begin) - t) / thy dx;
halfampsinangle = 0.5 * amplitude * sin (angle);
for (long j = begin; j <= end; j ++) {
if (fabs (angle) < 1e-6)
diff --git a/fon/PointProcess_def.h b/fon/PointProcess_def.h
index 92abf03..e74dd2b 100644
--- a/fon/PointProcess_def.h
+++ b/fon/PointProcess_def.h
@@ -30,12 +30,12 @@ oo_DEFINE_CLASS (PointProcess, Function)
#if oo_COPYING
oo_DOUBLE_VECTOR (t, maxnt)
#elif oo_READING
- if (nt) {
- maxnt = nt;
+ if (our nt) {
+ our maxnt = our nt;
oo_DOUBLE_VECTOR (t, nt)
} else {
- maxnt = 1;
- t = NUMvector <double> (1, 1);
+ our maxnt = 1;
+ our t = NUMvector <double> (1, 1);
}
#else
oo_DOUBLE_VECTOR (t, nt)
diff --git a/fon/RealTier.cpp b/fon/RealTier.cpp
index acd90d5..8cb8ee6 100644
--- a/fon/RealTier.cpp
+++ b/fon/RealTier.cpp
@@ -54,7 +54,7 @@ RealPoint RealPoint_create (double time, double value) {
void structRealTier :: v_info () {
structFunction :: v_info ();
- MelderInfo_writeLine (L"Number of points: ", Melder_integer (f_getNumberOfPoints ()));
+ MelderInfo_writeLine (L"Number of points: ", Melder_integer (our numberOfPoints ()));
MelderInfo_writeLine (L"Minimum value: ", Melder_double (RealTier_getMinimumValue (this)));
MelderInfo_writeLine (L"Maximum value: ", Melder_double (RealTier_getMaximumValue (this)));
}
@@ -71,16 +71,16 @@ double structRealTier :: v_getFunction1 (long irow, double x) {
void structRealTier :: v_shiftX (double xfrom, double xto) {
RealTier_Parent :: v_shiftX (xfrom, xto);
- for (long i = 1; i <= f_getNumberOfPoints (); i ++) {
- RealPoint point = f_peekPoint (i);
+ for (long i = 1; i <= our numberOfPoints (); i ++) {
+ RealPoint point = our point (i);
NUMshift (& point -> number, xfrom, xto);
}
}
void structRealTier :: v_scaleX (double xminfrom, double xmaxfrom, double xminto, double xmaxto) {
RealTier_Parent :: v_scaleX (xminfrom, xmaxfrom, xminto, xmaxto);
- for (long i = 1; i <= f_getNumberOfPoints (); i ++) {
- RealPoint point = f_peekPoint (i);
+ for (long i = 1; i <= our numberOfPoints (); i ++) {
+ RealPoint point = our point (i);
NUMscale (& point -> number, xminfrom, xmaxfrom, xminto, xmaxto);
}
}
@@ -123,22 +123,22 @@ void RealTier_addPoint (RealTier me, double t, double value) {
}
double RealTier_getValueAtIndex (RealTier me, long i) {
- if (i < 1 || i > my f_getNumberOfPoints ()) return NUMundefined;
- return my f_peekPoint (i) -> value;
+ if (i < 1 || i > my numberOfPoints ()) return NUMundefined;
+ return my point (i) -> value;
}
double RealTier_getValueAtTime (RealTier me, double t) {
- long n = my f_getNumberOfPoints ();
+ long n = my numberOfPoints ();
if (n == 0) return NUMundefined;
- RealPoint pointRight = my f_peekPoint (1);
+ RealPoint pointRight = my point (1);
if (t <= pointRight -> number) return pointRight -> value; // constant extrapolation
- RealPoint pointLeft = my f_peekPoint (n);
+ RealPoint pointLeft = my point (n);
if (t >= pointLeft -> number) return pointLeft -> value; // constant extrapolation
Melder_assert (n >= 2);
long ileft = AnyTier_timeToLowIndex (me, t), iright = ileft + 1;
Melder_assert (ileft >= 1 && iright <= n);
- pointLeft = my f_peekPoint (ileft);
- pointRight = my f_peekPoint (iright);
+ pointLeft = my point (ileft);
+ pointRight = my point (iright);
double tleft = pointLeft -> number, fleft = pointLeft -> value;
double tright = pointRight -> number, fright = pointRight -> value;
return t == tright ? fright // be very accurate
@@ -148,9 +148,9 @@ double RealTier_getValueAtTime (RealTier me, double t) {
double RealTier_getMaximumValue (RealTier me) {
double result = NUMundefined;
- long n = my f_getNumberOfPoints ();
+ long n = my numberOfPoints ();
for (long i = 1; i <= n; i ++) {
- RealPoint point = my f_peekPoint (i);
+ RealPoint point = my point (i);
if (result == NUMundefined || point -> value > result)
result = point -> value;
}
@@ -159,9 +159,9 @@ double RealTier_getMaximumValue (RealTier me) {
double RealTier_getMinimumValue (RealTier me) {
double result = NUMundefined;
- long n = my f_getNumberOfPoints ();
+ long n = my numberOfPoints ();
for (long i = 1; i <= n; i ++) {
- RealPoint point = my f_peekPoint (i);
+ RealPoint point = my point (i);
if (result == NUMundefined || point -> value < result)
result = point -> value;
}
@@ -169,8 +169,8 @@ double RealTier_getMinimumValue (RealTier me) {
}
double RealTier_getArea (RealTier me, double tmin, double tmax) {
- long n = my f_getNumberOfPoints (), imin, imax;
- RealPoint *points = my f_peekPoints ();
+ long n = my numberOfPoints (), imin, imax;
+ RealPoint *points = my peekPoints ();
if (n == 0) return NUMundefined;
if (n == 1) return (tmax - tmin) * points [1] -> value;
imin = AnyTier_timeToLowIndex (me, tmin);
@@ -203,8 +203,8 @@ double RealTier_getMean_curve (RealTier me, double tmin, double tmax) {
}
double RealTier_getStandardDeviation_curve (RealTier me, double tmin, double tmax) {
- long n = my f_getNumberOfPoints (), imin, imax;
- RealPoint *points = my f_peekPoints ();
+ long n = my numberOfPoints (), imin, imax;
+ RealPoint *points = my peekPoints ();
double mean, integral = 0.0;
if (tmax <= tmin) { tmin = my xmin; tmax = my xmax; } // autowindow
if (n == 0) return NUMundefined;
@@ -244,9 +244,9 @@ double RealTier_getStandardDeviation_curve (RealTier me, double tmin, double tma
}
double RealTier_getMean_points (RealTier me, double tmin, double tmax) {
- long n = my f_getNumberOfPoints (), imin, imax;
+ long n = my numberOfPoints (), imin, imax;
double sum = 0.0;
- RealPoint *points = my f_peekPoints ();
+ RealPoint *points = my peekPoints ();
if (tmax <= tmin) { tmin = my xmin; tmax = my xmax; } // autowindow
n = AnyTier_getWindowPoints (me, tmin, tmax, & imin, & imax);
if (n == 0) return NUMundefined;
@@ -256,9 +256,9 @@ double RealTier_getMean_points (RealTier me, double tmin, double tmax) {
}
double RealTier_getStandardDeviation_points (RealTier me, double tmin, double tmax) {
- long n = my f_getNumberOfPoints (), imin, imax;
+ long n = my numberOfPoints (), imin, imax;
double mean, sum = 0.0;
- RealPoint *points = my f_peekPoints ();
+ RealPoint *points = my peekPoints ();
if (tmax <= tmin) { tmin = my xmin; tmax = my xmax; } // autowindow
n = AnyTier_getWindowPoints (me, tmin, tmax, & imin, & imax);
if (n < 2) return NUMundefined;
@@ -271,8 +271,8 @@ double RealTier_getStandardDeviation_points (RealTier me, double tmin, double tm
}
void RealTier_multiplyPart (RealTier me, double tmin, double tmax, double factor) {
- for (long ipoint = 1; ipoint <= my f_getNumberOfPoints (); ipoint ++) {
- RealPoint point = my f_peekPoint (ipoint);
+ for (long ipoint = 1; ipoint <= my numberOfPoints (); ipoint ++) {
+ RealPoint point = my point (ipoint);
double t = point -> number;
if (t >= tmin && t <= tmax) {
point -> value *= factor;
@@ -285,7 +285,7 @@ void RealTier_draw (RealTier me, Graphics g, double tmin, double tmax, double fm
{
bool drawLines = wcsstr (method, L"lines") || wcsstr (method, L"Lines");
bool drawSpeckles = wcsstr (method, L"speckles") || wcsstr (method, L"Speckles");
- long n = my f_getNumberOfPoints (), imin, imax, i;
+ long n = my numberOfPoints (), imin, imax, i;
if (tmax <= tmin) { tmin = my xmin; tmax = my xmax; }
Graphics_setWindow (g, tmin, tmax, fmin, fmax);
Graphics_setInner (g);
@@ -297,7 +297,7 @@ void RealTier_draw (RealTier me, Graphics g, double tmin, double tmax, double fm
double fright = RealTier_getValueAtTime (me, tmax);
if (drawLines) Graphics_line (g, tmin, fleft, tmax, fright);
} else for (i = imin; i <= imax; i ++) {
- RealPoint point = my f_peekPoint (i);
+ RealPoint point = my point (i);
double t = point -> number, f = point -> value;
if (drawSpeckles) Graphics_speckle (g, t, f);
if (drawLines) {
@@ -310,7 +310,7 @@ void RealTier_draw (RealTier me, Graphics g, double tmin, double tmax, double fm
else if (i == imax)
Graphics_line (g, t, f, tmax, RealTier_getValueAtTime (me, tmax));
else {
- RealPoint pointRight = my f_peekPoint (i + 1);
+ RealPoint pointRight = my point (i + 1);
Graphics_line (g, t, f, pointRight -> number, pointRight -> value);
}
}
@@ -327,11 +327,11 @@ void RealTier_draw (RealTier me, Graphics g, double tmin, double tmax, double fm
TableOfReal RealTier_downto_TableOfReal (RealTier me, const wchar_t *timeLabel, const wchar_t *valueLabel) {
try {
- autoTableOfReal thee = TableOfReal_create (my f_getNumberOfPoints (), 2);
+ autoTableOfReal thee = TableOfReal_create (my numberOfPoints (), 2);
TableOfReal_setColumnLabel (thee.peek(), 1, timeLabel);
TableOfReal_setColumnLabel (thee.peek(), 2, valueLabel);
- for (long i = 1; i <= my f_getNumberOfPoints (); i ++) {
- RealPoint point = my f_peekPoint (i);
+ for (long i = 1; i <= my numberOfPoints (); i ++) {
+ RealPoint point = my point (i);
thy data [i] [1] = point -> number;
thy data [i] [2] = point -> value;
}
@@ -344,8 +344,8 @@ TableOfReal RealTier_downto_TableOfReal (RealTier me, const wchar_t *timeLabel,
void RealTier_interpolateQuadratically (RealTier me, long numberOfPointsPerParabola, int logarithmically) {
try {
autoRealTier thee = Data_copy (me);
- for (long ipoint = 1; ipoint < my f_getNumberOfPoints (); ipoint ++) {
- RealPoint point1 = my f_peekPoint (ipoint), point2 = my f_peekPoint (ipoint + 1);
+ for (long ipoint = 1; ipoint < my numberOfPoints (); ipoint ++) {
+ RealPoint point1 = my point (ipoint), point2 = my point (ipoint + 1);
double time1 = point1 -> number, time2 = point2 -> number, tmid = 0.5 * (time1 + time2);
double value1 = point1 -> value, value2 = point2 -> value, valuemid;
double timeStep = (tmid - time1) / (numberOfPointsPerParabola + 1);
@@ -384,14 +384,14 @@ void RealTier_interpolateQuadratically (RealTier me, long numberOfPointsPerParab
Table RealTier_downto_Table (RealTier me, const wchar_t *indexText, const wchar_t *timeText, const wchar_t *valueText) {
try {
- autoTable thee = Table_createWithoutColumnNames (my f_getNumberOfPoints (),
+ autoTable thee = Table_createWithoutColumnNames (my numberOfPoints (),
(indexText != NULL) + (timeText != NULL) + (valueText != NULL));
long icol = 0;
if (indexText != NULL) Table_setColumnLabel (thee.peek(), ++ icol, indexText);
if (timeText != NULL) Table_setColumnLabel (thee.peek(), ++ icol, timeText);
if (valueText != NULL) Table_setColumnLabel (thee.peek(), ++ icol, valueText);
- for (long ipoint = 1; ipoint <= my f_getNumberOfPoints (); ipoint ++) {
- RealPoint point = my f_peekPoint (ipoint);
+ for (long ipoint = 1; ipoint <= my numberOfPoints (); ipoint ++) {
+ RealPoint point = my point (ipoint);
icol = 0;
if (indexText != NULL) Table_setNumericValue (thee.peek(), ipoint, ++ icol, ipoint);
if (timeText != NULL) Table_setNumericValue (thee.peek(), ipoint, ++ icol, point -> number);
@@ -407,7 +407,7 @@ RealTier Vector_to_RealTier (Vector me, long channel, ClassInfo klas) {
try {
autoRealTier thee = RealTier_createWithClass (my xmin, my xmax, klas);
for (long i = 1; i <= my nx; i ++) {
- RealTier_addPoint (thee.peek(), my f_indexToX (i), my z [channel] [i]);
+ RealTier_addPoint (thee.peek(), Sampled_indexToX (me, i), my z [channel] [i]);
}
return thee.transfer();
} catch (MelderError) {
@@ -467,12 +467,12 @@ void RealTier_formula (RealTier me, const wchar_t *expression, Interpreter inter
try {
Formula_compile (interpreter, me, expression, kFormula_EXPRESSION_TYPE_NUMERIC, TRUE);
if (thee == NULL) thee = me;
- for (long icol = 1; icol <= my f_getNumberOfPoints (); icol ++) {
+ for (long icol = 1; icol <= my numberOfPoints (); icol ++) {
struct Formula_Result result;
Formula_run (0, icol, & result);
if (result. result.numericResult == NUMundefined)
Melder_throw ("Cannot put an undefined value into the tier.");
- thy f_peekPoint (icol) -> value = result. result.numericResult;
+ thy point (icol) -> value = result. result.numericResult;
}
} catch (MelderError) {
Melder_throw (me, ": formula not completed.");
@@ -480,8 +480,8 @@ void RealTier_formula (RealTier me, const wchar_t *expression, Interpreter inter
}
void RealTier_removePointsBelow (RealTier me, double level) {
- for (long ipoint = my f_getNumberOfPoints (); ipoint > 0; ipoint --) {
- RealPoint point = my f_peekPoint (ipoint);
+ for (long ipoint = my numberOfPoints (); ipoint > 0; ipoint --) {
+ RealPoint point = my point (ipoint);
if (point -> value < level) {
AnyTier_removePoint (me, ipoint);
}
diff --git a/fon/RealTierEditor.cpp b/fon/RealTierEditor.cpp
index b728755..bc799dc 100644
--- a/fon/RealTierEditor.cpp
+++ b/fon/RealTierEditor.cpp
@@ -151,67 +151,67 @@ void structRealTierEditor :: v_dataChanged () {
/********** DRAWING AREA **********/
void structRealTierEditor :: v_draw () {
- RealTier data = (RealTier) this -> data;
+ RealTier data = (RealTier) our data;
long ifirstSelected, ilastSelected, n = data -> points -> size, imin, imax, i;
Graphics_Viewport viewport;
- if (d_sound.data) {
- viewport = Graphics_insetViewport (d_graphics, 0, 1, 1 - SOUND_HEIGHT, 1.0);
- Graphics_setColour (d_graphics, Graphics_WHITE);
- Graphics_setWindow (d_graphics, 0, 1, 0, 1);
- Graphics_fillRectangle (d_graphics, 0, 1, 0, 1);
- f_drawSound (-1.0, 1.0);
- Graphics_resetViewport (d_graphics, viewport);
- Graphics_insetViewport (d_graphics, 0, 1, 0.0, 1 - SOUND_HEIGHT);
+ if (our d_sound.data) {
+ viewport = Graphics_insetViewport (our d_graphics, 0, 1, 1 - SOUND_HEIGHT, 1.0);
+ 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);
+ TimeSoundEditor_drawSound (this, -1.0, 1.0);
+ Graphics_resetViewport (our d_graphics, viewport);
+ Graphics_insetViewport (our d_graphics, 0, 1, 0.0, 1 - SOUND_HEIGHT);
}
- Graphics_setColour (d_graphics, Graphics_WHITE);
- Graphics_setWindow (d_graphics, 0, 1, 0, 1);
- Graphics_fillRectangle (d_graphics, 0, 1, 0, 1);
- Graphics_setWindow (d_graphics, d_startWindow, d_endWindow, ymin, ymax);
- Graphics_setColour (d_graphics, Graphics_RED);
- Graphics_line (d_graphics, d_startWindow, ycursor, d_endWindow, ycursor);
- Graphics_setTextAlignment (d_graphics, Graphics_RIGHT, Graphics_HALF);
- Graphics_text1 (d_graphics, d_startWindow, ycursor, Melder_float (Melder_half (ycursor)));
- Graphics_setColour (d_graphics, Graphics_BLUE);
- Graphics_setTextAlignment (d_graphics, Graphics_LEFT, Graphics_TOP);
- Graphics_text2 (d_graphics, d_endWindow, ymax, Melder_float (Melder_half (ymax)), v_rightTickUnits ());
- Graphics_setTextAlignment (d_graphics, Graphics_LEFT, Graphics_HALF);
- Graphics_text2 (d_graphics, d_endWindow, ymin, Melder_float (Melder_half (ymin)), v_rightTickUnits ());
- ifirstSelected = AnyTier_timeToHighIndex (data, d_startSelection);
- ilastSelected = AnyTier_timeToLowIndex (data, d_endSelection);
- imin = AnyTier_timeToHighIndex (data, d_startWindow);
- imax = AnyTier_timeToLowIndex (data, d_endWindow);
- Graphics_setLineWidth (d_graphics, 2);
+ 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, our ymin, our ymax);
+ Graphics_setColour (our d_graphics, Graphics_RED);
+ Graphics_line (our d_graphics, our d_startWindow, ycursor, our d_endWindow, our ycursor);
+ Graphics_setTextAlignment (our d_graphics, Graphics_RIGHT, Graphics_HALF);
+ Graphics_text1 (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_text2 (our d_graphics, our d_endWindow, our ymax, Melder_float (Melder_half (ymax)), our v_rightTickUnits ());
+ Graphics_setTextAlignment (our d_graphics, Graphics_LEFT, Graphics_HALF);
+ Graphics_text2 (our d_graphics, our d_endWindow, our ymin, Melder_float (Melder_half (our ymin)), our v_rightTickUnits ());
+ ifirstSelected = AnyTier_timeToHighIndex (data, our d_startSelection);
+ ilastSelected = AnyTier_timeToLowIndex (data, our d_endSelection);
+ imin = AnyTier_timeToHighIndex (data, our d_startWindow);
+ imax = AnyTier_timeToLowIndex (data, our d_endWindow);
+ Graphics_setLineWidth (our d_graphics, 2);
if (n == 0) {
- Graphics_setTextAlignment (d_graphics, Graphics_CENTRE, Graphics_HALF);
- Graphics_text (d_graphics, 0.5 * (d_startWindow + d_endWindow),
- 0.5 * (ymin + ymax), L"(no points)");
+ Graphics_setTextAlignment (our d_graphics, Graphics_CENTRE, Graphics_HALF);
+ Graphics_text (our d_graphics, 0.5 * (our d_startWindow + our d_endWindow),
+ 0.5 * (our ymin + our ymax), L"(no points)");
} else if (imax < imin) {
- double yleft = RealTier_getValueAtTime (data, d_startWindow);
- double yright = RealTier_getValueAtTime (data, d_endWindow);
- Graphics_line (d_graphics, d_startWindow, yleft, d_endWindow, yright);
+ double yleft = RealTier_getValueAtTime (data, our d_startWindow);
+ double yright = RealTier_getValueAtTime (data, our d_endWindow);
+ Graphics_line (our d_graphics, our d_startWindow, yleft, our d_endWindow, yright);
} else for (i = imin; i <= imax; i ++) {
- RealPoint point = (RealPoint) data -> points -> item [i];
+ RealPoint point = data -> point (i);
double t = point -> number, y = point -> value;
if (i >= ifirstSelected && i <= ilastSelected)
- Graphics_setColour (d_graphics, Graphics_RED);
- Graphics_fillCircle_mm (d_graphics, t, y, 3);
- Graphics_setColour (d_graphics, Graphics_BLUE);
+ 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 (d_graphics, d_startWindow, y, t, y);
+ Graphics_line (our d_graphics, our d_startWindow, y, t, y);
else if (i == imin)
- Graphics_line (d_graphics, t, y, d_startWindow, RealTier_getValueAtTime (data, d_startWindow));
+ Graphics_line (our d_graphics, t, y, our d_startWindow, RealTier_getValueAtTime (data, our d_startWindow));
if (i == n)
- Graphics_line (d_graphics, t, y, d_endWindow, y);
+ Graphics_line (our d_graphics, t, y, our d_endWindow, y);
else if (i == imax)
- Graphics_line (d_graphics, t, y, d_endWindow, RealTier_getValueAtTime (data, d_endWindow));
+ Graphics_line (our d_graphics, t, y, our d_endWindow, RealTier_getValueAtTime (data, our d_endWindow));
else {
- RealPoint pointRight = (RealPoint) data -> points -> item [i + 1];
- Graphics_line (d_graphics, t, y, pointRight -> number, pointRight -> value);
+ RealPoint pointRight = data -> point (i + 1);
+ Graphics_line (our d_graphics, t, y, pointRight -> number, pointRight -> value);
}
}
- Graphics_setLineWidth (d_graphics, 1);
- Graphics_setColour (d_graphics, Graphics_BLACK);
- v_updateMenuItems_file ();
+ Graphics_setLineWidth (our d_graphics, 1);
+ Graphics_setColour (our d_graphics, Graphics_BLACK);
+ our v_updateMenuItems_file ();
}
static void drawWhileDragging (RealTierEditor me, double xWC, double yWC, long first, long last, double dt, double dy) {
@@ -223,7 +223,7 @@ static void drawWhileDragging (RealTierEditor me, double xWC, double yWC, long f
* Draw all selected points as magenta empty circles, if inside the window.
*/
for (long i = first; i <= last; i ++) {
- RealPoint point = (RealPoint) data -> points -> item [i];
+ RealPoint point = data -> point (i);
double t = point -> number + dt, y = point -> value + dy;
if (t >= my d_startWindow && t <= my d_endWindow)
Graphics_circle_mm (my d_graphics, t, y, 3);
@@ -233,7 +233,7 @@ static void drawWhileDragging (RealTierEditor me, double xWC, double yWC, long f
/*
* Draw a crosshair with time and y.
*/
- RealPoint point = (RealPoint) data -> points -> item [first];
+ RealPoint point = data -> point (first);
double t = point -> number + dt, y = point -> value + dy;
Graphics_line (my d_graphics, t, my ymin, t, my ymax - Graphics_dyMMtoWC (my d_graphics, 4.0));
Graphics_setTextAlignment (my d_graphics, kGraphics_horizontalAlignment_CENTRE, Graphics_TOP);
@@ -245,7 +245,7 @@ static void drawWhileDragging (RealTierEditor me, double xWC, double yWC, long f
}
int structRealTierEditor :: v_click (double xWC, double yWC, bool shiftKeyPressed) {
- RealTier pitch = (RealTier) data;
+ RealTier pitch = (RealTier) our data;
long inearestPoint, ifirstSelected, ilastSelected;
RealPoint nearestPoint;
double dt = 0, df = 0;
@@ -255,20 +255,20 @@ int structRealTierEditor :: v_click (double xWC, double yWC, bool shiftKeyPresse
/*
* Perform the default action: move cursor.
*/
- //d_startSelection = d_endSelection = xWC;
- if (d_sound.data) {
+ //our d_startSelection = our d_endSelection = xWC;
+ if (our d_sound.data) {
if (yWC < 1 - SOUND_HEIGHT) { /* Clicked in tier area? */
yWC /= 1 - SOUND_HEIGHT;
- ycursor = (1.0 - yWC) * ymin + yWC * ymax;
- viewport = Graphics_insetViewport (d_graphics, 0, 1, 0, 1 - SOUND_HEIGHT);
+ our ycursor = (1.0 - yWC) * our ymin + yWC * our ymax;
+ viewport = Graphics_insetViewport (our d_graphics, 0, 1, 0, 1 - SOUND_HEIGHT);
} else {
- return RealTierEditor_Parent :: v_click (xWC, yWC, shiftKeyPressed);
+ return our RealTierEditor_Parent :: v_click (xWC, yWC, shiftKeyPressed);
}
} else {
- ycursor = (1.0 - yWC) * ymin + yWC * ymax;
+ our ycursor = (1.0 - yWC) * our ymin + yWC * our ymax;
}
- Graphics_setWindow (d_graphics, d_startWindow, d_endWindow, ymin, ymax);
- yWC = ycursor;
+ Graphics_setWindow (our d_graphics, our d_startWindow, our d_endWindow, our ymin, our ymax);
+ yWC = our ycursor;
/*
* Clicked on a point?
@@ -277,8 +277,8 @@ int structRealTierEditor :: v_click (double xWC, double yWC, bool shiftKeyPresse
if (inearestPoint == 0) return RealTierEditor_Parent :: v_click (xWC, yWC, shiftKeyPressed);
nearestPoint = (RealPoint) pitch -> points -> item [inearestPoint];
if (Graphics_distanceWCtoMM (d_graphics, xWC, yWC, nearestPoint -> number, nearestPoint -> value) > 1.5) {
- if (d_sound.data) Graphics_resetViewport (d_graphics, viewport);
- return RealTierEditor_Parent :: v_click (xWC, yWC, shiftKeyPressed);
+ if (d_sound.data) Graphics_resetViewport (our d_graphics, viewport);
+ return our RealTierEditor_Parent :: v_click (xWC, yWC, shiftKeyPressed);
}
/*
@@ -298,11 +298,11 @@ int structRealTierEditor :: v_click (double xWC, double yWC, bool shiftKeyPresse
/*
* Drag.
*/
- Graphics_xorOn (d_graphics, Graphics_MAROON);
+ Graphics_xorOn (our d_graphics, Graphics_MAROON);
drawWhileDragging (this, xWC, yWC, ifirstSelected, ilastSelected, dt, df); // draw at old position
- while (Graphics_mouseStillDown (d_graphics)) {
+ while (Graphics_mouseStillDown (our d_graphics)) {
double xWC_new, yWC_new;
- Graphics_getMouseLocation (d_graphics, & xWC_new, & yWC_new);
+ Graphics_getMouseLocation (our d_graphics, & xWC_new, & yWC_new);
if (xWC_new != xWC || yWC_new != yWC) {
drawWhileDragging (this, xWC, yWC, ifirstSelected, ilastSelected, dt, df); // undraw at old position
dt += xWC_new - xWC, df += yWC_new - yWC;
@@ -321,14 +321,14 @@ int structRealTierEditor :: v_click (double xWC, double yWC, bool shiftKeyPresse
* Points not dragged past neighbours?
*/
{
- RealPoint *points = (RealPoint *) pitch -> points -> item;
+ RealPoint *points = pitch -> peekPoints ();
double newTime = points [ifirstSelected] -> number + dt;
if (newTime < our tmin) return 1; // outside domain
if (ifirstSelected > 1 && newTime <= points [ifirstSelected - 1] -> number)
return 1; // past left neighbour
newTime = points [ilastSelected] -> number + dt;
if (newTime > our tmax) return 1; // outside domain
- if (ilastSelected < pitch -> points -> size && newTime >= points [ilastSelected + 1] -> number)
+ if (ilastSelected < pitch -> numberOfPoints() && newTime >= points [ilastSelected + 1] -> number)
return 1; // past right neighbour
}
@@ -336,7 +336,7 @@ int structRealTierEditor :: v_click (double xWC, double yWC, bool shiftKeyPresse
* Drop.
*/
for (int i = ifirstSelected; i <= ilastSelected; i ++) {
- RealPoint point = (RealPoint) pitch -> points -> item [i];
+ RealPoint point = pitch -> point (i);
point -> number += dt;
point -> value += df;
if (NUMdefined (v_minimumLegalValue ()) && point -> value < v_minimumLegalValue ())
@@ -349,40 +349,40 @@ int structRealTierEditor :: v_click (double xWC, double yWC, bool shiftKeyPresse
* Make sure that the same points are still selected (a problem with Undo...).
*/
- if (draggingSelection) d_startSelection += dt, d_endSelection += dt;
+ if (draggingSelection) our d_startSelection += dt, our d_endSelection += dt;
if (ifirstSelected == ilastSelected) {
/*
* Move crosshair to only selected pitch point.
*/
RealPoint point = (RealPoint) pitch -> points -> item [ifirstSelected];
- d_startSelection = d_endSelection = point -> number;
- ycursor = point -> value;
+ our d_startSelection = our d_endSelection = point -> number;
+ our ycursor = point -> value;
} else {
/*
* Move crosshair to mouse location.
*/
- /*cursor += dt;*/
- ycursor += df;
- if (NUMdefined (v_minimumLegalValue ()) && ycursor < v_minimumLegalValue ())
- ycursor = v_minimumLegalValue ();
- if (NUMdefined (v_maximumLegalValue ()) && ycursor > v_maximumLegalValue ())
- ycursor = v_maximumLegalValue ();
+ /*our cursor += dt;*/
+ our ycursor += df;
+ if (NUMdefined (v_minimumLegalValue ()) && our ycursor < v_minimumLegalValue ())
+ our ycursor = v_minimumLegalValue ();
+ if (NUMdefined (v_maximumLegalValue ()) && our ycursor > v_maximumLegalValue ())
+ our ycursor = v_maximumLegalValue ();
}
- broadcastDataChanged ();
+ our broadcastDataChanged ();
RealTierEditor_updateScaling (this);
return 1; // update needed
}
void structRealTierEditor :: v_play (double a_tmin, double a_tmax) {
- if (d_sound.data)
- Sound_playPart (d_sound.data, a_tmin, a_tmax, theFunctionEditor_playCallback, this);
+ if (our d_sound.data)
+ Sound_playPart (our d_sound.data, a_tmin, a_tmax, theFunctionEditor_playCallback, this);
}
void RealTierEditor_init (RealTierEditor me, const wchar_t *title, RealTier data, Sound sound, bool ownSound) {
Melder_assert (data != NULL);
Melder_assert (Thing_member (data, classRealTier));
- my structTimeSoundEditor :: f_init (title, data, sound, ownSound);
+ TimeSoundEditor_init (me, title, data, sound, ownSound);
my ymin = -1.0;
RealTierEditor_updateScaling (me);
my ycursor = 0.382 * my ymin + 0.618 * my ymax;
diff --git a/fon/RealTier_def.h b/fon/RealTier_def.h
index 1357195..558eceb 100644
--- a/fon/RealTier_def.h
+++ b/fon/RealTier_def.h
@@ -33,21 +33,21 @@ oo_DEFINE_CLASS (RealTier, Function)
oo_COLLECTION (SortedSetOfDouble, points, RealPoint, 0)
#if oo_DECLARING
+ // access functions:
+ long numberOfPoints () { return points -> size; }
+ RealPoint * peekPoints () { return reinterpret_cast <RealPoint *> (points -> item); }
+ RealPoint point (long ipoint) { return static_cast <RealPoint> (points -> item [ipoint]); }
// overridden methods:
virtual void v_info ();
- virtual bool v_hasGetNx () { return true; } virtual double v_getNx () { return points -> size; }
- virtual bool v_hasGetX () { return true; } virtual double v_getX (long ix) { return ((RealPoint) points -> item [ix]) -> number; }
- virtual bool v_hasGetNcol () { return true; } virtual double v_getNcol () { return points -> size; }
+ virtual bool v_hasGetNx () { return true; } virtual double v_getNx () { return numberOfPoints (); }
+ virtual bool v_hasGetX () { return true; } virtual double v_getX (long ix) { return point (ix) -> number; }
+ virtual bool v_hasGetNcol () { return true; } virtual double v_getNcol () { return numberOfPoints (); }
virtual bool v_hasGetVector () { return true; } virtual double v_getVector (long irow, long icol);
virtual bool v_hasGetFunction1 () { return true; } virtual double v_getFunction1 (long irow, double x);
virtual const wchar_t * v_getUnitText (long ilevel, int unit, unsigned long flags)
{ (void) ilevel; (void) unit; (void) flags; return L"Time (s)"; }
virtual void v_shiftX (double xfrom, double xto);
virtual void v_scaleX (double xminfrom, double xmaxfrom, double xminto, double xmaxto);
- // new functions:
- long f_getNumberOfPoints () { return points -> size; }
- RealPoint *f_peekPoints () { return (RealPoint *) points -> item; }
- RealPoint f_peekPoint (long ipoint) { return (RealPoint) points -> item [ipoint]; }
#endif
oo_END_CLASS (RealTier)
diff --git a/fon/Sampled.cpp b/fon/Sampled.cpp
index 93d35ee..a545be7 100644
--- a/fon/Sampled.cpp
+++ b/fon/Sampled.cpp
@@ -61,15 +61,6 @@ long Sampled_getWindowSamples (Sampled me, double xmin, double xmax, long *ixmin
return *ixmax - *ixmin + 1;
}
-long structSampled :: f_getWindowSamplesX (double xmin, double xmax, long *ixmin, long *ixmax) {
- double rixmin = 1.0 + ceil ((xmin - our x1) / our dx);
- double rixmax = 1.0 + floor ((xmax - our x1) / our dx); // could be above 32-bit LONG_MAX
- *ixmin = rixmin < 1.0 ? 1 : (long) rixmin;
- *ixmax = rixmax > (double) our nx ? our nx : (long) rixmax;
- if (*ixmin > *ixmax) return 0;
- return *ixmax - *ixmin + 1;
-}
-
void Sampled_init (Sampled me, double xmin, double xmax, long nx, double dx, double x1) {
my xmin = xmin;
my xmax = xmax;
@@ -99,7 +90,7 @@ double Sampled_getValueAtSample (Sampled me, long isamp, long ilevel, int unit)
double Sampled_getValueAtX (Sampled me, double x, long ilevel, int unit, bool interpolate) {
if (x < my xmin || x > my xmax) return NUMundefined;
if (interpolate) {
- double ireal = my f_xToIndex (x);
+ double ireal = Sampled_xToIndex (me, x);
long ileft = floor (ireal), inear, ifar;
double phase = ireal - ileft;
if (phase < 0.5) {
@@ -258,7 +249,7 @@ static void Sampled_getSumAndDefinitionRange
}
}
} else { /* No interpolation. */
- double rimin = my f_xToIndex (xmin), rimax = my f_xToIndex (xmax);
+ double rimin = Sampled_xToIndex (me, xmin), rimax = Sampled_xToIndex (me, xmax);
if (rimax >= 0.5 && rimin < my nx + 0.5) {
imin = rimin < 0.5 ? 0 : (long) floor (rimin + 0.5);
imax = rimax >= my nx + 0.5 ? my nx + 1 : (long) floor (rimax + 0.5);
@@ -433,7 +424,7 @@ static void Sampled_getSum2AndDefinitionRange
}
}
} else { // no interpolation
- double rimin = my f_xToIndex (xmin), rimax = my f_xToIndex (xmax);
+ double rimin = Sampled_xToIndex (me, xmin), rimax = Sampled_xToIndex (me, xmax);
if (rimax >= 0.5 && rimin < my nx + 0.5) {
imin = rimin < 0.5 ? 0 : (long) floor (rimin + 0.5);
imax = rimax >= my nx + 0.5 ? my nx + 1 : (long) floor (rimax + 0.5);
@@ -661,7 +652,7 @@ static void Sampled_speckleInside (Sampled me, Graphics g, double xmin, double x
for (long ix = ixmin; ix <= ixmax; ix ++) {
double value = Sampled_getValueAtSample (me, ix, ilevel, unit);
if (NUMdefined (value)) {
- double x = my f_indexToX (ix);
+ double x = Sampled_indexToX (me, ix);
if (value >= ymin && value <= ymax) {
Graphics_speckle (g, x, value);
}
@@ -691,11 +682,11 @@ void Sampled_drawInside (Sampled me, Graphics g, double xmin, double xmax, doubl
double previousValue = Sampled_getValueAtSample (me, ixmin - 1, ilevel, unit);
if (NUMdefined (previousValue)) {
startOfDefinedStretch = ixmin - 1;
- xarray [ixmin - 1] = my f_indexToX (ixmin - 1);
+ xarray [ixmin - 1] = Sampled_indexToX (me, ixmin - 1);
yarray [ixmin - 1] = previousValue;
}
for (long ix = ixmin; ix <= ixmax; ix ++) {
- double x = my f_indexToX (ix), value = Sampled_getValueAtSample (me, ix, ilevel, unit);
+ double x = Sampled_indexToX (me, ix), value = Sampled_getValueAtSample (me, ix, ilevel, unit);
if (NUMdefined (value)) {
if (NUMdefined (previousValue)) {
xarray [ix] = x;
@@ -724,7 +715,7 @@ void Sampled_drawInside (Sampled me, Graphics g, double xmin, double xmax, doubl
previousValue = value;
}
if (startOfDefinedStretch > -1) {
- double x = my f_indexToX (ixmax + 1), value = Sampled_getValueAtSample (me, ixmax + 1, ilevel, unit);
+ double x = Sampled_indexToX (me, ixmax + 1), value = Sampled_getValueAtSample (me, ixmax + 1, ilevel, unit);
Melder_assert (NUMdefined (previousValue));
if (NUMdefined (value)) {
xarray [ixmax + 1] = x;
diff --git a/fon/Sampled.h b/fon/Sampled.h
index 8446244..df62c21 100644
--- a/fon/Sampled.h
+++ b/fon/Sampled.h
@@ -31,12 +31,12 @@ oo_CLASS_CREATE (Sampled, Function);
/* The first sample point is at x1, the second at x1 + dx, */
/* and the last at x1 + (nx - 1) * dx. */
-static inline double Sampled_indexToX (Sampled me, long i) { return my f_indexToX (i); }
-static inline double Sampled_indexToX (Sampled me, double i) { return my f_indexToX (i); }
-static inline double Sampled_xToIndex (Sampled me, double x) { return my f_xToIndex (x); }
-static inline long Sampled_xToLowIndex (Sampled me, double x) { return my f_xToLowIndex (x); }
-static inline long Sampled_xToHighIndex (Sampled me, double x) { return my f_xToHighIndex (x); }
-static inline long Sampled_xToNearestIndex (Sampled me, double x) { return my f_xToNearestIndex (x); }
+static inline double Sampled_indexToX (Sampled me, long index) { return my x1 + (index - 1 ) * my dx; }
+static inline double Sampled_indexToX (Sampled me, double index) { return my x1 + (index - 1.0) * my dx; }
+static inline double Sampled_xToIndex (Sampled me, double x) { return (x - my x1) / my dx + 1.0; }
+static inline long Sampled_xToLowIndex (Sampled me, double x) { return (long) floor ((x - my x1) / my dx + 1.0); }
+static inline long Sampled_xToHighIndex (Sampled me, double x) { return (long) ceil ((x - my x1) / my dx + 1.0); }
+static inline long Sampled_xToNearestIndex (Sampled me, double x) { return (long) round ((x - my x1) / my dx + 1.0); }
long Sampled_getWindowSamples (Sampled me, double xmin, double xmax, long *ixmin, long *ixmax);
diff --git a/fon/SampledXY.cpp b/fon/SampledXY.cpp
index bc5ae20..bb8155b 100644
--- a/fon/SampledXY.cpp
+++ b/fon/SampledXY.cpp
@@ -40,23 +40,23 @@
Thing_implement (SampledXY, Sampled, 0);
-void structSampledXY :: f_init
- (double xmin_, double xmax_, long nx_, double dx_, double x1_,
- double ymin_, double ymax_, long ny_, double dy_, double y1_)
+void SampledXY_init (SampledXY me,
+ double xmin, double xmax, long nx, double dx, double x1,
+ double ymin, double ymax, long ny, double dy, double y1)
{
- Sampled_init (this, xmin_, xmax_, nx_, dx_, x1_);
- our ymin = ymin_;
- our ymax = ymax_;
- our ny = ny_;
- our dy = dy_;
- our y1 = y1_;
+ Sampled_init (me, xmin, xmax, nx, dx, x1);
+ my ymin = ymin;
+ my ymax = ymax;
+ my ny = ny;
+ my dy = dy;
+ my y1 = y1;
}
-long structSampledXY :: f_getWindowSamplesY (double ymin_, double ymax_, long *iymin, long *iymax) {
- double riymin = 1.0 + ceil ((ymin_ - our y1) / our dy);
- double riymax = 1.0 + floor ((ymax_ - our y1) / our dy); // could be above 32-bit LONG_MAX
+long SampledXY_getWindowSamplesY (SampledXY me, double fromY, double toY, long *iymin, long *iymax) {
+ double riymin = 1.0 + ceil ((fromY - my y1) / my dy);
+ double riymax = 1.0 + floor ((toY - my y1) / my dy); // could be above 32-bit LONG_MAX
*iymin = riymin < 1.0 ? 1 : (long) riymin;
- *iymax = riymax > (double) our ny ? our ny : (long) riymax;
+ *iymax = riymax > (double) my ny ? my ny : (long) riymax;
if (*iymin > *iymax) return 0;
return *iymax - *iymin + 1;
}
diff --git a/fon/SampledXY.h b/fon/SampledXY.h
index 53854aa..b343d57 100644
--- a/fon/SampledXY.h
+++ b/fon/SampledXY.h
@@ -24,5 +24,17 @@
#include "SampledXY_def.h"
oo_CLASS_CREATE (SampledXY, Sampled);
+void SampledXY_init (SampledXY me, double xmin, double xmax, long nx, double dx, double x1,
+ double ymin, double ymax, long ny, double dy, double y1);
+
+static inline double SampledXY_indexToY (SampledXY me, long index) { return my y1 + (index - 1 ) * my dy; }
+static inline double SampledXY_indexToY (SampledXY me, double index) { return my y1 + (index - 1.0) * my dy; }
+static inline double SampledXY_yToIndex (SampledXY me, double y) { return (y - my y1) / my dy + 1.0; }
+static inline long SampledXY_yToLowIndex (SampledXY me, double y) { return (long) floor ((y - my y1) / my dy + 1.0); }
+static inline long SampledXY_yToHighIndex (SampledXY me, double y) { return (long) ceil ((y - my y1) / my dy + 1.0); }
+static inline long SampledXY_yToNearestIndex (SampledXY me, double y) { return (long) round ((y - my y1) / my dy + 1.0); }
+
+long SampledXY_getWindowSamplesY (SampledXY me, double ymin, double ymax, long *iymin, long *iymax);
+
/* End of file SampledXY.h */
#endif
diff --git a/fon/SampledXY_def.h b/fon/SampledXY_def.h
index da11903..f6c930b 100644
--- a/fon/SampledXY_def.h
+++ b/fon/SampledXY_def.h
@@ -38,20 +38,9 @@ oo_DEFINE_CLASS (SampledXY, Sampled)
virtual bool v_hasGetNy () { return true; } virtual double v_getNy () { return ny; }
virtual bool v_hasGetDy () { return true; } virtual double v_getDy () { return dy; }
virtual bool v_hasGetY () { return true; } virtual double v_getY (long iy) { return y1 + (iy - 1) * dy; }
- // functions:
- void f_init (double xmin, double xmax, long nx, double dx, double x1,
- double ymin, double ymax, long ny, double dy, double y1);
- double f_indexToY (long index) { return y1 + (index - 1 ) * dy; }
- double f_indexToY (double index) { return y1 + (index - 1.0) * dy; }
- double f_yToIndex (double y) { return (y - y1) / dy + 1.0; }
- long f_yToLowIndex (double y) { return (long) floor (f_yToIndex (y)); }
- long f_yToHighIndex (double y) { return (long) ceil (f_yToIndex (y)); }
- long f_yToNearestIndex (double y) { return (long) round (f_yToIndex (y)); }
- long f_getWindowSamplesY (double ymin, double ymax, long *iymin, long *iymax);
#endif
oo_END_CLASS (SampledXY)
#undef ooSTRUCT
-
/* End of file SampledXY_def.h */
diff --git a/fon/Sampled_def.h b/fon/Sampled_def.h
index 3eaea82..9255c29 100644
--- a/fon/Sampled_def.h
+++ b/fon/Sampled_def.h
@@ -35,14 +35,6 @@ oo_DEFINE_CLASS (Sampled, Function)
// new methods:
virtual double v_getValueAtSample (long isamp, long ilevel, int unit)
{ (void) isamp; (void) ilevel; (void) unit; return NUMundefined; }
- // functions:
- inline double f_indexToX (long index) { return x1 + (index - 1 ) * dx; }
- inline double f_indexToX (double index) { return x1 + (index - 1.0) * dx; }
- double f_xToIndex (double x) { return (x - x1) / dx + 1.0; }
- long f_xToLowIndex (double x) { return (long) floor (f_xToIndex (x)); }
- long f_xToHighIndex (double x) { return (long) ceil (f_xToIndex (x)); }
- long f_xToNearestIndex (double x) { return (long) round (f_xToIndex (x)); }
- long f_getWindowSamplesX (double xmin, double xmax, long *ixmin, long *ixmax);
#endif
oo_END_CLASS (Sampled)
diff --git a/fon/Sound.cpp b/fon/Sound.cpp
index 6485952..b4a1477 100644
--- a/fon/Sound.cpp
+++ b/fon/Sound.cpp
@@ -337,7 +337,7 @@ Sound Sound_upsample (Sound me) {
try {
long nfft = 1;
while (nfft < my nx + 2000) nfft *= 2;
- autoSound thee = Sound_create (my ny, my xmin, my xmax, my nx * 2, my dx / 2, my x1);
+ autoSound thee = Sound_create (my ny, my xmin, my xmax, my nx * 2, my dx / 2, my x1 - my dx / 4);
autoNUMvector <double> data (1, 2 * nfft);
for (long channel = 1; channel <= my ny; channel ++) {
NUMvector_copyElements (my z [channel], & data [1000], 1, my nx);
@@ -399,8 +399,8 @@ Sound Sound_resample (Sound me, double samplingFrequency, long precision) {
double *to = thy z [channel];
if (precision <= 1) {
for (long i = 1; i <= numberOfSamples; i ++) {
- double x = thy f_indexToX (i);
- double index = my f_xToIndex (x);
+ double x = Sampled_indexToX (thee.peek(), i);
+ double index = Sampled_xToIndex (me, x);
long leftSample = floor (index);
double fraction = index - leftSample;
to [i] = leftSample < 1 || leftSample >= my nx ? 0.0 :
@@ -408,8 +408,8 @@ Sound Sound_resample (Sound me, double samplingFrequency, long precision) {
}
} else {
for (long i = 1; i <= numberOfSamples; i ++) {
- double x = thy f_indexToX (i);
- double index = my f_xToIndex (x);
+ double x = Sampled_indexToX (thee.peek(), i);
+ double index = Sampled_xToIndex (me, x);
to [i] = NUM_interpolate_sinc (my z [channel], my nx, index, precision);
}
}
@@ -775,7 +775,7 @@ void Sound_draw (Sound me, Graphics g,
maximum + (channel - 1) * (maximum - minimum));
if (wcsstr (method, L"bars") || wcsstr (method, L"Bars")) {
for (long ix = ixmin; ix <= ixmax; ix ++) {
- double x = my f_indexToX (ix);
+ double x = Sampled_indexToX (me, ix);
double y = my z [channel] [ix];
double left = x - 0.5 * my dx, right = x + 0.5 * my dx;
if (y > maximum) y = maximum;
@@ -787,12 +787,12 @@ void Sound_draw (Sound me, Graphics g,
}
} else if (wcsstr (method, L"poles") || wcsstr (method, L"Poles")) {
for (long ix = ixmin; ix <= ixmax; ix ++) {
- double x = my f_indexToX (ix);
+ double x = Sampled_indexToX (me, ix);
Graphics_line (g, x, 0, x, my z [channel] [ix]);
}
} else if (wcsstr (method, L"speckles") || wcsstr (method, L"Speckles")) {
for (long ix = ixmin; ix <= ixmax; ix ++) {
- double x = my f_indexToX (ix);
+ double x = Sampled_indexToX (me, ix);
Graphics_speckle (g, x, my z [channel] [ix]);
}
} else {
@@ -831,7 +831,7 @@ static double interpolate (Sound me, long i1, long channel)
/* Precondition: my z [1] [i1] != my z [1] [i1 + 1]; */
{
long i2 = i1 + 1;
- double x1 = my f_indexToX (i1), x2 = my f_indexToX (i2);
+ double x1 = Sampled_indexToX (me, i1), x2 = Sampled_indexToX (me, i2);
double y1 = my z [channel] [i1], y2 = my z [channel] [i2];
return x1 + (x2 - x1) * y1 / (y1 - y2); /* Linear. */
}
@@ -944,7 +944,7 @@ Sound Sound_createFromToneComplex (double startingTime, double endTime, double s
1 / sampleRate, startingTime + 0.5 / sampleRate);
double *amplitude = my z [1];
for (long isamp = 1; isamp <= my nx; isamp ++) {
- double value = 0.0, t = my f_indexToX (isamp);
+ double value = 0.0, t = Sampled_indexToX (me.peek(), isamp);
double omegaStepT = omegaStep * t, firstOmegaT = firstOmega * t;
if (phase == Sound_TONE_COMPLEX_SINE)
for (long icomp = 1; icomp <= numberOfComponents; icomp ++)
diff --git a/fon/SoundEditor.cpp b/fon/SoundEditor.cpp
index 9f74732..86265c6 100644
--- a/fon/SoundEditor.cpp
+++ b/fon/SoundEditor.cpp
@@ -363,7 +363,7 @@ void structSoundEditor :: v_draw () {
Graphics_setColour (d_graphics, Graphics_WHITE);
Graphics_setWindow (d_graphics, 0, 1, 0, 1);
Graphics_fillRectangle (d_graphics, 0, 1, 0, 1);
- f_drawSound (d_sound.minimum, d_sound.maximum);
+ TimeSoundEditor_drawSound (this, d_sound.minimum, d_sound.maximum);
Graphics_flushWs (d_graphics);
if (showAnalysis)
Graphics_resetViewport (d_graphics, viewport);
@@ -384,7 +384,7 @@ void structSoundEditor :: v_draw () {
if (showAnalysis)
viewport = Graphics_insetViewport (d_graphics, 0, 1, 0.5, 1);
v_draw_analysis_pulses ();
- f_drawSound (d_sound.minimum, d_sound.maximum); // second time, partially across the pulses
+ TimeSoundEditor_drawSound (this, d_sound.minimum, d_sound.maximum); // second time, partially across the pulses
Graphics_flushWs (d_graphics);
if (showAnalysis)
Graphics_resetViewport (d_graphics, viewport);
@@ -432,17 +432,17 @@ void structSoundEditor :: v_unhighlightSelection (double left, double right, dou
Graphics_unhighlight (d_graphics, left, right, bottom, top);
}
-void structSoundEditor :: f_init (const wchar_t *title, Sampled data) {
+void SoundEditor_init (SoundEditor me, const wchar_t *title, Sampled data) {
/*
* my longSound.data or my sound.data have to be set before we call FunctionEditor_init,
* because createMenus expect that one of them is not NULL.
*/
- structTimeSoundAnalysisEditor :: f_init (title, data, data, false);
- if (d_longSound.data && d_endWindow - d_startWindow > 30.0) {
- d_endWindow = d_startWindow + 30.0;
- if (our d_startWindow == our tmin)
- d_startSelection = d_endSelection = 0.5 * (d_startWindow + d_endWindow);
- FunctionEditor_marksChanged (this, false);
+ TimeSoundAnalysisEditor_init (me, title, data, data, false);
+ if (my d_longSound.data && my d_endWindow - my d_startWindow > 30.0) {
+ my d_endWindow = my d_startWindow + 30.0;
+ if (my d_startWindow == my tmin)
+ my d_startSelection = my d_endSelection = 0.5 * (my d_startWindow + my d_endWindow);
+ FunctionEditor_marksChanged (me, false);
}
}
@@ -450,7 +450,7 @@ SoundEditor SoundEditor_create (const wchar_t *title, Sampled data) {
Melder_assert (data != NULL);
try {
autoSoundEditor me = Thing_new (SoundEditor);
- me -> f_init (title, data);
+ SoundEditor_init (me.peek(), title, data);
return me.transfer();
} catch (MelderError) {
Melder_throw ("Sound window not created.");
diff --git a/fon/SoundEditor.h b/fon/SoundEditor.h
index 700c46a..da7a9e7 100644
--- a/fon/SoundEditor.h
+++ b/fon/SoundEditor.h
@@ -26,9 +26,6 @@ Thing_define (SoundEditor, TimeSoundAnalysisEditor) {
private:
GuiMenuItem cutButton, copyButton, pasteButton, zeroButton, reverseButton;
double maxBuffer;
- // functions:
- public:
- void f_init (const wchar_t *title, Sampled data);
// overridden methods:
private:
virtual void v_createMenus ();
@@ -42,6 +39,8 @@ Thing_define (SoundEditor, TimeSoundAnalysisEditor) {
virtual void v_unhighlightSelection (double left, double right, double bottom, double top);
};
+void SoundEditor_init (SoundEditor me, const wchar_t *title, Sampled data);
+
SoundEditor SoundEditor_create (
const wchar_t *title,
Sampled data // either a Sound or a LongSound
diff --git a/fon/SoundRecorder.cpp b/fon/SoundRecorder.cpp
index 350afab..b9e0862 100644
--- a/fon/SoundRecorder.cpp
+++ b/fon/SoundRecorder.cpp
@@ -229,30 +229,30 @@ void structSoundRecorder :: v_destroy () {
stopRecording (this); // must occur before freeing my buffer
MelderAudio_stopPlaying (MelderAudio_IMPLICIT); // must also occur before freeing my buffer
#if cocoa
- if (d_cocoaTimer) CFRunLoopTimerInvalidate (d_cocoaTimer);
+ if (our d_cocoaTimer) CFRunLoopTimerInvalidate (our d_cocoaTimer);
#elif gtk
g_idle_remove_by_data (this);
#elif motif
- if (workProcId) XtRemoveWorkProc (workProcId);
+ if (our workProcId) XtRemoveWorkProc (our workProcId);
#endif
- NUMvector_free <short> (buffer, 0);
+ NUMvector_free (buffer, 0);
- if (inputUsesPortAudio) {
- if (portaudioStream) Pa_StopStream (portaudioStream);
- if (portaudioStream) Pa_CloseStream (portaudioStream);
+ if (our inputUsesPortAudio) {
+ if (our portaudioStream) Pa_StopStream (our portaudioStream);
+ if (our portaudioStream) Pa_CloseStream (our portaudioStream);
} else {
#if defined (_WIN32)
- if (hWaveIn != 0) {
- waveInReset (hWaveIn);
- waveInUnprepareHeader (hWaveIn, & waveHeader [0], sizeof (WAVEHDR));
- waveInClose (hWaveIn);
+ if (our hWaveIn != 0) {
+ waveInReset (our hWaveIn);
+ waveInUnprepareHeader (our hWaveIn, & our waveHeader [0], sizeof (WAVEHDR));
+ waveInClose (our hWaveIn);
}
#elif defined (macintosh)
#elif defined (UNIX)
- if (fd != -1) close (fd);
+ if (our fd != -1) close (our fd);
#endif
}
- forget (graphics);
+ forget (our graphics);
SoundRecorder_Parent :: v_destroy ();
}
@@ -361,6 +361,7 @@ static long getMyNsamp (SoundRecorder me) {
#if cocoa
static void workProc (CFRunLoopTimerRef timer, void *void_me) {
+ (void) timer;
#elif gtk
static gboolean workProc (void *void_me) {
#else
diff --git a/fon/Sound_and_Spectrogram.cpp b/fon/Sound_and_Spectrogram.cpp
index 967e80e..410ef84 100644
--- a/fon/Sound_and_Spectrogram.cpp
+++ b/fon/Sound_and_Spectrogram.cpp
@@ -135,8 +135,8 @@ Spectrogram Sound_to_Spectrogram (Sound me, double effectiveAnalysisWidth, doubl
double oneByBinWidth = 1.0 / windowssq / binWidth_samples;
for (long iframe = 1; iframe <= numberOfTimes; iframe ++) {
- double t = thy f_indexToX (iframe);
- long leftSample = my f_xToLowIndex (t), rightSample = leftSample + 1;
+ double t = Sampled_indexToX (thee.peek(), iframe);
+ long leftSample = Sampled_xToLowIndex (me, t), rightSample = leftSample + 1;
long startSample = rightSample - halfnsamp_window;
long endSample = leftSample + halfnsamp_window;
Melder_assert (startSample >= 1);
@@ -189,8 +189,8 @@ Sound Spectrogram_to_Sound (Spectrogram me, double fsamp) {
if (n < 0) return NULL;
autoSound thee = Sound_create (1, my xmin, my xmax, n, dt, 0.5 * dt);
for (long i = 1; i <= n; i ++) {
- double t = thy f_indexToX (i);
- double rframe = my f_xToIndex (t), phase, value = 0.0;
+ double t = Sampled_indexToX (thee.peek(), i);
+ double rframe = Sampled_xToIndex (me, t), phase, value = 0.0;
long leftFrame, rightFrame;
if (rframe < 1 || rframe >= my nx) continue;
leftFrame = floor (rframe), rightFrame = leftFrame + 1, phase = rframe - leftFrame;
diff --git a/fon/Sound_to_Cochleagram.cpp b/fon/Sound_to_Cochleagram.cpp
index 6b6ee83..2bed453 100644
--- a/fon/Sound_to_Cochleagram.cpp
+++ b/fon/Sound_to_Cochleagram.cpp
@@ -48,7 +48,7 @@ Cochleagram Sound_to_Cochleagram (Sound me, double dt, double df, double dt_wind
autoCochleagram thee = Cochleagram_create (my xmin, my xmax, nFrames, dt, t1, df, nf);
autoSound window = Sound_createSimple (1, nsamp_window * my dx, 1.0 / my dx);
for (long iframe = 1; iframe <= nFrames; iframe ++) {
- double t = thy f_indexToX (iframe);
+ double t = Sampled_indexToX (thee.peek(), iframe);
long leftSample = Sampled_xToLowIndex (me, t);
long rightSample = leftSample + 1;
long startSample = rightSample - halfnsamp_window;
diff --git a/fon/Sound_to_Formant.cpp b/fon/Sound_to_Formant.cpp
index 90adcb3..a73cb52 100644
--- a/fon/Sound_to_Formant.cpp
+++ b/fon/Sound_to_Formant.cpp
@@ -293,8 +293,8 @@ static Formant Sound_to_Formant_any_inline (Sound me, double dt_in, int numberOf
}
for (long iframe = 1; iframe <= nFrames; iframe ++) {
- double t = thy f_indexToX (iframe);
- long leftSample = my f_xToLowIndex (t);
+ double t = Sampled_indexToX (thee.peek(), iframe);
+ long leftSample = Sampled_xToLowIndex (me, t);
long rightSample = leftSample + 1;
long startSample = rightSample - halfnsamp_window;
long endSample = leftSample + halfnsamp_window;
diff --git a/fon/Sound_to_Intensity.cpp b/fon/Sound_to_Intensity.cpp
index 0d21e27..d3f14fe 100644
--- a/fon/Sound_to_Intensity.cpp
+++ b/fon/Sound_to_Intensity.cpp
@@ -1,6 +1,6 @@
/* Sound_to_Intensity.cpp
*
- * Copyright (C) 1992-2011 Paul Boersma
+ * Copyright (C) 1992-2011,2014 Paul Boersma
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -71,8 +71,8 @@ static Intensity Sound_to_Intensity_ (Sound me, double minimumPitch, double time
}
autoIntensity thee = Intensity_create (my xmin, my xmax, numberOfFrames, timeStep, thyFirstTime);
for (long iframe = 1; iframe <= numberOfFrames; iframe ++) {
- double midTime = thy f_indexToX (iframe);
- long midSample = my f_xToNearestIndex (midTime);
+ double midTime = Sampled_indexToX (thee.peek(), iframe);
+ long midSample = Sampled_xToNearestIndex (me, midTime);
long leftSample = midSample - halfWindowSamples, rightSample = midSample + halfWindowSamples;
double sumxw = 0.0, sumw = 0.0, intensity;
if (leftSample < 1) leftSample = 1;
diff --git a/fon/Sound_to_Pitch.cpp b/fon/Sound_to_Pitch.cpp
index 60de074..4309977 100644
--- a/fon/Sound_to_Pitch.cpp
+++ b/fon/Sound_to_Pitch.cpp
@@ -318,7 +318,7 @@ static MelderThread_RETURN_TYPE Sound_into_Pitch (Sound_into_Pitch_Args me)
}
for (long iframe = my firstFrame; iframe <= my lastFrame; iframe ++) {
Pitch_Frame pitchFrame = & my pitch -> frame [iframe];
- double t = my pitch -> f_indexToX (iframe);
+ double t = Sampled_indexToX (my pitch, iframe);
if (my isMainThread) {
try {
Melder_progress (0.1 + 0.8 * (iframe - my firstFrame) / (my lastFrame - my firstFrame),
diff --git a/fon/Sound_to_PointProcess.cpp b/fon/Sound_to_PointProcess.cpp
index 0f3e76b..706fe9c 100644
--- a/fon/Sound_to_PointProcess.cpp
+++ b/fon/Sound_to_PointProcess.cpp
@@ -98,7 +98,7 @@ PointProcess Sound_to_PointProcess_zeroes (Sound me, long channel, bool includeR
if ((includeRaisers && y [i - 1] < 0.0 && y [i] >= 0.0) ||
(includeFallers && y [i - 1] >= 0.0 && y [i] < 0.0))
{
- double time = my f_indexToX (i - 1) + my dx * y [i - 1] / (y [i - 1] - y [i]); // linear
+ double time = Sampled_indexToX (me, i - 1) + my dx * y [i - 1] / (y [i - 1] - y [i]); // linear
PointProcess_addPoint (thee.peek(), time);
}
}
diff --git a/fon/SpectrogramEditor.cpp b/fon/SpectrogramEditor.cpp
index 2080e6a..167170c 100644
--- a/fon/SpectrogramEditor.cpp
+++ b/fon/SpectrogramEditor.cpp
@@ -1,6 +1,6 @@
/* SpectrogramEditor.cpp
*
- * Copyright (C) 1992-2011,2012 Paul Boersma
+ * Copyright (C) 1992-2011,2012,2014 Paul Boersma
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,59 +22,59 @@
Thing_implement (SpectrogramEditor, FunctionEditor, 0);
void structSpectrogramEditor :: v_draw () {
- Spectrogram spectrogram = (Spectrogram) data;
+ Spectrogram spectrogram = (Spectrogram) our data;
- Graphics_setWindow (d_graphics, 0, 1, 0, 1);
- Graphics_setColour (d_graphics, Graphics_WHITE);
- Graphics_fillRectangle (d_graphics, 0, 1, 0, 1);
- Graphics_setColour (d_graphics, Graphics_BLACK);
- Graphics_rectangle (d_graphics, 0, 1, 0, 1);
+ 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);
long itmin, itmax;
- Sampled_getWindowSamples (spectrogram, d_startWindow, d_endWindow, & itmin, & itmax);
+ Sampled_getWindowSamples (spectrogram, our d_startWindow, our d_endWindow, & itmin, & itmax);
/*
* Autoscale frequency axis.
*/
- maximum = spectrogram -> ymax;
+ our maximum = spectrogram -> ymax;
- Graphics_setWindow (d_graphics, d_startWindow, d_endWindow, 0.0, maximum);
- Spectrogram_paintInside (spectrogram, d_graphics, d_startWindow, d_endWindow, 0, 0, 0.0, TRUE,
+ Graphics_setWindow (our d_graphics, our d_startWindow, our d_endWindow, 0.0, our maximum);
+ Spectrogram_paintInside (spectrogram, our d_graphics, our d_startWindow, our d_endWindow, 0, 0, 0.0, TRUE,
60, 6.0, 0);
/*
* Horizontal scaling lines.
*/
- Graphics_setWindow (d_graphics, 0.0, 1.0, 0.0, maximum);
- Graphics_setTextAlignment (d_graphics, Graphics_RIGHT, Graphics_HALF);
- Graphics_setColour (d_graphics, Graphics_RED);
+ Graphics_setWindow (our d_graphics, 0.0, 1.0, 0.0, our maximum);
+ Graphics_setTextAlignment (our d_graphics, Graphics_RIGHT, Graphics_HALF);
+ Graphics_setColour (our d_graphics, Graphics_RED);
long df = 1000;
- for (long f = df; f <= maximum; f += df) {
- Graphics_line (d_graphics, 0.0, f, 1.0, f);
- Graphics_text2 (d_graphics, -0.01, f, Melder_integer (f), L" Hz");
+ for (long f = df; f <= our maximum; f += df) {
+ Graphics_line (our d_graphics, 0.0, f, 1.0, f);
+ Graphics_text2 (our d_graphics, -0.01, f, Melder_integer (f), L" Hz");
}
/*
* Vertical cursor lines.
*/
- Graphics_setWindow (d_graphics, d_startWindow, d_endWindow, 0.0, maximum);
- if (d_startSelection > d_startWindow && d_startSelection < d_endWindow)
- Graphics_line (d_graphics, d_startSelection, 0, d_startSelection, maximum);
- if (d_endSelection > d_startWindow && d_endSelection < d_endWindow)
- Graphics_line (d_graphics, d_endSelection, 0, d_endSelection, maximum);
- Graphics_setColour (d_graphics, Graphics_BLACK);
+ Graphics_setWindow (our d_graphics, our d_startWindow, our d_endWindow, 0.0, our maximum);
+ if (our d_startSelection > our d_startWindow && our d_startSelection < our d_endWindow)
+ Graphics_line (our d_graphics, our d_startSelection, 0, our d_startSelection, our maximum);
+ if (our d_endSelection > our d_startWindow && d_endSelection < d_endWindow)
+ Graphics_line (our d_graphics, our d_endSelection, 0, our d_endSelection, our maximum);
+ Graphics_setColour (our d_graphics, Graphics_BLACK);
}
int structSpectrogramEditor :: v_click (double xWC, double yWC, bool shiftKeyPressed) {
- Spectrogram spectrogram = (Spectrogram) data;
- /*double frequency = yWC * maximum;*/
+ Spectrogram spectrogram = (Spectrogram) our data;
+ /*double frequency = yWC * our maximum;*/
long bestFrame;
bestFrame = Sampled_xToNearestIndex (spectrogram, xWC);
if (bestFrame < 1)
bestFrame = 1;
else if (bestFrame > spectrogram -> nx)
bestFrame = spectrogram -> nx;
- return SpectrogramEditor_Parent :: v_click (xWC, yWC, shiftKeyPressed);
+ return our SpectrogramEditor_Parent :: v_click (xWC, yWC, shiftKeyPressed);
}
SpectrogramEditor SpectrogramEditor_create (const wchar_t *title, Spectrogram data) {
diff --git a/fon/SpectrumEditor.cpp b/fon/SpectrumEditor.cpp
index 8c45bd7..95be75a 100644
--- a/fon/SpectrumEditor.cpp
+++ b/fon/SpectrumEditor.cpp
@@ -1,6 +1,6 @@
/* SpectrumEditor.cpp
*
- * Copyright (C) 1992-2011,2012,2013 Paul Boersma
+ * Copyright (C) 1992-2011,2012,2013,2014 Paul Boersma
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -44,31 +44,31 @@ void structSpectrumEditor :: v_dataChanged () {
}
void structSpectrumEditor :: v_draw () {
- Spectrum spectrum = (Spectrum) data;
-
- Graphics_setWindow (d_graphics, 0, 1, 0, 1);
- Graphics_setColour (d_graphics, Graphics_WHITE);
- Graphics_fillRectangle (d_graphics, 0, 1, 0, 1);
- Graphics_setColour (d_graphics, Graphics_BLACK);
- Graphics_rectangle (d_graphics, 0, 1, 0, 1);
- Spectrum_drawInside (spectrum, d_graphics, d_startWindow, d_endWindow, minimum, maximum);
- FunctionEditor_drawRangeMark (this, maximum, Melder_fixed (maximum, 1), L" dB", Graphics_TOP);
- FunctionEditor_drawRangeMark (this, minimum, Melder_fixed (minimum, 1), L" dB", Graphics_BOTTOM);
- if (cursorHeight > minimum && cursorHeight < maximum)
- FunctionEditor_drawHorizontalHair (this, cursorHeight, Melder_fixed (cursorHeight, 1), L" dB");
- Graphics_setColour (d_graphics, Graphics_BLACK);
+ Spectrum spectrum = (Spectrum) our data;
+
+ 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);
+ Spectrum_drawInside (spectrum, our d_graphics, our d_startWindow, our d_endWindow, our minimum, our maximum);
+ FunctionEditor_drawRangeMark (this, our maximum, Melder_fixed (maximum, 1), L" dB", Graphics_TOP);
+ FunctionEditor_drawRangeMark (this, our minimum, Melder_fixed (minimum, 1), L" dB", Graphics_BOTTOM);
+ if (our cursorHeight > our minimum && our cursorHeight < our maximum)
+ FunctionEditor_drawHorizontalHair (this, our cursorHeight, Melder_fixed (our cursorHeight, 1), L" dB");
+ Graphics_setColour (our d_graphics, Graphics_BLACK);
/* Update buttons. */
long first, last;
- long selectedSamples = Sampled_getWindowSamples (spectrum, d_startSelection, d_endSelection, & first, & last);
- publishBandButton -> f_setSensitive (selectedSamples != 0);
- publishSoundButton -> f_setSensitive (selectedSamples != 0);
+ long selectedSamples = Sampled_getWindowSamples (spectrum, our d_startSelection, our d_endSelection, & first, & last);
+ our publishBandButton -> f_setSensitive (selectedSamples != 0);
+ our publishSoundButton -> f_setSensitive (selectedSamples != 0);
}
int structSpectrumEditor :: v_click (double xWC, double yWC, bool shiftKeyPressed) {
- cursorHeight = minimum + yWC * (maximum - minimum);
- return SpectrumEditor_Parent :: v_click (xWC, yWC, shiftKeyPressed); // move cursor or drag selection
+ our cursorHeight = our minimum + yWC * (our maximum - our minimum);
+ return our SpectrumEditor_Parent :: v_click (xWC, yWC, shiftKeyPressed); // move cursor or drag selection
}
static Spectrum Spectrum_band (Spectrum me, double fmin, double fmax) {
@@ -87,7 +87,7 @@ static Sound Spectrum_to_Sound_part (Spectrum me, double fmin, double fmax) {
}
void structSpectrumEditor :: v_play (double fmin, double fmax) {
- autoSound sound = Spectrum_to_Sound_part ((Spectrum) data, fmin, fmax);
+ autoSound sound = Spectrum_to_Sound_part ((Spectrum) our data, fmin, fmax);
Sound_play (sound.peek(), NULL, NULL);
}
@@ -162,8 +162,8 @@ static void menu_cb_help_Spectrum (EDITOR_ARGS) { EDITOR_IAM (SpectrumEditor); M
void structSpectrumEditor :: v_createMenus () {
SpectrumEditor_Parent :: v_createMenus ();
- publishBandButton = Editor_addCommand (this, L"File", L"Publish band", 0, menu_cb_publishBand);
- publishSoundButton = Editor_addCommand (this, L"File", L"Publish band-filtered sound", 0, menu_cb_publishSound);
+ our publishBandButton = Editor_addCommand (this, L"File", L"Publish band", 0, menu_cb_publishBand);
+ our publishSoundButton = Editor_addCommand (this, L"File", L"Publish band-filtered sound", 0, menu_cb_publishSound);
Editor_addCommand (this, L"File", L"-- close --", 0, NULL);
Editor_addCommand (this, L"Edit", L"-- edit band --", 0, NULL);
Editor_addCommand (this, L"Edit", L"Pass band...", 0, menu_cb_passBand);
diff --git a/fon/Spectrum_and_Spectrogram.cpp b/fon/Spectrum_and_Spectrogram.cpp
index f01399a..fe230d4 100644
--- a/fon/Spectrum_and_Spectrogram.cpp
+++ b/fon/Spectrum_and_Spectrogram.cpp
@@ -34,7 +34,7 @@ Spectrum Spectrogram_to_Spectrum (I, double tim) {
thy xmax = my ymax;
thy x1 = my y1; // centre of first band, instead of 0 (makes it unFFTable)
thy dx = my dy; // frequency step
- long itime = my f_xToIndex (tim);
+ long itime = Sampled_xToIndex (me, tim);
if (itime < 1 ) itime = 1;
if (itime > my nx) itime = my nx;
for (long ifreq = 1; ifreq <= my ny; ifreq ++) {
diff --git a/fon/Spectrum_to_Excitation.cpp b/fon/Spectrum_to_Excitation.cpp
index a3fc365..0f87b22 100644
--- a/fon/Spectrum_to_Excitation.cpp
+++ b/fon/Spectrum_to_Excitation.cpp
@@ -66,7 +66,7 @@ Excitation Spectrum_to_Excitation (Spectrum me, double dbark) {
autoExcitation thee = Excitation_create (dbark, nbark);
for (long i = 1; i <= nbark; i ++)
- thy z [1] [i] = Excitation_soundPressureToPhon (sqrt (outSig [i + nbark/2]), thy f_indexToX (i));
+ thy z [1] [i] = Excitation_soundPressureToPhon (sqrt (outSig [i + nbark/2]), Sampled_indexToX (thee.peek(), i));
return thee.transfer();
} catch (MelderError) {
diff --git a/fon/TextGridEditor.cpp b/fon/TextGridEditor.cpp
index 76e511c..910ce4b 100644
--- a/fon/TextGridEditor.cpp
+++ b/fon/TextGridEditor.cpp
@@ -1564,7 +1564,7 @@ void structTextGridEditor :: v_draw () {
Graphics_setColour (d_graphics, Graphics_WHITE);
Graphics_setWindow (d_graphics, 0, 1, 0, 1);
Graphics_fillRectangle (d_graphics, 0, 1, 0, 1);
- f_drawSound (-1.0, 1.0);
+ TimeSoundEditor_drawSound (this, -1.0, 1.0);
Graphics_flushWs (d_graphics);
Graphics_resetViewport (d_graphics, vp1);
}
@@ -1663,7 +1663,7 @@ void structTextGridEditor :: v_draw () {
if (p_pulses_show) {
vp1 = Graphics_insetViewport (d_graphics, 0.0, 1.0, soundY2, 1.0);
v_draw_analysis_pulses ();
- f_drawSound (-1.0, 1.0); // second time, partially across the pulses
+ TimeSoundEditor_drawSound (this, -1.0, 1.0); // second time, partially across the pulses
Graphics_flushWs (d_graphics);
Graphics_resetViewport (d_graphics, vp1);
}
@@ -1872,7 +1872,7 @@ static void do_dragBoundary (TextGridEditor me, double xbegin, int iClickedTier,
}
int structTextGridEditor :: v_click (double xclick, double yWC, bool shiftKeyPressed) {
- TextGrid grid = (TextGrid) data;
+ TextGrid grid = (TextGrid) our data;
double tmin, tmax, x, y;
long ntiers = grid -> tiers -> size, iClickedTier, iClickedInterval, iClickedPoint;
int clickedLeftBoundary = 0, nearBoundaryOrPoint, nearCursorCircle, drag = FALSE;
@@ -1888,11 +1888,11 @@ int structTextGridEditor :: v_click (double xclick, double yWC, bool shiftKeyPre
* we keep the same tier selected and move the cursor or drag the "yellow" selection.
*/
if (yWC > soundY) { /* Clicked in sound part? */
- if ((p_spectrogram_show || p_formant_show) && yWC < 0.5 * (soundY + 1.0)) {
- d_spectrogram_cursor = p_spectrogram_viewFrom +
- 2.0 * (yWC - soundY) / (1.0 - soundY) * (p_spectrogram_viewTo - p_spectrogram_viewFrom);
+ if ((our p_spectrogram_show || our p_formant_show) && yWC < 0.5 * (soundY + 1.0)) {
+ our d_spectrogram_cursor = our p_spectrogram_viewFrom +
+ 2.0 * (yWC - soundY) / (1.0 - soundY) * (our p_spectrogram_viewTo - our p_spectrogram_viewFrom);
}
- TextGridEditor_Parent :: v_click (xclick, yWC, shiftKeyPressed);
+ our TextGridEditor_Parent :: v_click (xclick, yWC, shiftKeyPressed);
return FunctionEditor_UPDATE_NEEDED;
}
@@ -1902,8 +1902,8 @@ int structTextGridEditor :: v_click (double xclick, double yWC, bool shiftKeyPre
*/
iClickedTier = _TextGridEditor_yWCtoTier (this, yWC);
- if (xclick <= d_startWindow || xclick >= d_endWindow) {
- selectedTier = iClickedTier;
+ if (xclick <= our d_startWindow || xclick >= our d_endWindow) {
+ our selectedTier = iClickedTier;
return FunctionEditor_UPDATE_NEEDED;
}
@@ -1930,7 +1930,7 @@ int structTextGridEditor :: v_click (double xclick, double yWC, bool shiftKeyPre
* She clicked outside time domain of intervals.
* This can occur when we are grouped with a longer time function.
*/
- selectedTier = iClickedTier;
+ our selectedTier = iClickedTier;
return FunctionEditor_UPDATE_NEEDED;
}
} else {
@@ -1945,18 +1945,18 @@ int structTextGridEditor :: v_click (double xclick, double yWC, bool shiftKeyPre
/*
* Where did she click?
*/
- nearBoundaryOrPoint = tnear != NUMundefined && fabs (Graphics_dxWCtoMM (d_graphics, xclick - tnear)) < 1.5;
- nearCursorCircle = d_startSelection == d_endSelection && Graphics_distanceWCtoMM (d_graphics, xclick, yWC,
- d_startSelection, (ntiers + 1 - iClickedTier) * soundY / ntiers - Graphics_dyMMtoWC (d_graphics, 1.5)) < 1.5;
+ nearBoundaryOrPoint = tnear != NUMundefined && fabs (Graphics_dxWCtoMM (our d_graphics, xclick - tnear)) < 1.5;
+ nearCursorCircle = our d_startSelection == our d_endSelection && Graphics_distanceWCtoMM (our d_graphics, xclick, yWC,
+ our d_startSelection, (ntiers + 1 - iClickedTier) * soundY / ntiers - Graphics_dyMMtoWC (our d_graphics, 1.5)) < 1.5;
/*
* Find out whether this is a click or a drag.
*/
- while (Graphics_mouseStillDown (d_graphics)) {
- Graphics_getMouseLocation (d_graphics, & x, & y);
- if (x < d_startWindow) x = d_startWindow;
- if (x > d_endWindow) x = d_endWindow;
- if (fabs (Graphics_dxWCtoMM (d_graphics, x - xclick)) > 1.5) {
+ while (Graphics_mouseStillDown (our d_graphics)) {
+ Graphics_getMouseLocation (our d_graphics, & x, & y);
+ if (x < our d_startWindow) x = our d_startWindow;
+ if (x > our d_endWindow) x = our d_endWindow;
+ if (fabs (Graphics_dxWCtoMM (our d_graphics, x - xclick)) > 1.5) {
drag = TRUE;
break;
}
@@ -1971,13 +1971,13 @@ int structTextGridEditor :: v_click (double xclick, double yWC, bool shiftKeyPre
/*
* Ignore click on left edge of first interval or right edge of last interval.
*/
- selectedTier = iClickedTier;
+ our selectedTier = iClickedTier;
} else if (drag) {
/*
* The tier that has been clicked becomes the new selected tier.
* This has to be done before the next Update, i.e. also before do_dragBoundary!
*/
- selectedTier = iClickedTier;
+ our selectedTier = iClickedTier;
do_dragBoundary (this, tnear, iClickedTier, shiftKeyPressed);
return FunctionEditor_NO_UPDATE_NEEDED;
} else {
@@ -1985,14 +1985,14 @@ int structTextGridEditor :: v_click (double xclick, double yWC, bool shiftKeyPre
* If she clicked on an unselected boundary or point, we select it.
*/
if (shiftKeyPressed) {
- if (tnear > 0.5 * (d_startSelection + d_endSelection))
- d_endSelection = tnear;
+ if (tnear > 0.5 * (our d_startSelection + our d_endSelection))
+ our d_endSelection = tnear;
else
- d_startSelection = tnear;
+ our d_startSelection = tnear;
} else {
- d_startSelection = d_endSelection = tnear; /* Move cursor so that the boundary or point is selected. */
+ our d_startSelection = our d_endSelection = tnear; /* Move cursor so that the boundary or point is selected. */
}
- selectedTier = iClickedTier;
+ our selectedTier = iClickedTier;
}
} else if (nearCursorCircle) {
/*
@@ -2000,23 +2000,23 @@ int structTextGridEditor :: v_click (double xclick, double yWC, bool shiftKeyPre
* Insert boundary or point. There is no danger that we insert on top of an existing boundary or point,
* because we are not 'nearBoundaryOrPoint'.
*/
- insertBoundaryOrPoint (this, iClickedTier, d_startSelection, d_startSelection, false);
- selectedTier = iClickedTier;
+ insertBoundaryOrPoint (this, iClickedTier, our d_startSelection, our d_startSelection, false);
+ our selectedTier = iClickedTier;
FunctionEditor_marksChanged (this, true);
- broadcastDataChanged ();
- if (drag) Graphics_waitMouseUp (d_graphics);
+ our broadcastDataChanged ();
+ if (drag) Graphics_waitMouseUp (our d_graphics);
return FunctionEditor_NO_UPDATE_NEEDED;
} else {
/*
* Possibility 3: she clicked in empty space.
*/
if (intervalTier) {
- d_startSelection = tmin;
- d_endSelection = tmax;
+ our d_startSelection = tmin;
+ our d_endSelection = tmax;
}
selectedTier = iClickedTier;
}
- if (drag) Graphics_waitMouseUp (d_graphics);
+ if (drag) Graphics_waitMouseUp (our d_graphics);
return FunctionEditor_UPDATE_NEEDED;
}
@@ -2024,22 +2024,22 @@ int structTextGridEditor :: v_clickB (double t, double yWC) {
double soundY = _TextGridEditor_computeSoundY (this);
if (yWC > soundY) { // clicked in sound part?
- d_startSelection = t;
- if (d_startSelection > d_endSelection) {
- double dummy = d_startSelection;
- d_startSelection = d_endSelection;
- d_endSelection = dummy;
+ our d_startSelection = t;
+ if (our d_startSelection > our d_endSelection) {
+ double dummy = our d_startSelection;
+ our d_startSelection = our d_endSelection;
+ our d_endSelection = dummy;
}
return FunctionEditor_UPDATE_NEEDED;
}
int itier = _TextGridEditor_yWCtoTier (this, yWC);
double tmin, tmax;
_TextGridEditor_timeToInterval (this, t, itier, & tmin, & tmax);
- d_startSelection = t - tmin < tmax - t ? tmin : tmax; // to nearest boundary
- if (d_startSelection > d_endSelection) {
- double dummy = d_startSelection;
- d_startSelection = d_endSelection;
- d_endSelection = dummy;
+ our d_startSelection = t - tmin < tmax - t ? tmin : tmax; // to nearest boundary
+ if (our d_startSelection > our d_endSelection) {
+ double dummy = our d_startSelection;
+ our d_startSelection = our d_endSelection;
+ our d_endSelection = dummy;
}
return FunctionEditor_UPDATE_NEEDED;
}
@@ -2048,39 +2048,39 @@ int structTextGridEditor :: v_clickE (double t, double yWC) {
double soundY = _TextGridEditor_computeSoundY (this);
if (yWC > soundY) { // clicked in sound part?
- d_endSelection = t;
- if (d_startSelection > d_endSelection) {
- double dummy = d_startSelection;
- d_startSelection = d_endSelection;
- d_endSelection = dummy;
+ our d_endSelection = t;
+ if (our d_startSelection > our d_endSelection) {
+ double dummy = our d_startSelection;
+ our d_startSelection = our d_endSelection;
+ our d_endSelection = dummy;
}
return FunctionEditor_UPDATE_NEEDED;
}
int itier = _TextGridEditor_yWCtoTier (this, yWC);
double tmin, tmax;
_TextGridEditor_timeToInterval (this, t, itier, & tmin, & tmax);
- d_endSelection = t - tmin < tmax - t ? tmin : tmax;
- if (d_startSelection > d_endSelection) {
- double dummy = d_startSelection;
- d_startSelection = d_endSelection;
- d_endSelection = dummy;
+ our d_endSelection = t - tmin < tmax - t ? tmin : tmax;
+ if (our d_startSelection > our d_endSelection) {
+ double dummy = our d_startSelection;
+ our d_startSelection = our d_endSelection;
+ our d_endSelection = dummy;
}
return FunctionEditor_UPDATE_NEEDED;
}
void structTextGridEditor :: v_play (double tmin, double tmax) {
- if (d_longSound.data) {
- LongSound_playPart (d_longSound.data, tmin, tmax, theFunctionEditor_playCallback, this);
- } else if (d_sound.data) {
- Sound_playPart (d_sound.data, tmin, tmax, theFunctionEditor_playCallback, this);
+ if (our d_longSound.data) {
+ LongSound_playPart (our d_longSound.data, tmin, tmax, theFunctionEditor_playCallback, this);
+ } else if (our d_sound.data) {
+ Sound_playPart (our d_sound.data, tmin, tmax, theFunctionEditor_playCallback, this);
}
}
void structTextGridEditor :: v_updateText () {
- TextGrid grid = (TextGrid) data;
+ TextGrid grid = (TextGrid) our data;
const wchar_t *newText = L"";
- trace ("selected tier %ld", selectedTier);
- if (selectedTier) {
+ trace ("selected tier %ld", our selectedTier);
+ if (our selectedTier) {
IntervalTier intervalTier;
TextTier textTier;
_AnyTier_identifyClass ((Function) grid -> tiers -> item [selectedTier], & intervalTier, & textTier);
@@ -2103,13 +2103,13 @@ void structTextGridEditor :: v_updateText () {
}
}
//Melder_casual ("v_updateText in editor %ld %ls %d", this, name, (int) suppressRedraw);
- if (text) {
- suppressRedraw = TRUE; // prevent valueChangedCallback from redrawing
+ if (our text) {
+ our suppressRedraw = TRUE; // prevent valueChangedCallback from redrawing
trace ("setting new text %ls", newText);
text -> f_setString (newText);
long cursor = wcslen (newText); // at end
text -> f_setSelection (cursor, cursor);
- suppressRedraw = FALSE;
+ our suppressRedraw = FALSE;
}
}
@@ -2158,22 +2158,22 @@ void structTextGridEditor :: v_createMenuItems_view_timeDomain (EditorMenu menu)
}
void structTextGridEditor :: v_highlightSelection (double left, double right, double bottom, double top) {
- if (v_hasAnalysis () && p_spectrogram_show && (d_longSound.data || d_sound.data)) {
+ if (our v_hasAnalysis () && our p_spectrogram_show && (our d_longSound.data || our d_sound.data)) {
double soundY = _TextGridEditor_computeSoundY (this), soundY2 = 0.5 * (1.0 + soundY);
- //Graphics_highlight (d_graphics, left, right, bottom, soundY * top + (1 - soundY) * bottom);
- Graphics_highlight (d_graphics, left, right, soundY2 * top + (1 - soundY2) * bottom, top);
+ //Graphics_highlight (our d_graphics, left, right, bottom, soundY * top + (1 - soundY) * bottom);
+ Graphics_highlight (our d_graphics, left, right, soundY2 * top + (1 - soundY2) * bottom, top);
} else {
- Graphics_highlight (d_graphics, left, right, bottom, top);
+ Graphics_highlight (our d_graphics, left, right, bottom, top);
}
}
void structTextGridEditor :: v_unhighlightSelection (double left, double right, double bottom, double top) {
- if (v_hasAnalysis () && p_spectrogram_show && (d_longSound.data || d_sound.data)) {
+ if (our v_hasAnalysis () && our p_spectrogram_show && (our d_longSound.data || our d_sound.data)) {
double soundY = _TextGridEditor_computeSoundY (this), soundY2 = 0.5 * (1.0 + soundY);
- //Graphics_unhighlight (d_graphics, left, right, bottom, soundY * top + (1 - soundY) * bottom);
- Graphics_unhighlight (d_graphics, left, right, soundY2 * top + (1 - soundY2) * bottom, top);
+ //Graphics_unhighlight (our d_graphics, left, right, bottom, soundY * top + (1 - soundY) * bottom);
+ Graphics_unhighlight (our d_graphics, left, right, soundY2 * top + (1 - soundY2) * bottom, top);
} else {
- Graphics_unhighlight (d_graphics, left, right, bottom, top);
+ Graphics_unhighlight (our d_graphics, left, right, bottom, top);
}
}
@@ -2192,8 +2192,8 @@ void structTextGridEditor :: v_createMenuItems_pitch_picture (EditorMenu menu) {
void structTextGridEditor :: v_updateMenuItems_file () {
TextGridEditor_Parent :: v_updateMenuItems_file ();
- extractSelectedTextGridPreserveTimesButton -> f_setSensitive (d_endSelection > d_startSelection);
- extractSelectedTextGridTimeFromZeroButton -> f_setSensitive (d_endSelection > d_startSelection);
+ extractSelectedTextGridPreserveTimesButton -> f_setSensitive (our d_endSelection > our d_startSelection);
+ extractSelectedTextGridTimeFromZeroButton -> f_setSensitive (our d_endSelection > our d_startSelection);
}
/********** EXPORTED **********/
@@ -2201,8 +2201,9 @@ void structTextGridEditor :: v_updateMenuItems_file () {
void TextGridEditor_init (TextGridEditor me, const wchar_t *title, TextGrid grid, Sampled sound, bool ownSound, SpellingChecker spellingChecker, const char *callbackSocket)
{
my spellingChecker = spellingChecker; // set in time
+ my callbackSocket = Melder_strdup (callbackSocket);
- my structTimeSoundAnalysisEditor :: f_init (title, grid, sound, ownSound);
+ TimeSoundAnalysisEditor_init (me, title, grid, sound, ownSound);
my selectedTier = 1;
my v_updateText (); // to reflect changed tier selection
diff --git a/fon/TextGrid_Sound.cpp b/fon/TextGrid_Sound.cpp
index c01bf4a..0d29195 100644
--- a/fon/TextGrid_Sound.cpp
+++ b/fon/TextGrid_Sound.cpp
@@ -28,6 +28,21 @@
#include "SpeechSynthesizer_and_TextGrid.h"
#include "LongSound.h"
+static bool IntervalTier_check (IntervalTier me) {
+ for (long iinterval = 1; iinterval <= my numberOfIntervals (); iinterval ++) {
+ TextInterval interval = my interval (iinterval);
+ if (interval -> xmin >= interval -> xmax)
+ return false;
+ }
+ if (my numberOfIntervals () < 2) return true;
+ for (long iinterval = 1; iinterval < my numberOfIntervals (); iinterval ++) {
+ TextInterval interval = my interval (iinterval), nextInterval = my interval (iinterval + 1);
+ if (interval -> xmax != nextInterval -> xmin)
+ return false;
+ }
+ return true;
+}
+
static void IntervalTier_insertIntervalDestructively (IntervalTier me, double tmin, double tmax) {
Melder_assert (tmin < tmax);
Melder_assert (tmin >= my xmin);
@@ -160,9 +175,33 @@ void TextGrid_anySound_alignInterval (TextGrid me, Function anySound, long tierN
Melder_assert (analysis -> xmax == interval -> xmax);
Melder_assert (analysis -> numberOfTiers () == 4);
Thing_cast (IntervalTier, analysisWordTier, analysis -> tier (3));
+ if (! IntervalTier_check (analysisWordTier))
+ Melder_throw (L"Analysis word tier out of order.");
IntervalTier_removeEmptyIntervals (analysisWordTier, NULL);
+ Melder_assert (analysisWordTier -> xmax == analysis -> xmax);
+ Melder_assert (analysisWordTier -> numberOfIntervals () >= 1);
+ TextInterval firstInterval = analysisWordTier -> interval (1);
+ TextInterval lastInterval = analysisWordTier -> interval (analysisWordTier -> numberOfIntervals ());
+ firstInterval -> xmin = analysis -> xmin;
+ lastInterval -> xmax = analysis -> xmax;
+ if (lastInterval -> xmax != analysis -> xmax)
+ Melder_fatal ("analysis ends at %ls, but last interval at %ls seconds",
+ Melder_double (analysis -> xmax), Melder_double (lastInterval -> xmax));
+ if (! IntervalTier_check (analysisWordTier))
+ Melder_throw (L"Analysis word tier out of order (2).");
Thing_cast (IntervalTier, analysisPhonemeTier, analysis -> tier (4));
+ if (! IntervalTier_check (analysisPhonemeTier))
+ Melder_throw (L"Analysis phoneme tier out of order.");
IntervalTier_removeEmptyIntervals (analysisPhonemeTier, analysisWordTier);
+ Melder_assert (analysisPhonemeTier -> xmax == analysis -> xmax);
+ Melder_assert (analysisPhonemeTier -> numberOfIntervals () >= 1);
+ firstInterval = analysisPhonemeTier -> interval (1);
+ lastInterval = analysisPhonemeTier -> interval (analysisPhonemeTier -> numberOfIntervals ());
+ firstInterval -> xmin = analysis -> xmin;
+ lastInterval -> xmax = analysis -> xmax;
+ Melder_assert (lastInterval -> xmax == analysis -> xmax);
+ if (! IntervalTier_check (analysisPhonemeTier))
+ Melder_throw (L"Analysis phoneme tier out of order (2).");
}
long wordTierNumber = 0, phonemeTierNumber = 0;
IntervalTier wordTier = NULL, phonemeTier = NULL;
@@ -204,6 +243,10 @@ void TextGrid_anySound_alignInterval (TextGrid me, Function anySound, long tierN
Melder_assert (wordIntervalNumber != 0);
if (analysis.peek()) {
Thing_cast (IntervalTier, analysisWordTier, analysis -> tier (3));
+ if (! IntervalTier_check (analysisWordTier))
+ Melder_throw (L"Analysis word tier out of order (3).");
+ if (! IntervalTier_check (wordTier))
+ Melder_throw (L"Word tier out of order (3).");
for (long ianalysisInterval = 1; ianalysisInterval <= analysisWordTier -> numberOfIntervals (); ianalysisInterval ++) {
TextInterval analysisInterval = analysisWordTier -> interval (ianalysisInterval);
TextInterval wordInterval = NULL;
@@ -219,6 +262,10 @@ void TextGrid_anySound_alignInterval (TextGrid me, Function anySound, long tierN
wordIntervalNumber ++;
}
}
+ if (! IntervalTier_check (analysisWordTier))
+ Melder_throw (L"Analysis word tier out of order (4).");
+ if (! IntervalTier_check (wordTier))
+ Melder_throw (L"Word tier out of order (4).");
}
}
/*
@@ -309,7 +356,7 @@ void TextGrid_Sound_draw (TextGrid me, Sound sound, Graphics g, double tmin, dou
Graphics_line (g, tmin, 0.0, tmax, 0.0);
Graphics_setLineType (g, Graphics_DRAWN);
Graphics_function (g, sound -> z [1], first, last,
- sound -> f_indexToX (first), sound -> f_indexToX (last));
+ Sampled_indexToX (sound, first), Sampled_indexToX (sound, last));
}
/*
diff --git a/fon/TimeSoundAnalysisEditor.cpp b/fon/TimeSoundAnalysisEditor.cpp
index bd7e49e..f68a9b3 100644
--- a/fon/TimeSoundAnalysisEditor.cpp
+++ b/fon/TimeSoundAnalysisEditor.cpp
@@ -754,7 +754,7 @@ static void menu_cb_pitchListing (EDITOR_ARGS) {
long i, i1, i2;
Sampled_getWindowSamples (my d_pitch, tmin, tmax, & i1, & i2);
for (i = i1; i <= i2; i ++) {
- double t = my d_pitch -> f_indexToX (i);
+ double t = Sampled_indexToX (my d_pitch, i);
double f0 = Sampled_getValueAtSample (my d_pitch, i, Pitch_LEVEL_FREQUENCY, my p_pitch_unit);
f0 = Function_convertToNonlogarithmic (my d_pitch, f0, Pitch_LEVEL_FREQUENCY, my p_pitch_unit);
MelderInfo_writeLine (Melder_fixed (t, 6), L" ", Melder_fixed (f0, 6));
@@ -1013,7 +1013,7 @@ static void menu_cb_intensityListing (EDITOR_ARGS) {
long i, i1, i2;
Sampled_getWindowSamples (my d_intensity, tmin, tmax, & i1, & i2);
for (i = i1; i <= i2; i ++) {
- double t = my d_intensity -> f_indexToX (i);
+ double t = Sampled_indexToX (my d_intensity, i);
double intensity = Vector_getValueAtX (my d_intensity, t, Vector_CHANNEL_1, Vector_VALUE_INTERPOLATION_NEAREST);
MelderInfo_writeLine (Melder_fixed (t, 6), L" ", Melder_fixed (intensity, 6));
}
@@ -1196,7 +1196,7 @@ static void menu_cb_formantListing (EDITOR_ARGS) {
long i, i1, i2;
Sampled_getWindowSamples (my d_formant, tmin, tmax, & i1, & i2);
for (i = i1; i <= i2; i ++) {
- double t = my d_formant -> f_indexToX (i);
+ double t = Sampled_indexToX (my d_formant, i);
double f1 = Formant_getValueAtTime (my d_formant, 1, t, 0);
double f2 = Formant_getValueAtTime (my d_formant, 2, t, 0);
double f3 = Formant_getValueAtTime (my d_formant, 3, t, 0);
@@ -1732,272 +1732,275 @@ void TimeSoundAnalysisEditor_computePulses (TimeSoundAnalysisEditor me) {
}
}
-void structTimeSoundAnalysisEditor :: v_draw_analysis () {
+static void TimeSoundAnalysisEditor_v_draw_analysis (TimeSoundAnalysisEditor me) {
/*
* d_pitch may not exist yet (if shown at all, it may be going to be created in TimeSoundAnalysisEditor_computePitch (),
* and even if if that fails we should see the pitch settings. So we use a dummy object.
*/
- double pitchFloor_hidden = Function_convertStandardToSpecialUnit (Thing_dummyObject (Pitch), p_pitch_floor, Pitch_LEVEL_FREQUENCY, p_pitch_unit);
- double pitchCeiling_hidden = Function_convertStandardToSpecialUnit (Thing_dummyObject (Pitch), p_pitch_ceiling, Pitch_LEVEL_FREQUENCY, p_pitch_unit);
- double pitchFloor_overt = Function_convertToNonlogarithmic (Thing_dummyObject (Pitch), pitchFloor_hidden, Pitch_LEVEL_FREQUENCY, p_pitch_unit);
- double pitchCeiling_overt = Function_convertToNonlogarithmic (Thing_dummyObject (Pitch), pitchCeiling_hidden, Pitch_LEVEL_FREQUENCY, p_pitch_unit);
- double pitchViewFrom_overt = p_pitch_viewFrom < p_pitch_viewTo ? p_pitch_viewFrom : pitchFloor_overt;
- double pitchViewTo_overt = p_pitch_viewFrom < p_pitch_viewTo ? p_pitch_viewTo : pitchCeiling_overt;
- double pitchViewFrom_hidden = Function_isUnitLogarithmic (Thing_dummyObject (Pitch), Pitch_LEVEL_FREQUENCY, p_pitch_unit) ? log10 (pitchViewFrom_overt) : pitchViewFrom_overt;
- double pitchViewTo_hidden = Function_isUnitLogarithmic (Thing_dummyObject (Pitch), Pitch_LEVEL_FREQUENCY, p_pitch_unit) ? log10 (pitchViewTo_overt) : pitchViewTo_overt;
-
- Graphics_setWindow (d_graphics, 0.0, 1.0, 0.0, 1.0);
- Graphics_setColour (d_graphics, Graphics_WHITE);
- Graphics_fillRectangle (d_graphics, 0.0, 1.0, 0.0, 1.0);
- Graphics_setColour (d_graphics, Graphics_BLACK);
- Graphics_rectangle (d_graphics, 0.0, 1.0, 0.0, 1.0);
-
- if (d_endWindow - d_startWindow > p_longestAnalysis) {
- Graphics_setFont (d_graphics, kGraphics_font_HELVETICA);
- Graphics_setFontSize (d_graphics, 10);
- Graphics_setTextAlignment (d_graphics, Graphics_CENTRE, Graphics_HALF);
- Graphics_text3 (d_graphics, 0.5, 0.67, L"(To see the analyses, zoom in to at most ", Melder_half (p_longestAnalysis), L" seconds,");
- Graphics_text (d_graphics, 0.5, 0.33, L"or raise the \"longest analysis\" setting with \"Show analyses\" in the View menu.)");
- Graphics_setFontSize (d_graphics, 12);
+ double pitchFloor_hidden = Function_convertStandardToSpecialUnit (Thing_dummyObject (Pitch), my p_pitch_floor, Pitch_LEVEL_FREQUENCY, my p_pitch_unit);
+ double pitchCeiling_hidden = Function_convertStandardToSpecialUnit (Thing_dummyObject (Pitch), my p_pitch_ceiling, Pitch_LEVEL_FREQUENCY, my p_pitch_unit);
+ double pitchFloor_overt = Function_convertToNonlogarithmic (Thing_dummyObject (Pitch), pitchFloor_hidden, Pitch_LEVEL_FREQUENCY, my p_pitch_unit);
+ double pitchCeiling_overt = Function_convertToNonlogarithmic (Thing_dummyObject (Pitch), pitchCeiling_hidden, Pitch_LEVEL_FREQUENCY, my p_pitch_unit);
+ double pitchViewFrom_overt = my p_pitch_viewFrom < my p_pitch_viewTo ? my p_pitch_viewFrom : pitchFloor_overt;
+ double pitchViewTo_overt = my p_pitch_viewFrom < my p_pitch_viewTo ? my p_pitch_viewTo : pitchCeiling_overt;
+ double pitchViewFrom_hidden = Function_isUnitLogarithmic (Thing_dummyObject (Pitch), Pitch_LEVEL_FREQUENCY, my p_pitch_unit) ? log10 (pitchViewFrom_overt) : pitchViewFrom_overt;
+ double pitchViewTo_hidden = Function_isUnitLogarithmic (Thing_dummyObject (Pitch), Pitch_LEVEL_FREQUENCY, my p_pitch_unit) ? log10 (pitchViewTo_overt) : pitchViewTo_overt;
+
+ Graphics_setWindow (my d_graphics, 0.0, 1.0, 0.0, 1.0);
+ Graphics_setColour (my d_graphics, Graphics_WHITE);
+ Graphics_fillRectangle (my d_graphics, 0.0, 1.0, 0.0, 1.0);
+ Graphics_setColour (my d_graphics, Graphics_BLACK);
+ Graphics_rectangle (my d_graphics, 0.0, 1.0, 0.0, 1.0);
+
+ if (my d_endWindow - my d_startWindow > my p_longestAnalysis) {
+ Graphics_setFont (my d_graphics, kGraphics_font_HELVETICA);
+ Graphics_setFontSize (my d_graphics, 10);
+ Graphics_setTextAlignment (my d_graphics, Graphics_CENTRE, Graphics_HALF);
+ Graphics_text3 (my d_graphics, 0.5, 0.67, L"(To see the analyses, zoom in to at most ", Melder_half (my p_longestAnalysis), L" seconds,");
+ Graphics_text (my d_graphics, 0.5, 0.33, L"or raise the \"longest analysis\" setting with \"Show analyses\" in the View menu.)");
+ Graphics_setFontSize (my d_graphics, 12);
return;
}
- TimeSoundAnalysisEditor_computeSpectrogram (this);
- if (p_spectrogram_show && d_spectrogram != NULL) {
- Spectrogram_paintInside (d_spectrogram, d_graphics, d_startWindow, d_endWindow,
- p_spectrogram_viewFrom, p_spectrogram_viewTo, p_spectrogram_maximum, p_spectrogram_autoscaling,
- p_spectrogram_dynamicRange, p_spectrogram_preemphasis, p_spectrogram_dynamicCompression);
+ TimeSoundAnalysisEditor_computeSpectrogram (me);
+ if (my p_spectrogram_show && my d_spectrogram != NULL) {
+ Spectrogram_paintInside (my d_spectrogram, my d_graphics, my d_startWindow, my d_endWindow,
+ my p_spectrogram_viewFrom, my p_spectrogram_viewTo, my p_spectrogram_maximum, my p_spectrogram_autoscaling,
+ my p_spectrogram_dynamicRange, my p_spectrogram_preemphasis, my p_spectrogram_dynamicCompression);
}
- TimeSoundAnalysisEditor_computePitch (this);
- if (p_pitch_show && d_pitch != NULL) {
- double periodsPerAnalysisWindow = p_pitch_method == kTimeSoundAnalysisEditor_pitch_analysisMethod_AUTOCORRELATION ? 3.0 : 1.0;
- double greatestNonUndersamplingTimeStep = 0.5 * periodsPerAnalysisWindow / p_pitch_floor;
+ TimeSoundAnalysisEditor_computePitch (me);
+ if (my p_pitch_show && my d_pitch != NULL) {
+ double periodsPerAnalysisWindow = my p_pitch_method == kTimeSoundAnalysisEditor_pitch_analysisMethod_AUTOCORRELATION ? 3.0 : 1.0;
+ double greatestNonUndersamplingTimeStep = 0.5 * periodsPerAnalysisWindow / my p_pitch_floor;
double defaultTimeStep = 0.5 * greatestNonUndersamplingTimeStep;
double timeStep =
- p_timeStepStrategy == kTimeSoundAnalysisEditor_timeStepStrategy_FIXED ? p_fixedTimeStep :
- p_timeStepStrategy == kTimeSoundAnalysisEditor_timeStepStrategy_VIEW_DEPENDENT ? (d_endWindow - d_startWindow) / p_numberOfTimeStepsPerView :
+ my p_timeStepStrategy == kTimeSoundAnalysisEditor_timeStepStrategy_FIXED ? my p_fixedTimeStep :
+ my p_timeStepStrategy == kTimeSoundAnalysisEditor_timeStepStrategy_VIEW_DEPENDENT ? (my d_endWindow - my d_startWindow) / my p_numberOfTimeStepsPerView :
defaultTimeStep;
int undersampled = timeStep > greatestNonUndersamplingTimeStep;
- long numberOfVisiblePitchPoints = (long) ((d_endWindow - d_startWindow) / timeStep);
- Graphics_setColour (d_graphics, Graphics_CYAN);
- Graphics_setLineWidth (d_graphics, 3.0);
- if ((p_pitch_drawingMethod == kTimeSoundAnalysisEditor_pitch_drawingMethod_AUTOMATIC && (undersampled || numberOfVisiblePitchPoints < 101)) ||
- p_pitch_drawingMethod == kTimeSoundAnalysisEditor_pitch_drawingMethod_SPECKLE)
+ long numberOfVisiblePitchPoints = (long) ((my d_endWindow - my d_startWindow) / timeStep);
+ Graphics_setColour (my d_graphics, Graphics_CYAN);
+ Graphics_setLineWidth (my d_graphics, 3.0);
+ if ((my p_pitch_drawingMethod == kTimeSoundAnalysisEditor_pitch_drawingMethod_AUTOMATIC && (undersampled || numberOfVisiblePitchPoints < 101)) ||
+ my p_pitch_drawingMethod == kTimeSoundAnalysisEditor_pitch_drawingMethod_SPECKLE)
{
- Pitch_drawInside (d_pitch, d_graphics, d_startWindow, d_endWindow, pitchViewFrom_overt, pitchViewTo_overt, 2, p_pitch_unit);
+ Pitch_drawInside (my d_pitch, my d_graphics, my d_startWindow, my d_endWindow, pitchViewFrom_overt, pitchViewTo_overt, 2, my p_pitch_unit);
}
- if ((p_pitch_drawingMethod == kTimeSoundAnalysisEditor_pitch_drawingMethod_AUTOMATIC && ! undersampled) ||
- p_pitch_drawingMethod == kTimeSoundAnalysisEditor_pitch_drawingMethod_CURVE)
+ if ((my p_pitch_drawingMethod == kTimeSoundAnalysisEditor_pitch_drawingMethod_AUTOMATIC && ! undersampled) ||
+ my p_pitch_drawingMethod == kTimeSoundAnalysisEditor_pitch_drawingMethod_CURVE)
{
- Pitch_drawInside (d_pitch, d_graphics, d_startWindow, d_endWindow, pitchViewFrom_overt, pitchViewTo_overt, FALSE, p_pitch_unit);
+ Pitch_drawInside (my d_pitch, my d_graphics, my d_startWindow, my d_endWindow, pitchViewFrom_overt, pitchViewTo_overt, FALSE, my p_pitch_unit);
}
- Graphics_setColour (d_graphics, Graphics_BLUE);
- Graphics_setLineWidth (d_graphics, 1.0);
- if ((p_pitch_drawingMethod == kTimeSoundAnalysisEditor_pitch_drawingMethod_AUTOMATIC && (undersampled || numberOfVisiblePitchPoints < 101)) ||
- p_pitch_drawingMethod == kTimeSoundAnalysisEditor_pitch_drawingMethod_SPECKLE)
+ Graphics_setColour (my d_graphics, Graphics_BLUE);
+ Graphics_setLineWidth (my d_graphics, 1.0);
+ if ((my p_pitch_drawingMethod == kTimeSoundAnalysisEditor_pitch_drawingMethod_AUTOMATIC && (undersampled || numberOfVisiblePitchPoints < 101)) ||
+ my p_pitch_drawingMethod == kTimeSoundAnalysisEditor_pitch_drawingMethod_SPECKLE)
{
- Pitch_drawInside (d_pitch, d_graphics, d_startWindow, d_endWindow, pitchViewFrom_overt, pitchViewTo_overt, 1, p_pitch_unit);
+ Pitch_drawInside (my d_pitch, my d_graphics, my d_startWindow, my d_endWindow, pitchViewFrom_overt, pitchViewTo_overt, 1, my p_pitch_unit);
}
- if ((p_pitch_drawingMethod == kTimeSoundAnalysisEditor_pitch_drawingMethod_AUTOMATIC && ! undersampled) ||
- p_pitch_drawingMethod == kTimeSoundAnalysisEditor_pitch_drawingMethod_CURVE)
+ if ((my p_pitch_drawingMethod == kTimeSoundAnalysisEditor_pitch_drawingMethod_AUTOMATIC && ! undersampled) ||
+ my p_pitch_drawingMethod == kTimeSoundAnalysisEditor_pitch_drawingMethod_CURVE)
{
- Pitch_drawInside (d_pitch, d_graphics, d_startWindow, d_endWindow, pitchViewFrom_overt, pitchViewTo_overt, FALSE, p_pitch_unit);
+ Pitch_drawInside (my d_pitch, my d_graphics, my d_startWindow, my d_endWindow, pitchViewFrom_overt, pitchViewTo_overt, FALSE, my p_pitch_unit);
}
- Graphics_setColour (d_graphics, Graphics_BLACK);
- }
- TimeSoundAnalysisEditor_computeIntensity (this);
- if (p_intensity_show && d_intensity != NULL) {
- Graphics_setColour (d_graphics, p_spectrogram_show ? Graphics_YELLOW : Graphics_LIME);
- Graphics_setLineWidth (d_graphics, p_spectrogram_show ? 1.0 : 3.0);
- Intensity_drawInside (d_intensity, d_graphics, d_startWindow, d_endWindow,
- p_intensity_viewFrom, p_intensity_viewTo);
- Graphics_setLineWidth (d_graphics, 1.0);
- Graphics_setColour (d_graphics, Graphics_BLACK);
- }
- TimeSoundAnalysisEditor_computeFormants (this);
- if (p_formant_show && d_formant != NULL) {
- Graphics_setColour (d_graphics, Graphics_RED);
- Graphics_setSpeckleSize (d_graphics, p_formant_dotSize);
- Formant_drawSpeckles_inside (d_formant, d_graphics, d_startWindow, d_endWindow,
- p_spectrogram_viewFrom, p_spectrogram_viewTo, p_formant_dynamicRange);
- Graphics_setColour (d_graphics, Graphics_BLACK);
+ Graphics_setColour (my d_graphics, Graphics_BLACK);
+ }
+ TimeSoundAnalysisEditor_computeIntensity (me);
+ if (my p_intensity_show && my d_intensity != NULL) {
+ Graphics_setColour (my d_graphics, my p_spectrogram_show ? Graphics_YELLOW : Graphics_LIME);
+ Graphics_setLineWidth (my d_graphics, my p_spectrogram_show ? 1.0 : 3.0);
+ Intensity_drawInside (my d_intensity, my d_graphics, my d_startWindow, my d_endWindow,
+ my p_intensity_viewFrom, my p_intensity_viewTo);
+ Graphics_setLineWidth (my d_graphics, 1.0);
+ Graphics_setColour (my d_graphics, Graphics_BLACK);
+ }
+ TimeSoundAnalysisEditor_computeFormants (me);
+ if (my p_formant_show && my d_formant != NULL) {
+ Graphics_setColour (my d_graphics, Graphics_RED);
+ Graphics_setSpeckleSize (my d_graphics, my p_formant_dotSize);
+ Formant_drawSpeckles_inside (my d_formant, my d_graphics, my d_startWindow, my d_endWindow,
+ my p_spectrogram_viewFrom, my p_spectrogram_viewTo, my p_formant_dynamicRange);
+ Graphics_setColour (my d_graphics, Graphics_BLACK);
}
/*
* Draw vertical scales.
*/
- if (p_pitch_show) {
+ if (my p_pitch_show) {
double pitchCursor_overt = NUMundefined, pitchCursor_hidden = NUMundefined;
- Graphics_setWindow (d_graphics, d_startWindow, d_endWindow, pitchViewFrom_hidden, pitchViewTo_hidden);
- Graphics_setColour (d_graphics, Graphics_BLUE);
- if (d_pitch) {
- if (d_startSelection == d_endSelection)
- pitchCursor_hidden = Pitch_getValueAtTime (d_pitch, d_startSelection, p_pitch_unit, 1);
+ Graphics_setWindow (my d_graphics, my d_startWindow, my d_endWindow, pitchViewFrom_hidden, pitchViewTo_hidden);
+ Graphics_setColour (my d_graphics, Graphics_BLUE);
+ if (my d_pitch) {
+ if (my d_startSelection == my d_endSelection)
+ pitchCursor_hidden = Pitch_getValueAtTime (my d_pitch, my d_startSelection, my p_pitch_unit, 1);
else
- pitchCursor_hidden = Pitch_getMean (d_pitch, d_startSelection, d_endSelection, p_pitch_unit);
- pitchCursor_overt = Function_convertToNonlogarithmic (d_pitch, pitchCursor_hidden, Pitch_LEVEL_FREQUENCY, p_pitch_unit);
+ pitchCursor_hidden = Pitch_getMean (my d_pitch, my d_startSelection, my d_endSelection, my p_pitch_unit);
+ pitchCursor_overt = Function_convertToNonlogarithmic (my d_pitch, pitchCursor_hidden, Pitch_LEVEL_FREQUENCY, my p_pitch_unit);
if (NUMdefined (pitchCursor_hidden)) {
- Graphics_setTextAlignment (d_graphics, Graphics_LEFT, Graphics_HALF);
- Graphics_text3 (d_graphics, d_endWindow, pitchCursor_hidden, Melder_float (Melder_half (pitchCursor_overt)), L" ",
- Function_getUnitText (d_pitch, Pitch_LEVEL_FREQUENCY, p_pitch_unit, Function_UNIT_TEXT_SHORT | Function_UNIT_TEXT_GRAPHICAL));
+ Graphics_setTextAlignment (my d_graphics, Graphics_LEFT, Graphics_HALF);
+ Graphics_text3 (my d_graphics, my d_endWindow, pitchCursor_hidden, Melder_float (Melder_half (pitchCursor_overt)), L" ",
+ Function_getUnitText (my d_pitch, Pitch_LEVEL_FREQUENCY, my p_pitch_unit, Function_UNIT_TEXT_SHORT | Function_UNIT_TEXT_GRAPHICAL));
}
- if (! NUMdefined (pitchCursor_hidden) || Graphics_dyWCtoMM (d_graphics, pitchCursor_hidden - pitchViewFrom_hidden) > 5.0) {
- Graphics_setTextAlignment (d_graphics, Graphics_LEFT, Graphics_BOTTOM);
- Graphics_text3 (d_graphics, d_endWindow, pitchViewFrom_hidden - Graphics_dyMMtoWC (d_graphics, 0.5),
+ if (! NUMdefined (pitchCursor_hidden) || Graphics_dyWCtoMM (my d_graphics, pitchCursor_hidden - pitchViewFrom_hidden) > 5.0) {
+ Graphics_setTextAlignment (my d_graphics, Graphics_LEFT, Graphics_BOTTOM);
+ Graphics_text3 (my d_graphics, my d_endWindow, pitchViewFrom_hidden - Graphics_dyMMtoWC (my d_graphics, 0.5),
Melder_float (Melder_half (pitchViewFrom_overt)), L" ",
- Function_getUnitText (d_pitch, Pitch_LEVEL_FREQUENCY, p_pitch_unit, Function_UNIT_TEXT_SHORT | Function_UNIT_TEXT_GRAPHICAL));
+ Function_getUnitText (my d_pitch, Pitch_LEVEL_FREQUENCY, my p_pitch_unit, Function_UNIT_TEXT_SHORT | Function_UNIT_TEXT_GRAPHICAL));
}
- if (! NUMdefined (pitchCursor_hidden) || Graphics_dyWCtoMM (d_graphics, pitchViewTo_hidden - pitchCursor_hidden) > 5.0) {
- Graphics_setTextAlignment (d_graphics, Graphics_LEFT, Graphics_TOP);
- Graphics_text3 (d_graphics, d_endWindow, pitchViewTo_hidden, Melder_float (Melder_half (pitchViewTo_overt)), L" ",
- Function_getUnitText (d_pitch, Pitch_LEVEL_FREQUENCY, p_pitch_unit, Function_UNIT_TEXT_SHORT | Function_UNIT_TEXT_GRAPHICAL));
+ if (! NUMdefined (pitchCursor_hidden) || Graphics_dyWCtoMM (my d_graphics, pitchViewTo_hidden - pitchCursor_hidden) > 5.0) {
+ Graphics_setTextAlignment (my d_graphics, Graphics_LEFT, Graphics_TOP);
+ Graphics_text3 (my d_graphics, my d_endWindow, pitchViewTo_hidden, Melder_float (Melder_half (pitchViewTo_overt)), L" ",
+ Function_getUnitText (my d_pitch, Pitch_LEVEL_FREQUENCY, my p_pitch_unit, Function_UNIT_TEXT_SHORT | Function_UNIT_TEXT_GRAPHICAL));
}
} else {
- Graphics_setTextAlignment (d_graphics, Graphics_CENTRE, Graphics_HALF);
- Graphics_setFontSize (d_graphics, 10);
- Graphics_text (d_graphics, 0.5 * (d_startWindow + d_endWindow), 0.5 * (pitchViewFrom_hidden + pitchViewTo_hidden),
+ Graphics_setTextAlignment (my d_graphics, Graphics_CENTRE, Graphics_HALF);
+ Graphics_setFontSize (my d_graphics, 10);
+ Graphics_text (my d_graphics, 0.5 * (my d_startWindow + my d_endWindow), 0.5 * (pitchViewFrom_hidden + pitchViewTo_hidden),
L"(Cannot show pitch contour. Zoom out or change bottom of pitch range in pitch settings.)");
- Graphics_setFontSize (d_graphics, 12);
+ Graphics_setFontSize (my d_graphics, 12);
}
- Graphics_setColour (d_graphics, Graphics_BLACK);
+ Graphics_setColour (my d_graphics, Graphics_BLACK);
}
- if (p_intensity_show) {
+ if (my p_intensity_show) {
double intensityCursor = NUMundefined;
int intensityCursorVisible;
Graphics_Colour textColour;
int alignment;
double y;
- if (! p_pitch_show) textColour = Graphics_GREEN, alignment = Graphics_LEFT, y = d_endWindow;
- else if (! p_spectrogram_show && ! p_formant_show) textColour = Graphics_GREEN, alignment = Graphics_RIGHT, y = d_startWindow;
- else textColour = p_spectrogram_show ? Graphics_LIME : Graphics_GREEN, alignment = Graphics_RIGHT, y = d_endWindow;
- Graphics_setWindow (d_graphics, d_startWindow, d_endWindow, p_intensity_viewFrom, p_intensity_viewTo);
- if (d_intensity) {
- if (d_startSelection == d_endSelection) {
- intensityCursor = Vector_getValueAtX (d_intensity, d_startSelection, Vector_CHANNEL_1, Vector_VALUE_INTERPOLATION_LINEAR);
+ if (! my p_pitch_show) textColour = Graphics_GREEN, alignment = Graphics_LEFT, y = my d_endWindow;
+ else if (! my p_spectrogram_show && ! my p_formant_show) textColour = Graphics_GREEN, alignment = Graphics_RIGHT, y = my d_startWindow;
+ else textColour = my p_spectrogram_show ? Graphics_LIME : Graphics_GREEN, alignment = Graphics_RIGHT, y = my d_endWindow;
+ Graphics_setWindow (my d_graphics, my d_startWindow, my d_endWindow, my p_intensity_viewFrom, my p_intensity_viewTo);
+ if (my d_intensity) {
+ if (my d_startSelection == my d_endSelection) {
+ intensityCursor = Vector_getValueAtX (my d_intensity, my d_startSelection, Vector_CHANNEL_1, Vector_VALUE_INTERPOLATION_LINEAR);
} else {
- intensityCursor = Intensity_getAverage (d_intensity, d_startSelection, d_endSelection, p_intensity_averagingMethod);
+ intensityCursor = Intensity_getAverage (my d_intensity, my d_startSelection, my d_endSelection, my p_intensity_averagingMethod);
}
}
- Graphics_setColour (d_graphics, textColour);
- intensityCursorVisible = NUMdefined (intensityCursor) && intensityCursor > p_intensity_viewFrom && intensityCursor < p_intensity_viewTo;
+ Graphics_setColour (my d_graphics, textColour);
+ intensityCursorVisible = NUMdefined (intensityCursor) && intensityCursor > my p_intensity_viewFrom && intensityCursor < my p_intensity_viewTo;
if (intensityCursorVisible) {
static const wchar_t *methodString [] = { L" (.5)", L" (\\muE)", L" (\\muS)", L" (\\mu)" };
- Graphics_setTextAlignment (d_graphics, alignment, Graphics_HALF);
- Graphics_text3 (d_graphics, y, intensityCursor, Melder_float (Melder_half (intensityCursor)), L" dB",
- d_startSelection == d_endSelection ? L"" : methodString [p_intensity_averagingMethod]);
+ Graphics_setTextAlignment (my d_graphics, alignment, Graphics_HALF);
+ Graphics_text3 (my d_graphics, y, intensityCursor, Melder_float (Melder_half (intensityCursor)), L" dB",
+ my d_startSelection == my d_endSelection ? L"" : methodString [my p_intensity_averagingMethod]);
}
- if (! intensityCursorVisible || Graphics_dyWCtoMM (d_graphics, intensityCursor - p_intensity_viewFrom) > 5.0) {
- Graphics_setTextAlignment (d_graphics, alignment, Graphics_BOTTOM);
- Graphics_text2 (d_graphics, y, p_intensity_viewFrom - Graphics_dyMMtoWC (d_graphics, 0.5),
- Melder_float (Melder_half (p_intensity_viewFrom)), L" dB");
+ if (! intensityCursorVisible || Graphics_dyWCtoMM (my d_graphics, intensityCursor - my p_intensity_viewFrom) > 5.0) {
+ Graphics_setTextAlignment (my d_graphics, alignment, Graphics_BOTTOM);
+ Graphics_text2 (my d_graphics, y, my p_intensity_viewFrom - Graphics_dyMMtoWC (my d_graphics, 0.5),
+ Melder_float (Melder_half (my p_intensity_viewFrom)), L" dB");
}
- if (! intensityCursorVisible || Graphics_dyWCtoMM (d_graphics, p_intensity_viewTo - intensityCursor) > 5.0) {
- Graphics_setTextAlignment (d_graphics, alignment, Graphics_TOP);
- Graphics_text2 (d_graphics, y, p_intensity_viewTo, Melder_float (Melder_half (p_intensity_viewTo)), L" dB");
+ if (! intensityCursorVisible || Graphics_dyWCtoMM (my d_graphics, my p_intensity_viewTo - intensityCursor) > 5.0) {
+ Graphics_setTextAlignment (my d_graphics, alignment, Graphics_TOP);
+ Graphics_text2 (my d_graphics, y, my p_intensity_viewTo, Melder_float (Melder_half (my p_intensity_viewTo)), L" dB");
}
- Graphics_setColour (d_graphics, Graphics_BLACK);
+ Graphics_setColour (my d_graphics, Graphics_BLACK);
}
- if (p_spectrogram_show || p_formant_show) {
+ if (my p_spectrogram_show || my p_formant_show) {
static MelderString text = { 0 };
- int frequencyCursorVisible = d_spectrogram_cursor > p_spectrogram_viewFrom && d_spectrogram_cursor < p_spectrogram_viewTo;
- Graphics_setWindow (d_graphics, d_startWindow, d_endWindow, p_spectrogram_viewFrom, p_spectrogram_viewTo);
+ int frequencyCursorVisible = my d_spectrogram_cursor > my p_spectrogram_viewFrom && my d_spectrogram_cursor < my p_spectrogram_viewTo;
+ Graphics_setWindow (my d_graphics, my d_startWindow, my d_endWindow, my p_spectrogram_viewFrom, my p_spectrogram_viewTo);
/*
* Range marks.
*/
- Graphics_setLineType (d_graphics, Graphics_DRAWN);
- Graphics_setColour (d_graphics, Graphics_BLACK);
- if (! frequencyCursorVisible || Graphics_dyWCtoMM (d_graphics, d_spectrogram_cursor - p_spectrogram_viewFrom) > 5.0) {
+ Graphics_setLineType (my d_graphics, Graphics_DRAWN);
+ Graphics_setColour (my d_graphics, Graphics_BLACK);
+ if (! frequencyCursorVisible || Graphics_dyWCtoMM (my d_graphics, my d_spectrogram_cursor - my p_spectrogram_viewFrom) > 5.0) {
MelderString_empty (& text);
- MelderString_append (& text, Melder_half (p_spectrogram_viewFrom), L" Hz");
- Graphics_setTextAlignment (d_graphics, Graphics_RIGHT, Graphics_BOTTOM);
- Graphics_text (d_graphics, d_startWindow, p_spectrogram_viewFrom - Graphics_dyMMtoWC (d_graphics, 0.5), Melder_float (text.string));
+ MelderString_append (& text, Melder_half (my p_spectrogram_viewFrom), L" Hz");
+ Graphics_setTextAlignment (my d_graphics, Graphics_RIGHT, Graphics_BOTTOM);
+ Graphics_text (my d_graphics, my d_startWindow, my p_spectrogram_viewFrom - Graphics_dyMMtoWC (my d_graphics, 0.5), Melder_float (text.string));
}
- if (! frequencyCursorVisible || Graphics_dyWCtoMM (d_graphics, p_spectrogram_viewTo - d_spectrogram_cursor) > 5.0) {
+ if (! frequencyCursorVisible || Graphics_dyWCtoMM (my d_graphics, my p_spectrogram_viewTo - my d_spectrogram_cursor) > 5.0) {
MelderString_empty (& text);
- MelderString_append (& text, Melder_half (p_spectrogram_viewTo), L" Hz");
- Graphics_setTextAlignment (d_graphics, Graphics_RIGHT, Graphics_TOP);
- Graphics_text (d_graphics, d_startWindow, p_spectrogram_viewTo, Melder_float (text.string));
+ MelderString_append (& text, Melder_half (my p_spectrogram_viewTo), L" Hz");
+ Graphics_setTextAlignment (my d_graphics, Graphics_RIGHT, Graphics_TOP);
+ Graphics_text (my d_graphics, my d_startWindow, my p_spectrogram_viewTo, Melder_float (text.string));
}
/*
* Cursor lines.
*/
- Graphics_setLineType (d_graphics, Graphics_DOTTED);
- Graphics_setColour (d_graphics, Graphics_RED);
+ Graphics_setLineType (my d_graphics, Graphics_DOTTED);
+ Graphics_setColour (my d_graphics, Graphics_RED);
if (frequencyCursorVisible) {
- double x = d_startWindow, y = d_spectrogram_cursor;
- Graphics_setTextAlignment (d_graphics, Graphics_RIGHT, Graphics_HALF);
- Graphics_text2 (d_graphics, x, y, Melder_float (Melder_half (y)), L" Hz");
- Graphics_line (d_graphics, x, y, d_endWindow, y);
+ double x = my d_startWindow, y = my d_spectrogram_cursor;
+ Graphics_setTextAlignment (my d_graphics, Graphics_RIGHT, Graphics_HALF);
+ Graphics_text2 (my d_graphics, x, y, Melder_float (Melder_half (y)), L" Hz");
+ Graphics_line (my d_graphics, x, y, my d_endWindow, y);
}
/*
- if (startSelection >= startWindow && startSelection <= endWindow)
- Graphics_line (graphics, startSelection, p_spectrogram_viewFrom, startSelection, p_spectrogram_viewTo);
- if (endSelection > startWindow && endSelection < endWindow && endSelection != startSelection)
- Graphics_line (graphics, endSelection, p_spectrogram_viewFrom, endSelection, p_spectrogram_viewTo);*/
+ if (our startSelection >= our startWindow && our startSelection <= our endWindow)
+ Graphics_line (our graphics, our startSelection, our p_spectrogram_viewFrom, our startSelection, our p_spectrogram_viewTo);
+ if (our endSelection > our startWindow && our endSelection < our endWindow && our endSelection != our startSelection)
+ Graphics_line (our graphics, our endSelection, our p_spectrogram_viewFrom, our endSelection, our p_spectrogram_viewTo);*/
/*
* Cadre.
*/
- Graphics_setLineType (d_graphics, Graphics_DRAWN);
- Graphics_setColour (d_graphics, Graphics_BLACK);
- Graphics_rectangle (d_graphics, d_startWindow, d_endWindow, p_spectrogram_viewFrom, p_spectrogram_viewTo);
+ Graphics_setLineType (my d_graphics, Graphics_DRAWN);
+ Graphics_setColour (my d_graphics, Graphics_BLACK);
+ Graphics_rectangle (my d_graphics, my d_startWindow, my d_endWindow, my p_spectrogram_viewFrom, my p_spectrogram_viewTo);
}
}
+void structTimeSoundAnalysisEditor :: v_draw_analysis () {
+ TimeSoundAnalysisEditor_v_draw_analysis (this);
+}
void structTimeSoundAnalysisEditor :: v_draw_analysis_pulses () {
TimeSoundAnalysisEditor_computePulses (this);
- if (p_pulses_show && d_endWindow - d_startWindow <= p_longestAnalysis && d_pulses != NULL) {
+ if (our p_pulses_show && our d_endWindow - our d_startWindow <= our p_longestAnalysis && our d_pulses != NULL) {
PointProcess point = d_pulses;
- Graphics_setWindow (d_graphics, d_startWindow, d_endWindow, -1.0, 1.0);
- Graphics_setColour (d_graphics, Graphics_BLUE);
+ Graphics_setWindow (our d_graphics, our d_startWindow, our d_endWindow, -1.0, 1.0);
+ Graphics_setColour (our d_graphics, Graphics_BLUE);
if (point -> nt < 2000) 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);
+ if (t >= our d_startWindow && t <= our d_endWindow)
+ Graphics_line (our d_graphics, t, -0.9, t, 0.9);
}
- Graphics_setColour (d_graphics, Graphics_BLACK);
+ Graphics_setColour (our d_graphics, Graphics_BLACK);
}
}
int structTimeSoundAnalysisEditor :: v_click (double xbegin, double ybegin, bool shiftKeyPressed) {
- if (p_pitch_show) {
+ if (our p_pitch_show) {
//Melder_warning (xbegin, L" ", ybegin);
- if (xbegin >= d_endWindow && ybegin > 0.48 && ybegin <= 0.50) {
- pref_pitch_ceiling () = p_pitch_ceiling = p_pitch_ceiling * 1.26;
- forget (d_pitch);
- forget (d_intensity);
- forget (d_pulses);
+ if (xbegin >= our d_endWindow && ybegin > 0.48 && ybegin <= 0.50) {
+ our pref_pitch_ceiling () = our p_pitch_ceiling = our p_pitch_ceiling * 1.26;
+ forget (our d_pitch);
+ forget (our d_intensity);
+ forget (our d_pulses);
return 1;
}
- if (xbegin >= d_endWindow && ybegin > 0.46 && ybegin <= 0.48) {
- pref_pitch_ceiling () = p_pitch_ceiling = p_pitch_ceiling / 1.26;
- forget (d_pitch);
- forget (d_intensity);
- forget (d_pulses);
+ if (xbegin >= our d_endWindow && ybegin > 0.46 && ybegin <= 0.48) {
+ our pref_pitch_ceiling () = our p_pitch_ceiling = our p_pitch_ceiling / 1.26;
+ forget (our d_pitch);
+ forget (our d_intensity);
+ forget (our d_pulses);
return 1;
}
}
return TimeSoundAnalysisEditor_Parent :: v_click (xbegin, ybegin, shiftKeyPressed);
}
-void structTimeSoundAnalysisEditor :: f_init (const wchar_t *title, Function data, Sampled sound, bool ownSound) {
- structTimeSoundEditor :: f_init (title, data, sound, ownSound);
- if (v_hasAnalysis ()) {
- if (p_log1_toLogFile == false && p_log1_toInfoWindow == false) {
- pref_log1_toLogFile () = p_log1_toLogFile = true;
- pref_log1_toInfoWindow () = p_log1_toInfoWindow = true;
+void TimeSoundAnalysisEditor_init (TimeSoundAnalysisEditor me, const wchar_t *title, Function data, Sampled sound, bool ownSound) {
+ TimeSoundEditor_init (me, title, data, sound, ownSound);
+ if (my v_hasAnalysis ()) {
+ if (my p_log1_toLogFile == false && my p_log1_toInfoWindow == false) {
+ my pref_log1_toLogFile () = my p_log1_toLogFile = true;
+ my pref_log1_toInfoWindow () = my p_log1_toInfoWindow = true;
}
- if (p_log2_toLogFile == false && p_log2_toInfoWindow == false) {
- pref_log2_toLogFile () = p_log2_toLogFile = true;
- pref_log2_toInfoWindow () = p_log2_toInfoWindow = true;
+ if (my p_log2_toLogFile == false && my p_log2_toInfoWindow == false) {
+ my pref_log2_toLogFile () = my p_log2_toLogFile = true;
+ my pref_log2_toInfoWindow () = my p_log2_toInfoWindow = true;
}
- if (! v_hasSpectrogram ())
- p_spectrogram_show = false;
- if (! v_hasPitch ())
- p_pitch_show = false;
- if (! v_hasIntensity ())
- p_intensity_show = false;
- if (! v_hasFormants ())
- p_formant_show = false;
- if (! v_hasPulses ())
- p_pulses_show = false;
+ if (! my v_hasSpectrogram ())
+ my p_spectrogram_show = false;
+ if (! my v_hasPitch ())
+ my p_pitch_show = false;
+ if (! my v_hasIntensity ())
+ my p_intensity_show = false;
+ if (! my v_hasFormants ())
+ my p_formant_show = false;
+ if (! my v_hasPulses ())
+ my p_pulses_show = false;
}
}
diff --git a/fon/TimeSoundAnalysisEditor.h b/fon/TimeSoundAnalysisEditor.h
index a067bd5..6135b34 100644
--- a/fon/TimeSoundAnalysisEditor.h
+++ b/fon/TimeSoundAnalysisEditor.h
@@ -2,7 +2,7 @@
#define _TimeSoundAnalysisEditor_h_
/* TimeSoundAnalysisEditor.h
*
- * Copyright (C) 1992-2011,2012,2013 Paul Boersma
+ * Copyright (C) 1992-2011,2012,2013,2014 Paul Boersma
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -64,8 +64,6 @@ Thing_define (TimeSoundAnalysisEditor, TimeSoundEditor) { public:
Formant d_formant;
PointProcess d_pulses;
GuiMenuItem spectrogramToggle, pitchToggle, intensityToggle, formantToggle, pulsesToggle;
- // functions:
- void f_init (const wchar_t *title, Function data, Sampled sound, bool ownSound);
// overridden methods:
virtual void v_destroy ();
virtual void v_info ();
@@ -97,6 +95,9 @@ Thing_define (TimeSoundAnalysisEditor, TimeSoundEditor) { public:
#include "TimeSoundAnalysisEditor_prefs.h"
};
+void TimeSoundAnalysisEditor_init (TimeSoundAnalysisEditor me,
+ const wchar_t *title, Function data, Sampled sound, bool ownSound);
+
void TimeSoundAnalysisEditor_computeSpectrogram (TimeSoundAnalysisEditor me);
void TimeSoundAnalysisEditor_computePitch (TimeSoundAnalysisEditor me);
void TimeSoundAnalysisEditor_computeIntensity (TimeSoundAnalysisEditor me);
diff --git a/fon/TimeSoundEditor.cpp b/fon/TimeSoundEditor.cpp
index 4e1cb8e..f775e9c 100644
--- a/fon/TimeSoundEditor.cpp
+++ b/fon/TimeSoundEditor.cpp
@@ -443,51 +443,51 @@ void structTimeSoundEditor :: v_updateMenuItems_file () {
writeFlacButton -> f_setSensitive (selectedSamples != 0);
}
-void structTimeSoundEditor :: f_drawSound (double globalMinimum, double globalMaximum) {
- Sound sound = d_sound.data;
- LongSound longSound = d_longSound.data;
+void TimeSoundEditor_drawSound (TimeSoundEditor me, double globalMinimum, double globalMaximum) {
+ Sound sound = my d_sound.data;
+ LongSound longSound = my d_longSound.data;
Melder_assert ((sound == NULL) != (longSound == NULL));
int nchan = sound ? sound -> ny : longSound -> numberOfChannels;
- bool cursorVisible = d_startSelection == d_endSelection and d_startSelection >= d_startWindow and d_startSelection <= d_endWindow;
- Graphics_setColour (d_graphics, Graphics_BLACK);
+ bool cursorVisible = my d_startSelection == my d_endSelection && my d_startSelection >= my d_startWindow && my d_startSelection <= my d_endWindow;
+ Graphics_setColour (my d_graphics, Graphics_BLACK);
bool fits;
try {
- fits = sound ? true : LongSound_haveWindow (longSound, d_startWindow, d_endWindow);
+ fits = sound ? true : LongSound_haveWindow (longSound, my d_startWindow, my d_endWindow);
} catch (MelderError) {
int outOfMemory = wcsstr (Melder_getError (), L"memory") != NULL;
if (Melder_debug == 9) Melder_flushError (NULL); else Melder_clearError ();
- Graphics_setWindow (d_graphics, 0, 1, 0, 1);
- Graphics_setTextAlignment (d_graphics, Graphics_CENTRE, Graphics_HALF);
- Graphics_text (d_graphics, 0.5, 0.5, outOfMemory ? L"(out of memory)" : L"(cannot read sound file)");
+ Graphics_setWindow (my d_graphics, 0, 1, 0, 1);
+ Graphics_setTextAlignment (my d_graphics, Graphics_CENTRE, Graphics_HALF);
+ Graphics_text (my d_graphics, 0.5, 0.5, outOfMemory ? L"(out of memory)" : L"(cannot read sound file)");
return;
}
if (! fits) {
- Graphics_setWindow (d_graphics, 0, 1, 0, 1);
- Graphics_setTextAlignment (d_graphics, Graphics_CENTRE, Graphics_HALF);
- Graphics_text (d_graphics, 0.5, 0.5, L"(window too large; zoom in to see the data)");
+ Graphics_setWindow (my d_graphics, 0, 1, 0, 1);
+ Graphics_setTextAlignment (my d_graphics, Graphics_CENTRE, Graphics_HALF);
+ Graphics_text (my d_graphics, 0.5, 0.5, L"(window too large; zoom in to see the data)");
return;
}
long first, last;
- if (Sampled_getWindowSamples (sound ? (Sampled) sound : (Sampled) longSound, d_startWindow, d_endWindow, & first, & last) <= 1) {
- Graphics_setWindow (d_graphics, 0, 1, 0, 1);
- Graphics_setTextAlignment (d_graphics, Graphics_CENTRE, Graphics_HALF);
- Graphics_text (d_graphics, 0.5, 0.5, L"(zoom out to see the data)");
+ if (Sampled_getWindowSamples (sound ? (Sampled) sound : (Sampled) longSound, my d_startWindow, my d_endWindow, & first, & last) <= 1) {
+ Graphics_setWindow (my d_graphics, 0, 1, 0, 1);
+ Graphics_setTextAlignment (my d_graphics, Graphics_CENTRE, Graphics_HALF);
+ Graphics_text (my d_graphics, 0.5, 0.5, L"(zoom out to see the data)");
return;
}
const int numberOfVisibleChannels = nchan > 8 ? 8 : nchan;
- const int firstVisibleChannel = d_sound.channelOffset + 1;
- int lastVisibleChannel = d_sound.channelOffset + numberOfVisibleChannels;
+ const int firstVisibleChannel = my d_sound.channelOffset + 1;
+ int lastVisibleChannel = my d_sound.channelOffset + numberOfVisibleChannels;
if (lastVisibleChannel > nchan) lastVisibleChannel = nchan;
double maximumExtent = 0.0, visibleMinimum = 0.0, visibleMaximum = 0.0;
- if (p_sound_scalingStrategy == kTimeSoundEditor_scalingStrategy_BY_WINDOW) {
+ if (my p_sound_scalingStrategy == kTimeSoundEditor_scalingStrategy_BY_WINDOW) {
if (longSound)
- LongSound_getWindowExtrema (longSound, d_startWindow, d_endWindow, firstVisibleChannel, & visibleMinimum, & visibleMaximum);
+ LongSound_getWindowExtrema (longSound, my d_startWindow, my d_endWindow, firstVisibleChannel, & visibleMinimum, & visibleMaximum);
else
Matrix_getWindowExtrema (sound, first, last, firstVisibleChannel, firstVisibleChannel, & visibleMinimum, & visibleMaximum);
for (int ichan = firstVisibleChannel + 1; ichan <= lastVisibleChannel; ichan ++) {
double visibleChannelMinimum, visibleChannelMaximum;
if (longSound)
- LongSound_getWindowExtrema (longSound, d_startWindow, d_endWindow, ichan, & visibleChannelMinimum, & visibleChannelMaximum);
+ LongSound_getWindowExtrema (longSound, my d_startWindow, my d_endWindow, ichan, & visibleChannelMinimum, & visibleChannelMaximum);
else
Matrix_getWindowExtrema (sound, first, last, ichan, ichan, & visibleChannelMinimum, & visibleChannelMaximum);
if (visibleChannelMinimum < visibleMinimum)
@@ -499,19 +499,19 @@ void structTimeSoundEditor :: f_drawSound (double globalMinimum, double globalMa
}
for (int ichan = firstVisibleChannel; ichan <= lastVisibleChannel; ichan ++) {
double cursorFunctionValue = longSound ? 0.0 :
- Vector_getValueAtX (sound, 0.5 * (d_startSelection + d_endSelection), ichan, 70);
+ Vector_getValueAtX (sound, 0.5 * (my d_startSelection + my d_endSelection), ichan, 70);
/*
* BUG: this will only work for mono or stereo, until Graphics_function16 handles quadro.
*/
- double ymin = (double) (numberOfVisibleChannels - ichan + d_sound.channelOffset) / numberOfVisibleChannels;
- double ymax = (double) (numberOfVisibleChannels + 1 - ichan + d_sound.channelOffset) / numberOfVisibleChannels;
- Graphics_Viewport vp = Graphics_insetViewport (d_graphics, 0, 1, ymin, ymax);
+ double ymin = (double) (numberOfVisibleChannels - ichan + my d_sound.channelOffset) / numberOfVisibleChannels;
+ double ymax = (double) (numberOfVisibleChannels + 1 - ichan + my d_sound.channelOffset) / numberOfVisibleChannels;
+ Graphics_Viewport vp = Graphics_insetViewport (my d_graphics, 0, 1, ymin, ymax);
bool horizontal = false;
double minimum = sound ? globalMinimum : -1.0, maximum = sound ? globalMaximum : 1.0;
- if (p_sound_scalingStrategy == kTimeSoundEditor_scalingStrategy_BY_WINDOW) {
+ if (my p_sound_scalingStrategy == kTimeSoundEditor_scalingStrategy_BY_WINDOW) {
if (nchan > 2) {
if (longSound) {
- LongSound_getWindowExtrema (longSound, d_startWindow, d_endWindow, ichan, & minimum, & maximum);
+ LongSound_getWindowExtrema (longSound, my d_startWindow, my d_endWindow, ichan, & minimum, & maximum);
} else {
Matrix_getWindowExtrema (sound, first, last, ichan, ichan, & minimum, & maximum);
}
@@ -524,103 +524,103 @@ void structTimeSoundEditor :: f_drawSound (double globalMinimum, double globalMa
minimum = visibleMinimum;
maximum = visibleMaximum;
}
- } else if (p_sound_scalingStrategy == kTimeSoundEditor_scalingStrategy_BY_WINDOW_AND_CHANNEL) {
+ } else if (my p_sound_scalingStrategy == kTimeSoundEditor_scalingStrategy_BY_WINDOW_AND_CHANNEL) {
if (longSound) {
- LongSound_getWindowExtrema (longSound, d_startWindow, d_endWindow, ichan, & minimum, & maximum);
+ LongSound_getWindowExtrema (longSound, my d_startWindow, my d_endWindow, ichan, & minimum, & maximum);
} else {
Matrix_getWindowExtrema (sound, first, last, ichan, ichan, & minimum, & maximum);
}
- } else if (p_sound_scalingStrategy == kTimeSoundEditor_scalingStrategy_FIXED_HEIGHT) {
+ } else if (my p_sound_scalingStrategy == kTimeSoundEditor_scalingStrategy_FIXED_HEIGHT) {
if (longSound) {
- LongSound_getWindowExtrema (longSound, d_startWindow, d_endWindow, ichan, & minimum, & maximum);
+ LongSound_getWindowExtrema (longSound, my d_startWindow, my d_endWindow, ichan, & minimum, & maximum);
} else {
Matrix_getWindowExtrema (sound, first, last, ichan, ichan, & minimum, & maximum);
}
- double channelExtent = p_sound_scaling_height;
+ double channelExtent = my p_sound_scaling_height;
double middle = 0.5 * (minimum + maximum);
minimum = middle - 0.5 * channelExtent;
maximum = middle + 0.5 * channelExtent;
- } else if (p_sound_scalingStrategy == kTimeSoundEditor_scalingStrategy_FIXED_RANGE) {
- minimum = p_sound_scaling_minimum;
- maximum = p_sound_scaling_maximum;
+ } else if (my p_sound_scalingStrategy == kTimeSoundEditor_scalingStrategy_FIXED_RANGE) {
+ minimum = my p_sound_scaling_minimum;
+ maximum = my p_sound_scaling_maximum;
}
if (minimum == maximum) { horizontal = true; minimum -= 1; maximum += 1;}
- Graphics_setWindow (d_graphics, d_startWindow, d_endWindow, minimum, maximum);
+ Graphics_setWindow (my d_graphics, my d_startWindow, my d_endWindow, minimum, maximum);
if (horizontal) {
- Graphics_setTextAlignment (d_graphics, Graphics_RIGHT, Graphics_HALF);
+ Graphics_setTextAlignment (my d_graphics, Graphics_RIGHT, Graphics_HALF);
double mid = 0.5 * (minimum + maximum);
- Graphics_text1 (d_graphics, d_startWindow, mid, Melder_float (Melder_half (mid)));
+ Graphics_text1 (my d_graphics, my d_startWindow, mid, Melder_float (Melder_half (mid)));
} else {
- if (not cursorVisible or ! NUMdefined (cursorFunctionValue) or Graphics_dyWCtoMM (d_graphics, cursorFunctionValue - minimum) > 5.0) {
- Graphics_setTextAlignment (d_graphics, Graphics_RIGHT, Graphics_BOTTOM);
- Graphics_text1 (d_graphics, d_startWindow, minimum, Melder_float (Melder_half (minimum)));
+ if (! cursorVisible || ! NUMdefined (cursorFunctionValue) || Graphics_dyWCtoMM (my d_graphics, cursorFunctionValue - minimum) > 5.0) {
+ Graphics_setTextAlignment (my d_graphics, Graphics_RIGHT, Graphics_BOTTOM);
+ Graphics_text1 (my d_graphics, my d_startWindow, minimum, Melder_float (Melder_half (minimum)));
}
- if (not cursorVisible or ! NUMdefined (cursorFunctionValue) or Graphics_dyWCtoMM (d_graphics, maximum - cursorFunctionValue) > 5.0) {
- Graphics_setTextAlignment (d_graphics, Graphics_RIGHT, Graphics_TOP);
- Graphics_text1 (d_graphics, d_startWindow, maximum, Melder_float (Melder_half (maximum)));
+ if (! cursorVisible || ! NUMdefined (cursorFunctionValue) || Graphics_dyWCtoMM (my d_graphics, maximum - cursorFunctionValue) > 5.0) {
+ Graphics_setTextAlignment (my d_graphics, Graphics_RIGHT, Graphics_TOP);
+ Graphics_text1 (my d_graphics, my d_startWindow, maximum, Melder_float (Melder_half (maximum)));
}
}
if (minimum < 0 && maximum > 0 && ! horizontal) {
- Graphics_setWindow (d_graphics, 0, 1, minimum, maximum);
- if (not cursorVisible or ! NUMdefined (cursorFunctionValue) or fabs (Graphics_dyWCtoMM (d_graphics, cursorFunctionValue - 0.0)) > 3.0) {
- Graphics_setTextAlignment (d_graphics, Graphics_RIGHT, Graphics_HALF);
- Graphics_text (d_graphics, 0, 0, L"0");
+ Graphics_setWindow (my d_graphics, 0, 1, minimum, maximum);
+ if (! cursorVisible || ! NUMdefined (cursorFunctionValue) || fabs (Graphics_dyWCtoMM (my d_graphics, cursorFunctionValue - 0.0)) > 3.0) {
+ Graphics_setTextAlignment (my d_graphics, Graphics_RIGHT, Graphics_HALF);
+ Graphics_text (my d_graphics, 0, 0, L"0");
}
- Graphics_setColour (d_graphics, Graphics_CYAN);
- Graphics_setLineType (d_graphics, Graphics_DOTTED);
- Graphics_line (d_graphics, 0, 0, 1, 0);
- Graphics_setLineType (d_graphics, Graphics_DRAWN);
+ Graphics_setColour (my d_graphics, Graphics_CYAN);
+ Graphics_setLineType (my d_graphics, Graphics_DOTTED);
+ Graphics_line (my d_graphics, 0, 0, 1, 0);
+ Graphics_setLineType (my d_graphics, Graphics_DRAWN);
}
/*
* Garnish the drawing area of each channel.
*/
- Graphics_setWindow (d_graphics, 0, 1, 0, 1);
- Graphics_setColour (d_graphics, Graphics_CYAN);
- Graphics_innerRectangle (d_graphics, 0, 1, 0, 1);
- Graphics_setColour (d_graphics, Graphics_BLACK);
+ Graphics_setWindow (my d_graphics, 0, 1, 0, 1);
+ Graphics_setColour (my d_graphics, Graphics_CYAN);
+ Graphics_innerRectangle (my d_graphics, 0, 1, 0, 1);
+ Graphics_setColour (my d_graphics, Graphics_BLACK);
if (nchan > 1) {
- Graphics_setTextAlignment (d_graphics, Graphics_LEFT, Graphics_HALF);
+ Graphics_setTextAlignment (my d_graphics, Graphics_LEFT, Graphics_HALF);
static MelderString channelLabel;
- const wchar_t *channelName = v_getChannelName (ichan);
+ const wchar_t *channelName = my v_getChannelName (ichan);
MelderString_copy (& channelLabel, channelName ? L"ch" : L"Channel ");
MelderString_append (& channelLabel, Melder_integer (ichan));
if (channelName)
MelderString_append (& channelLabel, L": ", channelName);
- if (ichan > 8 && ichan - d_sound.channelOffset == 1) {
+ if (ichan > 8 && ichan - my d_sound.channelOffset == 1) {
MelderString_append (& channelLabel, L" " UNITEXT_UPWARDS_ARROW);
- } else if (ichan >= 8 && ichan - d_sound.channelOffset == 8 && ichan < nchan) {
+ } else if (ichan >= 8 && ichan - my d_sound.channelOffset == 8 && ichan < nchan) {
MelderString_append (& channelLabel, L" " UNITEXT_DOWNWARDS_ARROW);
}
- Graphics_text1 (d_graphics, 1, 0.5, channelLabel.string);
+ Graphics_text1 (my d_graphics, 1, 0.5, channelLabel.string);
}
/*
* Draw a very thin separator line underneath.
*/
if (ichan < nchan) {
/*Graphics_setColour (d_graphics, Graphics_BLACK);*/
- Graphics_line (d_graphics, 0, 0, 1, 0);
+ Graphics_line (my d_graphics, 0, 0, 1, 0);
}
/*
* Draw the samples.
*/
/*if (ichan == 1) FunctionEditor_SoundAnalysis_drawPulses (this);*/
if (sound) {
- Graphics_setWindow (d_graphics, d_startWindow, d_endWindow, minimum, maximum);
+ Graphics_setWindow (my d_graphics, my d_startWindow, my d_endWindow, minimum, maximum);
if (cursorVisible && NUMdefined (cursorFunctionValue))
- FunctionEditor_drawCursorFunctionValue (this, cursorFunctionValue, Melder_float (Melder_half (cursorFunctionValue)), L"");
- Graphics_setColour (d_graphics, Graphics_BLACK);
- Graphics_function (d_graphics, sound -> z [ichan], first, last,
- sound -> f_indexToX (first), sound -> f_indexToX (last));
+ FunctionEditor_drawCursorFunctionValue (me, cursorFunctionValue, Melder_float (Melder_half (cursorFunctionValue)), L"");
+ Graphics_setColour (my d_graphics, Graphics_BLACK);
+ Graphics_function (my d_graphics, sound -> z [ichan], first, last,
+ Sampled_indexToX (sound, first), Sampled_indexToX (sound, last));
} else {
- Graphics_setWindow (d_graphics, d_startWindow, d_endWindow, minimum * 32768, maximum * 32768);
- Graphics_function16 (d_graphics,
+ Graphics_setWindow (my d_graphics, my d_startWindow, my d_endWindow, minimum * 32768, maximum * 32768);
+ Graphics_function16 (my d_graphics,
longSound -> buffer - longSound -> imin * nchan + (ichan - 1), nchan - 1, first, last,
- longSound -> f_indexToX (first), longSound -> f_indexToX (last));
+ Sampled_indexToX (longSound, first), Sampled_indexToX (longSound, last));
}
- Graphics_resetViewport (d_graphics, vp);
+ Graphics_resetViewport (my d_graphics, vp);
}
- Graphics_setWindow (d_graphics, 0, 1, 0, 1);
- Graphics_rectangle (d_graphics, 0, 1, 0, 1);
+ Graphics_setWindow (my d_graphics, 0, 1, 0, 1);
+ Graphics_rectangle (my d_graphics, 0, 1, 0, 1);
}
int structTimeSoundEditor :: v_click (double xbegin, double ybegin, bool shiftKeyPressed) {
@@ -644,24 +644,24 @@ int structTimeSoundEditor :: v_click (double xbegin, double ybegin, bool shiftKe
return TimeSoundEditor_Parent :: v_click (xbegin, ybegin, shiftKeyPressed);
}
-void structTimeSoundEditor :: f_init (const wchar_t *title, Function data, Sampled sound, bool ownSound) {
- d_ownSound = ownSound;
+void TimeSoundEditor_init (TimeSoundEditor me, const wchar_t *title, Function data, Sampled sound, bool ownSound) {
+ my d_ownSound = ownSound;
if (sound != NULL) {
if (ownSound) {
Melder_assert (Thing_member (sound, classSound));
- d_sound.data = Data_copy ((Sound) sound); // deep copy; ownership transferred
- Matrix_getWindowExtrema (d_sound.data, 1, d_sound.data -> nx, 1, d_sound.data -> ny, & d_sound.minimum, & d_sound.maximum);
+ my d_sound.data = Data_copy ((Sound) sound); // deep copy; ownership transferred
+ Matrix_getWindowExtrema (my d_sound.data, 1, my d_sound.data -> nx, 1, my d_sound.data -> ny, & my d_sound.minimum, & my d_sound.maximum);
} else if (Thing_member (sound, classSound)) {
- d_sound.data = (Sound) sound; // reference copy; ownership not transferred
- Matrix_getWindowExtrema (d_sound.data, 1, d_sound.data -> nx, 1, d_sound.data -> ny, & d_sound.minimum, & d_sound.maximum);
+ my d_sound.data = (Sound) sound; // reference copy; ownership not transferred
+ Matrix_getWindowExtrema (my d_sound.data, 1, my d_sound.data -> nx, 1, my d_sound.data -> ny, & my d_sound.minimum, & my d_sound.maximum);
} else if (Thing_member (sound, classLongSound)) {
- d_longSound.data = (LongSound) sound;
- d_sound.minimum = -1.0, d_sound.maximum = 1.0;
+ my d_longSound.data = (LongSound) sound;
+ my d_sound.minimum = -1.0, my d_sound.maximum = 1.0;
} else {
Melder_fatal ("Invalid sound class in TimeSoundEditor::init.");
}
}
- FunctionEditor_init (this, title, data);
+ FunctionEditor_init (me, title, data);
}
/* End of file TimeSoundEditor.cpp */
diff --git a/fon/TimeSoundEditor.h b/fon/TimeSoundEditor.h
index 589595c..e440296 100644
--- a/fon/TimeSoundEditor.h
+++ b/fon/TimeSoundEditor.h
@@ -2,7 +2,7 @@
#define _TimeSoundEditor_h_
/* TimeSoundEditor.h
*
- * Copyright (C) 1992-2012, 2013 Paul Boersma
+ * Copyright (C) 1992-2012,2013,2014 Paul Boersma
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -39,10 +39,6 @@ Thing_define (TimeSoundEditor, FunctionEditor) {
struct { LongSound data; } d_longSound;
GuiMenuItem drawButton, publishButton, publishPreserveButton, publishWindowButton, publishOverlapButton;
GuiMenuItem writeAiffButton, d_saveAs24BitWavButton, d_saveAs32BitWavButton, writeAifcButton, writeWavButton, writeNextSunButton, writeNistButton, writeFlacButton;
- // messages:
- public:
- void f_init (const wchar_t *title, Function data, Sampled sound, bool ownSound);
- void f_drawSound (double globalMinimum, double globalMaximum);
// overridden methods:
protected:
virtual void v_destroy ();
@@ -55,12 +51,16 @@ Thing_define (TimeSoundEditor, FunctionEditor) {
virtual void v_createMenuItems_view (EditorMenu menu);
virtual int v_click (double xbegin, double ybegin, bool shiftKeyPressed); // catch channel scrolling
// new methods:
- protected:
+ public: // BUG
virtual void v_createMenuItems_view_sound (EditorMenu menu);
virtual void v_updateMenuItems_file ();
virtual const wchar_t * v_getChannelName (long channelNumber) { (void) channelNumber; return NULL; }
#include "TimeSoundEditor_prefs.h"
};
+void TimeSoundEditor_init (TimeSoundEditor me, const wchar_t *title, Function data, Sampled sound, bool ownSound);
+
+void TimeSoundEditor_drawSound (TimeSoundEditor me, double globalMinimum, double globalMaximum);
+
/* End of file TimeSoundEditor.h */
#endif
diff --git a/fon/Vector.cpp b/fon/Vector.cpp
index d94999d..d58975d 100644
--- a/fon/Vector.cpp
+++ b/fon/Vector.cpp
@@ -118,14 +118,14 @@ double Vector_getValueAtX (Vector me, double x, long ilevel, int interpolation)
if (x < leftEdge || x > rightEdge) return NUMundefined;
if (ilevel > Vector_CHANNEL_AVERAGE) {
Melder_assert (ilevel <= my ny);
- return NUM_interpolate_sinc (my z [ilevel], my nx, my f_xToIndex (x),
+ return NUM_interpolate_sinc (my z [ilevel], my nx, Sampled_xToIndex (me, x),
interpolation == Vector_VALUE_INTERPOLATION_SINC70 ? NUM_VALUE_INTERPOLATE_SINC70 :
interpolation == Vector_VALUE_INTERPOLATION_SINC700 ? NUM_VALUE_INTERPOLATE_SINC700 :
interpolation);
}
double sum = 0.0;
for (long channel = 1; channel <= my ny; channel ++) {
- sum += NUM_interpolate_sinc (my z [channel], my nx, my f_xToIndex (x),
+ sum += NUM_interpolate_sinc (my z [channel], my nx, Sampled_xToIndex (me, x),
interpolation == Vector_VALUE_INTERPOLATION_SINC70 ? NUM_VALUE_INTERPOLATE_SINC70 :
interpolation == Vector_VALUE_INTERPOLATION_SINC700 ? NUM_VALUE_INTERPOLATE_SINC700 :
interpolation);
@@ -403,7 +403,7 @@ void Vector_draw (Vector me, Graphics g, double *pxmin, double *pxmax, double *p
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 = my f_indexToX (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;
@@ -417,12 +417,12 @@ void Vector_draw (Vector me, Graphics g, double *pxmin, double *pxmax, double *p
}
} else if (wcsstr (method, L"poles") || wcsstr (method, L"Poles")) {
for (ix = ixmin; ix <= ixmax; ix ++) {
- double x = my f_indexToX (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 = my f_indexToX (ix);
+ double x = Sampled_indexToX (me, ix);
Graphics_speckle (g, x, my z [1] [ix]);
}
} else {
diff --git a/fon/manual_tutorials.cpp b/fon/manual_tutorials.cpp
index c5a5b58..4afcce9 100644
--- a/fon/manual_tutorials.cpp
+++ b/fon/manual_tutorials.cpp
@@ -23,9 +23,18 @@
void manual_tutorials_init (ManPages me);
void manual_tutorials_init (ManPages me) {
-MAN_BEGIN (L"What's new?", L"ppgb", 20140726)
+MAN_BEGIN (L"What's new?", L"ppgb", 20140826)
INTRO (L"Latest changes in Praat.")
/*LIST_ITEM (L"\\bu Manual page about @@drawing a vowel triangle at .")*/
+NORMAL (L"##5.3.84# (26 August 2014)")
+LIST_ITEM (L"\\bu Manipulation: repaired a bug that could cause Praat to crash when playing a manipulation of a Sound created by the SpeechSynthesizer.")
+LIST_ITEM (L"\\bu Mac: repaired a bug that could cause poor sound quality on some USB headphones when playing a sound with a low sampling frequency.")
+NORMAL (L"##5.3.83# (16 August 2014)")
+LIST_ITEM (L"\\bu TextGrid window: repaired a bug with automatic alignment that could cause an analysis tier to go out of order.")
+LIST_ITEM (L"\\bu Linux audio: created a second workaround that reduces even more the chances of a freeze that is due to a potential deadlock "
+ "in the collaboration between Alsa and PulseAudio that can occur when the playback of a sound is cancelled.")
+LIST_ITEM (L"\\bu Smoother communication with Phon.")
+LIST_ITEM (L"\\bu Windows: repaired a memory leak when saving PNG files.")
NORMAL (L"##5.3.82# (26 July 2014)")
LIST_ITEM (L"\\bu Audio playback: if the sound has more channels than the audio hardware, distribute them evenly.")
LIST_ITEM (L"\\bu Pause forms: more consistent appearance of the Revert button.")
@@ -1806,7 +1815,7 @@ NORMAL (L"#Question: what algorithm is used for formant analysis?")
NORMAL (L"Answer: see @@Sound: To Formant (burg)... at .")
MAN_END
-MAN_BEGIN (L"FAQ: How to cite Praat", L"ppgb", 20100401)
+MAN_BEGIN (L"FAQ: How to cite Praat", L"ppgb", 20140826)
NORMAL (L"#Question: how do I cite Praat in my articles?")
NORMAL (L"Answer: nowadays most journals allow you to cite computer programs and web sites. "
"The style approved by the American Psychological Association, "
@@ -1820,6 +1829,7 @@ NORMAL (L"Boersma, Paul & Weenink, David (" xstr(PRAAT_YEAR) "). "
NORMAL (L"If the journal does not allow you to cite a web site, then try:")
NORMAL (L"Boersma, Paul (2001). Praat, a system for doing phonetics by computer. "
"%%Glot International% ##5:9/10#, 341-345.")
+NORMAL (L"This paper can be downloaded from Boersma's website.")
MAN_END
MAN_BEGIN (L"FAQ: Pitch analysis", L"ppgb", 20060913)
diff --git a/fon/praat_Fon.cpp b/fon/praat_Fon.cpp
index a6cf3e3..7e80822 100644
--- a/fon/praat_Fon.cpp
+++ b/fon/praat_Fon.cpp
@@ -2102,7 +2102,7 @@ FORM (Ltas_getBinNumberFromFrequency, L"Ltas: Get band from frequency", L"Ltas:
OK
DO
Ltas me = FIRST (Ltas);
- double binNumber = my f_xToIndex (GET_REAL (L"Frequency"));
+ double binNumber = Sampled_xToIndex (me, GET_REAL (L"Frequency"));
Melder_informationReal (binNumber, NULL);
END
@@ -2116,7 +2116,7 @@ FORM (Ltas_getFrequencyFromBinNumber, L"Ltas: Get frequency from bin number", L"
OK
DO
Ltas me = FIRST (Ltas);
- double frequency = my f_indexToX (GET_INTEGER (L"Bin number"));
+ double frequency = Sampled_indexToX (me, GET_INTEGER (L"Bin number"));
Melder_informationReal (frequency, L"hertz");
END
@@ -3223,7 +3223,7 @@ DO
LOOP {
iam (Photo);
autoPraatPicture picture;
- my f_paintCells (GRAPHICS,
+ Photo_paintCells (me, GRAPHICS,
GET_REAL (L"From x ="), GET_REAL (L"To x ="), GET_REAL (L"From y ="), GET_REAL (L"To y ="));
}
END
@@ -3238,7 +3238,7 @@ DO
LOOP {
iam (Photo);
autoPraatPicture picture;
- my f_paintImage (GRAPHICS,
+ Photo_paintImage (me, GRAPHICS,
GET_REAL (L"From x ="), GET_REAL (L"To x ="), GET_REAL (L"From y ="), GET_REAL (L"To y ="));
}
END
@@ -3246,56 +3246,56 @@ END
FORM_WRITE (Photo_saveAsAppleIconFile, L"Save as Apple icon file", 0, L"icns")
LOOP {
iam (Photo);
- my f_saveAsAppleIconFile (file);
+ Photo_saveAsAppleIconFile (me, file);
}
END
FORM_WRITE (Photo_saveAsGIF, L"Save as GIF file", 0, L"gif")
LOOP {
iam (Photo);
- my f_saveAsGIF (file);
+ Photo_saveAsGIF (me, file);
}
END
FORM_WRITE (Photo_saveAsJPEG, L"Save as JPEG file", 0, L"jpg")
LOOP {
iam (Photo);
- my f_saveAsJPEG (file);
+ Photo_saveAsJPEG (me, file);
}
END
FORM_WRITE (Photo_saveAsJPEG2000, L"Save as JPEG-2000 file", 0, L"jpg")
LOOP {
iam (Photo);
- my f_saveAsJPEG2000 (file);
+ Photo_saveAsJPEG2000 (me, file);
}
END
FORM_WRITE (Photo_saveAsPNG, L"Save as PNG file", 0, L"png")
LOOP {
iam (Photo);
- my f_saveAsPNG (file);
+ Photo_saveAsPNG (me, file);
}
END
FORM_WRITE (Photo_saveAsTIFF, L"Save as TIFF file", 0, L"tiff")
LOOP {
iam (Photo);
- my f_saveAsTIFF (file);
+ Photo_saveAsTIFF (me, file);
}
END
FORM_WRITE (Photo_saveAsWindowsBitmapFile, L"Save as Windows bitmap file", 0, L"bmp")
LOOP {
iam (Photo);
- my f_saveAsWindowsBitmapFile (file);
+ Photo_saveAsWindowsBitmapFile (me, file);
}
END
FORM_WRITE (Photo_saveAsWindowsIconFile, L"Save as Windows icon file", 0, L"ico")
LOOP {
iam (Photo);
- my f_saveAsWindowsIconFile (file);
+ Photo_saveAsWindowsIconFile (me, file);
}
END
@@ -3304,28 +3304,28 @@ END
DIRECT (Photo_Matrix_replaceBlue)
Photo me = FIRST (Photo);
Matrix thee = FIRST (Matrix);
- my f_replaceBlue (thee);
+ Photo_replaceBlue (me, thee);
praat_dataChanged (me);
END
DIRECT (Photo_Matrix_replaceGreen)
Photo me = FIRST (Photo);
Matrix thee = FIRST (Matrix);
- my f_replaceGreen (thee);
+ Photo_replaceGreen (me, thee);
praat_dataChanged (me);
END
DIRECT (Photo_Matrix_replaceRed)
Photo me = FIRST (Photo);
Matrix thee = FIRST (Matrix);
- my f_replaceRed (thee);
+ Photo_replaceRed (me, thee);
praat_dataChanged (me);
END
DIRECT (Photo_Matrix_replaceTransparency)
Photo me = FIRST (Photo);
Matrix thee = FIRST (Matrix);
- my f_replaceTransparency (thee);
+ Photo_replaceTransparency (me, thee);
praat_dataChanged (me);
END
@@ -5353,7 +5353,7 @@ FORM (Spectrum_getBinFromFrequency, L"Spectrum: Get bin from frequency", 0)
DO
LOOP {
iam (Spectrum);
- double bin = my f_xToIndex (GET_REAL (L"Frequency"));
+ double bin = Sampled_xToIndex (me, GET_REAL (L"Frequency"));
Melder_informationReal (bin, NULL);
}
END
@@ -5394,7 +5394,7 @@ FORM (Spectrum_getFrequencyFromBin, L"Spectrum: Get frequency from bin", 0)
DO
LOOP {
iam (Spectrum);
- double frequency = my f_indexToX (GET_INTEGER (L"Band number"));
+ double frequency = Sampled_indexToX (me, GET_INTEGER (L"Band number"));
Melder_informationReal (frequency, L"hertz");
}
END
@@ -5952,7 +5952,7 @@ FORM (TimeFrameSampled_getFrameFromTime, L"Get frame number from time", L"Get fr
DO
LOOP {
iam (Sampled);
- double frame = my f_xToIndex (GET_REAL (L"Time"));
+ double frame = Sampled_xToIndex (me, GET_REAL (L"Time"));
Melder_informationReal (frame, NULL);
}
END
@@ -5971,7 +5971,7 @@ FORM (TimeFrameSampled_getTimeFromFrame, L"Get time from frame number", L"Get ti
DO
LOOP {
iam (Sampled);
- double time = my f_indexToX (GET_INTEGER (L"Frame number"));
+ double time = Sampled_indexToX (me, GET_INTEGER (L"Frame number"));
Melder_informationReal (time, L"seconds");
}
END
diff --git a/fon/praat_Sound_init.cpp b/fon/praat_Sound_init.cpp
index 211991a..f9c876f 100644
--- a/fon/praat_Sound_init.cpp
+++ b/fon/praat_Sound_init.cpp
@@ -74,7 +74,7 @@ FORM (LongSound_getIndexFromTime, L"LongSound: Get sample index from time", L"So
DO
LOOP {
iam (LongSound);
- double index = my f_xToIndex (GET_REAL (L"Time"));
+ double index = Sampled_xToIndex (me, GET_REAL (L"Time"));
Melder_informationReal (index, NULL);
}
END2 }
@@ -99,7 +99,7 @@ FORM (LongSound_getTimeFromIndex, L"LongSound: Get time from sample index", L"So
DO
LOOP {
iam (LongSound);
- Melder_informationReal (my f_indexToX (GET_INTEGER (L"Sample index")), L"seconds");
+ Melder_informationReal (Sampled_indexToX (me, GET_INTEGER (L"Sample index")), L"seconds");
}
END2 }
@@ -973,7 +973,7 @@ FORM (Sound_getIndexFromTime, L"Get sample number from time", L"Get sample numbe
DO
LOOP {
iam (Sound);
- double realIndex = my f_xToIndex (GET_REAL (L"Time"));
+ double realIndex = Sampled_xToIndex (me, GET_REAL (L"Time"));
Melder_informationReal (realIndex, NULL);
}
END2 }
@@ -1172,7 +1172,7 @@ FORM (Sound_getTimeFromIndex, L"Get time from sample number", L"Get time from sa
DO
LOOP {
iam (Sound);
- double time = my f_indexToX (GET_INTEGER (L"Sample number"));
+ double time = Sampled_indexToX (me, GET_INTEGER (L"Sample number"));
Melder_informationReal (time, L"seconds");
}
END2 }
diff --git a/fon/praat_TextGrid_init.cpp b/fon/praat_TextGrid_init.cpp
index e195d34..d910247 100644
--- a/fon/praat_TextGrid_init.cpp
+++ b/fon/praat_TextGrid_init.cpp
@@ -838,6 +838,23 @@ DIRECT2 (TextGrid_edit) {
}
END2 }
+FORM (TextGrid_editWithCallback, L"TextGrid: View & Edit with callback", 0) {
+ SENTENCE (L"Callback text", L"r1")
+ OK2
+DO
+ if (theCurrentPraatApplication -> batch) Melder_throw ("Cannot view or edit a TextGrid from batch.");
+ Sound sound = NULL;
+ LOOP {
+ if (CLASS == classSound) sound = (Sound) OBJECT; // may stay NULL
+ }
+ LOOP if (CLASS == classTextGrid) {
+ iam (TextGrid);
+ autoTextGridEditor editor = TextGridEditor_create (ID_AND_FULL_NAME, me, sound, true, NULL, Melder_peekWcsToUtf8 (GET_STRING (L"Callback text")));
+ editor -> setPublicationCallback (cb_TextGridEditor_publication, NULL);
+ praat_installEditor (editor.transfer(), IOBJECT);
+ }
+END2 }
+
DIRECT2 (TextGrid_LongSound_edit) {
if (theCurrentPraatApplication -> batch) Melder_throw ("Cannot view or edit a TextGrid from batch.");
LongSound longSound = NULL;
@@ -1803,6 +1820,7 @@ praat_addAction1 (classTextGrid, 0, L"Synthesize", 0, 0, 0);
praat_addAction2 (classPitch, 1, classTextGrid, 1, L"Speckle separately (erb)...", 0, 1, DO_TextGrid_Pitch_speckleSeparatelyErb);
praat_addAction2 (classPitch, 1, classTextTier, 1, L"To PitchTier...", 0, 0, DO_Pitch_TextTier_to_PitchTier);
praat_addAction2 (classSound, 1, classTextGrid, 1, L"View & Edit", 0, praat_ATTRACTIVE, DO_TextGrid_edit);
+ praat_addAction2 (classSound, 1, classTextGrid, 1, L"View & Edit with callback", 0, praat_HIDDEN, DO_TextGrid_editWithCallback);
praat_addAction2 (classSound, 1, classTextGrid, 1, L"Edit", 0, praat_HIDDEN, DO_TextGrid_edit);
praat_addAction2 (classSound, 1, classTextGrid, 1, L"Draw...", 0, 0, DO_TextGrid_Sound_draw);
praat_addAction2 (classSound, 1, classTextGrid, 1, L"Extract -", 0, 0, 0);
diff --git a/gram/Network.cpp b/gram/Network.cpp
index 754519a..b17e28c 100644
--- a/gram/Network.cpp
+++ b/gram/Network.cpp
@@ -1,6 +1,6 @@
/* Network.cpp
*
- * Copyright (C) 2009-2012,2013 Paul Boersma
+ * Copyright (C) 2009-2012,2013,2014 Paul Boersma
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -57,45 +57,45 @@
void structNetwork :: v_info ()
{
structData :: v_info ();
- MelderInfo_writeLine (L"Spreading rate: ", Melder_double (d_spreadingRate));
- MelderInfo_writeLine (L"Activity clipping rule: ", kNetwork_activityClippingRule_getText (d_activityClippingRule));
- MelderInfo_writeLine (L"Minimum activity: ", Melder_double (d_minimumActivity));
- MelderInfo_writeLine (L"Maximum activity: ", Melder_double (d_maximumActivity));
- MelderInfo_writeLine (L"Activity leak: ", Melder_double (d_activityLeak));
- MelderInfo_writeLine (L"Learning rate: ", Melder_double (d_learningRate));
- MelderInfo_writeLine (L"Minimum weight: ", Melder_double (d_minimumWeight));
- MelderInfo_writeLine (L"Maximum weight: ", Melder_double (d_maximumWeight));
- MelderInfo_writeLine (L"Weight leak: ", Melder_double (d_weightLeak));
- MelderInfo_writeLine (L"Number of nodes: ", Melder_integer (d_numberOfNodes));
- MelderInfo_writeLine (L"Number of connections: ", Melder_integer (d_numberOfConnections));
+ MelderInfo_writeLine (L"Spreading rate: ", Melder_double (our spreadingRate));
+ MelderInfo_writeLine (L"Activity clipping rule: ", kNetwork_activityClippingRule_getText (our activityClippingRule));
+ MelderInfo_writeLine (L"Minimum activity: ", Melder_double (our minimumActivity));
+ MelderInfo_writeLine (L"Maximum activity: ", Melder_double (our maximumActivity));
+ MelderInfo_writeLine (L"Activity leak: ", Melder_double (our activityLeak));
+ MelderInfo_writeLine (L"Learning rate: ", Melder_double (our learningRate));
+ MelderInfo_writeLine (L"Minimum weight: ", Melder_double (our minimumWeight));
+ MelderInfo_writeLine (L"Maximum weight: ", Melder_double (our maximumWeight));
+ MelderInfo_writeLine (L"Weight leak: ", Melder_double (our weightLeak));
+ MelderInfo_writeLine (L"Number of nodes: ", Melder_integer (our numberOfNodes));
+ MelderInfo_writeLine (L"Number of connections: ", Melder_integer (our numberOfConnections));
}
Thing_implement (Network, Data, 6);
-void structNetwork :: f_init (double spreadingRate, enum kNetwork_activityClippingRule activityClippingRule,
+void Network_init (Network me, double spreadingRate, enum kNetwork_activityClippingRule activityClippingRule,
double minimumActivity, double maximumActivity, double activityLeak,
double learningRate, double minimumWeight, double maximumWeight, double weightLeak,
double xmin, double xmax, double ymin, double ymax, long numberOfNodes, long numberOfConnections)
{
- d_spreadingRate = spreadingRate;
- d_activityClippingRule = activityClippingRule;
- d_minimumActivity = minimumActivity;
- d_maximumActivity = maximumActivity;
- d_activityLeak = activityLeak;
- d_learningRate = learningRate;
- d_minimumWeight = minimumWeight;
- d_maximumWeight = maximumWeight;
- d_weightLeak = weightLeak;
- d_instar = 0.0;
- d_outstar = 0.0;
- d_xmin = xmin;
- d_xmax = xmax;
- d_ymin = ymin;
- d_ymax = ymax;
- d_numberOfNodes = numberOfNodes;
- d_nodes = NUMvector <structNetworkNode> (1, numberOfNodes);
- d_numberOfConnections = numberOfConnections;
- d_connections = NUMvector <structNetworkConnection> (1, numberOfConnections);
+ my spreadingRate = spreadingRate;
+ my activityClippingRule = activityClippingRule;
+ my minimumActivity = minimumActivity;
+ my maximumActivity = maximumActivity;
+ my activityLeak = activityLeak;
+ my learningRate = learningRate;
+ my minimumWeight = minimumWeight;
+ my maximumWeight = maximumWeight;
+ my weightLeak = weightLeak;
+ my instar = 0.0;
+ my outstar = 0.0;
+ my xmin = xmin;
+ my xmax = xmax;
+ my ymin = ymin;
+ my ymax = ymax;
+ my numberOfNodes = numberOfNodes;
+ my nodes = NUMvector <structNetworkNode> (1, numberOfNodes);
+ my numberOfConnections = numberOfConnections;
+ my connections = NUMvector <structNetworkConnection> (1, numberOfConnections);
}
Network Network_create (double spreadingRate, enum kNetwork_activityClippingRule activityClippingRule,
@@ -105,7 +105,7 @@ Network Network_create (double spreadingRate, enum kNetwork_activityClippingRule
{
try {
autoNetwork me = Thing_new (Network);
- me -> f_init (spreadingRate, activityClippingRule, minimumActivity, maximumActivity, activityLeak,
+ Network_init (me.peek(), spreadingRate, activityClippingRule, minimumActivity, maximumActivity, activityLeak,
learningRate, minimumWeight, maximumWeight, weightLeak,
xmin, xmax, ymin, ymax, numberOfNodes, numberOfConnections);
return me.transfer();
@@ -114,96 +114,96 @@ Network Network_create (double spreadingRate, enum kNetwork_activityClippingRule
}
}
-double structNetwork :: f_getActivity (long nodeNumber) {
+double Network_getActivity (Network me, long nodeNumber) {
try {
- if (nodeNumber <= 0 || nodeNumber > d_numberOfNodes)
- Melder_throw (this, ": node number (", nodeNumber, ") out of the range 1..", d_numberOfNodes, ".");
- return d_nodes [nodeNumber]. activity;
+ if (nodeNumber <= 0 || nodeNumber > my numberOfNodes)
+ Melder_throw (me, ": node number (", nodeNumber, ") out of the range 1..", my numberOfNodes, ".");
+ return my nodes [nodeNumber]. activity;
} catch (MelderError) {
- Melder_throw (this, ": activity not gotten.");
+ Melder_throw (me, ": activity not gotten.");
}
}
-void structNetwork :: f_setActivity (long nodeNumber, double activity) {
+void Network_setActivity (Network me, long nodeNumber, double activity) {
try {
- if (nodeNumber <= 0 || nodeNumber > d_numberOfNodes)
- Melder_throw (this, ": node number (", nodeNumber, ") out of the range 1..", d_numberOfNodes, ".");
- d_nodes [nodeNumber]. activity = d_nodes [nodeNumber]. excitation = activity;
+ if (nodeNumber <= 0 || nodeNumber > my numberOfNodes)
+ Melder_throw (me, ": node number (", nodeNumber, ") out of the range 1..", my numberOfNodes, ".");
+ my nodes [nodeNumber]. activity = my nodes [nodeNumber]. excitation = activity;
} catch (MelderError) {
- Melder_throw (this, ": activity not set.");
+ Melder_throw (me, ": activity not set.");
}
}
-double structNetwork :: f_getWeight (long connectionNumber) {
+double Network_getWeight (Network me, long connectionNumber) {
try {
- if (connectionNumber <= 0 || connectionNumber > d_numberOfConnections)
- Melder_throw (this, ": connection number (", connectionNumber, ") out of the range 1..", d_numberOfConnections, ".");
- return d_connections [connectionNumber]. weight;
+ if (connectionNumber <= 0 || connectionNumber > my numberOfConnections)
+ Melder_throw (me, ": connection number (", connectionNumber, ") out of the range 1..", my numberOfConnections, ".");
+ return my connections [connectionNumber]. weight;
} catch (MelderError) {
- Melder_throw (this, ": weight not gotten.");
+ Melder_throw (me, ": weight not gotten.");
}
}
-void structNetwork :: f_setWeight (long connectionNumber, double weight) {
+void Network_setWeight (Network me, long connectionNumber, double weight) {
try {
- if (connectionNumber <= 0 || connectionNumber > d_numberOfConnections)
- Melder_throw (this, ": connection number (", connectionNumber, ") out of the range 1..", d_numberOfConnections, ".");
- d_connections [connectionNumber]. weight = weight;
+ if (connectionNumber <= 0 || connectionNumber > my numberOfConnections)
+ Melder_throw (me, ": connection number (", connectionNumber, ") out of the range 1..", my numberOfConnections, ".");
+ my connections [connectionNumber]. weight = weight;
} catch (MelderError) {
- Melder_throw (this, ": weight not set.");
+ Melder_throw (me, ": weight not set.");
}
}
-void structNetwork :: f_setClamping (long nodeNumber, bool clamped) {
+void Network_setClamping (Network me, long nodeNumber, bool clamped) {
try {
- if (nodeNumber <= 0 || nodeNumber > d_numberOfNodes)
- Melder_throw (this, ": node number (", nodeNumber, ") out of the range 1..", d_numberOfNodes, ".");
- d_nodes [nodeNumber]. clamped = clamped;
+ if (nodeNumber <= 0 || nodeNumber > my numberOfNodes)
+ Melder_throw (me, ": node number (", nodeNumber, ") out of the range 1..", my numberOfNodes, ".");
+ my nodes [nodeNumber]. clamped = clamped;
} catch (MelderError) {
- Melder_throw (this, ": clamping not set.");
+ Melder_throw (me, ": clamping not set.");
}
}
-void structNetwork :: f_spreadActivities (long numberOfSteps) {
+void Network_spreadActivities (Network me, long numberOfSteps) {
for (long istep = 1; istep <= numberOfSteps; istep ++) {
- for (long inode = 1; inode <= d_numberOfNodes; inode ++) {
- NetworkNode node = & d_nodes [inode];
+ for (long inode = 1; inode <= my numberOfNodes; inode ++) {
+ NetworkNode node = & my nodes [inode];
if (! node -> clamped)
- node -> excitation -= d_spreadingRate * d_activityLeak * node -> excitation;
+ node -> excitation -= my spreadingRate * my activityLeak * node -> excitation;
}
- for (long iconn = 1; iconn <= d_numberOfConnections; iconn ++) {
- NetworkConnection connection = & d_connections [iconn];
- NetworkNode nodeFrom = & d_nodes [connection -> nodeFrom];
- NetworkNode nodeTo = & d_nodes [connection -> nodeTo];
- double shunting = d_connections [iconn]. weight >= 0.0 ? d_shunting : 0.0; // only for excitatory connections
+ for (long iconn = 1; iconn <= my numberOfConnections; iconn ++) {
+ NetworkConnection connection = & my connections [iconn];
+ NetworkNode nodeFrom = & my nodes [connection -> nodeFrom];
+ NetworkNode nodeTo = & my nodes [connection -> nodeTo];
+ double shunting = my connections [iconn]. weight >= 0.0 ? my shunting : 0.0; // only for excitatory connections
if (! nodeFrom -> clamped)
- nodeFrom -> excitation += d_spreadingRate * nodeTo -> activity * (d_connections [iconn]. weight - shunting * nodeFrom -> excitation);
+ nodeFrom -> excitation += my spreadingRate * nodeTo -> activity * (my connections [iconn]. weight - shunting * nodeFrom -> excitation);
if (! nodeTo -> clamped)
- nodeTo -> excitation += d_spreadingRate * nodeFrom -> activity * (d_connections [iconn]. weight - shunting * nodeTo -> excitation);
+ nodeTo -> excitation += my spreadingRate * nodeFrom -> activity * (my connections [iconn]. weight - shunting * nodeTo -> excitation);
}
- for (long inode = 1; inode <= d_numberOfNodes; inode ++) {
- NetworkNode node = & d_nodes [inode];
+ for (long inode = 1; inode <= my numberOfNodes; inode ++) {
+ NetworkNode node = & my nodes [inode];
if (! node -> clamped) {
- switch (d_activityClippingRule) {
+ switch (my activityClippingRule) {
case kNetwork_activityClippingRule_SIGMOID:
- node -> activity = d_minimumActivity +
- (d_maximumActivity - d_minimumActivity) * NUMsigmoid (node -> excitation - 0.5 * (d_minimumActivity + d_maximumActivity));
+ node -> activity = my minimumActivity +
+ (my maximumActivity - my minimumActivity) * NUMsigmoid (node -> excitation - 0.5 * (my minimumActivity + my maximumActivity));
break;
case kNetwork_activityClippingRule_LINEAR:
- if (node -> excitation < d_minimumActivity) {
- node -> activity = d_minimumActivity;
- } else if (node -> excitation > d_maximumActivity) {
- node -> activity = d_maximumActivity;
+ if (node -> excitation < my minimumActivity) {
+ node -> activity = my minimumActivity;
+ } else if (node -> excitation > my maximumActivity) {
+ node -> activity = my maximumActivity;
} else {
node -> activity = node -> excitation;
}
break;
case kNetwork_activityClippingRule_TOP_SIGMOID:
- if (node -> excitation <= d_minimumActivity) {
- node -> activity = d_minimumActivity;
+ if (node -> excitation <= my minimumActivity) {
+ node -> activity = my minimumActivity;
} else {
- node -> activity = d_minimumActivity +
- (d_maximumActivity - d_minimumActivity) * (2.0 * NUMsigmoid (2.0 * (node -> excitation - d_minimumActivity) / (d_maximumActivity - d_minimumActivity)) - 1.0);
+ node -> activity = my minimumActivity +
+ (my maximumActivity - my minimumActivity) * (2.0 * NUMsigmoid (2.0 * (node -> excitation - my minimumActivity) / (my maximumActivity - my minimumActivity)) - 1.0);
trace ("excitation %f, activity %f", node -> excitation, node -> activity);
}
break;
@@ -213,62 +213,62 @@ void structNetwork :: f_spreadActivities (long numberOfSteps) {
}
}
-void structNetwork :: f_zeroActivities (long nodeMin, long nodeMax) {
- if (d_numberOfNodes < 1) return;
- if (nodeMax == 0) { nodeMin = 1; nodeMax = d_numberOfNodes; }
+void Network_zeroActivities (Network me, long nodeMin, long nodeMax) {
+ if (my numberOfNodes < 1) return;
+ if (nodeMax == 0) { nodeMin = 1; nodeMax = my numberOfNodes; }
if (nodeMin < 1) nodeMin = 1;
- if (nodeMax > d_numberOfNodes) nodeMax = d_numberOfNodes;
+ if (nodeMax > my numberOfNodes) nodeMax = my numberOfNodes;
for (long inode = nodeMin; inode <= nodeMax; inode ++) {
- d_nodes [inode]. activity = d_nodes [inode]. excitation = 0.0;
+ my nodes [inode]. activity = my nodes [inode]. excitation = 0.0;
}
}
-void structNetwork :: f_normalizeActivities (long nodeMin, long nodeMax) {
- if (d_numberOfNodes < 1) return;
- if (nodeMax == 0) { nodeMin = 1; nodeMax = d_numberOfNodes; }
+void Network_normalizeActivities (Network me, long nodeMin, long nodeMax) {
+ if (my numberOfNodes < 1) return;
+ if (nodeMax == 0) { nodeMin = 1; nodeMax = my numberOfNodes; }
if (nodeMin < 1) nodeMin = 1;
- if (nodeMax > d_numberOfNodes) nodeMax = d_numberOfNodes;
+ if (nodeMax > my numberOfNodes) nodeMax = my numberOfNodes;
if (nodeMax < nodeMin) return;
double sum = 0.0;
for (long inode = nodeMin; inode <= nodeMax; inode ++) {
- sum += d_nodes [inode]. activity;
+ sum += my nodes [inode]. activity;
}
double average = sum / (nodeMax - nodeMin + 1);
for (long inode = nodeMin; inode <= nodeMax; inode ++) {
- d_nodes [inode]. activity -= average;
+ my nodes [inode]. activity -= average;
}
}
-void structNetwork :: f_updateWeights () {
- for (long iconn = 1; iconn <= d_numberOfConnections; iconn ++) {
- NetworkConnection connection = & d_connections [iconn];
- NetworkNode nodeFrom = & d_nodes [connection -> nodeFrom];
- NetworkNode nodeTo = & d_nodes [connection -> nodeTo];
- connection -> weight += connection -> plasticity * d_learningRate *
- (nodeFrom -> activity * nodeTo -> activity - (d_instar * nodeTo -> activity + d_outstar * nodeFrom -> activity + d_weightLeak) * connection -> weight);
- if (connection -> weight < d_minimumWeight) connection -> weight = d_minimumWeight;
- else if (connection -> weight > d_maximumWeight) connection -> weight = d_maximumWeight;
+void Network_updateWeights (Network me) {
+ for (long iconn = 1; iconn <= my numberOfConnections; iconn ++) {
+ NetworkConnection connection = & my connections [iconn];
+ NetworkNode nodeFrom = & my nodes [connection -> nodeFrom];
+ NetworkNode nodeTo = & my nodes [connection -> nodeTo];
+ connection -> weight += connection -> plasticity * my learningRate *
+ (nodeFrom -> activity * nodeTo -> activity - (my instar * nodeTo -> activity + my outstar * nodeFrom -> activity + my weightLeak) * connection -> weight);
+ if (connection -> weight < my minimumWeight) connection -> weight = my minimumWeight;
+ else if (connection -> weight > my maximumWeight) connection -> weight = my maximumWeight;
}
}
-void structNetwork :: f_normalizeWeights (long nodeMin, long nodeMax, long nodeFromMin, long nodeFromMax, double newSum) {
- if (d_numberOfNodes < 1) return;
- if (nodeMax == 0) { nodeMin = 1; nodeMax = d_numberOfNodes; }
+void Network_normalizeWeights (Network me, long nodeMin, long nodeMax, long nodeFromMin, long nodeFromMax, double newSum) {
+ if (my numberOfNodes < 1) return;
+ if (nodeMax == 0) { nodeMin = 1; nodeMax = my numberOfNodes; }
if (nodeMin < 1) nodeMin = 1;
- if (nodeMax > d_numberOfNodes) nodeMax = d_numberOfNodes;
+ if (nodeMax > my numberOfNodes) nodeMax = my numberOfNodes;
if (nodeMax < nodeMin) return;
for (long inode = nodeMin; inode <= nodeMax; inode ++) {
double sum = 0.0;
- for (long iconn = 1; iconn <= d_numberOfConnections; iconn ++) {
- NetworkConnection connection = & d_connections [iconn];
+ for (long iconn = 1; iconn <= my numberOfConnections; iconn ++) {
+ NetworkConnection connection = & my connections [iconn];
if (connection -> nodeTo == inode && connection -> nodeFrom >= nodeFromMin && connection -> nodeFrom <= nodeFromMax) {
sum += connection -> weight;
}
}
if (sum != 0.0) {
double factor = newSum / sum;
- for (long iconn = 1; iconn <= d_numberOfConnections; iconn ++) {
- NetworkConnection connection = & d_connections [iconn];
+ for (long iconn = 1; iconn <= my numberOfConnections; iconn ++) {
+ NetworkConnection connection = & my connections [iconn];
if (connection -> nodeTo == inode && connection -> nodeFrom >= nodeFromMin && connection -> nodeFrom <= nodeFromMax) {
connection -> weight *= factor;
}
@@ -291,12 +291,12 @@ Network Network_create_rectangle (double spreadingRate, enum kNetwork_activityCl
/*
* Define nodes.
*/
- for (long inode = 1; inode <= my d_numberOfNodes; inode ++) {
- NetworkNode node = & my d_nodes [inode];
+ for (long inode = 1; inode <= my numberOfNodes; inode ++) {
+ NetworkNode node = & my nodes [inode];
node -> x = (inode - 1) % numberOfColumns + 0.5;
node -> y = (inode - 1) / numberOfColumns + 0.5;
node -> clamped = bottomRowClamped && inode <= numberOfColumns;
- node -> activity = NUMrandomUniform (my d_minimumActivity, my d_maximumActivity);
+ node -> activity = NUMrandomUniform (my minimumActivity, my maximumActivity);
}
/*
* Define connections.
@@ -304,7 +304,7 @@ Network Network_create_rectangle (double spreadingRate, enum kNetwork_activityCl
long iconn = 0;
for (long irow = 1; irow <= numberOfRows; irow ++) {
for (long icol = 1; icol <= numberOfColumns - 1; icol ++) {
- NetworkConnection conn = & my d_connections [++ iconn];
+ NetworkConnection conn = & my connections [++ iconn];
conn -> nodeFrom = (irow - 1) * numberOfColumns + icol;
conn -> nodeTo = conn -> nodeFrom + 1;
conn -> weight = NUMrandomUniform (initialMinimumWeight, initialMaximumWeight);
@@ -313,14 +313,14 @@ Network Network_create_rectangle (double spreadingRate, enum kNetwork_activityCl
}
for (long irow = 1; irow <= numberOfRows - 1; irow ++) {
for (long icol = 1; icol <= numberOfColumns; icol ++) {
- NetworkConnection conn = & my d_connections [++ iconn];
+ NetworkConnection conn = & my connections [++ iconn];
conn -> nodeFrom = (irow - 1) * numberOfColumns + icol;
conn -> nodeTo = conn -> nodeFrom + numberOfColumns;
conn -> weight = NUMrandomUniform (initialMinimumWeight, initialMaximumWeight);
conn -> plasticity = 1.0;
}
}
- Melder_assert (iconn == my d_numberOfConnections);
+ Melder_assert (iconn == my numberOfConnections);
return me.transfer();
} catch (MelderError) {
Melder_throw ("Rectangular network not created.");
@@ -341,12 +341,12 @@ Network Network_create_rectangle_vertical (double spreadingRate, enum kNetwork_a
/*
* Define nodes.
*/
- for (long inode = 1; inode <= my d_numberOfNodes; inode ++) {
- NetworkNode node = & my d_nodes [inode];
+ for (long inode = 1; inode <= my numberOfNodes; inode ++) {
+ NetworkNode node = & my nodes [inode];
node -> x = (inode - 1) % numberOfColumns + 0.5;
node -> y = (inode - 1) / numberOfColumns + 0.5;
node -> clamped = bottomRowClamped && inode <= numberOfColumns;
- node -> activity = NUMrandomUniform (my d_minimumActivity, my d_maximumActivity);
+ node -> activity = NUMrandomUniform (my minimumActivity, my maximumActivity);
}
/*
* Define connections.
@@ -355,7 +355,7 @@ Network Network_create_rectangle_vertical (double spreadingRate, enum kNetwork_a
for (long icol = 1; icol <= numberOfColumns; icol ++) {
for (long jcol = 1; jcol <= numberOfColumns; jcol ++) {
for (long irow = 1; irow <= numberOfRows - 1; irow ++) {
- NetworkConnection conn = & my d_connections [++ iconn];
+ NetworkConnection conn = & my connections [++ iconn];
conn -> nodeFrom = (irow - 1) * numberOfColumns + icol;
conn -> nodeTo = irow * numberOfColumns + jcol;
conn -> weight = NUMrandomUniform (initialMinimumWeight, initialMaximumWeight);
@@ -363,29 +363,29 @@ Network Network_create_rectangle_vertical (double spreadingRate, enum kNetwork_a
}
}
}
- Melder_assert (iconn == my d_numberOfConnections);
+ Melder_assert (iconn == my numberOfConnections);
return me.transfer();
} catch (MelderError) {
Melder_throw ("Vertical rectangular network not created.");
}
}
-void structNetwork :: f_draw (Graphics graphics, bool colour) {
+void Network_draw (Network me, Graphics graphics, bool colour) {
double saveLineWidth = Graphics_inqLineWidth (graphics);
Graphics_setInner (graphics);
- Graphics_setWindow (graphics, d_xmin, d_xmax, d_ymin, d_ymax);
+ Graphics_setWindow (graphics, my xmin, my xmax, my ymin, my ymax);
if (colour) {
Graphics_setColour (graphics, Graphics_SILVER);
- Graphics_fillRectangle (graphics, d_xmin, d_xmax, d_ymin, d_ymax);
+ Graphics_fillRectangle (graphics, my xmin, my xmax, my ymin, my ymax);
}
/*
* Draw connections.
*/
- for (long iconn = 1; iconn <= d_numberOfConnections; iconn ++) {
- NetworkConnection conn = & d_connections [iconn];
+ for (long iconn = 1; iconn <= my numberOfConnections; iconn ++) {
+ NetworkConnection conn = & my connections [iconn];
if (fabs (conn -> weight) >= 0.01) {
- NetworkNode nodeFrom = & d_nodes [conn -> nodeFrom];
- NetworkNode nodeTo = & d_nodes [conn -> nodeTo];
+ NetworkNode nodeFrom = & my nodes [conn -> nodeFrom];
+ NetworkNode nodeTo = & my nodes [conn -> nodeTo];
Graphics_setLineWidth (graphics, fabs (conn -> weight) * 6.0);
Graphics_setColour (graphics, conn -> weight < 0.0 ? (colour ? Graphics_WHITE : Graphics_SILVER) : Graphics_BLACK);
Graphics_line (graphics, nodeFrom -> x, nodeFrom -> y, nodeTo -> x, nodeTo -> y);
@@ -395,8 +395,8 @@ void structNetwork :: f_draw (Graphics graphics, bool colour) {
/*
* Draw the backgrounds of the nodes.
*/
- for (long inode = 1; inode <= d_numberOfNodes; inode ++) {
- NetworkNode node = & d_nodes [inode];
+ for (long inode = 1; inode <= my numberOfNodes; inode ++) {
+ NetworkNode node = & my nodes [inode];
Graphics_setColour (graphics, colour ? Graphics_SILVER : Graphics_WHITE);
Graphics_fillCircle_mm (graphics, node -> x, node -> y, 5.0);
}
@@ -405,16 +405,16 @@ void structNetwork :: f_draw (Graphics graphics, bool colour) {
*/
Graphics_setColour (graphics, Graphics_BLACK);
Graphics_setLineWidth (graphics, 2.0);
- for (long inode = 1; inode <= d_numberOfNodes; inode ++) {
- NetworkNode node = & d_nodes [inode];
+ for (long inode = 1; inode <= my numberOfNodes; inode ++) {
+ NetworkNode node = & my nodes [inode];
Graphics_setLineType (graphics, node -> clamped ? Graphics_DRAWN : Graphics_DOTTED);
Graphics_circle_mm (graphics, node -> x, node -> y, 5.2);
}
/*
* Draw the activities of the nodes.
*/
- for (long inode = 1; inode <= d_numberOfNodes; inode ++) {
- NetworkNode node = & d_nodes [inode];
+ for (long inode = 1; inode <= my numberOfNodes; inode ++) {
+ NetworkNode node = & my nodes [inode];
double activity = fabs (node -> activity);
if (activity >= 1.0) activity = sqrt (activity);
double diameter = activity * 5.0;
@@ -431,58 +431,58 @@ void structNetwork :: f_draw (Graphics graphics, bool colour) {
Graphics_unsetInner (graphics);
}
-void structNetwork :: f_addNode (double x, double y, double activity, bool clamped) {
+void Network_addNode (Network me, double x, double y, double activity, bool clamped) {
try {
- NUMvector_append (& d_nodes, 1, & d_numberOfNodes);
- d_nodes [d_numberOfNodes]. x = x;
- d_nodes [d_numberOfNodes]. y = y;
- d_nodes [d_numberOfNodes]. activity = d_nodes [d_numberOfNodes]. excitation = activity;
- d_nodes [d_numberOfNodes]. clamped = clamped;
+ NUMvector_append (& my nodes, 1, & my numberOfNodes);
+ my nodes [my numberOfNodes]. x = x;
+ my nodes [my numberOfNodes]. y = y;
+ my nodes [my numberOfNodes]. activity = my nodes [my numberOfNodes]. excitation = activity;
+ my nodes [my numberOfNodes]. clamped = clamped;
} catch (MelderError) {
- Melder_throw (this, ": node not added.");
+ Melder_throw (me, ": node not added.");
}
}
-void structNetwork :: f_addConnection (long nodeFrom, long nodeTo, double weight, double plasticity) {
+void Network_addConnection (Network me, long nodeFrom, long nodeTo, double weight, double plasticity) {
try {
- NUMvector_append (& d_connections, 1, & d_numberOfConnections);
- d_connections [d_numberOfConnections]. nodeFrom = nodeFrom;
- d_connections [d_numberOfConnections]. nodeTo = nodeTo;
- d_connections [d_numberOfConnections]. weight = weight;
- d_connections [d_numberOfConnections]. plasticity = plasticity;
+ NUMvector_append (& my connections, 1, & my numberOfConnections);
+ my connections [my numberOfConnections]. nodeFrom = nodeFrom;
+ my connections [my numberOfConnections]. nodeTo = nodeTo;
+ my connections [my numberOfConnections]. weight = weight;
+ my connections [my numberOfConnections]. plasticity = plasticity;
} catch (MelderError) {
- Melder_throw (this, ": connection not added.");
+ Melder_throw (me, ": connection not added.");
}
}
-void structNetwork :: f_setInstar (double instar) {
- d_instar = instar;
+void Network_setInstar (Network me, double instar) {
+ my instar = instar;
}
-void structNetwork :: f_setOutstar (double outstar) {
- d_outstar = outstar;
+void Network_setOutstar (Network me, double outstar) {
+ my outstar = outstar;
}
-void structNetwork :: f_setWeightLeak (double weightLeak) {
- d_weightLeak = weightLeak;
+void Network_setWeightLeak (Network me, double weightLeak) {
+ my weightLeak = weightLeak;
}
-void structNetwork :: f_setActivityLeak (double activityLeak) {
- d_activityLeak = activityLeak;
- f_zeroActivities (0, 0);
+void Network_setActivityLeak (Network me, double activityLeak) {
+ my activityLeak = activityLeak;
+ Network_zeroActivities (me, 0, 0);
}
-void structNetwork :: f_setShunting (double shunting) {
- d_shunting = shunting;
- f_zeroActivities (0, 0);
+void Network_setShunting (Network me, double shunting) {
+ my shunting = shunting;
+ Network_zeroActivities (me, 0, 0);
}
-void structNetwork :: f_setActivityClippingRule (enum kNetwork_activityClippingRule activityClippingRule) {
- d_activityClippingRule = activityClippingRule;
- f_zeroActivities (0, 0);
+void Network_setActivityClippingRule (Network me, enum kNetwork_activityClippingRule activityClippingRule) {
+ my activityClippingRule = activityClippingRule;
+ Network_zeroActivities (me, 0, 0);
}
-Table structNetwork :: f_nodes_downto_Table (long fromNodeNumber, long toNodeNumber,
+Table Network_nodes_downto_Table (Network me, long fromNodeNumber, long toNodeNumber,
bool includeNodeNumbers,
bool includeX, bool includeY, int positionDecimals,
bool includeClamped,
@@ -490,9 +490,9 @@ Table structNetwork :: f_nodes_downto_Table (long fromNodeNumber, long toNodeNum
{
try {
if (fromNodeNumber < 1) fromNodeNumber = 1;
- if (toNodeNumber > d_numberOfNodes) toNodeNumber = d_numberOfNodes;
+ if (toNodeNumber > my numberOfNodes) toNodeNumber = my numberOfNodes;
if (fromNodeNumber > toNodeNumber)
- fromNodeNumber = 1, toNodeNumber = d_numberOfNodes;
+ fromNodeNumber = 1, toNodeNumber = my numberOfNodes;
long numberOfNodes = toNodeNumber - fromNodeNumber + 1;
Melder_assert (numberOfNodes >= 1);
autoTable thee = Table_createWithoutColumnNames (numberOfNodes,
@@ -505,7 +505,7 @@ Table structNetwork :: f_nodes_downto_Table (long fromNodeNumber, long toNodeNum
if (includeActivity) Table_setColumnLabel (thee.peek(), ++ icol, L"activity");
if (includeExcitation) Table_setColumnLabel (thee.peek(), ++ icol, L"excitation");
for (long inode = fromNodeNumber; inode <= toNodeNumber; inode ++) {
- NetworkNode node = & d_nodes [inode];
+ NetworkNode node = & my nodes [inode];
icol = 0;
if (includeNodeNumbers) Table_setNumericValue (thee.peek(), inode, ++ icol, inode);
if (includeX) Table_setStringValue (thee.peek(), inode, ++ icol, Melder_fixed (node -> x, positionDecimals));
@@ -516,22 +516,22 @@ Table structNetwork :: f_nodes_downto_Table (long fromNodeNumber, long toNodeNum
}
return thee.transfer();
} catch (MelderError) {
- Melder_throw (this, ": not converted to Table.");
+ Melder_throw (me, ": not converted to Table.");
}
}
-void structNetwork :: f_listNodes (long fromNodeNumber, long toNodeNumber,
+void Network_listNodes (Network me, long fromNodeNumber, long toNodeNumber,
bool includeNodeNumbers,
bool includeX, bool includeY, int positionDecimals,
bool includeClamped,
bool includeActivity, bool includeExcitation, int activityDecimals)
{
try {
- autoTable table = f_nodes_downto_Table (fromNodeNumber, toNodeNumber, includeNodeNumbers,
+ autoTable table = Network_nodes_downto_Table (me, fromNodeNumber, toNodeNumber, includeNodeNumbers,
includeX, includeY, positionDecimals, includeClamped, includeActivity, includeExcitation, activityDecimals);
Table_list (table.peek(), false);
} catch (MelderError) {
- Melder_throw (this, ": not listed.");
+ Melder_throw (me, ": not listed.");
}
}
diff --git a/gram/Network.h b/gram/Network.h
index cfebbaa..0e18e7f 100644
--- a/gram/Network.h
+++ b/gram/Network.h
@@ -2,7 +2,7 @@
#define _Network_h_
/* Network.h
*
- * Copyright (C) 2009-2012,2013 Paul Boersma
+ * Copyright (C) 2009-2012,2013,2014 Paul Boersma
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,6 +26,12 @@
#include "Network_def.h"
oo_CLASS_CREATE (Network, Data);
+void Network_init (Network me,
+ double spreadingRate, enum kNetwork_activityClippingRule activityClippingRule,
+ double minimumActivity, double maximumActivity, double activityLeak,
+ double learningRate, double minimumWeight, double maximumWeight, double weightLeak,
+ double xmin, double xmax, double ymin, double ymax, long numberOfNodes, long numberOfConnections);
+
Network Network_create (double spreadingRate, enum kNetwork_activityClippingRule activityClippingRule,
double minimumActivity, double maximumActivity, double activityLeak,
double learningRate, double minimumWeight, double maximumWeight, double weightLeak,
@@ -36,11 +42,42 @@ Network Network_create_rectangle (double spreadingRate, enum kNetwork_activityCl
double learningRate, double minimumWeight, double maximumWeight, double weightLeak,
long numberOfRows, long numberOfColumns, bool bottomRowClamped,
double initialMinimumWeight, double initialMaximumWeight);
+
Network Network_create_rectangle_vertical (double spreadingRate, enum kNetwork_activityClippingRule activityClippingRule,
double minimumActivity, double maximumActivity, double activityLeak,
double learningRate, double minimumWeight, double maximumWeight, double weightLeak,
long numberOfRows, long numberOfColumns, bool bottomRowClamped,
double initialMinimumWeight, double initialMaximumWeight);
+void Network_addNode (Network me, double x, double y, double activity, bool clamped);
+void Network_addConnection (Network me, long fromNodeNumber, long toNodeNumber, double weight, double plasticity);
+void Network_draw (Network me, Graphics graphics, bool colour);
+double Network_getActivity (Network me, long nodeNumber);
+void Network_setActivity (Network me, long nodeNumber, double activity);
+double Network_getWeight (Network me, long connectionNumber);
+void Network_setWeight (Network me, long connectionNumber, double weight);
+void Network_setClamping (Network me, long nodeNumber, bool clamped);
+void Network_zeroActivities (Network me, long fromNodeNumber, long toNodeNumber);
+void Network_normalizeActivities (Network me, long fromNodeNumber, long toNodeNumber);
+void Network_spreadActivities (Network me, long numberOfSteps);
+void Network_updateWeights (Network me);
+void Network_normalizeWeights (Network me, long nodeMin, long nodeMax, long nodeFromMin, long nodeFromMax, double newSum);
+void Network_setInstar (Network me, double instar);
+void Network_setOutstar (Network me, double outstar);
+void Network_setWeightLeak (Network me, double weightLeak);
+void Network_setActivityLeak (Network me, double activityLeak);
+void Network_setShunting (Network me, double shunting);
+void Network_setActivityClippingRule (Network me, enum kNetwork_activityClippingRule activityClippingRule);
+Table Network_nodes_downto_Table (Network me, long fromNodeNumber, long toNodeNumber,
+ bool includeNodeNumbers,
+ bool includeX, bool includeY, int positionDecimals,
+ bool includeClamped,
+ bool includeActivity, bool includeExcitation, int activityDecimals);
+void Network_listNodes (Network me, long fromNodeNumber, long toNodeNumber,
+ bool includeNodeNumbers,
+ bool includeX, bool includeY, int positionDecimals,
+ bool includeClamped,
+ bool includeActivity, bool includeExcitation, int activityDecimals);
+
/* End of file Network.h */
#endif
diff --git a/gram/Network_def.h b/gram/Network_def.h
index eb98206..7173f64 100644
--- a/gram/Network_def.h
+++ b/gram/Network_def.h
@@ -1,6 +1,6 @@
/* Network_def.h
*
- * Copyright (C) 2009-2011,2012,2013 Paul Boersma
+ * Copyright (C) 2009-2011,2012,2013,2014 Paul Boersma
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -55,85 +55,49 @@ oo_END_STRUCT (NetworkConnection)
#define ooSTRUCT Network
oo_DEFINE_CLASS (Network, Data)
- oo_DOUBLE (d_minimumActivity)
- oo_DOUBLE (d_maximumActivity)
+ oo_DOUBLE (minimumActivity)
+ oo_DOUBLE (maximumActivity)
oo_FROM (3)
- oo_BYTE (d_dummyActivitySpreadingRule)
+ oo_BYTE (dummyActivitySpreadingRule)
oo_ENDFROM
oo_FROM (4)
- oo_DOUBLE (d_shunting)
- oo_ENUM (kNetwork_activityClippingRule, d_activityClippingRule)
+ oo_DOUBLE (shunting)
+ oo_ENUM (kNetwork_activityClippingRule, activityClippingRule)
oo_ENDFROM
- oo_DOUBLE (d_spreadingRate)
- oo_DOUBLE (d_activityLeak)
- oo_DOUBLE (d_minimumWeight)
- oo_DOUBLE (d_maximumWeight)
+ oo_DOUBLE (spreadingRate)
+ oo_DOUBLE (activityLeak)
+ oo_DOUBLE (minimumWeight)
+ oo_DOUBLE (maximumWeight)
oo_FROM (2)
- oo_BYTE (d_dummyWeightUpdateRule)
+ oo_BYTE (dummyWeightUpdateRule)
oo_ENDFROM
- oo_DOUBLE (d_learningRate)
+ oo_DOUBLE (learningRate)
oo_FROM (5)
- oo_DOUBLE (d_instar)
- oo_DOUBLE (d_outstar)
+ oo_DOUBLE (instar)
+ oo_DOUBLE (outstar)
oo_ENDFROM
- oo_DOUBLE (d_weightLeak)
+ oo_DOUBLE (weightLeak)
#if oo_READING
if (localVersion < 6) {
if (localVersion < 5) {
- if (d_learningRate != 0.0) d_weightLeak /= d_learningRate;
- if (d_dummyWeightUpdateRule == 1) d_instar = 1.0, d_outstar = 0.0;
- if (d_dummyWeightUpdateRule == 2) d_instar = 0.0, d_outstar = 1.0;
- if (d_dummyWeightUpdateRule == 3) d_instar = 0.5, d_outstar = 0.5;
+ if (our learningRate != 0.0) our weightLeak /= our learningRate;
+ if (our dummyWeightUpdateRule == 1) our instar = 1.0, our outstar = 0.0;
+ if (our dummyWeightUpdateRule == 2) our instar = 0.0, our outstar = 1.0;
+ if (our dummyWeightUpdateRule == 3) our instar = 0.5, our outstar = 0.5;
}
- d_activityLeak = - d_activityLeak; // convert self-excitation to activity leak
+ our activityLeak = - our activityLeak; // convert self-excitation to activity leak
}
#endif
- oo_DOUBLE (d_xmin)
- oo_DOUBLE (d_xmax)
- oo_DOUBLE (d_ymin)
- oo_DOUBLE (d_ymax)
- oo_LONG (d_numberOfNodes)
- oo_STRUCT_VECTOR (NetworkNode, d_nodes, d_numberOfNodes)
- oo_LONG (d_numberOfConnections)
- oo_STRUCT_VECTOR (NetworkConnection, d_connections, d_numberOfConnections)
+ oo_DOUBLE (xmin)
+ oo_DOUBLE (xmax)
+ oo_DOUBLE (ymin)
+ oo_DOUBLE (ymax)
+ oo_LONG (numberOfNodes)
+ oo_STRUCT_VECTOR (NetworkNode, nodes, numberOfNodes)
+ oo_LONG (numberOfConnections)
+ oo_STRUCT_VECTOR (NetworkConnection, connections, numberOfConnections)
#if oo_DECLARING
- // functions:
- void f_init (
- double spreadingRate, enum kNetwork_activityClippingRule activityClippingRule,
- double minimumActivity, double maximumActivity, double activityLeak,
- double learningRate, double minimumWeight, double maximumWeight, double weightLeak,
- double xmin, double xmax, double ymin, double ymax, long numberOfNodes, long numberOfConnections);
- void f_addNode (double x, double y, double activity, bool clamped);
- void f_addConnection (long nodeFrom, long nodeTo, double weight, double plasticity);
- void f_draw (Graphics graphics, bool colour);
- double f_getActivity (long inode);
- void f_setActivity (long inode, double activity);
- double f_getWeight (long iconn);
- void f_setWeight (long iconn, double weight);
- void f_setClamping (long inode, bool clamped);
- void f_zeroActivities (long nodeMin, long nodeMax);
- void f_normalizeActivities (long nodeMin, long nodeMax);
- void f_spreadActivities (long numberOfSteps);
- void f_updateWeights ();
- void f_normalizeWeights (long nodeMin, long nodeMax, long nodeFromMin, long nodeFromMax, double newSum);
- void f_setInstar (double instar);
- void f_setOutstar (double outstar);
- void f_setWeightLeak (double weightLeak);
- void f_setActivityLeak (double activityLeak);
- void f_setShunting (double shunting);
- void f_setActivityClippingRule (enum kNetwork_activityClippingRule activityClippingRule);
- Table f_nodes_downto_Table (long fromNodeNumber, long toNodeNumber,
- bool includeNodeNumbers,
- bool includeX, bool includeY, int positionDecimals,
- bool includeClamped,
- bool includeActivity, bool includeExcitation, int activityDecimals);
- void f_listNodes (long fromNodeNumber, long toNodeNumber,
- bool includeNodeNumbers,
- bool includeX, bool includeY, int positionDecimals,
- bool includeClamped,
- bool includeActivity, bool includeExcitation, int activityDecimals);
-
// overridden methods:
virtual void v_info ();
#endif
diff --git a/gram/OTGrammar.cpp b/gram/OTGrammar.cpp
index 0e19b4a..4fdea50 100644
--- a/gram/OTGrammar.cpp
+++ b/gram/OTGrammar.cpp
@@ -2009,7 +2009,7 @@ void OTGrammar_learnOneFromPartialOutput (OTGrammar me, const wchar_t *partialAd
static void OTGrammar_learnOneFromPartialOutput_opt (OTGrammar me, const wchar_t *partialAdultOutput, long ipartialAdultOutput,
double evaluationNoise, enum kOTGrammar_rerankingStrategy updateRule, int honourLocalRankings,
double plasticity, double relativePlasticityNoise, long numberOfChews, int warnIfStalled,
- bool resampleForVirtualProduction, bool compareOnlyPartialOutput)
+ bool resampleForVirtualProduction, bool compareOnlyPartialOutput, long resampleForCorrectForm)
{
try {
OTGrammar_newDisharmonies (me, evaluationNoise);
@@ -2039,25 +2039,27 @@ static void OTGrammar_learnOneFromPartialOutput_opt (OTGrammar me, const wchar_t
} else {
if (wcsequ (winner -> output, assumedCorrect -> output)) return; // as far as we know, the grammar is already correct: don't update rankings
}
-
- /*
- * Find (perhaps the learner's interpretation of) the adult output in the learner's own tableau
- * (Tesar & Smolensky call this the "winner").
- */
- long iadult = 1;
- for (; iadult <= tableau -> numberOfCandidates; iadult ++) {
- OTGrammarCandidate cand = & tableau -> candidates [iadult];
- if (wcsequ (cand -> output, assumedCorrect -> output)) break;
+ if (resampleForCorrectForm) {
+ long itry = 1;
+ for (; itry <= resampleForCorrectForm; itry ++) {
+ OTGrammar_newDisharmonies (me, evaluationNoise);
+ long iwinner2 = OTGrammar_getWinner (me, assumedAdultInputTableau);
+ OTGrammarCandidate winner2 = & tableau -> candidates [iwinner2];
+ if (compareOnlyPartialOutput) {
+ if (wcsstr (winner2 -> output, partialAdultOutput)) { assumedAdultCandidate = iwinner2; break; }
+ } else {
+ if (wcsequ (winner2 -> output, assumedCorrect -> output)) { assumedAdultCandidate = iwinner2; break; }
+ }
+ }
+ if (itry > resampleForCorrectForm) return; // no match, so bail out
}
- if (iadult > tableau -> numberOfCandidates)
- Melder_throw ("Cannot generate adult output \"", assumedCorrect -> output, L"\".");
/*
* Now we know that the current hypothesis prefers the (wrong) learner's winner over the (correct) adult output.
* The grammar will have to change.
*/
int grammarHasChanged = FALSE;
- OTGrammar_modifyRankings (me, assumedAdultInputTableau, iwinner, iadult, updateRule, honourLocalRankings,
+ OTGrammar_modifyRankings (me, assumedAdultInputTableau, iwinner, assumedAdultCandidate, updateRule, honourLocalRankings,
plasticity, relativePlasticityNoise, warnIfStalled, & grammarHasChanged);
if (! grammarHasChanged) return;
}
@@ -2225,7 +2227,7 @@ void OTGrammar_Distributions_learnFromPartialOutputs (OTGrammar me, Distribution
double initialPlasticity, long replicationsPerPlasticity, double plasticityDecrement,
long numberOfPlasticities, double relativePlasticityNoise, long numberOfChews,
long storeHistoryEvery, OTHistory *history_out,
- bool resampleForVirtualProduction, bool compareOnlyPartialOutput)
+ bool resampleForVirtualProduction, bool compareOnlyPartialOutput, long resampleForCorrectForm)
{
long idatum = 0;
const long numberOfData = numberOfPlasticities * replicationsPerPlasticity;
@@ -2263,7 +2265,7 @@ void OTGrammar_Distributions_learnFromPartialOutputs (OTGrammar me, Distribution
OTGrammar_learnOneFromPartialOutput_opt (me, partialOutput, ipartialOutput,
evaluationNoise, updateRule, honourLocalRankings,
plasticity, relativePlasticityNoise, numberOfChews, FALSE,
- resampleForVirtualProduction, compareOnlyPartialOutput); // no warning if stalled: RIP form is allowed to be harmonically bounded
+ resampleForVirtualProduction, compareOnlyPartialOutput, resampleForCorrectForm); // no warning if stalled: RIP form is allowed to be harmonically bounded
} catch (MelderError) {
if (history.peek()) {
OTGrammar_updateHistory (me, history.peek(), storeHistoryEvery, idatum, thy rowLabels [ipartialOutput]);
@@ -2804,7 +2806,7 @@ void OTGrammar_Distributions_listObligatoryRankings (OTGrammar me, Distributions
Melder_progressOff ();
OTGrammar_Distributions_learnFromPartialOutputs (me, thee, columnNumber,
1e-9, kOTGrammar_rerankingStrategy_EDCD, TRUE /* honour fixed rankings; very important */,
- 1.0, 1000, 0.0, 1, 0.0, 1, 0, NULL, false, false);
+ 1.0, 1000, 0.0, 1, 0.0, 1, 0, NULL, false, false, 0);
Melder_progressOn ();
for (kcons = 1; kcons <= my numberOfConstraints; kcons ++) {
if (my constraints [kcons]. ranking < 0.0) {
diff --git a/gram/OTGrammar.h b/gram/OTGrammar.h
index a6f8266..0db7640 100644
--- a/gram/OTGrammar.h
+++ b/gram/OTGrammar.h
@@ -114,7 +114,7 @@ void OTGrammar_Distributions_learnFromPartialOutputs (OTGrammar me, Distribution
double initialPlasticity, long replicationsPerPlasticity, double plasticityDecrement,
long numberOfPlasticities, double relativePlasticityNoise, long numberOfChews,
long storeHistoryEvery, OTHistory *history_out,
- bool resampleForVirtualProduction, bool compareOnlyPartialOutput);
+ bool resampleForVirtualProduction, bool compareOnlyPartialOutput, long resampleForCorrectForm);
double OTGrammar_PairDistribution_getFractionCorrect (OTGrammar me, PairDistribution thee,
double evaluationNoise, long numberOfInputs);
long OTGrammar_PairDistribution_getMinimumNumberCorrect (OTGrammar me, PairDistribution thee,
diff --git a/gram/praat_gram.cpp b/gram/praat_gram.cpp
index 447ed83..43eef21 100644
--- a/gram/praat_gram.cpp
+++ b/gram/praat_gram.cpp
@@ -119,7 +119,7 @@ DO
autoPraatPicture picture;
LOOP {
iam_LOOP (Network);
- me -> f_draw (GRAPHICS, GET_INTEGER (L"Colour"));
+ Network_draw (me, GRAPHICS, GET_INTEGER (L"Colour"));
}
END2 }
@@ -140,7 +140,7 @@ FORM (Network_listNodes, L"Network: List nodes", 0) {
DO
LOOP {
iam (Network);
- my f_listNodes (GET_INTEGER (L"From node number"), GET_INTEGER (L"To node number"),
+ Network_listNodes (me, GET_INTEGER (L"From node number"), GET_INTEGER (L"To node number"),
GET_INTEGER (L"Include node numbers"),
GET_INTEGER (L"Include x"), GET_INTEGER (L"Include y"), GET_INTEGER (L"Position decimals"),
GET_INTEGER (L"Include clamped"),
@@ -163,7 +163,7 @@ FORM (Network_nodes_downto_Table, L"Network: Nodes down to Table", 0) {
DO
LOOP {
iam (Network);
- autoTable thee = my f_nodes_downto_Table (GET_INTEGER (L"From node number"), GET_INTEGER (L"To node number"),
+ autoTable thee = Network_nodes_downto_Table (me, GET_INTEGER (L"From node number"), GET_INTEGER (L"To node number"),
GET_INTEGER (L"Include node numbers"),
GET_INTEGER (L"Include x"), GET_INTEGER (L"Include y"), GET_INTEGER (L"Position decimals"),
GET_INTEGER (L"Include clamped"),
@@ -179,7 +179,7 @@ FORM (Network_getActivity, L"Network: Get activity", 0) {
OK2
DO
iam_ONLY (Network);
- double activity = me -> f_getActivity (GET_INTEGER (L"Node"));
+ double activity = Network_getActivity (me, GET_INTEGER (L"Node"));
Melder_information (Melder_double (activity));
END2 }
@@ -188,7 +188,7 @@ FORM (Network_getWeight, L"Network: Get weight", 0) {
OK2
DO
iam_ONLY (Network);
- double weight = me -> f_getWeight (GET_INTEGER (L"Connection"));
+ double weight = Network_getWeight (me, GET_INTEGER (L"Connection"));
Melder_information (Melder_double (weight));
END2 }
@@ -203,7 +203,7 @@ FORM (Network_addConnection, L"Network: Add connection", 0) {
DO
LOOP {
iam_LOOP (Network);
- me -> f_addConnection (GET_INTEGER (L"From node"), GET_INTEGER (L"To node"), GET_REAL (L"Weight"), GET_REAL (L"Plasticity"));
+ Network_addConnection (me, GET_INTEGER (L"From node"), GET_INTEGER (L"To node"), GET_REAL (L"Weight"), GET_REAL (L"Plasticity"));
praat_dataChanged (me);
}
END2 }
@@ -217,7 +217,7 @@ FORM (Network_addNode, L"Network: Add node", 0) {
DO
LOOP {
iam_LOOP (Network);
- me -> f_addNode (GET_REAL (L"x"), GET_REAL (L"y"), GET_REAL (L"Activity"), GET_INTEGER (L"Clamping"));
+ Network_addNode (me, GET_REAL (L"x"), GET_REAL (L"y"), GET_REAL (L"Activity"), GET_INTEGER (L"Clamping"));
praat_dataChanged (me);
}
END2 }
@@ -229,7 +229,7 @@ FORM (Network_normalizeActivities, L"Network: Normalize activities", 0) {
DO
LOOP {
iam_LOOP (Network);
- me -> f_normalizeActivities (GET_INTEGER (L"From node"), GET_INTEGER (L"To node"));
+ Network_normalizeActivities (me, GET_INTEGER (L"From node"), GET_INTEGER (L"To node"));
praat_dataChanged (me);
}
END2 }
@@ -244,7 +244,7 @@ FORM (Network_normalizeWeights, L"Network: Normalize weights", 0) {
DO
LOOP {
iam_LOOP (Network);
- me -> f_normalizeWeights (GET_INTEGER (L"From node"), GET_INTEGER (L"To node"),
+ Network_normalizeWeights (me, GET_INTEGER (L"From node"), GET_INTEGER (L"To node"),
GET_INTEGER (L"From incoming node"), GET_INTEGER (L"To incoming node"), GET_REAL (L"New sum"));
praat_dataChanged (me);
}
@@ -257,7 +257,7 @@ FORM (Network_setActivity, L"Network: Set activity", 0) {
DO
LOOP {
iam_LOOP (Network);
- me -> f_setActivity (GET_INTEGER (L"Node"), GET_REAL (L"Activity"));
+ Network_setActivity (me, GET_INTEGER (L"Node"), GET_REAL (L"Activity"));
praat_dataChanged (me);
}
END2 }
@@ -266,10 +266,10 @@ FORM (Network_setActivityClippingRule, L"Network: Set activity clipping rule", 0
RADIO_ENUM (L"Activity clipping rule", kNetwork_activityClippingRule, DEFAULT)
OK2
iam_ONLY (Network);
-SET_ENUM (L"Activity clipping rule", kNetwork_activityClippingRule, my d_activityClippingRule);
+SET_ENUM (L"Activity clipping rule", kNetwork_activityClippingRule, my activityClippingRule);
DO
iam_ONLY (Network);
- me -> f_setActivityClippingRule (GET_ENUM (kNetwork_activityClippingRule, L"Activity clipping rule"));
+ Network_setActivityClippingRule (me, GET_ENUM (kNetwork_activityClippingRule, L"Activity clipping rule"));
praat_dataChanged (me);
END2 }
@@ -277,10 +277,10 @@ FORM (Network_setActivityLeak, L"Network: Set activity leak", 0) {
REAL (L"Activity leak", L"1.0")
OK2
iam_ONLY (Network);
-SET_REAL (L"Activity leak", my d_activityLeak);
+SET_REAL (L"Activity leak", my activityLeak);
DO
iam_ONLY (Network);
- me -> f_setActivityLeak (GET_REAL (L"Activity leak"));
+ Network_setActivityLeak (me, GET_REAL (L"Activity leak"));
praat_dataChanged (me);
END2 }
@@ -291,7 +291,7 @@ FORM (Network_setClamping, L"Network: Set clamping", 0) {
DO
LOOP {
iam_LOOP (Network);
- me -> f_setClamping (GET_INTEGER (L"Node"), GET_INTEGER (L"Clamping"));
+ Network_setClamping (me, GET_INTEGER (L"Node"), GET_INTEGER (L"Clamping"));
praat_dataChanged (me);
}
END2 }
@@ -300,10 +300,10 @@ FORM (Network_setInstar, L"Network: Set instar", 0) {
REAL (L"Instar", L"0.0")
OK2
iam_ONLY (Network);
-SET_REAL (L"Instar", my d_instar);
+SET_REAL (L"Instar", my instar);
DO
iam_ONLY (Network);
- me -> f_setInstar (GET_REAL (L"Instar"));
+ Network_setInstar (me, GET_REAL (L"Instar"));
praat_dataChanged (me);
END2 }
@@ -311,10 +311,10 @@ FORM (Network_setWeightLeak, L"Network: Set weight leak", 0) {
REAL (L"Weight leak", L"0.0")
OK2
iam_ONLY (Network);
-SET_REAL (L"Weight leak", my d_weightLeak);
+SET_REAL (L"Weight leak", my weightLeak);
DO
iam_ONLY (Network);
- me -> f_setWeightLeak (GET_REAL (L"Weight leak"));
+ Network_setWeightLeak (me, GET_REAL (L"Weight leak"));
praat_dataChanged (me);
END2 }
@@ -322,10 +322,10 @@ FORM (Network_setOutstar, L"Network: Set outstar", 0) {
REAL (L"Outstar", L"0.0")
OK2
iam_ONLY (Network);
-SET_REAL (L"Outstar", my d_outstar);
+SET_REAL (L"Outstar", my outstar);
DO
iam_ONLY (Network);
- me -> f_setOutstar (GET_REAL (L"Outstar"));
+ Network_setOutstar (me, GET_REAL (L"Outstar"));
praat_dataChanged (me);
END2 }
@@ -335,7 +335,7 @@ FORM (Network_setShunting, L"Network: Set shunting", 0) {
DO
LOOP {
iam_LOOP (Network);
- me -> f_setShunting (GET_REAL (L"Shunting"));
+ Network_setShunting (me, GET_REAL (L"Shunting"));
praat_dataChanged (me);
}
END2 }
@@ -347,7 +347,7 @@ FORM (Network_setWeight, L"Network: Set weight", 0) {
DO
LOOP {
iam_LOOP (Network);
- me -> f_setWeight (GET_INTEGER (L"Connection"), GET_REAL (L"Weight"));
+ Network_setWeight (me, GET_INTEGER (L"Connection"), GET_REAL (L"Weight"));
praat_dataChanged (me);
}
END2 }
@@ -358,7 +358,7 @@ FORM (Network_spreadActivities, L"Network: Spread activities", 0) {
DO
LOOP {
iam_LOOP (Network);
- me -> f_spreadActivities (GET_INTEGER (L"Number of steps"));
+ Network_spreadActivities (me, GET_INTEGER (L"Number of steps"));
praat_dataChanged (me);
}
END2 }
@@ -366,7 +366,7 @@ END2 }
DIRECT2 (Network_updateWeights) {
LOOP {
iam_LOOP (Network);
- me -> f_updateWeights ();
+ Network_updateWeights (me);
praat_dataChanged (me);
}
END2 }
@@ -378,7 +378,7 @@ FORM (Network_zeroActivities, L"Network: Zero activities", 0) {
DO
LOOP {
iam (Network);
- me -> f_zeroActivities (GET_INTEGER (L"From node"), GET_INTEGER (L"To node"));
+ Network_zeroActivities (me, GET_INTEGER (L"From node"), GET_INTEGER (L"To node"));
praat_dataChanged (me);
}
END2 }
@@ -1077,7 +1077,7 @@ DO
GET_REAL (L"Initial plasticity"), GET_INTEGER (L"Replications per plasticity"),
GET_REAL (L"Plasticity decrement"), GET_INTEGER (L"Number of plasticities"),
GET_REAL (L"Rel. plasticity spreading"), GET_INTEGER (L"Number of chews"),
- GET_INTEGER (L"Store history every"), & history, false, false);
+ GET_INTEGER (L"Store history every"), & history, false, false, 0);
praat_dataChanged (me);
} catch (MelderError) {
praat_dataChanged (me);
@@ -1111,7 +1111,75 @@ DO
GET_REAL (L"Initial plasticity"), GET_INTEGER (L"Replications per plasticity"),
GET_REAL (L"Plasticity decrement"), GET_INTEGER (L"Number of plasticities"),
GET_REAL (L"Rel. plasticity spreading"), GET_INTEGER (L"Number of chews"),
- GET_INTEGER (L"Store history every"), & history, true, true);
+ GET_INTEGER (L"Store history every"), & history, true, true, 0);
+ praat_dataChanged (me);
+ } catch (MelderError) {
+ praat_dataChanged (me);
+ Melder_flushError (NULL);
+ }
+ if (history) praat_new (history, my name);
+END2 }
+
+FORM (OTGrammar_Distributions_learnFromPartialOutputs_eip, L"OTGrammar & Distributions: Learn from partial outputs (eip)", L"OT learning 6. Shortcut to grammar learning") {
+ NATURAL (L"Column number", L"1")
+ REAL (L"Evaluation noise", L"2.0")
+ OPTIONMENU_ENUM (L"Update rule", kOTGrammar_rerankingStrategy, SYMMETRIC_ALL)
+ REAL (L"Initial plasticity", L"1.0")
+ NATURAL (L"Replications per plasticity", L"100000")
+ REAL (L"Plasticity decrement", L"0.1")
+ NATURAL (L"Number of plasticities", L"4")
+ REAL (L"Rel. plasticity spreading", L"0.1")
+ BOOLEAN (L"Honour local rankings", 1)
+ NATURAL (L"Number of chews", L"1")
+ INTEGER (L"Store history every", L"0")
+ OK2
+DO
+ iam_ONLY (OTGrammar);
+ thouart_ONLY (Distributions);
+ OTHistory history = NULL;
+ try {
+ OTGrammar_Distributions_learnFromPartialOutputs (me, thee, GET_INTEGER (L"Column number"),
+ GET_REAL (L"Evaluation noise"),
+ GET_ENUM (kOTGrammar_rerankingStrategy, L"Update rule"),
+ GET_INTEGER (L"Honour local rankings"),
+ GET_REAL (L"Initial plasticity"), GET_INTEGER (L"Replications per plasticity"),
+ GET_REAL (L"Plasticity decrement"), GET_INTEGER (L"Number of plasticities"),
+ GET_REAL (L"Rel. plasticity spreading"), GET_INTEGER (L"Number of chews"),
+ GET_INTEGER (L"Store history every"), & history, true, true, 1000);
+ praat_dataChanged (me);
+ } catch (MelderError) {
+ praat_dataChanged (me);
+ Melder_flushError (NULL);
+ }
+ if (history) praat_new (history, my name);
+END2 }
+
+FORM (OTGrammar_Distributions_learnFromPartialOutputs_wrip, L"OTGrammar & Distributions: Learn from partial outputs (wrip)", L"OT learning 6. Shortcut to grammar learning") {
+ NATURAL (L"Column number", L"1")
+ REAL (L"Evaluation noise", L"2.0")
+ OPTIONMENU_ENUM (L"Update rule", kOTGrammar_rerankingStrategy, SYMMETRIC_ALL)
+ REAL (L"Initial plasticity", L"1.0")
+ NATURAL (L"Replications per plasticity", L"100000")
+ REAL (L"Plasticity decrement", L"0.1")
+ NATURAL (L"Number of plasticities", L"4")
+ REAL (L"Rel. plasticity spreading", L"0.1")
+ BOOLEAN (L"Honour local rankings", 1)
+ NATURAL (L"Number of chews", L"1")
+ INTEGER (L"Store history every", L"0")
+ OK2
+DO
+ iam_ONLY (OTGrammar);
+ thouart_ONLY (Distributions);
+ OTHistory history = NULL;
+ try {
+ OTGrammar_Distributions_learnFromPartialOutputs (me, thee, GET_INTEGER (L"Column number"),
+ GET_REAL (L"Evaluation noise"),
+ GET_ENUM (kOTGrammar_rerankingStrategy, L"Update rule"),
+ GET_INTEGER (L"Honour local rankings"),
+ GET_REAL (L"Initial plasticity"), GET_INTEGER (L"Replications per plasticity"),
+ GET_REAL (L"Plasticity decrement"), GET_INTEGER (L"Number of plasticities"),
+ GET_REAL (L"Rel. plasticity spreading"), GET_INTEGER (L"Number of chews"),
+ GET_INTEGER (L"Store history every"), & history, true, true, 1);
praat_dataChanged (me);
} catch (MelderError) {
praat_dataChanged (me);
@@ -1677,6 +1745,8 @@ void praat_uvafon_gram_init (void) {
praat_addAction2 (classOTGrammar, 1, classStrings, 2, L"Learn...", 0, 0, DO_OTGrammar_Stringses_learn);
praat_addAction2 (classOTGrammar, 1, classDistributions, 1, L"Learn from partial outputs...", 0, 0, DO_OTGrammar_Distributions_learnFromPartialOutputs);
praat_addAction2 (classOTGrammar, 1, classDistributions, 1, L"Learn from partial outputs (rrip)...", 0, 0, DO_OTGrammar_Distributions_learnFromPartialOutputs_rrip);
+ praat_addAction2 (classOTGrammar, 1, classDistributions, 1, L"Learn from partial outputs (eip)...", 0, 0, DO_OTGrammar_Distributions_learnFromPartialOutputs_eip);
+ praat_addAction2 (classOTGrammar, 1, classDistributions, 1, L"Learn from partial outputs (wrip)...", 0, 0, DO_OTGrammar_Distributions_learnFromPartialOutputs_wrip);
praat_addAction2 (classOTGrammar, 1, classDistributions, 1, L"Get fraction correct...", 0, 0, DO_OTGrammar_Distributions_getFractionCorrect);
praat_addAction2 (classOTGrammar, 1, classDistributions, 1, L"List obligatory rankings...", 0, praat_HIDDEN, DO_OTGrammar_Distributions_listObligatoryRankings);
praat_addAction2 (classOTGrammar, 1, classPairDistribution, 1, L"Learn...", 0, 0, DO_OTGrammar_PairDistribution_learn);
diff --git a/stat/Table_def.h b/stat/Table_def.h
index 8bc829f..2939c65 100644
--- a/stat/Table_def.h
+++ b/stat/Table_def.h
@@ -64,7 +64,7 @@ oo_DEFINE_CLASS (Table, Data)
#if oo_DECLARING
// functions:
- TableRow f_peekRow (long i) { return static_cast <TableRow> (rows -> item [i]); }
+ TableRow row (long i) { return static_cast <TableRow> (rows -> item [i]); }
// overridden methods:
virtual void v_info ();
virtual bool v_hasGetNrow () { return true; } virtual double v_getNrow () { return rows -> size; }
diff --git a/sys/Editor.cpp b/sys/Editor.cpp
index ed5b092..000e5ee 100644
--- a/sys/Editor.cpp
+++ b/sys/Editor.cpp
@@ -43,9 +43,9 @@ Thing_implement (Editor, Thing, 0);
Thing_implement (EditorCommand, Thing, 0);
void structEditorCommand :: v_destroy () {
- Melder_free (itemTitle);
- Melder_free (script);
- forget (d_uiform);
+ Melder_free (our itemTitle);
+ Melder_free (our script);
+ forget (our d_uiform);
EditorCommand_Parent :: v_destroy ();
}
@@ -54,8 +54,8 @@ void structEditorCommand :: v_destroy () {
Thing_implement (EditorMenu, Thing, 0);
void structEditorMenu :: v_destroy () {
- Melder_free (menuTitle);
- forget (commands);
+ Melder_free (our menuTitle);
+ forget (our commands);
EditorMenu_Parent :: v_destroy ();
}
@@ -248,29 +248,29 @@ void structEditor :: v_destroy () {
void structEditor :: v_info () {
MelderInfo_writeLine (L"Editor type: ", Thing_className (this));
- MelderInfo_writeLine (L"Editor name: ", name ? name : L"<no name>");
+ MelderInfo_writeLine (L"Editor name: ", our name ? our name : L"<no name>");
time_t today = time (NULL);
MelderInfo_writeLine (L"Date: ", Melder_peekUtf8ToWcs (ctime (& today))); // includes a newline
- if (data) {
- MelderInfo_writeLine (L"Data type: ", data -> classInfo -> className);
- MelderInfo_writeLine (L"Data name: ", data -> name);
+ if (our data) {
+ MelderInfo_writeLine (L"Data type: ", our data -> classInfo -> className);
+ MelderInfo_writeLine (L"Data name: ", our data -> name);
}
}
void structEditor :: v_nameChanged () {
- if (name)
- d_windowForm -> f_setTitle (name);
+ if (our name)
+ our d_windowForm -> f_setTitle (our name);
}
void structEditor :: v_saveData () {
- if (! data) return;
- forget (previousData);
- previousData = Data_copy (data);
+ if (! our data) return;
+ forget (our previousData);
+ our previousData = Data_copy (our data);
}
void structEditor :: v_restoreData () {
- if (data && previousData)
- Thing_swap (data, previousData);
+ if (our data && our previousData)
+ Thing_swap (our data, our previousData);
}
static void menu_cb_sendBackToCallingProgram (EDITOR_ARGS) {
@@ -280,7 +280,7 @@ static void menu_cb_sendBackToCallingProgram (EDITOR_ARGS) {
structMelderFile file;
MelderDir_getFile (& praatDir, L"praat_backToCaller.Data", & file);
Data_writeToBinaryFile (my data, & file);
- sendsocket (my callbackSocket, NULL);
+ sendsocket (my callbackSocket, Melder_peekWcsToUtf8 (my data -> name));
}
my v_goAway ();
}
@@ -335,8 +335,8 @@ void structEditor :: v_createMenuItems_file (EditorMenu menu) {
}
void structEditor :: v_createMenuItems_edit (EditorMenu menu) {
- if (data)
- undoButton = EditorMenu_addCommand (menu, L"Cannot undo", GuiMenu_INSENSITIVE + 'Z', menu_cb_undo);
+ if (our data)
+ our undoButton = EditorMenu_addCommand (menu, L"Cannot undo", GuiMenu_INSENSITIVE + 'Z', menu_cb_undo);
}
static void menu_cb_settingsReport (EDITOR_ARGS) {
diff --git a/sys/GraphicsScreen.cpp b/sys/GraphicsScreen.cpp
index 867f8e2..db771b7 100644
--- a/sys/GraphicsScreen.cpp
+++ b/sys/GraphicsScreen.cpp
@@ -86,7 +86,6 @@ void structGraphicsScreen :: v_destroy () {
if (d_gdiGraphicsContext != NULL) {
SelectPen (d_gdiGraphicsContext, GetStockPen (BLACK_PEN));
SelectBrush (d_gdiGraphicsContext, GetStockBrush (NULL_BRUSH));
- d_gdiGraphicsContext = NULL;
}
if (d_winPen != NULL) {
DeleteObject (d_winPen);
@@ -107,6 +106,7 @@ void structGraphicsScreen :: v_destroy () {
BITMAP bitmap;
GetObject (d_gdiBitmap, sizeof (BITMAP), & bitmap);
int width = bitmap. bmWidth, height = bitmap. bmHeight;
+ //int width = 3600, height = 3600;
trace ("width %d, height %d", width, height);
/*
@@ -168,11 +168,14 @@ void structGraphicsScreen :: v_destroy () {
//GlobalUnlock (handle);
//GlobalFree (handle);
DeleteObject (d_gdiBitmap);
+ Melder_assert (d_gdiGraphicsContext);
+ DeleteDC (d_gdiGraphicsContext); // this was a memory leak before 5.3.83
}
/*
* No ReleaseDC here, because we have not created it ourselves,
- * not even with GetDC.
+ * not even with GetDC. Is this a BUG?
*/
+ d_gdiGraphicsContext = NULL;
#elif mac
#if useCarbon
if (d_macPort == NULL && ! d_isPng) {
@@ -668,6 +671,8 @@ Graphics Graphics_create_pngfile (MelderFile file, int resolution,
Melder_assert (my d_gdiGraphicsContext != NULL);
my d_gdiBitmap = CreateCompatibleBitmap (screenDC, (x2inches - x1inches) * resolution, (y2inches - y1inches) * resolution);
trace ("d_gdiBitmap %p", my d_gdiBitmap);
+ Melder_assert (my d_gdiBitmap != NULL);
+ ReleaseDC (NULL, screenDC);
SelectObject (my d_gdiGraphicsContext, my d_gdiBitmap);
trace ("bitmap selected into device context");
my resolution = resolution;
diff --git a/sys/Graphics_linesAndAreas.cpp b/sys/Graphics_linesAndAreas.cpp
index 650d519..a293a6a 100644
--- a/sys/Graphics_linesAndAreas.cpp
+++ b/sys/Graphics_linesAndAreas.cpp
@@ -160,22 +160,22 @@ void structGraphicsScreen :: v_polyline (long numberOfPoints, double *xyDC, bool
#if ALLOW_GDK_DRAWING
gdkPrepareLine (this);
for (long i = 0; i < numberOfPoints - 1; i ++) {
- gdk_draw_line (d_window, d_gdkGraphicsContext,
+ gdk_draw_line (our d_window, our d_gdkGraphicsContext,
xyDC [i + i], xyDC [i + i + 1], xyDC [i + i + 2], xyDC [i + i + 3]);
}
gdkRevertLine (this);
gdk_flush ();
#endif
} else {
- if (d_cairoGraphicsContext == NULL) return;
+ if (our d_cairoGraphicsContext == NULL) return;
cairoPrepareLine (this);
// cairo_new_path (d_cairoGraphicsContext); // move_to() automatically creates a new path
- cairo_move_to (d_cairoGraphicsContext, xyDC [0], xyDC [1]);
+ cairo_move_to (our d_cairoGraphicsContext, xyDC [0], xyDC [1]);
for (long i = 1; i < numberOfPoints; i ++) {
- cairo_line_to (d_cairoGraphicsContext, xyDC [i + i], xyDC [i + i + 1]);
+ cairo_line_to (our d_cairoGraphicsContext, xyDC [i + i], xyDC [i + i + 1]);
}
- if (close) cairo_close_path (d_cairoGraphicsContext);
- cairo_stroke (d_cairoGraphicsContext);
+ if (close) cairo_close_path (our d_cairoGraphicsContext);
+ cairo_stroke (our d_cairoGraphicsContext);
cairoRevertLine (this);
}
#elif win
@@ -188,34 +188,34 @@ void structGraphicsScreen :: v_polyline (long numberOfPoints, double *xyDC, bool
}
if (close)
points [numberOfPoints] = points [0];
- Polyline (d_gdiGraphicsContext, points, numberOfPoints + close);
- if (d_fatNonSolid) {
+ Polyline (our d_gdiGraphicsContext, points, numberOfPoints + close);
+ if (our d_fatNonSolid) {
for (long i = 0; i < numberOfPoints; i ++)
points [i]. x -= 1;
if (close)
points [numberOfPoints] = points [0];
- Polyline (d_gdiGraphicsContext, points, numberOfPoints + close);
+ Polyline (our d_gdiGraphicsContext, points, numberOfPoints + close);
for (long i = 0; i < numberOfPoints; i ++) {
points [i]. x += 1;
points [i]. y -= 1;
}
if (close)
points [numberOfPoints] = points [0];
- Polyline (d_gdiGraphicsContext, points, numberOfPoints + close);
+ Polyline (our d_gdiGraphicsContext, points, numberOfPoints + close);
}
}
DEFAULT
#elif mac
GraphicsQuartz_initDraw (this);
quartzPrepareLine (this);
- CGContextBeginPath (d_macGraphicsContext);
- CGContextMoveToPoint (d_macGraphicsContext, xyDC [0], xyDC [1]); // starts a new subpath
+ CGContextBeginPath (our d_macGraphicsContext);
+ CGContextMoveToPoint (our d_macGraphicsContext, xyDC [0], xyDC [1]); // starts a new subpath
for (long i = 1; i < numberOfPoints; i ++) {
- CGContextAddLineToPoint (d_macGraphicsContext, xyDC [i + i], xyDC [i + i + 1]);
+ CGContextAddLineToPoint (our d_macGraphicsContext, xyDC [i + i], xyDC [i + i + 1]);
}
if (close)
- CGContextClosePath (d_macGraphicsContext); // closes only the subpath
- CGContextStrokePath (d_macGraphicsContext);
+ CGContextClosePath (our d_macGraphicsContext); // closes only the subpath
+ CGContextStrokePath (our d_macGraphicsContext);
quartzRevertLine (this);
GraphicsQuartz_exitDraw (this);
#endif
@@ -224,44 +224,44 @@ void structGraphicsScreen :: v_polyline (long numberOfPoints, double *xyDC, bool
void structGraphicsPostscript :: v_polyline (long numberOfPoints, double *xyDC, bool close) {
long nn = 2 * numberOfPoints;
psPrepareLine (this);
- d_printf (d_file, "N %.7g %.7g moveto\n", xyDC [0], xyDC [1]);
+ our d_printf (our d_file, "N %.7g %.7g moveto\n", xyDC [0], xyDC [1]);
for (long i = 2; i < nn; i += 2) {
double dx = xyDC [i] - xyDC [i - 2], dy = xyDC [i + 1] - xyDC [i - 1];
- d_printf (d_file, "%.7g %.7g L\n", dx, dy);
+ our d_printf (our d_file, "%.7g %.7g L\n", dx, dy);
}
if (close)
- d_printf (d_file, "closepath ");
- d_printf (d_file, "stroke\n");
+ our d_printf (our d_file, "closepath ");
+ our d_printf (our d_file, "stroke\n");
psRevertLine (this);
}
void structGraphicsScreen :: v_fillArea (long numberOfPoints, double *xyDC) {
#if cairo
- if (d_cairoGraphicsContext == NULL) return;
- // cairo_new_path (d_cairoGraphicsContext); // move_to() automatically creates a new path
- cairo_move_to (d_cairoGraphicsContext, xyDC [0], xyDC [1]);
+ if (our d_cairoGraphicsContext == NULL) return;
+ // cairo_new_path (our d_cairoGraphicsContext); // move_to() automatically creates a new path
+ cairo_move_to (our d_cairoGraphicsContext, xyDC [0], xyDC [1]);
for (long i = 1; i < numberOfPoints; i ++)
- cairo_line_to (d_cairoGraphicsContext, xyDC [i + i], xyDC [i + i + 1]);
- cairo_close_path (d_cairoGraphicsContext);
- cairo_fill (d_cairoGraphicsContext);
+ cairo_line_to (our d_cairoGraphicsContext, xyDC [i + i], xyDC [i + i + 1]);
+ cairo_close_path (our d_cairoGraphicsContext);
+ cairo_fill (our d_cairoGraphicsContext);
#elif win
MY_BRUSH
- BeginPath (d_gdiGraphicsContext);
- MoveToEx (d_gdiGraphicsContext, xyDC [0], xyDC [1], NULL);
+ BeginPath (our d_gdiGraphicsContext);
+ MoveToEx (our d_gdiGraphicsContext, xyDC [0], xyDC [1], NULL);
for (long i = 1; i < numberOfPoints; i ++)
- LineTo (d_gdiGraphicsContext, xyDC [i + i], xyDC [i + i + 1]);
- EndPath (d_gdiGraphicsContext);
- FillPath (d_gdiGraphicsContext);
+ LineTo (our d_gdiGraphicsContext, xyDC [i + i], xyDC [i + i + 1]);
+ EndPath (our d_gdiGraphicsContext);
+ FillPath (our d_gdiGraphicsContext);
DEFAULT
#elif mac
GraphicsQuartz_initDraw (this);
quartzPrepareFill (this);
- CGContextBeginPath (d_macGraphicsContext);
- CGContextMoveToPoint (d_macGraphicsContext, xyDC [0], xyDC [1]);
+ CGContextBeginPath (our d_macGraphicsContext);
+ CGContextMoveToPoint (our d_macGraphicsContext, xyDC [0], xyDC [1]);
for (long i = 1; i < numberOfPoints; i ++) {
- CGContextAddLineToPoint (d_macGraphicsContext, xyDC [i + i], xyDC [i + i + 1]);
+ CGContextAddLineToPoint (our d_macGraphicsContext, xyDC [i + i], xyDC [i + i + 1]);
}
- CGContextFillPath (d_macGraphicsContext);
+ CGContextFillPath (our d_macGraphicsContext);
GraphicsQuartz_exitDraw (this);
#endif
}
@@ -289,7 +289,7 @@ void structGraphicsScreen :: v_rectangle (double x1DC, double x2DC, double y1DC,
cairoRevertLine (this);
#elif win
winPrepareLine (this);
- Rectangle (d_gdiGraphicsContext, x1DC, y2DC, x2DC + 1, y1DC + 1);
+ Rectangle (our d_gdiGraphicsContext, x1DC, y2DC, x2DC + 1, y1DC + 1);
DEFAULT
#elif mac
GraphicsQuartz_initDraw (this);
@@ -1027,39 +1027,39 @@ void structGraphics :: v_arrowHead (double xDC, double yDC, double angle) {
void structGraphicsScreen :: v_arrowHead (double xDC, double yDC, double angle) {
#if cairo
- if (d_cairoGraphicsContext == NULL) return;
- double size = 10.0 * resolution * arrowSize / 75.0; // TODO: die 75 zou dat niet de scherm resolutie moeten worden?
- cairo_new_path (d_cairoGraphicsContext);
- cairo_move_to (d_cairoGraphicsContext, xDC + cos ((angle + 160) * NUMpi / 180) * size, yDC - sin ((angle + 160) * NUMpi / 180) * size);
- cairo_line_to (d_cairoGraphicsContext, xDC, yDC);
- cairo_line_to (d_cairoGraphicsContext, xDC + cos ((angle - 160) * NUMpi / 180) * size, yDC - sin ((angle - 160) * NUMpi / 180) * size);
- cairo_close_path (d_cairoGraphicsContext);
- cairo_fill (d_cairoGraphicsContext);
+ if (our d_cairoGraphicsContext == NULL) return;
+ double size = 10.0 * our resolution * our arrowSize / 75.0; // TODO: die 75 zou dat niet de scherm resolutie moeten worden?
+ cairo_new_path (our d_cairoGraphicsContext);
+ cairo_move_to (our d_cairoGraphicsContext, xDC + cos ((angle + 160) * NUMpi / 180) * size, yDC - sin ((angle + 160) * NUMpi / 180) * size);
+ cairo_line_to (our d_cairoGraphicsContext, xDC, yDC);
+ cairo_line_to (our d_cairoGraphicsContext, xDC + cos ((angle - 160) * NUMpi / 180) * size, yDC - sin ((angle - 160) * NUMpi / 180) * size);
+ cairo_close_path (our d_cairoGraphicsContext);
+ cairo_fill (our d_cairoGraphicsContext);
#elif win
- double size = 10.0 * resolution * arrowSize / 72.0;
+ double size = 10.0 * our resolution * our arrowSize / 72.0;
MY_BRUSH
- BeginPath (d_gdiGraphicsContext);
- MoveToEx (d_gdiGraphicsContext, xDC + cos ((angle + 160) * NUMpi / 180) * size, yDC - sin ((angle + 160) * NUMpi / 180) * size, NULL);
- LineTo (d_gdiGraphicsContext, xDC, yDC);
- LineTo (d_gdiGraphicsContext, xDC + cos ((angle - 160) * NUMpi / 180) * size, yDC - sin ((angle - 160) * NUMpi / 180) * size);
- EndPath (d_gdiGraphicsContext);
- FillPath (d_gdiGraphicsContext);
+ BeginPath (our d_gdiGraphicsContext);
+ MoveToEx (our d_gdiGraphicsContext, xDC + cos ((angle + 160) * NUMpi / 180) * size, yDC - sin ((angle + 160) * NUMpi / 180) * size, NULL);
+ LineTo (our d_gdiGraphicsContext, xDC, yDC);
+ LineTo (our d_gdiGraphicsContext, xDC + cos ((angle - 160) * NUMpi / 180) * size, yDC - sin ((angle - 160) * NUMpi / 180) * size);
+ EndPath (our d_gdiGraphicsContext);
+ FillPath (our d_gdiGraphicsContext);
DEFAULT
#elif mac
GraphicsQuartz_initDraw (this);
quartzPrepareFill (this);
- NSCAssert( d_macGraphicsContext, @"nil context");
- CGContextSaveGState (d_macGraphicsContext);
- CGContextBeginPath (d_macGraphicsContext);
- CGContextTranslateCTM (d_macGraphicsContext, xDC, yDC);
- CGContextRotateCTM (d_macGraphicsContext, - angle * NUMpi / 180);
- CGContextMoveToPoint (d_macGraphicsContext, 0.0, 0.0);
- double size = 10.0 * resolution * arrowSize / 72.0;
- double radius = resolution * arrowSize / 30;
- CGContextAddArc (d_macGraphicsContext, - size, 0.0, radius, - NUMpi / 3.0, NUMpi / 3.0, 0);
- CGContextAddLineToPoint (d_macGraphicsContext, 0.0, 0.0);
- CGContextFillPath (d_macGraphicsContext);
- CGContextRestoreGState (d_macGraphicsContext);
+ NSCAssert (our d_macGraphicsContext, @"nil context");
+ CGContextSaveGState (our d_macGraphicsContext);
+ CGContextBeginPath (our d_macGraphicsContext);
+ CGContextTranslateCTM (our d_macGraphicsContext, xDC, yDC);
+ CGContextRotateCTM (our d_macGraphicsContext, - angle * NUMpi / 180);
+ CGContextMoveToPoint (our d_macGraphicsContext, 0.0, 0.0);
+ double size = 10.0 * our resolution * our arrowSize / 72.0;
+ double radius = our resolution * our arrowSize / 30;
+ CGContextAddArc (our d_macGraphicsContext, - size, 0.0, radius, - NUMpi / 3.0, NUMpi / 3.0, 0);
+ CGContextAddLineToPoint (our d_macGraphicsContext, 0.0, 0.0);
+ CGContextFillPath (our d_macGraphicsContext);
+ CGContextRestoreGState (our d_macGraphicsContext);
GraphicsQuartz_exitDraw (this);
#endif
}
diff --git a/sys/Thing.cpp b/sys/Thing.cpp
index 6e8de59..b27a147 100644
--- a/sys/Thing.cpp
+++ b/sys/Thing.cpp
@@ -47,13 +47,13 @@ ClassInfo classThing = & theClassInfo_Thing;
const wchar_t * Thing_className (Thing me) { return my classInfo -> className; }
-Any _Thing_new (ClassInfo classInfo_) {
- Thing me = (Thing) classInfo_ -> _new ();
- trace ("created %ls", classInfo_ -> className);
+Any _Thing_new (ClassInfo classInfo) {
+ Thing me = (Thing) classInfo -> _new ();
+ trace ("created %ls", classInfo -> className);
theTotalNumberOfThings += 1;
- my classInfo = classInfo_;
+ my classInfo = classInfo;
Melder_assert (my name == NULL); // check that _new called calloc
- if (Melder_debug == 40) Melder_casual ("created %ls (%p, %p)", classInfo_ -> className, classInfo_, me);
+ if (Melder_debug == 40) Melder_casual ("created %ls (%p, %p)", classInfo -> className, classInfo, me);
return me;
}
diff --git a/sys/Thing.h b/sys/Thing.h
index 8292eb0..13d65f8 100644
--- a/sys/Thing.h
+++ b/sys/Thing.h
@@ -55,12 +55,21 @@ typedef void *Any; /* Prevent compile-time type checking. */
typedef struct structClassInfo *ClassInfo;
struct structClassInfo {
+ /*
+ * The following five fields are statically initialized by the Thing_implement() macro.
+ */
const wchar_t *className;
ClassInfo parent;
long size;
- Thing (* _new) ();
+ Thing (* _new) (); // objects have to be constructed via this function, because it calls C++ "new", which initializes the C++ class pointer
long version;
+ /*
+ * The following field is initialized by Thing_recognizeClassesByName, only for classes that have to be read (usually from disk).
+ */
long sequentialUniqueIdOfReadableClass;
+ /*
+ * The following field is initialized by Thing_dummyObject(), whihc is used only rarely.
+ */
Thing dummyObject;
};
@@ -89,7 +98,7 @@ extern ClassInfo classThing;
extern struct structClassInfo theClassInfo_Thing;
class structThing {
public:
- ClassInfo classInfo;
+ ClassInfo classInfo; // the Praat class pointer (every object also has a C++ class pointer initialized by C++ "new")
wchar_t *name;
void * operator new (size_t size) { return Melder_calloc (char, size); }
void operator delete (void *ptr, size_t size) { (void) size; Melder_free (ptr); }
diff --git a/sys/melder_audio.cpp b/sys/melder_audio.cpp
index 052222b..ec376f9 100644
--- a/sys/melder_audio.cpp
+++ b/sys/melder_audio.cpp
@@ -125,7 +125,7 @@ double MelderAudio_getOutputSilenceAfter (void) { return preferences. silenceAft
long MelderAudio_getOutputBestSampleRate (long fsamp) {
#if defined (macintosh)
- return fsamp;
+ return fsamp == 44100 || fsamp == 96000 ? fsamp : fsamp;
#elif defined (_WIN32)
return fsamp == 8000 || fsamp == 11025 || fsamp == 16000 || fsamp == 22050 ||
fsamp == 32000 || fsamp == 44100 || fsamp == 48000 || fsamp == 96000 ? fsamp : 44100;
diff --git a/sys/oo_CAN_WRITE_AS_ENCODING.h b/sys/oo_CAN_WRITE_AS_ENCODING.h
index 0e8e94b..976b495 100644
--- a/sys/oo_CAN_WRITE_AS_ENCODING.h
+++ b/sys/oo_CAN_WRITE_AS_ENCODING.h
@@ -1,6 +1,6 @@
/* oo_CAN_WRITE_AS_ENCODING.h
*
- * Copyright (C) 2007-2012,2013 Paul Boersma
+ * Copyright (C) 2007-2012,2013,2014 Paul Boersma
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -38,57 +38,57 @@
#define oo_ENUMx_VECTOR(type,storage,Type,x,min,max)
#define oo_STRINGx(storage,x) \
- if (x && ! Melder_isEncodable (x, encoding)) return false;
+ if (our x && ! Melder_isEncodable (our x, encoding)) return false;
#define oo_STRINGx_ARRAY(storage,x,cap,n) \
for (int i = 0; i < n; i ++) \
- if (x [i] && ! Melder_isEncodable (x [i], encoding)) return false;
+ if (our x [i] && ! Melder_isEncodable (our x [i], encoding)) return false;
#define oo_STRINGx_SET(storage,x,setType) \
for (int i = 0; i <= setType##_MAX; i ++) \
- if (x [i] && ! Melder_isEncodable (x [i], encoding)) return false;
+ if (our x [i] && ! Melder_isEncodable (our x [i], encoding)) return false;
#define oo_STRINGx_VECTOR(storage,x,min,max) \
- if (x) { \
+ if (our x) { \
for (long i = min; i <= max; i ++) \
- if (x [i] && ! Melder_isEncodable (x [i], encoding)) return false; \
+ if (our x [i] && ! Melder_isEncodable (our x [i], encoding)) return false; \
}
#define oo_STRUCT(Type,x) \
- if (! x. canWriteAsEncoding (encoding)) return false;
+ if (! our x. canWriteAsEncoding (encoding)) return false;
#define oo_STRUCT_ARRAY(Type,x,cap,n) \
for (int i = 0; i < n; i ++) \
- if (! x [i]. canWriteAsEncoding (encoding)) return false;
+ if (! our x [i]. canWriteAsEncoding (encoding)) return false;
#define oo_STRUCT_SET(Type,x,setType) \
for (int i = 0; i <= setType##_MAX; i ++) \
- if (! x [i]. canWriteAsEncoding (encoding)) return false;
+ if (! our x [i]. canWriteAsEncoding (encoding)) return false;
#define oo_STRUCT_VECTOR_FROM(Type,x,min,max) \
- if (x) { \
+ if (our x) { \
for (long i = min; i <= max; i ++) \
- if (! x [i]. canWriteAsEncoding (encoding)) return false; \
+ if (! our x [i]. canWriteAsEncoding (encoding)) return false; \
}
#define oo_STRUCT_MATRIX_FROM(Type,x,row1,row2,col1,col2) \
- if (x) { \
+ if (our x) { \
for (long i = row1; i <= row2; i ++) \
for (long j = col1; j <= col2; j ++) \
- if (! x [i] [j]. canWriteAsEncoding (encoding)) return false; \
+ if (! our x [i] [j]. canWriteAsEncoding (encoding)) return false; \
}
#define oo_OBJECT(Class,version,x) \
- if (x && ! Data_canWriteAsEncoding (x, encoding)) return false;
+ if (our x && ! Data_canWriteAsEncoding (our x, encoding)) return false;
#define oo_COLLECTION(Class,x,ItemClass,version) \
- if (x && ! Data_canWriteAsEncoding (x, encoding)) return false;
+ if (our x && ! Data_canWriteAsEncoding (our x, encoding)) return false;
#define oo_FILE(x) \
- if (! Melder_isEncodable (x. path, encoding)) return false;
+ if (! Melder_isEncodable (our x. path, encoding)) return false;
#define oo_DIR(x) \
- if (! Melder_isEncodable (x. path, encoding)) return false;
+ if (! Melder_isEncodable (our x. path, encoding)) return false;
#define oo_DEFINE_STRUCT(Type) \
bool struct##Type :: canWriteAsEncoding (int encoding) { \
diff --git a/sys/oo_COPY.h b/sys/oo_COPY.h
index 27ef500..9db3646 100644
--- a/sys/oo_COPY.h
+++ b/sys/oo_COPY.h
@@ -1,6 +1,6 @@
/* oo_COPY.h
*
- * Copyright (C) 1994-2012,2013 Paul Boersma
+ * Copyright (C) 1994-2012,2013,2014 Paul Boersma
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,89 +20,89 @@
#include "oo_undef.h"
#define oo_SIMPLE(type,storage,x) \
- thy x = x;
+ thy x = our x;
#define oo_ARRAY(type,storage,x,cap,n) \
for (int i = 0; i < n; i ++) \
- thy x [i] = x [i];
+ thy x [i] = our x [i];
#define oo_SET(type,storage,x,setType) \
for (int i = 0; i <= setType##_MAX; i ++) \
- thy x [i] = x [i];
+ thy x [i] = our x [i];
#define oo_VECTOR(type,storage,x,min,max) \
- if (x) thy x = NUMvector_copy (x, min, max);
+ if (our x) thy x = NUMvector_copy (our x, min, max);
#define oo_MATRIX(type,storage,x,row1,row2,col1,col2) \
- if (x) thy x = NUMmatrix_copy (x, row1, row2, col1, col2);
+ if (our x) thy x = NUMmatrix_copy (our x, row1, row2, col1, col2);
#define oo_ENUMx(type,storage,Type,x) \
- thy x = x;
+ thy x = our x;
#define oo_ENUMx_ARRAY(type,storage,Type,x,cap,n) \
- for (int i = 0; i < n; i ++) thy x [i] = x [i];
+ for (int i = 0; i < n; i ++) thy x [i] = our x [i];
#define oo_ENUMx_SET(type,storage,Type,x,setType) \
- for (int i = 0; i <= setType##_MAX; i ++) thy x [i] = x [i];
+ for (int i = 0; i <= setType##_MAX; i ++) thy x [i] = our x [i];
#define oo_ENUMx_VECTOR(type,storage,Type,x,min,max) \
- if (x) thy x = NUMvector_copy (x, min, max);
+ if (our x) thy x = NUMvector_copy (our x, min, max);
#define oo_STRINGx(storage,x) \
- if (x) thy x = Melder_wcsdup (x);
+ if (our x) thy x = Melder_wcsdup (our x);
#define oo_STRINGx_ARRAY(storage,x,cap,n) \
for (int i = 0; i < n; i ++) \
- if (x [i]) thy x [i] = Melder_wcsdup (x [i]);
+ if (our x [i]) thy x [i] = Melder_wcsdup (our x [i]);
#define oo_STRINGx_SET(storage,x,setType) \
for (int i = 0; i <= setType##_MAX; i ++) \
- if (x [i]) thy x [i] = Melder_wcsdup (x [i]);
+ if (our x [i]) thy x [i] = Melder_wcsdup (our x [i]);
#define oo_STRINGx_VECTOR(storage,x,min,max) \
- if (x) { \
+ if (our x) { \
thy x = NUMvector <wchar_t*> (min, max); \
for (long i = min; i <= max; i ++) \
- if (x [i]) thy x [i] = Melder_wcsdup (x [i]); \
+ if (our x [i]) thy x [i] = Melder_wcsdup (our x [i]); \
}
#define oo_STRUCT(Type,x) \
- x. copy (& thy x);
+ our x. copy (& thy x);
#define oo_STRUCT_ARRAY(Type,x,cap,n) \
for (int i = 0; i < n; i ++) \
- x [i]. copy (& thy x [i]);
+ our x [i]. copy (& thy x [i]);
#define oo_STRUCT_SET(Type,x,setType) \
for (int i = 0; i <= setType##_MAX; i ++) \
- x [i]. copy (& thy x [i]);
+ our x [i]. copy (& thy x [i]);
#define oo_STRUCT_VECTOR_FROM(Type,x,min,max) \
if (x) { \
thy x = NUMvector <struct##Type> (min, max); \
for (long i = min; i <= max; i ++) \
- x [i]. copy (& thy x [i]); \
+ our x [i]. copy (& thy x [i]); \
}
#define oo_STRUCT_MATRIX_FROM(Type,x,row1,row2,col1,col2) \
- if (x) { \
+ if (our x) { \
thy x = NUMmatrix <struct##Type> (row1, row2, col1, col2); \
for (long i = row1; i <= row2; i ++) \
for (long j = col1; j <= col2; j ++) \
- x [i] [j]. copy (& thy x [i] [j]); \
+ our x [i] [j]. copy (& thy x [i] [j]); \
}
#define oo_OBJECT(Class,version,x) \
- if (x) thy x = Data_copy (x);
+ if (our x) thy x = Data_copy (our x);
#define oo_COLLECTION(Class,x,ItemClass,version) \
- if (x) thy x = Data_copy (x);
+ if (our x) thy x = Data_copy (our x);
#define oo_FILE(x) \
- MelderFile_copy (& x, & thy x);
+ MelderFile_copy (& our x, & thy x);
#define oo_DIR(x) \
- MelderDir_copy (& x, & thy x);
+ MelderDir_copy (& our x, & thy x);
#define oo_DEFINE_STRUCT(Type) \
void struct##Type :: copy (Type thee) {
diff --git a/sys/oo_DESTROY.h b/sys/oo_DESTROY.h
index b2959f4..879442c 100644
--- a/sys/oo_DESTROY.h
+++ b/sys/oo_DESTROY.h
@@ -1,6 +1,6 @@
/* oo_DESTROY.h
*
- * Copyright (C) 1994-2012,2013 Paul Boersma
+ * Copyright (C) 1994-2012,2013,2014 Paul Boersma
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,10 +26,10 @@
#define oo_SET(type,storage,x,setType)
#define oo_VECTOR(type,storage,x,min,max) \
- NUMvector_free <type> (x, min);
+ NUMvector_free <type> (our x, min);
#define oo_MATRIX(type,storage,x,row1,row2,col1,col2) \
- NUMmatrix_free <type> (x, row1, col1);
+ NUMmatrix_free <type> (our x, row1, col1);
#define oo_ENUMx(type,storage,Type,x)
@@ -39,57 +39,57 @@
#define oo_ENUMx_SET(type,storage,Type,x,setType)
#define oo_ENUMx_VECTOR(type,storage,Type,x,min,max) \
- NUMvector_free <type> (x, min);
+ NUMvector_free <type> (our x, min);
#define oo_STRINGx(storage,x) \
- Melder_free (x);
+ Melder_free (our x);
#define oo_STRINGx_ARRAY(storage,x,cap,n) \
for (int i = 0; i < n; i ++) \
- Melder_free (x [i]);
+ Melder_free (our x [i]);
#define oo_STRINGx_SET(storage,x,setType) \
for (int i = 0; i <= setType##_MAX; i ++) \
- Melder_free (x [i]);
+ Melder_free (our x [i]);
#define oo_STRINGx_VECTOR(storage,x,min,max) \
- if (x) { \
+ if (our x) { \
for (long i = min; i <= max; i ++) \
- Melder_free (x [i]); \
- NUMvector_free <wchar_t*> (x, min); \
+ Melder_free (our x [i]); \
+ NUMvector_free <wchar_t*> (our x, min); \
}
#define oo_STRUCT(Type,x) \
- x. destroy ();
+ our x. destroy ();
#define oo_STRUCT_ARRAY(Type,x,cap,n) \
for (int i = 0; i < n; i ++) \
- x [i]. destroy ();
+ our x [i]. destroy ();
#define oo_STRUCT_SET(Type,x,setType) \
for (int i = 0; i <= setType##_MAX; i ++) \
- x [i]. destroy ();
+ our x [i]. destroy ();
#define oo_STRUCT_VECTOR_FROM(Type,x,min,max) \
- if (x) { \
+ if (our x) { \
for (long i = min; i <= max; i ++) \
- x [i]. destroy (); \
- NUMvector_free <struct##Type> (x, min); \
+ our x [i]. destroy (); \
+ NUMvector_free <struct##Type> (our x, min); \
}
#define oo_STRUCT_MATRIX_FROM(Type,x,row1,row2,col1,col2) \
- if (x) { \
+ if (our x) { \
for (long i = row1; i <= row2; i ++) \
for (long j = col1; j <= col2; j ++) \
- x [i] [j]. destroy (); \
- NUMmatrix_free <struct##Type> (x, row1, col1); \
+ our x [i] [j]. destroy (); \
+ NUMmatrix_free <struct##Type> (our x, row1, col1); \
}
#define oo_OBJECT(Class,version,x) \
- forget (x);
+ forget (our x);
#define oo_COLLECTION(Class,x,ItemClass,version) \
- forget (x);
+ forget (our x);
#define oo_FILE(x)
diff --git a/sys/oo_EQUAL.h b/sys/oo_EQUAL.h
index 7b7cb27..6d8aef5 100644
--- a/sys/oo_EQUAL.h
+++ b/sys/oo_EQUAL.h
@@ -1,6 +1,6 @@
/* oo_EQUAL.h
*
- * Copyright (C) 1994-2012,2013 Paul Boersma
+ * Copyright (C) 1994-2012,2013,2014 Paul Boersma
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,92 +20,92 @@
#include "oo_undef.h"
#define oo_SIMPLE(type,storage,x) \
- if (x != thy x) return false;
+ if (our x != thy x) return false;
#define oo_ARRAY(type,storage,x,cap,n) \
for (int i = 0; i < n; i ++) \
- if (x [i] != thy x [i]) return false; \
+ if (our x [i] != thy x [i]) return false; \
#define oo_SET(type,storage,x,setType) \
for (int i = 0; i <= setType##_MAX; i ++) \
- if (x [i] != thy x [i]) return false; \
+ if (our x [i] != thy x [i]) return false; \
#define oo_VECTOR(type,storage,x,min,max) \
- if (! x != ! thy x || \
- (x && ! NUMvector_equal <type> (x, thy x, min, max))) return false;
+ if (! our x != ! thy x || \
+ (our x && ! NUMvector_equal <type> (our x, thy x, min, max))) return false;
#define oo_MATRIX(type,storage,x,row1,row2,col1,col2) \
- if (! x != ! thy x || \
- (x && ! NUMmatrix_equal <type> (x, thy x, row1, row2, col1, col2))) return false;
+ if (! our x != ! thy x || \
+ (our x && ! NUMmatrix_equal <type> (our x, thy x, row1, row2, col1, col2))) return false;
#define oo_ENUMx(type,storage,Type,x) \
- if (x != thy x) return false;
+ if (our x != thy x) return false;
#define oo_ENUMx_ARRAY(type,storage,Type,x,cap,n) \
- for (int i = 0; i < n; i ++) if (x [i] != thy x [i]) return false;
+ for (int i = 0; i < n; i ++) if (our x [i] != thy x [i]) return false;
#define oo_ENUMx_SET(type,storage,Type,x,setType) \
- for (int i = 0; i <= setType##_MAX; i ++) if (x [i] != thy x [i]) return false;
+ for (int i = 0; i <= setType##_MAX; i ++) if (our x [i] != thy x [i]) return false;
#define oo_ENUMx_VECTOR(type,storage,Type,x,min,max) \
- if (! x != ! thy x || \
- (x && ! NUMvector_equal <type> (x, thy x, min, max))) return false;
+ if (! our x != ! thy x || \
+ (our x && ! NUMvector_equal <type> (our x, thy x, min, max))) return false;
#define oo_STRINGx(storage,x) \
- if (! Melder_wcsequ (x, thy x)) return false;
+ if (! Melder_wcsequ (our x, thy x)) return false;
#define oo_STRINGx_ARRAY(storage,x,cap,n) \
for (int i = 0; i < n; i ++) \
- if (! Melder_wcsequ (x [i], thy x [i])) return false;
+ if (! Melder_wcsequ (our x [i], thy x [i])) return false;
#define oo_STRINGx_SET(storage,x,setType) \
for (int i = 0; i <= setType##_MAX; i ++) \
- if (! Melder_wcsequ (x [i], thy x [i])) return false;
+ if (! Melder_wcsequ (our x [i], thy x [i])) return false;
#define oo_STRINGx_VECTOR(storage,x,min,max) \
- if (! x != ! thy x) return false; \
- if (x) { \
+ if (! our x != ! thy x) return false; \
+ if (our x) { \
for (long i = min; i <= max; i ++) \
- if (! Melder_wcsequ (x [i], thy x [i])) return false; \
+ if (! Melder_wcsequ (our x [i], thy x [i])) return false; \
}
#define oo_STRUCT(Type,x) \
- if (! x. equal (& thy x)) return false;
+ if (! our x. equal (& thy x)) return false;
#define oo_STRUCT_ARRAY(Type,x,cap,n) \
for (int i = 0; i < n; i ++) \
- if (! x [i]. equal (& thy x [i])) return false;
+ if (! our x [i]. equal (& thy x [i])) return false;
#define oo_STRUCT_SET(Type,x,setType) \
for (int i = 0; i <= setType##_MAX; i ++) \
- if (! x [i]. equal (& thy x [i])) return false;
+ if (! our x [i]. equal (& thy x [i])) return false;
#define oo_STRUCT_VECTOR_FROM(Type,x,min,max) \
- if (! x != ! thy x) return false; \
- if (x) { \
+ if (! our x != ! thy x) return false; \
+ if (our x) { \
for (long i = min; i <= max; i ++) \
- if (! x [i]. equal (& thy x [i])) return false; \
+ if (! our x [i]. equal (& thy x [i])) return false; \
}
#define oo_STRUCT_MATRIX_FROM(Type,x,row1,row2,col1,col2) \
- if (! x != ! thy x) return false; \
- if (x) { \
+ if (! our x != ! thy x) return false; \
+ if (our x) { \
for (long i = row1; i <= row2; i ++) \
for (long j = col1; j <= col2; j ++) \
- if (! x [i] [j]. equal (& thy x [i] [j])) return false; \
+ if (! our x [i] [j]. equal (& thy x [i] [j])) return false; \
}
#define oo_OBJECT(Class,version,x) \
- if (! x != ! thy x || (x && ! Data_equal (x, thy x))) return false;
+ if (! our x != ! thy x || (our x && ! Data_equal (our x, thy x))) return false;
#define oo_COLLECTION(Class,x,ItemClass,version) \
- if (! x != ! thy x || (x && ! Data_equal (x, thy x))) return false;
+ if (! our x != ! thy x || (our x && ! Data_equal (our x, thy x))) return false;
#define oo_FILE(x) \
- if (! MelderFile_equal (& x, & thy x)) return false;
+ if (! MelderFile_equal (& our x, & thy x)) return false;
#define oo_DIR(x) \
- if (! MelderDir_equal (& x, & thy x)) return false;
+ if (! MelderDir_equal (& our x, & thy x)) return false;
#define oo_DEFINE_STRUCT(Type) \
bool struct##Type :: equal (Type thee) {
diff --git a/sys/oo_READ_BINARY.h b/sys/oo_READ_BINARY.h
index 09fff68..aa3e762 100644
--- a/sys/oo_READ_BINARY.h
+++ b/sys/oo_READ_BINARY.h
@@ -1,6 +1,6 @@
/* oo_READ_BINARY.h
*
- * Copyright (C) 1994-2012,2013 Paul Boersma
+ * Copyright (C) 1994-2012,2013,2014 Paul Boersma
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,100 +20,100 @@
#include "oo_undef.h"
#define oo_SIMPLE(type,storage,x) \
- x = binget##storage (f);
+ our x = binget##storage (f);
#define oo_ARRAY(type,storage,x,cap,n) \
if (n > cap) Melder_throw ("Number of \"", #x, "\" (", n, ") greater than ", cap, "."); \
for (int i = 0; i < n; i ++) { \
- x [i] = binget##storage (f); \
+ our x [i] = binget##storage (f); \
}
#define oo_SET(type,storage,x,setType) \
for (int i = 0; i <= setType##_MAX; i ++) { \
- x [i] = binget##storage (f); \
+ our x [i] = binget##storage (f); \
}
#define oo_VECTOR(type,storage,x,min,max) \
if (max >= min) { \
- x = NUMvector_readBinary_##storage (min, max, f); \
+ our x = NUMvector_readBinary_##storage (min, max, f); \
}
#define oo_MATRIX(type,storage,x,row1,row2,col1,col2) \
if (row2 >= row1 && col2 >= col1) { \
- x = NUMmatrix_readBinary_##storage (row1, row2, col1, col2, f); \
+ our x = NUMmatrix_readBinary_##storage (row1, row2, col1, col2, f); \
}
#define oo_ENUMx(type,storage,Type,x) \
- x = binget##storage (f, Type##_MIN, Type##_MAX, L"" #Type);
+ our x = binget##storage (f, Type##_MIN, Type##_MAX, L"" #Type);
#define oo_ENUMx_ARRAY(type,storage,Type,x,cap,n) \
if (n > cap) Melder_throw ("Number of \"", #x, "\" (", n, ") greater than ", cap, "."); \
for (int i = 0; i < n; i ++) { \
- x [i] = binget##storage (f, Type##_MIN, Type##_MAX, L"" #Type); \
+ our x [i] = binget##storage (f, Type##_MIN, Type##_MAX, L"" #Type); \
}
#define oo_ENUMx_SET(type,storage,Type,x,setType) \
for (int i = 0; i <= setType##_MAX; i ++) { \
- x [i] = binget##storage (f, Type##_MIN, Type##_MAX, L"" #Type); \
+ our x [i] = binget##storage (f, Type##_MIN, Type##_MAX, L"" #Type); \
}
#define oo_ENUMx_VECTOR(type,storage,Type,x,min,max) \
if (max >= min) { \
- x = NUMvector <type> (min, max); \
+ our x = NUMvector <type> (min, max); \
for (long i = min; i <= max; i ++) { \
- x [i] = binget##storage (f, Type##_MIN, Type##_MAX, L"" #Type); \
+ our x [i] = binget##storage (f, Type##_MIN, Type##_MAX, L"" #Type); \
}
#define oo_STRINGx(storage,x) \
- x = binget##storage (f);
+ our x = binget##storage (f);
#define oo_STRINGx_ARRAY(storage,x,cap,n) \
if (n > cap) Melder_throw ("Number of \"", #x, "\" (", n, ") greater than ", cap, "."); \
for (int i = 0; i < n; i ++) { \
- x [i] = binget##storage (f); \
+ our x [i] = binget##storage (f); \
}
#define oo_STRINGx_SET(storage,x,setType) \
for (int i = 0; i <= setType##_MAX; i ++) { \
- x [i] = binget##storage (f); \
+ our x [i] = binget##storage (f); \
}
#define oo_STRINGx_VECTOR(storage,x,min,max) \
if (max >= min) { \
- x = NUMvector <wchar_t *> (min, max); \
+ our x = NUMvector <wchar_t *> (min, max); \
for (long i = min; i <= max; i ++) { \
- x [i] = binget##storage (f); \
+ our x [i] = binget##storage (f); \
} \
}
#define oo_STRUCT(Type,x) \
- x. readBinary (f);
+ our x. readBinary (f);
#define oo_STRUCT_ARRAY(Type,x,cap,n) \
if (n > cap) Melder_throw ("Number of \"", #x, "\" (", n, ") greater than ", cap, "."); \
for (int i = 0; i < n; i ++) { \
- x [i]. readBinary (f); \
+ our x [i]. readBinary (f); \
}
#define oo_STRUCT_SET(Type,x,setType) \
for (int i = 0; i <= setType##_MAX; i ++) { \
- x [i]. readBinary (f); \
+ our x [i]. readBinary (f); \
}
#define oo_STRUCT_VECTOR_FROM(Type,x,min,max) \
if (max >= min) { \
- x = NUMvector <struct##Type> (min, max); \
+ our x = NUMvector <struct##Type> (min, max); \
for (long i = min; i <= max; i ++) { \
- x [i]. readBinary (f); \
+ our x [i]. readBinary (f); \
} \
}
#define oo_STRUCT_MATRIX_FROM(Type,x,row1,row2,col1,col2) \
if (row2 >= row1 && col2 >= col1) { \
- x = NUMmatrix <struct##Type> (row1, row2, col1, col2); \
+ our x = NUMmatrix <struct##Type> (row1, row2, col1, col2); \
for (long i = row1; i <= row2; i ++) { \
for (long j = col1; j <= col2; j ++) { \
- x [i] [j]. readBinary (f); \
+ our x [i] [j]. readBinary (f); \
} \
} \
}
@@ -121,23 +121,23 @@
#define oo_OBJECT(Class,version,x) \
if (bingetex (f)) { \
long saveVersion = Thing_version; \
- x = Thing_new (Class); \
+ our x = Thing_new (Class); \
Thing_version = version; \
- x -> v_readBinary (f); \
+ our x -> v_readBinary (f); \
Thing_version = saveVersion; \
}
#define oo_COLLECTION(Class,x,ItemClass,version) \
{ \
long n = bingeti4 (f); \
- x = Class##_create (); \
+ our x = Class##_create (); \
for (long i = 1; i <= n; i ++) { \
long saveVersion = Thing_version; \
auto##ItemClass item = (ItemClass) Thing_new (ItemClass); \
Thing_version = version; \
item.peek() -> v_readBinary (f); \
Thing_version = saveVersion; \
- Collection_addItem (x, item.transfer()); \
+ Collection_addItem (our x, item.transfer()); \
} \
}
@@ -155,7 +155,7 @@
#define oo_DEFINE_CLASS(Class,Parent) \
void struct##Class :: v_readBinary (FILE *f) { \
int localVersion = Thing_version; (void) localVersion; \
- if (localVersion > this -> classInfo -> version) \
+ if (localVersion > our classInfo -> version) \
Melder_throw ("The format of this file is too new. Download a newer version of Praat."); \
Class##_Parent :: v_readBinary (f);
diff --git a/sys/oo_READ_TEXT.h b/sys/oo_READ_TEXT.h
index c86c047..4de9aab 100644
--- a/sys/oo_READ_TEXT.h
+++ b/sys/oo_READ_TEXT.h
@@ -1,6 +1,6 @@
/* oo_READ_TEXT.h
*
- * Copyright (C) 1994-2012,2013 Paul Boersma
+ * Copyright (C) 1994-2012,2013,2014 Paul Boersma
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@
#define oo_SIMPLE(type,storage,x) \
try { \
- x = texget##storage (a_text); \
+ our x = texget##storage (a_text); \
} catch (MelderError) { \
Melder_throw ("\"", #x, L"\" not read."); \
}
@@ -30,7 +30,7 @@
if (n > cap) Melder_throw ("Number of \"", #x, "\" (", n, ") greater than ", cap, "."); \
for (long i = 0; i < n; i ++) { \
try { \
- x [i] = texget##storage (a_text); \
+ our x [i] = texget##storage (a_text); \
} catch (MelderError) { \
Melder_throw ("Element ", i+1, " of \"", #x, "\" not read."); \
} \
@@ -39,7 +39,7 @@
#define oo_SET(type,storage,x,setType) \
for (long i = 0; i <= setType##_MAX; i ++) { \
try { \
- x [i] = texget##storage (a_text); \
+ our x [i] = texget##storage (a_text); \
} catch (MelderError) { \
Melder_throw ("Element ", i+1, " of \"", #x, "\" not read."); \
} \
@@ -47,39 +47,39 @@
#define oo_VECTOR(type,storage,x,min,max) \
if (max >= min) { \
- x = NUMvector_readText_##storage (min, max, a_text, #x); \
+ our x = NUMvector_readText_##storage (min, max, a_text, #x); \
}
#define oo_MATRIX(type,storage,x,row1,row2,col1,col2) \
if (row2 >= row1 && col2 >= col1) { \
- x = NUMmatrix_readText_##storage (row1, row2, col1, col2, a_text, #x); \
+ our x = NUMmatrix_readText_##storage (row1, row2, col1, col2, a_text, #x); \
}
#define oo_ENUMx(type,storage,Type,x) \
- x = texget##storage (a_text, Type##_getValue);
+ our x = texget##storage (a_text, Type##_getValue);
#define oo_ENUMx_ARRAY(type,storage,Type,x,cap,n) \
if (n > cap) Melder_throw ("Number of \"", #x, "\" (", n, ") greater than ", cap, "."); \
for (long i = 0; i < n; i ++) { \
- x [i] = texget##storage (a_text, Type##_getValue); \
+ our x [i] = texget##storage (a_text, Type##_getValue); \
}
#define oo_ENUMx_SET(type,storage,Type,x,setType) \
for (long i = 0; i <= setType##_MAX; i ++) { \
- x [i] = texget##storage (a_text, & Type##_getValue); \
+ our x [i] = texget##storage (a_text, & Type##_getValue); \
}
#define oo_ENUMx_VECTOR(type,storage,Type,x,min,max) \
if (max >= min) { \
- x = NUMvector <type> (min, max); \
+ our x = NUMvector <type> (min, max); \
for (long i = min; i <= max; i ++) { \
- x [i] = texget##storage (a_text, & Type##_getValue); \
+ our x [i] = texget##storage (a_text, & Type##_getValue); \
} \
}
#define oo_STRINGx(storage,x) \
try { \
- x = texget##storage (a_text); \
+ our x = texget##storage (a_text); \
} catch (MelderError) { \
Melder_throw ("String \"", #x, "\" not read."); \
}
@@ -87,20 +87,20 @@
#define oo_STRINGx_ARRAY(storage,x,cap,n) \
if (n > cap) Melder_throw ("Number of \"", #x, "\" (", n, ") greater than ", cap, "."); \
for (long i = 0; i < n; i ++) { \
- x [i] = texget##storage (a_text); \
+ our x [i] = texget##storage (a_text); \
}
#define oo_STRINGx_SET(storage,x,setType) \
for (long i = 0; i <= setType##_MAX; i ++) { \
- x [i] = texget##storage (a_text); \
+ our x [i] = texget##storage (a_text); \
}
#define oo_STRINGx_VECTOR(storage,x,min,max) \
if (max >= min) { \
- x = NUMvector <wchar_t*> (min, max); \
+ our x = NUMvector <wchar_t*> (min, max); \
for (long i = min; i <= max; i ++) { \
try { \
- x [i] = texget##storage (a_text); \
+ our x [i] = texget##storage (a_text); \
} catch (MelderError) { \
Melder_throw ("Element ", i, " of \"" #x, "\" not read."); \
} \
@@ -108,33 +108,33 @@
}
#define oo_STRUCT(Type,x) \
- x. readText (a_text);
+ our x. readText (a_text);
#define oo_STRUCT_ARRAY(Type,x,cap,n) \
if (n > cap) Melder_throw ("Number of \"", #x, "\" (", n, ") greater than ", cap, "."); \
for (long i = 0; i < n; i ++) { \
- x [i]. readText (a_text); \
+ our x [i]. readText (a_text); \
}
#define oo_STRUCT_SET(Type,x,setType) \
for (long i = 0; i <= setType##_MAX; i ++) { \
- x [i]. readText (a_text); \
+ our x [i]. readText (a_text); \
}
#define oo_STRUCT_VECTOR_FROM(Type,x,min,max) \
if (max >= min) { \
- x = NUMvector <struct##Type> (min, max); \
+ our x = NUMvector <struct##Type> (min, max); \
for (long i = min; i <= max; i ++) { \
- x [i]. readText (a_text); \
+ our x [i]. readText (a_text); \
} \
}
#define oo_STRUCT_MATRIX_FROM(Type,x,row1,row2,col1,col2) \
if (row2 >= row1 && col2 >= col1) { \
- x = NUMmatrix <struct##Type> (row1, row2, col1, col2); \
+ our x = NUMmatrix <struct##Type> (row1, row2, col1, col2); \
for (long i = row1; i <= row2; i ++) { \
for (long j = col1; j <= col2; j ++) { \
- x [i] [j]. readText (a_text); \
+ our x [i] [j]. readText (a_text); \
} \
} \
}
@@ -142,23 +142,23 @@
#define oo_OBJECT(Class,version,x) \
if (texgetex (a_text) == 1) { \
long saveVersion = Thing_version; \
- x = Thing_new (Class); \
+ our x = Thing_new (Class); \
Thing_version = version; \
- x -> v_readText (a_text); \
+ our x -> v_readText (a_text); \
Thing_version = saveVersion; \
}
#define oo_COLLECTION(Class,x,ItemClass,version) \
{ \
long n = texgeti4 (a_text); \
- x = Class##_create (); \
+ our x = Class##_create (); \
for (long i = 1; i <= n; i ++) { \
long saveVersion = Thing_version; \
auto##ItemClass item = (ItemClass) Thing_new (ItemClass); \
Thing_version = version; \
item.peek() -> v_readText (a_text); \
Thing_version = saveVersion; \
- Collection_addItem (x, item.transfer()); \
+ Collection_addItem (our x, item.transfer()); \
} \
}
@@ -176,7 +176,7 @@
#define oo_DEFINE_CLASS(Class,Parent) \
void struct##Class :: v_readText (MelderReadText a_text) { \
int localVersion = Thing_version; (void) localVersion; \
- if (localVersion > this -> classInfo -> version) \
+ if (localVersion > our classInfo -> version) \
Melder_throw ("The format of this file is too new. Download a newer version of Praat."); \
Class##_Parent :: v_readText (a_text);
diff --git a/sys/oo_WRITE_BINARY.h b/sys/oo_WRITE_BINARY.h
index 47f40c6..a722853 100644
--- a/sys/oo_WRITE_BINARY.h
+++ b/sys/oo_WRITE_BINARY.h
@@ -1,6 +1,6 @@
/* oo_WRITE_BINARY.h
*
- * Copyright (C) 1994-2012,2013 Paul Boersma
+ * Copyright (C) 1994-2012,2013,2014 Paul Boersma
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,84 +20,84 @@
#include "oo_undef.h"
#define oo_SIMPLE(type,storage,x) \
- binput##storage (x, f);
+ binput##storage (our x, f);
#define oo_ARRAY(type,storage,x,cap,n) \
for (int i = 0; i < n; i ++) \
- binput##storage (x [i], f);
+ binput##storage (our x [i], f);
#define oo_SET(type,storage,x,setType) \
for (int i = 0; i <= setType##_MAX; i ++) \
- binput##storage (x [i], f);
+ binput##storage (our x [i], f);
#define oo_VECTOR(type,storage,x,min,max) \
- if (x) \
- NUMvector_writeBinary_##storage (x, min, max, f);
+ if (our x) \
+ NUMvector_writeBinary_##storage (our x, min, max, f);
#define oo_MATRIX(type,storage,x,row1,row2,col1,col2) \
- if (x) \
- NUMmatrix_writeBinary_##storage (x, row1, row2, col1, col2, f);
+ if (our x) \
+ NUMmatrix_writeBinary_##storage (our x, row1, row2, col1, col2, f);
#define oo_ENUMx(type,storage,Type,x) \
- binput##storage (x, f);
+ binput##storage (our x, f);
#define oo_ENUMx_ARRAY(type,storage,Type,x,cap,n) \
for (int i = 0; i < n; i ++) \
- binput##storage (x [i], f);
+ binput##storage (our x [i], f);
#define oo_ENUMx_SET(type,storage,Type,x,setType) \
for (int i = 0; i <= setType##_MAX; i ++) \
- binput##storage (x [i], f);
+ binput##storage (our x [i], f);
#define oo_ENUMx_VECTOR(type,storage,Type,x,min,max) \
- if (x) \
- NUMvector_writeBinary_##storage (x, min, max, f);
+ if (our x) \
+ NUMvector_writeBinary_##storage (our x, min, max, f);
#define oo_STRINGx(storage,x) \
- binput##storage (x, f);
+ binput##storage (our x, f);
#define oo_STRINGx_ARRAY(storage,x,cap,n) \
for (int i = 0; i < n; i ++) \
- binput##storage (x [i], f);
+ binput##storage (our x [i], f);
#define oo_STRINGx_SET(storage,x,setType) \
for (int i = 0; i <= setType##_MAX; i ++) \
- binput##storage (x [i], f);
+ binput##storage (our x [i], f);
#define oo_STRINGx_VECTOR(storage,x,min,max) \
for (long i = min; i <= max; i ++) \
- binput##storage (x [i], f);
+ binput##storage (our x [i], f);
#define oo_STRUCT(Type,x) \
- x. writeBinary (f);
+ our x. writeBinary (f);
#define oo_STRUCT_ARRAY(Type,x,cap,n) \
for (int i = 0; i < n; i ++) \
- x [i]. writeBinary (f);
+ our x [i]. writeBinary (f);
#define oo_STRUCT_SET(Type,x,setType) \
for (int i = 0; i <= setType##_MAX; i ++) \
- x [i]. writeBinary (f);
+ our x [i]. writeBinary (f);
#define oo_STRUCT_VECTOR_FROM(Type,x,min,max) \
for (long i = min; i <= max; i ++) \
- x [i]. writeBinary (f);
+ our x [i]. writeBinary (f);
#define oo_STRUCT_MATRIX_FROM(Type,x,row1,row2,col1,col2) \
for (long i = row1; i <= row2; i ++) \
for (long j = col1; j <= col2; j ++) \
- x [i] [j]. writeBinary (f);
+ our x [i] [j]. writeBinary (f);
#define oo_OBJECT(Class,version,x) \
- binputex (x != NULL, f); \
- if (x) \
- Data_writeBinary (x, f);
+ binputex (our x != NULL, f); \
+ if (our x) \
+ Data_writeBinary (our x, f);
#define oo_COLLECTION(Class,x,ItemClass,version) \
- binputi4 (x ? x -> size : 0, f); \
- if (x) { \
- for (long i = 1; i <= x -> size; i ++) { \
- ItemClass data = (ItemClass) x -> item [i]; \
+ binputi4 (our x ? our x -> size : 0, f); \
+ if (our x) { \
+ for (long i = 1; i <= our x -> size; i ++) { \
+ ItemClass data = (ItemClass) our x -> item [i]; \
data -> struct##ItemClass :: v_writeBinary (f); \
} \
}
diff --git a/sys/oo_WRITE_TEXT.h b/sys/oo_WRITE_TEXT.h
index ebbc7a8..292af9f 100644
--- a/sys/oo_WRITE_TEXT.h
+++ b/sys/oo_WRITE_TEXT.h
@@ -1,6 +1,6 @@
/* oo_WRITE_TEXT.h
*
- * Copyright (C) 1994-2012,2013 Paul Boersma
+ * Copyright (C) 1994-2012,2013,2014 Paul Boersma
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,80 +20,80 @@
#include "oo_undef.h"
#define oo_SIMPLE(type,storage,x) \
- texput##storage (file, x, L"" #x, 0,0,0,0,0);
+ texput##storage (file, our x, L"" #x, 0,0,0,0,0);
#define oo_ARRAY(type,storage,x,cap,n) \
texputintro (file, L"" #x " []: ", n ? NULL : L"(empty)", 0,0,0,0); \
for (int i = 0; i < n; i ++) \
- texput##storage (file, x [i], L"" #x " [", Melder_integer (i), L"]", 0,0,0); \
+ texput##storage (file, our x [i], L"" #x " [", Melder_integer (i), L"]", 0,0,0); \
texexdent (file);
#define oo_SET(type,storage,x,setType) \
texputintro (file, L"" #x " []:", 0,0,0,0,0); \
for (int i = 0; i <= setType##_MAX; i ++) \
- texput##storage (file, x [i], L"" #x " [", setType##_getText (i), L"]", 0,0,0); \
+ texput##storage (file, our x [i], L"" #x " [", setType##_getText (i), L"]", 0,0,0); \
texexdent (file);
#define oo_VECTOR(type,storage,x,min,max) \
- if (x) \
- NUMvector_writeText_##storage (x, min, max, file, L"" #x);
+ if (our x) \
+ NUMvector_writeText_##storage (our x, min, max, file, L"" #x);
#define oo_MATRIX(type,storage,x,row1,row2,col1,col2) \
- if (x) \
- NUMmatrix_writeText_##storage (x, row1, row2, col1, col2, file, L"" #x);
+ if (our x) \
+ NUMmatrix_writeText_##storage (our x, row1, row2, col1, col2, file, L"" #x);
#define oo_ENUMx(type,storage,Type,x) \
- texput##storage (file, x, Type##_getText, L"" #x, 0,0,0,0,0);
+ texput##storage (file, our x, Type##_getText, L"" #x, 0,0,0,0,0);
#define oo_ENUMx_ARRAY(type,storage,Type,x,cap,n) \
texputintro (file, L"" #x " []:", 0,0,0,0,0); \
for (int i = 0; i < n; i ++) \
- texput##storage (file, x [i], Type##_getText, L"" #x " [", Melder_integer (i), L"]", 0,0,0); \
+ texput##storage (file, our x [i], Type##_getText, L"" #x " [", Melder_integer (i), L"]", 0,0,0); \
texexdent (file);
#define oo_ENUMx_SET(type,storage,Type,x,setType) \
texputintro (file, L"" #x " []: ", n ? NULL : L"(empty)", 0,0,0,0); \
for (int i = 0; i <= setType##_MAX; i ++) \
- texput##storage (file, x [i], Type##_getText, L"" #x " [", setType##_getText (i), L"]", 0,0,0); \
+ texput##storage (file, our x [i], Type##_getText, L"" #x " [", setType##_getText (i), L"]", 0,0,0); \
texexdent (file);
#define oo_ENUMx_VECTOR(type,storage,Type,x,min,max) \
texputintro (file, L"" #x " []: ", max >= min ? NULL : L"(empty)", 0,0,0,0); \
for (long i = min; i <= max; i ++) \
- texput##storage (file, x [i], Type##_getText, L"" #x " [", Melder_integer (i), L"]", 0,0,0); \
+ texput##storage (file, our x [i], Type##_getText, L"" #x " [", Melder_integer (i), L"]", 0,0,0); \
texexdent (file);
#define oo_STRINGx(storage,x) \
- texput##storage (file, x, L""#x, 0,0,0,0,0);
+ texput##storage (file, our x, L""#x, 0,0,0,0,0);
#define oo_STRINGx_ARRAY(storage,x,cap,n) \
texputintro (file, L"" #x " []: ", n ? NULL : L"(empty)", 0,0,0,0); \
for (int i = 0; i < n; i ++) \
- texput##storage (file, x [i], L"" #x " [", Melder_integer (i), L"]", 0,0,0); \
+ texput##storage (file, our x [i], L"" #x " [", Melder_integer (i), L"]", 0,0,0); \
texexdent (file);
#define oo_STRINGx_SET(storage,x,setType) \
texputintro (file, L"" #x " []:", 0,0,0,0,0); \
for (int i = 0; i <= setType##_MAX; i ++) \
- texput##storage (file, x [i], L"" #x " [", setType##_getText (i), L"]", 0,0,0); \
+ texput##storage (file, our x [i], L"" #x " [", setType##_getText (i), L"]", 0,0,0); \
texexdent (file);
#define oo_STRINGx_VECTOR(storage,x,min,max) \
texputintro (file, L"" #x " []: ", max >= min ? NULL : L"(empty)", 0,0,0,0); \
for (long i = min; i <= max; i ++) \
- texput##storage (file, x [i], L"" #x " [", Melder_integer (i), L"]", 0,0,0); \
+ texput##storage (file, our x [i], L"" #x " [", Melder_integer (i), L"]", 0,0,0); \
texexdent (file);
#define oo_STRUCT(Type,x) \
texputintro (file, L"" #x ":", 0,0,0,0,0); \
- x. writeText (file); \
+ our x. writeText (file); \
texexdent (file);
#define oo_STRUCT_ARRAY(Type,x,cap,n) \
texputintro (file, L"" #x " []: ", n ? NULL : L"(empty)", 0,0,0,0); \
for (int i = 0; i < n; i ++) { \
texputintro (file, L"" #x " [", Melder_integer (i), L"]:", 0,0,0); \
- x [i]. writeText (file); \
+ our x [i]. writeText (file); \
texexdent (file); \
} \
texexdent (file);
@@ -102,7 +102,7 @@
texputintro (file, L"" #x " []:", 0,0,0,0,0); \
for (int i = 0; i <= setType##_MAX; i ++) { \
texputintro (file, L"" #x " [", setType##_getText (i), L"]:", 0,0,0); \
- x [i]. writeText (file); \
+ our x [i]. writeText (file); \
texexdent (file); \
} \
texexdent (file);
@@ -111,7 +111,7 @@
texputintro (file, L"" #x " []: ", max >= min ? NULL : L"(empty)", 0,0,0,0); \
for (long i = min; i <= max; i ++) { \
texputintro (file, L"" #x " [", Melder_integer (i), L"]:", 0,0,0); \
- x [i]. writeText (file); \
+ our x [i]. writeText (file); \
texexdent (file); \
} \
texexdent (file);
@@ -122,7 +122,7 @@
texputintro (file, L"" #x " [", Melder_integer (i), L"]:", 0,0,0); \
for (long j = col1; j <= col2; j ++) { \
texputintro (file, L"" #x " [", Melder_integer (i), L"] [", Melder_integer (j), L"]:", 0); \
- x [i] [j]. writeText (file); \
+ our x [i] [j]. writeText (file); \
texexdent (file); \
} \
texexdent (file); \
@@ -130,15 +130,15 @@
texexdent (file);
#define oo_OBJECT(Class,version,x) \
- texputex (file, x != NULL, L"" #x, 0,0,0,0,0); \
- if (x) \
- Data_writeText (x, file);
+ texputex (file, our x != NULL, L"" #x, 0,0,0,0,0); \
+ if (our x) \
+ Data_writeText (our x, file);
#define oo_COLLECTION(Class,x,ItemClass,version) \
- texputi4 (file, x ? x -> size : 0, L"" #x ": size", 0,0,0,0,0); \
- if (x) { \
- for (long i = 1; i <= x -> size; i ++) { \
- ItemClass data = (ItemClass) x -> item [i]; \
+ texputi4 (file, our x ? our x -> size : 0, L"" #x ": size", 0,0,0,0,0); \
+ if (our x) { \
+ for (long i = 1; i <= our x -> size; i ++) { \
+ ItemClass data = (ItemClass) our x -> item [i]; \
texputintro (file, L"" #x " [", Melder_integer (i), L"]:", 0,0,0); \
data -> struct##ItemClass :: v_writeText (file); \
texexdent (file); \
diff --git a/sys/praat.cpp b/sys/praat.cpp
index a4fa132..530acf2 100644
--- a/sys/praat.cpp
+++ b/sys/praat.cpp
@@ -1049,9 +1049,10 @@ void praat_setStandAloneScriptText (wchar_t *text) {
}
void praat_init (const char *title, unsigned int argc, char **argv) {
- static char truncatedTitle [300]; /* Static because praatP.title will point into it. */
+ static char truncatedTitle [300]; // static because praatP.title will point into it
#if defined (UNIX)
setlocale (LC_ALL, "C");
+ setenv ("PULSE_LATENCY_MSEC", "1", 0); // Rafael Laboissiere, August 2014
#elif defined (_WIN32)
setlocale (LC_ALL, "C"); // said to be superfluous
#elif defined (macintosh)
diff --git a/sys/praat_version.h b/sys/praat_version.h
index 125d38f..0ba955e 100644
--- a/sys/praat_version.h
+++ b/sys/praat_version.h
@@ -1,5 +1,5 @@
-#define PRAAT_VERSION_STR 5.3.82
-#define PRAAT_VERSION_NUM 5382
+#define PRAAT_VERSION_STR 5.3.84
+#define PRAAT_VERSION_NUM 5384
#define PRAAT_YEAR 2014
-#define PRAAT_MONTH July
+#define PRAAT_MONTH August
#define PRAAT_DAY 26
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/praat.git
More information about the debian-med-commit
mailing list