Rhythmic Recursion

Video thumbnail (Frame 0) Video thumbnail (Frame 13433) Video thumbnail (Frame 14749) Video thumbnail (Frame 18677) Video thumbnail (Frame 21780) Video thumbnail (Frame 23800) Video thumbnail (Frame 35491) Video thumbnail (Frame 47182) Video thumbnail (Frame 49829)
Video in TIB AV-Portal: Rhythmic Recursion

Formal Metadata

Title
Rhythmic Recursion
Title of Series
Number of Parts
67
Author
License
CC Attribution - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this license.
Identifiers
Publisher
Release Date
2016
Language
English
Producer
Confreaks, LLC
Production Place
Cincinnati

Content Metadata

Subject Area
Abstract
One of the best things about multi-disciplinary work is recognizing familiar ideas in a different setting. It’s like running into an old friend while you’re on vacation halfway around the world-- “I had no idea you’d be here! It’s so great to see you!” In this talk we’ll run into our old friend recursion in the faraway land of minimalist music, by rewriting a piece of rhythmic music in Ruby.
Group action Code Multiplication sign Archaeological field survey Numbering scheme Primitive (album) Mereology Computer programming Neuroinformatik Vapor Videoconferencing Process (computing) Social class Observational study Software engineering Feedback Computer Bit Maxima and minima Measurement Twitter Degree (graph theory) Process (computing) Computer science Right angle Pattern language Figurate number Quicksort Representation (politics) Fundamental theorem of algebra Recursion Geometry Classical physics Web page Open source Observational study Field (computer science) Revision control Latent heat Internet forum Representation (politics) Data structure Form (programming) Rule of inference Focus (optics) Dependent and independent variables Information Polygon Mathematical analysis Line (geometry) Cartesian coordinate system Word Loop (music) Personal digital assistant Interpreter (computing) Video game Musical ensemble Abstraction
Positional notation Different (Kate Ryan album) Flag Control flow Bit Repetition Mereology Measurement
Greatest element Code Control flow Parallel port Mereology Perspective (visual) Array data structure Process (computing) Order (biology) Bus (computing) Representation (politics) Pattern language Musical ensemble Spacetime
Execution unit Beat (acoustics) Code 1 (number) Line (geometry) Mereology Perspective (visual) Measurement Field (computer science) Neuroinformatik 2 (number) Mathematics Process (computing) Bridging (networking) Operator (mathematics) Self-reference Pattern language Right angle Figurate number Recursion Alpha (investment) Recursion
Context awareness Group action Greatest element Thread (computing) Code Ferry Corsten Multiplication sign Sheaf (mathematics) Voltmeter Function (mathematics) Parameter (computer programming) Mereology Computer programming Rotation Neuroinformatik Measurement Supersonic speed Mathematics Different (Kate Ryan album) Pattern language Cloning Process (computing) Recursion Social class Rotation Link (knot theory) Texture mapping Touchscreen Web page Menu (computing) Bit Mereology Instance (computer science) Term (mathematics) Variable (mathematics) Measurement Twitter Message passing Process (computing) Phase transition Right angle Pattern language File viewer Quicksort Figurate number Representation (politics) Recursion Probability density function Web page Point (geometry) Slide rule Link (knot theory) Variety (linguistics) Maxima and minima Similarity (geometry) Infinity Bit Number Term (mathematics) Operator (mathematics) Representation (politics) Data structure Multiplication sign Pairwise comparison MIDI Slide rule Supersonic speed Basis <Mathematik> Line (geometry) System call Word Personal digital assistant Sheaf (mathematics) Normed vector space Collision Musical ensemble
Code Multiplication sign Feedback Keyboard shortcut Supersonic speed Coma Berenices Bit Line (geometry) Hand fan Neuroinformatik Goodness of fit Different (Kate Ryan album) Text editor Physical system
hi my name is Celine and I have a degree
in music um yeah actually I'm really glad that was y'all's response to that joke because I in retrospect it's kind of a joke in poor taste but I keep trying it anyway yeah so my name is Celine I'm a software engineer at a company called Braintree in Chicago I'm putting my information up here now in case you like want to write it down have any questions feel free to reach out I love making new friends also I love feedback uh so if you have any feedback for me and these are really great forums to give them to I'm going to post this again at the end of the talk so this is great um this is kind of a talk about computer science how many people I imagine may be there at least a few people in the audience who have at least heard of structure and interpretation of computer programs the scheme's yeah yeah cool has anyone in the audience watched the video lectures that are posted on the MIT open source version of it there's a crapshoot I watched half of the first one and then haven't really picked it back up again I think hopefully some of you guys can relate to that experience but it did really strike me there's a gentleman named how abelson i think is the person who gives that lecture um it looks like it's from the 80's it's really fantastic and I love a lot of the things that he says in it he says welcome to this class on computer science except that that's not really a good name for it because it's not really science and it's not really about computers so you know there are there reasons that we call it that he he done likens it to the study of geometry which was developed initially by the ancient Egyptians the name for it comes from Gaia which means earth and Metron which means to measure it was developed as a way of like surveying land um got a peek in my notes so much like the ancient Egyptians developed these sort of rudimentary like fundamentals of geometry geometry then developed into a way of talking precisely about declarative knowledge a way of talking about what is true mr. abelson says that he believes it centuries from now people will look back at those 20th century primitives and think like oh yeah those folks were fiddling around with these gadgets called computers but really they were developing a formalized process a formalized way to talk about intuitions about process and I really like that I've heard it said elsewhere that computer science is a study of process and I think that if that's true then programming is the application of that study or at least one of one application of that study as I mentioned I have a degree in music and as such I've been noticing a lot of musicians in the field since I transitioned into tech how many people in the audience today like dabble and music or know a little bit about it cool is there anyone in the audience who feels like they really don't know anything about music awesome I'm so glad that there are both both people who identify with both sides here I'm hoping that this talk will be very clear to all of us in the room because it approaches things from the code side um another another idea I want to call out before we get started proper is um I went to strange loop this year and there was a talk given by a gentleman named Chris Ford he talked about um ethnomusicology African poly rhythms and Paula funny and I really really enjoyed a lot of the way that he talked about these ideas he talked specifically about some aspects that music have in common to programming and that is that they both use an abstract form of representation to communicate ideas they both use this abstract form of representation to communicate ideas about a process and then there's also a lot of like composition and analysis in in both pieces and I think this is probably true of many other fields as well but perhaps obviously the reason I noticed in music is because I studied music for most of my life so what we're going to do today in this talk is we're going to look at one piece of music it was written by a gentleman named Steve Reich published in 1973 it's part of an era of academic music called minimalism and you can maybe see just from looking at this page why it's called minimalism especially if you do have any kind of background or experience with music like a lot of classical music pieces take up an entire book and this one is half a page so it is just in appearance very minimalistic we're going to deconstruct the the representation on this page some of the more traditional musical representation that we see here we're going to deconstruct the process and figure out how to describe it conceptually and then we're going to recompose that process using a tool that's familiar to all of us Ruby code and we're going to use sonic PI to help with that process but i'm not going to focus too much on that tool we can talk about it after if you'll want to great i'm really excited let's get going so in beginning to break down this piece the first thing i want to point out is that there are five of what we call stanzas each stanza is this like broader line we read music just in case anyone doesn't know we read music from left to right top to bottom each of the stanzas is made up of two parts you can see them delineate it in the top left-hand corner with the words clap one and clap to this indicates that there are two performers in the peace and the instrument is clapping which is not terribly common in the world of academic music just to point that out so each stanza has two lines which represent two parts five stanzas the next thing I want to point out is a structure that formal music calls a bar or a measure in each of these broader stanzas there are three bars or measures and appropriately enough those are delineated by these like vertical bars in between each group of notes right cool one two three right we got that next I want to bring your attention to the top of the page where we see a little piece of instructions here the first bit of this that's like got a note and it says equals 160 180 for that's just a tempo marking we're not going to worry too much about that for the purposes of this talk after that though it says repeat each bar 12 times though that's instructions from the composer if you look down each of these bars measures in the score you can see little colin's on each line traditionally in music when you you read like a few bars of music and you come to the colon that means repeat from where you see the first colon that's facing to the right and in this case Steve Reich has given us very specific instructions he's saying don't repeat the way you normally would just once repeat at twelve times that's how this is meant to be read disclaimer here we're not going to repeat it 12 times we're going to repeat 4 times because this is my talk and I think 12 is too many for this talk fantastic so one last thing I want to point out before we move on is that the top part has exactly the same pattern of notes in every measure it plays the same thing the whole time and that is arguably the boring part of the piece but it's also a really important important part of the piece it gives the changing part something to work against
let's take a closer look at that first measure we're both parts are the same
and let's break down some of the rep entation we see in here so despite the way this looks it looks like these are lots of different notes but don't be fooled this musical notation is a little bit weird I always thought it was crazy how inconsistent the way that notes like like visually are represented but these are all all these notes represent exactly the same rhythmic value and in fact the little markings between the notes those are called breasts that kind of look like flags those also represent the same rhythmic value which is kind of cool because it's the only looking back at the whole score those are the only notes and rests in the entire piece that
coupled with the fact that it's a rhythmic piece makes this piece really easy to represent in code because we don't have to worry about pitch at all and we don't have to worry about different rhythmic values even we just have to worry about the order in which the rhythmic values appear um so that's kind of neat and I do want to i want to play this rhythmic pattern to you because it's it's really the theme of the piece you hear it a lot a lot a lot it goes like this I'm going to do that again and I'm going to emphasize the rests with my hands I like thinking of rests in music as white space coming at it from a code perspective okay cool um and I also i have a mnemonic for that because i found it especially like in teaching music lyrics make it a lot easier to remember rhythms and melodies and stuff so I've got a fun story behind this I was a big fat choir nerd when I was in college and my college choir used to go on tour every winter break and being music nerds we we sat in the back of the bus one year and tried to learn how to play this piece of clapping music because all it takes is a couple people hands and familiarity with the process of so we'd sits in the back of the bus and play clapping music and we came up with these lyrics that i'm about to share with you with good reason I think anyone who has ever been on a tour bus for more than a couple days understands the sentiment that these lyrics express they go like this there is no pooping on the bus so now you have a really easy way to remember this thematic rhythm we'll get back to that another really fun thing about this really simple representation is that there is perhaps perhaps an obvious way definitely a very simplistic way to represent this in code and particularly in Ruby code and that's with arrays I've chosen to represent hear the first part with one array on top and the second part with another array on bottom and appropriately enough I've chosen to represent the spaces where there is a note or a clock with one and the spaces where there isn't with a zero gotta look parallelism cool
so let's not take a look at the rest of the score past the first measure I've already pointed it out but you may you may have noticed as well but the second part changes throughout the piece and spoiler alert it's a recursive pattern so before we move on breaking down notes and process let's be really aggressive about defining our terms and make sure that we talk from a broad perspective about what recursion is is there a brave soul in the audience who might want to volunteer their own definition of recursion go for it yeah I really like that self reference that's a good way of putting it there are so many different definitions this is the first one I found I'm doing that Wikipedia thing and that this particular definition is I think more particular it's it's are honed into computers than what you offered up and that's really common we're all familiar with the the computer-based reference a definition of recursion so I wasn't found another one which tries to be really particular to mathematics but I really like the part of this that says it's a recursion is generated by repeating a particular operation and I think of like examples of recursion that occur outside of mathematics or computers like when two mirrors are facing each other that's arguably recursion um and what is the repeated operation here it's it's reflecting they're reflecting each other across and that I mean there's no kick in mirror reflecting but that doesn't matter so I like this definition specifically because it's not particular to computers and what we're trying to do here is build a bridge across two different fields by analyzing similar processes so thinking of it as a repeated operation serves our purpose
really well for that cool so looking again at the rest of the score the second part we know it's a recursive process let's see if we can pinpoint that repeated operation and let's do that by taking a closer look at the second measure this measure we've established that the first part is the same so we have an idea of what because it's only the second measure we have an idea of what the part was in the measure right before it and we can look at the second part and figure out exactly what happens again do I have a brave soul in the audience who might want to volunteer if they've noticed what this repeated operation is yeah the whole pattern has been shifted back and the first note has been placed at the end of the bar very well said sir thank you um cool and that just keeps going until the end of the piece but well I'll take another look at that later i keep getting ahead of myself we can represent the these these notes and rhythms and patterns in code again fairly easily same thing ones represent Klopp 0s represent arrest and as a side note I just I really like the way it looks when they are different because you can see where the beats line up with each other and where they're doubled and it's great cool so taking a look at the
rest of the piece it's easy to visualize the way that that operation is repeated throughout the piece and you can sort of trace the lines through the piece if you'd like to unlatched measure in the fifth stanza where they return to playing the same pattern again cool um so now we get to get into the the part where we sort of figure out how to recompose this process I think we've got a solid understanding of what the process is overall how do we recompose this with code what needs representation there the two parts the two performers that'll need some kind of representation there's what they're playing the notes on the page we've already started without a little bit and then there's also how to play the parts that process how do we represent that in code we have a conceptual understanding of it how do we represent that with the tools that we're already familiar with so I've taken the liberty of establishing a couple pieces of this already there's the two parts I will take just a small minute to say sonic PI is a DSL over Ruby and there are a couple of weird quirks to it in that regard and so I have not defined any of this within a class like perhaps you normally would in object-oriented Ruby but i'm still using instance variables so they're um so I've assigned to different package voices to these two instance variables we've got a high-pitched percussive voice and a mid pitch percussive voice and this is just to provide us a little bit of texture and variety because in part because it's a computer they're coming from the same speakers if it was the same pitch it would be a little bit harder to differentiate between parts honestly I don't think this helps too much but it does help a little bit and then we've already established that we have the baseline part I was supposed to deliver that differently so that I could focus on the pun a little bit more apologies yeah I've called our our part that stays the same the baseline and then we have what is absolutely and a rotating part I thought I'd deleted the clone I figured out that wasn't absolutely necessary but fortunately for us ruby has a package method in it that will do exactly the operation we needed to do what's called rotate um it's beautiful lastly the interesting part not that the rest of this hasn't been interesting but I really like recursion and it's fun to play with and we get to do that now so let's redefine some of these important terms for anyone who who might be watching this who is not familiar with music I think this is an important thing to do we've got our measures or bars which is a grouping of notes we've got a section I haven't said this word before I'm calling the repetition of measures a section remember in the score when he said repeat each repeat each measure 12 times that's that's what I'm calling a section we're repeating it four times as a reminder I just couldn't really think of a better way of describing that so a section repeated section and then I I've defined a couple of methods for us to start with play note and play rest they're fairly straightforward just because every note and every rest is the same rhythmic value and it's not really that interesting or important to the process so you're welcome other helper methods I think would be a good way to move forward I'm proposing that that the design of this particular recomposition we tell the computer how to play a measure how to play a section and then how to play both parts playing a section at the same time normally if two humans were clapping this piece it would be two separate brains performing one process together a computer arguably can be two separate brains there's not really a basis of comparison there or there is but I don't want to get into it and we have to tell the computer how to play two parts at the same time so for playing the measure this we take two arguments the pattern of notes that we want to play and the voice that we want to play them so for each value in this pattern if it's a one we play the note with the voice given and if it's a zero we play the rest and that I can tell you what that sounds like at least I think I can there we go great that makes sense we already learned that rhythm so then to play the section there are so many different ways to to implement this I I did it this way for reasons I think probably if it were in a class you would want to extract the number into a constant or something like that but this is how it turned out and the code works it still sounds like things and I think that's really fun it sounds like this make sense so far great and then lastly we know how to tell the computer to play both parts at the same time and we'll do that a section at a time because that kind of makes sense to the the structure of this process and in sonic PI the way that's done is that we just wrap one play section call in a thread and then let the other play and that's I think it's kind of neat the way it works but it also makes sense you can just tell it to have a separate processing and go so that sounds I do want to tell you that sounds like this cool and just for a little context I'll shout shout back to the thing I was saying earlier this is one part is that one part yeah and this is two parts so maybe you can hear the difference to me it just sounds a little bit louder I becomes more obvious when they're playing different things I have to go back to the slide there we go um no it's time for the collision um oh thank you well obviously very excited about this part let's continue to be a thorough about defining our terms and just go over the pieces of recursion we've already been so good about defining terms anyway so let's let's do that right now recursion uh in in my mind anyway recursion is typically broken down into three or so parts there's the part where the function is called within itself there is the kick often also
called the base case you might be familiar with either of those names that tells the function to exit after a certain point of repeating the operation and then there's the part of it that changes something so that it can get to the kick and often that's you can think of it in a couple different ways there is the repeated operation itself the part of the functions meant to call the classic example is is in the factorial problem the thing that the function does is multiply two numbers and the thing that the function changes is that one of the numbers is subtracted by one every time it repeats that makes sense cool so we're going to start with the obvious part written for us with this very aptly named method play recursive bit we pass in a part that we want it to play cursive Lee and then we we call the method within itself and we'll get to what we pass into the repeated call in a minute I just gave it away so then we have the base case which is didn't anyone notice this earlier any any volunteers to interpret the code i have on screen go for it right exactly the very last measure they line up again so we know we're done with the recursive process when the two parts line up again and are playing the same thing and incidentally steve reich called this piece and a lot of other similar pieces that he wrote phase music for exactly that reason because it's like 80 it's phasic you start with one thing and you kind of rotate through a phase and then it stops it's really neat right so next what's the change that we want to pass into to the recursive call go for it exactly rotating part 8 and and that'll well you guys know that signals are our thing that it needs to change and it'll keep going until the base case we just need one more piece which is the actual like action that we want to happen any takers any yeah yeah play the section sweet so we've told both practically the section we are returning when the piece is done but when it's not done we're just going to keep playing it with the part rotated so let's put all these pieces together we could potentially just use the method we just wrote play recursive bit and pass in a rotated baseline but there's one problem with that um any any takers does anyone already know I see a hand halfway raised in back maybe yeah right exactly exactly yeah the problem with doing it this way is that as the gentleman back said the first section you want to play is going to be the same it won't immediately exit because we're passing in the rotated baseline it just won't actually play the whole piece right so we'll want to play the section the same way first and then go through the recursive bit into the kick and you could you could arrange the actual recursive method a little bit differently so that the kick is at the top and it just doesn't play again when when they're the same and but then you would have to put both parts play section at bottom and you know it doesn't really matter it's the same thing fantastic so we're going to listen to this all at the same time the way the pieces arrange it ends up like just feeling really good at the end of it so I want to go through some thank yous and post some links before we start listening to it so I've got a link to sonic PI because it's a really neat little dsl if anyone wants to explore that do it I've got the completed code up on my github as well as a PDF of my slides I'm using deck set there's a markdown up there too if anyone's interested the name of the composer and the piece up there again if anyone's interested and I do want to thank a couple of my co-workers who helped who helped me prepare mentored me through this process John Downey and josh Josh Larson I want to thank dev bootcamp for initially asking me to give a talk about music and programming and inspiring this and then of course I Sam Aaron and anyone who's ever contributed to sonic PI I like it a lot cool so let's do so in doing this I'm going to pull sonic PI over here to the viewer I'm going to make this a little smaller I hope there we go I've written in a logging method it'll tell us when the base case is achieved and also just write out each part the first time it's played so that we can see that visual of each note against each other and how rotation is occurring yeah let's do it thank you um does anyone have any questions that's a good that's a very
good question I wish I could you mean like out of different speakers yeah thank you the question is can we play the bass line out of one speaker and the rotating part out of another speaker so it's a little bit easier to hear the difference and i would like to figure out what the best way is to do that as it was we had a little bit of trouble with the line out on the computer and the sounds that you heard were provided to you by a microphone sitting next to the speaker so that is a very good feedback I'll keep that in mind for if I give this talk another time and try to make that improvement thank you oh it's a great question that what is the editor that I'm using to write the code in there or yeah so that that's built into sonic x sonic PI was originally developed for use on Raspberry Pi that they developed like an OSX port for it I'm honestly not a huge fan of the editor in sonic PI especially after having learned and gotten used to them I'm like trying to like even even I used sublime even like all the keyboard shortcuts in supplying there just may be there are keyboard shortcuts in sonic PI and I just didn't take the time to learn them but I became mildly frustrated when I was developing this at like having to like copy and paste with a mouse and like click on things that said though it's I didn't have to write my own system of turning code into sound which was really nice cool um thanks again so much for coming
Feedback