Bach, Mozart and Brahms walk into a bar...
of music :)
That's all I wanted to create; a bar of music with a staff, a treble clef and some notes for good measure (ooh...that's a musical pun!)
Working in Python/turtles and text-based coding was a good experience in literalism. The program will run as coded. Or will not, as I learned. So much of the experience was about finding that one little thing that was not properly coded and making the change. A few times it was an extra space between my turtle name and the command, other times it was forgetting to put in the period. Several times it was misspelling my turtles' names. (I gave all of my turtles names of composers.) The work required multiple trials and runs and a concentration and focus that I usually reserve for writing music or lyrics. It was somewhat all-consuming and it was extraordinary how quickly time flew by in an attempt to program just one little part of the desired image.
I began with the staff. There were several ways to do this; by coding the horizontal line, then 90 degrees right or left which, when it was run, created a labyrinth of lines that I eventually capped at each end. Then I tried coding it so that the turtle would backtrack over its lines, leaving the end bar as its final program. I felt it looked more elegant that way when running.
In an effort to use as little code as possible, I used a 'repeat' function so that the staff lines would repeat without having to code each command multiple times:
To avoid having to watch the staff run over and over in order to begin another element, I created separate repls to work on the other elements. The treble clef was the most difficult element. I was stuck in a visual of how I had always handwritten my treble clefs. It wasn't until I let go of the idea of creating that specific image and allowed myself to embrace the notion of a stylized treble clef, working within the lines and arcs in the program, that I began to have some fun with it:
January,
ReplyDeleteThis is just so great. I particularly loved this: "So much of the experience was about finding that one little thing that was not properly coded and making the change."
There are many, many relevant quotes from giants of Computer Science. But this is my favorite. It's from Seymour Papert, a pioneer in teaching with and through CS from his book Mindstorms: "“What we see as a good program with a small bug, the child sees as “wrong”, “bad”, “a mistake”. School teaches that errors are bad; the last thing one wants to do is to pore over them, dwell on them, or think about them. The child is glad to take advantage of a computer’s ability to erase it all without any trace for anyone to see. The debugging philosophy suggests an opposite attitude. Errors benefit us because they lead us to study what happened, to understand what went wrong, and, through understanding, to fix it. Experience with computer programming leads children more effectively than any other activity to “believe in” debugging.”"
One last question: where can we see your code?
Hi Dr. A! Thank you for your compliment and for sharing that amazing quote. As someone who teaches with theater, I have always espoused that "an error is an illumination." BTW, I added a little bit to my image as I didn't quite feel it was finished. I believe you can see my code by this link: https://replit.com/join/mvdeoeta-akselradj
DeleteJanuary,
ReplyDeleteI am glad you liked the quote. Papert is one of my heroes. And I think you would love his Mindstorms.
And thanks for the link. I will poke around in your code.
I am always a fan of a good pun! This was such a good project idea and I love it. I wonder if there is any library of functions that can create sound. I did a quick search to see if I could find anything and found some code where you can adjust frequency and duration. This should theoretically allow us to make some sort of sound, right? https://stackoverflow.com/questions/6537481/python-making-a-beep-noise
ReplyDeleteWas just a thought that I figured you may be interested in looking into further so that maybe the turtle can play the music too!
Really nicely done, January!
I will definitely check out the stackoverflow link. I actually created a little 'playlist' from each composer while I was working each element and thought about making a soundtrack that switched composers when the elements changed. Heaven knows one could fixate on how to augment this indefinitely...and then there's laundry to do :) . Thanks very much for your comment, Kevin!
DeleteYou can also play sounds in Python. I will find some references for you.
ReplyDelete