Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #!/usr/bin/env ruby
  2. # agn.rb -- Bill Schottstaedt's agn.cl
  3. # (see clm-2/clm-example.clm and clm-2/bess5.cl)
  4. # Translator/Author: Michael Scholz <mi-scholz@users.sourceforge.net>
  5. # Created: Sat May 24 20:35:03 CEST 2003
  6. # Changed: Sat Jul 28 00:37:44 CEST 2012
  7. # Type do_agn
  8. # or start the script in a shell.
  9. $clm_c_version = true
  10. require "sndlib"
  11. if $clm_c_version
  12. require "sndins"
  13. else
  14. require "v" # fm_violin_rb, jc_reverb_rb
  15. require "clm-ins" # nrev_rb
  16. class Instrument
  17. alias fm_violin fm_violin_rb
  18. alias jc_reverb jc_reverb_rb
  19. alias nrev nrev_rb
  20. end
  21. end
  22. require "clm"
  23. require "ws"
  24. require "env"
  25. $clm_play = true
  26. $clm_statistics = true
  27. $clm_verbose = true
  28. $clm_srate = 44100
  29. $clm_channels = 2
  30. $clm_reverb = :jc_reverb
  31. $clm_reverb_data = [:volume, 0.8]
  32. $clm_reverb_channels = 2
  33. $clm_delete_reverb = true
  34. class Agn
  35. include Math
  36. include Env
  37. Limit = 256
  38. Time = 60
  39. def initialize
  40. mode = [0, 0, 2, 4, 11, 11, 5, 6, 7, 0, 0, 0, 0]
  41. @octs = make_array(Limit) do |i| (4 + 2 * rbell(random(1.0))).floor end
  42. @pits = make_array(Limit) do |i| mode[(12 * random(1.0)).floor] end
  43. @rhys = make_array(Limit) do |i| (4 + 6 * random(1.0)).floor end
  44. @amps = make_array(Limit) do |i| (1 + 8 * rbell(random(1.0))).floor end
  45. end
  46. def tune(x)
  47. [1.0, 256.0 / 243, 9.0 / 8, 32.0 / 27, 81.0 / 64,
  48. 4.0 / 3, 1024.0 / 729, 3.0 / 2, 128.0 / 81, 27.0 / 16,
  49. 16.0 / 9, 243.0 / 128, 2.0].at(x % 12) * 2 ** x.divmod(12).first
  50. end
  51. def rbell(x)
  52. envelope_interp(x * 100, [0, 0, 10, 0.25, 90, 1.0, 100, 1.0])
  53. end
  54. def agn(file)
  55. File.open(file, "w") do |f|
  56. f << "# from agn.cl (see clm-2/clm-example.clm and clm-2/bess5.cl)\n"
  57. f << "#\n"
  58. f << make_default_comment() << "\n\n"
  59. wins = [[0, 0, 40, 0.1, 60, 0.2, 75, 0.4, 82, 1, 90, 1, 100, 0],
  60. [0, 0, 60, 0.1, 80, 0.2, 90, 0.4, 95, 1, 100, 0],
  61. [0, 0, 10, 1, 16, 0, 32, 0.1, 50, 1, 56, 0, 60, 0, 90, 0.3,100,0],
  62. [0, 0, 30, 1, 56, 0, 60, 0, 90, 0.3, 100, 0],
  63. [0, 0, 50, 1, 80, 0.3, 100, 0],
  64. [0, 0, 40, 0.1, 60, 0.2, 75, 0.4, 82, 1, 90, 1, 100, 0],
  65. [0, 0, 40, 0.1, 60, 0.2, 75, 0.4, 82, 1, 90, 1, 100, 0],
  66. [0, 0, 10, 1, 32, 0.1, 50, 1, 90, 0.3, 100, 0],
  67. [0, 0, 60, 0.1, 80, 0.3, 95, 1, 100, 0],
  68. [0, 0, 80, 0.1, 90, 1, 100, 0]]
  69. (1..3).each do |i|
  70. cellbeg, cellsiz, cellctr = 0, 4, 0
  71. whichway, base, mi, winnum, mytempo = 1, i, i - 1, 0, 0.2
  72. nextbeg = revamt = ranamt = beg = dur = freq = ampl = ind = 0.0
  73. while beg < Time and cellctr < Limit
  74. beg += nextbeg
  75. nextbeg = dur = [0.25,
  76. mytempo * (0.9 + 0.2 * random(1.0)) * @rhys[cellctr]].max
  77. freq = (16.352 / 2 ** mi) * tune(@pits[cellctr]) * 2 ** @octs[cellctr]
  78. dur += dur if freq < 100
  79. ampl = [0.003, @amps[cellctr] * (1.0 / (60 * base))].max
  80. ind = random(1.0) * 2 * base
  81. revamt = base * 0.1
  82. winnum = (10 * (beg - beg.floor)).floor
  83. ranamt = 0.00001 * (logn(freq, 2.0) - 4) ** 4
  84. f << format("\
  85. fm_violin(%f, %f, %f, %f, :fm_index, %f,
  86. :amp_env, %s,
  87. :reverb_amount, %f, :noise_amount, %f)\n",
  88. beg, dur, freq, ampl, ind,
  89. wins[winnum].inspect, revamt, ranamt)
  90. cellctr += 1
  91. if cellctr > (cellsiz + cellbeg)
  92. cellbeg += 1
  93. if random(1.0) > 0.5
  94. cellsiz += whichway
  95. end
  96. if cellsiz > 16 and random(1.0) > 0.99
  97. whichway = -2
  98. if cellsiz > 12 and random(1.0) > 0.999
  99. whichway = -1
  100. if cellsiz < 4
  101. whichway = 1
  102. end
  103. end
  104. end
  105. cellbeg += 3
  106. cellctr = cellbeg
  107. end
  108. end
  109. end
  110. f << "\n# " + file + " ends here\n"
  111. end
  112. file
  113. end
  114. end
  115. def do_agn(file = "agn.rbm")
  116. sndfile = File.basename(file, ".*") + ".snd"
  117. message("Writing %s", file.inspect)
  118. Agn.new.agn(file)
  119. clm_load(file, :clm, true, :output, sndfile)
  120. end
  121. unless provided?(:snd)
  122. do_agn((ARGV[0] or "agn.rbm"))
  123. end
  124. # agn.rb ends here