SonicPiで曲作り 5

use_bpm 45
use_random_seed 1

index = -1
s_index = 0
b_index = 0

s = [
  ##| 0,1,2,3,4,5,6
  0,1,2,3,4,5,3,4,1,2,5,6
];

c = []


##| scale(:A, :ritusen)
##| sc_name =  :minor_pentatonic
##| sc_name = :egyptian
##| sc_name =:hex_dorian
sc_name = :ritusen

c[0] = [
  [scale(:Es4 ,sc_name) ,0.125,32],
  [scale(:As4 ,sc_name) ,0.125,32],
  [scale(:Ds4 ,sc_name) ,0.125,32],
  [scale(:Es4 ,sc_name) ,0.125,32],
]
c[1]=[
  [scale(:Es3 ,sc_name) ,0.25,16],
  [scale(:Ds3 ,sc_name) ,0.25,16],
  [scale(:Es3 ,sc_name) ,0.25,16],
  [scale(:As3 ,sc_name) ,0.25,16],
]
c[2]=[
  [scale(:Ds3 ,sc_name) ,0.25,16],
  [scale(:Es3 ,sc_name) ,0.25,16],
  [scale(:As3 ,sc_name) ,0.25,16],
  [scale(:Ds3 ,sc_name) ,0.25,16],
]
c[3]=[
  [scale(:Es3 ,sc_name) ,0.25,16],
  [scale(:Ds4 ,sc_name) ,0.25,16],
  [scale(:Es4 ,sc_name) ,0.25,16],
  [scale(:As3 ,sc_name) ,0.25,16],
]
c[4]=[
  [scale(:Ds3 ,sc_name) ,0.25,16],
  [scale(:Es3 ,sc_name) ,0.25,16],
  [scale(:As3 ,sc_name) ,0.25,16],
  [scale(:Ds4 ,sc_name) ,0.25,16],
]
c[5]=[
  [scale(:Es4 ,sc_name) ,0.25,16],
  [scale(:Es3 ,sc_name) ,0.25,16],
  [scale(:Ds3 ,sc_name) ,0.25,16],
  [scale(:As3 ,sc_name) ,0.25,16],
]
c[6]=[
  [scale(:Es4 ,sc_name) ,0.25,16],
  [scale(:Es3 ,sc_name) ,0.25,16],
  [scale(:Ds3 ,sc_name) ,0.25,16],
  [scale(:As3 ,sc_name) ,0.25,16],
]

a = c[0][0]

with_fx :reverb, room: 0.99, mix: 0.7 do
  live_loop :loop0 do
    use_octave 1
    cue :loop0
    
    index = index+1
    if(index >= c[s[s_index]].length)
      index = 0
      s_index = s_index + 1
      if(s_index >= s.length)
        s_index = 0
      end
    end
    a =  c[s[s_index]][index]
    
    
    a[2].times do
      print "index ",index, "s ", s[s_index],"t ",(s_index*4+index)
      synth :sine ,
        note: a[0].shuffle.take(2),
        attack: 0, release: 0.1, amp: 0.5, pan: rrand(-0.7, 0.7)
      if((s_index*4+index) >=4)
        cue :bd
        b_index = 0
      end
      sleep a[1]
    end
  end
end

with_fx :reverb, room: 0.99, mix: 0.7 do
  live_loop :loop2 do
    sync "/live_loop/loop0"
    use_octave 1
    synth :pluck , note: a[0].shuffle.take(2), attack: 0.125, release: 2.15, amp: 0.8
    sleep 1;
  end
end


with_fx :reverb, room: 0.99, mix: 0.7 do
  live_loop :loop5  do
    use_synth :blade
    play note: a[0].pick(2), attack: 0.5, release: 8, amp: 0.15, vibrato_rate: rand(0.01..2), pan: rrand(-0.7, 0.7)
    play note: a[0].pick(2)-12, attack: 0.25, release: 8, amp: 0.15, vibrato_rate: rand(0.01..2), pan: rrand(-0.7, 0.7)
    sleep 2;
  end
end


