Saturday, August 16, 2008

august 14 notes

August 14 notes

Minim libraries for using sound
Tritonin libraires will be future for sound in processing

toxi.code or toxilibs (look at google code).


Object oriented programming

An extension of the way to work. If you use functions you are starting to use object oriented programming.

Attributes and then stept.

Instantiate object – choose instance variables. Push matrix and pop matrix inside the class so you can draw lots of them. Variable in object-speak is an attribute. Can change attributes over time like a variable and find owh what they bcome.


Underscore is to separate variable that has already been defined. So it’s an instance of the variable and easier to figure out what you used because it’s similar without being the same, which you can’t use the same variable for 2 different thing.

To be really good you would encapsulate those values. Below is good code form for programming with many classes. Not usual for processing sketches which should be fast and simple.

void setX(_x) {
x = _x;
}

void get() {
y = _y;
}



Private variables are not available outside of something.


Peter showed an example of using laptop microphone to read into the cube tower and change the stacking order so it pops. Then he did a spectral analysis.

Objects makes it easier to use more than one object. Showed array of cube towers that react to his voice in different ways. Efficient and fast. Frequency spectrum. Has same basic idea.

Making arrays of objects. Go to people example.

CubeTower[] towers;


Class name[] array instance name. use plural for name of array so you remember what it is when you see it again.

When you create an object variable you make a space in memory for it. Like an empty box. First you create a name for it.

For an array, you make more of them. So name array and make a variable for it. Then you fill each empty box with some stuff.

Person[] people;
people = new Person[4];



pushMatrix and popMatrix is within the object class to draw but not within draw in this case.


For next week read dan shifmann’s class chapter 8 about object oriented programming and chapter 9 and do the examples.




Ben Fry book Visualizing Data uses processing for all the examples so if you want to do lots of rollover types of things get that book and look at how he does the examples. The book is not about processing but still makes a good reference work.

No comments: