Skip to content

About

Generate and score chord progressions in this python algo/project

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Moniooshko

Project built for educational purposes for "Programming in Functional Languages" course. Topic is listed below. image

Tech Stack / Requirements

Libraries:

  • PyQt5
  • pyfluidsynth
  • mido

Also required:

  • FluidSynth (!) installed on system
  • .sf2 soundfont

Topic

ENG: "Application which generates and rates chord progressions in real time with the following functionalities: in-app playback, export to MIDI and export to sound file."

PL: "Program generujący i oceniający progresje akordów w realnym czasie, z funkcją odtwarzania dźwięku w programie, eksportu do MIDI i (w miarę możliwości) eksportu do gotowej ścieżki dźwiękowej."

Idea breakdown

It would be cool if project could let you explore different chord progressions and let you hear differences between them based on some characteristics that can be seen in classical music. These include:

  1. root movement (traditionally: the less movement the more organised progression seemed)
  2. voice movement (how much each note travels between chords - the less the better)
  3. cadence (tradiationally: chords that ended in IV, I or V, I etc. were seen as more complete and good sounding)

In order to better explore different optimal chord progressions and make them more spicy (as values of parameters increase) we also restrict the available chord progressions by imposing these rules:

  1. Progression's roots' jumps have to be at least of alpha parameter.
  2. Progression HAS to have exactly beta parameter notes out of classic diatonic triad built from given achords root note.

If we could score all progression combinations made from some set of chords given to the program by us depending on these 3 criteria AND fulfill the 2 restrictions, some really interesting conclusions maybe could be drawn.

How it's implemented

The criteria and final harmonic cost are calculated by the following function:

def harmonic_cost(p):
    names=[identify_chord_name(c) for c in p]
    idx=[ROMAN2IDX[n] for n in names]
    cost_root=sum(abs(idx[i]-idx[(i+1)%4]) for i in range(4))
    cost_voice=sum(voice_motion(p[i],p[(i+1)%4]) for i in range(4))
    cad_bonus = -4 if names[-2] in {'V','V7/V','vii°'} and names[-1]=='I' else (-2 if names[-2]=='IV' and names[-1]=='I' else 0)
    return W_ROOT*cost_root + W_VOICE*cost_voice + cad_bonus

The restrictions are checked by these functions:

def alpha_ok(p, a):
        idx = [ROMAN2IDX.get(identify_chord_name(c), -1) for c in p]
        if -1 in idx:
            return False
        moves = [abs(idx[i] - idx[(i+1) % 4]) for i in range(4)]
        return min(moves) >= a and any(m > 0 for m in moves)

def beta_chord(ch):
        root = ch[0] % 12
        mod_scale = [n % 12 for n in scale]
        if root not in mod_scale:
            return 3

        i = mod_scale.index(root)
        triad = {root, scale[(i+2)%7] % 12, scale[(i+4)%7] % 12}
        chord_notes = {n % 12 for n in ch}

        diff = chord_notes - triad
        return len(diff)

    def beta_prog(p):
        return sum(beta_chord(c) for c in p)

About

Generate and score chord progressions in this python algo/project

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages