def switchOn(sampleRate=48000, outputDevice=None, bufferSize=None):
    """You need to switch on the microphone before use, which can take
    several seconds. The only time you can specify the sample rate (in Hz)
    is during switchOn().

    Considerations on the default sample rate 48kHz::

        DVD or video = 48,000
        CD-quality   = 44,100 / 24 bit
        human hearing: ~15,000 (adult); children & young adult higher
        human speech: 100-8,000 (useful for telephone: 100-3,300)
        Google speech API: 16,000 or 8,000 only
        Nyquist frequency: twice the highest rate, good to oversample a bit

    pyo's downsamp() function can reduce 48,000 to 16,000 in about 0.02s
    (uses integer steps sizes). So recording at 48kHz will generate
    high-quality archival data, and permit easy downsampling.

    outputDevice, bufferSize: set these parameters on the pyoSndServer
        before booting; None means use pyo's default values
    """
    # imports pyo, creates sound.pyoSndServer using sound.initPyo() if not yet
    # created
    t0 = core.getTime()
    try:
        global pyo
        import pyo
        global haveMic
        haveMic = True
    except ImportError:  # pragma: no cover
        msg = ('Microphone class not available, needs pyo; '
               'see http://code.google.com/p/pyo/')
        logging.error(msg)
        raise ImportError(msg)
    if pyo.serverCreated():
        sound.pyoSndServer.setSamplingRate(sampleRate)
    else:
        # sound.initPyo() will create pyoSndServer. We want there only
        # ever to be one server
        # will automatically use duplex=1 and stereo if poss
        sound.initPyo(rate=sampleRate)
    if outputDevice:
        sound.pyoSndServer.setOutputDevice(outputDevice)
    if bufferSize:
        sound.pyoSndServer.setBufferSize(bufferSize)
    logging.exp('%s: switch on (%dhz) took %.3fs' %
                (__file__.strip('.py'), sampleRate, core.getTime() - t0))
def switchOn(sampleRate=48000, outputDevice=None, bufferSize=None):
    """You need to switch on the microphone before use, which can take
    several seconds. The only time you can specify the sample rate (in Hz)
    is during switchOn().

    Considerations on the default sample rate 48kHz::

        DVD or video = 48,000
        CD-quality   = 44,100 / 24 bit
        human hearing: ~15,000 (adult); children & young adult higher
        human speech: 100-8,000 (useful for telephone: 100-3,300)
        Google speech API: 16,000 or 8,000 only
        Nyquist frequency: twice the highest rate, good to oversample a bit

    pyo's downsamp() function can reduce 48,000 to 16,000 in about 0.02s
    (uses integer steps sizes). So recording at 48kHz will generate
    high-quality archival data, and permit easy downsampling.

    outputDevice, bufferSize: set these parameters on the pyoSndServer
        before booting; None means use pyo's default values
    """
    # imports pyo, creates sound.pyoSndServer using sound.initPyo() if not yet
    # created
    t0 = core.getTime()
    try:
        global pyo
        import pyo
        global haveMic
        haveMic = True
    except ImportError:  # pragma: no cover
        msg = ('Microphone class not available, needs pyo; '
               'see http://code.google.com/p/pyo/')
        logging.error(msg)
        raise ImportError(msg)
    if pyo.serverCreated():
        sound.pyoSndServer.setSamplingRate(sampleRate)
    else:
        # sound.initPyo() will create pyoSndServer. We want there only
        # ever to be one server
        # will automatically use duplex=1 and stereo if poss
        sound.initPyo(rate=sampleRate)
    if outputDevice:
        sound.pyoSndServer.setOutputDevice(outputDevice)
    if bufferSize:
        sound.pyoSndServer.setBufferSize(bufferSize)
    logging.exp('%s: switch on (%dhz) took %.3fs' %
                (__file__.strip('.py'), sampleRate, core.getTime() - t0))
 def test_reinit_pyo(self):
     pytest.skip()
     # was stalling on some machines; revisit if decide to stick with pyo
     sound.initPyo()
 def test_reinit_pyo(self):
     pytest.skip()
     # was stalling on some machines; revisit if decide to stick with pyo
     sound.initPyo()
Exemple #5
0
 def test_reinit_pyo(self):
     sound.initPyo()
Exemple #6
0
 def test_reinit_pyo(self):
     sound.initPyo()