[Note: this webpage last modified Friday, 04-Feb-2011 19:44:51 EST]
Adinistrative...
Homework 7.
Final Project.
Wednesday office hours canceled.
Today: splitting into multiple files using import, general copy and clip functions (more splicing, this time with spoken words)
Putting code into a separate function that can act like a "library" that we can just reuse anytime we need it.
The way to do that in Python is with the import command. I have put all the functions we have done in class into a file called cs151functions.py that you can download off the webpage. The Python sample file for today shows how to use the functions from that file without having to retype them or copy/paste them.
This is good! No more copy/pasting of old functions! And if we ever want to change the old functions, we only need to change them once.
Warning: the functions being imported are only "loaded" the first time JES sees them. If you make changes to the cs151functions.py file, you need to quit JES and open it again to make JES reload the file.
Warning: JES has been "loading/importing" for us all along - all the media type functions (like getRed, makeSound, etc.) and some math functions like sqrt. I had to import those myself in the cs151functions.py file because JES does not automatically load those things for files that are imported.
More splicing, with general copy and clip functions.
Clip - function that gets as input a sound, and the index of which sample to start and which sample to stop, and then creates a sound clip of that part of the sound.
Copy - copies one sound into a specified part of another sound.
Next time: "lab" day.
And make sure to take the quiz, and type things into JES to try them out!