with_fx :reverb, room: 0.7, mix: 0.7 do
  live_loop :base do
    sync "/live_loop/loop0"
    sync "/cue/bd"
    4.times do
      use_octave 1
      synth :pluck ,
        note: a[0].pick(b_index % 4),
        attack: 0.2, release: 0.25, amp: 0.5
      b_index = b_index + 1
      sleep a[1]/2
    end
  end
end


live_loop :bd1 do
  sync "/live_loop/loop0"
  sync "/cue/bd"
  sample :bd_ada, amp: 0.8
  sleep 0.5
  sleep 0.25
  sample :bd_ada, amp: 0.4
  sleep 0.25
  sample :bd_ada, amp: 0.4
  sleep 0.25
  sample :bd_ada, amp: 0.4
  sleep 0.25
end
live_loop :bd2 do
  sync "/live_loop/loop0"
  sync "/cue/bd"
  sleep 2
  sample :bd_ada, amp: 0.6
  sleep 0.5
  sleep 0.25
  sample :bd_ada, amp: 0.2
  sleep 0.25
  sample :bd_ada, amp: 0.2
  sleep 0.25
  sample :bd_ada, amp: 0.2
  sleep 0.25
end

SonicPiで曲作り 4

use_bpm 45
use_random_seed 1

index = -1
s_index = 0
b_index = 0

s = [
  0,1,2,3,4,5,6
  ##| 0,1,2,3,4,5,3,4,1,2,5,6
];

c = []

##| sc_name =  :minor_pentatonic
sc_name = :dorian

c[0] = [
  [scale(:Es4 ,sc_name) ,0.125,32],
  [scale(:As4 ,sc_name) ,0.125,32],
  [scale(:Ds4 ,sc_name) ,0.125,32],
  [scale(:Es4 ,sc_name) ,0.125,32],
]
c[1]=[
  [scale(:Es3 ,sc_name) ,0.25,16],
  [scale(:Ds3 ,sc_name) ,0.25,16],
  [scale(:Es3 ,sc_name) ,0.25,16],
  [scale(:As3 ,sc_name) ,0.25,16],
]
c[2]=[
  [scale(:Ds3 ,sc_name) ,0.25,16],
  [scale(:Es3 ,sc_name) ,0.25,16],
  [scale(:As3 ,sc_name) ,0.25,16],
  [scale(:Ds3 ,sc_name) ,0.25,16],
]
c[3]=[
  [scale(:Es3 ,sc_name) ,0.25,16],
  [scale(:Ds4 ,sc_name) ,0.25,16],
  [scale(:Es4 ,sc_name) ,0.25,16],
  [scale(:As3 ,sc_name) ,0.25,16],
]
c[4]=[
  [scale(:Ds3 ,sc_name) ,0.25,16],
  [scale(:Es3 ,sc_name) ,0.25,16],
  [scale(:As3 ,sc_name) ,0.25,16],
  [scale(:Ds4 ,sc_name) ,0.25,16],
]
c[5]=[
  [scale(:Es4 ,sc_name) ,0.25,16],
  [scale(:Es3 ,sc_name) ,0.25,16],
  [scale(:Ds3 ,sc_name) ,0.25,16],
  [scale(:As3 ,sc_name) ,0.25,16],
]
c[6]=[
  [scale(:Es4 ,sc_name) ,0.125,32],
  [scale(:Es3 ,sc_name) ,0.125,32],
  [scale(:Ds3 ,sc_name) ,0.125,32],
  [scale(:As3 ,sc_name) ,0.125,32],
]

a = c[0][0]

with_fx :reverb, room: 0.99, mix: 0.7 do
  live_loop :loop0 do
    use_octave 1
    cue :loop0
    
    index = index+1
    if(index >= c[s[s_index]].length)
      index = 0
      s_index = s_index + 1
      if(s_index >= s.length)
        s_index = 0
      end
    end
    a =  c[s[s_index]][index]
    
    
    a[2].times do
      print "index ",index, "s ", s[s_index],"t ",(s_index*4+index)
      synth :sine ,
        note: a[0].shuffle.take(2),
        attack: 0, release: 0.1, amp: 0.5, pan: rrand(-0.7, 0.7)
      if((s_index*4+index) >=4)
        cue :bd
        b_index = 0
      end
      sleep a[1]
    end
  end
