# Path: fofix/core/Language.py
# def getAvailableLanguages():


import logging
import math
import numpy as np
    import pyaudio
from fretwork.task import Task
from fretwork.audio import MicrophonePassthroughStream
from fofix.core.Language import _
    from pypitch import pypitch
        def getSemitones(self):
            tone = self.analyzer.findTone()
            if tone is None:
                return tone
            return int(round((math.log(tone.freq) - LN_440) * 12.0 / LN_2) % 12)

        # Work out how accurately the note (passed in as a MIDI note number) is being
        # sung.  Return a float in the range [-6.0, 6.0] representing the number of
        # semitones difference there is from the nearest occurrence of the note.  The
        # octave doesn't matter.  Or return None if there's no note being sung.
        def getDeviation(self, midiNote):
            tone = self.analyzer.findTone()
            if tone is None:
                return tone

            # Convert to semitones from A-440.
            semitonesFromA440 = (math.log(tone.freq) - LN_440) * 12.0 / LN_2
            # midiNote % 12 = semitones above C, which is 3 semitones above A
            semitoneDifference = (semitonesFromA440 - 3.0) - float(midiNote % 12)
            # Adjust to the proper range.
            acc = math.fmod(semitoneDifference, 12.0)
            if acc > 6.0:
                acc -= 12.0
            elif acc < -6.0:
                acc += 12.0
            return acc


else:
    def getAvailableMics():

# Path: fofix/core/Language.py
# def getAvailableLanguages():


# Path: fofix/core/Microphone.py
import logging
import math
import numpy as np
    import pyaudio
from fretwork.task import Task
from fretwork.audio import MicrophonePassthroughStream
from fofix.core.Language import _
    from pypitch import pypitch

        def getSemitones(self):
            tone = self.analyzer.findTone()
            if tone is None:
                return tone
            return int(round((math.log(tone.freq) - LN_440) * 12.0 / LN_2) % 12)

        # Work out how accurately the note (passed in as a MIDI note number) is being
        # sung.  Return a float in the range [-6.0, 6.0] representing the number of
        # semitones difference there is from the nearest occurrence of the note.  The
        # octave doesn't matter.  Or return None if there's no note being sung.
        def getDeviation(self, midiNote):
            tone = self.analyzer.findTone()
            if tone is None:
                return tone

            # Convert to semitones from A-440.
            semitonesFromA440 = (math.log(tone.freq) - LN_440) * 12.0 / LN_2
            # midiNote % 12 = semitones above C, which is 3 semitones above A
            semitoneDifference = (semitonesFromA440 - 3.0) - float(midiNote % 12)
            # Adjust to the proper range.
            acc = math.fmod(semitoneDifference, 12.0)
            if acc > 6.0:
                acc -= 12.0
            elif acc < -6.0:
                acc += 12.0
            return acc


else:
    def getAvailableMics():

        return {-1: _('[Microphones not supported]')}