Skip to content

Instantly share code, notes, and snippets.

@villares
Created March 27, 2021 15:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save villares/365fc8a551663e9279779df5c78256c0 to your computer and use it in GitHub Desktop.
Um exemplo mínimo de escutar o volume do microfone no Processing modo Python
add_library('sound') # aviso de que vai usar o microfone
x, y = 400, 300
def setup():
global loudness
size(800, 600)
# fullScreen() # testar se 1 vai para segundo monitor
background(0)
# Burocracia para receber o som e analisar o volume
source = AudioIn(this, 0)
source.start()
loudness = Amplitude(this)
loudness.input(source)
def draw():
fill(0, 10)
noStroke()
rect(0, 0, width, height)
volume = loudness.analyze()
tamanho = int(map(volume, 0, 0.5, 30, 350))
stroke(255)
circle(x, y, tamanho)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment