double structVector :: v_getValueAtSample (long isamp, long ilevel, int unit) { // Preconditions: // 1 <= isamp <= my nx // 0 <= ilevel <= my ny double value; if (ilevel > Vector_CHANNEL_AVERAGE) { value = z [ilevel] [isamp]; } else if (ny == 1) { value = z [1] [isamp]; // optimization } else if (ny == 2) { value = 0.5 * (z [1] [isamp] + z [2] [isamp]); // optimization } else { double sum = 0.0; for (long channel = 1; channel <= ny; channel ++) { sum += z [channel] [isamp]; } value = sum / ny; } return NUMdefined (value) ? v_convertStandardToSpecialUnit (value, ilevel, unit) : NUMundefined; }
double structPitch :: v_getValueAtSample (long iframe, long ilevel, int unit) { double f = frame [iframe]. candidate [1]. frequency; if (f <= 0.0 || f >= ceiling) return NUMundefined; // frequency out of range (or NUMundefined)? Voiceless return v_convertStandardToSpecialUnit (ilevel == Pitch_LEVEL_FREQUENCY ? f : frame [iframe]. candidate [1]. strength, ilevel, unit); }
double Function_convertStandardToSpecialUnit (Function me, double value, long ilevel, int unit) { return NUMdefined (value) ? my v_convertStandardToSpecialUnit (value, ilevel, unit) : NUMundefined; }
double structMatrix :: v_getValueAtSample (long isamp, long ilevel, int unit) { double value = our z [ilevel] [isamp]; return NUMdefined (value) ? our v_convertStandardToSpecialUnit (value, ilevel, unit) : NUMundefined; }