Melody improvisation

hi @hitsware

may i suggest some improvements ? Explain what this code does with comments to help people to understand and learn about your code :slight_smile:

There has been some brief discussion on the code further up this thread.

# Since normally a piano melody is played with the right hand
# ( higher notes ) while the left plays the rhythym , our mind
# translates the random high octave notes as an improvision .

midinumber=[:r]
# create array with '0' element as rest

for justnumber in 1..1023
  # array index 1 to 1023 (ratiometric notes)
  # I.E. octave = 2 : 1 .... fifth = 3 : 2
  
  midinumber [justnumber] = hz_to_midi(justnumber * 1.5)
  # set midinumbers to desired frequencies
end

chord=[9,8,6,9,6,6,6,6,8,8,6,6]
# 12 bar blues progression
# key = 6 ... forth = 8 ... fifth = 9

multiplier = [9,9,10,10,11,11,10,10]
# boogie style note pattern

octave=[1,2,4]
# possible note octaves

loop do
  for x in 0..11
    for y in 0..7
      # 12 bars of eighth notes
      
      synth :piano, note: midinumber [12*choose(octave)*chord[x]]
      # finger one plays root chord notes (random octaves)
      
      synth :piano, note: midinumber[multiplier[y]*choose(octave)*chord[x]]
      # finger two plays pattern (random octaves)
      
sleep 0.3; end; end; end
2 Likes

hi @hitsware,

Thanks for these comments.
I copy paste the code and play and

plays “weird”, 'disonnant" ?
Is it wanted :slight_smile:

hopefully correcting

# One man's dissonance is another man's funk : )
# Yes ... I like to use as small of numbers as possible
# and tolerate some instrument abuse ...

mn=[:r]; for jn in 1..1023
  mn[jn]=hz_to_midi(jn*1.5)
  
  # change above to : mn[jn]=hz_to_midi(jn*1.5).round
  # this will make all midi numbers integars insuring
  # equal tempered tuning
end

o=[1,2,4]
m=[9,9,10,10,11,11,10,10]
# OR the above should be [27,27,30,30,32,32,30,30]
c=[9,8,6,9,6,6,6,6,8,8,6,6]

loop do
  for x in 0..11; for y in 0..7
      synth :piano, note: mn[12*choose(o)*c[x]]
      # AND the 12 changed to 9 above ...
      synth :piano, note: mn[m[y]*choose(o)*c[x]]
sleep 0.3; end; end; end
1 Like

thanks for your changes but, well not a lot of differences for me, sorry about that but i’m not convinced. Or let say your build the very new synth for sonic pi : "old piano from the attic "
Cheers

Hmmmmm …
That is interesting .
What type of music do you usually listen to ?
The boogie type riffs do use intervals which
could sound off to someone unaccustomed
( I think ) Does this YouTube sound ?

1 Like

classical music, indies stuff from 80s and 90s etc.
Some dissonance stuff : sonic youth as example also Chopin, Debussy, Fauré.
but not boogie :slight_smile: (the video sound looks fine to me, even if not "my cup of tea " :slight_smile: ) and mainly western music
I don’t know if these details feed the topic… :slight_smile:

Double Hmmmmmm !
If the tempered version of my piece still sounds
’ off ’ to you then ???
Maybe someone will chime in with some insight .
AND I will reconsider my ’ score ’ …

I also find that piece of code very ‘off’… dissonant. out of tune
screeches nails on blackboard

Eli…

Triple Hmmmmm …

######## A Study in Honky Tonk ##########

a=[18,27,18,30,18,32,18,30]
b=[18,27,18,30,18,33,18,30]
c=[55,62,55,64,55,65,55,64]

loop do
  
  for i in 0..7; puts "just intonation"
    play hz_to_midi(11*a[i]), release: 2
  sleep 0.5; end; sleep 1
  
  for i in 0..7; puts "equal tempered"
    play hz_to_midi(11*a[i]).round, release: 2
  sleep 0.5; end; sleep 1
  
  for i in 0..7; puts "just hitswares folly"
    play hz_to_midi(11*b[i]), release: 2
  sleep 0.5; end; sleep 1
  
  for i in 0..7; puts "tempered hitswares folly"
    play hz_to_midi(11*b[i]).round, release: 2
  sleep 0.5; end; sleep 1
  
  for i in 0..7; puts "official midi numbers"
    play c[i], release: 2
  sleep 0.5; end; sleep 1
  
end

I like that.

Over there at Lines there is an thread about microtonal music. It is an interesting and challenging idea that you could say we are somehow spoiled by the tyranny of the well-tempered tuning in western musical culture.

And this is my currently favorite example how microtonality works really well in popular music.

yes but boogie music is not oriental or indian music ? Boogie seems to be a western music no ?
ps : Listening to Daniel Johnston is awesome too and often “off”.

cool stuff not off at all for this style of music.

yes but boogie music is not oriental or indian music ?

Right .

Boogie seems to be a western music no ?

Yes. Some ’ blues ’ intervals could possibly be construed as ’ off ’ though .
Try ’ Purple Haze ’ ( Jimi Hendrix ) compared to Vivaldi : )

ps : Listening to Daniel Johnston is awesome too and often “off”.

Thank You … Hadn ’ t heard him … Reminds me of early Bob Dylan .

Wow! As a newb and not a musician that was quite the class. Thanks maestro.

1 Like

I’ve been looking all over the internet for music and melody generation.

Music Theory I know little about but I wonder how hard it would be to program something like this.

Not necessarily in sonic pi. But something that I could use to generate notes heck even hard code it to parse for copy in paste into sonic pi.

You might be interested in my current project then.

1 Like