The Processsing Sound library sounds fine in py5 #779
Replies: 2 comments
-
|
Neat, very nice that the Processing sound library can easily integrate with py5. This work: https://jamesschmitz.art/the-earth-eaters.html has sound. I tried the Processing sound library but didn't like how it handles loops. There's a pause when an audio file loops, which didn't work for us. Instead I used mpv with the Python library https://pypi.org/project/mpv/. It is a more sophisticated library (it does video also) and requires more effort to get working. It does work nicely though. It is a worthy alternative to VLC. |
Beta Was this translation helpful? Give feedback.
-
|
The simple microphone input example ported... """
This is an example ported from the Processing Sound library examples.
Grab audio from the microphone input and draw a circle whose size
is determined by how loud the audio input is.
"""
import py5
from processing.sound import AudioIn, Amplitude
def setup():
global snd_input, loudness
py5.size(640, 360)
py5.background(255)
this = py5.get_current_sketch()
# Create an Audio snd_input and grab the 1st channel
snd_input = AudioIn(this, 0)
# Begin capturing the audio snd_input
snd_input.start()
# start() activates audio capture so that you can use it as
# the snd_input to live sound analysis, but it does NOT cause the
# captured audio to be played back to you. if you also want the
# microphone snd_input to be played back to you, call
# snd_input.play()
# instead (be careful with your speaker volume, you might produce
# painful audio feedback. best to first try it out wearing headphones!)
# Create a new Amplitude analyzer
loudness = Amplitude(this)
# Patch the snd_input to the volume analyzer
loudness.input(snd_input)
def draw():
# Adjust the volume of the audio snd_input based on mouse position
snd_input_level = py5.remap(py5.mouse_y, 0, py5.height, 1.0, 0.0)
snd_input.amp(snd_input_level)
# loudness.analyze() return a value between 0 and 1. To adjust
# the scaling and mapping of an ellipse we scale from 0 to 0.5
volume = loudness.analyze()
d = int(py5.remap(volume, 0, 0.5, 1, 350))
py5.background(125, 255, 125)
py5.no_stroke()
py5.fill(255, 0, 150)
# We draw a circle whose size is coupled to the audio analysis
py5.circle(py5.width / 2, py5.height / 2, d)
py5.run_sketch() |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Just passing to say that a first very attempt at reproducing
.aifsound samples went well, it seemed super easy...I used 5 files that come with one the Processing Sound example sketches.
If I have the chance to check the (many) other features from the library (such as input and analysis) I'll report here. And if someone else wishes to experiment and post on this thread, it would be awesome.
Beta Was this translation helpful? Give feedback.
All reactions