Video details

Create a PsyTrance Riff with JavaScript in Ableton Live | Walmik



This video demonstrates how you can use Scribbletune and a little bit of JavaScript to create the common "riffs" we hear in electronic music. The riff is imported in Ableton Live in this video, but it can be used in any DAW.
You can do this without writing JavaScript via a Max for Live plugin I created for this same purpose:
You need Node.js installed on your computer for this, Mac: Windows: Linux:
PUBLICATION PERMISSIONS: Scribbletune YouTube channel provided Coding Tech with the permission to republish this video.


So I'm going to show you how to use JavaScript in an interesting way to create some riffs that you typically see in electronic music. In this example, I'm using psychedelic trance music and what we're going to create some what sounds like this. Yes, so the rift that you heard in this track, which is just a silent patch, some default pattern I'm using, it's played from this channel about the startling effect just for a little bit of extra zing to the riff that we create, but we don't need it at this point. Same about these two video clips. We don't need them and we don't even need this. So this is just a kick off base. I got it from some sample back and a set of drums. This is how it sounds without driv. OK, and at the same time, I have a project set up a way on the site. This is rescored and I put together a folder called How To I already installed Scribble Down. So I've just done this. And I can tell you, when I iPhone started doing JavaScript library that I created for generating MIDI files using JavaScript strings and arrays, it has now gone beyond that original goal of just creating many files. Now you can use it in the browser as well as in Max for life. But for this tutorial, we are just going to use it to create MIDI files and I'm going to create a JavaScript file called Refugees and maybe I'll open it over here. But if it doesn't have anything at the moment. So let's just quickly bring in scribble. Do I typically call the variable that I instantiate scribble down on a scribble? That's what I'm doing yet again. Now we have scribble down inside the JavaScript file. So what I'm going to do is before I write a script, I want to show you how to do this without a script. And this is a pretty common technique that people do while people use while creating electronic dance music. It's not something new or certainly not something original, but this is what they do. So they start off with a 16 by 16 boot kind of a bar, and then they randomly click on notes like this. So I'm not really particular as to where I'm clicking, I'm just randomly clicking anyway, let me expand this a little bit so I have this a note going on like this. Maybe I just moved one octave up and then if I played out just the way it is. Yes, so it sounds kind of decent, and then what you do is all these missing notes where you just create another note for them like this. And now you play that again. And make it interesting, you take the route out of the base, not that you want it, and cut it into half like this and then play that again. And then you can pretty much do anything from there, like, you know, just move around these notes a little bit. I'm just sticking to the white notes. You could decide a scale that you want to stick to and you could move into that scale or you could have been dragging the scale, the effect of alien life and keep on playing with white notes. But stick to a scale with the meta device. I just used white notario. So let's see how that sounds. Yes, so this is a technique that I want to do with JavaScript, and quite honestly, you don't need JavaScript, you could have just kept on walking like this, kept on creating graphs like this. But the thing is, you can imagine that if you're just randomly clicking notes around and then moving the other nodes again randomly, why can't you just do it with a script? Why can't we just use JavaScript to do that random bit? And then you can just focus on the creative aspect of music or even the sound engineering aspect of music, like, you know, you want to shape the sound or whatever. And at the same time, if you write a script, it can generate like potentially hundreds and thousands of riffs that you can sample a few out of and use that as a starting point for your. So without further ado, let's try to create this similar thing, just this thing that we did by just pointing and clicking on this bass note and then these alternate notes and just moving them around randomly with JavaScript. I'm gonna remove this clip, obviously, and head back to my project way up. Since I've already imported scribble down, I'm just going to make use of that and I'm going to use the mini method of scribble down. So the method of scribble except a clip. So let's let's create a clip of what we call it clip because we might create another clip to concatenate with it and then scribble down has a method called clip within itself for creating these clips. And you could have very well put this script clip right inside oil. But I just want to separate these concerns so that I can show you what I'm doing. So a clip is a container of a musical idea and at a very basic it takes a notes parameter. And since we were playing in the key of a real use, A3 goes Ableton Live is going to put that down by an octave. So this A3 is going to translate to it once you bring it to modern life. It has nothing to do with doing it just the way Ableton Live treats the middle C, and that's kind of digressing. So I'm not going to go too much into it, but I'm going to create the second parameter of this object called pattern and I'm going to create a pattern. You know, I was randomly selecting these notes in the 16 bit, but so let's assume that we have a note, not a bar separated by 16 notes. And to do that, we just said the subject, the property of scribble down to be 16, not because by default it is Cordano. And let's say that each time we type X, we are selecting a sixteenth note in that bar and every time we type minus, we are not selecting it. We are kind of letting it go. So I'm just randomly kind of, you know, putting together something till it becomes like 16. Let me see, how many have I got now? One, two, three, four, five, six, seven, eight, nine, 10, 11, 12, 13, 14, 15. I just need one more. Maybe I will do something like this. So now I have these I have this board of sixteenth notes where each X signifies a note on event and each minus signifies a note of event. So this is the pattern language of scribble down, really. It is a very small part of language. And this X and this minus signify a note on and a note of event. So let's see how this sounds. OK, so let's just take this clip and stick it in here and here. I'm going to use node one instead of node to kind of keep generating this. So this has generated a final music not made, if you can see that oil. Let me zoom in a bit. So it has created a mini file called Music Department, you could have given it a specific name, but if you don't give it a name, is going to default to music. Not heading back to Ableton Live. Let's go to our how to fold and then we can see this music Northmead file. Let's drag it in if we double click it. As you can see now, we have a very similar looking riff which we created at the beginning of this video. So if I play that out. And now I want to go a step further and create those random notes that we were just clicking around. So for random notes, what I'm going to do is I'm going to use another method from scribble down call skill and maybe I'll go for a Phrygian mode, OK? Because psytrance music, from what I understood, uses a lot of energy and more. So what I've done is now I have a root node of a tree which will transfer, which will transposed onto it when it comes to inside life, and maybe we can go for like one octave up. So it's going to select these random notes and stick them inside this minus heso to signify that we want to use a random note instead of a note of it. And all we need to do is just change every minus to a R. R stands for random and the scribble tune pattern language recognizes that as a random not just doing this will create a very basic riff which uses the A note as a root and the notes from a four phrygian scale as the are not like the random notes. So let us try that out. As you can see, it's kind of put together this little riff. It's our second version of the riff that we created at the beginning of this video. Let's play that out. What we need to do is kind of got these nodes into half like we did earlier. So to do that, I'm going to create a little bit of a difference. So, for example, I'm just going to augment these aspect of the pattern language, which is the square. Brace's the square. This is just subdivide an existing pattern so far each. So if our X node was sixteenth note long each, a square brace will subdivided. If I had put two of these now these are two, three to six nodes in the space of 16 nodes. But I wanted it just like cut off over there and then have a node off after it. So I'm just going to augment the part like this for each X. Like that and then back into Eberlin life, I bring back this music, Northmead, as you can see now, it has kind of subdivided those notes and left the note just the way they were. And obviously, those notes have changed from the previous version of this modified simply because it's a it's randomly pulling out those notes from the different Inskip. So let's play that out. I'm not so fond of that. All I need to do is just hit Sabria so that it can generate a new music file, a new music document file. Excuse me for that and then pull that in. OK, so this one is not that bad, but what I would like to do is I would like to repeat this particular riff like maybe three times and then the fourth time I would like to change it a bit. I would like to leave it just the way it is like that or does it. And the random notes are from every region. But I would like to create a little bit of a variation on the fourth bar, so let's try that. So since we created this clip, we generated this clip clip, we'll create two of these. OK, as simple as this. And then we will use this structuring to. You clip it three times and then finally. So now I have created this idea out of Clippy three times and Clippy only once. So let's see how that sounds. So now we have a much bigger clip, it has like four bars already, and if you play that out. Yes, that's already sounding good, but maybe we can just say one more time and create one more clip like this and either we can drag on top of this or another one so that we can preserve the first one and then so bit both of them. Yeah, so that's pretty much it. And now what we can do is we can just keep on. We could just add some optimization to the script. It's it's pretty small, as you can see. We can make it even small, of course, but we can add some optimizations to it so that we can get a new riff every time. So the first optimization I want to add is I want to create a function called get clip because this is pretty much the same thing. Right? I don't want to keep duplicating stuff, so I'm going to create this method called get clip and all it does is it just returns a new clip. OK. In fact, we can even go and do this. So this jet clip is now returning a clip. So this jet clip, we is going to move it up over here. And then this clip, it is going to use jet clip to get the clip instead of defining it explicitly. And the same thing we're going to be so technically, we've got new two new clips. We are just using them in a particular fashion to create if if I say we don't want to get too much of a big difference is pretty much the same. But at least now we have a method that does that for us and we're not duplicating. OK, so now why do we just use this particular pattern every time? Right, so even if you have some randomization going on, we're going to get the same pattern every time. So I want to create a method that kind of changes this pattern each time. So let's do that. I'm going to create a method called get pattern. All it does is it returns about OK, and let's say that pattern is PDN is equal to an empty string. We'll do a follow that goes, oh, maybe eight times. And this can be obviously made dynamic by passing an input away, like, you know, you accept an input, something like this, like count, and we can set as the default value to it and they can start it like this and we can use that count over here and then increment I like this for each iteration. We can just increment this pattern like this pattern plus is equal to and we can randomly decide between. So we are just this is like doing our this kind of thing, like bowling, yes or no kind of a thing. True or false, randomly deciding, true or false. And based on that, we are going to do either. This. Or we can just move past. Like this, so each time this loop runs is going to randomly decide if it's going to stick in a subdivided X within or into this pattern or a random note and then subdivided X inside this pattern. And now we have a pattern. So we just redone it. My keyboard is funky, so please forgive me for that. And I will use this method of, well, instead of setting a pattern which is constant, we'll get a dynamic pattern each time. The only problem with this is this clip and clip B will now get different patterns. So what we can do is we can create a variable called pattern and we can set get pattern to that variable and then we'll just use this pattern as the default. Yeah, so now we'll have the same pattern for each of these clips, but each time a different pattern will be created and if you want, we can even, you know, console this pattern out just to see what it looks like. So look at that. When I generate a new MIDI file, this pattern is what is getting generated. If I see you again, a slightly different pattern has got created. So let's head over to Bit and Lo and see how that sounds. Now, the only thing left to do is probably make this a bit dynamic, right? Like, why do we stick to Phrygian and why do we stick to it for a while? We can just send that information from here like this note and scale, or we can call it more. OK, and then in here, we lose this more, and in here we'll use the route so that we can get some sort of root node like this and we can set some defaults for, let's say the default is a three of sorry doctor is not dynamic at the moment. But as you can imagine, it can make the dynamic as well. And you will take by default harmonic minor for a change. And you can use like that. Are hundreds of scales available in scalability and why it only is so you can use any one of those. And then the last thing is to use the root note here. And now we have a get clipped method that accepts more as well as a root. Not so you can change the key of your riff or the mode or the scale of your riff, and it can sound different. So let's say let's see how this sounds because we've now changed from frigging to harmonic minor if I put that in. Or maybe we can have something like Phrygian dominant. What the hell, right? We can go for any scale we want to. You can play these parts, not just like this, but how about let's call it first of all, let's rename this clip to just A and B. So instead of clip, let's just call it clip, just a and then it'll be just B and then maybe let's create a C as well. Right. Let's to see and we'll concatenated this like a, B, A and C. OK, and let's see how that sounds. Yeah, so that's about it. I mean, that's the end of it, and I've created a Maxwell IV plugin that does this bit for you and you don't necessarily need to write JavaScript. But as you can imagine, once you make something into a plugin, you start limiting the options that you can. You start limiting the things that you can do with a script. For example, you cannot generate that riff just the way you want. You know, you're dependent on the author of that plugin for that, for that matter. To me, in this case, just the way I have decided to put this clip, the Spartan method away, others get Paddon. This is my idea, right. Let me put it like this. But what if you had a different idea? You want to construct your pattern in a different way. You can do those kind of things only with scripts. So it's so if you're not keen on writing JavaScript or doing all this business, you can just use my Max for like device and I'll post the link to that device. In the description of this video, I would encourage you to just try this out. You know, JavaScript is very easy, if not anything. You can just pick up a new skill and discover a new way of creating these riffs, have some fun. You know, it's an interesting way in my opinion. So do give it a shot to try it out. It's not a very long script. And I will leave some information on how you can install not just on your system in case you don't already have that. So that's it from me. I hope you enjoyed this tutorial. And I leave this playing for a bit so that it sounds like a nice little ending to this video. Thank you for watching.