Funky Music from Functional Programming – Computerphile

Funky Music from Functional Programming – Computerphile

I work in the functional programming lab Here in the School of Computer Science We’re interested in finding programming languages and techniques For making it easy to write pretty programs And we believe functional programming is the way to achieve that Functions are quite simple in the way you specify them Because it is easy to put big systems together using small reasonable functions But then the question is, okay, we talk about functions in the mathematical sense and it’s easy to understand how you might write a function to, say, compute the square of two sums or something like that uhm But, can we also use it to write say interactive applications, or games, or musical applications, that’s not too clear then. We have an application here, it’s called the arpeggigon, it’s patterned after something called the reactogon Which to say is a so called chain reactive performance arpeggiator And this was implemented using functional programming and then more…specifically, a variation of functional programming called reactive functional programming it is tailored for doing this kind of interactive applications ok, so now that’s one way in which we can do write games or animations or musical applications in a functional language. BRADY: I’m liking the sounds. Do we need all this equipment to make this work. NILSSON: No it’s all sort of midi based. So we can just make … Connected to a software synthesizer for example. And then everything can be contained in the laptop. But because it is midi based you can also use it as a component of a larger studio setup for example. BRADY: Now I have seen applications like this sort of thing in the music world before. So what’s new here I suppose? Why would somebody consider going down this route. NILSSON: Well, the thing is that time is of course central to music, right? And indeed two kinds of time. We have both continuous time and discrete time. So a musical note might start at a very specific point in time. But if it has say a crescendo or accelerando or something that takes place over a period of time gradually changing. And writing an application like this for music, it is a nice to have a language in which you can express aspects about time in a way that really fits the application domain and functional interactive programming supports this kind of what we call hybrid systems both continuous and discrete time aspects okay, in a rather high level way so it’s easier to write this kind of applications So the arpeggigon is based on something called the harmonic table The harmonic table is this kind of hexagonal grid musical nodes are placed on this grid on each direction has a specific musical interval so if you go north it’s a perfect fifth if you go north east it’s a major third and so on and so forth BRADY: Just so people if they are not that musical understand the idea of this is that harmonics and things mean that it’ll sound musical, it won’t just… NILSSON: Yes, so for example if you play a note and the perfect fifth and a major third we get a major chord which sort of sounds nice together it’s very easy to play sounds together it sounds nice if they have this kind of layout BRADY: Can you show us what that would be like on a keyboard? NILSSON: You mean here? Well, a major chord on a keyboard would be something like this, right [synthesizer plays major chord] What’s mostly interesting here is that we have this two-dimensional layout So, we can use that to sort of for example implement a kind of pinball game if you like so we can place these tokens or counters on the grid and this, we have a few different ones here, meaning that can do different things so that thing there with the dot that’s a start token so when we press play that’s going to put the ball on the grid and shoot it off in the direction indicated with the arrow and the other one there is a ricochet token and whenever the ball hits it’s going to sort of bounce back in the direction of the arrow And whenever the ball hits the token it’s going to play the corresponding notes. If I start this you will see [musical tone] this ball is bouncing back and forth and you get a kind of musical pattern there, right And we can even, if we want to, we can even modify the layouts dynamically, so you could imagine performing with this if you wanted to we could put more start counters onto the grid Now, with a different distance between them and that means if I hit play here we are going to get a more of a polyrhythmic pattern we have gotten two different patterns, two different lengths playing at the same time BRADY: So they go out of sync? NILSSON: Yes, and then in sync again, right. And we can continue playing this game I can place a few more of these ones up here and the last one there And then we press play And that’s quite nice, I think at least – depends on your musical taste I suppose but I like it. BRADY: And are all of these guaranteed because of this pattern in this layout to be musical; You couldn’t make a cacophony, or could you? NILSSON: I guess “musical” depends on the listener, right? But it is certainly a lot easier to make it musical because you have these specific intervals, absolutely, yes. BRADY: And could people play with this themselves… Yes, this is free software, it is available online, you can download it and play with it. Right now it is a bit rough around the edges, but we are working on it to make it more polished and easy to use. BRADY: Why is it…you mentioned time, let’s try and clarify that then Why is it easier to write something like this in your functional reactive programming rather than say, Java or… NILSSON: Right, so the thing is that in functional reactive programming or FRP as we say, we have a number of language constructs that deals with time directly. and in both continuous time and discrete time. So if we have these elements at your disposal, you can express in this case musical ideas much more directly than you could in, say, Java or C. Obviously depending on the specific context sometimes you might want to write a piece of C code or whatever and obviously if you work hard enough in C you can maybe implement this kind of support in C as well, right. But here we have done this for you in that sense. And in a very principle way which makes it fit for a functional programming context. BRADY: Can you see other applications for this, other time-critical things? NILSSON: It’s been used for games, for example and the ideas of reactive programming is seeing increased use for banking applications and things and whenever you have this system and they sort of communicate, you can view these communications as signals over time and then you can sort of process them using FRP-like ideas so it’s a quite big takeup. Now FRP is not just one system, it’s a lot of different systems as it is more of an umbrella term and depending on this; exactly what to do, there are different implementations of FRP that are more or less suitable but the idea as such has really caught traction. Um, and in particalar in a distributed setting it is important that that everything is purely functional because if it is not fully functional then it is very difficult to handle the side effects – but if everything is pure, then every node in this system has a function and they communicate by signals. it is a very good fit for very complex distributed systems BRADY: So is FRP a language or are the languages the…? NILSSON: Um It’s a umbrella term for a number of related languages, let’s say. BRADY: What’s next for this project, then? We would really want to make it into a tool that people can use for example in a large studio setting like this Because we think actually this is the only software implementation of of the reactagon that we are aware of and if people like to compose music in this particular way I think it could be a quite nice application, ignoring how it is written, just for an end user to use. BRADY: What, you did mention this rectagon, I mean what is that, how does that look normally, is that a piece of hardware or..? NILSSON: It is a piece of hardware, yes, you can google “Rectagon” You’ll find it on Youtube and see this big, impressive table with lots of hardware on it. And you can… there are these physical things you can place on all over the board and interact with it. That’s very cool but this is easier to use, obviously.>Right, we’ve done B we can count that as done. So, C next right, so we are here we can’t go to S we can only go to L, that’s a nice, easy one so I need to find L so L goes to C and it’s three plus two, it’s five so L comes in just underneath A, like this.

50 thoughts to “Funky Music from Functional Programming – Computerphile”

  1. If you make a video with him again, please tell him to talk slower. Especially as a non native english speaker I only understand every other word.

  2. Oh hey, I remember the Reactagon from ages ago. I actually wrote something like this inside of Secondlife again, many years ago. But my version had about a dozen different tiles to use, instead of just the start arrows, redirection arrows, and the burst.

  3. it would be great if you could make a modular synthesizer program, so you can add oscillators and draw waveshapes..

  4. Unfortunately I think this video did a poor job of explaining anything about what functional reactive programming is. It's a very powerful concept and it's not tied to any specific languages or frameworks though there are some excellent frameworks out there for it.

    It is very useful for large, complex or distributed systems like he said but he didn't really explain why at all. It kind of sounds like he doesn't have a strong understanding of it himself.

  5. Am I the only one who appreciates that the pattern of the buttons in the program is similar to the pattern on the chairs?

  6. as soon as you add the abs(x) fuction you can make any logical gate and through that just emulate a pc with a normal language on the pc q:

  7. Don't know about music but in web servers RFP is already the thing not only for Drs in universities but actual products for every day use.

  8. The only thing I got out of this video was that it's built using real functional programming. The Doctor's English is really hard to understand too.

  9. I recognize the hardware synth he's using is a Yamaha one, but I can't remember the exact model number. I know it's a desktop version of the SY-22 range.

  10. 6:50 you can use reactive programming in manufacturing. When you want everything to sync up before shipping. A sale triggers a pull from manufacturing which triggers a pull from inventory or from vendors.

  11. I can see this thing being encapsulated into a VST plugin which you can then use in your favourite DAW using your own samples.

  12. Not very funky, but interesting nonetheless reminds me of the tenori-on by Yamaha maybe it could be programmed onto a tenori-on possibly.

  13. I made a music program that uses a subdivide and displace 2D terrain generation algorithm, and maps the height field to notes on a piano. It was pretty cool. It had a smoother flow than simply throwing down random notes in a scale.

  14. So, why would someone want to use the tool they showed, or something like it, instead of another tool that actually shows things like musical notes and so on (i.e. things musicians can read and understand)? Is this supposed to be use for algorithmically generating new music or something along those lines?

    In other contexts (e.g. games), it seems purely functional programming might not have a lot of advantages and might actually have quite a few disadvantages. For example, one reason I see is that, in high-performance applications, the results of expensive calculations are often stored/cached in variables in order to avoid the unnecessary expense of re-calculating the same value repeatedly.

  15. The next time you make a video about sound, please stop talking for a few seconds so we can actually hear the sound. Every time he hits play he (and the interviewer) just talk over it.

  16. I don't think he really got across what it was he was trying to achieve or why functional programming made things easier. The software looked fun but I didn't see anything that would be difficult to develop in a non-functional language.

  17. Seriously I want to install their programm but the Install Guide on their website is so short that I am not sure where to start. I never heard of Funktional Programming… What Liberies are neccassary? What is a Jack Server? …..

  18. I tried it out, but I must have issues with my audio setup because each node had a random chance that it would play the note. The virtual midi keyboard I was using seems to work though. The GUI is super polished though, shiny!

  19. Tried to figure out how to install it (starting from roughly zero programming knowledge) but I've given up due to lack of perseverance. If this ever makes its way into being an app that can be downloaded as a single program that can run itself without scaffolding, I hope you let us know — this is really cool and I'd love to play with it.

  20. I'm a bit irritated that the video makes it sound as if FRP is a language, and that it isn't available to C or Java programmers. FRP is a paradigm and collection of patterns. It's a style of software architecture. (And yes, I know around 6:00 there is a clarification, but not one that seems to balance the misunderstanding very well.)

  21. Would be nice if the arpeggigon had an actual installation instruction (especially of the dependencies) or even better if the installation would be straightforward…

  22. A two-dimensional grid like this can actually be used to implement much better tuning systems than 12 EDO in a transposition invariant way. For example, both meantone temperament(s) and Pythagorean tuning can be implemented with a 2d lattice structure. Any "rank-2" temperament can be implemented in this way.

Leave a Reply

Your email address will not be published. Required fields are marked *