sonic-pi_osc.txt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. set :tC1, current_time
  2. oldT1 = 0
  3. set :tC2, current_time
  4. oldT2 = 0
  5. set :tC3, current_time
  6. oldT3 = 0
  7. latency = 0.3
  8. #use_sched_ahead_time 0.4
  9. #set_sched_ahead_time! 0.3
  10. live_loop :sample01 do
  11. use_sched_ahead_time latency
  12. a, b, c = sync "/osc*/trigger/sample01"
  13. nowT = a
  14. inc = nowT - oldT1
  15. oldT1 = nowT
  16. print inc
  17. delta = (get[:tC1] - current_time) + inc #0.25
  18. print delta
  19. if(delta > 0.1 )
  20. delta = 0
  21. end
  22. if(delta < -0.1 )
  23. delta = 0
  24. end
  25. time_warp delta do
  26. t = current_time
  27. set :tC1, t
  28. sample b, amp: c
  29. end
  30. end
  31. live_loop :sample02 do
  32. use_sched_ahead_time latency
  33. a, b, c = sync "/osc*/trigger/sample02"
  34. nowT = a
  35. inc = nowT - oldT2
  36. oldT2 = nowT
  37. print inc
  38. delta = (get[:tC2] - current_time) + inc #0.25
  39. print delta
  40. if(delta > 0.1 )
  41. delta = 0
  42. end
  43. if(delta < -0.1 )
  44. delta = 0
  45. end
  46. time_warp delta do
  47. t = current_time
  48. set :tC2, t
  49. print current_time
  50. sample b, amp: c
  51. end
  52. end
  53. live_loop :synth01 do
  54. use_sched_ahead_time latency
  55. a, b, c, d, e, f = sync "/osc*/trigger/synth01"
  56. nowT = a
  57. inc = nowT - oldT3
  58. oldT3 = nowT
  59. print inc
  60. delta = (get[:tC3] - current_time) + inc #0.25
  61. print delta
  62. if(delta > 0.1 )
  63. delta = 0
  64. end
  65. if(delta < -0.1 )
  66. delta = 0
  67. end
  68. time_warp delta do
  69. t = current_time
  70. set :tC3, t
  71. print current_time
  72. synth b, note: c, cutoff: d, sustain: e, amp: f
  73. end
  74. end