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:

    The next elements were the notes.  For this, I opened another repl and began experimenting with small dots, large dots, stems, braces, ties and other little keystrokes like making my turtle invisible. I ended up with some interesting results:

    With a bit of space left in the measure, I decided to add a rest.  While it would have been easiest to program a half or whole rest, as they are simply rectangles, I decided instead to open yet another repl and try the more difficult quarter rest in all of its squirmy glory. 

Some weird stuff, until I got it...

                                                                ...and then I had to lose the turtle who looked like he was "resting".

   
    The last effort was bringing the coding lists from my "treble clef", "notes"  and "quarter note" repls and adding them to the "staff" repl. This was a little daunting and I needed to tweak it quite a bit so that the elements arrived at their locations, keeping the final image neat and  balanced. I titled the work "A Musical Moment" and added # references to indicate which turtles represented which elements so as to make it easier to follow or edit.  

    I thought about using colors and tried it with a rainbow of hues but it looks more authentic in black.

    I think it's very pretty and I love to watch it run!





  
~ J




Comments

  1. January,
    This 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?

    ReplyDelete
    Replies
    1. 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

      Delete
  2. January,
    I 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.

    ReplyDelete
  3. 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

    Was 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!

    ReplyDelete
    Replies
    1. 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!

      Delete
  4. You can also play sounds in Python. I will find some references for you.

    ReplyDelete

Post a Comment

Popular Posts