We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Wrapping up the semester in intro programming, students are happily using processing's python mode. Trying to figure out how to let them play sounds in python mode. I've tried a few things to no avail, but I'm hoping someone here can just make it easy for me and post a snippet of python mode that plays a sound from a sound file. Thanks, Albert
Answers
Thanks, didn't really know about the whole library system. Beads was way more than I was looking for, but the "sound" library from the processing folks is great. After adding the sound library using the "Sketch -> Import Library... -> Add Library..." dialog (I did this in Java mode, not sure if that matters), the following little snippet works just fine in Python mode (provide your own sound file and put it in the data folder of the sketch):
It should not! But who cares? :)) Glad it's finally worked for ya! :-bd
On a side note, I'm curious about the "this" argument in the SoundFile() function. What's it doing? It has to be there, but I don't know why.
this
is a Java keyword which holds the current instance reference of the class it's scoped written: https://Processing.org/reference/this.htmlthis
is outside any class, it refers to the sketch's PApplet instance.this
.this
changes its datatype according to the class it belongs to.