Loading EEG/ERPWindow.cpp +8 −8 Original line number Diff line number Diff line /* ERPWindow.cpp * * Copyright (C) 2012-2018 Paul Boersma * Copyright (C) 2012-2019 Paul Boersma * * This code is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by Loading Loading @@ -172,7 +172,7 @@ void ERP_drawScalp (ERP me, Graphics graphics, double tmin, double tmax, double Graphics_setWindow (graphics, -1.0, 1.0, -1.0, 1.0); //Graphics_setGrey (graphics, 1.0); //Graphics_fillRectangle (graphics, -1.1, 1.1, -1.01, 1.19); //Graphics_setColour (graphics, Graphics_BLACK); //Graphics_setColour (graphics, Melder_BLACK); integer numberOfDrawableChannels = my ny >= 64 && Melder_equ (my channelNames [64].get(), U"O2") ? 64 : my ny >= 32 && Melder_equ (my channelNames [32].get(), U"Cz") ? 32 : Loading Loading @@ -243,7 +243,7 @@ void ERP_drawScalp (ERP me, Graphics graphics, double tmin, double tmax, double double x [3] = { -0.08, 0.0, 0.08 }, y [3] = { 0.99, 1.18, 0.99 }; Graphics_fillArea (graphics, 3, x, y); } Graphics_setColour (graphics, Graphics_BLACK); Graphics_setColour (graphics, Melder_BLACK); Graphics_line (graphics, -0.08, 0.99, 0.0, 1.18); Graphics_line (graphics, 0.08, 0.99, 0.0, 1.18); /* Loading @@ -252,7 +252,7 @@ void ERP_drawScalp (ERP me, Graphics graphics, double tmin, double tmax, double Graphics_setGrey (graphics, colourScale == kGraphics_colourScale::BLUE_TO_RED ? 1.0 : 0.5); Graphics_fillRectangle (graphics, -1.09, -1.00, -0.08, 0.08); Graphics_fillRectangle (graphics, 1.09, 1.00, -0.08, 0.08); Graphics_setColour (graphics, Graphics_BLACK); Graphics_setColour (graphics, Melder_BLACK); Graphics_line (graphics, -0.99, 0.08, -1.09, 0.08); Graphics_line (graphics, -1.09, 0.08, -1.09, -0.08); Graphics_line (graphics, -1.09, -0.08, -0.99, -0.08); Loading @@ -273,9 +273,9 @@ void ERP_drawScalp (ERP me, Graphics graphics, double tmin, double tmax, double void structERPWindow :: v_drawSelectionViewer () { ERP erp = (ERP) our data; Graphics_setWindow (our graphics.get(), -1.1, 1.1, -1.01, 1.19); Graphics_setColour (our graphics.get(), Graphics_WINDOW_BACKGROUND_COLOUR); Graphics_setColour (our graphics.get(), Melder_WINDOW_BACKGROUND_COLOUR); Graphics_fillRectangle (our graphics.get(), -1.1, 1.1, -1.01, 1.19); Graphics_setColour (our graphics.get(), Graphics_BLACK); Graphics_setColour (our graphics.get(), Melder_BLACK); integer numberOfDrawableChannels = erp -> ny >= 64 && Melder_equ (erp -> channelNames [64].get(), U"O2") ? 64 : erp -> ny >= 32 && Melder_equ (erp -> channelNames [32].get(), U"Cz") ? 32 : Loading Loading @@ -368,7 +368,7 @@ void structERPWindow :: v_drawSelectionViewer () { double x [3] = { -0.08, 0.0, 0.08 }, y [3] = { 0.99, 1.18, 0.99 }; Graphics_fillArea (our graphics.get(), 3, x, y); } Graphics_setColour (our graphics.get(), Graphics_BLACK); Graphics_setColour (our graphics.get(), Melder_BLACK); Graphics_line (our graphics.get(), -0.08, 0.99, 0.0, 1.18); Graphics_line (our graphics.get(), 0.08, 0.99, 0.0, 1.18); /* Loading @@ -377,7 +377,7 @@ void structERPWindow :: v_drawSelectionViewer () { Graphics_setGrey (our graphics.get(), our p_scalp_colourScale == kGraphics_colourScale::BLUE_TO_RED ? 1.0 : 0.5); Graphics_fillRectangle (our graphics.get(), -1.09, -1.00, -0.08, 0.08); Graphics_fillRectangle (our graphics.get(), 1.09, 1.00, -0.08, 0.08); Graphics_setColour (our graphics.get(), Graphics_BLACK); Graphics_setColour (our graphics.get(), Melder_BLACK); Graphics_line (our graphics.get(), -0.99, 0.08, -1.09, 0.08); Graphics_line (our graphics.get(), -1.09, 0.08, -1.09, -0.08); Graphics_line (our graphics.get(), -1.09, -0.08, -0.99, -0.08); Loading FFNet/FFNet.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -547,7 +547,7 @@ void FFNet_drawTopology (FFNet me, Graphics g) { x2WC += dx2; } } Graphics_setColour (g, Graphics_RED); Graphics_setColour (g, Melder_RED); x2WC = x2; for (integer j = 1; j <= numberOfUnitsInLayer; j ++) { Graphics_circle (g, x2WC, y2WC, radius); Loading @@ -555,7 +555,7 @@ void FFNet_drawTopology (FFNet me, Graphics g) { Graphics_fillCircle (g, x2WC, y2WC, radius); x2WC += dx2; } Graphics_setColour (g, Graphics_BLACK); Graphics_setColour (g, Melder_BLACK); if (i > 0) { integer numberOfUnitsInLayer_m1 = ( i == 1 ? my numberOfInputs : my numberOfUnitsInLayer [i - 1] ); double dx1 = dx; Loading Loading @@ -595,7 +595,7 @@ void FFNet_drawTopology (FFNet me, Graphics g) { void FFNet_drawActivation (FFNet me, Graphics g) { integer node = 1, maxNumOfUnits = my numberOfInputs; int dxIsFixed = 1; Graphics_Colour colour = Graphics_inqColour (g); MelderColour colour = Graphics_inqColour (g); double dy = 1.0 / (my numberOfLayers + 1); Graphics_setInner (g); Loading @@ -618,7 +618,7 @@ void FFNet_drawActivation (FFNet me, Graphics g) { for (integer j = 1; j <= numberOfUnitsInLayer; j ++, node ++) { double activity = my activity [node]; double radius = r1 * (fabs (activity) < 0.05 ? 0.05 : fabs (activity)); /*Graphics_setColour (g, activity < 0 ? Graphics_BLACK : Graphics_RED);*/ /*Graphics_setColour (g, activity < 0 ? Melder_BLACK : Melder_RED);*/ Graphics_circle (g, x2WC, y2WC, radius); if (activity < 0) Graphics_fillCircle (g, x2WC, y2WC, radius); Loading LPC/Cepstrumc.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ void Cepstrumc_init (Cepstrumc me, double tmin, double tmax, integer nt, double my samplingFrequency = samplingFrequency; my maxnCoefficients = nCoefficients; Sampled_init (me, tmin, tmax, nt, dt, t1); my frame = NUMvector<structCepstrumc_Frame> (1, nt); my frame = newvectorzero <structCepstrumc_Frame> (nt); } autoCepstrumc Cepstrumc_create (double tmin, double tmax, integer nt, double dt, double t1, Loading LPC/Cepstrumc_def.h +1 −1 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ oo_DEFINE_CLASS (Cepstrumc, Sampled) oo_DOUBLE (samplingFrequency) // from Sound oo_INT (maxnCoefficients) oo_STRUCT_VECTOR (Cepstrumc_Frame, frame, nx) oo_STRUCTVEC (Cepstrumc_Frame, frame, nx) #if oo_DECLARING void v_info () Loading LPC/Formant_extensions.cpp +29 −28 Original line number Diff line number Diff line Loading @@ -23,18 +23,20 @@ void Formant_formula (Formant me, double tmin, double tmax, integer formantmin, try { integer numberOfPossibleFormants = my maxnFormants; if (tmax <= tmin) { tmin = my xmin; tmax = my xmax; tmin = my xmin; tmax = my xmax; } if (formantmax >= formantmin) { formantmin = 1; formantmax = numberOfPossibleFormants; formantmin = 1; formantmax = numberOfPossibleFormants; } formantmin = formantmin < 1 ? 1 : formantmin; formantmax = formantmax > numberOfPossibleFormants ? numberOfPossibleFormants : formantmax; Melder_clipLeft (integer (1), & formantmin); Melder_clipRight (& formantmax, numberOfPossibleFormants); autoMatrix fb = Matrix_create (my xmin, my xmax, my nx, my dx, my x1, 1.0, 2 * numberOfPossibleFormants, 2 * numberOfPossibleFormants, 1.0, 1.0); for (integer iframe = 1; iframe <= my nx; iframe ++) { Formant_Frame frame = & my d_frames [iframe]; int numberOfFormants = frame -> nFormants < numberOfPossibleFormants ? frame -> nFormants : numberOfPossibleFormants; Formant_Frame frame = & my frames [iframe]; integer numberOfFormants = std::min (integer (frame -> nFormants), numberOfPossibleFormants); for (integer iformant = 1; iformant <= numberOfFormants; iformant++) { if (iformant <= frame -> nFormants) { fb -> z [2 * iformant - 1] [iframe] = frame -> formant [iformant]. frequency; Loading @@ -43,7 +45,7 @@ void Formant_formula (Formant me, double tmin, double tmax, integer formantmin, } } // Apply formula double ymin = 2.0 * formantmin - 1.0, ymax = 2.0 * formantmax; const double ymin = 2.0 * formantmin - 1.0, ymax = 2.0 * formantmax; Matrix_formula_part (fb.get(), tmin, tmax, ymin, ymax, expression, interpreter, nullptr); // Put results back in Formant integer ixmin, ixmax, iymin, iymax; Loading @@ -52,12 +54,12 @@ void Formant_formula (Formant me, double tmin, double tmax, integer formantmin, for (integer iframe = ixmin; iframe <= ixmax; iframe ++) { // if some of the formant frequencies are set to zero => remove the formant Formant_Frame frame = & my d_frames [iframe]; int numberOfFormants = frame -> nFormants < formantmax ? frame -> nFormants : formantmax; int iformantto = formantmin > 1 ? formantmin - 1 : 0; Formant_Frame frame = & my frames [iframe]; integer numberOfFormants = std::min (integer (frame -> nFormants), formantmax); integer iformantto = ( formantmin > 1 ? formantmin - 1 : 0 ); for (integer iformant = formantmin; iformant <= numberOfFormants; iformant++) { double frequency = fb -> z [2 * iformant - 1] [iframe]; double bandWidth = fb -> z [2 * iformant ] [iframe]; const double frequency = fb -> z [2 * iformant - 1] [iframe]; const double bandWidth = fb -> z [2 * iformant ] [iframe]; if (frequency > 0 && bandWidth > 0) { iformantto ++; frame -> formant [iformantto]. frequency = frequency; Loading Loading @@ -94,20 +96,19 @@ autoIntensityTier Formant_Spectrogram_to_IntensityTier (Formant me, Spectrogram double previousValue = -80000.0; // can never occur double previousTime = my xmin; for (integer iframe = 1; iframe <= my nx; iframe ++) { Formant_Frame frame = & my d_frames [iframe]; Formant_Frame frame = & my frames [iframe]; integer numberOfFormants = frame -> nFormants; double time = Sampled_indexToX (me, iframe); double value = 0; const double time = Sampled_indexToX (me, iframe); double value = 0.0; if (iformant <= numberOfFormants) { double f = frame -> formant [iformant].frequency; const double f = frame -> formant [iformant]. frequency; value = Matrix_getValueAtXY (thee, time, f); value = isdefined (value) ? value : 0.0; } value = 10.0 * log10 ((value + 1e-30) / 4.0e-10); /* dB / Hz */ if (value != previousValue) { if (iframe > 1 && previousTime < time - 1.5 * my dx) { // mark the end of the same interval if (iframe > 1 && previousTime < time - 1.5 * my dx) // mark the end of the same interval RealTier_addPoint (him.get(), time - my dx, previousValue); } RealTier_addPoint (him.get(), time, value); previousTime = time; } Loading Loading
EEG/ERPWindow.cpp +8 −8 Original line number Diff line number Diff line /* ERPWindow.cpp * * Copyright (C) 2012-2018 Paul Boersma * Copyright (C) 2012-2019 Paul Boersma * * This code is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by Loading Loading @@ -172,7 +172,7 @@ void ERP_drawScalp (ERP me, Graphics graphics, double tmin, double tmax, double Graphics_setWindow (graphics, -1.0, 1.0, -1.0, 1.0); //Graphics_setGrey (graphics, 1.0); //Graphics_fillRectangle (graphics, -1.1, 1.1, -1.01, 1.19); //Graphics_setColour (graphics, Graphics_BLACK); //Graphics_setColour (graphics, Melder_BLACK); integer numberOfDrawableChannels = my ny >= 64 && Melder_equ (my channelNames [64].get(), U"O2") ? 64 : my ny >= 32 && Melder_equ (my channelNames [32].get(), U"Cz") ? 32 : Loading Loading @@ -243,7 +243,7 @@ void ERP_drawScalp (ERP me, Graphics graphics, double tmin, double tmax, double double x [3] = { -0.08, 0.0, 0.08 }, y [3] = { 0.99, 1.18, 0.99 }; Graphics_fillArea (graphics, 3, x, y); } Graphics_setColour (graphics, Graphics_BLACK); Graphics_setColour (graphics, Melder_BLACK); Graphics_line (graphics, -0.08, 0.99, 0.0, 1.18); Graphics_line (graphics, 0.08, 0.99, 0.0, 1.18); /* Loading @@ -252,7 +252,7 @@ void ERP_drawScalp (ERP me, Graphics graphics, double tmin, double tmax, double Graphics_setGrey (graphics, colourScale == kGraphics_colourScale::BLUE_TO_RED ? 1.0 : 0.5); Graphics_fillRectangle (graphics, -1.09, -1.00, -0.08, 0.08); Graphics_fillRectangle (graphics, 1.09, 1.00, -0.08, 0.08); Graphics_setColour (graphics, Graphics_BLACK); Graphics_setColour (graphics, Melder_BLACK); Graphics_line (graphics, -0.99, 0.08, -1.09, 0.08); Graphics_line (graphics, -1.09, 0.08, -1.09, -0.08); Graphics_line (graphics, -1.09, -0.08, -0.99, -0.08); Loading @@ -273,9 +273,9 @@ void ERP_drawScalp (ERP me, Graphics graphics, double tmin, double tmax, double void structERPWindow :: v_drawSelectionViewer () { ERP erp = (ERP) our data; Graphics_setWindow (our graphics.get(), -1.1, 1.1, -1.01, 1.19); Graphics_setColour (our graphics.get(), Graphics_WINDOW_BACKGROUND_COLOUR); Graphics_setColour (our graphics.get(), Melder_WINDOW_BACKGROUND_COLOUR); Graphics_fillRectangle (our graphics.get(), -1.1, 1.1, -1.01, 1.19); Graphics_setColour (our graphics.get(), Graphics_BLACK); Graphics_setColour (our graphics.get(), Melder_BLACK); integer numberOfDrawableChannels = erp -> ny >= 64 && Melder_equ (erp -> channelNames [64].get(), U"O2") ? 64 : erp -> ny >= 32 && Melder_equ (erp -> channelNames [32].get(), U"Cz") ? 32 : Loading Loading @@ -368,7 +368,7 @@ void structERPWindow :: v_drawSelectionViewer () { double x [3] = { -0.08, 0.0, 0.08 }, y [3] = { 0.99, 1.18, 0.99 }; Graphics_fillArea (our graphics.get(), 3, x, y); } Graphics_setColour (our graphics.get(), Graphics_BLACK); Graphics_setColour (our graphics.get(), Melder_BLACK); Graphics_line (our graphics.get(), -0.08, 0.99, 0.0, 1.18); Graphics_line (our graphics.get(), 0.08, 0.99, 0.0, 1.18); /* Loading @@ -377,7 +377,7 @@ void structERPWindow :: v_drawSelectionViewer () { Graphics_setGrey (our graphics.get(), our p_scalp_colourScale == kGraphics_colourScale::BLUE_TO_RED ? 1.0 : 0.5); Graphics_fillRectangle (our graphics.get(), -1.09, -1.00, -0.08, 0.08); Graphics_fillRectangle (our graphics.get(), 1.09, 1.00, -0.08, 0.08); Graphics_setColour (our graphics.get(), Graphics_BLACK); Graphics_setColour (our graphics.get(), Melder_BLACK); Graphics_line (our graphics.get(), -0.99, 0.08, -1.09, 0.08); Graphics_line (our graphics.get(), -1.09, 0.08, -1.09, -0.08); Graphics_line (our graphics.get(), -1.09, -0.08, -0.99, -0.08); Loading
FFNet/FFNet.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -547,7 +547,7 @@ void FFNet_drawTopology (FFNet me, Graphics g) { x2WC += dx2; } } Graphics_setColour (g, Graphics_RED); Graphics_setColour (g, Melder_RED); x2WC = x2; for (integer j = 1; j <= numberOfUnitsInLayer; j ++) { Graphics_circle (g, x2WC, y2WC, radius); Loading @@ -555,7 +555,7 @@ void FFNet_drawTopology (FFNet me, Graphics g) { Graphics_fillCircle (g, x2WC, y2WC, radius); x2WC += dx2; } Graphics_setColour (g, Graphics_BLACK); Graphics_setColour (g, Melder_BLACK); if (i > 0) { integer numberOfUnitsInLayer_m1 = ( i == 1 ? my numberOfInputs : my numberOfUnitsInLayer [i - 1] ); double dx1 = dx; Loading Loading @@ -595,7 +595,7 @@ void FFNet_drawTopology (FFNet me, Graphics g) { void FFNet_drawActivation (FFNet me, Graphics g) { integer node = 1, maxNumOfUnits = my numberOfInputs; int dxIsFixed = 1; Graphics_Colour colour = Graphics_inqColour (g); MelderColour colour = Graphics_inqColour (g); double dy = 1.0 / (my numberOfLayers + 1); Graphics_setInner (g); Loading @@ -618,7 +618,7 @@ void FFNet_drawActivation (FFNet me, Graphics g) { for (integer j = 1; j <= numberOfUnitsInLayer; j ++, node ++) { double activity = my activity [node]; double radius = r1 * (fabs (activity) < 0.05 ? 0.05 : fabs (activity)); /*Graphics_setColour (g, activity < 0 ? Graphics_BLACK : Graphics_RED);*/ /*Graphics_setColour (g, activity < 0 ? Melder_BLACK : Melder_RED);*/ Graphics_circle (g, x2WC, y2WC, radius); if (activity < 0) Graphics_fillCircle (g, x2WC, y2WC, radius); Loading
LPC/Cepstrumc.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ void Cepstrumc_init (Cepstrumc me, double tmin, double tmax, integer nt, double my samplingFrequency = samplingFrequency; my maxnCoefficients = nCoefficients; Sampled_init (me, tmin, tmax, nt, dt, t1); my frame = NUMvector<structCepstrumc_Frame> (1, nt); my frame = newvectorzero <structCepstrumc_Frame> (nt); } autoCepstrumc Cepstrumc_create (double tmin, double tmax, integer nt, double dt, double t1, Loading
LPC/Cepstrumc_def.h +1 −1 Original line number Diff line number Diff line Loading @@ -45,7 +45,7 @@ oo_DEFINE_CLASS (Cepstrumc, Sampled) oo_DOUBLE (samplingFrequency) // from Sound oo_INT (maxnCoefficients) oo_STRUCT_VECTOR (Cepstrumc_Frame, frame, nx) oo_STRUCTVEC (Cepstrumc_Frame, frame, nx) #if oo_DECLARING void v_info () Loading
LPC/Formant_extensions.cpp +29 −28 Original line number Diff line number Diff line Loading @@ -23,18 +23,20 @@ void Formant_formula (Formant me, double tmin, double tmax, integer formantmin, try { integer numberOfPossibleFormants = my maxnFormants; if (tmax <= tmin) { tmin = my xmin; tmax = my xmax; tmin = my xmin; tmax = my xmax; } if (formantmax >= formantmin) { formantmin = 1; formantmax = numberOfPossibleFormants; formantmin = 1; formantmax = numberOfPossibleFormants; } formantmin = formantmin < 1 ? 1 : formantmin; formantmax = formantmax > numberOfPossibleFormants ? numberOfPossibleFormants : formantmax; Melder_clipLeft (integer (1), & formantmin); Melder_clipRight (& formantmax, numberOfPossibleFormants); autoMatrix fb = Matrix_create (my xmin, my xmax, my nx, my dx, my x1, 1.0, 2 * numberOfPossibleFormants, 2 * numberOfPossibleFormants, 1.0, 1.0); for (integer iframe = 1; iframe <= my nx; iframe ++) { Formant_Frame frame = & my d_frames [iframe]; int numberOfFormants = frame -> nFormants < numberOfPossibleFormants ? frame -> nFormants : numberOfPossibleFormants; Formant_Frame frame = & my frames [iframe]; integer numberOfFormants = std::min (integer (frame -> nFormants), numberOfPossibleFormants); for (integer iformant = 1; iformant <= numberOfFormants; iformant++) { if (iformant <= frame -> nFormants) { fb -> z [2 * iformant - 1] [iframe] = frame -> formant [iformant]. frequency; Loading @@ -43,7 +45,7 @@ void Formant_formula (Formant me, double tmin, double tmax, integer formantmin, } } // Apply formula double ymin = 2.0 * formantmin - 1.0, ymax = 2.0 * formantmax; const double ymin = 2.0 * formantmin - 1.0, ymax = 2.0 * formantmax; Matrix_formula_part (fb.get(), tmin, tmax, ymin, ymax, expression, interpreter, nullptr); // Put results back in Formant integer ixmin, ixmax, iymin, iymax; Loading @@ -52,12 +54,12 @@ void Formant_formula (Formant me, double tmin, double tmax, integer formantmin, for (integer iframe = ixmin; iframe <= ixmax; iframe ++) { // if some of the formant frequencies are set to zero => remove the formant Formant_Frame frame = & my d_frames [iframe]; int numberOfFormants = frame -> nFormants < formantmax ? frame -> nFormants : formantmax; int iformantto = formantmin > 1 ? formantmin - 1 : 0; Formant_Frame frame = & my frames [iframe]; integer numberOfFormants = std::min (integer (frame -> nFormants), formantmax); integer iformantto = ( formantmin > 1 ? formantmin - 1 : 0 ); for (integer iformant = formantmin; iformant <= numberOfFormants; iformant++) { double frequency = fb -> z [2 * iformant - 1] [iframe]; double bandWidth = fb -> z [2 * iformant ] [iframe]; const double frequency = fb -> z [2 * iformant - 1] [iframe]; const double bandWidth = fb -> z [2 * iformant ] [iframe]; if (frequency > 0 && bandWidth > 0) { iformantto ++; frame -> formant [iformantto]. frequency = frequency; Loading Loading @@ -94,20 +96,19 @@ autoIntensityTier Formant_Spectrogram_to_IntensityTier (Formant me, Spectrogram double previousValue = -80000.0; // can never occur double previousTime = my xmin; for (integer iframe = 1; iframe <= my nx; iframe ++) { Formant_Frame frame = & my d_frames [iframe]; Formant_Frame frame = & my frames [iframe]; integer numberOfFormants = frame -> nFormants; double time = Sampled_indexToX (me, iframe); double value = 0; const double time = Sampled_indexToX (me, iframe); double value = 0.0; if (iformant <= numberOfFormants) { double f = frame -> formant [iformant].frequency; const double f = frame -> formant [iformant]. frequency; value = Matrix_getValueAtXY (thee, time, f); value = isdefined (value) ? value : 0.0; } value = 10.0 * log10 ((value + 1e-30) / 4.0e-10); /* dB / Hz */ if (value != previousValue) { if (iframe > 1 && previousTime < time - 1.5 * my dx) { // mark the end of the same interval if (iframe > 1 && previousTime < time - 1.5 * my dx) // mark the end of the same interval RealTier_addPoint (him.get(), time - my dx, previousValue); } RealTier_addPoint (him.get(), time, value); previousTime = time; } Loading