No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. -*- outline -*-
  2. * Introduction
  3. The C/XEN library `libsndins.so' provides the instrument FM-VIOLIN and
  4. the reverberators JC-REVERB, NREV, and FREEVERB to use them in longer
  5. notelists in Snd/Scheme, Snd/Ruby, or Snd/Forth. They are not so fast
  6. as Lisp's FFI versions, at least not on my machine, but they run much
  7. faster than the Scheme, Ruby, or Forth variants. In addition I have
  8. added the FCOMB example from sndscm.html which is used in freeverb.
  9. The library is based on Bill Schottstaedt's `xen' and `sndlib'
  10. libraries and the Snd editor itself. Thank you for these great music
  11. programs and libraries!
  12. * XEN-Instruments
  13. The following generator and instruments are accessible from Scheme,
  14. Ruby and Forth.
  15. ** make-fcomb, fcomb?, and fcomb
  16. These are the examples from sndscm.html.
  17. *** (make-fcomb (:scaler 1.0) (:size 1) (:a0 0.0) (:a1 0.0))
  18. *** make_fcomb(:scaler, 1.0, :size, 1, :a0, 0.0, :a1, 0.0)
  19. *** make-fcomb ( :scaler 1.0 :size 1 :a0 0.0 :a1 0.0 -- gen )
  20. Return a new fcomb generator.
  21. *** (fcomb? gen)
  22. *** fcomb?(gen)
  23. *** fcomb? ( gen -- f )
  24. Test if GEN is an fcomb generator.
  25. *** (fcomb gen (input 0.0))
  26. *** fcomb(gen[, input=0.0])
  27. *** fcomb ( gen input=0.0 -- result )
  28. Return the next value of the fcomb generator GEN.
  29. *** (mus-describe gen)
  30. *** gen.to_s
  31. *** object->string ( gen -- str )
  32. Show the inspect string of the fcomb GEN.
  33. *** (mus-length gen)
  34. *** gen.length
  35. *** mus-length ( gen -- len )
  36. Show length of delay line.
  37. *** (mus-scaler gen) (set! (mus-scaler gen) scl)
  38. *** gen.scaler gen.scaler = scl
  39. *** mus-scaler ( gen -- scl ) set-mus-scaler ( gen scl -- scl )
  40. Show the scaler value, settable.
  41. *** (mus-xcoeff gen index) (set! (mus-xcoeff gen index) val)
  42. *** gen.xcoeff(index) gen.xcoeff = [index, val]
  43. *** mus-xcoeff ( gen index -- val ) set-mus-xcoeff ( gen index val -- val )
  44. Show the a0/a1 values, settable (index == 0: a0, index == 1: a1)
  45. ** fm-violin
  46. Keyword options for fm-violin (v.ins, v.scm, examp.rb, clm-ins.fs).
  47. *** :startime 0.0
  48. *** :duration 1.0
  49. *** :frequency 440.0
  50. *** :amplitude 0.5
  51. *** :fm-index 1.0
  52. *** :amp-env '( 0 0 25 1 75 1 100 0 )
  53. *** :periodic-vibrato-rate 5.0
  54. *** :periodic-vibrato-amplitude 0.0025
  55. *** :random-vibrato-rate 16.0
  56. *** :random-vibrato-amplitude 0.005
  57. *** :noise-freq 1000.0
  58. *** :noise-amount 0.0
  59. *** :ind-noise-freq 10.0
  60. *** :ind-noise-amount 0.0
  61. *** :amp-noise-freq 20.0
  62. *** :amp-noise-amount 0.0
  63. *** :gliss-env '( 0 0 100 0 )
  64. *** :glissando-amount 0.0
  65. *** :fm1-env '( 0 1 25 0.4 75 0.6 100 0 )
  66. *** :fm2-env '( 0 1 25 0.4 75 0.6 100 0 )
  67. *** :fm3-env '( 0 1 25 0.4 75 0.6 100 0 )
  68. *** :fm1-rat 1.0
  69. *** :fm2-rat 3.0
  70. *** :fm3-rat 4.0
  71. *** :fm1-index #f
  72. *** :fm2-index #f
  73. *** :fm3-index #f
  74. *** :base 1.0
  75. *** :degree 0.0
  76. *** :distance 1.0
  77. *** :reverb-amount 0.01
  78. *** :index-type 'violin ('cello or 'violin)
  79. *** :no-waveshaping #f
  80. ** jc-reverb
  81. Keyword options for jc-reverb (jcrev.ins, jcrev.scm, examp.rb,
  82. clm-ins.fs).
  83. *** :volume 1.0
  84. *** :delay1 0.013
  85. *** :delay2 0.011
  86. *** :delay3 0.015
  87. *** :delay4 0.017
  88. *** :low-pass #f
  89. *** :doubled #f
  90. *** :amp-env #f
  91. If more than one reverb channel exists, the values from them are
  92. collected together before computing the result.
  93. ** nrev
  94. Keyword options for nrev (nrev.ins, clm-ins.scm, clm-ins.rb).
  95. *** :reverb-factor 1.09
  96. *** :lp-coeff 0.7
  97. *** :lp-out-coeff 0.85
  98. *** :output-scale 1.0
  99. *** :amp-env '( 0 1 1 1 )
  100. *** :volume 1.0
  101. If more than one reverb channel exists, the values from them are
  102. collected together before computing the result.
  103. ** freeverb
  104. Keyword options for freeverb (freeverb.ins, freeverb.scm, freeverb.rb).
  105. *** :room-decay 0.5
  106. *** :damping 0.5
  107. *** :global 0.3
  108. *** :predelay 0.03
  109. *** :output-gain 1.0
  110. *** :output-mixer #f
  111. *** :scale-room-decay 0.28
  112. *** :offset-room-decay 0.7
  113. *** :combtuning '( 1116 1188 1277 1356 1422 1491 1557 1617 )
  114. *** :allpasstuning '( 556 441 341 225 )
  115. *** :scale-damping 0.4
  116. *** :stereo-spread 23.0
  117. Works with one reverb channel or the same number of reverb channels
  118. like output channels.
  119. * C-Instruments
  120. The following functions are accessible from C.
  121. ** mus_any *mus_make_fcomb(Float scaler, int size, Float a0, Float a1);
  122. ** int mus_fcomb_p(mus_any *ptr);
  123. ** Float mus_fcomb(mus_any *ptr, Float input, Float ignored);
  124. ** off_t ins_fm_violin(Float start,
  125. Float dur,
  126. Float freq,
  127. Float amp,
  128. Float fm_index,
  129. Float *amp_env,
  130. int amp_len,
  131. Float periodic_vibrato_rate,
  132. Float periodic_vibrato_amp,
  133. Float random_vibrato_rate,
  134. Float random_vibrato_amp,
  135. Float noise_freq,
  136. Float noise_amount,
  137. Float ind_noise_freq,
  138. Float ind_noise_amount,
  139. Float amp_noise_freq,
  140. Float amp_noise_amount,
  141. Float *gliss_env,
  142. int gliss_len,
  143. Float gliss_amount,
  144. Float *fm1_env,
  145. int fm1_len,
  146. Float *fm2_env,
  147. int fm2_len,
  148. Float *fm3_env,
  149. int fm3_len,
  150. Float fm1_rat,
  151. Float fm2_rat,
  152. Float fm3_rat,
  153. Float fm1_index,
  154. Float fm2_index,
  155. Float fm3_index,
  156. Float base,
  157. Float degree,
  158. Float distance,
  159. Float reverb_amount,
  160. bool index_type,
  161. bool no_waveshaping,
  162. mus_any *out,
  163. mus_any *rev,
  164. mus_interp_t mode);
  165. ** off_t ins_jc_reverb(Float start,
  166. Float dur,
  167. Float volume,
  168. bool low_pass,
  169. bool doubled,
  170. Float delay1,
  171. Float delay2,
  172. Float delay3,
  173. Float delay4,
  174. Float *amp_env,
  175. int amp_len,
  176. mus_any *out,
  177. mus_any *rev);
  178. ** off_t ins_nrev(Float start,
  179. Float dur,
  180. Float reverb_factor,
  181. Float lp_coeff,
  182. Float lp_out_coeff,
  183. Float output_scale,
  184. Float volume,
  185. Float *amp_env,
  186. int amp_len,
  187. mus_any *out,
  188. mus_any *rev);
  189. ** off_t ins_freeverb(Float start,
  190. Float dur,
  191. Float room_decay,
  192. Float damping,
  193. Float global,
  194. Float predelay,
  195. Float output_gain,
  196. Float scale_room_decay,
  197. Float offset_room_decay,
  198. Float scale_damping,
  199. Float stereo_spread,
  200. int *combtuning,
  201. int comb_len,
  202. int *allpasstuning,
  203. int all_len,
  204. mus_any *output_mixer,
  205. mus_any *out,
  206. mus_any *rev);
  207. * Prerequisite
  208. Sndins depends on a configured and compiled, but not necessary
  209. installed, libsndlib.a one directory in the hierarchy above sndins.
  210. Configuring sndlib from sndlib.tar.gz creates a Makefile in
  211. sndlib/sndins, sndlib's mus-config.h is needed as well and the
  212. compiled sndlib/libsndlib.a will be linked in
  213. sndlib/sndins/libsndins.*
  214. * Compilation
  215. Running Sndlib's configure script in sndlib path creates
  216. sndins/Makefile from sndins/Makefile.in so we can use the configured
  217. variables from Sndlib. Then one can cd to sndins and run make.
  218. Again: Sndlib must be configured before!
  219. cd sndins
  220. make
  221. * Installation
  222. ** Scheme
  223. You can install libsndlib.so and libsndins.so to ${prefix}/lib with
  224. the usual `make install' command. Again: Sndlib must be configured
  225. before!
  226. cd ${compile_sndlib_dir}
  227. make
  228. make install
  229. cd sndins
  230. make
  231. make install
  232. The library path should be in your LD_LIBRARY_PATH, e.g. if you have
  233. installed the library in the unusual path /usr/gnu/lib., you can add
  234. it by:
  235. (csh) setenv LD_LIBRARY_PATH /usr/gnu/lib:${LD_LIBRARY_PATH}
  236. (sh) LD_LIBRARY_PATH=/usr/gnu/lib:${LD_LIBRARY_PATH}; export LD_LIBRARY_PATH
  237. In Snd/Scheme one can add to the ~/.snd init file:
  238. (if (provided? 'snd)
  239. (begin
  240. (if (not (provided? 'sndlib))
  241. (let ((hsndlib (dlopen "sndlib.so")))
  242. (if (string? hsndlib)
  243. (snd-error (format #f "script needs the sndlib module: ~A" hsndlib))
  244. (dlinit hsndlib "Init_sndlib"))))
  245. (if (not (provided? 'sndins))
  246. (let ((hsndins (dlopen "sndins.so")))
  247. (if (string? hsndins)
  248. (snd-error (format #f "script needs the sndins module: ~A" hsndins))
  249. (dlinit hsndins "Init_sndins")))))
  250. (begin
  251. (if (not (provided? 'sndlib)) (load-extension "libsndlib" "Init_sndlib"))
  252. (if (not (provided? 'sndins)) (load-extension "libsndins" "Init_sndins"))))
  253. ** Ruby
  254. You can install sndlib.so and sndins.so in the ruby library path, e.g.
  255. (csh) setenv RUBYLIB ${HOME}/share/ruby/site-ruby:${HOME}/share/snd:${HOME}/lib/ruby/site-ruby
  256. (sh) RUBYLIB=${HOME}/share/ruby/site-ruby:${HOME}/share/snd:${HOME}/lib/ruby/site-ruby
  257. (sh) export RUBYLIB
  258. cd ${compile_sndlib_dir}
  259. make
  260. install -c sndlib.so ~/lib/ruby/site-ruby/
  261. cd sndins
  262. make
  263. install -c sndins.so ~/lib/ruby/site-ruby/
  264. So in Snd/Ruby one can add to the ~/.snd(_ruby) init file:
  265. require "sndlib"
  266. require "sndins"
  267. ** Forth
  268. Installing so-libs in Forth is possible with these command lines:
  269. (csh) setenv FTH_FTHPATH ${HOME}/share/fth/site-fth
  270. (csh) setenv FTH_LIBPATH ${HOME}/lib/fth
  271. (sh) FTH_FTHPATH=${HOME}/share/fth/site-fth; export FTH_FTHPATH
  272. (sh) FTH_LIBPATH=${HOME}/lib/fth; export FTH_LIBPATH
  273. cd ${compile_sndlib_dir}
  274. make
  275. fth -Qve "install sndlib.so"
  276. cd sndins
  277. make
  278. fth -Qve "install sndins.so"
  279. These lines install the libraries in ~/lib/fth, the first user
  280. writeable path.
  281. Then in Snd/Forth one can add to the ~/.snd(_forth) init file:
  282. dl-load sndlib Init_sndlib
  283. dl-load sndins Init_sndins
  284. * Samples
  285. You can load the sample files into Snd, with Ruby and Forth you can
  286. test them in a shell too. One may set with-sound variables in agn.*
  287. and fmviolin.* files.
  288. The agn.* files are translations of clm/clm-example.clm into Scheme,
  289. Ruby, and Forth as a test case.
  290. The fmviolin.* files are translations of clm/fmviolin.clm into Scheme,
  291. Ruby, and Forth as a test case.
  292. ** Scheme
  293. You can load the *.scm scripts into Snd. If you have compiled and
  294. installed the Scheme sndlib and sndins libraries, you can type
  295. (do-agn) ;; agn.scm
  296. (short-example) ;; fmviolin.scm
  297. (long-example) ;; fmviolin.scm
  298. ** Ruby
  299. If you have compiled and installed the Ruby sndlib and sndins
  300. libraries, you can type in a shell
  301. ./agn.rb [ outfile.rbm ]
  302. ./fmviolin.rb [ -s ]
  303. The default outfile is agn.rbm. A different outfile name may end
  304. in *.rbm. The option -s can be everything, its only meaning is to
  305. choose the short_example, without an option long_example is chosen.
  306. You can load these scripts into Snd too.
  307. ** Forth
  308. If you have compiled and installed the Forth sndlib and sndins
  309. libraries, you can type
  310. ./agn.fth [ outfile.fsm ]
  311. ./fmviolin.fth [ -s ]
  312. The default outfile is agn.fsm. A different outfile name should end
  313. in *.fsm. The option -s can be everything, its only meaning is to
  314. choose the short-example, without an option long-example is chosen.
  315. You can load these scripts into Snd too.
  316. * README ends here