Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Science I Libraries. Sound. Saving frames as images. Classwork/Homework: Make sketch using sound. Add saving frames.

Similar presentations


Presentation on theme: "Computer Science I Libraries. Sound. Saving frames as images. Classwork/Homework: Make sketch using sound. Add saving frames."— Presentation transcript:

1 Computer Science I Libraries. Sound. Saving frames as images. Classwork/Homework: Make sketch using sound. Add saving frames.

2 Libraries are collections of code. Why doesn't the Processing Development Environment (or IntelliJ, which comes next) provide everything? – Too big – New ones being developed all the time. So, the mechanism for including new stuff is the same as mechanism for including more of built-in stuff import libraryname;

3 Steps to using sound Make or find a sound file(s) you want. Download In Processing, use Sketch/Add file… find on your computer In Processing, use Sketch/Inport Library…/Add Library… find on list. If it isn't there, find it online and look up how to add!

4 Very simple example // using sound import processing.sound.*; SoundFile shutter; void setup() { size(600,400); shutter = new SoundFile(this,"camera-shutter-click-01.wav"); frameRate(.25); //notice slowing down of frames } void draw() { shutter.play(); } Notice this

5 About the reference this Remember: our Processing code actually is part of a larger Java program. Using sound (and video and other things) requires some attention to the rest of the coding. The this refers to the object, called a PApplet, that holds our code.

6 Saving frames Making the current frame into an image file and saving that image file to the Sketch folder. The function is saveFrame(your_choice_of_name); Can designate a folder AND series of numbers. I chose to add code to my path making Sketch and take the snapshot when user clicks on key.

7 Within a program void keyPressed(){ saveFrame("snaps/worms####.png"); }

8 When to trigger taking snapshot? Whenever you want! Caution: if you do it in draw, and have a high frameRate, that will be a lot of pictures. Possibilities: keyPressed, mouse action, condition determined by coding, etc.

9 To retrieve Processing/Sketch/Show Sketch folder

10 Family mark for my father

11 Classwork Incorporate sound – Find sound file(s) – Write your own program using sound. Add to data file Import library – Use headset to check? – Obvious choice is some kind of bump when bouncing thing hits the wall Incorporate saving image of frames – Obvious choice: make a sound like a camera shutter when taking a snapshot


Download ppt "Computer Science I Libraries. Sound. Saving frames as images. Classwork/Homework: Make sketch using sound. Add saving frames."

Similar presentations


Ads by Google