Melody improvisation

@Eli Thank you for sharing the performance from @NanoMan (really beautiful…) and the MusicRadar resource! I also coincidentally found this post from 2017 on this forum the same day I wrote the comment on middle eastern music:

Maqam Music with Sonic Pi - Performance

I think I will try and see if I can create my own fork of SonicPi and customize it the same way :smiley:

@mrbombmusic That function is quite nice and actually gives a result that is not so far off from what I achieved manually! I learned a lot by examining your code, I started to play around with it to see if I can add a bit more functionality like chord changes and timing variations. If I come up with anything interesting I will post it here :grinning:

Thanks all of you for the amazing inspiration! This forum is quickly becoming one of my favourite online hangout places :grin:

2 Likes
#..........A.M.I.
mn=[:r]; for jn in 1..1023
  mn[jn]=hz_to_midi(24*jn).round
end

c=[6,5,8,9]
h=[48,54,60,72,81,96,0]
m=[0.25,0.5,0.75]

live_loop :keys do
  for x in 0..3
    synth :dtri, note: mn[c[x]], detune: 7,
      sustain: 2, release: 0,amp: 0.3
sleep 2; end;end

live_loop :lead do
  n=choose(h)
  t=choose(m)
  synth :pluck, note: mn[n/8]
sleep t; end
2 Likes

This sounds very nice and works well.

Thank You ! … :slight_smile:
A lesson I have learned
is that ‘music’ is in the ear
of the beholder. There is a
threshold where chaos transforms
into beauty. (Or at least tunefulness)

I agree with Robin, it works well.

There are several people who post code here in the
same… ‘style’?

To me it seems very mathematical, far more so than
musical… is it a syntax from a different programme that
people know about?

Eli…

Thank You !
Do You mean it sounds mathematical, or looks mathematical ?
Here is the essence …

 mn=[:r]; for jn in 1..1023# midi-number[just-number]
  mn[jn]=hz_to_midi(24*jn).round; end
#just intonation uses the mathematical relationships
#of the frequencies of pitch as the framework
#I.E.
c=[6,5,8,9]
#6,8,9 are the relationships of (key of C) C,F,G
#tonic, sub-dominant, dominant
#5 is the relative Minor ... A

sorry but where does this come from ? a wizard hat ?

1 Like

Derivation of C scale @ A 440 Hz using just intonation …
Sequence of lowest integers that represent the ratios of frequencies of a major scale …
24, 27, 30, 32, 36, 40, 45, 48
In the key of C
C, D, E, F, G, A, B, C
We see that ’ A ’ is represented by ’ 40 ’
If we want to normalize the scale to A - 440 Hz
440 / n = 40 … therefore n = 11
If we want to produce the scale numerically using
midi numbers ( as with Sonic Pi ) …
Then …
midi-number [ just-number ] = hz_to_midi ( just-number * 11 )

1 Like

I mean it -looks- mathematical. The sound does not -sound- mathematical, nor just ‘random’…
it sounds natural.

Eli…

Random , but with ’ steerage ’
The ’ chords ’ are 1 rst & 5 th pairs .
The notes are a pentatonic scale
in C … Sort of like a harmonica …
hard to go wrong . The one possible
rest in each choice helps . The timing
is random … but on intervals that imply
4 / 4 time . It was a lucky try :slight_smile:

mn=[:r]; for jn in 1..1023
mn[jn]=hz_to_midi(jn*1.5); end

o=[1,2,4]
m=[9,9,10,10,11,11,10,10]
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]]
      synth :piano, note: mn[m[y]*choose(o)*c[x]]
sleep 0.3; end; end; end

I know this might seem weird for some. But this kind of code helps me learn more about music because it makes more sense for me. There is no right way just your way. Thanks all for sharing codes and thoughts.

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