wojciech franke - composing music with clojure.spec - clojure/conj 2016

Download Wojciech Franke - Composing music with clojure.spec - Clojure/conj 2016

If you can't read please download the document

Post on 22-Feb-2017

319 views

Category:

Software

0 download

Embed Size (px)

TRANSCRIPT

Composing music withclojure.specWojtek Franke@apogsasisClojure/conj 2016(s/def ::music ...)

Welcome to "Composing music with clojure.spec"

Agendafun with clojure.specgenerate some tunesreflect on generative music

We'll have some fun with clojure.spec.We'll model a genre of music using.We'll make music.Finally I'll reflect on generative music and the direction where it's heading.

Not on the agendahow to use clojure.spec in productionbest practices

you can find this in talks elsewhere.

$> whoami

this is a computer's rendition of me - I especially like the chalice neck

$> whoamicomposing and performing music as ENAY since ~2007software testinginterested in chaos

composing and performing electronic music since around 2007used procedural real-time 3d visuals - used to be called demoscene back thenbut also a software tester by trade - I like to break stuff and use it in novel ways.I'm approaching this more from the perspective of the musician on a vision quest

Describing musical dataHypothesis:

The primary paradigmof computer music is

"Music is Data"

You might be wondering how does clojure.spec apply generating music? We'll let me state a hypothesis. ... If music is data we should be able to use whatever tools we know for manipulating data to.

Toolsclojure.specleipzigovertone

I will be using spec.Chris Ford's library leipzig which you may be familiar with if you've seen his great talks. There's a lot of Chris Ford fans here in the audience.and finally overtone for the actual audio (up till 1.9.0-alpha8)this is all pretty standard stuff for Clojure and music

Picking the domain

As you can probably imaging I did not build a universal music making machine.Instead I just focus on one particular type.So what kind of music will I be showing?

I resisted the temptation to do something completely crazy - as it's not Paris and it's not 1924. Instead I decided to pick a genre that I think is fairly simple and "canonical" but also close to my heart.

And it's Jungle. [PLAY SONG]A good way to explain it is that it's a flavour of drum and bass with a twist. Let me give you the context of what we'll be creating.

Modeling musicaudio

symbolic representation

When speaking about computer music we can speak of really 2 kinds of data - the audio whether it's a .wav file or a buffer of number which is ultimately converted from Digital -> Analogue and ultimately air vibration. The other is the symbolic representation of music - sheet music, MIDI files, guitar tabs. This data is a blueprint for musical performance.

Modeling musicaudio

symbolic representation

To an extent we can translate between these domains. We want to synthesise audio from a symbolic representation but also we may want to analyse or fingerprint audio to go the other way round. To create jungle we will rely on both sources of data - jungle is heavily sample-based making it an interesting choice for autonomous composition.

Hardware samplers

The birth of jungle and also drum and bass and hip-hop is linked to the emergence of digital samplers. Their availability, lower cost and ease of use compared to earlier tape techniques meant the democratisation of musical production. Tons of people were sampling vinyl records, whatever they could get their hand on and using samplers to loop, slice, stretch, pitch shift, reverse bits of audio.

What's in a track?

So what's the bare minimum that I think constitutes a classical jungle track?

What's in a track?sampled drumsbassvocal samples

What's in a track?sampled drumsbassvocal samples

Let's start with the drums as that's the core of the jungle sound.

Breakbeatsbreakbeat |brekbit|noun

a sample of a syncopated drum beat, usually repeated to form a rhythm used as a basis for dance music, hip hop, etc.

The breakbeat is literally a break in the song when the pitched instruments stop playing and the drummer plays solo. These most often come from funk, soul or gospel tracks. Syncopated means that the accent is placed on the "weak" parts of the beat.

What's in a track?drums aka breakbeat or break

Here's the most iconic breakbeat of them all.Even if you're not into jungle you've probably heard it in everything from NWA's "Straight Outta Compton" to TV commercials, Futurama theme song.

It's called the 'Amen break'. Heck it even has its own Chardonnay- that's how big of a deal this is. Notice this pattern at the top is a transcription of the drum pattern for the crash cymbal, ride, snare and bass-drum. Let's listen to it again. Maybe if you have good eyesight you can follow along

