예제 #1
0
    void PitchDetected(PitchTracker sender, PitchTracker.PitchRecord record)
    {
        if (!Constants.GameOn)
        {
            return;
        }

        if (record.Pitch > 0)
        {
            bool consistentNote = true;
            foreach (PitchTracker.PitchRecord rec in pitchTracker.PitchRecords)
            {
                if (rec.MidiNote != 0 && record.MidiNote != rec.MidiNote)
                {
                    consistentNote = false;
                    break;
                }
            }

            if (consistentNote)
            {
                MidiNote   = record.MidiNote;
                PitchValue = record.Pitch;
                PitchAC    = record.Pitch;
            }
        }
    }
예제 #2
0
    /// <summary>
    /// Pitchs detected delegate.
    /// </summary>
    /// <param name="sender">Sender.</param>
    /// <param name="pitchRecord">Pitch record.</param>
    private void PitchDetectedListener(PitchTracker sender, PitchTracker.PitchRecord pitchRecord)
    {
        int pitch = (int)Mathf.Round(pitchRecord.Pitch);

        if (!detectedPitches.Contains(pitch))
        {
            detectedPitches.Add(pitch);
        }

        int lowestPitch = pitch;

        foreach (int p in detectedPitches)
        {
            if (p > 0 && p < lowestPitch)
            {
                lowestPitch = p;
            }
        }

        currrentPitch = lowestPitch;

        // Fire pitch detected event
        if (pitchDetectedEvent != null)
        {
            pitchDetectedEvent(currrentPitch);
        }
    }
예제 #3
0
        private void PitchDetectedListener(PitchTracker sender, PitchTracker.PitchRecord pitchRecord)
        {
            int pitch = (int)Math.Round(pitchRecord.Pitch);

            if (!_detectedPitches.Contains(pitch))
            {
                _detectedPitches.Add(pitch);
            }
        }
예제 #4
0
    private void PitchDetected(PitchTracker sender, PitchTracker.PitchRecord pitchRecord)
    {
        float logPitch = Mathf.Log(pitchRecord.Pitch, 2);

        if (!float.IsInfinity(logPitch))
        {
            currentPitch   = logPitch - midPitch;
            isPitchChanged = true;
        }
    }
예제 #5
0
    private void PitchDetected(PitchTracker sender, PitchTracker.PitchRecord pitchRecord)
    {
        float logPitch = Mathf.Log(pitchRecord.Pitch, 2);

        if (!float.IsInfinity(logPitch))
        {
            if (!currentPitch.HasValue)
            {
                currentPitch = 0;
            }
            currentPitch += logPitch;
            numPitchSamples++;
        }
    }
예제 #6
0
        private void OnPitchDetected(PitchTracker sender, PitchTracker.PitchRecord pitchRecord)
        {
            // During the call to PitchTracker.ProcessBuffer, this event will be fired zero or more times,
            // depending how many pitch records will fit in the new and previously cached buffer.
            //
            // This means that there is no size restriction on the buffer that is passed into ProcessBuffer.
            // For instance, ProcessBuffer can be called with one large buffer that contains all of the
            // audio to be processed, or just a small buffer at a time which is more typical for realtime
            // applications. This PitchDetected event will only occur once enough data has been accumulated
            // to do another detect operation.

            /*
             * cfg.logInfo("PITCH", "MidiCents: " + pitchRecord.MidiCents
             + " MidiNote: " + pitchRecord.MidiNote
             + " Pitch: " + pitchRecord.Pitch
             + " RecordIndex: " + pitchRecord.RecordIndex);*/
            double d = pitchRecord.Pitch;

            if (d > 0)
            {
                pitch.Add(d);
            }
        }
예제 #7
0
 private void HandleNewPitchDetected(PitchTracker sender, PitchTracker.PitchRecord pitchRecord)
 {
     _pitchesThisUpdate.Add(pitchRecord.Pitch);
 }