Giter VIP home page Giter VIP logo

Comments (3)

villares avatar villares commented on June 7, 2024

Sim!

Para fazer isso é possível usar a biblioteca Sound da própria fundação Processing.
Dá tanto para ouvir um arquivo .mp3 como a entrada de áudio (ou microfone) do micro em tempo ral.

Examplo de sketch que reage ao som (precisa baixar a biblioteca Sound no IDE):
https://github.com/villares/sketch-a-day/blob/f4b15d8ac49d12cbd31eff4995addf606de3df3d/2019/sketch_190916b/sketch_190916b.pyde

from material-aulas.

villares avatar villares commented on June 7, 2024

Vou começar a escrever alguma coisa nesta página aqui:
https://github.com/villares/material-aulas/blob/master/Processing-Python/audio_in_out.md

  • Reagir ao microfone
  • Produzir som
    • Importar e tocar um arquivo/sample de som (mp3 ou outro formato)
    • Produzir som sintetizado
  • Visualizações / análise da onda sonora

https://github.com/villares/py.processing-play/tree/master/sound_samples

from material-aulas.

villares avatar villares commented on June 7, 2024

Com a migração para o py5, eu vou fechar essa issue.

Me interessaria sim mostrar integração com som, mas teria que abrir uma outra issue nova.

Exemplo do sketch-a-day com pyaudio https://github.com/villares/sketch-a-day/blob/main/2023/sketch_2023_04_08/sketch_2023_04_08.py

import py5
import pyaudio
import numpy as np

"""Simple Blocking Stream PyAudio"""
CHUNK = 128  # Samples: 1024,  512, 256, 128
RATE = 44100  # Equivalent to Human Hearing at around 40 kHz
INTERVAL = 0.1  # Sampling Interval in Seconds

# If you are having trouble  making sense of the above, this might help:
# CHUNK: How many slices of sound
# RATE: How Fast these slices are captured
# INTERVAL: How much time to listen
# INIT PyAudio Instance
p = pyaudio.PyAudio()
# OPEN/Configure Stream:
stream = p.open(format=pyaudio.paInt16,
                channels=1,
                rate=RATE,
                input=True,
                frames_per_buffer=CHUNK)

def setup():
    py5.size(400, 400)
    py5.no_fill()

def draw():
    py5.background(240)
    sample_size = int(INTERVAL*RATE/CHUNK)
    w = py5.width / sample_size
    for i in range(sample_size):  # STREAN INTERVAL
        data = np.frombuffer(stream.read(CHUNK), dtype=np.int16)
        v = np.amax(data)
        py5.circle(i * w, py5.height / 2, v / 10)
        
def exiting():
    stream.stop_stream()
    stream.close()
    p.terminate()

py5.run_sketch()

from material-aulas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.