# fmap and tidal-midi example

New user, I'm struggling a little with how to transpose a tidal-midi pattern. I've read that fmap with up etc can do this, but I can't get the syntax right to make it work. Could anyone provide an example?

for example, with something like the following:

m1 $every 4 (density 2)$ note "[-12 24 5 2 4 7 12 9 12]/3"


where would fmap be inserted..?

edit retag close merge delete

Sort by » oldest newest most voted

Hi Dazid,

Breaking your example down a bit,

this is a pattern of numbers: "[-12 24 5 2 4 7 12 9 12]/3"

this is a pattern of synth messages: note "[-12 24 5 2 4 7 12 9 12]/3". In other words, the note function takes a pattern of numbers and turns it into a pattern of synth messages.

Both are patterns, for example you could have applied the every 4 (density 2) transformation to the pattern of numbers: m1 $note$ every 4 (density 2) "[-12 24 5 2 4 7 12 9 12]/3"

Both will have the same result.

However what fmap does is apply a function to each of the things inside the pattern. So if you want to transpose note values you'll want to apply the fmap to the pattern of numbers, rather than the pattern of synth messages. Some examples:

m1 $every 4 (density 2)$ note (fmap (+2) "[-12 24 5 2 4 7 12 9 12]/3")

m1 $every 4 (density 2)$ note (every 3 (fmap (+7)) "[-12 24 5 2 4 7 12 9 12]/3")

m1 $every 4 (density 2)$ note (sometimes (fmap (subtract 5)) "[-12 24 5 2 4 7 12 9 12]/3")

(untested, but hopefully work!)

You mention the up parameter - you can ignore this when doing things with MIDI, that actually manipulates the speed parameter and is probably only ever used when triggering samples from SuperDirt.

There are other tricks you can do, for example using |+| to combine two note parameters by adding together their values:

m1 $note "[-12 24 5 2 4 7 12 9 12]/3" |+| note (slow 4 "2 7 12") m1$ every 3 (|+| note "12") \$ note "[-12 24 5 2 4 7 12 9 12]/3"

more