The Amen Breaka drum solo (breakbeat) from "Amen Brother" a 1969 track by The Winstonsone of the most sampled songs in historyrevered for its timbre and rhythm

Notationmusic scenes develop their own vernacularnotation can allow easier, more intuitive communication

OK, so we know that we want to use sampled breakbeat - how do we represent them symbolically? If you look at the wine bottle you'll have the instruments separated out. But this is not really what we're working with. It's really a single layer, the breakbeat is the instrument. I wanted to create a notation for using breakbeats that feels natural. When thinking about a beat I hear in my head something close to the sounds themselves. Since my first language is Polish

Polish Jungle Notation

It seems only appropriate to call it the Polish Jungle notation

Polish Jungle Notation

At it's simplest we can think of this as a set of single-syllable onomatopaoic sounds which correspond to the dominant percussion sound happening at the time.But this is's enough information to get us going. As in most genres of electronic music, the key is repetition. And since

Polish Jungle Notation

We define simple rules for how many times a specific sound can be repeat and build a collection we can use.

Spec doesn't force you to use it in

Composing breaksThe different renditions of the amen break and other breakbeats are composable. We can mix and match parts of different breaks.

There is a interesting property - that these rules can be applied not just to the amen break but to other breaks as well.

Preparing samplesCharacteristics of the samples:

equal in length in the same tempo volume is normalised

To do this we need to prepare our sample base.

Picking breakbeats

I load up a bunch of them as audio buffers. Define a fuction which plays back a specific slice of the buffer. And pick some different renditions of the amen break to begin with. Here's how they sound like:

Slicing

Here we play a single kick drum sound.

Slicing

We can map the syllables to selected parts of the break.

Wait for it...

Now we can generate a sequence from the spec earlier. We flatten the repetitions, pick 4 bars of 8 sounds. Rhythmise just takes a collection of amen sounds and arranges them in time using absolute values.

Playing some breaks (finally!)

Finally we can play our breaks together. Repeating the entire sequence 2 times, playing at a brisk 172 beats per minute.

Composing breaks

I mentioned that we can mix and matche different breakbeat sounds - here I'm doing so at runtime. This is a pattern I commonly use - to choose.

Effectsexpanding the model with effect triggers (reverse, pitch shift, filters)

In the future we could expand our model to perform even wilder variations. With per-note effect triggers. There are really a lot of variations we can do to replicate the kinds of edits that human musicians do.

What's in a track?drums (breaks)bassvocal samples

Now that we've set up the scene for slicing breakbeats let's talk a bit about the bass.

Bass

Now these sequences are rather rudimentary. But bass in jungle plays a rather simple role.

What's in a track?bass

Typically we'll see a simple sine oscillator used for generating the bass like in this example.

Bass

note |nt|noun

a single tone of definite pitch made by a musical instrument or the human voice

Bass is obviously a pitched instrument, meaning that the height of the sound varies to create a melody. When speaking about melodies at least in the West we thisk of them as sequences of notes.

Bass

Here I'm representing pitch in the usual fashion - as an integer operating withn two octaves and the duration is represented by the familiar rational number notation used in sheet music.

Bass sequence

But playing pitch as random integers is like having a monkey sit at the piano - they may get it right sometimes but we'll likely be annoyed with our primate companion first. Instead we can compose leipzigs scale functions to transform our random integers into random integers on a scale of our choosing.

Bass sequence

It's not great but at least I don't hate it which is good.

What's in a track?drums (break)bassvocal samples

Alright let's add our final spice to the mix - the vocal samples. And specifically, we'll be using ragga samples.

What's in a track?ragga |ra|noun [ mass noun ]

a style of dance music originating in Jamaica and derived from reggae, in which a DJ improvises lyrics over a sampled or electronic backing track.

Now not ragga as that of India.

What's in a track?ragga samples

These sound something like this.

Ragga samples

Nothing fancy here, just loading a set of these samples and specifying their timing.

Ragga samples

Let's hear all of them together.