Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

151 lines
3.9KB

  1. #! /usr/bin/env fth
  2. \ agn.fth -- 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: Wed Dec 15 23:30:43 CET 2004
  6. \ Changed: Sat Jul 28 00:00:24 CEST 2012
  7. \ Type do-agn
  8. \ or start the script in a shell.
  9. #t value *clm-c-version*
  10. dl-load sndlib Init_sndlib
  11. *clm-c-version* [if]
  12. dl-load sndins Init_sndins
  13. [else]
  14. require clm-ins
  15. [then]
  16. require clm
  17. require env
  18. *argc* 2 > [if]
  19. *argv* 2 array-ref
  20. [else]
  21. "agn.fsm"
  22. [then] value agn-test-file
  23. 60.0 value agn-time
  24. #t to *clm-play*
  25. #t to *clm-statistics*
  26. #t to *clm-verbose*
  27. 44100 to *clm-srate*
  28. 2 to *clm-channels*
  29. <'> jc-reverb to *clm-reverb*
  30. '( :volume 0.8 ) to *clm-reverb-data*
  31. 2 to *clm-reverb-channels*
  32. #t to *clm-delete-reverb*
  33. : rbell ( x -- r ) 100 f* '( 0 0 10 0.25 90 1 100 1 ) 1.0 envelope-interp ;
  34. : tune ( x -- r )
  35. { x }
  36. #( 1 256/243 9/8 32/27 81/64 4/3 1024/729 3/2 128/81 27/16 16/9 243/128 2 )
  37. x 12.0 fmod f>s array-ref
  38. 2.0 x 12.0 f/ floor f**
  39. f*
  40. ;
  41. #( 0 0 2 4 11 11 5 6 7 9 2 0 0 ) constant agn-mode
  42. 256 constant agn-lim
  43. #f value agn-octs
  44. #f value agn-pits
  45. #f value agn-rhys
  46. #f value agn-amps
  47. #f value agn-begs
  48. : agn-init ( -- )
  49. agn-lim make-array map!
  50. 1.0 random rbell f2* 4.0 f+ floor
  51. end-map to agn-octs
  52. agn-lim make-array map!
  53. agn-mode 1.0 random 12.0 f* floor f>s array-ref
  54. end-map to agn-pits
  55. agn-lim make-array map!
  56. 1.0 random 6.0 f* 4.0 f+
  57. end-map to agn-rhys
  58. agn-lim make-array map!
  59. 1.0 random rbell 8.0 f* 1.0 f+
  60. end-map to agn-amps
  61. agn-lim make-array map!
  62. 1.0 random 0.9 f< if 1.0 random f2* 4.0 f+ else 4.0 random 6.0 f* then
  63. end-map to agn-begs
  64. ;
  65. : agn ( fname -- )
  66. ( fname ) io-open-write { io }
  67. io "\\ from agn.cl (see clm-2/clm-example.clm and clm-2/bess5.cl)\n" io-write
  68. io "\\\n" io-write
  69. io "%s\n" '( make-default-comment ) io-write-format
  70. #( '( 0 0 40 0.1 60 0.2 75 0.4 82 1 90 1 100 0 )
  71. '( 0 0 60 0.1 80 0.2 90 0.4 95 1 100 0 )
  72. '( 0 0 10 1 16 0 32 0.1 50 1 56 0 60 0 90 0.3 100 0 )
  73. '( 0 0 30 1 56 0 60 0 90 0.3 100 0 )
  74. '( 0 0 50 1 80 0.3 100 0 )
  75. '( 0 0 40 0.1 60 0.2 75 0.4 82 1 90 1 100 0 )
  76. '( 0 0 40 0.1 60 0.2 75 0.4 82 1 90 1 100 0 )
  77. '( 0 0 10 1 32 0.1 50 1 90 0.3 100 0 )
  78. '( 0 0 60 0.1 80 0.3 95 1 100 0 )
  79. '( 0 0 80 0.1 90 1 100 0 ) ) { wins }
  80. agn-init
  81. 4 1 do
  82. 0 4 0 { cellbeg cellsiz cellctr }
  83. 1 i s>f i 1- s>f 0.2 { whichway base mi mytempo }
  84. 0.0 0.0 { nextbeg beg }
  85. begin
  86. beg agn-time f< cellctr agn-lim < and
  87. while
  88. beg nextbeg f+ to beg
  89. 0.25 mytempo 1.0 random 0.2 f* 0.9 f+ f* agn-rhys
  90. cellctr array-ref f* fmax to nextbeg
  91. 16.352 2.0 mi f** f/ agn-pits cellctr array-ref tune f*
  92. 2.0 agn-octs cellctr array-ref f** f* { freq }
  93. freq 100.0 f< if nextbeg f2* else nextbeg then { dur }
  94. 0.003 agn-amps cellctr array-ref 60.0 base f* 1/f f* fmax { amp }
  95. 1.0 random 2.0 f* base f* { ind }
  96. base 0.1 f* { revamt }
  97. 10.0 beg beg floor f- f* floor f>s { winnum }
  98. 0.00001 freq 2.0 flogn 4.0 f- 4.0 f** f* { ranamt }
  99. io
  100. "
  101. %f %f %f %f :fm-index %f
  102. :amp-env %S
  103. :reverb-amount %f :noise-amount %f fm-violin"
  104. '( beg dur freq amp ind wins winnum array-ref revamt ranamt )
  105. io-write-format
  106. cellctr 1+ to cellctr
  107. cellctr cellsiz cellbeg + > if
  108. cellbeg 1+ to cellbeg
  109. 1.0 random 0.5 f> if cellsiz whichway + to cellsiz then
  110. cellsiz 16 > 1.0 random 0.99 f> and if
  111. -2 to whichway
  112. else
  113. cellsiz 12 > 1.0 random 0.999 f> and if
  114. -1 to whichway
  115. else
  116. cellsiz 4 < if
  117. 1 to whichway
  118. then
  119. then
  120. then
  121. cellbeg 3 + to cellbeg
  122. cellbeg to cellctr
  123. then
  124. repeat
  125. loop
  126. io "\n\n\\ %s ends here\n" '( agn-test-file ) io-write-format
  127. io io-close
  128. ;
  129. : do-agn ( -- )
  130. agn-test-file undef file-basename ".snd" $+ { sndfile }
  131. "\\ writing \"%s\"\n" '( agn-test-file ) fth-print
  132. agn-test-file agn
  133. :output sndfile agn-test-file clm-load
  134. ;
  135. 'snd provided? [unless] do-agn [then]
  136. \ agn.fth ends here