Cabbage Logo
Back to Cabbage Site

Randomize with conditions?

Hi :slight_smile:

I am trying to create a Csound program that follows this chord progression chart:

I have created a 2D array that stores these chords using pitch classes in the key of C:
Screen Shot 2022-02-18 at 10.38.30 PM

Is there a way to let the program run the chord progression endlessly but following this progression chart? For example in the key of C, starting with C major (0 4 7), it can move to any chord randomly, and let’s say D minor (2 5 9), which only goes to either G major (2 7 11) or Bdim (2 5 11). If going to G major, then it goes to either C major or A minor (0 4 9), so on and so forth. This would allow me to create harmonic background music that sounds musically and seamlessly.

The next step would be adding chances and conditions to modulate to different keys and even expand to 7th chords.

I would really appreciate it if someone could help me out with any suggestions and ideas! Thank you so much XD

Yes, this is of course possible. It sounds like you need to define a formal grammar based on the chord sequences.

iii -> vi
vi -> IV/ii
ii -> vii/V
IV -> vii/V
vii -> [I]
V -> [i]

The start on iii, move to vi, then randomly pick from IV or ii, etc. If you have all the chords defined in arrays then you have much of the work done already.

That sounds great! Should I use a nested if statement?

You’ll probably need more than an nested if statement. I would start by trying to generate a sequence of random numbers and move on from there. I would do this in a separate instrument, and then once you have the basic logic worked out try to bring it over into your main project.

I don’t know if this will help, but here is a JS based instrument that constructs musical phrases based on a simple grammar. Each time you press the mouse, a new phrase is generated that is based on a simple construct - article, noun, verb, noun, verb, article, noun. Each entity has multiple choices, for example a ‘verb’ can be midi note 72, 69 or 67.

Thanks for sharing! That looks really interesting :))

I started working on it today and I have done the random sequencing as you suggested. I created an array of seventh chords in the same key and it actually already sounds pretty musical without the grammar. I am going to take a deep look at your examples to program the grammar, making the chord progressions and phrases more logical and predictable.

https://drive.google.com/file/d/1L5IpfIE8Lf_6Mg_Ug1g0j5t_N4qMuzNQ/view?usp=sharing

Muse is sending OSC data to Csound controlling the scanned synthesis, as well some panning and vibratos. Thanks to Shengzheng Zhang for designing the beautiful instrument!

1 Like