Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 14.73 KB | None | 0 0
  1. #The Saw Theme V1.0 (Before Refactoring)
  2. #I did this over the course of the last 4 hours.
  3. #Enjoy <3
  4.  
  5. #Thank you for watching!
  6. #I Hope the rest of your night goes wonderful!
  7. #Don't let Jigsaw get you! >:)
  8.  
  9. #I wanna play a game
  10.  
  11. define :parseChord do |notes, n, s, t|
  12.   x = 0
  13.   t.times do
  14.     play notes[x], sustain: n, release: n
  15.     x = x + 1
  16.   end
  17.   sleep s
  18. end
  19.  
  20. define :parseChordVel do |notes, n, s, t,v|
  21.   x = 0
  22.   t.times do
  23.     play notes[x], sustain: n, release: n, vel: v
  24.     x = x + 1
  25.   end
  26.   sleep s
  27. end
  28.  
  29. #new Method I created today!
  30.  
  31. ###INtro Methods
  32. #####################
  33. define :intro do
  34.   in_thread do
  35.     3.times do
  36.       introRightHand true
  37.     end
  38.     introRightHand false
  39.   end
  40.   introLeftHand
  41. end
  42.  
  43. define :introLeftHand do
  44.   listOfNotes = [:gs2,:cs2]
  45.   x = 0
  46.   4.times do
  47.     parseChord listOfNotes, 8, 8, 2
  48.     x = x + 1
  49.   end
  50.   listOfNotes = [:cs3, :gs2, :cs2]
  51.   parseChord listOfNotes, 4, 2, 3
  52.   listOfNotes = [:cs3, :gs3]
  53.   parseChord listOfNotes, 4, 2, 2
  54.   2.times do
  55.     play :gs3, sustain: 4, release: 4
  56.     sleep 2
  57.   end
  58.   2.times do
  59.     listOfNotes = [:cs3, :gs2, :cs2]
  60.     parseChord listOfNotes, 4, 2, 3
  61.     listOfNotes = [:cs3,:gs3]
  62.     3.times do
  63.       parseChord listOfNotes, 4, 2, 2
  64.     end
  65.   end
  66.   listOfNotes = [:cs3, :gs2, :cs2]
  67.   parseChord listOfNotes, 4, 2, 3
  68.   listOfNotes = [:cs3,:gs3]
  69.   parseChord listOfNotes, 4, 2, 2
  70.   play :gs3, sustain: 8, release: 8
  71.   sleep 4
  72. end
  73.  
  74. define :introRightHand do |flag|
  75.   introNotes = [:cs4,:ds4,:e4]
  76.   #Sleep Counter
  77.   s = 2
  78.   2.times do
  79.     x = 0
  80.     3.times do
  81.       if (x == 2)
  82.         play introNotes[x], sustain: 1, release: 1
  83.         x = x + 1
  84.         sleep s
  85.         #Cuts Rest for next loop
  86.         s = s - 0.5
  87.       else
  88.         play introNotes[x], sustain: 0.5, release: 0.5
  89.         x = x + 1
  90.         sleep 0.5
  91.       end
  92.     end
  93.   end
  94.   introNotes = [:cs4,:cs4,:ds4,:e4]
  95.   x = 0
  96.   4.times do
  97.     if (x == 3)
  98.       play introNotes[x], sustain: 1, release: 1
  99.       x = x + 1
  100.       sleep 1
  101.     else
  102.       play introNotes[x], sustain: 0.5, release: 0.5
  103.       x = x + 1
  104.       sleep 0.5
  105.     end
  106.   end
  107.   introNotes = [:cs4,:ds4,:e4]
  108.   2.times do
  109.     x = 0
  110.     3.times do
  111.       if (x == 2)
  112.         play introNotes[x], sustain: 1, release: 1
  113.         x = x + 1
  114.         sleep 2
  115.       else
  116.         play introNotes[x], sustain: 0.5, release: 0.5
  117.         x = x + 1
  118.         sleep 0.5
  119.       end
  120.     end
  121.   end
  122.   s = 1
  123.   if (flag == true)
  124.     introNotes = [:ds4,:e4,:fs4]
  125.     x = 0
  126.     3.times do
  127.       if (x == 2)
  128.         play introNotes[x], sustain: 1, release: 1
  129.         x = x + 1
  130.         sleep s
  131.       else
  132.         play introNotes[x], sustain: 0.5, release: 0.5
  133.         x = x + 1
  134.         sleep 0.5
  135.       end
  136.     end
  137.   end
  138. end
  139.  
  140. ######
  141. # SOLO 1
  142. #####
  143. define :solo1 do
  144.   2.times do
  145.     in_thread do
  146.       solo1LH
  147.     end
  148.     solo1RH
  149.   end
  150. end
  151.  
  152. define :soloHelper do |notes, n, s, t|
  153.   x = 0
  154.   t.times do
  155.     play notes[x], sustain: n, release: n
  156.     x = x + 1
  157.     sleep 0.2
  158.     s = s - 0.2
  159.   end
  160.   sleep s
  161. end
  162.  
  163. define :solo1LH do
  164.   listOfNotes = [:gs4, :cs5, :e5]
  165.   soloHelper listOfNotes, 4, 4, 3
  166.   listOfNotes = [:fs4, :b4, :ds5]
  167.   soloHelper listOfNotes, 4, 4, 3
  168.   listOfNotes = [:e4,:gs4,:cs5]
  169.   soloHelper listOfNotes, 8, 8, 3
  170.  
  171.   listOfNotes = [:gs4, :cs5, :e5]
  172.   soloHelper listOfNotes, 4, 4, 3
  173.   listOfNotes = [:b4, :ds5, :fs5]
  174.   soloHelper listOfNotes, 4, 3.25, 3
  175.   listOfNotes = [:ds5]
  176.   soloHelper listOfNotes, 2, 0.75, 1
  177.   listOfNotes = [:e4,:gs4,:cs5]
  178.   soloHelper listOfNotes, 2, 8, 3
  179. end
  180.  
  181. define :solo1RH do
  182.   notes = [:cs3,:gs3,:e4,:gs3,:cs3,:gs3,:ds4,:gs3,:cs3,:gs3,:cs4,:gs3,:cs2,:gs3,:cs4,:gs3]
  183.   l = notes.length
  184.   x = 0
  185.   l.times do
  186.     play notes[x], sustain: 2, release: 2
  187.     x = x + 1
  188.     sleep 1
  189.   end
  190.   notes = [:cs3,:gs3,:e4,:gs3,:cs3,:gs3,:ds4,:gs3,:cs3,:gs3,:e4,:ds4,:cs1,:gs3,:cs4,:gs3]
  191.   l = notes.length
  192.   x = 0
  193.   l.times do
  194.     play notes[x], sustain: 2, release: 2
  195.     x = x + 1
  196.     sleep 1
  197.   end
  198. end
  199.  
  200. ####
  201. #Main Riff
  202. ####
  203. define :main1 do
  204.   2.times do
  205.     in_thread do
  206.       introRightHand true
  207.     end
  208.     main1LH
  209.   end
  210.   in_thread do
  211.     2.times do
  212.       main1RH
  213.     end
  214.   end
  215.   main2LH
  216.   main3LH
  217. end
  218.  
  219. define :main1LH do
  220.   in_thread do
  221.     2.times do
  222.       play :cs1, release: 8, sustain: 8
  223.       sleep 8
  224.     end
  225.   end
  226.   32.times do
  227.     play :cs2, sustain: 2, release: 2, vel: 0.125
  228.     sleep 0.5
  229.   end
  230. end
  231.  
  232. define :main2LH do
  233.   in_thread do
  234.     2.times do
  235.       play :cs2, release: 8, sustain: 8
  236.       sleep 8
  237.     end
  238.   end
  239.   32.times do
  240.     play :cs3, sustain: 2, release: 2, vel: 0.17
  241.     sleep 0.5
  242.   end
  243. end
  244.  
  245. define :main3LH do
  246.   in_thread do
  247.     16.times do
  248.       play :cs2, release: 2, sustain: 2, vel: 0.15
  249.       sleep 1
  250.     end
  251.   end
  252.   32.times do
  253.     play :cs3, sustain: 2, release: 2, vel: 0.17
  254.     sleep 0.5
  255.   end
  256. end
  257.  
  258. define :main1RH do
  259.   introNotes = [:cs5,:ds5,:e5]
  260.   #Sleep Counter
  261.   s = 2
  262.   2.times do
  263.     x = 0
  264.     3.times do
  265.       if (x == 2)
  266.         play introNotes[x], sustain: 1, release: 1
  267.         x = x + 1
  268.         sleep s
  269.         #Cuts Rest for next loop
  270.         s = s - 0.5
  271.       else
  272.         play introNotes[x], sustain: 0.5, release: 0.5
  273.         x = x + 1
  274.         sleep 0.5
  275.       end
  276.     end
  277.   end
  278.   introNotes = [:cs5,:cs5,:ds5,:e5]
  279.   x = 0
  280.   4.times do
  281.     if (x == 3)
  282.       play introNotes[x], sustain: 1, release: 1
  283.       x = x + 1
  284.       sleep 1
  285.     else
  286.       play introNotes[x], sustain: 0.5, release: 0.5
  287.       x = x + 1
  288.       sleep 0.5
  289.     end
  290.   end
  291.   introNotes = [:cs5,:ds5,:e5]
  292.   2.times do
  293.     x = 0
  294.     3.times do
  295.       if (x == 2)
  296.         play introNotes[x], sustain: 1, release: 1
  297.         x = x + 1
  298.         sleep 2
  299.       else
  300.         play introNotes[x], sustain: 0.5, release: 0.5
  301.         x = x + 1
  302.         sleep 0.5
  303.       end
  304.     end
  305.   end
  306.   s = 1
  307.   introNotes = [:ds5,:e5,:fs5]
  308.   x = 0
  309.   3.times do
  310.     if (x == 2)
  311.       play introNotes[x], sustain: 1, release: 1
  312.       x = x + 1
  313.       sleep s
  314.     else
  315.       play introNotes[x], sustain: 0.5, release: 0.5
  316.       x = x + 1
  317.       sleep 0.5
  318.     end
  319.   end
  320. end
  321.  
  322. ####
  323. #MAIN 2
  324. ###############
  325.  
  326. define :main2LH1 do
  327.   in_thread do
  328.     2.times do
  329.       8.times do
  330.         play :cs2, release: 2, sustain: 2, vel: 0.17
  331.         sleep 0.5
  332.       end
  333.       4.times do
  334.         play :e2, release: 2, sustain: 2, vel: 0.17
  335.         sleep 0.5
  336.       end
  337.       4.times do
  338.         play :fs2, release: 2, sustain: 2, vel: 0.17
  339.         sleep 0.5
  340.       end
  341.     end
  342.   end
  343.   32.times do
  344.     play :cs3, sustain: 2, release: 2, vel: 0.15
  345.     sleep 0.5
  346.   end
  347. end
  348.  
  349. define :main2LH2 do
  350.   in_thread do
  351.     8.times do
  352.       play :gs2, release: 2, sustain: 2, vel: 0.19
  353.       sleep 0.5
  354.     end
  355.     4.times do
  356.       play :a2, release: 2, sustain: 2, vel: 0.19
  357.       sleep 0.5
  358.     end
  359.     4.times do
  360.       play :as2, release: 2, sustain: 2, vel: 0.19
  361.       sleep 0.5
  362.     end
  363.   end
  364.   16.times do
  365.     play :cs3, sustain: 2, release: 2, vel: 0.17
  366.     sleep 0.5
  367.   end
  368. end
  369.  
  370. define :main2RH1 do
  371.   introNotes = [:cs4,:ds4,:e4]
  372.   #Sleep Counter
  373.   x = 0
  374.   3.times do
  375.     if (x == 2)
  376.       play introNotes[x], sustain: 1, release: 1
  377.       x = x + 1
  378.       sleep 2
  379.     else
  380.       play introNotes[x], sustain: 0.5, release: 0.5
  381.       x = x + 1
  382.       sleep 0.5
  383.     end
  384.   end
  385.   introNotes = [:e4,:fs4,:gs4]
  386.   x = 0
  387.   x = 0
  388.   3.times do
  389.     if (x == 2)
  390.       play introNotes[x], sustain: 1, release: 1
  391.       x = x + 1
  392.       sleep 2
  393.     else
  394.       play introNotes[x], sustain: 0.5, release: 0.5
  395.       x = x + 1
  396.       sleep 0.5
  397.     end
  398.   end
  399.   introNotes = [:gs4,:as4,:b4]
  400.   x = 0
  401.   x = 0
  402.   3.times do
  403.     if (x == 2)
  404.       play introNotes[x], sustain: 1, release: 1
  405.       x = x + 1
  406.       sleep 1
  407.     else
  408.       play introNotes[x], sustain: 0.5, release: 0.5
  409.       x = x + 1
  410.       sleep 0.5
  411.     end
  412.   end
  413. end
  414.  
  415. define :main2RH2 do
  416.   introNotes = [:cs4,:ds4,:e4]
  417.   #Sleep Counter
  418.   x = 0
  419.   3.times do
  420.     if (x == 2)
  421.       play introNotes[x], sustain: 1, release: 1
  422.       x = x + 1
  423.       sleep 2
  424.     else
  425.       play introNotes[x], sustain: 0.5, release: 0.5
  426.       x = x + 1
  427.       sleep 0.5
  428.     end
  429.   end
  430.   introNotes = [:e4,:fs4,:gs4]
  431.   x = 0
  432.   x = 0
  433.   3.times do
  434.     if (x == 2)
  435.       play introNotes[x], sustain: 1, release: 1
  436.       x = x + 1
  437.       sleep 1
  438.     else
  439.       play introNotes[x], sustain: 0.5, release: 0.5
  440.       x = x + 1
  441.       sleep 0.5
  442.     end
  443.   end
  444.   introNotes = [:gs4,:fs4,:gs4, :as4,:b4]
  445.   x = 0
  446.   x = 0
  447.   5.times do
  448.     if (x == 4)
  449.       play introNotes[x], sustain: 1, release: 1
  450.       x = x + 1
  451.       sleep 1
  452.     else
  453.       play introNotes[x], sustain: 0.5, release: 0.5
  454.       x = x + 1
  455.       sleep 0.5
  456.     end
  457.   end
  458. end
  459.  
  460. define :main2 do
  461.   in_thread do
  462.     2.times do
  463.       main2RH1
  464.     end
  465.     3.times do
  466.       main2RH2
  467.     end
  468.   end
  469.   2.times do
  470.     main2LH1
  471.   end
  472.   main2LH2
  473. end
  474.  
  475. #####
  476. #solo 2
  477. ####
  478. define :solo2LH1 do
  479.   listOfNotes = [:gs4, :cs5, :e5]
  480.   parseChord listOfNotes, 4, 4, 3
  481.   listOfNotes = [:fs4, :b4, :ds5]
  482.   parseChord listOfNotes, 4, 4, 3
  483.   listOfNotes = [:e4,:gs4,:cs5]
  484.   parseChord listOfNotes, 8, 8, 3
  485.  
  486.   listOfNotes = [:e4,:gs4,:cs5, :e5]
  487.   parseChord listOfNotes, 4, 4, 4
  488.   listOfNotes = [:fs4, :b4, :fs5]
  489.   parseChord listOfNotes, 4, 4, 4
  490.   listOfNotes = [:e4,:cs5, :e5]
  491.   parseChord listOfNotes, 2, 2, 3
  492.   listOfNotes = [:ds4]
  493.   parseChord listOfNotes, 2, 2, 1
  494.   listOfNotes = [:cs4]
  495.   parseChord listOfNotes, 4, 4, 1
  496. end
  497.  
  498. define :solo2LH2 do |flag|
  499.   if (flag == true)
  500.     listOfNotes = [:e6, :ds6, :cs6,:ds6,:cs6,:b5,:cs6,:cs6,:ds6]
  501.   else
  502.     listOfNotes = [:e6, :ds6, :cs6,:ds6,:cs6,:b5,:cs6,:cs7,:ds7]
  503.   end
  504.   x = 0
  505.   9.times do
  506.     if(x == 0) or (x == 3)
  507.       play listOfNotes[x], sustain: 2, release: 2
  508.       x = x + 1
  509.       sleep 2
  510.     elsif (x == 6)
  511.       play listOfNotes[x], sustain: 7, release: 7
  512.       x = x + 1
  513.       sleep 7.6
  514.     elsif (x == 7) or (x ==8)
  515.       play listOfNotes[x], sustain: 0.5, release: 0.5
  516.       x = x + 1
  517.       sleep 0.2
  518.     else
  519.       play listOfNotes[x]
  520.       x = x + 1
  521.       sleep 1
  522.     end
  523.   end
  524.   if (flag == true)
  525.     listOfNotes = [:e6, :ds6, :cs6,:ds6,:e6,:fs6]
  526.   else
  527.     listOfNotes = [:e7, :ds7, :cs7,:ds7,:e7,:fs7]
  528.   end
  529.   x = 0
  530.   6.times do
  531.     if (x == 0) or (x == 3)
  532.       play listOfNotes[x], sustain: 4, release: 4
  533.       x = x + 1
  534.       sleep 2
  535.     else
  536.       play listOfNotes[x], sustain: 2, release: 2
  537.       x = x + 1
  538.       sleep 1
  539.     end
  540.   end
  541.   if (flag == true)
  542.     listOfNotes = [:cs6,:e6,:gs6]
  543.   else
  544.     listOfNotes = [:cs7,:e7, :gs7]
  545.   end
  546.   soloHelper listOfNotes, 4, 3, 4
  547.   listOfNotes = [:e7, :gs6, :e6,:cs6,:gs5,:e5,:cs5,:ds5]
  548.   l = listOfNotes.length
  549.   x = 0
  550.   l.times do
  551.     play listOfNotes[x], sustain: 0.5, release: 0.5
  552.     x = x + 1
  553.     sleep 0.5
  554.   end
  555. end
  556.  
  557. define :solo2LH3 do
  558.   listOfNotes = [:e6, :ds6, :cs6,:ds6,:cs6,:b5,:cs6,:cs6,:ds6]
  559.   x = 0
  560.   9.times do
  561.     if(x == 0) or (x == 3)
  562.       play listOfNotes[x], sustain: 2, release: 2
  563.       x = x + 1
  564.       sleep 2
  565.     elsif (x == 6)
  566.       play listOfNotes[x], sustain: 7, release: 7
  567.       x = x + 1
  568.       sleep 7.6
  569.     elsif (x == 7) or (x ==8)
  570.       play listOfNotes[x], sustain: 0.5, release: 0.5
  571.       x = x + 1
  572.       sleep 0.2
  573.     else
  574.       play listOfNotes[x]
  575.       x = x + 1
  576.       sleep 1
  577.     end
  578.   end
  579.   listOfNotes = [:e6, :ds6, :cs6,:ds6,:e6,:fs6]
  580.   x = 0
  581.   6.times do
  582.     if (x == 0) or (x == 3)
  583.       play listOfNotes[x], sustain: 4, release: 4
  584.       x = x + 1
  585.       sleep 2
  586.     else
  587.       play listOfNotes[x], sustain: 2, release: 2
  588.       x = x + 1
  589.       sleep 1
  590.     end
  591.   end
  592.   listOfNotes = [:cs6,:e6,:gs6]
  593.   soloHelper listOfNotes, 4, 3, 4
  594.   listOfNotes = [:e7,:gs6, :e6,:cs6,:gs5,:e5,:cs5,:gs4,:e4,:cs,:gs3,:e3,:cs3]#,:ds4,:e4,:gs4]
  595.   l = listOfNotes.length
  596.   x = 0
  597.   l.times do
  598.     if(x > 9) and (x < 10)
  599.       play listOfNotes[x], sustain: 2, release: 2
  600.       x = x + 1
  601.       sleep 0.75
  602.     elsif (x > 10) and (x < l)
  603.       play listOfNotes[x], sustain: 4, release: 4
  604.       x = x + 1
  605.       sleep 1
  606.     elsif(x == l)
  607.       play listOfNotes[x], sustain: 8, release: 8
  608.       x = x + 1
  609.       sleep 2
  610.     else
  611.       play listOfNotes[x], sustain: 0.5, release: 0.5
  612.       x = x + 1
  613.       sleep 0.5
  614.     end
  615.   end
  616.   listOfNotes = [:e1,:e2,:e3]
  617.   parseChordVel listOfNotes, 8, 8, 3, 0.25
  618.  
  619. end
  620.  
  621.  
  622. define :solo2RH1 do
  623.   listOfNotes = [:e3,:gs3,:e4]
  624.   parseChord listOfNotes, 2, 1, 3
  625.   listOfNotes = [:cs4,:ds4,:e4]
  626.   x = 0
  627.   3.times do
  628.     x = x + 1
  629.     play listOfNotes[x], sustain: 2, release: 2
  630.     sleep 1
  631.   end
  632.  
  633.   listOfNotes = [:ds3,:fs3,:ds4]
  634.   parseChord listOfNotes, 2, 1, 3
  635.   listOfNotes = [:b3,:cs4,:ds4]
  636.   x = 0
  637.   3.times do
  638.     x = x + 1
  639.     play listOfNotes[x], sustain: 2, release: 2
  640.     sleep 1
  641.   end
  642.  
  643.   listOfNotes = [:cs3,:e3,:cs4]
  644.   parseChord listOfNotes, 2, 1, 3
  645.   listOfNotes = [:gs3,:b3,:cs4]
  646.   x = 0
  647.   3.times do
  648.     x = x + 1
  649.     play listOfNotes[x], sustain: 2, release: 2
  650.     sleep 1
  651.   end
  652.  
  653.   listOfNotes = [:e3,:e4]
  654.   parseChord listOfNotes, 4, 2, 2
  655.   listOfNotes = [:fs3,:fs4]
  656.   parseChord listOfNotes, 4, 2, 2
  657.   2.times do
  658.     listOfNotes = [:e2,:cs3,:e3]
  659.     parseChord listOfNotes, 4, 2, 3
  660.     listOfNotes = [:cs2,:cs3]
  661.     parseChord listOfNotes, 2, 1, 2
  662.     listOfNotes = [:b1,:b2]
  663.     parseChord listOfNotes, 2, 1, 2
  664.   end
  665.  
  666.   listOfNotes = [:cs3,:gs3,:cs4]
  667.   parseChordVel listOfNotes, 16, 8, 3, 0.215
  668. end
  669.  
  670. define :solo2RH2 do
  671.   listOfNotes = [:cs2,:cs1]
  672.   parseChord listOfNotes, 4, 4, 2
  673.   listOfNotes = [:b1,:b0]
  674.   parseChord listOfNotes, 4, 4, 2
  675.   listOfNotes = [:cs2,:cs1]
  676.   parseChord listOfNotes, 2, 2, 2
  677.   listOfNotes = [:ds2,:ds1]
  678.   parseChord listOfNotes, 2, 2, 2
  679.   listOfNotes = [:e2,:e1]
  680.   parseChord listOfNotes, 2, 2, 2
  681.   listOfNotes = [:fs2,:fs1]
  682.   parseChord listOfNotes, 2, 2, 2
  683.   listOfNotes = [:cs3,:cs2]
  684.   parseChord listOfNotes, 4, 4, 2
  685.   listOfNotes = [:b2,:b1]
  686.   parseChord listOfNotes, 2, 4, 2
  687.   listOfNotes = [:cs3,:cs2]
  688.   parseChord listOfNotes, 4, 4, 2
  689. end
  690. define :solo2 do
  691.   in_thread do
  692.     solo2RH1
  693.   end
  694.   solo2LH1
  695.   solo2LH2 true
  696.   in_thread do
  697.     solo2RH2
  698.   end
  699.   solo2LH2 false
  700. end
  701. #########################
  702. #SONG METHOD
  703. ########################
  704. with_synth :piano do
  705.   with_fx :lpf, cutoff: 95 do
  706.     with_fx :reverb, room: 0.97 do
  707.       with_bpm 135 do
  708.         intro
  709.         solo1
  710.       end
  711.       with_bpm 138 do
  712.         main1
  713.       end
  714.       with_bpm 141 do
  715.         main2
  716.         solo2
  717.       end
  718.       with_bpm 144 do
  719.         main1
  720.         main2
  721.       end
  722.       with_bpm 132 do
  723.         solo2LH3
  724.       end
  725.     end
  726.   end
  727. end
  728.  
  729. #All the code will be availabe in the description in a pastebin as always.
  730. #Don't worry about following along. :p
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement