Randomly Generated Motif

Skip to the bottom

  • @saumera  1 week

    I thought it would be fun to make a song based around a motif consisting of a series of random notes, then I thought hey I'm a coder why don't I open this challenge up! So I wrote a small script that will randomly generate a musical motif that's 4 to 10 notes in length.

    Want a motif of your own? Give me a key (or it can be chromatic for an extra challenge) and I'll create one for you. It can be in any key and the scales available are:
    - Major
    - Minor
    - Minor blues
    - Whole Tone
    - Octatonic (whole/half)
    - Octatonic (half/whole)

    When you get your motif, you can use it any way you can come up with:
    it can be a bass line, it can outline your main melody, it can even be the roots of your chord progression, whatever you can make work. When you're done tag your song #motif and post it here!

    EDIT: @quillwraith created a quick little website that uses my script, and will generate one for you! Check it out!

    https://forrestweiswolf.github.io/ran...

  • @saumera  1 week

    For my fellow coders out there, here's the code! (I wrote it in Javascript to be executed by node lol):

    const notes = [ 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B', ];
    const MIN = 4;
    const MAX = 10;

    const scales = {
    major: [ 0, 2, 4, 5, 7, 9, 11 ],
    minor: [ 0, 2, 3, 5, 7, 8, 10, 11 ],
    blues: [ 0, 2, 3, 5, 6, 7, 10 ],
    halfWhole: [ 0, 1, 3, 4, 6, 7, 9, 10 ],
    wholeHalf: [ 0, 2, 3, 5, 6, 8, 9, 11 ],
    wholeTone: [ 0, 2, 4, 6, 8, 10 ],
    chromatic: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ],
    }

    const getRand = (array) => array[Math.floor(Math.random() * (array.length))];

    const createGetNote = (baseIndex, scale) => {
    return () => notes[(baseIndex + getRand(scale)) % notes.length];
    }

    const generate = (key='', scaleType='') => {
    const baseIndex = notes.indexOf(key.toUpperCase()) || 0;
    const scale = scales[scaleType] || scales.chromatic;

    const len = Math.floor(Math.random() * (MAX - MIN)) + MIN;
    const getNote = createGetNote(baseIndex, scale);
    return Array.from({ length: len }, getNote);
    }

    const [ key, scaleType ] = process.argv.slice(2);

    const motif = generate(key, scaleType);
    console.log('Motif: ', motif.join(', '));

  • @valeriecox  1 week

    That sounds fun! Please generate me one in C Major.

  • @saumera  1 week

    Sure thing!

    @valeriecox your motif consists of the notes A, B, G, F, E, D, E

    Sounds like a fun one!

  • @vomvorton  1 week

    This sounds fun, and I'm desperate for some inspiration! D major please.

  • @saumera  1 week

    @vomvorton your motif consists of the notes G, D, F#, B. Seems like a cool bass line!

  • @vomvorton  1 week

    @saumera thanks, I will attempt to create something using that right away!

  • @saumera  1 week

    I decided to do a chromatic one and looks like I got G, A, C, F, C#, D, G, F#

  • @pearlmanhattan  1 week

    @saumera

    I'll take one, please? In G major

  • @saumera  1 week

    @pearlmanhattan your motif consists of the notes B, F#, E, G, F#, E, B

  • @krayzie003  1 week

    This is cool. I'll take a motif.

    I'm not a coder but I would like to know how to run this code. This could be great for future inspiration.

  • @saumera  1 week

    @krayzie003 any key?

  • @krayzie003  1 week

    @saumera. Something major. Don't care which.

  • @saumera  1 week

    @krayzie003 I picked Ab major. Here's your motif:

    C, Db, Ab, Eb, Bb, Bb, Ab, C, Ab

    And as for your running that code on your own, it's a little tricky just because of the language I chose. Computers don't come pre-loaded with something that can run it, so you would have to install node.js on the command line and then run "node motif_generator.js C major."

    If there's enough interest, I can rewrite it in something like python or perl that every computer has and the command could be run from the command line of any machine.

  • @sherrycanary  6 days

    I would like one in G
    Thank you

  • @saumera  6 days

    @sherrycanary your motif has the notes G, C, F#, A, D. That tritone might be tricky!

  • @gbg2016  4 days

    I'd love one. Chromatic please!

  • @quillwraith  4 days

    @sherrycanary "And as for your running that code on your own, it's a little tricky just because of the language I chose. Computers don't come pre-loaded with something that can run it, so you would have to install node.js on the command line and then run "node motif_generator.js C major.""

    JavaScript runs in the browser, and the only node specific thing here is process.argv. It would be pretty simple to do a webpage version: https://forrestweiswolf.github.io/ran...

    ( I'll take it down if you want, or hand over the repository - I don't mean to take your work! Just seemed like a quick way to make it more usable for people.)

  • @saumera  3 days

    @quillwraith nah this looks great! I forget, does github have some service that allows you to host a simple webpage like this? It'd be pretty cool to get it up somewhere.

  • @saumera  3 days

    Oh disregard that you're already hosting it, I missed the link!

  • @powerstars 3 days

    Ooh! I couldn't think of a key so I picked one at random. Can I get one in G Minor?

  • @krayzie003  3 days

    Along these same lines I found a website where you can type in you name (or any phrase) and it will generate music from it. http://www.clarallel.com/

  • @owl  3 days

    May I have one in A minor?

  • @musicsongwriter 3 days

    I'd like a motif please. Thank you.

  • @saumera  3 days

    @powerstars: F, A, Eb, Gb, Bb

    @owl: D, A, C, B, A

    @musicsongwriter: you didn't give me a key so I picked chromatic. F#, A#, C#, F

  • @pearlmanhattan  2 days

    https://fawm.org/songs/94058/ My contribution based on my random generated motif. thank you.

  • @musicsongwriter 2 days

    Thank you for your motif. Here is my take:
    https://fawm.org/songs/94071/

  • @krayzie003  2 days

    Here is what I created with my random motif... https://fawm.org/songs/94209/

    This was really fun.

  • @vomvorton  2 days

    Here's my motif song! The notes I was generated formed the verse bassline (which is also played by the keyboard), everything else spiralled out from there.

    https://fawm.org/songs/94301/

  • @splittybooms  2 days

    That's super cool...and I love motifs.
    I'll take one in Eb minor, please!

  • @saumera  2 days

    This is so awesome, guys! I'm so glad to see the motif idea is working out for some of you.

    @splittybooms here's your Motif in Eb minor: Db, F, Cb, Gb, Gb, Gb, Bb, F

  • @fearlessflight2014  2 days

    I would like something in my favourite key of Bb? Thanks!

  • @saumera  2 days

    @fearlessflight2014 your motif is Bb, Eb, G, D, Bb, G, C, C

  • @erikleppen 2 days

    Shouldn't scales.minor be [0, 2, 3, 5, 7, 8, 10], without the 11?

    As far as I know, C-Minor is C, D, Eb, F, G, Ab, Bb. Without B.

    But I really like the idea 😁

  • @saumera  1 day

    @erikleppen I included the leading tone as an available note so dominant chords could be used. It's a note in the harmonic minor scale.

  • @erikleppen 1 day

    Aha. Guess I learned something new today 😀 Thanks!

  • @splittybooms  1 day

    Am I understanding correctly, that we have to use the notes in the order given to us, @saumera?

  • @saumera  1 day

    @splittybooms I wouldn't say there are any hard and fast rules with using motifs, I would say the general idea is to use them as the groundwork for a line or chord progression. For instance in yours there are three notes that repeat, which might be kind of tricky. But if you make them emphasized notes and then put a couple neighboring tones in between them, it would still get the idea across that those three notes were the important ones.

    You could do the same thing with a bass line where each note in the motif falls on the down beat and everything else in between can be whatever you want. Just play around with it and see what you come up with!

  • @splittybooms  1 day

    Ah yes, ok - i just wanted to see how free we were with the notes you gave; if there were indeed 'hard and fast' rules lol
    I kept to the order given on all but the pad and the lead, though the lead strays only somewhat for the most part.
    Bass, and a melody pluck, and the root of all the chords follow the motif in order.
    Geez, thanks a lot, CODING, for giving me that wonderful GbGbGb! lol

Leave a Message. Log in to FAWM or sign up first...