Algorithic music on alternative tuning

#1

The code

nota = 260
raiz = 1.1040895136738123
nt = []

for i in 0..14 do
    nt[i]= nota
    nota = nota*raiz
    puts nt[i]
  end
  with_fx :reverb do
   
    live_loop :acordes do
      d = (ring 1,2).choose
      use_synth :piano
      play hz_to_midi(nt[0]/d),pan: (ring -0.7,-0.3,0.7,0.3).choose
    sleep 0.5
    play hz_to_midi(nt[2]/d),pan: (ring -0.7,-0.3,0.7,0.3).choose
      sleep 0.5
      
      play hz_to_midi(nt[4]/d),pan: (ring -0.7,-0.3,0.7,0.3).choose
    sleep 0.5
    play hz_to_midi(nt[0]/d),pan: (ring -0.7,-0.3,0.7,0.3).choose
      sleep 0.5
      
      play hz_to_midi(nt[2]/d),pan: (ring -0.7,-0.3,0.7,0.3).choose
    sleep 0.5
    play hz_to_midi(nt[5]/d),pan: (ring -0.7,-0.3,0.7,0.3).choose
      sleep 0.5
      play hz_to_midi(nt[0]/d),pan: (ring -0.7,-0.3,0.7,0.3).choose
    sleep 0.5
    play hz_to_midi(nt[3]/d),pan: (ring -0.7,-0.3,0.7,0.3).choose
      sleep 0.5
      
      play hz_to_midi(nt[5]/d),pan: (ring -0.7,-0.3,0.7,0.3).choose
    sleep 0.5
    play hz_to_midi(nt[1]/d),pan: (ring -0.7,-0.3,0.7,0.3).choose
      sleep 0.5
      play hz_to_midi(nt[4]/d),pan: (ring -0.7,-0.3,0.7,0.3).choose
    sleep 0.5
    play hz_to_midi(nt[6]/d),pan: (ring -0.7,-0.3,0.7,0.3).choose
      sleep 0.5
    end
    
    sleep 12
    live_loop :mus do
      use_synth :piano
      azar = rrand_i(0,5000)
      veces = rrand_i(5,8)
      d = (ring 0.5,1,2).choose
      with_fx :echo, phase: (ring 0.25,0.50).choose do
        2.times do
          use_random_seed azar
          veces.times do
            i = rrand_i(0,7)
            n = rrand_i(2,4)
            play hz_to_midi(nt[i]/d), pan: rrand(-0.5,0.5)
            play hz_to_midi(nt[i+n]/d), pan: rrand(-0.5,0.5)
            sleep (ring 0.75,0.25,0.50).choose
          end
        end
      end
      with_fx :echo, phase: (ring 0.25,0.50).choose do
        2.times do
          use_random_seed azar
          veces.times do
            i = rrand_i(0,7)
            n = rrand_i(2,4)
            play hz_to_midi(nt[i]/d), pan: rrand(-0.5,0.5)
            sleep 0.25
            play hz_to_midi(nt[i+n]/d), pan: rrand(-0.5,0.5)
            sleep (ring 0.75,0.25,0.50).choose
          end
        end
      end
    end

https://www.youtube.com/watch?v=iQ2sPHg59o4

2 Likes
#2

Nice stuff, although please be aware that the :piano synth only plays whole tones, and so the following will result in exactly the same pitch:

synth :piano, note: 60
synth :piano, note: 60.4

However, all other synths will honour fractional notes.

Also, for experimenting with different tuning systems, you might be interested in playing with use_tuning :slight_smile:

#3

@samaaron what’s the reason the piano synth won’t do fractional notes?
It would be nice if it was possible to use it with different tunings (or just out of tune).

#4

@emlyn The limitation is down to the specific way in which the piano synth was coded at the SuperCollider level. It uses a lot of hard-coded magic numbers for each piano note.

#5

Thanks @samaaron. I had a look through the source code, and while it does quantise the input note to the nearest midi number, it doesn’t look like it’s inherently limited to whole numbers, since the ugen has a tune input that looks like it’s for the fractional part of the note (here).
When I get a bit of time I may try compiling a synthdef with the fractional part of the note wired up to the tune input and see if I can get it to play non-integer notes.

1 Like
Modifying and compiling synthdefs
#6

Oh nice! If you can figure out a way of using that to essentially interpolate between well tempered pitches, that would be nice. What would be ideal is if the synthdef just accepted a float MIDI value and handled this tune parameter internally.

#7

@samaaron I’ve made a new topic over here to avoid hijacking this thread further. I had an initial go at modifying the synthdef but am a bit stuck - any pointers you have would be great.