end

with_fx :reverb, room: 0.99, mix: 0.7 do
  live_loop :loop2 do
    sync "/live_loop/loop0"
    use_octave 1
    synth :piano , note: a[0].shuffle.take(2), attack: 0.125, release: 2.15, amp: 0.8
    sleep 1;
  end
end


with_fx :reverb, room: 0.99, mix: 0.7 do
  live_loop :loop5  do
    use_synth :saw;
    play note: a[0].pick(2), attack: 0.5, release: 8, amp: 0.1, vibrato_rate: rand(0.01..2)
    play note: a[0].pick(2)-12, attack: 0.25, release: 8, amp: 0.1, vibrato_rate: rand(0.01..2)
    sleep 2;
  end
end


with_fx :reverb, room: 0.7, mix: 0.7 do
  live_loop :base do
    sync "/live_loop/loop0"
    sync "/cue/bd"
    4.times do
      use_octave 1
      synth :piano ,
        note: a[0].pick(b_index % 4),
        attack: 0.2, release: 0.25, amp: 0.5
      b_index = b_index + 1
      sleep a[1]/2
    end
  end
end


live_loop :bd1 do
  sync "/live_loop/loop0"
  sync "/cue/bd"
  sample :bd_ada, amp: 0.8
  sleep 0.5
  sleep 0.25
  sample :bd_ada, amp: 0.4
  sleep 0.25
  sample :bd_ada, amp: 0.4
  sleep 0.25
  sample :bd_ada, amp: 0.4
  sleep 0.25
end
live_loop :bd2 do
  sync "/live_loop/loop0"
  sync "/cue/bd"
  sleep 2
  sample :bd_ada, amp: 0.6
  sleep 0.5
  sleep 0.25
  sample :bd_ada, amp: 0.2
  sleep 0.25
  sample :bd_ada, amp: 0.2
  sleep 0.25
  sample :bd_ada, amp: 0.2
  sleep 0.25
end

SonicPiで曲作り 3

use_bpm 45
use_random_seed 1

tr = 0
t = 0
c = [
  :Gb3,:Gb3,:Gb3,:Gb3,:Cb3,:Db3,:Cb3,:Db3,
  :Ab3,:Ab3,:Ab3,:Ab3,:Bb3,:Bb3,:Bb3,:Bb3,
  :Eb4,:Eb4,:Db4,:Db4,:Gb4,:Gb4
]
a = c[0]


in_thread do
  cue :start
  with_fx :reverb, room: 0.99, mix: 0.7 do
    synth :saw , note: scale(:Gb3, :minor_pentatonic).shuffle.take(3), attack: 1.5, release: 16, amp: 0.1
    sleep 2;
    synth :saw , note: scale(:Gb4, :minor_pentatonic).shuffle.take(3), attack: 1.0, release: 12, amp: 0.1
    sleep 2;
    synth :saw , note: scale(:Gb5, :minor_pentatonic).shuffle.take(3), attack: 0.5, release: 8, amp: 0.1
    sleep 4;
  end
end

with_fx :reverb, room: 0.99, mix: 0.7 do
  4.times do
    synth :sine , note: scale(:Gb3, :minor_pentatonic).shuffle.take(2), attack: 0, release: 0.1, amp: 0.2
    sleep 1;
    synth :sine , note: scale(:Gb4, :minor_pentatonic).shuffle.take(2), attack: 0, release: 0.1, amp: 0.2
    sleep 1
  end
end

cue :bd1
cue :bd

live_loop :zoo do
  cue :bd1
  tr = c[t]
  if(tr != nil)
    a = tr
  else
    t=0
    tr = c[t]
    a = tr
  end
  
  t=t+1
  print t,a
  sleep 2
end

live_loop :bd1 do
  sync "/cue/bd"
  sample :bd_ada, amp: 0.8
  sleep 0.5
  sleep 0.25
  sample :bd_ada, amp: 0.4
  sleep 0.25
end

live_loop :bd2 do
  sync "/cue/bd"
  sleep 3
  sample :bd_ada, amp: 0.4
  sleep 0.5
  sleep 0.25
  sample :bd_ada, amp: 0.2
end


with_fx :reverb, room: 0.99, mix: 0.7 do
  live_loop :loop2 do
    ##| sync "/cue/bd1"
    cue :bd
    synth :piano ,
      note: scale(a, :minor_pentatonic, num_octaves: 2).shuffle.take(3),
      attack: 0, release: 0.15, amp: [1, 0.5, 0.25].choose
    sleep 4;
  end
end


with_fx :reverb, room: 0.99, mix: 0.7 do
  live_loop :melo do
    
    4.times do
      synth :piano ,
        note: scale(a, :minor_pentatonic, num_octaves: 2).shuffle.take(3),
        attack: 0, release: 2, amp: 0.5
      sleep 1
      
      use_synth :piano;
      32.times do
        play choose(scale(a, :minor_pentatonic, num_octaves: 2)), attack: 0, release: 0.5, amp: [0.2, 0.1, 0.4].choose
        sleep 0.125
      end
    end
    
  end
end


with_fx :reverb, room: 0.5, mix: 0.7 do
  live_loop :melo2 do
    
    if(!one_in(8))
      32.times do
        synth :pretty_bell ,
          note: scale(a, :minor_pentatonic, num_octaves: 2).shuffle.take(3),
          attack: 0, release: 0.15, amp: [0.2, 0.1, 0.25].choose
        sleep 0.125
      end
    else
      
      28.times do
        synth :pretty_bell ,
          note: scale(a, :minor_pentatonic, num_octaves: 2).shuffle.take(3),
          attack: 0, release: 0.15, amp: [0.2, 0.1, 0.25].choose
        sleep 0.125
      end
      
      8.times do
        synth :pretty_bell ,
          note: scale(a, :minor_pentatonic, num_octaves: 2).shuffle.take(3),
          attack: 0, release: 0.15, amp: [0.2, 0.1, 0.25].choose
        sleep 0.125/2
      end
    end
    
  end
end



SonicPiで曲作り 2

use_bpm 45

in_thread do
  cue :start
  with_fx :reverb, room: 0.99, mix: 0.7 do
    synth :saw , note: scale(:G3, :minor_pentatonic).shuffle.take(3), attack: 1.5, release: 16, amp: 0.1
    sleep 2;
    synth :saw , note: scale(:G4, :minor_pentatonic).shuffle.take(3), attack: 1.0, release: 12, amp: 0.1
    sleep 2;
    synth :saw , note: scale(:G5, :minor_pentatonic).shuffle.take(3), attack: 0.5, release: 8, amp: 0.1
    sleep 4;
  end
end

with_fx :reverb, room: 0.99, mix: 0.7 do
  4.times do
    synth :sine , note: scale(:G3, :minor_pentatonic).shuffle.take(2), attack: 0, release: 0.1, amp: 0.2
    sleep 1;
    synth :sine , note: scale(:G4, :minor_pentatonic).shuffle.take(2), attack: 0, release: 0.1, amp: 0.2
    sleep 1
  end
end

cue :bd

live_loop :bd1 do
  sync "/cue/bd"
  sample :bd_ada, amp: 0.8
  sleep 0.5
  sleep 0.25
  sample :bd_ada, amp: 0.4
  sleep 0.25
end

live_loop :bd2 do
  sync "/cue/bd"
  sleep 3
  sample :bd_ada, amp: 0.4
  sleep 0.5
  sleep 0.25
  sample :bd_ada, amp: 0.2
end


with_fx :reverb, room: 0.99, mix: 0.7 do
  live_loop :loop2 do
    cue :bd
    synth :piano ,
      note: scale(:G, :minor_pentatonic, num_octaves: 2).shuffle.take(3),
      attack: 0, release: 0.15, amp: [1, 0.5, 0.25].choose
    sleep 4;
  end
end

with_fx :reverb, room: 0.99, mix: 0.7 do
  live_loop :melo do
    synth :piano ,
      note: scale(:G, :minor_pentatonic, num_octaves: 2).shuffle.take(3),
      attack: 0, release: 2, amp: 0.5
    sleep 1
    
    use_synth :piano;
    32.times do
      play choose(scale(:G, :minor_pentatonic, num_octaves: 2)), attack: 0, release: 0.5, amp: [0.2, 0.1, 0.05].choose
      sleep 0.125
    end
  end
