Created
March 27, 2021 15:00
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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