search


Art, Music and the Black-Box
Mon Apr 09 00:00:00 UTC 2018

One of the best way to learn programming is to read other people's code and modify it. This is what we will do in the next class. We will look at some code together and discuss. Then you will pick examples from Quil and Klangmeister . You will modify and play with other people's code and I will be there to guide your exploration and answer any questions that you may have

A useful tool when experimenting with Klangmeister is Wolfram Alpha

(connect-> (sine 440)
           (gain 0.1)) ; Try adjusting the gain.

When you run this example of Klangmeister you can hear it. The gain is defined as multiplication of the sine wave. You can use Wolfram Alpha To see the graph of that sign wave. For example, you can type into Wolfram Alpha
Plot 0.1*sine(x) vs sine(x) x=400 to 500
Wolframe Alpha will show you a graph of 0.1*sine(x) and sine(x) super imposed from x = 400 to 500. Now you can see your sound too!

We have not covered everything in Clojure but we have covered enough so that you can experiment.

Here is what you should already know
  • Invoking functions
  • Defining your own functions with defn
  • Understand namespace: how to create namespace and how to reference names in a namespace
  • Creating global names using def.
  • Creating local names using let
  • Creating list and vectors.
  • Accessing data in a vector using the nth function
Black-box testing

There will things you wouldn't understand, but that is OK. The first step to understand is to ask the right questions so that I can answer. Or you can do your own research by reading documentation and asking Google/Bing/Baidu

We will use a technique called Black Box Testing to experiment with code we didn't write or understand. It is technique use to reverse engineers systems and hacking into systems. As we test the blackbox, we are constantly ask questions like what, why, how, and what if? At first we will give random inputs and observe the output. Base on this understanding we will craft input to test our understanding about how the blackbox works. Blackbox testing is just another form of the Scientific Method



Smile
Wed Apr 04 00:00:00 UTC 2018
Draw a happy face

Today in class we will focus on drawing a happy face. Here are questions you need to answer to draw a happy face

  • How do I draw a circle?
  • How do I move the turtle without drawing?
    • use (penup) to stop drawing. when pen is lifted, calling forward will move the turtle but not draw
    • use (pendown) to start drawing again.
  • How do I draw a semi-circle for the smiling mouth?
    • This is a hard one but look at the circle function. try to understand it. if you don't understand it, use the scientific method and experiment with it in the power turtle REPL

I expect you to struggle through this. This is normal. I remember my first experience programming. I was about your age. I found stack of computer magazine in someone's trash that had source code for games written in BASIC . I had no idea what the code is doing but I painstakingly spent hours typing in the code. What was the result after spending hours typing gibberish I didn't understand? Complete and utter frustration because it did not work due to some typing errors. But I was motivated to play the game so I took a break and tried again later. I finally got it to work after a couple of days fixing typos. I had no idea how the code works, but my interest in playing video games motivated me to learn what the cryptic BASIC code did. Art also motivated me to learn programming. I was facinated with fractals and was interested in learning how to draw fractals. This lead me to learning mathematics even though I hated math.

Drawing a happy face might not inspire you to learn programming but its a simple exercise to demonstrate programming ideas. Find something that motivates you, a problem you want to solve or something you find fun. When you find that right project, you will spend countless hours learning Clojure just so that you can build your project. We don't have enough time together in class for you to gain proficiency in Clojure. You need to motivate yourself and spend time outside of class working on projects that you are passionate about. I can give you guidance but I cannot give you motivation or passion. Seek it yourself and become a creator!

Here's an interview of Kai-Fu Lee , a well known researcher in Artificial Intelligence. He talks about the purpose of human beings if machines can replace routine tasks that people do now. The future is grim for people who are not creators. Be a creator and not a just simple consumer. Start experimenting with many things to find what interests you, then create. If you can't figure it out pick something at random and create something be it in art, music, or computer science or combine multiple disciplines. Passion is discovered when doing hard things and over coming challenges. Who wants to do something easy? There is no fun in that. If you ever find yourself in a stupor dull-drum as a teenager or an adult, just remember back to your childhood when the simpliest of things was a curiosity and facinating. Start from there to find your way again. Some of you have expressed interest in music. We can use Clojure to program music. Perhaps in the next few classes, I can show you how to program music with Clojure. Here is a preview