# (Hopefully) Interesting snippet for making melodies

**URL:** <https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012>\
**Category:** TidalCycles\
**Tags:** resources\
**Created:** [24 August 2020 13:37 UTC](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012 "2020-08-24T13:37:13Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![artheist](https://uzu.lurk.org/user_avatar/uzu.lurk.org/artheist/32/594_2.png) [@artheist](https://uzu.lurk.org/u/artheist)\
**Post date:** [24 August 2020 13:37 UTC](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012/1 "2020-08-24T13:37:13Z")

</div>

This snippet is based on @BongLebowski performance during the marathon, with some little help from @yaxu to make it work like I wanted.

```haskell
do
    let dascale = "hirajoshi"
    let chord = "'maj"
    let melo = "0 3 4 7"
    let root = "<e4 d4 c4>"
    d1 $ n (scale dascale (chord + melo) + (root + "<-12 -7>")) 
        # s "superpiano"
    d2 $ every 3 (rev) $ n (scale dascale (melo) + root) # s "superpwm" 

```

This is just the core idea, but feel free to experiment by changing the variables to see how it works.  
For the full list of scales and chords, have a look here:  
[https://tidalcycles.org/index.php/scale](https://tidalcycles.org/index.php/scale)  
and here:  
[https://tidalcycles.org/index.php/chords](https://tidalcycles.org/index.php/chords)

---

<div class="post-metadata">

**Author:** ![artheist](https://uzu.lurk.org/user_avatar/uzu.lurk.org/artheist/32/594_2.png) [@artheist](https://uzu.lurk.org/u/artheist)\
**Post date:** [24 August 2020 14:44 UTC](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012/2 "2020-08-24T14:44:39Z")

</div>

Now that I look back at it, melo should be strictly speaking be called degree and melody would be the combination of root + degrees

---

<div class="post-metadata">

**Author:** ![BongLebowski](https://uzu.lurk.org/user_avatar/uzu.lurk.org/bonglebowski/32/831_2.png) [@BongLebowski](https://uzu.lurk.org/u/BongLebowski)\
**Post date:** [24 August 2020 17:57 UTC](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012/3 "2020-08-24T17:57:01Z")

</div>

Just ran this, sounds perfect! And the code looks more professional than mine too, I was haywire with everything - debut performance got the best of me I guess 😃

Can you explain how this works:

> [@artheist](#):
>
> `(root + "<-12 -7>")`

From what I understand, it's taking in the 7th note and the octave below the current root?

Also, my code was based on a solution provided by @earthlydelight on another thread in the forum. I'll have to dig that post up.

---

<div class="post-metadata">

**Author:** ![artheist](https://uzu.lurk.org/user_avatar/uzu.lurk.org/artheist/32/594_2.png) [@artheist](https://uzu.lurk.org/u/artheist)\
**Post date:** [24 August 2020 18:12 UTC](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012/4 "2020-08-24T18:12:35Z")

</div>

Yes, it is a transposition an octave and a major fifth below the actual root, alternating between these, just to show some more possibilities. And also gives two separate melodic lines

---

<div class="post-metadata">

**Author:** ![artheist](https://uzu.lurk.org/user_avatar/uzu.lurk.org/artheist/32/594_2.png) [@artheist](https://uzu.lurk.org/u/artheist)\
**Post date:** [24 August 2020 18:13 UTC](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012/5 "2020-08-24T18:13:50Z")

</div>

Also:

```haskell
d1 $ every 2 (arpeggiate) 
        $ n (scale dascale (chord + melo) + (root + "<-12 -7>")) 
        # s "superpiano"

```

yields interesting results

---

<div class="post-metadata">

**Author:** ![ghales](https://uzu.lurk.org/user_avatar/uzu.lurk.org/ghales/32/2171_2.png) [@ghales](https://uzu.lurk.org/u/ghales)\
**Post date:** [24 August 2020 21:43 UTC](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012/6 "2020-08-24T21:43:10Z")

</div>

Hi all! I really like this topic, this is my favorite one-liner:

```haskell
let tonal root mode = note . (|+ root) . scale mode

d1 $ tonal "<0 3>" "major" $ "0 2 4 7"

```

I'm currently researching ways to use `ControlMaps` for this. This is what I'm aiming for:

```haskell
d1 $ "0 2 4 6" # key "0:major"

```

---

<div class="post-metadata">

**Author:** ![BongLebowski](https://uzu.lurk.org/user_avatar/uzu.lurk.org/bonglebowski/32/831_2.png) [@BongLebowski](https://uzu.lurk.org/u/BongLebowski)\
**Post date:** [25 August 2020 02:29 UTC](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012/7 "2020-08-25T02:29:09Z")

</div>

The arpegiate works great with something like a arpy or supermandolin, never quite got good results with the superpiano. But this is a great starting point!

---

<div class="post-metadata">

**Author:** ![BongLebowski](https://uzu.lurk.org/user_avatar/uzu.lurk.org/bonglebowski/32/831_2.png) [@BongLebowski](https://uzu.lurk.org/u/BongLebowski)\
**Post date:** [25 August 2020 02:30 UTC](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012/8 "2020-08-25T02:30:08Z")

</div>

I'd be interested in the ControlMaps versions of the code. Do keep us in loop when you figure it out!

---

<div class="post-metadata">

**Author:** ![cleary](https://uzu.lurk.org/user_avatar/uzu.lurk.org/cleary/32/177_2.png) [@cleary](https://uzu.lurk.org/u/cleary)\
**Post date:** [25 August 2020 05:09 UTC](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012/9 "2020-08-25T05:09:42Z")

</div>

This looks super promising!

paging @earthlydelight - I think this is something you were looking for here:

> [@Building chords from scales](https://club.tidalcycles.org/t/building-chords-from-scales/1721):
>
> Hi! Is there a way to get chords built on a particular scale by specifying the degree? I'm thinking something like the chord\_degree function in Sonic Pi that takes degree, root note, scale and number of notes and returns a list of midi notes: (chord\_degree :i, :c4, :major, 3) \> 60, 64, 67 (chord\_degree :ii, :c4, :major, 3) \> 62, 65, 69 (chord\_degree :vii, :c4, :major, 3) \> 71, 74, 77 Can I achieve something similar in Tidal? Maybe composing "scale" with some other function?

Side note, that thread was unresolved - in theory I think my stuff should've worked, but it did not sound right to my ears, I didn't dig further...

---

<div class="post-metadata">

**Author:** ![earthlydelight](https://uzu.lurk.org/letter_avatar_proxy/v4/letter/e/ecc23a/32.png) [@earthlydelight](https://uzu.lurk.org/u/earthlydelight)\
**Post date:** [25 August 2020 12:05 UTC](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012/10 "2020-08-25T12:05:32Z")

</div>

Thank you guys, that's some great improvement on the original idea! When I saw @BongLebowski 's performance it was very interesting to see it applied in such a creative way 🙂

The one-liner I currently came up with is:

```haskell
let chorddeg scl root voices degree = (scale scl (voices + degree - 1) + root)

```

I added the `-1` because I'm more comfortable using 1-based numbers for chords built on the scale degrees. It resembles more the standard roman numbers (e.g. "I IV V ii").

These two are equivalent:

```haskell
d1 $ arpeggiate $ n (chorddeg "major" "c4" "'maj" "1 4 5 2") # s "superpiano"

d1 $ arpeggiate $ n (chorddeg "major" "c4" "[0,4,7]" "1 4 5 2") # s "superpiano"

```

You can also do something like this, alternating octaves:

```haskell
d1 $ arp "pinkyup" $ n (chorddeg "major" ("c4" + "<-12 0 12>") "'maj" "1 4 5 2") # s "supervibe"

```

or creating melodies on the chord progression by giving structure to the arpeggio (with a pattern or a semi-random mask):

```haskell
d1 $ struct "t [~ t] t@2 [t*2 ~] t" $ arp "pinkyup" $ n (chorddeg "major" ("c4" + "<-12 0 12>") "'maj" "1 4 5 2") # s "supervibe"

d1 $ mask (binaryN 8 54385230) $ arp "pinkyup" $ n (chorddeg "major" ("c4" + "<-12 0 12>") "'maj" "1 4 5 2") # s "supervibe"

```

So many possibilities!

---

<div class="post-metadata">

**Author:** ![artheist](https://uzu.lurk.org/user_avatar/uzu.lurk.org/artheist/32/594_2.png) [@artheist](https://uzu.lurk.org/u/artheist)\
**Post date:** [25 August 2020 12:50 UTC](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012/11 "2020-08-25T12:50:24Z")

</div>

I might have a small improvement on your one liner, but not enough time right now to make it right, so I'll post later.  
Btw, no big deal, but your use of binaryN is a bit awkward since you cannot encode such a big number on 8 bits. The biggest number possible is 256 (or 255 depending if you're a human or not).

---

<div class="post-metadata">

**Author:** ![earthlydelight](https://uzu.lurk.org/letter_avatar_proxy/v4/letter/e/ecc23a/32.png) [@earthlydelight](https://uzu.lurk.org/u/earthlydelight)\
**Post date:** [25 August 2020 13:04 UTC](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012/12 "2020-08-25T13:04:09Z")

</div>

Yeah I know, I usually just type a big number mashing the keyboard so I can increase the first parameter and take more values without running out of digits... 8, 12, 16 ecc.

As for your improvement I'm very interested 🙂

---

<div class="post-metadata">

**Author:** ![artheist](https://uzu.lurk.org/user_avatar/uzu.lurk.org/artheist/32/594_2.png) [@artheist](https://uzu.lurk.org/u/artheist)\
**Post date:** [25 August 2020 13:28 UTC](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012/13 "2020-08-25T13:28:24Z")

</div>

OK I see, I just discovered the function, so I was a bit puzzled.

As for the improvement, I would like to decouple the root from the octave, so probably a prime function would be worth. The only problem is the octave is embedded in the root "c4", "c5" etc ... which is a bit annoying.

---

<div class="post-metadata">

**Author:** ![earthlydelight](https://uzu.lurk.org/letter_avatar_proxy/v4/letter/e/ecc23a/32.png) [@earthlydelight](https://uzu.lurk.org/u/earthlydelight)\
**Post date:** [25 August 2020 13:33 UTC](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012/14 "2020-08-25T13:33:26Z")

</div>

I think you can just do `# octave "<3 4 5>"`

---

<div class="post-metadata">

**Author:** ![artheist](https://uzu.lurk.org/user_avatar/uzu.lurk.org/artheist/32/594_2.png) [@artheist](https://uzu.lurk.org/u/artheist)\
**Post date:** [25 August 2020 13:37 UTC](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012/15 "2020-08-25T13:37:27Z")

</div>

OK, but what I mean is the function would look like :

```haskell
let chorddeg scl root octave voices degree = (scale scl (voices + degree - 1) + (root + (octave - 5) * 12)

```

(btw, it looks like 0 == c5 which is unusual)

But, then if you want to use it, it would look like :

```haskell
(chorddeg "major" "c5" "<-1 0 1>" "'maj" "1 4 5 2")

```

which is confusing ... do you see my point ?

---

<div class="post-metadata">

**Author:** ![earthlydelight](https://uzu.lurk.org/letter_avatar_proxy/v4/letter/e/ecc23a/32.png) [@earthlydelight](https://uzu.lurk.org/u/earthlydelight)\
**Post date:** [25 August 2020 13:45 UTC](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012/16 "2020-08-25T13:45:02Z")

</div>

Ok I see, you're right, that could also be an option...

---

<div class="post-metadata">

**Author:** ![artheist](https://uzu.lurk.org/user_avatar/uzu.lurk.org/artheist/32/594_2.png) [@artheist](https://uzu.lurk.org/u/artheist)\
**Post date:** [25 August 2020 13:51 UTC](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012/17 "2020-08-25T13:51:23Z")

</div>

One option I would LOVE to see in tidal is the ability to use "do re mi" instead of alphabet.  
That would solve a lot of issue regarding mini-notation (like eigth note for example)  
As a side effect, I would not have to think about translation when building chords ... 🙂

```haskell
(chorddeg "major" "do" "<3 4 5>" "'maj" "i iv v ii")

```

so much nicer to my ears 😉

---

<div class="post-metadata">

**Author:** ![earthlydelight](https://uzu.lurk.org/letter_avatar_proxy/v4/letter/e/ecc23a/32.png) [@earthlydelight](https://uzu.lurk.org/u/earthlydelight)\
**Post date:** [25 August 2020 13:58 UTC](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012/18 "2020-08-25T13:58:46Z")

</div>

That indeed would be very nice 😄

---

<div class="post-metadata">

**Author:** ![artheist](https://uzu.lurk.org/user_avatar/uzu.lurk.org/artheist/32/594_2.png) [@artheist](https://uzu.lurk.org/u/artheist)\
**Post date:** [25 August 2020 14:07 UTC](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012/19 "2020-08-25T14:07:28Z")

</div>

We got to sell to @yaxu letting him know he could then proudly wear a shirt that says:

Anti-Fa# (reversed hashtag)

---

<div class="post-metadata">

**Author:** ![earthlydelight](https://uzu.lurk.org/letter_avatar_proxy/v4/letter/e/ecc23a/32.png) [@earthlydelight](https://uzu.lurk.org/u/earthlydelight)\
**Post date:** [25 August 2020 14:10 UTC](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012/20 "2020-08-25T14:10:42Z")

</div>

🤣

[Next page](https://uzu.lurk.org/t/hopefully-interesting-snippet-for-making-melodies/2012.md?page=2)
