Chapter 1: Introduction to Computer Science and Media
What is computer science about?
What computers really understand,
and where Programming Languages fit in
Media Computation: Why digitize media?
How can it possibly work?
def paste( source, target ):
targetDup = duplicatePicture( target )
for x in range(0, getWidth(source):
for y in range(0, getHeight(source):
targetPixel = getPixel(targetDup, x, y)
sourcePixel = getPixel(source, x, y)
sourceColor = getColor
30 October 2013
for sample in getSamples(sound):
value = getSample(sample)
def normalize(sound): #from the book
largest = 0
for sample in getSamples(sound):
largest = max(largest, getSample(sample)
multiplier = 32
String: characters in double or single quotes (asdfjkl)
> str(123.4) #turns it into a string
s = str(dslkdfdkl)
#you can store strings in variables
range() prints out an array of numbers
can call specific locations in the array and edit the array
mirrorPoint = getWidth(source) / 2
width = getWidth(source)
for y in range (0, getHeight(source):
for x in range (0, mirrorPoint):
leftPixel = getPixel(source, x, y)
rightPixel = getPixel(source, width-x-1, y)
color = getColor(
def swapBack(pic, back, newBG):
for x in range(0, getWidth(pic):
for y in range(0, getHeight(pic):
p1Pixel = getPixel(pic, x, y)
backPixel = getPixel(back, x, y)
addText(pict, x, y, string) puts string at position (x, y) in
/Bucky Tutorial: 84
/THe purpose of this program is to make graphics on the screen
public class Drawphics extends JPanelcfw_
/this method is used to create all graphics
/Bucky Tutorials: 77
/Adapter classes allow for implementation of only methods that are needed/used from interfaces
/i.e instead of overwriting all of the methods in MouseListener and Mouse
/Bucky Tutorial: 74 - 76
import java.awt.*; /imports colors, border layouts, etc
public class MouseClass extends JFramecfw_
private JPanel mousepanel; /empty space to test out all of the mouse events
The physics of sound:
-sounds are waves of air pressure which come in cycles
-frequency = number of cycles per second (Hertz)
-amplitude = maximum height of the wave
-our perception of volume is logarithmically related to changes in amplitude
Topics in Computer Science: Object-Oriented
History of Objects: Where they
Start of the Story: Late 60's and Early 70's
Windows are made of glass, mice are undesirable rodents
Good programming = Procedural Abstraction
Chapter 2: Introduction to Programming
Chapter Learning Objectives
Installing JES and starting it up
Go to http:/www.mediacomputation.org and get the version of JES for your
If you know that you have a Java compiler (e.g., a JDK o
Chapter 3: Modifying Pictures using Loops
We perceive light different from
how it actually is
Color is continuous
Visible light is in the wavelengths between 370 and 730 nanometers
Thats 0.00000037 and 0.00000073 meters
But we perceive light with color s
Chapter 4: Modifying Pixels in a Range
Reminder: Pixels are in a matrix
Matrices have two dimensions: A height and a width
We can reference any element in the matrix with (x,y) or
We refer to those coordinates as index numbers or in
Chapter 6: Modifying Sounds Using Loops
How sound works:
Acoustics, the physics of sound
Sounds are waves of air
Sound comes in cycles
The frequency of a wave is the
number of cycles per second
(cps), or Hertz
more than one
Modifying Samples in a Range
Knowing where we are in the
More complex operations require us to know where we
are in the sound, which sample
Not just process all the samples exactly the same
Reversing a sound
Its just copying, li
Chapter 8: Making Sounds by Combining Pieces
We know that natural sounds are often the combination
of multiple sounds.
Adding waves in physics or math is hard.
In computer science, its easy! Simply add the samples
at the same index in the two waves:
Building Bigger Programs
How to Design Larger
Building something larger requires good software engineering.
Top-down: Start from requirements, then identify the pieces to
write, then write the pices.
Bottom-up: Start building pieces
Creating and Modifying Text
Text is the universal medium
We can convert any other media to a text representation.
We can convert between media formats using text.
Text is simple.
Like sound, text is usually processed in an arraya long
Advanced Text Techniques: Web and Information
Networks: Two or more
Networks are formed when distinct computers
communicate via some mechanism.
Rarely does the communication take the place of 0/1
voltages over a wire.
Making Text for the Web
Hypertext Markup Language
HTML is a kind of SGML (Standardized general markup
SGML was invented by IBM and others as a way of defining parts of a document
COMPLETELY APART FROM HOW THE DOCUMENT WAS FOR
Creating and Modifying Movies
Movies, animations, and video
Were going to refer generically to captured (recorded)
motion as movies.
This includes motion entirely generated by graphical
drawings, which are normally called animations.
Topics in Computer Science: Speed
Big speed differences
Many of the techniques weve learned take no time at all
in other applications
Select a figure in Word.
Its automatically inverted as fast as you can wipe.
Color changes in Photoshop happe
Topics in Computer Science: Functional Programming
Functions: Whats the point?
Why do we have functions?
More specifically, why have more than one?
And if you have more than one, which ones should you
Once I have functions, what can I us
/Bucky Tutorial: 70 - 71
/The purpose of JList is to make a list of a GUI and when an option is clicked, an event
public class JListClass extends JFrame