/** * Create a new pitch detector for a stream with the defined sample rate. * Processes the audio in blocks of the defined size. * * @param audioSampleRate * The sample rate of the audio stream. E.g. 44.1 kHz. * @param bufferSize * The size of a buffer. E.g. 1024. * @param yinThreshold * The parameter that defines which peaks are kept as possible * pitch candidates. See the YIN paper for more details. */ public YinPitchDetector(float audioSampleRate, int bufferSize, double yinThreshold) { this.sampleRate = audioSampleRate; this.threshold = yinThreshold; yinBuffer = new float[bufferSize / 2]; result = new PitchDetectionResult(); }
/** * A copy constructor. Since PitchDetectionResult objects are reused for performance reasons, creating a copy can be practical. * @param other */ public PitchDetectionResult(PitchDetectionResult other) { this.Pitch = other.Pitch; this.Probability = other.Probability; this.IsPitched = other.IsPitched; }