Loading Sounds#
After covering images, we'll go over this a little bit more quickly. Loading sounds follows mostly the same pattern!
Sound is not build into Processing, however, so there are extra steps involved.
Sound Library Setup#
Processing comes with a "Library Manager" that you will find in your Sketch → Import Library → Manage Libraries menu.
In there, please search for Sound and find the one from the Processing Foundation and hit "install" in the lower right corner.
This should be all that's required. Well... That and a sound file to play!
Mini Soundboard#
Ignore (and copy) the import
on line 1 for now. That's a topic for much later. Other than that, this looks somewhat similar.
- We declare two variables of type
SoundFile
(lines 2 and 3). - We use
new Soundfile()
in lines 6 and 7 to load the file (yes, this looks different than what we did before, but it serves the same purpose). - We use
.play()
to trigger playing that sound file. (lines 16 or 18)
Example on Gitlab
You will find this code example in the Examples Gitlab Repository, including the two clips.
Many Many Possibilities#
Sound is a thing we're not getting into too much, sadly. There are TONS of options here that we can't cover. I would encourage you to skim Processing's Sound Reference! You can even work with live audio!
Sound Sources#
Here are a few places where you can get audio clips
(okay, admittedly that list is not very long. Sorry. Suggestions welcome!)
Always Credit the Author
In a university context, all work you hand in is assumed to be yours, that includes any assets that you use. Credit authors of sound bites even if their license does not require it.