示例#1
0
文件: swmixer.py 项目: cutun/kazoo
def mic_test (play_background = False):
  """records and plays back data from the microphone
  while playing a test sound in the background.
    
  (2009:12:10) XXX this has high latency"""

  import sys
  import swmixer
  import numpy

  swmixer.init(samplerate=44100, chunksize=1024, stereo=False, microphone=True)

  if play_background:
    snd = swmixer.Sound("test.wav")
    snd.play(loops=-1)

  micdata = []
  frame = 0

  while True:
    swmixer.tick()
    frame += 1
    if frame < 50:
      micdata = numpy.append(micdata, swmixer.get_microphone())
    if frame == 50:
      micsnd = swmixer.Sound(data=micdata)
      micsnd.play()
      micdata = []
      frame = 0
示例#2
0
文件: test4.py 项目: ypcs/pygalaxy
import sys
import swmixer
import numpy

swmixer.init(samplerate=44100, chunksize=1024, stereo=False, microphone=True, input_device_index=1)
snd = swmixer.Sound("test1.wav")
snd.play(loops=-1)

micdata = []
frame = 0

while True:
    swmixer.tick()
    frame += 1
    if frame < 50:
        micdata = numpy.append(micdata, swmixer.get_microphone())
    if frame == 50:
        micsnd = swmixer.Sound(data=micdata)
        micsnd.play()
        micdata = []
        frame = 0

    

示例#3
0
import sys
import swmixer
import numpy

swmixer.init(samplerate=44100, chunksize=1024, stereo=False, microphone=True)
snd = swmixer.Sound("test1.wav")
snd.play(loops=-1)

micdata = []
frame = 0

while True:
    swmixer.tick()
    frame += 1
    if frame < 50:
        micdata = numpy.append(micdata, swmixer.get_microphone())
    if frame == 50:
        micsnd = swmixer.Sound(data=micdata)
        micsnd.play()
        micdata = []
        frame = 0