end




SonicPiで曲作り 1

use_bpm 45
use_random_seed 1

t = 0
c = [
  :Es4,:As4,:Ds4,:Es4,
  
  :Es3,:Es3,:Ds3,:Ds3,
  :Es3,:As3,:Ds3,:Es3,
  :As3,:Ds3,:As3,:Ds4,
  
  :Es4,:As4,:Ds4,:Es4,
  :Ds4,:Es4,:Es4,:Ds4,
  :As4,:Ds4,:Ds4,:Gs4,
  
  :Gs3,:Ds3,:As3,:Ds3,
  :Es3,:As3,:Ds3,:Ds3,
  :Gs3,:Es3,:As3,:Ds3
]
a = c[0]

live_loop :bd do
  sync "/cue/bd"
  sample :bd_ada, amp: 0.4
  sleep 0.5
  sleep 0.25
  sample :bd_ada, amp: 0.2
end

live_loop :loop0 do
  tr = c[t]
  if(tr != nil)
    a = tr
  else
    t=0
    tr = c[t]
    a = tr
  end
  t=t+1
  print t,a
  sleep 4
end

with_fx :reverb, room: 0.5, mix: 0.7 do
  live_loop :loop1 do
    use_synth :sine;
    play choose(scale(a, :minor_pentatonic, num_octaves: 1)), attack: 0, release: 0.1, amp: 0.1
    play choose(scale(a+12, :minor_pentatonic, num_octaves: 1)), attack: 0, release: 0.1, amp: 0.1
    sleep 0.125;
  end
end

with_fx :reverb, room: 0.99, mix: 0.7 do
  live_loop :loop2 do
    if(t>=5 && t!=20)
      cue :bd
    end
    synth :piano , note: scale(a, :minor_pentatonic, num_octaves: 2).shuffle.take(3), attack: 0, release: 0.15, amp: 1
    sleep 1;
  end
end

with_fx :reverb, room: 0.99, mix: 0.7 do
  live_loop :loop3 do
    use_synth :saw
    play note: scale(a, :minor_pentatonic, num_octaves: 2).shuffle.take(3), attack: 0.5, release: 16, amp: 0.05
    sleep 4;
  end
end

PureData「freeverb~」オブジェクト

「freeverb~」はroomsizeや、wet、dryのパラメータなどを設定すると、音が響くようにできるエフェクトです。作品「いしのこえ」の音などに使っていて、とてもよい響の音になります。しかし、RaspberryPiの最新のPureDataには対応が追いついていなくて、無理矢理つかうとPureDataが落ちてしまいました。もう使えないのかな、と思っていたのですが、改良されたソースがあり、自分でコンパイルすることで使うことができるようになりました。今回はそのメモです。

“PureData「freeverb~」オブジェクト” の続きを読む

PureDataのexternalsをつくる(1)

PureDataの機能拡張をつくりたいなと思ってトライしたことがあるのですが、すっかり忘れてしまっていたのでメモしていきたいと思います。

Githubのpure-dataのリポジトリに、externals-howtoというものがあります。
https://github.com/pure-data/externals-howto

bangでメッセージを出力する

“PureDataのexternalsをつくる(1)” の続きを読む

CNC:モーターグレードアップ(1)

マスラックスの木の彫刻を削ってくれるCNCは、OpenBuiledsという団体のLeadCNCという名前のものです。オープンソースに設計されていて汎用的な部材で拡張できるのが特徴です。今回はそのCNCのXYZ軸を動かしているモーターに「クローズドループ」という機能を追加して、「位置保持機能つきモーター」にグレードアップする途中報告になります。

“CNC:モーターグレードアップ(1)” の続きを読む

接着と塗装の実験(4)

前回は、隙間があいて失敗だと思ってたヒノキのハトを、クランプして一晩置いたら奇跡の復活!。そのあと液体ガラス塗装して乾かしているところまで進みました。今回はその乾燥状態です。まだ次の液体ガラス塗装が残っていますが、ウレタンシンナーを取り寄せ中のためもうしばらく完成はおあずけ。

“接着と塗装の実験(4)” の続きを読む