# Building chords from scales

**URL:** <https://uzu.lurk.org/t/building-chords-from-scales/1721>\
**Category:** TidalCycles\
**Tags:** questions\
**Created:** [22 July 2020 12:05 UTC](https://uzu.lurk.org/t/building-chords-from-scales/1721 "2020-07-22T12:05:36Z")\
**Posts on this page:** 16\
**Page:** 1

<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:** [22 July 2020 12:05 UTC](https://uzu.lurk.org/t/building-chords-from-scales/1721/1 "2020-07-22T12:05:37Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![yaxu](https://uzu.lurk.org/user_avatar/uzu.lurk.org/yaxu/32/2_2.png) [@yaxu](https://uzu.lurk.org/u/yaxu)\
**Post date:** [22 July 2020 19:41 UTC](https://uzu.lurk.org/t/building-chords-from-scales/1721/2 "2020-07-22T19:41:46Z")

</div>

Hi, yes you can do it in the mini-notation, e.g.  
`n "c4'maj'3i"`

the first bit is the note and octave, then chord, then number of notes and the degree. I just noticed that degree only accepts a succession of `i`s, I'll make a note to fix that..

---

<div class="post-metadata">

**Author:** ![yaxu](https://uzu.lurk.org/user_avatar/uzu.lurk.org/yaxu/32/2_2.png) [@yaxu](https://uzu.lurk.org/u/yaxu)\
**Post date:** [22 July 2020 19:42 UTC](https://uzu.lurk.org/t/building-chords-from-scales/1721/3 "2020-07-22T19:42:45Z")

</div>

There: [https://github.com/tidalcycles/Tidal/issues/699](https://github.com/tidalcycles/Tidal/issues/699)

---

<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:** [23 July 2020 05:18 UTC](https://uzu.lurk.org/t/building-chords-from-scales/1721/4 "2020-07-23T05:18:38Z")

</div>

Thank you, that's exactly what I was looking for.

---

<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:** [23 July 2020 12:35 UTC](https://uzu.lurk.org/t/building-chords-from-scales/1721/5 "2020-07-23T12:35:01Z")

</div>

After further inspection I realized that adding degrees in the mini-notation does something different from what I expected. The Sonic Pi chord\_degree I was referring to actually returns the chord built on the specific scale degree, picking notes from the original scale but respecting the intervals, thus giving you the classic chord progressions. For the C major scale that would be:

```haskell
I ii iii IV V vi vii(diminished)
Cmaj Dmin Emin Fmaj Gmaj Amin Bdim

```

For example:

```haskell
(chord_degree :ii, :c4, :major, 3)
# 62, 65, 69 -> D minor (degree ii of the C major scale)

(chord_degree :vii, :c4, :major, 3)
# 71, 74, 77 -> B diminished (degree vii(dim) of the C major scale)

```

Both these chords (Dmin and Bdim) fit in the C tonality and are built on the C scale.  
What Tidal does instead I think is looking at the degree specified, picking the notes that compose the original chord, applying an offset and adding the same notes on top from an octave above. For example:

```haskell
d1 $ arpg $ n "c'maj'4ii" # sound "superpiano"
-- same as:
d1 $ arpg $ n "[g5,c6,e6,g6]" # sound "superpiano"

d1 $ arpg $ n "c'maj'4iiiiiii" # sound "superpiano"
-- same as:
d1 $ arpg $ n "[e7,g7,c8,e8]" # sound "superpiano"

```

If I'm not mistaken these are all C chord inversions, but my knowledge of musical theory is not so good, I might be wrong 🙂

---

<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:** [24 July 2020 01:19 UTC](https://uzu.lurk.org/t/building-chords-from-scales/1721/6 "2020-07-24T01:19:16Z")

</div>

You're correct, that notation is for inversions, not referencing scale degrees

This is an interesting problem, you could build triads using mini notation, then describe the interval change:

```haskell
d1 $ n (scale "ionian" "[0,2,4]") |+ n "<0 1 2 3 4 5 6>" # s "superpiano" 

```

That should play the triads (built in the scale section), with the degree of the scale described as n - 1 after the |+

Not intuitive relative to normal music notation, but at the very least trying to describe the intended outcome to @yaxu

---

<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:** [24 July 2020 12:09 UTC](https://uzu.lurk.org/t/building-chords-from-scales/1721/7 "2020-07-24T12:09:11Z")

</div>

@cleary I came to a similar solution, maybe a bit more "intuitive":

```haskell
-- degree IV of the D major scale:
d1 $ n (scale "major" ("[-1,1,3]" + "4") + "d5") # s "superpiano"

-- simple progression (I IV V ii) in D major:
d1 $ slow 2 $ n (scale "major" ("[-1,1,3]" + "1 4 5 2") + "d5") # s "superpiano"

-- same as:
d1 $ slow 2 $ n "d5'maj'3 g5'maj'3 a5'maj'3 e5'min'3" # s "superpiano"

-- simple progression (I III v VII) in E minor:
d1 $ slow 2 $ n (scale "minor" ("[-1,1,3]" + "1 3 5 7") + "e5") # s "superpiano"

-- same as:
d1 $ slow 2 $ n "e5'min'3 g5'maj'3 b5'min'3 d6'maj'3" # s "superpiano"

```

It would be nice to have a dedicated function that could take also roman numbers for the degrees and a chord type (e.g. "maj" instead of "[-1,1,3]") but I'm really a beginner at Haskell 🙄

---

<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:10 UTC](https://uzu.lurk.org/t/building-chords-from-scales/1721/8 "2020-08-25T05:10:37Z")

</div>

Cross linking:

> [@(Hopefully) Interesting snippet for making melodies](https://club.tidalcycles.org/t/hopefully-interesting-snippet-for-making-melodies/2012/6):
>
> Hi all! I really like this topic, this is my favorite one-liner: 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: d1 $ "0 2 4 6" # key "0:major"

---

<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:** [12 April 2021 06:24 UTC](https://uzu.lurk.org/t/building-chords-from-scales/1721/9 "2021-04-12T06:24:25Z")

</div>

> [@earthlydelight](#):
>
> It would be nice to have a dedicated function that could take also roman numbers for the degrees and a chord type (e.g. "maj" instead of "[-1,1,3]")

Cross linking

> [@RFC: working on making chord naming/chordList more consistent](https://club.tidalcycles.org/t/rfc-working-on-making-chord-naming-chordlist-more-consistent/2717):
>
> Hi all, Referencing [this discussion](https://club.tidalcycles.org/t/week-5-lesson-2-chords-arpeggios-and-algoraoke/913/27) on chord naming, I thought it would be worth having a bit of a discussion about what people want/are expecting: [Here's the source code](https://github.com/tidalcycles/Tidal/blob/main/src/Sound/Tidal/Chords.hs) My first idea is to take the standard capitalised M (major) and lower case m (minor) nomenclature and apply it - I assume this has been considered though... My proposal - taking: elevenSharp :: Num a =\> [a] m11sharp :: Num a =\> [a] and changing to: M11sharp :: Num a =\> [a] m11sharp :: Num a =\> [a]@yaxu does haskell all…

---

<div class="post-metadata">

**Author:** ![mrreason](https://uzu.lurk.org/user_avatar/uzu.lurk.org/mrreason/32/3203_2.png) [@mrreason](https://uzu.lurk.org/u/mrreason)\
**Post date:** [7 July 2022 16:34 UTC](https://uzu.lurk.org/t/building-chords-from-scales/1721/10 "2022-07-07T16:34:26Z")

</div>

This is one of the topics I've been working on a lot lately.

My motivation was to make some rules accessible via TidalCycles using the system of western music theory that I am familiar with. However, I attach great importance to defining and transforming chord progressions and notes with patterns, in order to be able to use the strengths of TidalCycles flexibly here.

There are now a lot of ideas flowed in here and I have collected everything here once. To give you an idea, the usage in TidalCycles looks like this:

```haskell
do
-- Define chord progressions with roman numerals
s1 = sheet {key = "c", mode "major", numerals = "<1 1 4 5>"}
-- The chord will be created on their elements like 
-- root (1), major/minor third (3) and perfect fifth (5).
-- And the chord progressions is based on the sheet. 
-- This will play <Cmaj Cmaj Fmaj Gmaj>  
d1 $ s "superpiano" <| prog s1 "[1,3,5]" |- note 12
-- Create a melody with the chord changes but use 
-- diatonic notes outside of the chord
d2 $ s "superpiano" <| prog s1 "1 5 7@2 3 6 8@2" 

```

I addressed a lot of western harmony concepts like secondary dominants, tritone substitution, borrowed chords and inversions. And you can play a harmony in one scale (like major) and the melody in another scale (like minPent).

Personally, I'm able to code melodic sets much more specifically live with it. I also use it to write flexible backing tracks/loops for the guitar.

If you are interested in such stuff, here is the complete post:

> **[GitHub - thgrund/mrreason-setup: Design, ideas and motivation for my...](https://github.com/thgrund/mrreason-setup#applying-western-music-theory)**
>
> Design, ideas and motivation for my TidalCycles setup. - GitHub - thgrund/mrreason-setup: Design, ideas and motivation for my TidalCycles setup.

---

<div class="post-metadata">

**Author:** ![kit-christopher](https://uzu.lurk.org/user_avatar/uzu.lurk.org/kit-christopher/32/686_2.png) [@kit-christopher](https://uzu.lurk.org/u/kit-christopher)\
**Post date:** [13 July 2022 18:01 UTC](https://uzu.lurk.org/t/building-chords-from-scales/1721/11 "2022-07-13T18:01:28Z")

</div>

hey @mrreason i am getting hung up on this portion of your code.tidal...it won't evaluate for me. do i not have a certain extension/package installed? any other ideas?

```haskell
-- Used for using parts and segments
stacker = Map.fromList
(!) = (Map.!)
transformStacker parts = stacker $ map (\x -> (fst $ head x, transform x)) (transpose $ filledWithSilence parts)
    where allowedAndNeededKeys = ["lead", "bass", "key", "drums", "pad", "clock", "pod", "arp"]
          filledWithSilence parts = map (\x -> addSilence x) parts
          addSilence pt = map (\x -> if (Map.member x (pt)) then (x, pt ! x) else (x, silence)) allowedAndNeededKeys
          transform x = transformBy 1 x
          transformBy _ [] = []
          transformBy y [x] = [(show y, snd x)]
          transformBy y (x:xs) = (show y, snd x) : (transformBy (y + 1) xs)

```

---

<div class="post-metadata">

**Author:** ![mrreason](https://uzu.lurk.org/user_avatar/uzu.lurk.org/mrreason/32/3203_2.png) [@mrreason](https://uzu.lurk.org/u/mrreason)\
**Post date:** [14 July 2022 11:29 UTC](https://uzu.lurk.org/t/building-chords-from-scales/1721/12 "2022-07-14T11:29:35Z")

</div>

Hey @kit-christopher, glad to hear that you give these concepts a chance!

> any other ideas?

Hard to tell since I don't recognize the indentations. It it possible for you to add the TC code here in the code block? Do you get an error message? What does it look like? When I evaluate the code from `code.tidal`, everything works like I expect.

---

<div class="post-metadata">

**Author:** ![kit-christopher](https://uzu.lurk.org/user_avatar/uzu.lurk.org/kit-christopher/32/686_2.png) [@kit-christopher](https://uzu.lurk.org/u/kit-christopher)\
**Post date:** [14 July 2022 13:54 UTC](https://uzu.lurk.org/t/building-chords-from-scales/1721/13 "2022-07-14T13:54:02Z")

</div>

sorry! i put the code into a block above...i just copied and pasted your stuff into an existing tidal session i had open and evaluated every line on its own. here's the error i get when trying to eval the `Map` portion

```haskell
Not in scope: `Map.fromList'
    No module named `Map' is imported.

    Not in scope: `Map.!'
    No module named `Map' is imported.

    Not in scope: `Map.member'
    No module named `Map' is imported

```

---

<div class="post-metadata">

**Author:** ![mrreason](https://uzu.lurk.org/user_avatar/uzu.lurk.org/mrreason/32/3203_2.png) [@mrreason](https://uzu.lurk.org/u/mrreason)\
**Post date:** [14 July 2022 13:58 UTC](https://uzu.lurk.org/t/building-chords-from-scales/1721/14 "2022-07-14T13:58:19Z")

</div>

Oh, I didn't realized that I forgot that. You need to evaluate `import qualified Data.Map.Strict as Map`. I have this added to my `BootTidal.hs` and will add it this line to the `code.tidal` file.  
This should fix the problem.

---

<div class="post-metadata">

**Author:** ![kit-christopher](https://uzu.lurk.org/user_avatar/uzu.lurk.org/kit-christopher/32/686_2.png) [@kit-christopher](https://uzu.lurk.org/u/kit-christopher)\
**Post date:** [14 July 2022 16:10 UTC](https://uzu.lurk.org/t/building-chords-from-scales/1721/15 "2022-07-14T16:10:49Z")

</div>

wonderful, adding now! thanks @mrreason!

---

<div class="post-metadata">

**Author:** ![HoshiNoRandii](https://uzu.lurk.org/user_avatar/uzu.lurk.org/hoshinorandii/32/2735_2.png) [@HoshiNoRandii](https://uzu.lurk.org/u/HoshiNoRandii)\
**Post date:** [24 October 2023 15:34 UTC](https://uzu.lurk.org/t/building-chords-from-scales/1721/16 "2023-10-24T15:34:10Z")

</div>

Hi all! I am also interested in this problem, though I've gone about it a little differently than @mrreason.

I like the way chord modifications work in TidalCycles, but with the existing chord utilities, in order to stay in the key, I would need to know if the chord built on, say, the 2nd scale degree should be major or minor (or something else) to keep all the tones in the key. And I'd also need to know what note the 2nd scale degree is -- an easier problem but a non-trivial one (for me, at least). I've become more familiar with answering these questions in a major scale over time, but I hate memorizing and wanted to be able to play around in other modes/scales.

[I've been playing with my ideas in a fork.](https://github.com/HoshiNoRandii/Tidal/blob/main/KEYCHORDS_README.md) The `keyChords` function that I wrote builds chords on scale degrees with a given tonic and scale. Here's an example:

```haskell
d1 $ slow 4 $ keyChords "g4" "major" "1 2 4-i-d 5-ii-d" # s "superfm"

```

This would play a I ii IV V progression in g major, with the IV being first inversion and the V being second inversion. The `-d` on those two chords brings them down an octave. I've implemented some other chord modifications to work with this function as well.

One fun thing that wasn't part of my original intention is that the tonic and the scale can be patterned too, which I want to play with a bit more in compositions.

I'm wondering: is anybody working on bringing something like this to version 2.0, or is it out of scope? I'd love for TidalCycles to have more options for composition within a chosen key. I'd be happy to work on upstreaming any of this if people want, or to help if there's other efforts 🙂
