Riff
A riff is a short, repeated musical phrase that forms the basis of a musical idea. In trance and other electronic music, riffs are often created by repeating a pattern of notes with some randomness.
Before we begin, here’s what we are going for in this article. It is a riff created with JavaScript and Scribbletune after importing it into a DAW alongside a kick and bass and some drums.
Here’s a video walkthrough of how what this article is all about and how to go about creating such riffs with or without Scribbletune.
This is a commonly used technique. You randomly click some of the steps in a 16 beat pattern and move them around while sticking to a particular scale. Then, on a lower octave, add notes to the missing steps on a particular key to act as the counter point notes. This works great and quickly creates a nice little riff that looks a bit like this,
Instead of doing it in a DAW, you can create a JavaScript function that does this and allow it to accept some things dynamically such as “key”, “scale” and “chord degrees” to use as the progression.
Pattern
Here’s how you can create a random pattern for a riff using Scribbletune:
const getRandomPattern = function (count) {
let str = '[x-]R';
for (let i = 1; i < (count || 8); i++) {
str += Math.round(Math.random()) ? '[x-]R' : 'R[x-]';
}
return str;
};
Here we are starting with [x-]R
as I would like to have the root note of our riff to have a “note on” event every time the riff starts. From then on, we are randomly alternating between [x-]R
and R[x-]
instead of [x-]
and R
to avoid creating a pattern that is too sparse. The reason we are using [x-]
instead of x is to subdivide that note so that the x plays for half it’s duration which could be interesting for the riff as I cannot do palm muting with JavaScript (yet). The function will produce something like,
[x-]RR[x-][x-]R[x-]R[x-]R[x-]R[x-]RR[x-]
Random notes
To make it more interesting, you can provide more notes to the randomNotes
parameter:
randomNotes: scribble.arp(
scribble.getChordsByProgression('D2 minor', 'ii iii')
)
Now, create a clip and set the notes to be used:
const clip = scribble.clip({
notes: 'D2',
randomNotes: 'D3',
pattern: getRandomPattern(),
subdiv: '16n',
});
scribble.midi(clip, 'riff.mid');
To take it up just one notch up, we could generate 2 clips, Clip A and Clip B. For Clip A, we will use the ii and iii chord degree and for Clip B, we’ll use the iii and v chord degree and then concatenate the clips in this order
Clip A + Clip A + Clip A + Clip B
To see the complete script so far, click here. For reference, here’s the earlier sample constructed using this approach. I used Sylenth1 for the riff itself.
You can experiment with different note values, patterns, and randomization to create your own unique riffs!