Electric Boogaloo Processing Basics Audio Processing has a builtin audio library known as Minim Import it by using import ddfminim then create a Minim object M inim minim There are two types of objects that Minim uses that will be focused on ID: 617420
Download Presentation The PPT/PDF document "Processing II" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Processing II
Electric BoogalooSlide2
Processing Basics – Audio
Processing has a built-in audio library known as
Minim
Import it by using import ddf.minim.*, then create a Minim object (Minim minim;)There are two types of objects that Minim uses that will be focused on: AudioPlayer and AudioSample.
AudioPlayer
is used primarily for background music, while AudioSample is best used for sound effects that are triggered. Slide3
Processing Basics – Audio (cont’d)
Just like with Images, you need to load your music files to actually get them to play
First, put your music file in your project folder like you’d do for a picture
Accepted formats include .mp3, .wav, .aiff, .au, & .sndLoading files is different for whether you want to use the Player or the Sample, see the syntax belowSlide4
Processing Basics – Audio (cont’d)
Now that the files are loaded, all that’s left is to play them when desired. You can do this in either the
setup()
or the draw() functionsAudioSamples can be used as triggered sounds, like when a button is pressed like below, note that keyPressed is kept within it’s own function, not in draw() or setup()Slide5
Processing Basics – Audio (cont’d)
There are many more functions that can be used within the minim library, all can be found in the reference library on their website at:
http://code.compartmental.net/minim
/:^)Slide6
Processing Basics – Key Input
Sometimes, you want to have actions go on the press of a key instead of the click of a mouse
Processing has a very easy function:
void keyPressed(),that allows you to do just thatTo have an event occur off of an ASCII-applicable key, you can set the reserved word ‘key’ equal to a char of the letterSlide7
Processing Basics – Key Input
To do something with a “special”
key,
such as the arrow keys, you need to put an extra if statement if (key == CODED) within your keyPressed function. This will allow you to refer to the key presses by certain key words like UP, DOWN, etc.Use the processing reference library for other keyCodes:https://processing.org/reference/