選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326
  1. \ clm-ins.fs -- clm-ins.scm|rb -> clm-ins.fs -*- snd-forth -*-
  2. \ Translator/Author: Michael Scholz <mi-scholz@users.sourceforge.net>
  3. \ Created: Fri Feb 03 10:36:51 CET 2006
  4. \ Changed: Thu Jun 25 19:41:26 CEST 2009
  5. \ Commentary:
  6. \
  7. \ jc-reverb ( keyword-args -- )
  8. \ violin ( start dur freq amp keyword-args -- )
  9. \ fm-violin ( start dur freq amp keyword-args -- )
  10. \
  11. \ clm-ins.scm|rb instruments
  12. \
  13. \ pluck ( start dur freq amp :optional weighting lossfact -- )
  14. \ vox ( start dur freq amp ampfun freqfun freqscl voxfun index :optional vibscl -- )
  15. \ fofins ( start dur freq amp vib f0 a0 f1 a1 f2 a2 :optional ae ve -- )
  16. \ fm-trumpet ( start dur keyword-args -- )
  17. \ pqw-vox ( start dur freq spacing-freq amp ampfun freqfun freqscl ... -- )
  18. \ stereo-flute ( start dur freq flow keyword-args -- )
  19. \ fm-bell ( start dur freq amp :optional amp-env index-env index -- )
  20. \ fm-insect ( start dur freq amp amp-env ... -- )
  21. \ fm-drum ( start dur freq amp index :optional high degr dist rev-amt -- )
  22. \ gong ( start dur freq amp -- )
  23. \ attract ( start dur amp c -- )
  24. \ pqw ( start dur sfreq cfreq amp ampfun indexfun parts -- )
  25. \ tubebell ( start dur freq amp :optional base --)
  26. \ wurley ( start dur freq amp -- )
  27. \ rhodey ( start dur freq amp :optional base -- )
  28. \ hammondoid ( start dur freq amp -- )
  29. \ metal ( start dur freq amp -- )
  30. \ drone ( start dur freq amp ampfun synth ampat ampdc rvibamt rvibfreq -- )
  31. \ canter ( start dur pitch amp ampfun ranfun skewfun ... -- )
  32. \ nrev ( keyword-args -- )
  33. \ reson ( start dur pitch amp indxfun skewfun ... -- )
  34. \ cellon ( start dur pitch0 amp ampfun betafun ... -- )
  35. \ jl-reverb ( keyword-args -- )
  36. \ gran-synth ( start dur freq grain-dur interval amp -- )
  37. \ touch-tone ( numbers keyword-args -- )
  38. \ spectra ( start dur freq amp :optional parts ampenv vibamp vibfrq degr dist rev-amt -- )
  39. \ two-tab ( start dur freq amp :optional par1 par2 aenv ienv vamp vfrq degr dist rev -- )
  40. \ lbj-piano ( start dur freq amp -- )
  41. \ resflt ( start dur keyword-args -- )
  42. \ scratch-ins ( start file src-ratio turntable -- )
  43. \ pins ( file start dur keyword-args -- )
  44. \ zc ( start dur freq amp len1 len2 feedback -- )
  45. \ zn ( start dur freq amp len1 len2 feedforward -- )
  46. \ za ( start dur freq amp len1 len2 fb ffw -- )
  47. \ clm-expsrc ( start dur in-file exp-ratio src-ratio amp :optional rev start-in-file -- )
  48. \ exp-snd ( file start dur amp :optional exp-amt ramp seglen sr hop ampenv -- )
  49. \ expfil ( start dur hopsecs rampsecs steadysecs file1 file2 -- )
  50. \ graph-eq ( file start dur keyword-args -- )
  51. \ anoi ( fname start dur :optional fftsize amp-scaler R -- )
  52. \ fullmix ( in-file :optional start dur inbeg matrix srate reverb-amount -- )
  53. \ bes-fm ( start dur freq amp ratio index -- )
  54. require clm
  55. require env
  56. \ Prevent name clash with possibly loaded sndins.so.
  57. \ sndins.so instruments can be called with fm-violin-ins etc.
  58. [defined] fm-violin [if] <'> fm-violin alias fm-violin-ins [then]
  59. [defined] jc-reverb [if] <'> jc-reverb alias jc-reverb-ins [then]
  60. [defined] nrev [if] <'> nrev alias nrev-ins [then]
  61. \ General input function for src, granulate etc.
  62. : readin-cb ( gen -- proc; dir self -- r )
  63. 1 proc-create swap ,
  64. does> ( dir self -- r )
  65. nip @ ( gen ) readin
  66. ;
  67. : reverb-dur ( rev -- dur ) mus-length samples->seconds *clm-decay-time* f+ ;
  68. \ clm/jcrev.ins
  69. instrument: jc-reverb-fs <{ :key
  70. volume 1.0
  71. delay1 0.013
  72. delay2 0.011
  73. delay3 0.015
  74. delay4 0.017
  75. low-pass #f
  76. doubled #f
  77. amp-env #f -- }>
  78. doc" The Chowning reverb.\n\
  79. 0 1 440 0.2 <'> fm-violin :reverb <'> jc-reverb with-sound\n\
  80. 0 1 440 0.2 <'> fm-violin\n\
  81. :reverb-data #( :low-pass #t ) :reverb <'> jc-reverb :channels 2 with-sound"
  82. *output* mus-channels { chans }
  83. *reverb* mus-channels { rev-chans }
  84. *reverb* reverb-dur { dur }
  85. *verbose* if get-func-name rev-chans chans reverb-info then
  86. :feedback -0.7 :feedforward 0.7 :size 1051 make-all-pass { allpass1 }
  87. :feedback -0.7 :feedforward 0.7 :size 337 make-all-pass { allpass2 }
  88. :feedback -0.7 :feedforward 0.7 :size 113 make-all-pass { allpass3 }
  89. :scaler 0.742 :size 4799 make-comb { comb1 }
  90. :scaler 0.733 :size 4999 make-comb { comb2 }
  91. :scaler 0.715 :size 5399 make-comb { comb3 }
  92. :scaler 0.697 :size 5801 make-comb { comb4 }
  93. chans 1 > { chan2 }
  94. chans 4 = { chan4 }
  95. :size delay1 seconds->samples make-delay { outdel1 }
  96. chan2 if :size delay2 seconds->samples make-delay else #f then { outdel2 }
  97. doubled chan4 || if :size delay3 seconds->samples make-delay else #f then { outdel3 }
  98. chan4 doubled chan2 && || if :size delay4 seconds->samples make-delay else #f then { outdel4 }
  99. amp-env if :envelope amp-env :scaler volume :duration dur make-env else #f then { env-a }
  100. doubled chan4 && if $" jc-reverb is not set up for doubled reverb in quad" _ error then
  101. 0.0 0.0 { comb-sum comb-sum-1 }
  102. 0.0 dur run
  103. 0.0 rev-chans 0 ?do j i *reverb* in-any f+ loop { in-val }
  104. allpass3 allpass2 allpass1 in-val 0.0 all-pass 0.0 all-pass 0.0 all-pass { allpass-sum }
  105. comb-sum-1 { comb-sum-2 }
  106. comb-sum to comb-sum-1
  107. comb1 allpass-sum 0.0 comb
  108. comb2 allpass-sum 0.0 comb f+
  109. comb3 allpass-sum 0.0 comb f+
  110. comb4 allpass-sum 0.0 comb f+ to comb-sum
  111. low-pass if
  112. comb-sum comb-sum-2 f+ 0.25 f* comb-sum-1 f2/ f+
  113. else
  114. comb-sum
  115. then { all-sums }
  116. outdel1 all-sums 0.0 delay { del-a }
  117. doubled if outdel3 all-sums 0.0 delay del-a f+ to del-a then
  118. env-a ?dup-if env to volume then
  119. i del-a volume f* *output* outa drop
  120. chan2 if
  121. outdel2 all-sums 0.0 delay { del-b }
  122. doubled if outdel4 all-sums 0.0 delay del-b f+ to del-b then
  123. i del-b volume f* *output* outb drop
  124. then
  125. chan4 if
  126. i outdel3 all-sums 0.0 delay volume f* *output* outc drop
  127. i outdel4 all-sums 0.0 delay volume f* *output* outd drop
  128. then
  129. loop
  130. ;instrument
  131. <'> jc-reverb-fs alias jc-reverb
  132. \ snd/fm.html
  133. instrument: violin <{ start dur freq amp
  134. :key
  135. fm-index 1.0
  136. amp-env #( 0 0 25 1 75 1 100 0 )
  137. index-env #( 0 1 25 0.4 75 0.6 100 0 )
  138. degree 0.0
  139. distance 1.0
  140. reverb-amount 0.01 -- }>
  141. doc" Violin example from snd/fm.html.\n\
  142. 0 3 440 0.5 :fm-index 0.5 <'> violin with-sound"
  143. freq hz->radians { frq-scl }
  144. frq-scl fm-index f* { maxdev }
  145. 5.0 freq flog f/ maxdev f* { index1 }
  146. 8.5 freq flog f- 3.0 freq 1000.0 f/ f+ f/ maxdev 3.0 f* f* { index2 }
  147. 4.0 freq fsqrt f/ maxdev f* { index3 }
  148. :frequency freq make-oscil { carrier }
  149. :frequency freq make-oscil { fmosc1 }
  150. :frequency freq 3.0 f* make-oscil { fmosc2 }
  151. :frequency freq 4.0 f* make-oscil { fmosc3 }
  152. :envelope amp-env :scaler amp :duration dur make-env { ampf }
  153. :envelope index-env :scaler index1 :duration dur make-env { indf1 }
  154. :envelope index-env :scaler index2 :duration dur make-env { indf2 }
  155. :envelope index-env :scaler index3 :duration dur make-env { indf3 }
  156. :frequency 5.0 :amplitude 0.0025 frq-scl f* make-triangle-wave { pervib }
  157. :frequency 16.0 :amplitude 0.005 frq-scl f* make-rand-interp { ranvib }
  158. start dur #{ :degree degree :distance distance :reverb-amount reverb-amount } run-instrument
  159. pervib 0.0 triangle-wave ranvib 0.0 rand-interp f+ { vib }
  160. carrier
  161. vib
  162. fmosc1 vib 0.0 oscil indf1 env f* f+
  163. fmosc2 3.0 vib f* 0.0 oscil indf2 env f* f+
  164. fmosc3 4.0 vib f* 0.0 oscil indf3 env f* f+
  165. 0.0 oscil ampf env f*
  166. end-run
  167. ;instrument
  168. : violin-test <{ :optional start 0.0 dur 1.0 -- }>
  169. start now!
  170. now@ dur 440 0.5 violin
  171. dur 0.2 f+ step
  172. ;
  173. \ === FM-Violin (clm/v.ins, snd/v.scm|rb) ===
  174. instrument: fm-violin-fs <{ start dur freq amp
  175. :key
  176. fm-index 1.0
  177. amp-env #( 0 0 25 1 75 1 100 0 )
  178. periodic-vibrato-rate 5.0
  179. periodic-vibrato-amplitude 0.0025
  180. random-vibrato-rate 16.0
  181. random-vibrato-amplitude 0.005
  182. noise-freq 1000.0
  183. noise-amount 0.0
  184. ind-noise-freq 10.0
  185. ind-noise-amount 0.0
  186. amp-noise-freq 20.0
  187. amp-noise-amount 0.0
  188. gliss-env #( 0 0 100 0 )
  189. glissando-amount 0.0
  190. fm1-env #( 0 1 25 0.4 75 0.6 100 0 )
  191. fm2-env #( 0 1 25 0.4 75 0.6 100 0 )
  192. fm3-env #( 0 1 25 0.4 75 0.6 100 0 )
  193. fm1-rat 1.0
  194. fm2-rat 3.0
  195. fm3-rat 4.0
  196. fm1-index #f
  197. fm2-index #f
  198. fm3-index #f
  199. base 1.0
  200. degree 0.0
  201. distance 1.0
  202. reverb-amount 0.01
  203. index-type 'violin -- }>
  204. doc" FM-Violin from clm/v.ins|snd/v.scm|rb.\n\
  205. 0 3 440 0.5 :fm-index 0.5 <'> fm-violin with-sound"
  206. freq fabs 1.0 f<= if
  207. $" freq = %s? reset to 440.0" _ #( freq ) string-format warning
  208. 440.0 to freq
  209. then
  210. freq hz->radians { frq-scl }
  211. fm-index f0<> { modulate }
  212. frq-scl fm-index f* { maxdev }
  213. index-type 'violin equal? { vln }
  214. freq flog { logfreq }
  215. freq fsqrt { sqrtfreq }
  216. fm1-index unless maxdev vln if 5.0 else 7.5 then logfreq f/ f* pi fmin to fm1-index then
  217. fm2-index unless
  218. maxdev 3.0 f* vln if 8.5 logfreq f- 3.0 freq 0.001 f* f+ f/ else 15.0 sqrtfreq f/ then
  219. f* pi fmin to fm2-index
  220. then
  221. fm3-index unless maxdev vln if 4.0 else 8.0 then sqrtfreq f/ f* pi fmin to fm3-index then
  222. noise-amount f0=
  223. fm1-env fm2-env equal? &&
  224. fm1-env fm3-env equal? &&
  225. fm1-rat fm1-rat floor f- f0= &&
  226. fm2-rat fm1-rat floor f- f0= &&
  227. fm2-rat fm2-rat floor f- f0= &&
  228. fm3-rat fm1-rat floor f- f0= &&
  229. fm3-rat fm3-rat floor f- f0= && { easy-case }
  230. easy-case modulate && 1.0 && fm1-index || { norm }
  231. :frequency freq make-oscil { carrier }
  232. :envelope amp-env :scaler amp :duration dur :base base make-env { ampf }
  233. #f #f #f { fmosc1 fmosc2 fmosc3 }
  234. #f #f #f { indf1 indf2 indf3 }
  235. modulate if
  236. easy-case if
  237. :frequency freq fm1-rat f*
  238. :coeffs
  239. #( fm1-rat f>s fm1-index
  240. fm2-rat fm1-rat f/ fround->s fm2-index
  241. fm3-rat fm1-rat f/ fround->s fm3-index ) 1 partials->polynomial make-polyshape
  242. else
  243. :frequency freq fm1-rat f* make-oscil
  244. then to fmosc1
  245. easy-case unless
  246. :frequency freq fm2-rat f* make-oscil to fmosc2
  247. :frequency freq fm3-rat f* make-oscil to fmosc3
  248. :envelope fm1-env :scaler norm :duration dur make-env to indf1
  249. :envelope fm2-env :scaler fm2-index :duration dur make-env to indf2
  250. :envelope fm3-env :scaler fm3-index :duration dur make-env to indf3
  251. then
  252. then
  253. :envelope gliss-env :scaler glissando-amount frq-scl f* :duration dur make-env { frqf }
  254. :frequency periodic-vibrato-rate
  255. :amplitude periodic-vibrato-amplitude frq-scl f* make-triangle-wave { pervib }
  256. :frequency random-vibrato-rate
  257. :amplitude random-vibrato-amplitude frq-scl f* make-rand-interp { ranvib }
  258. #f #f #f { fm-noi ind-noi amp-noi }
  259. noise-amount f0<> if
  260. :frequency noise-freq :amplitude noise-amount pi f* make-rand to fm-noi
  261. then
  262. ind-noise-freq f0<> ind-noise-amount f0<> && if
  263. :frequency ind-noise-freq :amplitude ind-noise-amount make-rand-interp to ind-noi
  264. then
  265. amp-noise-freq f0<> amp-noise-amount f0<> && if
  266. :frequency amp-noise-freq :amplitude amp-noise-amount make-rand-interp to amp-noi
  267. then
  268. 0.0 0.0 1.0 1.0 { vib fuzz ind-fuzz amp-fuzz }
  269. modulate if
  270. easy-case if
  271. start dur #{ :degree degree :distance distance :reverb-amount reverb-amount } run-instrument
  272. fm-noi if fm-noi 0.0 rand to fuzz then
  273. frqf env pervib 0.0 triangle-wave f+ ranvib 0.0 rand-interp f+ to vib
  274. ind-noi if ind-noi 0.0 rand-interp 1.0 f+ to ind-fuzz then
  275. amp-noi if amp-noi 0.0 rand-interp 1.0 f+ to amp-fuzz then
  276. carrier fmosc1 1.0 vib polyshape ind-fuzz f* vib f+ 0.0 oscil ampf env f* amp-fuzz f*
  277. end-run
  278. else
  279. start dur #{ :degree degree :distance distance :reverb-amount reverb-amount } run-instrument
  280. fm-noi if fm-noi 0.0 rand to fuzz then
  281. frqf env pervib 0.0 triangle-wave f+ ranvib 0.0 rand-interp f+ to vib
  282. ind-noi if ind-noi 0.0 rand-interp 1.0 f+ to ind-fuzz then
  283. amp-noi if amp-noi 0.0 rand-interp 1.0 f+ to amp-fuzz then
  284. carrier ( gen )
  285. fmosc1 fm1-rat vib f* fuzz f+ 0.0 oscil indf1 env f*
  286. fmosc2 fm2-rat vib f* fuzz f+ 0.0 oscil indf2 env f* f+
  287. fmosc3 fm3-rat vib f* fuzz f+ 0.0 oscil indf3 env f* f+ ind-fuzz f* vib f+ ( fm )
  288. 0.0 ( pm ) oscil ampf env f* amp-fuzz f*
  289. end-run
  290. then
  291. else
  292. start dur #{ :degree degree :distance distance :reverb-amount reverb-amount } run-instrument
  293. fm-noi if fm-noi 0.0 rand to fuzz then
  294. frqf env pervib 0.0 triangle-wave f+ ranvib 0.0 rand-interp f+ to vib
  295. ind-noi if ind-noi 0.0 rand-interp 1.0 f+ to ind-fuzz then
  296. amp-noi if amp-noi 0.0 rand-interp 1.0 f+ to amp-fuzz then
  297. carrier vib 0.0 oscil ampf env f* amp-fuzz f*
  298. end-run
  299. then
  300. ;
  301. <'> fm-violin-fs alias fm-violin
  302. : fm-violin-test <{ :optional start 0.0 dur 1.0 -- }>
  303. start now!
  304. now@ dur 440 0.5 fm-violin
  305. dur 0.2 f+ step
  306. ;
  307. \ === CLM-INS.(RB|SCM) ===
  308. \ (with original comments from clm-ins.scm)
  309. hide
  310. : get-optimum-c { s o p -- t c }
  311. o 1/f s o fsin f* 1.0 s f- s o fcos f* f+ fatan2 f* { pa }
  312. p pa f- f>s { tmp_int } tmp_int unless 1 to tmp_int then
  313. p pa f- tmp_int f- { pc }
  314. begin pc 0.1 f< while tmp_int 1 - to tmp_int pc 1e f+ to pc repeat
  315. tmp_int
  316. o fsin o pc f* fsin f- o o pc f* f+ fsin f/
  317. ;
  318. : tune-it { f s1 -- s c t }
  319. mus-srate f f/ { p }
  320. s1 f0= if 0.5 else s1 then { s }
  321. f hz->radians { o }
  322. s o p get-optimum-c { t1 c1 }
  323. 1.0 s f- o p get-optimum-c { t2 c2 }
  324. s 0.5 f<> c1 fabs c2 fabs f< && if 1.0 s f- c1 t1 else s c2 t2 then
  325. ;
  326. set-current
  327. \ PLUCK
  328. \
  329. \ The Karplus-Strong algorithm as extended by David Jaffe and Julius
  330. \ Smith -- see Jaffe and Smith, "Extensions of the Karplus-Strong
  331. \ Plucked-String Algorithm" CMJ vol 7 no 2 Summer 1983, reprinted in
  332. \ "The Music Machine". translated from CLM's pluck.ins
  333. instrument: pluck <{ start dur freq amp
  334. :optional
  335. weighting 0.5
  336. lossfact 0.9 -- }>
  337. doc" Implements the Jaffe-Smith plucked string physical model. \
  338. WEIGHTING is the ratio of the once-delayed to the twice-delayed samples. \
  339. It defaults to 0.5 = shortest decay. \
  340. Anything other than 0.5 = longer decay. \
  341. Must be between 0 and less than 1.0. \
  342. LOSSFACT can be used to shorten decays. \
  343. Most useful values are between 0.8 and 1.0.\n\
  344. 0 1 330 0.3 0.95 0.95 <'> pluck with-sound"
  345. freq weighting tune-it { wt0 c dlen }
  346. lossfact f0= if 1.0 else 1.0 lossfact fmin then { lf }
  347. wt0 f0= if 0.5 else 1.0 wt0 fmin then { wt }
  348. lf 1.0 wt f- f* lf wt f* make-one-zero { allp }
  349. c 1.0 make-one-zero { feedb }
  350. dlen 0.0 make-vct map 1.0 2.0 mus-random f- end-map { tab }
  351. start dur #{ :degree 90.0 random } run-instrument
  352. tab cycle-ref { val }
  353. tab i dlen mod 1.0 c f- feedb allp val one-zero one-zero f* vct-set! drop
  354. amp val f*
  355. end-run
  356. ;instrument
  357. previous
  358. : pluck-test <{ :optional start 0.0 dur 1.0 -- }>
  359. start now!
  360. now@ dur 330 0.3 0.95 0.95 pluck
  361. dur 0.2 f+ step
  362. ;
  363. \ formant center frequencies for a male speaker (vox and pqw-vox)
  364. #{ :I: #( 390.0 1990.0 2550.0 )
  365. :UH: #( 520.0 1190.0 2390.0 )
  366. :U: #( 440.0 1020.0 2240.0 )
  367. :W: #( 300.0 610.0 2200.0 )
  368. :Y: #( 300.0 2200.0 3065.0 )
  369. :L: #( 300.0 1300.0 3000.0 )
  370. :D: #( 300.0 1700.0 2600.0 )
  371. :N: #( 280.0 1700.0 2600.0 )
  372. :T: #( 200.0 1700.0 2600.0 )
  373. :TH: #( 200.0 1400.0 2200.0 )
  374. :V: #( 175.0 1100.0 2400.0 )
  375. :ZH: #( 175.0 1800.0 2000.0 )
  376. :E: #( 530.0 1840.0 2480.0 )
  377. :A: #( 730.0 1090.0 2440.0 )
  378. :OO: #( 300.0 870.0 2240.0 )
  379. :LL: #( 380.0 880.0 2575.0 )
  380. :EE: #( 260.0 3500.0 3800.0 )
  381. :I2: #( 350.0 2300.0 3340.0 )
  382. :G: #( 250.0 1350.0 2000.0 )
  383. :NG: #( 280.0 2300.0 2750.0 )
  384. :K: #( 350.0 1350.0 2000.0 )
  385. :S: #( 200.0 1300.0 2500.0 )
  386. :THE: #( 200.0 1600.0 2200.0 )
  387. :ZZ: #( 900.0 2400.0 3800.0 )
  388. :AE: #( 660.0 1720.0 2410.0 )
  389. :OW: #( 570.0 840.0 2410.0 )
  390. :ER: #( 490.0 1350.0 1690.0 )
  391. :R: #( 420.0 1300.0 1600.0 )
  392. :LH: #( 280.0 1450.0 1600.0 )
  393. :B: #( 200.0 800.0 1750.0 )
  394. :M: #( 280.0 900.0 2200.0 )
  395. :P: #( 300.0 800.0 1750.0 )
  396. :F: #( 175.0 900.0 4400.0 )
  397. :SH: #( 200.0 1800.0 2000.0 )
  398. :Z: #( 200.0 1300.0 2500.0 )
  399. :VV: #( 565.0 1045.0 2400.0 ) } value clm-ins-formants
  400. \ MLBVOI
  401. \
  402. \ translation from MUS10 of Marc LeBrun's waveshaping voice instrument
  403. \ (using FM here) this version translated (and simplified slightly)
  404. \ from CLM's mlbvoi.ins
  405. instrument: vox <{ start dur freq amp ampfun freqfun freqscl voxfun index
  406. :optional
  407. vibscl 0.1 -- }>
  408. voxfun length { size }
  409. size make-array { f1 }
  410. size make-array { f2 }
  411. size make-array { f3 }
  412. size 1- 0 ?do
  413. clm-ins-formants voxfun i 1+ object-ref hash-ref { phon }
  414. voxfun i object-ref { n }
  415. f1 i n array-set!
  416. phon 0 array-ref f1 i 1+ rot array-set!
  417. f2 i n array-set!
  418. phon 1 array-ref f2 i 1+ rot array-set!
  419. f3 i n array-set!
  420. phon 2 array-ref f3 i 1+ rot array-set!
  421. 2 +loop
  422. :frequency 0.0 make-oscil { car-os }
  423. 6 make-array map :frequency 0.0 make-oscil end-map { ofs }
  424. :envelope ampfun :scaler amp :duration dur make-env { ampf }
  425. :envelope f1 :duration dur make-env { frmf1 }
  426. :envelope f2 :duration dur make-env { frmf2 }
  427. :envelope f3 :duration dur make-env { frmf3 }
  428. :envelope freqfun :duration dur :scaler freqscl freq f* :offset freq make-env { freqf }
  429. :frequency 6.0 :amplitude freq vibscl f* make-triangle-wave { per-vib }
  430. :frequency 20.0 :amplitude freq 0.01 f* make-rand-interp { ran-vib }
  431. 6 0.0 make-vct { freqs }
  432. 6 0.0 make-vct { amps }
  433. start dur #{ :degree 90.0 random } run-instrument
  434. freqf env per-vib 0.0 triangle-wave f+ ran-vib 0.0 rand-interp f+ { frq }
  435. frmf1 env { frm }
  436. frm frq f/ { frm0 }
  437. frm0 floor dup f>s { frm-fint frm-int }
  438. frm-int 2 mod unless
  439. freqs 0 frm-fint frq f* hz->radians vct-set! drop
  440. freqs 1 frm-fint 1.0 f+ frq f* hz->radians vct-set! drop
  441. amps 1 frm0 frm-fint f- vct-set! drop
  442. amps 0 1.0 amps 1 vct-ref f- vct-set! drop
  443. else
  444. freqs 1 frm-fint frq f* hz->radians vct-set! drop
  445. freqs 0 frm-fint 1.0 f+ frq f* hz->radians vct-set! drop
  446. amps 0 frm0 frm-fint f- vct-set! drop
  447. amps 1 1.0 amps 0 vct-ref f- vct-set! drop
  448. then
  449. frmf2 env to frm
  450. frm frq f/ to frm0
  451. frm0 floor to frm-fint
  452. frm-fint f>s to frm-int
  453. frm-int 2 mod unless
  454. freqs 2 frm-fint frq f* hz->radians vct-set! drop
  455. freqs 3 frm-fint 1.0 f+ frq f* hz->radians vct-set! drop
  456. amps 3 frm0 frm-fint f- vct-set! drop
  457. amps 2 1.0 amps 3 vct-ref f- vct-set! drop
  458. else
  459. freqs 3 frm-fint frq f* hz->radians vct-set! drop
  460. freqs 2 frm-fint 1.0 f+ frq f* hz->radians vct-set! drop
  461. amps 2 frm0 frm-fint f- vct-set! drop
  462. amps 3 1.0 amps 2 vct-ref f- vct-set! drop
  463. then
  464. frmf3 env to frm
  465. frm frq f/ to frm0
  466. frm0 floor to frm-fint
  467. frm-fint f>s to frm-int
  468. frm-int 2 mod unless
  469. freqs 4 frm-fint frq f* hz->radians vct-set! drop
  470. freqs 5 frm-fint 1.0 f+ frq f* hz->radians vct-set! drop
  471. amps 5 frm0 frm-fint f- vct-set! drop
  472. amps 4 1.0 amps 5 vct-ref f- vct-set! drop
  473. else
  474. freqs 5 frm-fint frq f* hz->radians vct-set! drop
  475. freqs 4 frm-fint 1.0 f+ frq f* hz->radians vct-set! drop
  476. amps 4 frm0 frm-fint f- vct-set! drop
  477. amps 5 1.0 amps 4 vct-ref f- vct-set! drop
  478. then
  479. car-os frq hz->radians 0.0 oscil index f* { caros }
  480. ofs 0 array-ref caros 0.2 f* freqs 0 vct-ref f+ 0.0 oscil amps 0 vct-ref f*
  481. ofs 1 array-ref caros 0.2 f* freqs 1 vct-ref f+ 0.0 oscil amps 1 vct-ref f* f+ 0.80 f*
  482. ofs 2 array-ref caros 0.5 f* freqs 2 vct-ref f+ 0.0 oscil amps 2 vct-ref f*
  483. ofs 3 array-ref caros 0.5 f* freqs 3 vct-ref f+ 0.0 oscil amps 3 vct-ref f* f+ 0.15 f* f+
  484. ofs 4 array-ref caros freqs 4 vct-ref f+ 0.0 oscil amps 4 vct-ref f*
  485. ofs 5 array-ref caros freqs 5 vct-ref f+ 0.0 oscil amps 5 vct-ref f* f+ 0.05 f* f+
  486. ampf env f*
  487. end-run
  488. ;instrument
  489. : vox-test <{ :optional start 0.0 dur 1.0 -- }>
  490. start now!
  491. #( 0 0 25 1 75 1 100 0 ) { amp-env }
  492. #( 0 0 5 0.5 10 0 100 1 ) { frq-env }
  493. #( 0 :E: 25 :AE: 35 :ER: 65 :ER: 75 :I: 100 :UH: ) { examp1 }
  494. #( 0 :I: 5 :OW: 10 :I: 50 :AE: 100 :OO: ) { examp2 }
  495. now@ dur 170 0.4 amp-env frq-env 0.1 examp1 0.05 0.1 vox
  496. dur 0.2 f+ step
  497. now@ dur 300 0.4 amp-env frq-env 0.1 examp2 0.02 0.1 vox
  498. dur 0.2 f+ step
  499. now@ 5.0 600 0.4 amp-env frq-env 0.1 examp2 0.01 0.1 vox
  500. 5.0 0.2 f+ step
  501. ;
  502. \ FOF example
  503. \
  504. \ snd/sndclm.html, section wave-train
  505. instrument: fofins <{ start dur freq amp vib f0 a0 f1 a1 f2 a2
  506. :optional
  507. ae #( 0 0 25 1 75 1 100 0 )
  508. ve #( 0 1 100 1 ) -- }>
  509. doc" produces FOF synthesis.\n\
  510. 0 1 270 0.2 0.001 730 0.6 1090 0.3 2440 0.1 <'> fofins with-sound"
  511. :envelope ae :scaler amp :duration dur make-env { ampf }
  512. :frequency 6.0 make-oscil { vibr }
  513. :envelope ve :scaler vib :duration dur make-env { vibenv }
  514. f0 hz->radians { frq0 }
  515. f1 hz->radians { frq1 }
  516. f2 hz->radians { frq2 }
  517. mus-srate 22050.0 f= if 100 else 200 then { foflen }
  518. two-pi foflen f/ { win-freq }
  519. foflen 0.0 make-vct map
  520. a0 i frq0 f* fsin f*
  521. a1 i frq1 f* fsin f* f+
  522. a2 i frq2 f* fsin f* f+ f2/
  523. 1.0 i win-freq f* fcos f- f*
  524. end-map { foftab }
  525. :frequency freq :wave foftab make-wave-train { wt0 }
  526. start dur #{ :degree 90.0 random } run-instrument
  527. ampf env wt0 vibenv env vibr 0.0 0.0 oscil f* wave-train f*
  528. end-run
  529. ;instrument
  530. : fofins-test <{ :optional start 0.0 dur 1.0 -- }>
  531. start now!
  532. now@ dur 270 0.2 0.001 730 0.6 1090 0.3 2440 0.1 fofins
  533. dur 0.2 f+ step
  534. ;
  535. \ FM TRUMPET
  536. \
  537. \ Dexter Morrill's FM-trumpet: from CMJ feb 77 p51
  538. instrument: fm-trumpet <{ start dur
  539. :key
  540. frq1 250
  541. frq2 1500
  542. amp1 0.5
  543. amp2 0.1
  544. ampatt1 0.03
  545. ampdec1 0.35
  546. ampatt2 0.03
  547. ampdec2 0.3
  548. modfrq1 250
  549. modind11 0
  550. modind12 2.66
  551. modfrq2 250
  552. modind21 0
  553. modind22 1.8
  554. rvibamp 0.007
  555. rvibfrq 125
  556. vibamp 0.007
  557. vibfrq 7
  558. vibatt 0.6
  559. vibdec 0.2
  560. frqskw 0.03
  561. frqatt 0.06
  562. ampenv1 #( 0 0 25 1 75 0.9 100 0 )
  563. ampenv2 #( 0 0 25 1 75 0.9 100 0 )
  564. indenv1 #( 0 0 25 1 75 0.9 100 0 )
  565. indenv2 #( 0 0 25 1 75 0.9 100 0 ) -- }>
  566. doc" 0 2 <'> fm-trumpet with-sound"
  567. :envelope
  568. #( 0 1 25 0.1 75 0 100 0 )
  569. 25
  570. 100 vibatt dur f/ f* 45.0 fmin
  571. 75
  572. 100 1 vibdec dur f/ f- f* 55.0 fmax stretch-envelope
  573. :scaler vibamp :duration dur make-env { per-vib-f }
  574. :frequency rvibfrq :amplitude rvibamp make-rand-interp { ran-vib }
  575. :frequency vibfrq make-oscil { per-vib }
  576. 75 100 1 0.01 dur f/ f- f* fmax { dec-01 }
  577. :envelope
  578. #( 0 0 25 1 75 1 100 0 )
  579. 25 25 100 frqatt dur f/ f* fmin
  580. 75 dec-01 stretch-envelope
  581. :scaler frqskw :duration dur make-env { frq-f }
  582. 25 100 ampatt1 dur f/ f* fmin { ampattpt1 }
  583. 75 100 1 ampdec1 dur f/ f- f* fmax { ampdecpt1 }
  584. 25 100 ampatt2 dur f/ f* fmin { ampattpt2 }
  585. 75 100 1 ampdec2 dur f/ f- f* fmax { ampdecpt2 }
  586. :envelope indenv1 25 ampattpt1 75 dec-01 stretch-envelope
  587. :scaler modfrq1 modind12 modind11 f- f* :duration dur make-env { mod1-f }
  588. :frequency 0.0 make-oscil { mod1 }
  589. :frequency 0.0 make-oscil { car1 }
  590. :envelope ampenv1 25 ampattpt1 75 ampdecpt1 stretch-envelope
  591. :scaler amp1 :duration dur make-env { car1-f }
  592. :envelope indenv2 25 ampattpt2 75 dec-01 stretch-envelope
  593. :scaler modfrq2 modind22 modind21 f- f* :duration dur make-env { mod2-f }
  594. :frequency 0.0 make-oscil { mod2 }
  595. :frequency 0.0 make-oscil { car2 }
  596. :envelope ampenv2 25 ampattpt2 75 ampdecpt2 stretch-envelope
  597. :scaler amp2 :duration dur make-env { car2-f }
  598. start dur #{ :degree 90.0 random } run-instrument
  599. ran-vib 0.0 rand-interp 1.0 f+
  600. 1.0 per-vib-f env per-vib 0.0 0.0 oscil f* f+ f*
  601. 1.0 frq-f env f+ f* hz->radians { frq-change }
  602. car1-f env
  603. car1 mod1 modfrq1 frq-change f* 0.0 oscil mod1-f env f* frq1 f+ frq-change f* 0.0 oscil f*
  604. car2-f env
  605. car2 mod2 modfrq2 frq-change f* 0.0 oscil mod2-f env f* frq2 f+ frq-change f* 0.0 oscil f* f+
  606. end-run
  607. ;instrument
  608. : fm-trumpet-test <{ :optional start 0.0 dur 1.0 -- }>
  609. start now!
  610. now@ dur fm-trumpet
  611. dur 0.2 f+ step
  612. ;
  613. struct
  614. cell% field sin-evens
  615. cell% field cos-evens
  616. cell% field sin-odds
  617. cell% field cos-odds
  618. cell% field frmfs
  619. cell% field sin-coeffs
  620. cell% field cos-coeffs
  621. cell% field amps
  622. end-struct pqw-vox%
  623. \ PQWVOX
  624. \
  625. \ translation of CLM pqwvox.ins (itself translated from MUS10 of MLB's
  626. \ waveshaping voice instrument (using phase quadrature waveshaping))
  627. instrument: pqw-vox <{ start dur
  628. freq spacing-freq
  629. amp ampfun
  630. freqfun freqscl
  631. phonemes
  632. formant-amps formant-shapes -- }>
  633. :frequency 0.0 make-oscil { car-sin }
  634. :frequency 0.0 :initial-phase half-pi make-oscil { car-cos }
  635. :envelope ampfun :scaler amp :duration dur make-env { ampf }
  636. :envelope freqfun :scaler freqscl freq f* :duration dur :offset freq make-env { freqf }
  637. :frequency 6.0 :amplitude freq 0.1 f* make-triangle-wave { per-vib }
  638. :frequency 20.0 :amplitude freq 0.05 f* make-rand-interp { ran-vib }
  639. phonemes length { plen }
  640. plen make-array { phone1 }
  641. plen make-array { phone2 }
  642. plen make-array { phone3 }
  643. plen 1- 0 ?do
  644. phonemes i object-ref { ph }
  645. phone1 i ph array-set!
  646. phone2 i ph array-set!
  647. phone3 i ph array-set!
  648. clm-ins-formants phonemes i 1+ object-ref hash-ref { ary }
  649. phone1 i 1+ ary 0 object-ref array-set!
  650. phone2 i 1+ ary 1 object-ref array-set!
  651. phone3 i 1+ ary 2 object-ref array-set!
  652. 2 +loop
  653. phone1 phone2 phone3 3 >array { phones }
  654. nil { pv }
  655. formant-amps map
  656. pqw-vox% %alloc to pv
  657. :frequency 0.0 make-oscil pv sin-evens !
  658. :frequency 0.0 make-oscil pv sin-odds !
  659. :frequency 0.0 :initial-phase half-pi make-oscil pv cos-evens !
  660. :frequency 0.0 :initial-phase half-pi make-oscil pv cos-odds !
  661. formant-shapes i object-ref normalize-partials { shape }
  662. shape mus-chebyshev-first-kind partials->polynomial pv cos-coeffs !
  663. shape mus-chebyshev-second-kind partials->polynomial pv sin-coeffs !
  664. :envelope phones i array-ref :duration dur make-env pv frmfs !
  665. formant-amps i object-ref pv amps !
  666. pv
  667. end-map { values }
  668. 4 0.0 make-vct { vals }
  669. spacing-freq freq f/ { frq-ratio }
  670. start dur #{ :degree 90.0 random } run-instrument
  671. freqf env per-vib 0.0 triangle-wave f+ ran-vib 0.0 rand-interp f+ { frq }
  672. frq frq-ratio f* hz->radians { frqscl }
  673. car-sin frqscl 0.0 oscil { carsin }
  674. car-cos frqscl 0.0 oscil { carcos }
  675. 0.0 ( sum )
  676. values each to pv
  677. pv frmfs @ env frq f/ { frm0 }
  678. frm0 floor { frm-fint }
  679. frm-fint f>s 2 mod unless
  680. vals 0 frm-fint frq f* hz->radians vct-set! drop ( even-freq )
  681. vals 1 frm-fint 1e f+ frq f* hz->radians vct-set! drop ( odd-freq )
  682. vals 3 frm0 frm-fint f- vct-set! drop ( odd-amp )
  683. vals 2 1.0 vals 3 vct-ref f- vct-set! drop ( even-amp )
  684. else
  685. vals 1 frm-fint frq f* hz->radians vct-set! drop ( odd-freq )
  686. vals 0 frm-fint 1e f+ frq f* hz->radians vct-set! drop ( even-freq )
  687. vals 2 frm0 frm-fint f- vct-set! drop ( even-amp )
  688. vals 3 1.0 vals 2 vct-ref f- vct-set! drop ( odd-amp )
  689. then
  690. pv cos-coeffs @ carcos polynomial { fax }
  691. pv sin-coeffs @ carcos polynomial carsin f* { yfax }
  692. pv sin-evens @ vals 0 vct-ref 0.0 oscil yfax f*
  693. pv cos-evens @ vals 0 vct-ref 0.0 oscil fax f* f- vals 2 vct-ref f*
  694. pv sin-odds @ vals 1 vct-ref 0.0 oscil yfax f*
  695. pv cos-odds @ vals 1 vct-ref 0.0 oscil fax f* f- vals 3 vct-ref f* f+ pv amps @ f* f+
  696. end-each
  697. ampf env f*
  698. end-run
  699. values each ( pv ) free throw end-each
  700. ;instrument
  701. : pqw-vox-test <{ :optional start 0.0 dur 1.0 -- }>
  702. start now!
  703. #( 0 0 50 1 100 0 ) { ampfun }
  704. #( 0 0 100 0 ) { freqfun }
  705. #( 0 0 100 1 ) { freqramp }
  706. #( #( 1 1 2 0.5 ) #( 1 0.5 2 0.5 3 1 ) #( 1 1 4 0.5 ) ) { shapes1 }
  707. #( #( 1 1 2 0.5 ) #( 1 1 2 0.5 3 0.2 4 0.1 ) #( 1 1 3 0.1 4 0.5 ) ) { shapes2 }
  708. #( #( 1 1 2 0.5 ) #( 1 1 4 0.1 ) #( 1 1 2 0.1 4 0.05 ) ) { shapes3 }
  709. #( #( 1 1 2 0.5 3 0.1 4 0.01 ) #( 1 1 4 0.1 ) #( 1 1 2 0.1 4 0.05 ) ) { shapes4 }
  710. #( 0.8 0.15 0.05 ) { amps }
  711. now@ dur 300 300 0.5 ampfun freqfun 0.00 #( 0 :L: 100 :L: ) #( 0.33 0.33 0.33 ) shapes1 pqw-vox
  712. dur 0.2 f+ step
  713. now@ dur 200 200 0.5 ampfun freqramp 0.10 #( 0 :UH: 100 :ER: ) amps shapes2 pqw-vox
  714. dur 0.2 f+ step
  715. now@ dur 100 314 0.5 ampfun freqramp 0.10 #( 0 :UH: 100 :ER: ) amps shapes2 pqw-vox
  716. dur 0.2 f+ step
  717. now@ dur 200 314 0.5 ampfun freqramp 0.01 #( 0 :UH: 100 :ER: ) amps shapes3 pqw-vox
  718. dur 0.2 f+ step
  719. now@ dur 100 414 0.5 ampfun freqramp 0.01 #( 0 :OW: 50 :E: 100 :ER: ) amps shapes4 pqw-vox
  720. dur 0.2 f+ step
  721. ;
  722. \ STEREO-FLUTE
  723. instrument: stereo-flute <{ start dur freq flow
  724. :key
  725. flow-envelope #( 0 1 100 1 )
  726. decay 0.01
  727. noise 0.0356
  728. embouchure-size 0.5
  729. fbk-scl1 0.5
  730. fbk-scl2 0.55
  731. out-scl 1.0
  732. a0 0.7
  733. b1 -0.3
  734. vib-rate 5.0
  735. vib-amount 0.03
  736. ran-rate 5.0
  737. ran-amount 0.03 -- }>
  738. doc" A physical model of a flute.\n\
  739. 0 1 440 0.55 :flow-envelope #( 0 0 1 1 2 1 3 0 ) <'> stereo-flute with-sound"
  740. :envelope flow-envelope :scaler flow :duration dur decay f- make-env { flowf }
  741. :frequency vib-rate make-oscil { p-vib }
  742. :frequency ran-rate make-rand-interp { ran-vib }
  743. :frequency mus-srate f2/ :amplitude 1.0 make-rand { breath }
  744. mus-srate freq f/ fround->s { periodic-samples }
  745. embouchure-size periodic-samples f* fround->s make-delay { emb }
  746. periodic-samples make-delay { bore }
  747. a0 b1 make-one-pole { rlf }
  748. 0.0 0.0 0.0 0.0 { emb-sig delay-sig out-sig prev-out-sig }
  749. 0.0 0.0 0.0 0.0 0.0 { cur-exit cur-diff cur-flow dc-blocked prev-dc-blocked }
  750. start dur #{ :degree 90.0 random } run-instrument
  751. bore out-sig 0.0 delay to delay-sig
  752. emb cur-diff 0.0 delay to emb-sig
  753. p-vib 0.0 0.0 oscil vib-amount f*
  754. ran-vib 0.0 rand-interp ran-amount f* f+
  755. flowf env f+ to cur-flow
  756. breath 0.0 rand cur-flow f* noise f* cur-flow f+ fbk-scl1 delay-sig f* f+ to cur-diff
  757. emb-sig emb-sig emb-sig f* emb-sig f* f- to cur-exit
  758. rlf fbk-scl2 delay-sig f* cur-exit f+ one-pole to out-sig
  759. \ ;; NB the DC blocker is not in the cicuit. It is applied to the out-sig
  760. \ ;; but the result is not fed back into the system.
  761. out-sig prev-out-sig f- 0.995 prev-dc-blocked f* f+ to dc-blocked
  762. out-sig to prev-out-sig
  763. dc-blocked to prev-dc-blocked
  764. out-scl dc-blocked f*
  765. end-run
  766. ;instrument
  767. : flute-test <{ :optional start 0.0 dur 1.0 -- }>
  768. start now!
  769. now@ dur 440 0.55 :flow-envelope #( 0 0 1 1 2 1 3 0 ) stereo-flute
  770. dur 0.2 f+ step
  771. ;
  772. \ FM-BELL
  773. instrument: fm-bell <{ start dur freq amp
  774. :optional
  775. amp-env #( 0 0 0.1 1 10 0.6 25 0.3 50 0.15 90 0.1 100 0 )
  776. index-env #( 0 1 2 1.1 25 0.75 75 0.5 100 0.2 )
  777. index 1.0 -- }>
  778. freq 32.0 f* hz->radians { fm-ind1 }
  779. 8.0 freq 50.0 f/ f- 4.0 f* hz->radians { fm-ind2 }
  780. 1.4 freq 250.0 f/ f- 0.705 f* fm-ind2 f* { fm-ind3 }
  781. 20.0 freq 20.0 f/ f- 32.0 f* hz->radians { fm-ind4 }
  782. :frequency freq f2* make-oscil { mod1 }
  783. :frequency freq 1.41 f* make-oscil { mod2 }
  784. :frequency freq 2.82 f* make-oscil { mod3 }
  785. :frequency freq 2.4 f* make-oscil { mod4 }
  786. :frequency freq make-oscil { car1 }
  787. :frequency freq make-oscil { car2 }
  788. :frequency freq 2.4 f* make-oscil { car3 }
  789. :envelope amp-env :scaler amp :duration dur make-env { ampf }
  790. :envelope index-env :scaler index :duration dur make-env { indf }
  791. 0.0 { fmenv }
  792. start dur #{ :degree 90.0 random } run-instrument
  793. indf env to fmenv
  794. car1 fmenv fm-ind1 f* mod1 0.0 0.0 oscil f* 0.0 oscil
  795. car2 fmenv fm-ind2 mod2 0.0 0.0 oscil f*
  796. fm-ind3 mod3 0.0 0.0 oscil f* f+ f* 0.0 oscil 0.15 f* f+
  797. car3 fmenv fm-ind4 f* mod4 0.0 0.0 oscil f* 0.0 oscil 0.15 f* f+
  798. ampf env f*
  799. end-run
  800. ;instrument
  801. : fm-bell-test <{ :optional start 0.0 dur 1.0 -- }>
  802. start now!
  803. now@ dur 440.0 0.5 fm-bell
  804. dur 0.2 f+ step
  805. ;
  806. \ FM-INSECT
  807. \ clm/insect.ins
  808. instrument: fm-insect <{ start dur
  809. freq amp amp-env
  810. mod-freq mod-skew mod-freq-env
  811. mod-index mod-index-env
  812. fm-index fm-ratio -- }>
  813. :frequency freq make-oscil { carrier }
  814. :frequency mod-freq make-oscil { fm1-osc }
  815. :frequency fm-ratio freq f* make-oscil { fm2-osc }
  816. :envelope amp-env :scaler amp :duration dur make-env { ampf }
  817. :envelope mod-index-env :scaler mod-index hz->radians :duration dur make-env { indf }
  818. :envelope mod-freq-env :scaler mod-skew hz->radians :duration dur make-env { modfrqf }
  819. fm-index fm-ratio f* freq f* hz->radians { fm2-amp }
  820. start dur #{ :degree 90.0 random } run-instrument
  821. fm1-osc modfrqf env 0.0 oscil indf env f* { garble-in }
  822. fm2-osc garble-in 0.0 oscil fm2-amp f* { garble-out }
  823. carrier garble-out garble-in f+ 0.0 oscil ampf env f*
  824. end-run
  825. ;instrument
  826. : fm-insect-test <{ :optional start 0.0 dur 1.0 -- }>
  827. start now!
  828. #( 0 0 40 1 95 1 100 0.5 ) { locust }
  829. #( 0 1 25 0.7 75 0.78 100 1 ) { bug-hi }
  830. #( 0 0 25 1 75 0.7 100 0 ) { amp }
  831. now@ 0.000 f+ 1.699 4142.627 0.015 amp 60 -16.707 locust 500.866 bug-hi 0.346 0.5 fm-insect
  832. now@ 0.195 f+ 0.233 4126.284 0.030 amp 60 -12.142 locust 649.490 bug-hi 0.407 0.5 fm-insect
  833. now@ 0.217 f+ 2.057 3930.258 0.045 amp 60 -3.011 locust 562.087 bug-hi 0.591 0.5 fm-insect
  834. now@ 2.100 f+ 1.500 900.627 0.060 amp 40 -16.707 locust 300.866 bug-hi 0.346 0.5 fm-insect
  835. now@ 3.000 f+ 1.500 900.627 0.060 amp 40 -16.707 locust 300.866 bug-hi 0.046 0.5 fm-insect
  836. now@ 3.450 f+ 1.500 900.627 0.090 amp 40 -16.707 locust 300.866 bug-hi 0.006 0.5 fm-insect
  837. now@ 3.950 f+ 1.500 900.627 0.120 amp 40 -10.707 locust 300.866 bug-hi 0.346 0.5 fm-insect
  838. now@ 4.300 f+ 1.500 900.627 0.090 amp 40 -20.707 locust 300.866 bug-hi 0.246 0.5 fm-insect
  839. 6.0 step
  840. ;
  841. \ FM-DRUM
  842. \
  843. \ Jan Mattox's fm drum:
  844. instrument: fm-drum <{ start dur freq amp index
  845. :optional
  846. high #f
  847. degr 0.0
  848. dist 1.0
  849. rev-amt 0.01 -- }>
  850. high if 3.414 8.525 else 1.414 3.515 then { casrat fmrat }
  851. :envelope #( 0 0 25 0 75 1 100 1 )
  852. :scaler high if 66.0 hz->radians else 0 then :duration dur make-env { glsf }
  853. #( 0 0 3 0.05 5 0.2 7 0.8 8 0.95 10 1.0 12 0.95 20 0.3 30 0.1 100 0 ) { ampfun }
  854. 100 high if 0.01 else 0.015 then f* dur f/ { atdrpt }
  855. :envelope ampfun 10 atdrpt 15 atdrpt 1 f+ 100 100 dur 0.2 f- dur f/ f* f- fmax stretch-envelope
  856. :scaler amp :duration dur make-env { ampf }
  857. #( 0 0 5 0.014 10 0.033 15 0.061 20 0.099
  858. 25 0.153 30 0.228 35 0.332 40 0.477 45 0.681
  859. 50 0.964 55 0.681 60 0.478 65 0.332 70 0.228
  860. 75 0.153 80 0.099 85 0.061 90 0.033 95 0.0141 100 0 ) { indxfun }
  861. 100 100 dur 0.1 f- dur f/ f* f- { indxpt }
  862. indxfun 50 atdrpt 65 indxpt stretch-envelope { divindxf }
  863. :envelope divindxf :duration dur
  864. :scaler index fmrat freq f* f* hz->radians pi fmin make-env { indxf }
  865. :envelope divindxf :duration dur
  866. :scaler index casrat freq f* f* hz->radians pi fmin make-env { mindxf }
  867. :envelope ampfun 10 atdrpt 90 atdrpt 1 f+ 100 100 dur 0.05 f- dur f/ f* f- fmax stretch-envelope
  868. :duration dur
  869. :scaler 7000 hz->radians pi fmin make-env { devf }
  870. :frequency 7000 :amplitude 1 make-rand { rn }
  871. :frequency freq make-oscil { car }
  872. :frequency freq fmrat f* make-oscil { fmosc }
  873. :frequency freq casrat f* make-oscil { cc }
  874. 0.0 { gls }
  875. start dur #{ :degree degr :distance dist :reverb-amount rev-amt } run-instrument
  876. glsf env to gls
  877. cc devf env rn 0.0 rand f* gls casrat f* f+ 0.0 oscil
  878. mindxf env f* gls fmrat f* f+ fmosc swap 0.0 oscil
  879. indxf env f* gls f+ car swap 0.0 oscil ampf env f*
  880. end-run
  881. ;instrument
  882. : fm-drum-test <{ :optional start 0.0 dur 1.0 -- }>
  883. start now!
  884. now@ dur 55 0.3 5 fm-drum
  885. dur 0.2 f+ step
  886. now@ dur 66 0.3 4 #t fm-drum
  887. dur 0.2 f+ step
  888. ;
  889. \ FM-GONG
  890. \
  891. \ Paul Weineke's gong.
  892. instrument: gong <{ start dur freq amp
  893. :key
  894. degree 0.0
  895. distance 1.0
  896. reverb-amount 0.005 -- }>
  897. 0.01 1.160 freq f* f* hz->radians { indx01 }
  898. 0.30 1.160 freq f* f* hz->radians { indx11 }
  899. 0.01 3.140 freq f* f* hz->radians { indx02 }
  900. 0.38 3.140 freq f* f* hz->radians { indx12 }
  901. 0.01 1.005 freq f* f* hz->radians { indx03 }
  902. 0.50 1.005 freq f* f* hz->radians { indx13 }
  903. 5 { atpt }
  904. 100 0.002 dur f/ f* { atdur }
  905. #( 0 0 3 1 15 0.5 27 0.25 50 0.1 100 0 ) { expf }
  906. #( 0 0 15 0.3 30 1.0 75 0.5 100 0 ) { rise }
  907. #( 0 0 75 1.0 98 1.0 100 0 ) { fmup }
  908. #( 0 0 2 1.0 100 0 ) { fmdwn }
  909. :envelope expf atpt atdur 0 0 stretch-envelope :scaler amp :duration dur make-env { ampfun }
  910. :envelope fmup :scaler indx11 indx01 f- :duration dur :offset indx01 make-env { indxfun1 }
  911. :envelope fmdwn :scaler indx12 indx02 f- :duration dur :offset indx02 make-env { indxfun2 }
  912. :envelope rise :scaler indx13 indx03 f- :duration dur :offset indx03 make-env { indxfun3 }
  913. :frequency freq make-oscil { car }
  914. :frequency freq 1.160 f* make-oscil { mod1 }
  915. :frequency freq 3.140 f* make-oscil { mod2 }
  916. :frequency freq 1.005 f* make-oscil { mod3 }
  917. start dur #{ :degree degree :distance distance :reverb-amount reverb-amount } run-instrument
  918. car
  919. mod3 0.0 0.0 oscil indxfun3 env f*
  920. mod2 0.0 0.0 oscil indxfun2 env f* f+
  921. mod1 0.0 0.0 oscil indxfun1 env f* f+
  922. 0.0 oscil ampfun env f*
  923. end-run
  924. ;instrument
  925. : gong-test <{ :optional start 0.0 dur 1.0 -- }>
  926. start now!
  927. now@ dur 261.61 0.6 gong
  928. dur 0.2 f+ step
  929. ;
  930. \ ATTRACT
  931. \
  932. \ by James McCartney, from CMJ vol 21 no 3 p 6
  933. instrument: attract <{ start dur amp c -- }>
  934. 0.2 0.2 { a b }
  935. 0.04 { dt }
  936. amp f2/ c f/ { scale }
  937. -1.0 { x }
  938. 0.0 0.0 0.0 { x1 y z }
  939. start dur #{ :degree 90.0 random } run-instrument
  940. x y z f+ dt f* f- to x1
  941. a y f* x f+ dt f* +to y
  942. x z f* b f+ c z f* f- dt f* +to z
  943. x1 to x
  944. scale x f*
  945. end-run
  946. ;instrument
  947. : attract-test <{ :optional start 0.0 dur 1.0 -- }>
  948. start now!
  949. now@ dur 0.5 2.0 attract
  950. dur 0.2 f+ step
  951. ;
  952. \ PQW
  953. \
  954. \ phase-quadrature waveshaping used to create asymmetric (i.e. single
  955. \ side-band) spectra. The basic idea here is a variant of sin x sin y
  956. \ - cos x cos y = cos (x + y)
  957. \
  958. \ clm/pqw.ins
  959. instrument: pqw <{ start dur sfreq cfreq amp ampfun indexfun parts
  960. :key
  961. degree 0.0
  962. distance 1.0
  963. reverb-amount 0.005 -- }>
  964. parts normalize-partials { nparts }
  965. :frequency sfreq :initial-phase half-pi make-oscil { sp-cos }
  966. :frequency sfreq make-oscil { sp-sin }
  967. :frequency cfreq :initial-phase half-pi make-oscil { c-cos }
  968. :frequency cfreq make-oscil { c-sin }
  969. nparts mus-chebyshev-second-kind partials->polynomial { sin-coeffs }
  970. nparts mus-chebyshev-first-kind partials->polynomial { cos-coeffs }
  971. :envelope ampfun :scaler amp :duration dur make-env { amp-env }
  972. :envelope indexfun :duration dur make-env { ind-env }
  973. 0.0 0.0 0.0 0.0 { vib ax fax yfax }
  974. cfreq sfreq f/ { r }
  975. :frequency 5.0 :amplitude 0.005 sfreq f* hz->radians make-triangle-wave { tr }
  976. :frequency 12.0 :amplitude 0.005 sfreq f* hz->radians make-rand-interp { rn }
  977. start dur #{ :degree degree :distance distance :reverb-amount reverb-amount } run-instrument
  978. tr 0.0 triangle-wave rn 0.0 rand-interp f+ to vib
  979. 1.0 ind-env env fmin sp-cos vib 0.0 oscil f* to ax
  980. cos-coeffs ax polynomial to fax
  981. sp-sin vib 0.0 oscil sin-coeffs ax polynomial f* to yfax
  982. c-sin vib r f* 0.0 oscil yfax f*
  983. c-cos vib r f* 0.0 oscil fax f* f- amp-env env f*
  984. end-run
  985. ;instrument
  986. : pqw-test <{ :optional start 0.0 dur 1.0 -- }>
  987. start now!
  988. now@ dur 200 1000 0.2 #( 0 0 25 1 100 0 ) #( 0 1 100 0 ) #( 2 0.1 3 0.3 6 0.5 ) pqw
  989. dur 0.2 f+ step
  990. ;
  991. \ taken from Perry Cook's stkv1.tar.Z (Synthesis Toolkit), but I was
  992. \ in a bit of a hurry and may not have made slavishly accurate
  993. \ translations. Please let me (bil@ccrma.stanford.edu) know of any
  994. \ serious (non-envelope) errors.
  995. \
  996. \ from Perry Cook's TubeBell.cpp
  997. instrument: tubebell <{ start dur freq amp :optional base 32.0 -- }>
  998. :frequency freq 0.995 f* make-oscil { osc0 }
  999. :frequency freq 0.995 1.414 f* f* make-oscil { osc1 }
  1000. :frequency freq 1.005 f* make-oscil { osc2 }
  1001. :frequency freq 1.414 f* make-oscil { osc3 }
  1002. :envelope #( 0 0 0.005 1 dur 0.006 fmax 0 ) :base base :duration dur make-env { ampenv1 }
  1003. :envelope #( 0 0 0.001 1 dur 0.002 fmax 0 ) :base base f2* :duration dur make-env { ampenv2 }
  1004. :frequency 2.0 make-oscil { ampmod }
  1005. amp f2/ { g0 }
  1006. g0 0.707 f* { g1 }
  1007. start dur #{ :degree 90.0 random } run-instrument
  1008. ampmod 0.0 0.0 oscil 0.007 f* 0.993 f+
  1009. osc0 osc1 0.0 0.0 oscil 0.203 f* 0.0 oscil ampenv1 env g1 f* f*
  1010. osc2 osc3 0.0 0.0 oscil 0.144 f* 0.0 oscil ampenv2 env g0 f* f* f+ f*
  1011. end-run
  1012. ;instrument
  1013. : tubebell-test <{ :optional start 0.0 dur 1.0 -- }>
  1014. start now!
  1015. now@ dur 440 0.2 32 tubebell
  1016. dur 0.2 f+ step
  1017. ;
  1018. \ from Perry Cook's Wurley.cpp
  1019. instrument: wurley <{ start dur freq amp -- }>
  1020. :frequency freq make-oscil { osc0 }
  1021. :frequency freq 4 f* make-oscil { osc1 }
  1022. :frequency 510 make-oscil { osc2 }
  1023. :frequency 510 make-oscil { osc3 }
  1024. :frequency 8 make-oscil { ampmod }
  1025. :envelope #( 0 0 1 1 9 1 10 0 ) :duration dur make-env { ampenv }
  1026. :envelope #( 0 0 0.001 1 0.15 0 dur 0.16 fmax 0 ) :duration dur make-env { indenv }
  1027. :envelope #( 0 0 0.001 1 0.25 0 dur 0.26 fmax 0 ) :duration dur make-env { resenv }
  1028. amp f2/ { g0 }
  1029. g0 0.307 f* { g1 }
  1030. start dur #{ :degree 90.0 random } run-instrument
  1031. ampenv env
  1032. ampmod 0.0 0.0 oscil 0.007 f* 1.0 f+ f*
  1033. osc0 osc1 0.0 0.0 oscil 0.307 f* 0.0 oscil g0 f*
  1034. osc2 osc3 0.0 0.0 oscil indenv env f* 0.117 f* 0.0 oscil g1 f* resenv env f* f+ f*
  1035. end-run
  1036. ;instrument
  1037. : wurley-test <{ :optional start 0.0 dur 1.0 -- }>
  1038. start now!
  1039. now@ dur 440 0.2 wurley
  1040. dur 0.2 f+ step
  1041. ;
  1042. \ from Perry Cook's Rhodey.cpp
  1043. instrument: rhodey <{ start dur freq amp :optional base 0.5 -- }>
  1044. :frequency freq make-oscil { osc0 }
  1045. :frequency freq make-oscil { osc1 }
  1046. :frequency freq make-oscil { osc2 }
  1047. :frequency freq make-oscil { osc3 }
  1048. :envelope #( 0 0 0.005 1 dur 0.006 fmax 0 ) :base base :duration dur make-env { ampenv1 }
  1049. :envelope #( 0 0 0.001 1 dur 0.002 fmax 0 ) :base base 1.5 f* :duration dur make-env { ampenv2 }
  1050. :envelope #( 0 0 0.001 1 0.25 0 ) :base base 4 f* :duration dur make-env { ampenv3 }
  1051. amp f2/ { g0 }
  1052. start dur #{ :degree 90.0 random } run-instrument
  1053. osc0 osc1 0.0 0.0 oscil 0.535 f* 0.0 oscil ampenv1 env f* g0 f*
  1054. osc2 osc3 0.0 0.0 oscil 0.109 f* ampenv3 env f* 0.0 oscil ampenv2 env f* g0 f* f+
  1055. end-run
  1056. ;instrument
  1057. : rhodey-test <{ :optional start 0.0 dur 1.0 -- }>
  1058. start now!
  1059. now@ dur 440 0.2 0.5 rhodey
  1060. dur 0.2 f+ step
  1061. ;
  1062. \ from Perry Cook's BeeThree.cpp
  1063. instrument: hammondoid <{ start dur freq amp -- }>
  1064. :frequency freq 0.999 f* make-oscil { osc0 }
  1065. :frequency freq 1.997 f* make-oscil { osc1 }
  1066. :frequency freq 3.006 f* make-oscil { osc2 }
  1067. :frequency freq 6.009 f* make-oscil { osc3 }
  1068. :envelope #( 0 0 0.005 1 dur 0.006 fmax 0.008 f- 1 dur 0 ) :duration dur make-env { ampenv1 }
  1069. :envelope #( 0 0 0.005 1 dur 0.006 fmax 0 ) :duration dur make-env { ampenv2 }
  1070. amp f2/ { g0 }
  1071. start dur #{ :degree 90.0 random } run-instrument
  1072. osc0 0.0 0.0 oscil 0.1875 amp f* f*
  1073. osc1 0.0 0.0 oscil 0.1875 amp f* f* f+
  1074. osc2 0.0 0.0 oscil g0 f* f+ ampenv1 env f*
  1075. osc3 0.0 0.0 oscil 0.375 amp f* f* ampenv2 env f* f+
  1076. end-run
  1077. ;instrument
  1078. : hammondoid-test <{ :optional start 0.0 dur 1.0 -- }>
  1079. start now!
  1080. now@ dur 440 0.2 hammondoid
  1081. dur 0.2 f+ step
  1082. ;
  1083. \ from Perry Cook's HeavyMtl.cpp
  1084. instrument: metal <{ start dur freq amp -- }>
  1085. :frequency freq make-oscil { osc0 }
  1086. :frequency freq 4 f* 0.999 f* make-oscil { osc1 }
  1087. :frequency freq 3 f* 1.001 f* make-oscil { osc2 }
  1088. :frequency freq 0.5 f* 1.002 f* make-oscil { osc3 }
  1089. :envelope #( 0 0 0.001 1 dur 0.002 fmax 0.002 f- 1 dur 0 ) :duration dur make-env { ampenv0 }
  1090. :envelope #( 0 0 0.001 1 dur 0.002 fmax 0.011 f- 1 dur 0 ) :duration dur make-env { ampenv1 }
  1091. :envelope #( 0 0 0.010 1 dur 0.020 fmax 0.015 f- 1 dur 0 ) :duration dur make-env { ampenv2 }
  1092. :envelope #( 0 0 0.030 1 dur 0.040 fmax 0.040 f- 1 dur 0 ) :duration dur make-env { ampenv3 }
  1093. start dur #{ :degree 90.0 random } run-instrument
  1094. osc0
  1095. osc1 osc2 0.0 0.0 oscil ampenv2 env f* 0.574 f* 0.0 oscil ampenv1 env f* 0.202 f*
  1096. osc3 0.0 0.0 oscil ampenv3 env f* 0.116 f* f+ ( osc0 ) 0.0 oscil ampenv0 env f* 0.615 amp f* f*
  1097. end-run
  1098. ;instrument
  1099. : metal-test <{ :optional start 0.0 dur 1.0 -- }>
  1100. start now!
  1101. now@ dur 440 0.2 metal
  1102. dur 0.2 f+ step
  1103. ;
  1104. \ DRONE
  1105. instrument: drone <{ start dur freq amp ampfun synth ampat ampdc rvibamt rvibfreq -- }>
  1106. :frequency freq :wave synth #f #f partials->wave make-table-lookup { s }
  1107. :envelope ampfun 25.0 100.0 ampat dur f/ f* 75.0 100.0 100.0 ampdc dur f/ f* f- stretch-envelope
  1108. :scaler amp 0.25 f*
  1109. :duration dur make-env { ampenv }
  1110. :frequency rvibfreq :amplitude rvibamt freq f* hz->radians make-rand { ranvib }
  1111. start dur #{ :degree 90.0 random } run-instrument
  1112. s ranvib 0.0 rand fabs table-lookup ampenv env f*
  1113. end-run
  1114. ;instrument
  1115. \ CANTER
  1116. instrument: canter <{ start dur pitch amp
  1117. ampfun ranfun skewfun skewpc ranpc ranfreq indexfun atdr dcdr
  1118. ampfun1 indfun1 fmtfun1
  1119. ampfun2 indfun2 fmtfun2
  1120. ampfun3 indfun3 fmtfun3
  1121. ampfun4 indfun4 fmtfun4 -- }>
  1122. pitch 400.0 f/ flog 910.0 400.0 f/ flog f/ 100.0 f* floor { k }
  1123. 100.0 atdr dur f/ f* { atpt }
  1124. 100.0 100.0 dcdr dur f/ f* f- { dcpt }
  1125. k fmtfun1 1.0 envelope-interp { lfmt1 }
  1126. 0.5 lfmt1 pitch f/ f+ floor { harm1 }
  1127. k indfun1 1.0 envelope-interp pitch f* hz->radians { dev11 }
  1128. dev11 f2/ { dev01 }
  1129. k ampfun1 1.0 envelope-interp amp f* 1.0 harm1 lfmt1 pitch f/ f- fabs f- f* { lamp1 }
  1130. k fmtfun2 1.0 envelope-interp { lfmt2 }
  1131. 0.5 lfmt2 pitch f/ f+ floor { harm2 }
  1132. k indfun2 1.0 envelope-interp pitch f* hz->radians { dev12 }
  1133. dev12 f2/ { dev02 }
  1134. k ampfun2 1.0 envelope-interp amp f* 1.0 harm2 lfmt2 pitch f/ f- fabs f- f* { lamp2 }
  1135. k fmtfun3 1.0 envelope-interp { lfmt3 }
  1136. 0.5 lfmt3 pitch f/ f+ floor { harm3 }
  1137. k indfun3 1.0 envelope-interp pitch f* hz->radians { dev13 }
  1138. dev13 f2/ { dev03 }
  1139. k ampfun3 1.0 envelope-interp amp f* 1.0 harm3 lfmt3 pitch f/ f- fabs f- f* { lamp3 }
  1140. k fmtfun4 1.0 envelope-interp { lfmt4 }
  1141. 0.5 lfmt4 pitch f/ f+ floor { harm4 }
  1142. k indfun4 1.0 envelope-interp pitch f* hz->radians { dev14 }
  1143. dev14 f2/ { dev04 }
  1144. k ampfun4 1.0 envelope-interp amp f* 1.0 harm4 lfmt4 pitch f/ f- fabs f- f* { lamp4 }
  1145. :envelope ampfun 25.0 atpt 75.0 dcpt stretch-envelope
  1146. :duration dur make-env { tampfun }
  1147. :envelope skewfun 25.0 atpt 75.0 dcpt stretch-envelope
  1148. :duration dur
  1149. :scaler pitch skewpc f* hz->radians make-env { tskwfun }
  1150. :envelope ranfun 25.0 atpt 75.0 dcpt stretch-envelope
  1151. :duration dur make-env { tranfun }
  1152. :envelope indexfun 25.0 atpt 75.0 dcpt stretch-envelope
  1153. :duration dur make-env { tidxfun }
  1154. :frequency pitch make-oscil { modgen }
  1155. :frequency pitch harm1 f* make-oscil { gen1 }
  1156. :frequency pitch harm2 f* make-oscil { gen2 }
  1157. :frequency pitch harm3 f* make-oscil { gen3 }
  1158. :frequency pitch harm4 f* make-oscil { gen4 }
  1159. :frequency ranfreq :amplitude ranpc pitch f* hz->radians make-rand { ranvib }
  1160. start dur #{ :degree 90.0 random } run-instrument
  1161. tskwfun env tranfun env ranvib 0.0 rand f* f+ { frqval }
  1162. modgen frqval 0.0 oscil { modval }
  1163. tampfun env { ampval }
  1164. tidxfun env { indval }
  1165. gen1 dev01 indval dev11 f* f+ modval f* frqval f+ harm1 f* 0.0 oscil lamp1 ampval f* f*
  1166. gen2 dev02 indval dev12 f* f+ modval f* frqval f+ harm2 f* 0.0 oscil lamp3 ampval f* f* f+
  1167. gen3 dev03 indval dev13 f* f+ modval f* frqval f+ harm3 f* 0.0 oscil lamp3 ampval f* f* f+
  1168. gen4 dev04 indval dev14 f* f+ modval f* frqval f+ harm4 f* 0.0 oscil lamp4 ampval f* f* f+
  1169. end-run
  1170. ;instrument
  1171. : drone/canter-test <{ :optional start 0.0 dur 1.0 -- }>
  1172. start now!
  1173. #( 0 1200 100 1000 ) { fmt1 }
  1174. #( 0 2250 100 1800 ) { fmt2 }
  1175. #( 0 4500 100 4500 ) { fmt3 }
  1176. #( 0 6750 100 8100 ) { fmt4 }
  1177. #( 0 0.67 100 0.70 ) { amp1 }
  1178. #( 0 0.95 100 0.95 ) { amp2 }
  1179. #( 0 0.28 100 0.33 ) { amp3 }
  1180. #( 0 0.14 100 0.15 ) { amp4 }
  1181. #( 0 0.75 100 0.65 ) { ind1 }
  1182. #( 0 0.75 100 0.75 ) { ind2 }
  1183. #( 0 1 100 1 ) { ind3 }
  1184. #( 0 1 100 1 ) { ind4 }
  1185. #( 0 0 100 0 ) { skwf }
  1186. #( 0 0 25 1 75 1 100 0 ) { ampf }
  1187. #( 0 0.5 100 0.5 ) { ranf }
  1188. #( 0 1 100 1 ) { index }
  1189. #( 0 0 5 1 95 1 100 0 ) { solid }
  1190. #( 0.5 0.06 1 0.62 1.5 0.07 2 0.6 2.5 0.08 3 0.56 4 0.24 5 0.98 6 0.53
  1191. 7 0.16 8 0.33 9 0.62 10 0.12 12 0.14 14 0.86 16 0.12 23 0.14 24 0.17 ) { bassdr2 }
  1192. #( 0.3 0.04 1 0.81 2 0.27 3 0.2 4 0.21 5 0.18 6 0.35 7 0.03
  1193. 8 0.07 9 0.02 10 0.025 11 0.035 ) { tenordr }
  1194. now@ 4 115.0 0.125 solid bassdr2 0.1 0.5 0.01 10 drone
  1195. now@ 4 229.0 0.125 solid tenordr 0.1 0.5 0.01 11 drone
  1196. now@ 4 229.5 0.125 solid tenordr 0.1 0.5 0.01 09 drone
  1197. now@ 2.100 918.000 0.175 ampf ranf skwf 0.050 0.01 10 index 0.005 0.005
  1198. amp1 ind1 fmt1 amp2 ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4 canter
  1199. now@ 2.100 f+ 0.300 688.500 0.175 ampf ranf skwf 0.050 0.01 10 index 0.005 0.005
  1200. amp1 ind1 fmt1 amp2 ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4 canter
  1201. now@ 2.400 f+ 0.040 826.200 0.175 ampf ranf skwf 0.050 0.01 10 index 0.005 0.005
  1202. amp1 ind1 fmt1 amp2 ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4 canter
  1203. now@ 2.440 f+ 0.560 459.000 0.175 ampf ranf skwf 0.050 0.01 10 index 0.005 0.005
  1204. amp1 ind1 fmt1 amp2 ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4 canter
  1205. now@ 3.000 f+ 0.040 408.000 0.175 ampf ranf skwf 0.050 0.01 10 index 0.005 0.005
  1206. amp1 ind1 fmt1 amp2 ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4 canter
  1207. now@ 3.040 f+ 0.040 619.650 0.175 ampf ranf skwf 0.050 0.01 10 index 0.005 0.005
  1208. amp1 ind1 fmt1 amp2 ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4 canter
  1209. now@ 3.080 f+ 0.040 408.000 0.175 ampf ranf skwf 0.050 0.01 10 index 0.005 0.005
  1210. amp1 ind1 fmt1 amp2 ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4 canter
  1211. now@ 3.120 f+ 0.040 688.500 0.175 ampf ranf skwf 0.050 0.01 10 index 0.005 0.005
  1212. amp1 ind1 fmt1 amp2 ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4 canter
  1213. now@ 3.160 f+ 0.290 459.000 0.175 ampf ranf skwf 0.050 0.01 10 index 0.005 0.005
  1214. amp1 ind1 fmt1 amp2 ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4 canter
  1215. now@ 3.450 f+ 0.150 516.375 0.175 ampf ranf skwf 0.050 0.01 10 index 0.005 0.005
  1216. amp1 ind1 fmt1 amp2 ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4 canter
  1217. now@ 3.600 f+ 0.040 826.200 0.175 ampf ranf skwf 0.050 0.01 10 index 0.005 0.005
  1218. amp1 ind1 fmt1 amp2 ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4 canter
  1219. now@ 3.640 f+ 0.040 573.750 0.175 ampf ranf skwf 0.050 0.01 10 index 0.005 0.005
  1220. amp1 ind1 fmt1 amp2 ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4 canter
  1221. now@ 3.680 f+ 0.040 619.650 0.175 ampf ranf skwf 0.050 0.01 10 index 0.005 0.005
  1222. amp1 ind1 fmt1 amp2 ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4 canter
  1223. now@ 3.720 f+ 0.180 573.750 0.175 ampf ranf skwf 0.050 0.01 10 index 0.005 0.005
  1224. amp1 ind1 fmt1 amp2 ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4 canter
  1225. now@ 3.900 f+ 0.040 688.500 0.175 ampf ranf skwf 0.050 0.01 10 index 0.005 0.005
  1226. amp1 ind1 fmt1 amp2 ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4 canter
  1227. now@ 3.940 f+ 0.260 459.000 0.175 ampf ranf skwf 0.050 0.01 10 index 0.005 0.005
  1228. amp1 ind1 fmt1 amp2 ind2 fmt2 amp3 ind3 fmt3 amp4 ind4 fmt4 canter
  1229. 4.4 step
  1230. ;
  1231. \ NREV (the most popular Samson box reverb)
  1232. \
  1233. \ REVERB-FACTOR controls the length of the decay -- it should not
  1234. \ exceed (/ 1.0 .823), LP-COEFF controls the strength of the low pass
  1235. \ filter inserted in the feedback loop, VOLUME can be used to boost the
  1236. \ reverb output.
  1237. \
  1238. \ clm/nrev.ins
  1239. instrument: nrev-fs <{ :key
  1240. reverb-factor 1.09
  1241. lp-coeff 0.7
  1242. lp-out-coeff 0.85
  1243. output-scale 1.0
  1244. volume 1.0
  1245. amp-env #( 0 1 1 1 ) -- }>
  1246. doc" NREV (the most popular Samson box reverb).\n\
  1247. <'> fm-violin-test :reverb <'> nrev with-sound"
  1248. *output* mus-channels { chans }
  1249. *reverb* mus-channels { rev-chans }
  1250. *reverb* reverb-dur { dur }
  1251. *verbose* if get-func-name rev-chans chans reverb-info then
  1252. mus-srate 25641.0 f/ { sr }
  1253. #( 1433 1601 1867 2053 2251 2399 347 113 37 59 43 37 29 19 ) map
  1254. sr *key* f* f>s dup 2 mod unless 1+ then ( val )
  1255. begin ( val ) dup prime? false? while 2 + repeat ( val )
  1256. end-map { dly-len }
  1257. :scaler 0.822 reverb-factor f* :size dly-len 0 array-ref make-comb { comb0 }
  1258. :scaler 0.802 reverb-factor f* :size dly-len 1 array-ref make-comb { comb1 }
  1259. :scaler 0.773 reverb-factor f* :size dly-len 2 array-ref make-comb { comb2 }
  1260. :scaler 0.753 reverb-factor f* :size dly-len 3 array-ref make-comb { comb3 }
  1261. :scaler 0.753 reverb-factor f* :size dly-len 4 array-ref make-comb { comb4 }
  1262. :scaler 0.733 reverb-factor f* :size dly-len 5 array-ref make-comb { comb5 }
  1263. :feedback -0.7 :feedforward 0.7 :size dly-len 6 array-ref make-all-pass { allp0 }
  1264. :feedback -0.7 :feedforward 0.7 :size dly-len 7 array-ref make-all-pass { allp1 }
  1265. :feedback -0.7 :feedforward 0.7 :size dly-len 8 array-ref make-all-pass { allp2 }
  1266. :feedback -0.7 :feedforward 0.7 :size dly-len 9 array-ref make-all-pass { allp3 }
  1267. :feedback -0.7 :feedforward 0.7 :size dly-len 10 array-ref make-all-pass { allp4 }
  1268. :feedback -0.7 :feedforward 0.7 :size dly-len 11 array-ref make-all-pass { allp5 }
  1269. :feedback -0.7 :feedforward 0.7 :size dly-len 12 array-ref make-all-pass { allp6 }
  1270. :feedback -0.7 :feedforward 0.7 :size dly-len 13 array-ref make-all-pass { allp7 }
  1271. lp-coeff lp-coeff 1.0 f- make-one-pole { low }
  1272. lp-out-coeff lp-coeff 1.0 f- make-one-pole { low-a }
  1273. lp-out-coeff lp-coeff 1.0 f- make-one-pole { low-b }
  1274. lp-out-coeff lp-coeff 1.0 f- make-one-pole { low-c }
  1275. lp-out-coeff lp-coeff 1.0 f- make-one-pole { low-d }
  1276. :envelope amp-env :scaler output-scale :duration dur make-env { ampf }
  1277. 0.0 dur run
  1278. 0.0 ( rev ) rev-chans 0 ?do j i *reverb* in-any f+ loop volume f* ampf env f* { rev }
  1279. 0.0 ( outrev )
  1280. comb0 rev 0.0 comb f+
  1281. comb1 rev 0.0 comb f+
  1282. comb2 rev 0.0 comb f+
  1283. comb3 rev 0.0 comb f+
  1284. comb4 rev 0.0 comb f+
  1285. comb5 rev 0.0 comb f+ { outrev }
  1286. allp2 allp1 allp0 outrev 0.0 all-pass 0.0 all-pass 0.0 all-pass to outrev
  1287. allp3 low outrev one-pole 0.0 all-pass to outrev
  1288. low-a allp4 outrev 0.0 all-pass one-pole output-scale f* { sample-a }
  1289. low-b allp5 outrev 0.0 all-pass one-pole output-scale f* { sample-b }
  1290. low-c allp6 outrev 0.0 all-pass one-pole output-scale f* { sample-c }
  1291. low-d allp7 outrev 0.0 all-pass one-pole output-scale f* { sample-d }
  1292. chans 2 = if
  1293. i sample-a sample-d f+ f2/ *output* outa drop
  1294. else
  1295. i sample-a *output* outa drop
  1296. then
  1297. chans 2 = chans 4 = || if
  1298. chans 2 = if
  1299. i sample-b sample-c f+ f2/ *output* outb drop
  1300. else
  1301. i sample-b *output* outb drop
  1302. then
  1303. then
  1304. chans 4 = if
  1305. i sample-c *output* outc drop
  1306. i sample-d *output* outd drop
  1307. then
  1308. loop
  1309. ;instrument
  1310. <'> nrev-fs alias nrev
  1311. struct
  1312. cell% field carriers
  1313. cell% field ampfs
  1314. cell% field indfs
  1315. cell% field c-rats
  1316. end-struct reson%
  1317. \ RESON
  1318. instrument: reson <{ start dur pitch amp
  1319. indxfun skewfun pcskew
  1320. skewat skewdc
  1321. vibfreq vibpc
  1322. ranvibfreq ranvibpc data -- }>
  1323. :frequency pitch make-oscil { mod }
  1324. :envelope skewfun 25 100 skewat dur f/ f* 75 100 100 skewdc dur f/ f* f- stretch-envelope
  1325. :scaler pcskew pitch f* hz->radians
  1326. :duration dur make-env { frqf }
  1327. :frequency vibfreq :amplitude vibpc pitch f* hz->radians make-triangle-wave { pervib }
  1328. :frequency ranvibfreq :amplitude ranvibpc pitch f* hz->radians make-rand-interp { ranvib }
  1329. 0.0 data each ( lst-val ) 2 object-ref f+ end-each { totalamp }
  1330. nil { rs }
  1331. data object->array map! *key* { frmdat }
  1332. reson% %alloc to rs
  1333. frmdat 0 object-ref { ampf }
  1334. frmdat 1 object-ref { freq }
  1335. frmdat 2 object-ref { rfamp }
  1336. frmdat 3 object-ref dur f/ 100.0 f* { ampat }
  1337. 100.0 frmdat 4 object-ref dur f/ 100.0 f* f- { ampdc }
  1338. frmdat 5 object-ref freq f* hz->radians { dev0 }
  1339. frmdat 6 object-ref freq f* hz->radians { dev1 }
  1340. frmdat 7 object-ref dur f/ 100.0 f* { indxat }
  1341. 100.0 frmdat 8 object-ref dur f/ 100.0 f* f- { indxdc }
  1342. freq pitch f/ fround->s { harm }
  1343. 1.0 harm freq pitch f/ f- fabs f- { rsamp }
  1344. pitch harm f* { cfq }
  1345. ampat f0= if 25.0 to ampat then
  1346. ampdc f0= if 75.0 to ampdc then
  1347. indxat f0= if 25.0 to indxat then
  1348. indxdc f0= if 75.0 to indxdc then
  1349. :envelope indxfun 25 indxat 75 indxdc stretch-envelope
  1350. :scaler dev1 dev0 f-
  1351. :offset dev0
  1352. :duration dur make-env rs indfs !
  1353. :envelope ampf 25 ampat 75 ampdc stretch-envelope
  1354. :scaler rsamp amp rfamp totalamp f/ f* f*
  1355. :duration dur make-env rs ampfs !
  1356. harm rs c-rats !
  1357. :frequency cfq make-oscil rs carriers !
  1358. rs
  1359. end-map { values }
  1360. start dur #{ :degree 90.0 random } run-instrument
  1361. pervib 0.0 triangle-wave ranvib 0.0 rand-interp f+ frqf env f+ { vib }
  1362. mod vib 0.0 oscil { modsig }
  1363. 0.0
  1364. values each { rs }
  1365. rs ampfs @ env rs carriers @ vib rs c-rats @ f* rs indfs @ env modsig f* f+ 0.0 oscil f* f+
  1366. end-each
  1367. end-run
  1368. values each ( rs ) free throw end-each
  1369. ;instrument
  1370. : reson-test <{ :optional start 0.0 dur 1.0 -- }>
  1371. start now!
  1372. #( #( #( 0 0 100 1 ) 1200 0.5 0.1 0.1 0 1.0 0.1 0.1 )
  1373. #( #( 0 1 100 0 ) 2400 0.5 0.1 0.1 0 1.0 0.1 0.1 ) ) { data }
  1374. now@ dur 440 0.5 #( 0 0 100 1 ) #( 0 0 100 1 ) 0.1 0.1 0.1 5 0.01 5 0.01 data reson
  1375. dur 0.2 f+ step
  1376. ;
  1377. \ STK's feedback-fm instrument named CelloN in Sambox-land
  1378. instrument: cellon <{ start dur pitch0 amp ampfun
  1379. betafun beta0 beta1 betaat betadc ampat ampdc
  1380. pitch1 glissfun glissat glissdc
  1381. pvibfreq pvibpc pvibfun pvibat pvibdc
  1382. rvibfreq rvibpc rvibfun -- }>
  1383. pitch1 f0= if pitch0 else pitch1 then { pit1 }
  1384. :frequency pitch0 make-oscil { carr }
  1385. 0.5 -0.5 make-one-zero { low }
  1386. :frequency pitch0 make-oscil { fmosc }
  1387. :frequency pvibfreq :amplitude 1.0 make-triangle-wave { pvib }
  1388. :frequency rvibfreq :amplitude 1.0 make-rand-interp { rvib }
  1389. ampat f0> if 100 ampat dur f/ f* else 25 then { ampap }
  1390. ampdc f0> if 100 1 ampdc dur f/ f- f* else 75 then { ampdp }
  1391. glissat f0> if 100 glissat dur f/ f* else 25 then { glsap }
  1392. glissdc f0> if 100 1 glissdc dur f/ f- f* else 75 then { glsdp }
  1393. betaat f0> if 100 betaat dur f/ f* else 25 then { betap }
  1394. betadc f0> if 100 1 betadc dur f/ f- f* else 75 then { betdp }
  1395. pvibat f0> if 100 pvibat dur f/ f* else 25 then { pvbap }
  1396. pvibdc f0> if 100 1 pvibdc dur f/ f- f* else 75 then { pvbdp }
  1397. :envelope pvibfun 25 pvbap 75 pvbdp stretch-envelope
  1398. :scaler pvibpc pitch0 f* hz->radians
  1399. :duration dur make-env { pvibenv }
  1400. :envelope rvibfun
  1401. :scaler rvibpc pitch0 f* hz->radians
  1402. :duration dur make-env { rvibenv }
  1403. :envelope glissfun 25 glsap 75 glsdp stretch-envelope
  1404. :scaler pit1 pitch0 f- hz->radians
  1405. :duration dur make-env { glisenv }
  1406. :envelope ampfun 25 ampap 75 ampdp stretch-envelope
  1407. :scaler amp
  1408. :duration dur make-env { amplenv }
  1409. :envelope betafun 25 betap 75 betdp stretch-envelope
  1410. :scaler beta1 beta0 f-
  1411. :offset beta0
  1412. :duration dur make-env { betaenv }
  1413. 0.0 { fm }
  1414. start dur #{ :degree 90.0 random } run-instrument
  1415. pvibenv env pvib 0.0 triangle-wave f*
  1416. rvibenv env rvib 0.0 rand-interp f* f+
  1417. glisenv env f+ { vib }
  1418. low betaenv env fmosc vib fm f+ 0.0 oscil f* one-zero to fm
  1419. amplenv env carr vib fm f+ 0.0 oscil f*
  1420. end-run
  1421. ;instrument
  1422. : cellon-test <{ :optional start 0.0 dur 1.0 -- }>
  1423. start now!
  1424. now@ dur 220 0.5
  1425. #( 0 0 25 1 75 1 100 0 ) \ ampfun
  1426. #( 0 0 25 1 75 1 100 0 ) \ betafun
  1427. 0.75 1 0 0 0 0 220
  1428. #( 0 0 25 1 75 1 100 0 ) \ glissfun
  1429. 0 0 0 0
  1430. #( 0 0 100 0 ) \ pvibfun
  1431. 0 0 0 0
  1432. #( 0 0 100 0 ) \ rvibfun
  1433. cellon
  1434. dur 0.2 f+ step
  1435. ;
  1436. \ JL-REVERB
  1437. instrument: jl-reverb <{ :key -- }>
  1438. *output* mus-channels { chans }
  1439. *reverb* mus-channels { rev-chans }
  1440. *reverb* reverb-dur { dur }
  1441. *verbose* if get-func-name rev-chans chans reverb-info then
  1442. :feedback -0.7 :feedforward 0.7 :size 2111 make-all-pass { allpass1 }
  1443. :feedback -0.7 :feedforward 0.7 :size 673 make-all-pass { allpass2 }
  1444. :feedback -0.7 :feedforward 0.7 :size 223 make-all-pass { allpass3 }
  1445. :scaler 0.742 :size 9601 make-comb { comb1 }
  1446. :scaler 0.733 :size 10007 make-comb { comb2 }
  1447. :scaler 0.715 :size 10799 make-comb { comb3 }
  1448. :scaler 0.697 :size 11597 make-comb { comb4 }
  1449. :size 0.013 seconds->samples make-delay { outdel1 }
  1450. chans 1 > if :size 0.011 seconds->samples make-delay else #f then { outdel2 }
  1451. chans 2 > if :size 0.015 seconds->samples make-delay else #f then { outdel3 }
  1452. chans 3 > if :size 0.017 seconds->samples make-delay else #f then { outdel4 }
  1453. 0.0 { allpass-sum }
  1454. 0.0 { all-sums }
  1455. 0.0 dur run
  1456. 0.0 rev-chans 0 ?do j i *reverb* in-any f+ loop { in-val }
  1457. allpass3 allpass2 allpass1 in-val 0.0 all-pass 0.0 all-pass 0.0 all-pass to allpass-sum
  1458. comb1 allpass-sum 0.0 comb
  1459. comb2 allpass-sum 0.0 comb f+
  1460. comb3 allpass-sum 0.0 comb f+
  1461. comb4 allpass-sum 0.0 comb f+ to all-sums
  1462. i outdel1 all-sums 0.0 delay *output* outa drop
  1463. outdel2 if i outdel2 all-sums 0.0 delay *output* outb drop then
  1464. outdel3 if i outdel3 all-sums 0.0 delay *output* outc drop then
  1465. outdel4 if i outdel4 all-sums 0.0 delay *output* outd drop then
  1466. loop
  1467. ;instrument
  1468. \ GRAN-SYNTH
  1469. instrument: gran-synth <{ start dur freq grain-dur interval amp -- }>
  1470. :envelope #( 0 0 25 1 75 1 100 0 ) :duration grain-dur make-env { grain-env }
  1471. :frequency freq make-oscil { carrier }
  1472. grain-dur interval fmax mus-srate f* fceil f>s { grain-size }
  1473. :frequency interval 1/f :size grain-size make-wave-train { grains }
  1474. grains mus-data map! grain-env env carrier 0.0 0.0 oscil f* end-map drop
  1475. start dur #{ :degree 90.0 random } run-instrument
  1476. grains 0.0 wave-train amp f*
  1477. end-run
  1478. ;instrument
  1479. : gran-synth-test <{ :optional start 0.0 dur 1.0 -- }>
  1480. start now!
  1481. now@ dur 100 0.0189 0.02 0.4 gran-synth
  1482. dur 0.2 f+ step
  1483. ;
  1484. \ TOUCH-TONE
  1485. \
  1486. \ clm/ugex.ins
  1487. instrument: touch-tone <{ numbers :key start 0.0 -- }>
  1488. doc" (see clm/ugex.ins) NUMBERS is an array with phone numbers.\n\
  1489. #( 8 5 7 7 5 8 ) <'> touch-tone with-sound"
  1490. #( 0 697 697 697 770 770 770 852 852 852 941 941 941 ) { tt1 }
  1491. #( 0 1209 1336 1477 1209 1336 1477 1209 1336 1477 1209 1336 1477 ) { tt2 }
  1492. numbers each ( numb ) dup 0= if drop 11 then { idx }
  1493. :frequency tt1 idx array-ref make-oscil { frq1 }
  1494. :frequency tt2 idx array-ref make-oscil { frq2 }
  1495. i 0.3 f* start f+ 0.2 #{ :degree 90.0 random } run-instrument
  1496. frq1 0.0 0.0 oscil frq2 0.0 0.0 oscil f+ 0.25 f*
  1497. end-run
  1498. end-each
  1499. ;instrument
  1500. : touch-tone-test <{ :optional start 0.0 dur 1.0 -- }>
  1501. start now!
  1502. #( 8 5 7 7 5 8 ) :start now@ touch-tone
  1503. dur 6 ( numbers ) f* 0.2 f+ step
  1504. ;
  1505. \ SPECTRA
  1506. instrument: spectra <{ start dur freq amp
  1507. :optional
  1508. parts #( 1 1 2 0.5 )
  1509. ampenv #( 0 0 50 1 100 0 )
  1510. vibamp 0.005
  1511. vibfrq 5.0
  1512. degr 0.0
  1513. dist 1.0
  1514. rev-amt 0.005 -- }>
  1515. :frequency freq :wave parts #f #f partials->wave make-table-lookup { s }
  1516. :envelope ampenv :scaler amp :duration dur make-env { ampf }
  1517. freq hz->radians vibamp f* { vamp }
  1518. :frequency vibfrq :amplitude vamp make-triangle-wave { pervib }
  1519. :frequency vibfrq 1.0 f+ :amplitude vamp make-rand-interp { ranvib }
  1520. start dur #{ :degree degr :distance dist :reverb-amount rev-amt } run-instrument
  1521. s pervib 0.0 triangle-wave ranvib 0.0 rand-interp f+ table-lookup ampf env f*
  1522. end-run
  1523. ;instrument
  1524. : spectra-test <{ :optional start 0.0 dur 1.0 -- }>
  1525. start now!
  1526. #( 1.00 0.1132 2.00 0.0252 3.00 0.0292 4.01 0.0136 5.03 0.0045
  1527. 6.06 0.0022 7.11 0.0101 8.17 0.0004 9.23 0.0010 10.33 0.0012
  1528. 11.44 0.0013 12.58 0.0011 13.75 0.0002 14.93 0.0005 16.14 0.0002 ) { p-a4 }
  1529. now@ dur 440 2.0 p-a4 #( 0 0 1 1 5 0.9 12 0.5 25 0.25 100 0 ) spectra
  1530. dur 0.2 f+ step
  1531. ;
  1532. \ TWO-TAB
  1533. \
  1534. \ interpolate between two waveforms (this could be extended to
  1535. \ implement all the various wavetable-based synthesis techniques).
  1536. instrument: two-tab <{ start dur freq amp
  1537. :optional
  1538. part1 #( 1.0 1.0 2.0 0.5 )
  1539. part2 #( 1.0 0.0 3.0 1.0 )
  1540. ampenv #( 0 0 50 1 100 0 )
  1541. interpenv #( 0 1 100 0 )
  1542. vibamp 0.005
  1543. vibfrq 5.0
  1544. degr 0.0
  1545. dist 1.0
  1546. rev-amt 0.005 -- }>
  1547. :frequency freq :wave part1 #f #f partials->wave make-table-lookup { s1 }
  1548. :frequency freq :wave part2 #f #f partials->wave make-table-lookup { s2 }
  1549. :envelope ampenv :scaler amp :duration dur make-env { ampf }
  1550. :envelope interpenv :duration dur make-env { interpf }
  1551. freq hz->radians vibamp f* { vamp }
  1552. :frequency vibfrq :amplitude vamp make-triangle-wave { pervib }
  1553. :frequency vibfrq 1.0 f+ :amplitude vamp make-rand-interp { ranvib }
  1554. start dur #{ :degree degr :distance dist :reverb-amount rev-amt } run-instrument
  1555. pervib 0.0 triangle-wave ranvib 0.0 rand-interp f+ { vib }
  1556. interpf env { intrp }
  1557. s1 vib table-lookup intrp f* s2 vib table-lookup 1.0 intrp f- f* f+ ampf env f*
  1558. end-run
  1559. ;instrument
  1560. : two-tab-test <{ :optional start 0.0 dur 1.0 -- }>
  1561. start now!
  1562. now@ dur 440 0.5 two-tab
  1563. dur 0.2 f+ step
  1564. ;
  1565. \ LBJ-PIANO
  1566. #( #( 1.97 0.0326 2.99 0.0086 3.95 0.0163 4.97 0.0178 5.98 0.0177
  1567. 6.95 0.0315 8.02 0.0001 8.94 0.0076 9.96 0.0134 10.99 0.0284
  1568. 11.98 0.0229 13.02 0.0229 13.89 0.0010 15.06 0.0090 16.00 0.0003
  1569. 17.08 0.0078 18.16 0.0064 19.18 0.0129 20.21 0.0085 21.27 0.0225
  1570. 22.32 0.0061 23.41 0.0102 24.48 0.0005 25.56 0.0016 26.64 0.0018
  1571. 27.70 0.0113 28.80 0.0111 29.91 0.0158 31.06 0.0093 32.17 0.0017
  1572. 33.32 0.0002 34.42 0.0018 35.59 0.0027 36.74 0.0055 37.90 0.0037
  1573. 39.06 0.0064 40.25 0.0033 41.47 0.0014 42.53 0.0004 43.89 0.0010
  1574. 45.12 0.0039 46.33 0.0039 47.64 0.0009 48.88 0.0016 50.13 0.0006
  1575. 51.37 0.0010 52.70 0.0002 54.00 0.0004 55.30 0.0008 56.60 0.0025
  1576. 57.96 0.0010 59.30 0.0012 60.67 0.0011 61.99 0.0003 62.86 0.0001
  1577. 64.36 0.0005 64.86 0.0001 66.26 0.0004 67.70 0.0006 68.94 0.0002
  1578. 70.10 0.0001 70.58 0.0002 72.01 0.0007 73.53 0.0006 75.00 0.0002
  1579. 77.03 0.0005 78.00 0.0002 79.57 0.0006 81.16 0.0005 82.70 0.0005
  1580. 84.22 0.0003 85.41 0.0002 87.46 0.0001 90.30 0.0001 94.02 0.0001
  1581. 95.26 0.0002 109.39 0.0003 )
  1582. #( 1.98 0.0194 2.99 0.0210 3.97 0.0276 4.96 0.0297 5.96 0.0158
  1583. 6.99 0.0207 8.01 0.0009 9.00 0.0101 10.00 0.0297 11.01 0.0289
  1584. 12.02 0.0211 13.04 0.0127 14.07 0.0061 15.08 0.0174 16.13 0.0009
  1585. 17.12 0.0093 18.16 0.0117 19.21 0.0122 20.29 0.0108 21.30 0.0077
  1586. 22.38 0.0132 23.46 0.0073 24.14 0.0002 25.58 0.0026 26.69 0.0035
  1587. 27.77 0.0053 28.88 0.0024 30.08 0.0027 31.13 0.0075 32.24 0.0027
  1588. 33.36 0.0004 34.42 0.0004 35.64 0.0019 36.78 0.0037 38.10 0.0009
  1589. 39.11 0.0027 40.32 0.0010 41.51 0.0013 42.66 0.0019 43.87 0.0007
  1590. 45.13 0.0017 46.35 0.0019 47.65 0.0021 48.89 0.0014 50.18 0.0023
  1591. 51.42 0.0015 52.73 0.0002 54.00 0.0005 55.34 0.0006 56.60 0.0010
  1592. 57.96 0.0016 58.86 0.0005 59.30 0.0004 60.75 0.0005 62.22 0.0003
  1593. 63.55 0.0005 64.82 0.0003 66.24 0.0003 67.63 0.0011 69.09 0.0007
  1594. 70.52 0.0004 72.00 0.0005 73.50 0.0008 74.95 0.0003 77.13 0.0013
  1595. 78.02 0.0002 79.48 0.0004 82.59 0.0004 84.10 0.0003 )
  1596. #( 2.00 0.0313 2.99 0.0109 4.00 0.0215 5.00 0.0242 5.98 0.0355
  1597. 7.01 0.0132 8.01 0.0009 9.01 0.0071 10.00 0.0258 11.03 0.0221
  1598. 12.02 0.0056 13.06 0.0196 14.05 0.0160 15.11 0.0107 16.11 0.0003
  1599. 17.14 0.0111 18.21 0.0085 19.23 0.0010 20.28 0.0048 21.31 0.0128
  1600. 22.36 0.0051 23.41 0.0041 24.05 0.0006 25.54 0.0019 26.62 0.0028
  1601. 27.72 0.0034 28.82 0.0062 29.89 0.0039 30.98 0.0058 32.08 0.0011
  1602. 33.21 0.0002 34.37 0.0008 35.46 0.0018 36.62 0.0036 37.77 0.0018
  1603. 38.92 0.0042 40.07 0.0037 41.23 0.0011 42.67 0.0003 43.65 0.0018
  1604. 44.68 0.0025 45.99 0.0044 47.21 0.0051 48.40 0.0044 49.67 0.0005
  1605. 50.88 0.0019 52.15 0.0003 53.42 0.0008 54.69 0.0010 55.98 0.0005
  1606. 57.26 0.0013 58.53 0.0027 59.83 0.0011 61.21 0.0027 62.54 0.0003
  1607. 63.78 0.0003 65.20 0.0001 66.60 0.0006 67.98 0.0008 69.37 0.0019
  1608. 70.73 0.0007 72.14 0.0004 73.62 0.0002 74.40 0.0003 76.52 0.0006
  1609. 77.97 0.0002 79.49 0.0004 80.77 0.0003 81.00 0.0001 82.47 0.0005
  1610. 83.97 0.0001 87.27 0.0002 )
  1611. #( 2.00 0.0257 2.99 0.0142 3.97 0.0202 4.95 0.0148 5.95 0.0420
  1612. 6.95 0.0037 7.94 0.0004 8.94 0.0172 9.95 0.0191 10.96 0.0115
  1613. 11.97 0.0059 12.98 0.0140 14.00 0.0178 15.03 0.0121 16.09 0.0002
  1614. 17.07 0.0066 18.08 0.0033 19.15 0.0022 20.18 0.0057 21.22 0.0077
  1615. 22.29 0.0037 23.33 0.0066 24.97 0.0002 25.49 0.0019 26.55 0.0042
  1616. 27.61 0.0043 28.73 0.0038 29.81 0.0084 30.91 0.0040 32.03 0.0025
  1617. 33.14 0.0005 34.26 0.0003 35.38 0.0019 36.56 0.0037 37.68 0.0049
  1618. 38.86 0.0036 40.11 0.0011 41.28 0.0008 42.50 0.0004 43.60 0.0002
  1619. 44.74 0.0022 45.99 0.0050 47.20 0.0009 48.40 0.0036 49.68 0.0004
  1620. 50.92 0.0009 52.17 0.0005 53.46 0.0007 54.76 0.0006 56.06 0.0005
  1621. 57.34 0.0011 58.67 0.0005 59.95 0.0015 61.37 0.0008 62.72 0.0004
  1622. 65.42 0.0009 66.96 0.0003 68.18 0.0003 69.78 0.0003 71.21 0.0004
  1623. 72.45 0.0002 74.22 0.0003 75.44 0.0001 76.53 0.0003 78.31 0.0004
  1624. 79.83 0.0003 80.16 0.0001 81.33 0.0003 82.44 0.0001 83.17 0.0002
  1625. 84.81 0.0003 85.97 0.0003 89.08 0.0001 90.70 0.0002 92.30 0.0002
  1626. 95.59 0.0002 97.22 0.0003 98.86 0.0001 108.37 0.0001 125.54 0.0001 )
  1627. #( 1.99 0.0650 3.03 0.0040 4.03 0.0059 5.02 0.0090 5.97 0.0227
  1628. 6.98 0.0050 8.04 0.0020 9.00 0.0082 9.96 0.0078 11.01 0.0056
  1629. 12.01 0.0095 13.02 0.0050 14.04 0.0093 15.08 0.0064 16.14 0.0017
  1630. 17.06 0.0020 18.10 0.0025 19.14 0.0023 20.18 0.0015 21.24 0.0032
  1631. 22.29 0.0029 23.32 0.0014 24.37 0.0005 25.43 0.0030 26.50 0.0022
  1632. 27.60 0.0027 28.64 0.0024 29.76 0.0035 30.81 0.0136 31.96 0.0025
  1633. 33.02 0.0003 34.13 0.0005 35.25 0.0007 36.40 0.0014 37.51 0.0020
  1634. 38.64 0.0012 39.80 0.0019 40.97 0.0004 42.09 0.0003 43.24 0.0003
  1635. 44.48 0.0002 45.65 0.0024 46.86 0.0005 48.07 0.0013 49.27 0.0008
  1636. 50.49 0.0006 52.95 0.0001 54.23 0.0005 55.45 0.0004 56.73 0.0001
  1637. 58.03 0.0003 59.29 0.0002 60.59 0.0003 62.04 0.0002 65.89 0.0002
  1638. 67.23 0.0002 68.61 0.0002 69.97 0.0004 71.36 0.0005 85.42 0.0001 )
  1639. #( 1.98 0.0256 2.96 0.0158 3.95 0.0310 4.94 0.0411 5.95 0.0238
  1640. 6.94 0.0152 7.93 0.0011 8.95 0.0185 9.92 0.0166 10.93 0.0306
  1641. 11.94 0.0258 12.96 0.0202 13.97 0.0403 14.95 0.0228 15.93 0.0005
  1642. 17.01 0.0072 18.02 0.0034 19.06 0.0028 20.08 0.0124 21.13 0.0137
  1643. 22.16 0.0102 23.19 0.0058 23.90 0.0013 25.30 0.0039 26.36 0.0039
  1644. 27.41 0.0025 28.47 0.0071 29.64 0.0031 30.60 0.0027 31.71 0.0021
  1645. 32.84 0.0003 33.82 0.0002 35.07 0.0019 36.09 0.0054 37.20 0.0038
  1646. 38.33 0.0024 39.47 0.0055 40.55 0.0016 41.77 0.0006 42.95 0.0002
  1647. 43.27 0.0018 44.03 0.0006 45.25 0.0019 46.36 0.0033 47.50 0.0024
  1648. 48.87 0.0012 50.03 0.0016 51.09 0.0004 53.52 0.0017 54.74 0.0012
  1649. 56.17 0.0003 57.40 0.0011 58.42 0.0020 59.70 0.0007 61.29 0.0008
  1650. 62.56 0.0003 63.48 0.0002 64.83 0.0002 66.12 0.0012 67.46 0.0017
  1651. 68.81 0.0003 69.13 0.0003 70.53 0.0002 71.84 0.0001 73.28 0.0002
  1652. 75.52 0.0010 76.96 0.0005 77.93 0.0003 78.32 0.0003 79.73 0.0003
  1653. 81.69 0.0002 82.52 0.0001 84.01 0.0001 84.61 0.0002 86.88 0.0001
  1654. 88.36 0.0002 89.85 0.0002 91.35 0.0003 92.86 0.0002 93.40 0.0001
  1655. 105.28 0.0002 106.22 0.0002 107.45 0.0001 108.70 0.0003 122.08 0.0002 )
  1656. #( 1.97 0.0264 2.97 0.0211 3.98 0.0234 4.98 0.0307 5.96 0.0085
  1657. 6.94 0.0140 7.93 0.0005 8.96 0.0112 9.96 0.0209 10.98 0.0194
  1658. 11.98 0.0154 12.99 0.0274 13.99 0.0127 15.01 0.0101 15.99 0.0002
  1659. 17.04 0.0011 18.08 0.0032 19.14 0.0028 20.12 0.0054 21.20 0.0053
  1660. 22.13 0.0028 23.22 0.0030 24.32 0.0006 25.24 0.0004 26.43 0.0028
  1661. 27.53 0.0048 28.52 0.0039 29.54 0.0047 30.73 0.0044 31.82 0.0007
  1662. 32.94 0.0008 34.04 0.0012 35.13 0.0018 36.29 0.0007 37.35 0.0075
  1663. 38.51 0.0045 39.66 0.0014 40.90 0.0004 41.90 0.0002 43.08 0.0002
  1664. 44.24 0.0017 45.36 0.0013 46.68 0.0020 47.79 0.0015 48.98 0.0010
  1665. 50.21 0.0012 51.34 0.0001 53.82 0.0003 55.09 0.0004 56.23 0.0005
  1666. 57.53 0.0004 58.79 0.0005 59.30 0.0002 60.03 0.0002 61.40 0.0003
  1667. 62.84 0.0001 66.64 0.0001 67.97 0.0001 69.33 0.0001 70.68 0.0001
  1668. 73.57 0.0002 75.76 0.0002 76.45 0.0001 79.27 0.0001 80.44 0.0002
  1669. 81.87 0.0002 )
  1670. #( 2.00 0.0311 2.99 0.0086 3.99 0.0266 4.97 0.0123 5.98 0.0235
  1671. 6.97 0.0161 7.97 0.0008 8.96 0.0088 9.96 0.0621 10.99 0.0080
  1672. 11.99 0.0034 12.99 0.0300 14.03 0.0228 15.04 0.0105 16.03 0.0004
  1673. 17.06 0.0036 18.09 0.0094 18.95 0.0009 20.17 0.0071 21.21 0.0161
  1674. 22.25 0.0106 23.28 0.0104 24.33 0.0008 25.38 0.0030 26.46 0.0035
  1675. 27.50 0.0026 28.59 0.0028 29.66 0.0128 30.75 0.0139 31.81 0.0038
  1676. 32.93 0.0006 34.04 0.0004 35.16 0.0005 36.25 0.0023 37.35 0.0012
  1677. 38.46 0.0021 39.59 0.0035 40.71 0.0006 41.86 0.0007 42.42 0.0001
  1678. 43.46 0.0003 44.17 0.0032 45.29 0.0013 46.57 0.0004 47.72 0.0011
  1679. 48.79 0.0005 50.11 0.0005 51.29 0.0003 52.47 0.0002 53.68 0.0004
  1680. 55.02 0.0005 56.18 0.0003 57.41 0.0003 58.75 0.0007 59.33 0.0009
  1681. 60.00 0.0004 61.34 0.0001 64.97 0.0003 65.20 0.0002 66.48 0.0002
  1682. 67.83 0.0002 68.90 0.0003 70.25 0.0003 71.59 0.0002 73.68 0.0001
  1683. 75.92 0.0001 77.08 0.0002 78.45 0.0002 81.56 0.0002 82.99 0.0001
  1684. 88.39 0.0001 )
  1685. #( 0.97 0.0059 1.98 0.0212 2.99 0.0153 3.99 0.0227 4.96 0.0215
  1686. 5.97 0.0153 6.98 0.0085 7.98 0.0007 8.97 0.0179 9.98 0.0512
  1687. 10.98 0.0322 12.00 0.0098 13.02 0.0186 14.00 0.0099 15.05 0.0109
  1688. 15.88 0.0011 17.07 0.0076 18.11 0.0071 19.12 0.0045 20.16 0.0038
  1689. 21.23 0.0213 22.27 0.0332 23.34 0.0082 24.34 0.0014 25.42 0.0024
  1690. 26.47 0.0012 27.54 0.0014 28.60 0.0024 29.72 0.0026 30.10 0.0008
  1691. 31.91 0.0021 32.13 0.0011 33.02 0.0007 34.09 0.0014 35.17 0.0007
  1692. 36.27 0.0024 37.39 0.0029 38.58 0.0014 39.65 0.0017 40.95 0.0012
  1693. 41.97 0.0004 42.43 0.0002 43.49 0.0001 44.31 0.0012 45.42 0.0031
  1694. 46.62 0.0017 47.82 0.0013 49.14 0.0013 50.18 0.0010 51.54 0.0003
  1695. 53.90 0.0006 55.06 0.0010 56.31 0.0003 57.63 0.0001 59.02 0.0003
  1696. 60.09 0.0004 60.35 0.0004 61.62 0.0009 63.97 0.0001 65.19 0.0001
  1697. 65.54 0.0002 66.92 0.0002 67.94 0.0002 69.17 0.0003 69.60 0.0004
  1698. 70.88 0.0002 72.24 0.0002 76.12 0.0001 78.94 0.0001 81.75 0.0001
  1699. 82.06 0.0001 83.53 0.0001 90.29 0.0002 91.75 0.0001 92.09 0.0002
  1700. 93.28 0.0001 97.07 0.0001 )
  1701. #( 1.98 0.0159 2.98 0.1008 3.98 0.0365 4.98 0.0133 5.97 0.0101
  1702. 6.97 0.0115 7.97 0.0007 8.99 0.0349 10.01 0.0342 11.01 0.0236
  1703. 12.00 0.0041 13.02 0.0114 14.05 0.0137 15.06 0.0100 16.05 0.0007
  1704. 17.04 0.0009 18.12 0.0077 19.15 0.0023 20.12 0.0017 21.24 0.0113
  1705. 22.26 0.0126 23.30 0.0093 24.36 0.0007 25.43 0.0007 26.47 0.0009
  1706. 27.55 0.0013 28.59 0.0025 29.61 0.0010 30.77 0.0021 31.86 0.0023
  1707. 32.96 0.0003 34.03 0.0007 35.06 0.0005 36.20 0.0006 37.34 0.0006
  1708. 38.36 0.0009 39.60 0.0016 40.69 0.0005 41.77 0.0002 42.92 0.0002
  1709. 44.02 0.0003 45.24 0.0006 46.33 0.0004 47.50 0.0007 48.71 0.0007
  1710. 49.87 0.0002 51.27 0.0002 53.42 0.0003 55.88 0.0003 57.10 0.0004
  1711. 58.34 0.0002 59.86 0.0003 61.13 0.0003 67.18 0.0001 68.50 0.0001
  1712. 71.17 0.0001 83.91 0.0001 90.55 0.0001 )
  1713. #( 0.98 0.0099 2.00 0.0181 2.99 0.0353 3.98 0.0285 4.97 0.0514
  1714. 5.96 0.0402 6.96 0.0015 7.98 0.0012 8.98 0.0175 9.98 0.0264
  1715. 10.98 0.0392 11.98 0.0236 13.00 0.0153 14.04 0.0049 15.00 0.0089
  1716. 16.01 0.0001 17.03 0.0106 18.03 0.0028 19.05 0.0024 20.08 0.0040
  1717. 21.11 0.0103 22.12 0.0104 23.20 0.0017 24.19 0.0008 25.20 0.0007
  1718. 26.24 0.0011 27.36 0.0009 27.97 0.0030 29.40 0.0044 30.37 0.0019
  1719. 31.59 0.0017 32.65 0.0008 33.59 0.0005 34.79 0.0009 35.75 0.0027
  1720. 36.88 0.0035 37.93 0.0039 39.00 0.0031 40.08 0.0025 41.16 0.0010
  1721. 43.25 0.0004 44.52 0.0012 45.62 0.0023 45.85 0.0012 47.00 0.0006
  1722. 47.87 0.0008 48.99 0.0003 50.48 0.0003 51.62 0.0001 52.43 0.0001
  1723. 53.56 0.0002 54.76 0.0002 56.04 0.0002 56.68 0.0006 57.10 0.0003
  1724. 58.28 0.0005 59.47 0.0003 59.96 0.0002 60.67 0.0001 63.08 0.0002
  1725. 64.29 0.0002 66.72 0.0001 67.97 0.0001 68.65 0.0001 70.43 0.0001
  1726. 79.38 0.0001 80.39 0.0001 82.39 0.0001 )
  1727. #( 1.00 0.0765 1.99 0.0151 2.99 0.0500 3.99 0.0197 5.00 0.0260
  1728. 6.00 0.0145 6.98 0.0128 7.97 0.0004 8.98 0.0158 9.99 0.0265
  1729. 11.02 0.0290 12.02 0.0053 13.03 0.0242 14.03 0.0103 15.06 0.0054
  1730. 16.04 0.0006 17.08 0.0008 18.10 0.0058 19.16 0.0011 20.16 0.0055
  1731. 21.18 0.0040 22.20 0.0019 23.22 0.0014 24.05 0.0005 25.31 0.0019
  1732. 26.38 0.0018 27.44 0.0022 28.45 0.0024 29.57 0.0073 30.58 0.0032
  1733. 31.66 0.0071 32.73 0.0015 33.85 0.0005 34.96 0.0003 36.00 0.0020
  1734. 37.11 0.0018 38.18 0.0055 39.23 0.0006 40.33 0.0004 41.52 0.0003
  1735. 43.41 0.0028 45.05 0.0003 45.99 0.0002 47.07 0.0003 48.52 0.0002
  1736. 49.48 0.0003 50.63 0.0003 51.81 0.0002 54.05 0.0002 55.24 0.0001
  1737. 56.62 0.0001 57.81 0.0004 59.16 0.0013 60.23 0.0003 66.44 0.0001
  1738. 68.99 0.0004 75.49 0.0001 87.56 0.0004 )
  1739. #( 0.98 0.0629 1.99 0.0232 2.98 0.0217 4.00 0.0396 4.98 0.0171
  1740. 5.97 0.0098 6.99 0.0167 7.99 0.0003 8.98 0.0192 9.98 0.0266
  1741. 10.99 0.0256 12.01 0.0061 13.02 0.0135 14.02 0.0062 15.05 0.0158
  1742. 16.06 0.0018 17.08 0.0101 18.09 0.0053 19.11 0.0074 20.13 0.0020
  1743. 21.17 0.0052 22.22 0.0077 23.24 0.0035 24.00 0.0009 25.32 0.0016
  1744. 26.40 0.0022 27.43 0.0005 28.55 0.0026 29.60 0.0026 30.65 0.0010
  1745. 31.67 0.0019 32.77 0.0008 33.81 0.0003 34.91 0.0003 36.01 0.0005
  1746. 37.11 0.0010 38.20 0.0014 39.29 0.0039 40.43 0.0012 41.50 0.0006
  1747. 43.38 0.0017 43.75 0.0002 44.94 0.0005 46.13 0.0002 47.11 0.0003
  1748. 48.28 0.0005 48.42 0.0005 49.44 0.0003 50.76 0.0004 51.93 0.0002
  1749. 54.15 0.0003 55.31 0.0005 55.50 0.0003 56.98 0.0003 57.90 0.0004
  1750. 60.33 0.0002 61.39 0.0001 61.59 0.0001 65.09 0.0002 66.34 0.0001
  1751. 68.85 0.0001 70.42 0.0002 71.72 0.0001 73.05 0.0003 79.65 0.0001
  1752. 85.28 0.0002 93.52 0.0001 )
  1753. #( 1.02 0.0185 1.99 0.0525 2.98 0.0613 3.99 0.0415 4.98 0.0109
  1754. 5.97 0.0248 6.99 0.0102 7.98 0.0005 8.98 0.0124 9.99 0.0103
  1755. 10.99 0.0124 12.00 0.0016 13.01 0.0029 14.03 0.0211 15.04 0.0128
  1756. 16.07 0.0021 17.09 0.0009 18.09 0.0043 19.14 0.0022 20.13 0.0016
  1757. 21.20 0.0045 22.21 0.0088 23.26 0.0046 24.29 0.0013 25.35 0.0009
  1758. 26.39 0.0028 27.49 0.0009 28.51 0.0006 29.58 0.0012 30.70 0.0010
  1759. 31.74 0.0019 32.75 0.0002 33.85 0.0001 34.95 0.0005 36.02 0.0003
  1760. 37.16 0.0009 38.25 0.0018 39.35 0.0008 40.54 0.0004 41.61 0.0002
  1761. 43.40 0.0004 43.74 0.0003 45.05 0.0001 46.11 0.0003 47.40 0.0002
  1762. 48.36 0.0004 49.55 0.0004 50.72 0.0002 52.00 0.0001 55.58 0.0002
  1763. 57.02 0.0001 57.98 0.0002 59.13 0.0003 61.56 0.0001 66.56 0.0001
  1764. 87.65 0.0002 )
  1765. #( 1.00 0.0473 1.99 0.0506 2.99 0.0982 3.99 0.0654 5.00 0.0196
  1766. 5.99 0.0094 6.99 0.0118 7.93 0.0001 8.99 0.0057 10.01 0.0285
  1767. 11.01 0.0142 12.03 0.0032 13.03 0.0056 14.06 0.0064 15.06 0.0059
  1768. 16.11 0.0005 17.09 0.0033 18.14 0.0027 19.15 0.0014 20.17 0.0010
  1769. 21.21 0.0059 22.26 0.0043 23.31 0.0031 24.31 0.0018 25.33 0.0009
  1770. 26.41 0.0005 27.47 0.0015 28.53 0.0015 29.58 0.0041 30.65 0.0025
  1771. 31.73 0.0011 32.83 0.0010 34.98 0.0003 36.07 0.0009 37.23 0.0001
  1772. 38.26 0.0020 39.41 0.0014 40.53 0.0005 41.40 0.0003 42.80 0.0002
  1773. 43.48 0.0028 43.93 0.0001 45.03 0.0003 46.18 0.0007 47.41 0.0001
  1774. 48.57 0.0002 49.67 0.0001 50.83 0.0002 54.39 0.0001 55.58 0.0002
  1775. 57.97 0.0005 58.11 0.0002 59.21 0.0001 60.42 0.0002 61.66 0.0001 )
  1776. #( 1.00 0.0503 2.00 0.0963 2.99 0.1304 3.99 0.0218 4.98 0.0041
  1777. 5.98 0.0292 6.98 0.0482 7.99 0.0005 8.99 0.0280 10.00 0.0237
  1778. 11.00 0.0152 12.02 0.0036 12.95 0.0022 14.06 0.0111 15.07 0.0196
  1779. 16.08 0.0016 17.11 0.0044 18.13 0.0073 19.17 0.0055 20.19 0.0028
  1780. 21.20 0.0012 22.27 0.0068 23.30 0.0036 24.35 0.0012 25.35 0.0002
  1781. 26.46 0.0005 27.47 0.0005 28.59 0.0009 29.65 0.0021 30.70 0.0020
  1782. 31.78 0.0012 32.89 0.0010 35.06 0.0005 36.16 0.0008 37.27 0.0010
  1783. 38.36 0.0010 39.47 0.0014 40.58 0.0004 41.43 0.0007 41.82 0.0003
  1784. 43.48 0.0008 44.53 0.0001 45.25 0.0003 46.43 0.0002 47.46 0.0002
  1785. 48.76 0.0005 49.95 0.0004 50.96 0.0002 51.12 0.0002 52.33 0.0001
  1786. 54.75 0.0001 55.75 0.0002 56.90 0.0002 58.17 0.0002 59.40 0.0004
  1787. 60.62 0.0002 65.65 0.0001 66.91 0.0002 69.91 0.0001 71.25 0.0002 )
  1788. #( 1.00 0.1243 1.98 0.1611 3.00 0.0698 3.98 0.0390 5.00 0.0138
  1789. 5.99 0.0154 7.01 0.0287 8.01 0.0014 9.01 0.0049 10.00 0.0144
  1790. 11.01 0.0055 12.05 0.0052 13.01 0.0011 14.05 0.0118 15.07 0.0154
  1791. 16.12 0.0028 17.14 0.0061 18.25 0.0007 19.22 0.0020 20.24 0.0011
  1792. 21.27 0.0029 22.30 0.0046 23.34 0.0049 24.35 0.0004 25.45 0.0003
  1793. 26.47 0.0007 27.59 0.0008 28.16 0.0009 29.12 0.0002 29.81 0.0006
  1794. 30.81 0.0009 31.95 0.0004 33.00 0.0011 34.12 0.0005 35.18 0.0003
  1795. 36.30 0.0008 37.38 0.0003 38.55 0.0003 39.64 0.0006 40.77 0.0007
  1796. 41.52 0.0006 41.89 0.0006 43.04 0.0011 43.60 0.0009 44.31 0.0002
  1797. 45.68 0.0002 46.56 0.0003 47.60 0.0001 48.83 0.0006 50.01 0.0003
  1798. 51.27 0.0003 56.04 0.0005 57.21 0.0003 58.56 0.0004 59.83 0.0003
  1799. 61.05 0.0001 62.20 0.0001 67.37 0.0002 76.53 0.0001 )
  1800. #( 0.99 0.0222 1.99 0.0678 2.99 0.0683 4.00 0.0191 5.00 0.0119
  1801. 6.01 0.0232 6.98 0.0336 7.99 0.0082 9.01 0.0201 10.01 0.0189
  1802. 11.01 0.0041 12.01 0.0053 13.05 0.0154 14.04 0.0159 15.06 0.0092
  1803. 16.11 0.0038 17.12 0.0014 18.15 0.0091 19.16 0.0006 20.30 0.0012
  1804. 21.25 0.0061 22.28 0.0099 23.34 0.0028 24.38 0.0012 25.43 0.0016
  1805. 26.49 0.0048 27.55 0.0025 28.62 0.0015 29.71 0.0032 30.78 0.0077
  1806. 31.88 0.0011 32.97 0.0007 34.08 0.0006 35.16 0.0008 36.28 0.0004
  1807. 37.41 0.0006 38.54 0.0005 39.62 0.0002 40.80 0.0003 41.93 0.0001
  1808. 43.06 0.0002 44.21 0.0003 45.38 0.0002 46.54 0.0007 47.78 0.0003
  1809. 48.95 0.0004 50.10 0.0003 51.37 0.0002 53.79 0.0003 56.20 0.0001
  1810. 58.71 0.0002 66.47 0.0003 )
  1811. #( 1.01 0.0241 1.99 0.1011 2.98 0.0938 3.98 0.0081 4.99 0.0062
  1812. 5.99 0.0291 6.99 0.0676 7.59 0.0004 8.98 0.0127 9.99 0.0112
  1813. 10.99 0.0142 12.00 0.0029 13.02 0.0071 14.02 0.0184 15.03 0.0064
  1814. 16.07 0.0010 17.09 0.0011 18.11 0.0010 19.15 0.0060 20.19 0.0019
  1815. 21.24 0.0025 22.29 0.0013 23.31 0.0050 25.41 0.0030 26.50 0.0018
  1816. 27.53 0.0006 28.63 0.0012 29.66 0.0013 30.77 0.0020 31.84 0.0006
  1817. 34.04 0.0001 35.14 0.0001 36.32 0.0004 37.41 0.0007 38.53 0.0007
  1818. 39.67 0.0009 40.85 0.0003 45.49 0.0002 46.65 0.0001 47.81 0.0004
  1819. 49.01 0.0002 53.91 0.0002 55.14 0.0002 57.69 0.0002 )
  1820. #( 1.00 0.0326 2.00 0.1066 2.99 0.1015 4.00 0.0210 4.97 0.0170
  1821. 5.99 0.0813 6.98 0.0820 7.96 0.0011 8.99 0.0248 10.03 0.0107
  1822. 11.01 0.0126 12.01 0.0027 13.01 0.0233 14.04 0.0151 15.05 0.0071
  1823. 16.04 0.0002 17.10 0.0061 18.12 0.0059 19.15 0.0087 20.23 0.0005
  1824. 21.25 0.0040 22.30 0.0032 23.35 0.0004 24.40 0.0001 25.45 0.0030
  1825. 26.54 0.0022 27.60 0.0003 28.70 0.0009 29.80 0.0029 30.85 0.0006
  1826. 31.97 0.0006 34.19 0.0004 35.30 0.0003 36.43 0.0007 37.56 0.0005
  1827. 38.68 0.0019 39.88 0.0013 41.00 0.0003 43.35 0.0003 44.51 0.0002
  1828. 45.68 0.0006 46.93 0.0010 48.11 0.0006 49.29 0.0003 55.58 0.0002 )
  1829. #( 0.98 0.0113 1.99 0.0967 3.00 0.0719 3.98 0.0345 4.98 0.0121
  1830. 6.00 0.0621 7.00 0.0137 7.98 0.0006 9.01 0.0314 10.01 0.0171
  1831. 11.02 0.0060 12.03 0.0024 13.05 0.0077 14.07 0.0040 15.12 0.0032
  1832. 16.13 0.0004 17.15 0.0011 18.20 0.0028 19.18 0.0003 20.26 0.0003
  1833. 21.31 0.0025 22.35 0.0021 23.39 0.0005 25.55 0.0002 26.62 0.0014
  1834. 27.70 0.0003 28.78 0.0005 29.90 0.0030 31.01 0.0011 32.12 0.0005
  1835. 34.31 0.0001 35.50 0.0002 36.62 0.0002 37.76 0.0005 38.85 0.0002
  1836. 40.09 0.0004 43.60 0.0001 44.73 0.0002 46.02 0.0002 47.25 0.0004
  1837. 48.44 0.0004 )
  1838. #( 0.99 0.0156 1.98 0.0846 2.98 0.0178 3.98 0.0367 4.98 0.0448
  1839. 5.98 0.0113 6.99 0.0189 8.00 0.0011 9.01 0.0247 10.02 0.0089
  1840. 11.01 0.0184 12.03 0.0105 13.00 0.0039 14.07 0.0116 15.09 0.0078
  1841. 16.13 0.0008 17.14 0.0064 18.19 0.0029 19.22 0.0028 20.25 0.0017
  1842. 21.32 0.0043 22.37 0.0055 23.42 0.0034 24.48 0.0004 25.54 0.0002
  1843. 26.61 0.0017 27.70 0.0011 28.80 0.0002 29.89 0.0019 30.97 0.0028
  1844. 32.09 0.0007 34.30 0.0002 35.44 0.0003 36.55 0.0001 37.69 0.0004
  1845. 38.93 0.0002 40.05 0.0005 41.20 0.0005 42.37 0.0002 43.54 0.0003
  1846. 44.73 0.0001 45.95 0.0002 47.16 0.0001 48.43 0.0005 49.65 0.0004
  1847. 55.90 0.0002 59.81 0.0004 )
  1848. #( 1.01 0.0280 2.00 0.0708 2.99 0.0182 3.99 0.0248 4.98 0.0245
  1849. 5.98 0.0279 6.98 0.0437 7.99 0.0065 8.99 0.0299 10.00 0.0073
  1850. 10.99 0.0011 12.03 0.0122 13.03 0.0028 14.08 0.0044 15.11 0.0097
  1851. 16.15 0.0010 17.17 0.0025 18.19 0.0017 19.24 0.0008 20.28 0.0040
  1852. 21.32 0.0024 22.38 0.0008 23.46 0.0032 24.52 0.0010 25.59 0.0008
  1853. 26.68 0.0009 27.76 0.0012 28.88 0.0003 29.95 0.0005 31.05 0.0017
  1854. 32.14 0.0002 33.29 0.0003 37.88 0.0002 39.03 0.0002 40.19 0.0004
  1855. 41.37 0.0003 43.74 0.0002 46.20 0.0001 48.68 0.0001 49.93 0.0001
  1856. 51.19 0.0002 )
  1857. #( 1.00 0.0225 1.99 0.0921 2.98 0.0933 3.99 0.0365 4.99 0.0100
  1858. 5.98 0.0213 6.98 0.0049 7.98 0.0041 8.98 0.0090 9.99 0.0068
  1859. 11.01 0.0040 12.03 0.0086 13.02 0.0015 14.04 0.0071 15.09 0.0082
  1860. 16.14 0.0011 17.15 0.0014 18.18 0.0010 19.26 0.0013 20.26 0.0005
  1861. 21.33 0.0006 22.36 0.0011 23.46 0.0016 24.52 0.0004 25.59 0.0002
  1862. 26.70 0.0006 27.78 0.0007 28.87 0.0002 30.03 0.0008 31.14 0.0010
  1863. 32.24 0.0006 33.37 0.0002 35.67 0.0003 37.99 0.0004 39.17 0.0004
  1864. 40.35 0.0005 41.53 0.0001 46.42 0.0001 )
  1865. #( 1.00 0.0465 1.99 0.0976 2.98 0.0678 4.00 0.0727 4.99 0.0305
  1866. 5.98 0.0210 6.98 0.0227 8.00 0.0085 9.01 0.0183 10.02 0.0258
  1867. 11.05 0.0003 12.06 0.0061 13.05 0.0021 14.10 0.0089 15.12 0.0077
  1868. 16.16 0.0016 17.21 0.0061 18.23 0.0011 19.29 0.0031 20.36 0.0031
  1869. 21.41 0.0007 22.48 0.0013 23.55 0.0020 24.64 0.0004 25.74 0.0005
  1870. 26.81 0.0006 27.95 0.0006 29.03 0.0001 30.22 0.0010 31.30 0.0004
  1871. 32.48 0.0001 33.60 0.0002 38.30 0.0003 )
  1872. #( 1.00 0.0674 1.99 0.0841 2.98 0.0920 3.99 0.0328 4.99 0.0368
  1873. 5.98 0.0206 6.99 0.0246 8.01 0.0048 9.01 0.0218 10.03 0.0155
  1874. 11.05 0.0048 12.06 0.0077 13.00 0.0020 14.10 0.0083 15.15 0.0084
  1875. 16.18 0.0015 17.22 0.0039 18.27 0.0032 19.34 0.0026 20.40 0.0012
  1876. 21.47 0.0009 22.54 0.0008 23.62 0.0016 24.71 0.0005 25.82 0.0004
  1877. 26.91 0.0002 28.03 0.0008 29.17 0.0002 30.32 0.0028 31.45 0.0004
  1878. 32.61 0.0005 33.77 0.0001 36.14 0.0003 37.32 0.0002 38.54 0.0005
  1879. 39.75 0.0002 42.23 0.0002 48.65 0.0001 )
  1880. #( 1.01 0.0423 1.99 0.0240 2.98 0.0517 4.00 0.0493 5.00 0.0324
  1881. 6.00 0.0094 6.99 0.0449 7.99 0.0050 9.00 0.0197 10.03 0.0132
  1882. 11.03 0.0009 12.07 0.0017 13.08 0.0023 14.12 0.0094 15.16 0.0071
  1883. 16.21 0.0020 17.25 0.0005 18.30 0.0027 19.04 0.0004 20.43 0.0022
  1884. 21.51 0.0002 22.59 0.0006 23.72 0.0018 24.80 0.0002 25.88 0.0002
  1885. 27.03 0.0002 28.09 0.0006 29.31 0.0002 30.46 0.0004 31.61 0.0007
  1886. 32.78 0.0005 33.95 0.0001 36.34 0.0002 37.56 0.0001 38.80 0.0001
  1887. 40.02 0.0001 44.14 0.0001 )
  1888. #( 1.00 0.0669 1.99 0.0909 2.99 0.0410 3.98 0.0292 4.98 0.0259
  1889. 5.98 0.0148 6.98 0.0319 7.99 0.0076 9.01 0.0056 10.02 0.0206
  1890. 11.04 0.0032 12.05 0.0085 13.08 0.0040 14.12 0.0037 15.16 0.0030
  1891. 16.20 0.0013 17.24 0.0021 18.30 0.0010 19.36 0.0015 20.44 0.0013
  1892. 21.50 0.0009 22.60 0.0015 23.69 0.0014 24.80 0.0006 25.87 0.0002
  1893. 27.02 0.0006 28.12 0.0002 29.28 0.0003 30.43 0.0002 31.59 0.0007
  1894. 32.79 0.0001 35.14 0.0001 37.57 0.0001 40.03 0.0002 41.28 0.0004
  1895. 44.10 0.0001 )
  1896. #( 0.99 0.0421 1.99 0.1541 2.98 0.0596 3.98 0.0309 4.98 0.0301
  1897. 5.99 0.0103 7.00 0.0240 8.01 0.0073 9.01 0.0222 10.04 0.0140
  1898. 11.05 0.0033 12.08 0.0045 13.13 0.0009 14.13 0.0015 15.21 0.0026
  1899. 16.24 0.0003 17.30 0.0004 18.35 0.0010 19.39 0.0003 20.50 0.0015
  1900. 21.57 0.0003 22.68 0.0011 23.80 0.0005 24.90 0.0008 26.02 0.0002
  1901. 27.16 0.0001 28.30 0.0006 29.48 0.0002 31.81 0.0005 33.00 0.0003
  1902. 34.21 0.0001 37.89 0.0001 )
  1903. #( 0.99 0.0389 2.00 0.2095 3.00 0.0835 3.99 0.0289 5.00 0.0578
  1904. 5.99 0.0363 7.01 0.0387 8.01 0.0056 9.04 0.0173 10.05 0.0175
  1905. 11.08 0.0053 12.10 0.0056 13.15 0.0064 14.19 0.0036 15.22 0.0019
  1906. 16.29 0.0010 17.36 0.0017 18.43 0.0018 19.51 0.0004 20.60 0.0011
  1907. 21.70 0.0003 22.82 0.0003 23.95 0.0001 25.05 0.0004 26.17 0.0001
  1908. 28.50 0.0003 29.68 0.0001 32.07 0.0003 33.28 0.0004 34.52 0.0001 )
  1909. #( 1.00 0.1238 1.99 0.2270 3.00 0.0102 3.99 0.0181 4.98 0.0415
  1910. 6.00 0.0165 7.01 0.0314 8.02 0.0148 9.04 0.0203 10.05 0.0088
  1911. 11.07 0.0062 12.11 0.0070 13.14 0.0054 14.19 0.0028 15.24 0.0044
  1912. 16.30 0.0029 17.38 0.0009 18.45 0.0026 19.56 0.0003 20.65 0.0025
  1913. 21.74 0.0014 22.87 0.0013 23.99 0.0007 25.15 0.0002 27.46 0.0004
  1914. 28.39 0.0006 28.65 0.0004 29.85 0.0001 31.05 0.0002 32.27 0.0003
  1915. 33.52 0.0002 34.76 0.0003 )
  1916. #( 1.00 0.1054 2.00 0.2598 2.99 0.0369 3.98 0.0523 4.99 0.0020
  1917. 5.99 0.0051 7.00 0.0268 8.01 0.0027 9.04 0.0029 10.05 0.0081
  1918. 11.08 0.0047 12.12 0.0051 13.16 0.0091 14.19 0.0015 15.27 0.0030
  1919. 16.34 0.0017 17.42 0.0006 18.51 0.0003 19.61 0.0007 20.72 0.0003
  1920. 21.84 0.0001 22.99 0.0010 24.13 0.0001 28.44 0.0001 30.09 0.0001 )
  1921. #( 0.99 0.0919 2.00 0.0418 2.99 0.0498 3.99 0.0135 4.99 0.0026
  1922. 6.00 0.0155 7.01 0.0340 8.02 0.0033 9.04 0.0218 10.08 0.0084
  1923. 11.11 0.0057 12.15 0.0051 13.21 0.0043 14.25 0.0015 15.31 0.0023
  1924. 16.40 0.0008 17.48 0.0004 18.59 0.0016 19.71 0.0010 20.84 0.0018
  1925. 21.98 0.0002 23.11 0.0013 24.26 0.0003 26.67 0.0002 29.12 0.0002
  1926. 30.37 0.0002 31.62 0.0003 32.92 0.0001 )
  1927. #( 0.99 0.1174 1.99 0.1126 2.99 0.0370 3.99 0.0159 5.01 0.0472
  1928. 6.01 0.0091 7.03 0.0211 8.05 0.0015 9.07 0.0098 10.11 0.0038
  1929. 11.15 0.0042 12.20 0.0018 13.24 0.0041 14.32 0.0033 15.41 0.0052
  1930. 16.49 0.0001 17.61 0.0004 18.71 0.0004 19.84 0.0004 20.99 0.0002
  1931. 22.14 0.0006 23.31 0.0006 24.50 0.0004 25.70 0.0002 28.09 0.0002
  1932. 28.66 0.0002 32.00 0.0001 )
  1933. #( 1.00 0.1085 2.00 0.1400 2.99 0.0173 3.99 0.0229 5.00 0.0272
  1934. 6.02 0.0077 7.03 0.0069 8.04 0.0017 9.08 0.0045 10.10 0.0030
  1935. 11.15 0.0040 12.20 0.0007 13.25 0.0019 14.32 0.0008 15.42 0.0024
  1936. 16.50 0.0002 17.59 0.0005 18.71 0.0003 19.83 0.0002 20.98 0.0005
  1937. 23.29 0.0008 )
  1938. #( 1.00 0.0985 2.00 0.1440 2.99 0.0364 3.99 0.0425 5.00 0.0190
  1939. 6.01 0.0089 7.03 0.0278 8.04 0.0006 9.07 0.0083 10.10 0.0021
  1940. 11.14 0.0050 12.18 0.0005 13.26 0.0036 14.33 0.0005 15.41 0.0026
  1941. 17.62 0.0004 18.75 0.0004 19.89 0.0003 21.04 0.0012 22.21 0.0002
  1942. 23.38 0.0004 27.04 0.0001 )
  1943. #( 0.99 0.1273 2.00 0.1311 2.99 0.0120 4.00 0.0099 5.00 0.0235
  1944. 6.02 0.0068 7.03 0.0162 8.06 0.0009 9.08 0.0083 10.12 0.0014
  1945. 11.17 0.0050 12.24 0.0010 13.29 0.0013 14.39 0.0022 15.48 0.0011
  1946. 16.59 0.0002 17.70 0.0003 18.84 0.0010 20.00 0.0003 21.17 0.0003
  1947. 23.56 0.0004 28.79 0.0003 )
  1948. #( 1.00 0.1018 2.00 0.1486 3.00 0.0165 4.00 0.0186 5.01 0.0194
  1949. 6.02 0.0045 7.04 0.0083 8.06 0.0012 9.10 0.0066 10.15 0.0009
  1950. 11.19 0.0008 12.26 0.0011 13.34 0.0028 14.45 0.0006 15.53 0.0009
  1951. 16.66 0.0002 17.79 0.0006 18.94 0.0005 20.11 0.0003 21.29 0.0005
  1952. 22.49 0.0003 23.73 0.0005 26.22 0.0001 27.52 0.0001 28.88 0.0002 )
  1953. #( 1.00 0.1889 1.99 0.1822 3.00 0.0363 4.00 0.0047 5.01 0.0202
  1954. 6.03 0.0053 7.05 0.0114 8.01 0.0002 9.13 0.0048 10.17 0.0010
  1955. 11.23 0.0033 12.30 0.0010 13.38 0.0006 14.50 0.0002 15.62 0.0010
  1956. 20.27 0.0001 21.47 0.0001 )
  1957. #( 1.00 0.0522 1.99 0.0763 2.99 0.0404 4.00 0.0139 5.01 0.0185
  1958. 6.01 0.0021 7.06 0.0045 8.09 0.0002 9.11 0.0003 10.17 0.0006
  1959. 11.25 0.0004 12.32 0.0005 13.40 0.0003 14.53 0.0003 15.65 0.0007
  1960. 16.80 0.0001 17.95 0.0002 19.14 0.0006 20.34 0.0002 21.56 0.0003 )
  1961. #( 0.99 0.1821 1.99 0.0773 3.00 0.0125 4.01 0.0065 5.01 0.0202
  1962. 6.03 0.0071 7.05 0.0090 8.08 0.0006 9.13 0.0008 10.18 0.0013
  1963. 11.25 0.0010 12.33 0.0012 13.42 0.0006 14.54 0.0005 15.65 0.0004
  1964. 17.97 0.0002 19.15 0.0001 )
  1965. #( 1.00 0.1868 2.00 0.0951 3.00 0.0147 4.01 0.0134 5.02 0.0184
  1966. 6.04 0.0132 7.06 0.0011 8.11 0.0008 9.15 0.0010 10.22 0.0012
  1967. 11.30 0.0011 12.40 0.0003 13.11 0.0004 13.49 0.0002 14.62 0.0003
  1968. 15.77 0.0001 )
  1969. #( 1.00 0.1933 2.00 0.0714 3.00 0.0373 4.00 0.0108 5.02 0.0094
  1970. 6.02 0.0010 7.07 0.0022 8.11 0.0002 9.16 0.0065 10.23 0.0015
  1971. 11.31 0.0023 12.40 0.0003 13.53 0.0014 14.66 0.0002 15.81 0.0011
  1972. 18.20 0.0002 19.41 0.0001 )
  1973. #( 0.99 0.2113 1.99 0.0877 3.00 0.0492 4.01 0.0094 5.02 0.0144
  1974. 6.04 0.0103 7.07 0.0117 8.12 0.0006 9.19 0.0019 10.25 0.0007
  1975. 11.35 0.0017 12.45 0.0010 13.58 0.0003 14.74 0.0003 15.91 0.0003
  1976. 19.57 0.0002 )
  1977. #( 0.99 0.2455 1.99 0.0161 3.00 0.0215 4.01 0.0036 5.03 0.0049
  1978. 6.04 0.0012 7.09 0.0036 8.14 0.0011 9.21 0.0009 10.30 0.0001
  1979. 11.40 0.0012 12.50 0.0001 13.66 0.0005 14.84 0.0001 )
  1980. #( 1.00 0.1132 2.00 0.0252 3.00 0.0292 4.01 0.0136 5.03 0.0045
  1981. 6.06 0.0022 7.11 0.0101 8.17 0.0004 9.23 0.0010 10.33 0.0012
  1982. 11.44 0.0013 12.58 0.0011 13.75 0.0002 14.93 0.0005 16.14 0.0002 )
  1983. #( 1.00 0.1655 2.00 0.0445 3.00 0.0120 4.00 0.0038 5.02 0.0015
  1984. 6.07 0.0038 7.11 0.0003 8.19 0.0002 9.25 0.0010 10.36 0.0011
  1985. 11.48 0.0005 12.63 0.0002 13.79 0.0003 16.24 0.0002 )
  1986. #( 0.99 0.3637 1.99 0.0259 3.01 0.0038 4.01 0.0057 5.03 0.0040
  1987. 6.07 0.0067 7.12 0.0014 8.19 0.0004 9.27 0.0003 10.38 0.0002
  1988. 12.67 0.0001 )
  1989. #( 1.00 0.1193 2.00 0.0230 3.00 0.0104 4.01 0.0084 5.04 0.0047
  1990. 6.08 0.0035 7.13 0.0041 8.20 0.0002 9.29 0.0005 10.40 0.0005
  1991. 11.53 0.0003 12.70 0.0002 13.91 0.0002 )
  1992. #( 1.00 0.0752 2.00 0.0497 3.00 0.0074 4.02 0.0076 5.05 0.0053
  1993. 6.09 0.0043 7.15 0.0024 8.22 0.0001 9.32 0.0006 10.45 0.0002
  1994. 11.58 0.0001 12.78 0.0001 15.22 0.0001 )
  1995. #( 1.00 0.2388 2.00 0.0629 3.01 0.0159 4.04 0.0063 5.07 0.0051
  1996. 6.12 0.0045 7.19 0.0026 8.29 0.0015 9.43 0.0001 11.75 0.0002 )
  1997. #( 1.00 0.1919 2.01 0.0116 3.01 0.0031 4.03 0.0090 5.07 0.0061
  1998. 6.13 0.0036 7.19 0.0013 8.30 0.0016 9.13 0.0001 10.59 0.0002
  1999. 11.78 0.0002 )
  2000. #( 1.00 0.1296 2.00 0.0135 3.01 0.0041 4.04 0.0045 5.09 0.0028
  2001. 6.14 0.0046 7.23 0.0007 8.32 0.0007 9.50 0.0001 )
  2002. #( 1.00 0.0692 2.00 0.0209 3.02 0.0025 4.05 0.0030 5.09 0.0047
  2003. 6.17 0.0022 7.25 0.0015 8.36 0.0015 9.53 0.0010 10.69 0.0001
  2004. 13.40 0.0001 )
  2005. #( 1.00 0.1715 2.00 0.0142 3.01 0.0024 4.03 0.0015 5.07 0.0017
  2006. 6.13 0.0018 7.22 0.0009 8.33 0.0014 9.51 0.0007 10.69 0.0002 )
  2007. #( 1.00 0.1555 2.01 0.0148 3.02 0.0007 4.06 0.0006 5.10 0.0005
  2008. 6.16 0.0008 7.26 0.0009 8.39 0.0008 9.58 0.0002 )
  2009. #( 1.00 0.1357 2.00 0.0116 3.02 0.0026 4.04 0.0009 5.09 0.0004
  2010. 6.17 0.0005 7.27 0.0002 8.40 0.0001 )
  2011. #( 1.00 0.2185 2.01 0.0087 3.03 0.0018 4.06 0.0025 5.11 0.0020
  2012. 6.20 0.0012 7.32 0.0005 8.46 0.0001 9.66 0.0003 )
  2013. #( 1.00 0.2735 2.00 0.0038 3.02 0.0008 4.06 0.0012 5.12 0.0008
  2014. 6.22 0.0011 7.35 0.0003 8.50 0.0002 )
  2015. #( 1.00 0.1441 1.99 0.0062 3.01 0.0023 4.05 0.0011 5.11 0.0012
  2016. 6.20 0.0003 7.33 0.0004 8.50 0.0001 )
  2017. #( 1.00 0.0726 2.01 0.0293 3.03 0.0022 5.14 0.0005 6.26 0.0011
  2018. 7.41 0.0002 8.63 0.0002 )
  2019. #( 1.00 0.0516 2.00 0.0104 3.02 0.0029 5.15 0.0002 6.27 0.0001 )
  2020. #( 1.00 0.0329 2.00 0.0033 3.03 0.0013 4.10 0.0005 5.19 0.0004
  2021. 6.32 0.0002 )
  2022. #( 1.00 0.0179 1.99 0.0012 3.04 0.0005 4.10 0.0017 5.20 0.0005
  2023. 6.35 0.0001 )
  2024. #( 1.00 0.0334 2.01 0.0033 3.04 0.0011 4.13 0.0003 5.22 0.0003 )
  2025. #( 0.99 0.0161 2.01 0.0100 3.04 0.0020 4.13 0.0003 )
  2026. #( 1.00 0.0475 1.99 0.0045 3.03 0.0035 4.12 0.0011 )
  2027. #( 1.00 0.0593 2.00 0.0014 4.17 0.0002 )
  2028. #( 1.00 0.0249 2.01 0.0016 )
  2029. #( 1.00 0.0242 2.00 0.0038 4.19 0.0002 )
  2030. #( 1.00 0.0170 2.02 0.0030 )
  2031. #( 1.00 0.0381 2.00 0.0017 3.09 0.0002 )
  2032. #( 1.00 0.0141 2.03 0.0005 3.11 0.0003 4.26 0.0001 )
  2033. #( 1.00 0.0122 2.03 0.0024 )
  2034. #( 1.00 0.0107 2.07 0.0007 3.12 0.0004 )
  2035. #( 1.00 0.0250 2.02 0.0026 3.15 0.0002 )
  2036. #( 1.01 0.0092 )
  2037. #( 1.01 0.0102 2.09 0.0005 )
  2038. #( 1.00 0.0080 2.00 0.0005 3.19 0.0001 )
  2039. #( 1.01 0.0298 2.01 0.0005 ) ) constant piano-spectra
  2040. 0.04 value *clm-piano-attack-duration*
  2041. 0.2 value *clm-piano-realease-duration*
  2042. -10 value *clm-db-drop-per-second*
  2043. \ This thing sounds pretty good down low, below middle c or so.
  2044. \ Unfortunately, there are some tens of partials down there and we're
  2045. \ using exponential envelopes. You're going to wait for a long long
  2046. \ time just to hear a single low note. The high notes sound pretty
  2047. \ rotten--they just don't sparkle; I have a feeling that this is due
  2048. \ to the low amplitude of the original data, and the lack of
  2049. \ mechanical noise.
  2050. \
  2051. \ The only thing you can do to alter the sound of a piano note is to
  2052. \ set the pfreq parameter. Pfreq is used to look up the partials. By
  2053. \ default, it's set to the requested frequency. Setting it to a
  2054. \ neighboring freq is useful when you're repeating notes. Note that
  2055. \ there's no nyquist detection; a high freq with a low pfreq, will
  2056. \ give you fold over (hmmm...maybe I can get those high notes to
  2057. \ sparkle after all).
  2058. instrument: lbj-piano <{ start dur freq amp
  2059. :key
  2060. degree 45.0
  2061. distance 1.0
  2062. reverb-amount 0.0 -- }>
  2063. piano-spectra 12.0 freq 32.703 f/ flog 2.0 flog f/ f* f>s array-ref normalize-partials { parts }
  2064. dur *clm-piano-attack-duration* *clm-piano-realease-duration* f+ f+ to dur
  2065. dur *clm-piano-realease-duration* f- { env1dur }
  2066. env1dur mus-srate f* fround->s { env1samples }
  2067. #( 0.0
  2068. 0.0
  2069. *clm-piano-attack-duration* 100.0 f* env1dur f/ 4.0 f/
  2070. 1.0
  2071. *clm-piano-attack-duration* 100.0 f* env1dur f/
  2072. 1.0
  2073. 100.0
  2074. *clm-db-drop-per-second* env1dur f* db->linear ) { ampfun1 }
  2075. :envelope ampfun1 :scaler amp :duration env1dur :base 10000.0 make-env { ampenv1 }
  2076. :envelope #( 0 1 100 0 )
  2077. :scaler amp ampfun1 -1 array-ref f*
  2078. :duration env1dur
  2079. :base 1.0 make-env { ampenv2 }
  2080. parts length 2/ 0.0 make-vct { alist }
  2081. parts length 2/ make-array map!
  2082. alist i parts i 2* 1+ array-ref vct-set! drop
  2083. :frequency parts i 2* array-ref freq f* make-oscil
  2084. end-map { oscils }
  2085. start dur #{ :degree degree :distance distance :reverb-amount reverb-amount } run-instrument
  2086. 0.0 ( sum ) oscils each ( os ) 0.0 0.0 oscil alist i vct-ref f* f+ end-each ( sum )
  2087. i env1samples > if ampenv2 else ampenv1 then env ( sum ) f*
  2088. end-run
  2089. ;instrument
  2090. : lbj-piano-test <{ :optional start 0.0 dur 1.0 -- }>
  2091. start now!
  2092. now@ dur 440 0.5 lbj-piano
  2093. dur 0.24 f+ 0.2 f+ step
  2094. ;
  2095. \ RESFLT
  2096. \ clm/resflt.ins
  2097. instrument: resflt <{ start dur
  2098. :key
  2099. driver #f
  2100. ranfreq 10000.0
  2101. noiamp 0.01
  2102. noifun #( 0 0 50 1 100 0 )
  2103. cosamp 0.1
  2104. cosfreq1 200.0
  2105. cosfreq0 230.0
  2106. cosnum 10
  2107. ampcosfun #( 0 0 50 1 100 0 )
  2108. freqcosfun #( 0 0 100 1 )
  2109. freq1 550.0
  2110. r1 0.995
  2111. g1 0.1
  2112. freq2 1000.0
  2113. r2 0.995
  2114. g2 0.1
  2115. freq3 2000.0
  2116. r3 0.995
  2117. g3 0.1
  2118. degree 0.0
  2119. distance 1.0 -- }>
  2120. doc" 0 1 <'> resflt with-sound"
  2121. :radius r1 :frequency freq1 make-two-pole { f1 }
  2122. :radius r2 :frequency freq2 make-two-pole { f2 }
  2123. :radius r3 :frequency freq3 make-two-pole { f3 }
  2124. nil nil nil { frqf ampf gen }
  2125. driver if
  2126. :envelope noifun :scaler noiamp :duration dur make-env to ampf
  2127. :frequency ranfreq make-rand to gen
  2128. else
  2129. :envelope freqcosfun :scaler cosfreq1 cosfreq0 f- hz->radians :duration dur make-env to frqf
  2130. :envelope ampcosfun :scaler cosamp :duration dur make-env to ampf
  2131. :frequency cosfreq0 :cosines cosnum make-sum-of-cosines to gen
  2132. then
  2133. start dur #{ :degree degree :distance distance } run-instrument
  2134. gen driver if 0.0 ( rand ) else frqf env ( sum-of-cosines ) then 0.0 mus-run ampf env f*
  2135. { input }
  2136. f1 input g1 f* two-pole
  2137. f2 input g2 f* two-pole f+
  2138. f3 input g3 f* two-pole f+
  2139. end-run
  2140. ;instrument
  2141. : resflt-test <{ :optional start 0.0 dur 1.0 -- }>
  2142. start now!
  2143. now@ dur :driver #f resflt
  2144. dur 0.2 f+ step
  2145. now@ dur :driver #t resflt
  2146. dur 0.2 f+ step
  2147. ;
  2148. hide
  2149. : scratch-input-cb { rd samp -- proc ; dir self -- r }
  2150. 1 proc-create samp , rd ,
  2151. does> { dir self -- r }
  2152. self @ { samp }
  2153. self cell+ @ { rd }
  2154. rd samp 0 file->sample \ (file->sample rd samp 0)
  2155. dir self +! \ samp += dir
  2156. ;
  2157. set-current
  2158. \ SCRATCH-INS
  2159. instrument: scratch-ins <{ start file src-ratio turntable -- }>
  2160. file find-file to file
  2161. file false? if 'file-not-found $" %s: cannot find %S" #( get-func-name file ) fth-raise then
  2162. file mus-sound-duration { dur }
  2163. file make-readin { f }
  2164. turntable 0 object-ref seconds->samples { cur-samp }
  2165. turntable 1 object-ref seconds->samples { turn-samp }
  2166. :input f cur-samp scratch-input-cb :srate src-ratio make-src { rd }
  2167. src-ratio f0> { forwards }
  2168. forwards turn-samp cur-samp < && if rd src-ratio fnegate set-mus-increment drop then
  2169. 1 { turn-i }
  2170. 0 { turning }
  2171. 0.0 0.0 { last-val1 last-val2 }
  2172. start dur #{ :degree 90.0 random } run-instrument
  2173. turn-i turntable length >= if leave then
  2174. rd 0.0 src { val }
  2175. turning unless
  2176. forwards cur-samp turn-samp >= && if
  2177. 1
  2178. else
  2179. forwards 0= cur-samp turn-samp <= &&
  2180. if
  2181. -1
  2182. else
  2183. turning
  2184. then
  2185. then to turning
  2186. else
  2187. last-val2 last-val1 f<= last-val1 val f>= &&
  2188. last-val2 last-val1 f>= last-val1 val f<= && || if
  2189. turn-i 1+ to turn-i
  2190. turn-i turntable length < if
  2191. turntable turn-i object-ref seconds->samples to turn-samp
  2192. forwards negate to forwards
  2193. rd rd mus-increment fnegate set-mus-increment drop
  2194. then
  2195. 0 to turning
  2196. then
  2197. then
  2198. last-val1 to last-val2
  2199. val to last-val1
  2200. val
  2201. end-run
  2202. f mus-close drop
  2203. ;instrument
  2204. previous
  2205. : scratch-test <{ :optional start 0.0 dur 1.0 -- }>
  2206. start now!
  2207. start "fyow.snd" dur 1.5 fmin #( 0 0.5 0.25 1 ) scratch-ins
  2208. "fyow.snd" find-file mus-sound-duration 0.2 f+ step
  2209. ;
  2210. \ PINS
  2211. \
  2212. \ spectral modeling (SMS)
  2213. instrument: pins <{ start dur file amp
  2214. :key
  2215. transposition 1.0
  2216. time-scaler 1.0
  2217. fftsize 256
  2218. highest-bin 128
  2219. max-peaks 16
  2220. attack #f -- }>
  2221. doc" start dur \"fyow.snd\" 1.0 :time-scaler 2.0 pins"
  2222. file find-file to file
  2223. file false? if 'file-not-found $" %s: cannot find %S" #( get-func-name file ) fth-raise then
  2224. file mus-sound-duration { fdur }
  2225. dur time-scaler f/ { sdur }
  2226. sdur fdur f> if
  2227. 'forth-error
  2228. $" %s is %.3f seconds long, but we'll need %.3f seconds of data for this note"
  2229. #( file fdur sdur ) fth-raise
  2230. then
  2231. file make-readin { fil }
  2232. fftsize make-vct { fdr }
  2233. fftsize make-vct { fdi }
  2234. blackman2-window fftsize 0.0 0.0 make-fft-window { win }
  2235. fftsize make-vct { fftamps }
  2236. max-peaks 2* { max-oscils }
  2237. max-oscils make-vct { current-peak-freqs }
  2238. max-oscils make-vct { last-peak-freqs }
  2239. max-oscils make-vct { current-peak-amps }
  2240. max-oscils make-vct { last-peak-amps }
  2241. max-peaks make-vct { peak-amps }
  2242. max-peaks make-vct { peak-freqs }
  2243. max-oscils make-array map! :frequency 0.0 make-oscil end-map { resynth-oscils }
  2244. max-oscils make-vct { ampls }
  2245. max-oscils make-vct { rates }
  2246. max-oscils make-vct { freqs }
  2247. max-oscils make-vct { sweeps }
  2248. fftsize 4.0 f/ fround->s { hop }
  2249. time-scaler hop f* fround->s { outhop }
  2250. outhop 1/f { ifreq }
  2251. ifreq hz->radians { ihifreq }
  2252. mus-srate fftsize f/ { fft-mag }
  2253. max-oscils { cur-oscils }
  2254. attack if attack else 0 then { ramped }
  2255. attack { splice-attack }
  2256. attack if attack else 1 then { attack-size }
  2257. 0.0 { ramp-ind }
  2258. attack-size make-vct { ramped-attack }
  2259. outhop { trigger }
  2260. win fftsize 0.42323 f* 1/f vct-scale! drop
  2261. 0 { filptr }
  2262. start dur #{ :degree 90.0 random } run-instrument
  2263. splice-attack if
  2264. attack-size 1/f { ramp }
  2265. fil filptr 0 file->sample amp f* ( outval )
  2266. filptr 1+ to filptr
  2267. filptr attack-size > if
  2268. 1 { mult }
  2269. ramped-attack map!
  2270. fil filptr i + 0 file->sample mult f*
  2271. mult ramp f- to mult
  2272. end-map drop
  2273. #f to splice-attack
  2274. then
  2275. ( outval )
  2276. else
  2277. trigger outhop >= if
  2278. 0 { peaks }
  2279. 0 to trigger
  2280. fdr map! fil filptr i + 0 file->sample win i vct-ref f* end-map drop
  2281. filptr fdr vct-length + to filptr
  2282. fdi 0.0 vct-fill! drop
  2283. filptr fftsize hop - - to filptr
  2284. fdr fdi fftsize 1 mus-fft drop
  2285. highest-bin 0 ?do
  2286. fftamps i fdr i vct-ref dup f* fdi i vct-ref dup f* f+ fsqrt f2* vct-set! drop
  2287. loop
  2288. current-peak-freqs each { fv }
  2289. current-peak-amps i vct-ref { av }
  2290. last-peak-freqs i fv vct-set! drop
  2291. last-peak-amps i av vct-set! drop
  2292. current-peak-amps i 0.0 vct-set! drop
  2293. end-each
  2294. peak-amps 0.0 vct-fill! drop
  2295. fftamps 0 vct-ref { ra }
  2296. 0.0 0.0 { la ca }
  2297. highest-bin 0 ?do
  2298. ca to la
  2299. ra to ca
  2300. fftamps i vct-ref to ra
  2301. ca 0.001 f>
  2302. ca ra f> &&
  2303. ca la f> && if
  2304. la flog10 ra flog10 f- f2/ la flog10 -2.0 ca flog10 f* f+ ra flog10 f+ f/ { offset }
  2305. 10.0 ca flog10 0.25 la flog10 ra flog10 f- f* offset f* f- f** { amp-1 }
  2306. fft-mag i offset -1.0 f+ f+ f* { freq }
  2307. peaks max-peaks = if
  2308. 0 { minp }
  2309. peak-amps 0 vct-ref { minpeak }
  2310. max-peaks 1 ?do
  2311. peak-amps i vct-ref minpeak f< if
  2312. i to minp
  2313. peak-amps i vct-ref to minpeak
  2314. then
  2315. loop
  2316. amp-1 minpeak f> if
  2317. peak-freqs minp freq vct-set! drop
  2318. peak-amps minp amp-1 vct-set! drop
  2319. then
  2320. else
  2321. peak-freqs peaks freq vct-set! drop
  2322. peak-amps peaks amp-1 vct-set! drop
  2323. peaks 1+ to peaks
  2324. then
  2325. then
  2326. loop
  2327. peaks 0 ?do
  2328. 0 { maxp }
  2329. peak-amps 0 vct-ref ( maxpk )
  2330. max-peaks 1 ?do
  2331. peak-amps i vct-ref over f> if
  2332. i to maxp
  2333. drop ( maxpk )
  2334. peak-amps i vct-ref ( maxpk )
  2335. then
  2336. loop
  2337. ( maxpk ) f0> if
  2338. -1 { closestp }
  2339. 10 { closestamp }
  2340. peak-freqs maxp vct-ref { cur-freq }
  2341. cur-freq 1/f { icf }
  2342. max-peaks 0 ?do
  2343. last-peak-amps i vct-ref f0> if
  2344. icf last-peak-freqs i vct-ref cur-freq f- fabs f* { closeness }
  2345. closeness closestamp f< if
  2346. closeness to closestamp
  2347. i to closestp
  2348. then
  2349. then
  2350. loop
  2351. closestamp 0.1 f< if
  2352. current-peak-amps closestp peak-amps maxp vct-ref vct-set! drop
  2353. peak-amps maxp 0.0 vct-set! drop
  2354. current-peak-freqs closestp cur-freq vct-set! drop
  2355. then
  2356. then
  2357. loop
  2358. max-peaks 0 ?do
  2359. peak-amps i vct-ref f0> if
  2360. -1 { new-place }
  2361. max-oscils 0 ?do
  2362. last-peak-amps i vct-ref f0= current-peak-amps i vct-ref f0= && if
  2363. i to new-place
  2364. leave
  2365. then
  2366. loop
  2367. current-peak-amps new-place peak-amps i vct-ref vct-set! drop
  2368. peak-amps i 0.0 vct-set! drop
  2369. current-peak-freqs new-place peak-freqs i vct-ref vct-set! drop
  2370. last-peak-freqs new-place peak-freqs i vct-ref vct-set! drop
  2371. resynth-oscils new-place array-ref ( gen )
  2372. transposition peak-freqs i vct-ref f* ( val )
  2373. set-mus-frequency drop
  2374. then
  2375. loop
  2376. 0 to cur-oscils
  2377. max-oscils 0 ?do
  2378. rates i current-peak-amps i vct-ref last-peak-amps i vct-ref f- ifreq f* vct-set! drop
  2379. current-peak-amps i vct-ref f0<> last-peak-amps i vct-ref f0<> || if
  2380. i to cur-oscils
  2381. then
  2382. sweeps i
  2383. current-peak-freqs i vct-ref last-peak-freqs i vct-ref f- transposition f* ihifreq f*
  2384. vct-set! drop
  2385. loop
  2386. cur-oscils 1+ to cur-oscils
  2387. then
  2388. trigger 1+ to trigger
  2389. ramped 0= if
  2390. 0.0 ( sum )
  2391. else
  2392. ramped-attack ramp-ind vct-ref ( sum )
  2393. ramp-ind 1+ to ramp-ind
  2394. ramp-ind ramped = if 0 to ramp-ind then
  2395. then ( sum )
  2396. cur-oscils 0 ?do
  2397. ampls i vct-ref f0<> rates i vct-ref f0<> || if
  2398. resynth-oscils i array-ref freqs i vct-ref 0.0 oscil
  2399. ampls i vct-ref f* f+ ( sum += ... )
  2400. ampls i rates i vct-ref object-set+!
  2401. freqs i sweeps i vct-ref object-set+!
  2402. then
  2403. loop
  2404. amp ( sum ) f*
  2405. then
  2406. end-run
  2407. ;instrument
  2408. : pins-test <{ :optional start 0.0 dur 1.0 -- }>
  2409. start now!
  2410. now@ dur "fyow.snd" 1.0 :time-scaler 2.0 pins
  2411. dur 0.2 f+ step
  2412. ;
  2413. \ ZC
  2414. instrument: zc <{ start dur freq amp len1 len2 feedback -- }>
  2415. :frequency freq make-pulse-train { s }
  2416. :size len1 :scaler feedback :max-size len1 len2 max 1+ make-comb { d0 }
  2417. :envelope #( 0 0 1 1 ) :scaler len2 len1 f- :duration dur make-env { zenv }
  2418. start dur #{ :degree 90.0 random } run-instrument
  2419. d0 s 0.0 pulse-train amp f* zenv env comb
  2420. end-run
  2421. ;instrument
  2422. : zc-test <{ :optional start 0.0 dur 1.0 -- }>
  2423. start now!
  2424. now@ dur 100 0.4 20 100 0.95 zc
  2425. dur 0.2 f+ step
  2426. now@ dur 100 0.4 100 20 0.95 zc
  2427. dur 0.2 f+ step
  2428. ;
  2429. \ ZN
  2430. \
  2431. \ notches are spaced at srate/len, feedforward sets depth thereof so
  2432. \ sweep of len from 20 to 100 sweeps the notches down from 1000 Hz to
  2433. \ ca 200 Hz so we hear our downward glissando beneath the pulses.
  2434. instrument: zn <{ start dur freq amp len1 len2 feedforward -- }>
  2435. :frequency freq make-pulse-train { s }
  2436. :size len1 :scaler feedforward :max-size len1 len2 max 1+ make-notch { d0 }
  2437. :envelope #( 0 0 1 1 ) :scaler len2 len1 f- :duration dur make-env { zenv }
  2438. start dur #{ :degree 90.0 random } run-instrument
  2439. d0 s 0.0 pulse-train amp f* zenv env notch
  2440. end-run
  2441. ;instrument
  2442. : zn-test <{ :optional start 0.0 dur 1.0 -- }>
  2443. start now!
  2444. now@ dur 100 0.5 20 100 0.95 zn
  2445. dur 0.2 f+ step
  2446. now@ dur 100 0.5 100 20 0.95 zn
  2447. dur 0.2 f+ step
  2448. ;
  2449. \ ZA
  2450. instrument: za <{ start dur freq amp len1 len2 fb ffw -- }>
  2451. :frequency freq make-pulse-train { s }
  2452. :size len1 :feedback fb :feedforward ffw :max-size len1 len2 max 1+ make-all-pass { d0 }
  2453. :envelope #( 0 0 1 1 ) :scaler len2 len1 f- :duration dur make-env { zenv }
  2454. start dur #{ :degree 90.0 random } run-instrument
  2455. d0 s 0.0 pulse-train amp f* zenv env all-pass
  2456. end-run
  2457. ;instrument
  2458. : za-test <{ :optional start 0.0 dur 1.0 -- }>
  2459. start now!
  2460. now@ dur 100 0.3 20 100 0.95 0.95 za
  2461. dur 0.2 f+ step
  2462. now@ dur 100 0.3 100 20 0.95 0.95 za
  2463. dur 0.2 f+ step
  2464. ;
  2465. hide
  2466. : clm-src-cb { gen -- proc; dir self -- r }
  2467. 1 proc-create gen ,
  2468. does> ( dir self -- r )
  2469. nip @ ( gen ) #f #f granulate
  2470. ;
  2471. set-current
  2472. \ CLM-EXPSRC
  2473. instrument: clm-expsrc <{ start dur in-file exp-ratio src-ratio amp
  2474. :optional
  2475. rev #f
  2476. start-in-file 0 -- }>
  2477. in-file find-file to in-file
  2478. in-file false? if 'file-not-found $" %s: cannot find %S" #( get-func-name in-file ) fth-raise then
  2479. start-in-file in-file mus-sound-srate f* fround->s { stf }
  2480. :file in-file :channel 0 :start stf make-readin { fdA }
  2481. :input fdA readin-cb :expansion exp-ratio make-granulate { exA }
  2482. in-file mus-sound-chans 2 = *output* mus-channels 2 = && { two-chans }
  2483. two-chans if :file in-file :channel 1 :start stf make-readin else #f then { fdB }
  2484. :input fdB readin-cb :expansion exp-ratio make-granulate { exB }
  2485. :input exA clm-src-cb :srate src-ratio make-src { srcA }
  2486. two-chans if :input exB clm-src-cb :srate src-ratio make-src else #f then { srcB }
  2487. *reverb* rev && { revit }
  2488. revit if two-chans if rev f2/ else rev then else 0.0 then { rev-amp }
  2489. start dur run
  2490. srcA 0.0 src amp f* { valA }
  2491. two-chans if srcB 0.0 src amp f* else 0.0 then { valB }
  2492. i valA 0 *output* out-any drop
  2493. two-chans if i valB 1 *output* out-any drop then
  2494. revit if i valA valB f+ rev-amp f* 0 *reverb* out-any drop then
  2495. loop
  2496. ;instrument
  2497. previous
  2498. : clm-expsrc-test <{ :optional start 0.0 dur 1.0 -- }>
  2499. start now!
  2500. now@ dur "oboe.snd" 2.0 1.0 1.0 clm-expsrc
  2501. dur 0.2 f+ step
  2502. ;
  2503. \ EXP-SND
  2504. instrument: exp-snd <{ file start dur amp
  2505. :optional
  2506. exp-amt 1.0
  2507. ramp 0.4
  2508. seglen 0.15
  2509. sr 1.0
  2510. hop 0.05
  2511. ampenv #f -- }>
  2512. doc" ;; granulate with envelopes on the expansion amount, segment envelope shape,\n\
  2513. ;; segment length, hop length, and input file resampling rate\n\
  2514. \"fyow.snd\" 0 3 1 #( 0 1 1 3 ) 0.4 0.15 #( 0 2 1 0.5 ) 0.05 <'> exp-snd with-sound\n\
  2515. \"oboe.snd\" 0 3 1 #( 0 1 1 3 ) 0.4 0.15 #( 0 2 1 0.5 ) 0.2 <'> exp-snd with-sound"
  2516. file find-file to file
  2517. file false? if 'file-not-found $" %s: cannot find %S" #( get-func-name file ) fth-raise then
  2518. file 0 make-readin { f0 }
  2519. :envelope exp-amt array? if exp-amt else #( 0 exp-amt 1 exp-amt ) then
  2520. :duration dur make-env { expenv }
  2521. :envelope seglen array? if seglen else #( 0 seglen 1 seglen ) then
  2522. :duration dur make-env { lenenv }
  2523. seglen if
  2524. seglen array? if seglen max-envelope else seglen then
  2525. else
  2526. 0.15
  2527. then { max-seg-len }
  2528. seglen if
  2529. seglen array? if seglen 1 array-ref else seglen then
  2530. else
  2531. 0.15
  2532. then { initial-seg-len }
  2533. max-seg-len 0.15 f> if 0.6 0.15 f* max-seg-len f/ else 0.6 then { scaler-amp }
  2534. :envelope sr array? if sr else #( 0 sr 1 sr ) then
  2535. :duration dur make-env { srenv }
  2536. ramp array? if ramp else #( 0 ramp 1 ramp ) then { rampdata }
  2537. :envelope rampdata :duration dur make-env { rampenv }
  2538. ramp if
  2539. ramp array? if ramp 1 array-ref else ramp then
  2540. else
  2541. 0.4
  2542. then { initial-ramp-time }
  2543. :envelope hop array? if hop else #( 0 hop 1 hop ) then
  2544. :duration dur make-env { hopenv }
  2545. hop if
  2546. hop array? if hop max-envelope else hop then
  2547. else
  2548. 0.05
  2549. then { max-out-hop }
  2550. hop if
  2551. hop array? if hop 1 array-ref else hop then
  2552. else
  2553. 0.05
  2554. then { initial-out-hop }
  2555. exp-amt if
  2556. exp-amt array? if exp-amt min-envelope else exp-amt then
  2557. else
  2558. 1.0
  2559. then { min-exp-amt }
  2560. exp-amt if
  2561. exp-amt array? if exp-amt 1 array-ref else exp-amt then
  2562. else
  2563. 1.0
  2564. then { initial-exp-amt }
  2565. max-out-hop min-exp-amt f/ { max-in-hop }
  2566. :envelope ampenv #( 0 0 0.5 1 1 0 ) || :scaler amp :duration dur make-env { ampe }
  2567. :input f0 readin-cb
  2568. :expansion initial-exp-amt
  2569. :max-size max-out-hop max-in-hop fmax max-seg-len f+ mus-srate f* fceil f>s
  2570. :ramp initial-ramp-time
  2571. :hop initial-out-hop
  2572. :length initial-seg-len
  2573. :scaler scaler-amp make-granulate { ex-a }
  2574. ampe env { vol }
  2575. ex-a granulate vol f* { val-a0 }
  2576. ex-a granulate vol f* { val-a1 }
  2577. rampdata min-envelope f0<= rampdata max-envelope 0.5 f>= || if
  2578. 'forth-error
  2579. $" ramp argument to expand must always be between 0.0 and 0.5, %.3f -- %.3f"
  2580. #( rampdata min-envelope rampdata max-envelope ) fth-raise
  2581. then
  2582. 0.0 0.0 { ex-samp next-samp }
  2583. 0.0 0.0 0.0 0.0 0.0 { expa segl resa rmpl hp }
  2584. 0 0 { sl rl }
  2585. start dur #{ :degree 90.0 random } run-instrument
  2586. expenv env to expa
  2587. lenenv env to segl
  2588. srenv env to resa
  2589. rampenv env to rmpl
  2590. hopenv env to hp
  2591. segl mus-srate f* floor dup f>s to sl
  2592. ( fsl ) rmpl f* floor f>s to rl
  2593. ampe env to vol
  2594. ex-a sl set-mus-length drop
  2595. ex-a rl set-mus-ramp drop
  2596. ex-a hp set-mus-frequency drop
  2597. ex-a expa set-mus-increment drop
  2598. resa +to next-samp
  2599. next-samp ex-samp 1.0 f+ f> if
  2600. next-samp ex-samp f- fround->s 0 ?do
  2601. val-a1 to val-a0
  2602. ex-a granulate vol f* to val-a1
  2603. 1.0 +to ex-samp
  2604. loop
  2605. then
  2606. next-samp ex-samp f= if
  2607. val-a0
  2608. else
  2609. next-samp ex-samp f- val-a1 val-a0 f- f* val-a0 f+
  2610. then
  2611. end-run
  2612. ;instrument
  2613. : exp-snd-test <{ :optional start 0.0 dur 1.0 -- }>
  2614. start now!
  2615. "fyow.snd" now@ dur 1.0 #( 0 1 1 3 ) 0.4 0.15 #( 0 2 1 0.5 ) 0.05 exp-snd
  2616. dur 0.2 f+ step
  2617. "oboe.snd" now@ dur 1.0 #( 0 1 1 3 ) 0.4 0.15 #( 0 2 1 0.5 ) 0.2 exp-snd
  2618. dur 0.2 f+ step
  2619. ;
  2620. struct
  2621. cell% field exp-rampval
  2622. cell% field exp-rampinc
  2623. cell% field exp-loc
  2624. cell% field exp-segctr
  2625. cell% field exp-whichseg
  2626. cell% field exp-ramplen
  2627. cell% field exp-steadylen
  2628. cell% field exp-trigger
  2629. end-struct grn%
  2630. \ EXPFIL
  2631. instrument: expfil <{ start dur hopsecs rampsecs steadysecs file1 file2 -- }>
  2632. rampsecs seconds->samples { ramplen }
  2633. grn% %alloc { grn1 }
  2634. grn% %alloc { grn2 }
  2635. 0.0 0.0 grn1 exp-rampval ! grn2 exp-rampval !
  2636. ramplen 1/f dup grn1 exp-rampinc ! grn2 exp-rampinc !
  2637. 0 0 grn1 exp-loc ! grn2 exp-loc !
  2638. 0 0 grn1 exp-segctr ! grn2 exp-segctr !
  2639. 0 0 grn1 exp-whichseg ! grn2 exp-whichseg !
  2640. ramplen dup grn1 exp-ramplen ! grn2 exp-ramplen !
  2641. steadysecs seconds->samples dup grn1 exp-steadylen ! grn2 exp-steadylen !
  2642. 0 0 grn1 exp-trigger ! grn2 exp-trigger !
  2643. hopsecs seconds->samples { hop }
  2644. start seconds->samples { out1 }
  2645. hop out1 + { out2 }
  2646. file1 find-file to file1
  2647. file1 false? if 'file-not-found $" %s: cannot find %S" #( get-func-name file1 ) fth-raise then
  2648. file1 0 make-readin { fil1 }
  2649. file2 find-file to file2
  2650. file2 false? if 'file-not-found $" %s: cannot find %S" #( get-func-name file2 ) fth-raise then
  2651. file2 0 make-readin { fil2 }
  2652. 0.0 { inval }
  2653. start dur #{ :degree 90.0 random } run-instrument
  2654. 0.0 ( val )
  2655. i out1 = if
  2656. fil1 grn1 exp-loc @ 0 file->sample to inval
  2657. 1 grn1 exp-loc +!
  2658. grn1 exp-whichseg @ case
  2659. 0 of
  2660. grn1 exp-rampval @ inval f* to inval
  2661. grn1 exp-rampinc @ grn1 exp-rampval +!
  2662. 1 grn1 exp-segctr +!
  2663. grn1 exp-segctr @ grn1 exp-ramplen @ = if
  2664. 0 grn1 exp-segctr !
  2665. 1 grn1 exp-whichseg +!
  2666. then
  2667. endof
  2668. 1 of
  2669. 1 grn1 exp-segctr +!
  2670. grn1 exp-segctr @ grn1 exp-steadylen @ = if
  2671. 0 grn1 exp-segctr !
  2672. 1 grn1 exp-whichseg +!
  2673. then
  2674. endof
  2675. grn1 exp-rampval @ inval f* to inval
  2676. 1 grn1 exp-segctr +!
  2677. grn1 exp-rampinc @ fnegate grn1 exp-rampval +!
  2678. grn1 exp-segctr @ grn1 exp-ramplen @ = if
  2679. 0 grn1 exp-segctr !
  2680. 1 grn1 exp-trigger !
  2681. 0 grn1 exp-whichseg !
  2682. 0.0 grn1 exp-rampval !
  2683. then
  2684. endcase
  2685. inval f+ ( val )
  2686. 1 +to out1
  2687. grn1 exp-trigger @ 1 = if
  2688. 0 grn1 exp-trigger !
  2689. hop +to out1
  2690. then
  2691. then
  2692. i out2 = if
  2693. fil2 grn2 exp-loc @ 0 file->sample { inval }
  2694. 1 grn2 exp-loc +!
  2695. grn2 exp-whichseg @ case
  2696. 0 of
  2697. grn2 exp-rampval @ inval f* to inval
  2698. grn2 exp-rampinc @ grn2 exp-rampval +!
  2699. 1 grn2 exp-segctr +!
  2700. grn2 exp-segctr @ grn2 exp-ramplen @ = if
  2701. 0 grn2 exp-segctr !
  2702. 1 grn2 exp-whichseg +!
  2703. then
  2704. endof
  2705. 1 of
  2706. 1 grn2 exp-segctr +!
  2707. grn2 exp-segctr @ grn2 exp-steadylen @ = if
  2708. 0 grn2 exp-segctr !
  2709. 1 grn2 exp-whichseg +!
  2710. then
  2711. endof
  2712. grn2 exp-rampval @ inval f* to inval
  2713. 1 grn2 exp-segctr +!
  2714. grn2 exp-rampinc @ fnegate grn2 exp-rampval +!
  2715. grn2 exp-segctr @ grn2 exp-ramplen @ = if
  2716. 0 grn2 exp-segctr !
  2717. 1 grn2 exp-trigger !
  2718. 0 grn2 exp-whichseg !
  2719. 0.0 grn2 exp-rampval !
  2720. then
  2721. endcase
  2722. inval f+ ( val )
  2723. 1 +to out2
  2724. grn2 exp-trigger @ 1 = if
  2725. 0 grn2 exp-trigger !
  2726. hop +to out2
  2727. then
  2728. then
  2729. end-run
  2730. grn1 free throw
  2731. grn2 free throw
  2732. ;instrument
  2733. : expfil-test <{ :optional start 0.0 dur 1.0 -- }>
  2734. start now!
  2735. now@ dur 0.2 0.01 0.1 "oboe.snd" "fyow.snd" expfil
  2736. dur 0.2 f+ step
  2737. ;
  2738. \ GRAPH-EQ
  2739. \
  2740. \ From: Marco Trevisani <marco@ccrma.Stanford.EDU>
  2741. \
  2742. \ This should work like a Graphic Equalizer....
  2743. \ Very easy to use. Just some note:
  2744. \
  2745. \ "amp" & "amp-env" apply an enveloppe to the final result of the
  2746. \ filtering.
  2747. \
  2748. \ "dur" as ""standard"" in my instruments, when dur = 0 it will take the length of the
  2749. \ sndfile input, otherwise the duration in seconds.
  2750. \
  2751. \ "gain-freq-list" is a list of gains and frequencies to
  2752. \ filter --in this order gain and frequencies--. There is no limit to
  2753. \ the size of the list. Gain can be a number or an
  2754. \ envelope. Unfortunatelly in this version they cant alternate, one
  2755. \ should chose, all envelopes or all numbers i.e.:
  2756. \ case 1 -> #( .1 440.0 .3 1500.0 .2 330.0 ...etc) or
  2757. \ case 2 -> #((0 .1 1 .5) 440.0 (0 1 1 .01) 1500 (0 .3 1 .5) 330.0 ...etc)
  2758. \ #( .1 440.0 (0 1 1 .01) 1500 ..etc) <<< again, this is not allowed ..
  2759. \
  2760. \ "offset-gain" This apply to all the gains if case 1. It adds or
  2761. \ subtracts an offset to all the gains in the list. This number can be positive or
  2762. \ negative. In case the result is a negative number --let's say offset =
  2763. \ -.4 and, like in case 1, the first gain is .1, the result would be
  2764. \ -.3 -- the instrument will pass a gain equal to 0.
  2765. \
  2766. \ "filt-gain-scale" & "filt-gain-base" will apply to the elements of the
  2767. \ envelopes if we are in case 2, gains are envelopes.
  2768. instrument: graph-eq <{ file start dur
  2769. :key
  2770. file-start 0.0
  2771. amplitude 1.0
  2772. amp-env #( 0 1 0.8 1 1 0 )
  2773. amp-base 1.0
  2774. offset-gain 0.0
  2775. gain-freq-list #( #( 0 1 1 0 ) 440 #( 0 0 1 1 ) 660 )
  2776. filt-gain-scale 1.0
  2777. filt-gain-base 1.0
  2778. a1 0.99 -- }>
  2779. doc" \"oboe.snd\" 0 2 graph-eq"
  2780. file find-file to file
  2781. file false? if 'file-not-found $" %s: cannot find %S" #( get-func-name file ) fth-raise then
  2782. :file file :start file mus-sound-srate file-start f* fround->s make-readin { rd }
  2783. :envelope amp-env :scaler amplitude :duration dur :base amp-base make-env { ampf }
  2784. gain-freq-list length 2/ { len }
  2785. len make-array { gainl }
  2786. len make-array { freql }
  2787. 0 { idx }
  2788. gain-freq-list length 1- 0 ?do
  2789. gainl idx gain-freq-list i array-ref array-set!
  2790. freql idx gain-freq-list i 1+ array-ref array-set!
  2791. 1 +to idx
  2792. 2 +loop
  2793. gainl 0 array-ref array? dup { if-list-in-gain } if
  2794. len make-array map!
  2795. :envelope gainl i array-ref
  2796. :scaler filt-gain-scale
  2797. :duration dur
  2798. :base filt-gain-base make-env
  2799. end-map
  2800. else
  2801. #f
  2802. then { env-size }
  2803. freql map :frequency *key* :radius a1 make-formant end-map { frm-size }
  2804. len 1.0 make-vct { gains }
  2805. gainl each { gval }
  2806. freql i array-ref { fval }
  2807. if-list-in-gain if
  2808. :envelope gval
  2809. :scaler filt-gain-scale
  2810. :duration dur
  2811. :base filt-gain-base make-env
  2812. env-size i rot ( en ) array-set!
  2813. frm-size i :frequency fval :radius a1 make-formant array-set!
  2814. else
  2815. frm-size i :frequency fval :radius a1 make-formant array-set!
  2816. gains i
  2817. offset-gain gval f+ f0< if
  2818. 0.0
  2819. else
  2820. offset-gain gval f+
  2821. then vct-set! drop
  2822. then
  2823. end-each
  2824. 1.0 a1 f- { 1-a1 }
  2825. start dur #{ :degree 90.0 random } run-instrument
  2826. rd readin { inval }
  2827. 0.0 ( outval )
  2828. env-size each { en }
  2829. if-list-in-gain if
  2830. gains i en env 1-a1 f* vct-set! drop
  2831. then
  2832. gains i vct-ref
  2833. frm-size i array-ref ( fmt ) inval 0.0 formant f* f+ ( outval )
  2834. end-each
  2835. ampf env f* ( outval )
  2836. end-run
  2837. rd mus-close drop
  2838. ;instrument
  2839. : graph-eq-test <{ :optional start 0.0 dur 1.0 -- }>
  2840. start now!
  2841. "oboe.snd" now@ dur :amplitude 50.0 graph-eq
  2842. dur 0.2 f+ step
  2843. ;
  2844. \ ANOI
  2845. \
  2846. \ a kind of noise reduction -- on-going average spectrum is squelched
  2847. \ to some extent obviously aimed at intermittent signal in background
  2848. \ noise
  2849. \ this is based on Perry Cook's Scrubber.m
  2850. \
  2851. \ clm/anoi.ins
  2852. instrument: anoi <{ fname start dur :optional fftsize 128 amp-scaler 1.0 R two-pi -- }>
  2853. fftsize 2/ { freq-inc }
  2854. fftsize 0.0 make-vct { fdr }
  2855. fftsize 0.0 make-vct { fdi }
  2856. freq-inc 1.0 make-vct { spectr }
  2857. freq-inc 1.0 make-vct { scales }
  2858. freq-inc 0.0 make-vct { diffs }
  2859. blackman2-window fftsize 0.0 0.0 make-fft-window { win }
  2860. 0.0 { amp }
  2861. amp-scaler 4.0 f* mus-srate f/ { incr }
  2862. fname find-file to fname
  2863. fname false? if 'file-not-found $" %s: cannot find %S" #( get-func-name fname ) fth-raise then
  2864. fname make-file->sample { fil }
  2865. 1.0 R fftsize f/ f- { radius }
  2866. mus-srate fftsize f/ { bin }
  2867. freq-inc make-array map! :radius radius :frequency i bin f* make-formant end-map { fs }
  2868. start seconds->samples { beg }
  2869. start dur #{ :degree 90.0 random } run-instrument
  2870. fil i beg - 0 file->sample { inval }
  2871. fdr inval cycle-set!
  2872. \ fdr i fftsize mod inval vct-set! drop
  2873. amp amp-scaler f< if incr +to amp then
  2874. \ i beg - fftsize mod unless
  2875. fdr cycle-start@ 0= if
  2876. fdr fdi win 1 spectrum drop
  2877. diffs map
  2878. spectr i vct-ref 0.9 f* fdr i vct-ref 0.1 f* f+ { x }
  2879. spectr i x vct-set! drop
  2880. x fdr i vct-ref f>= if
  2881. scales i vct-ref fftsize fnegate f/
  2882. else
  2883. fdr i vct-ref dup spectr i vct-ref f- swap f/ scales i vct-ref f- fftsize f/
  2884. then
  2885. end-map drop
  2886. then
  2887. 0.0 ( outval )
  2888. fs each { fmt }
  2889. scales i vct-ref { curscl }
  2890. fmt inval 0.0 formant curscl f* f+ ( outval += ... )
  2891. scales i diffs i vct-ref curscl f+ vct-set! drop
  2892. end-each
  2893. ( outval ) amp f*
  2894. end-run
  2895. fil mus-close drop
  2896. ;instrument
  2897. : anoi-test <{ :optional start 0.0 dur 1.0 -- }>
  2898. start now!
  2899. "fyow.snd" now@ dur 128 2.0 anoi
  2900. dur 0.2 f+ step
  2901. ;
  2902. \ Date: Fri, 25 Sep 1998 09:56:41 +0300
  2903. \ From: Matti Koskinen <mjkoskin@sci.fi>
  2904. \ To: linux-audio-dev@ginette.musique.umontreal.ca
  2905. \ Subject: [linux-audio-dev] Announce: alpha version of denoising
  2906. \ [...]
  2907. \ I wrote a simple denoiser called anoi after it's parent
  2908. \ clm-instrument anoi.ins.
  2909. \
  2910. \ anoi tries to remove white noise like tape hiss from wav-
  2911. \ files. Removing of noise succeeds ok, but depending of the
  2912. \ original sound, some distortion can be audible.
  2913. \
  2914. \ If someone is interested, http://www.sci.fi/~mjkoskin
  2915. \ contains tarred and gzipped file.
  2916. \
  2917. \ Now only monophonic wav-files can be denoised, but adding
  2918. \ others isn't too difficult.
  2919. \
  2920. \ -matti
  2921. \ mjkoskin@sci.fi
  2922. \ FULLMIX
  2923. instrument: fullmix <{ in-file
  2924. :optional
  2925. start 0.0
  2926. dur #f
  2927. inbeg 0.0
  2928. matrix #f
  2929. sr #f
  2930. rev-amount #f -- }>
  2931. doc" \"pistol.snd\" 0 1 fullmix\n\
  2932. :envelope #( 0 0 1 1 ) :duration dur :scaler 0.5 make-env value en
  2933. \"oboe.snd\" 0 2 0 #( #( 0.8 en ) ) 2.0 <'> fullmix with-sound"
  2934. in-file find-file to in-file
  2935. in-file false? if 'file-not-found $" %s: cannot find %S" #( get-func-name in-file ) fth-raise then
  2936. dur unless in-file mus-sound-duration inbeg f- sr if sr fabs else 1.0 then f/ to dur then
  2937. in-file mus-sound-chans { in-chans }
  2938. inbeg in-file mus-sound-srate f* fround->s { inloc }
  2939. *output* mus-channels { out-chans }
  2940. matrix if
  2941. in-chans out-chans max make-mixer
  2942. else
  2943. in-chans out-chans max 1.0 make-scalar-mixer
  2944. then { mx }
  2945. *reverb* rev-amount f0> && if
  2946. in-chans make-mixer { rmx }
  2947. in-chans 0 ?do rmx i 0 rev-amount mixer-set! drop loop
  2948. rmx
  2949. else
  2950. #f
  2951. then { rev-mx }
  2952. #f { envs }
  2953. matrix if
  2954. matrix object-length 0> if
  2955. in-chans 0 ?do
  2956. matrix i object-ref { inlist }
  2957. out-chans 0 ?do
  2958. inlist i object-ref { outn }
  2959. outn if
  2960. outn number? if
  2961. mx j ( inp ) i ( outp ) outn mixer-set! drop
  2962. else
  2963. outn env? outn array? || if
  2964. envs unless
  2965. in-chans make-array map! out-chans make-array end-map to envs
  2966. then
  2967. envs j ( inp ) array-ref i ( outp )
  2968. outn env? if outn else :envelope outn :duration dur make-env then
  2969. array-set!
  2970. else
  2971. $" %s: unknown element in matrix: %S" #( get-func-name outn ) string-format warning
  2972. then
  2973. then
  2974. then
  2975. loop
  2976. loop
  2977. else
  2978. in-chans 0 ?do i out-chans < if mx i i matrix mixer-set! drop then loop
  2979. then
  2980. then
  2981. sr unless
  2982. \ ws-info ( start dur local-vars -- start dur )
  2983. \
  2984. \ This is normally done in RUN or RUN-INSTRUMENT, but here
  2985. \ we haven't one of them.
  2986. \
  2987. start dur local-variables ws-info ( start dur )
  2988. ( start ) seconds->samples { st }
  2989. ( dur ) seconds->samples { samps }
  2990. *output* in-file undef make-file->frame st samps inloc mx envs mus-mix drop
  2991. rev-mx if *reverb* 1 make-frame st samps inloc rev-mx #f mus-mix drop then
  2992. else
  2993. in-chans make-frame { inframe }
  2994. out-chans make-frame { outframe }
  2995. in-chans make-array map!
  2996. :file in-file :channel i :start inloc make-readin { rd }
  2997. :input rd readin-cb :srate sr make-src
  2998. end-map { srcs }
  2999. envs if
  3000. start dur run
  3001. envs each
  3002. each { en } env? if mx j ( inp ) i ( outp ) en env mixer-set! drop then end-each
  3003. end-each
  3004. in-chans 0 ?do inframe i srcs i array-ref 0.0 src frame-set! drop loop
  3005. *output* i inframe mx outframe frame->frame frame->file drop
  3006. rev-mx if *reverb* i inframe rev-mx outframe frame->frame frame->file drop then
  3007. loop
  3008. else
  3009. start dur run
  3010. in-chans 0 ?do inframe i srcs i array-ref 0.0 src frame-set! drop loop
  3011. *output* i inframe mx outframe frame->frame frame->file drop
  3012. rev-mx if *reverb* i inframe rev-mx outframe frame->frame frame->file drop then
  3013. loop
  3014. then
  3015. then
  3016. ;instrument
  3017. : fullmix-test <{ :optional start 0.0 dur 1.0 -- }>
  3018. .stack
  3019. start now!
  3020. :envelope #( 0 0 1 1 ) :duration dur :scaler 0.5 make-env { en }
  3021. "pistol.snd" now@ dur fullmix
  3022. dur 0.2 f+ step
  3023. "oboe.snd" now@ dur 0 #( #( 0.1 en ) ) fullmix
  3024. dur 0.2 f+ step
  3025. ;
  3026. 'snd provided? [if]
  3027. \ ;;; bes-fm -- can also use bes-j0 here as in earlier versions
  3028. instrument: bes-fm <{ start dur freq amp ratio index -- }>
  3029. 0.0 0.0 { car-ph mod-ph }
  3030. freq hz->radians { car-incr }
  3031. ratio car-incr f* { mod-incr }
  3032. :envelope #( 0 0 25 1 75 1 100 0 ) :scaler amp :duration dur make-env { ampenv }
  3033. start dur #{ :degree 90.0 random } run-instrument
  3034. ampenv env car-ph bes-j1 f* ( result )
  3035. mod-ph bes-j1 index f* car-incr f+ +to car-ph
  3036. mod-incr +to mod-ph
  3037. end-run
  3038. ;instrument
  3039. : bes-fm-test <{ :optional start 0.0 dur 1.0 -- }>
  3040. start now!
  3041. now@ dur 440.0 10.0 1.0 4.0 bes-fm
  3042. dur 0.2 f+ step
  3043. ;
  3044. include dsp
  3045. [else]
  3046. : bes-fm-test <{ :optional start 0.0 dur 1.0 -- }>
  3047. ;
  3048. \ --- Hilbert transform
  3049. : make-hilbert-transform ( len -- gen )
  3050. doc" Makes a Hilbert transform filter."
  3051. { len }
  3052. len 2* 1+ { arrlen }
  3053. arrlen 0.0 make-vct { arr }
  3054. len even? if len else len 1+ then { lim }
  3055. lim len negate ?do
  3056. i len + { kk }
  3057. i pi f* { denom }
  3058. 1.0 denom fcos f- { num }
  3059. num f0<> i 0<> || if
  3060. arr kk num denom f/ denom len f/ fcos 0.46 f* 0.54 f+ f* vct-set! drop
  3061. then
  3062. loop
  3063. arrlen arr make-fir-filter
  3064. ;
  3065. <'> fir-filter alias hilbert-transform
  3066. [then]
  3067. \ SSB-FM
  3068. \ ;;; this might be better named "quasi-ssb-fm" -- cancellations are not perfect
  3069. struct
  3070. cell% field sbfm-am0
  3071. cell% field sbfm-am1
  3072. cell% field sbfm-car0
  3073. cell% field sbfm-car1
  3074. cell% field sbfm-mod0
  3075. cell% field sbfm-mod1
  3076. end-struct sbfm%
  3077. : make-ssb-fm ( freq -- ssb )
  3078. { freq }
  3079. sbfm% %alloc { sbfm }
  3080. freq 0.0 make-oscil sbfm sbfm-am0 !
  3081. freq half-pi make-oscil sbfm sbfm-am1 !
  3082. 0.0 0.0 make-oscil sbfm sbfm-car0 !
  3083. 0.0 half-pi make-oscil sbfm sbfm-car1 !
  3084. 40 make-hilbert-transform sbfm sbfm-mod0 !
  3085. 40 make-delay sbfm sbfm-mod1 !
  3086. sbfm
  3087. ;
  3088. : ssb-fm ( gen modsig -- val )
  3089. { gen modsig }
  3090. gen sbfm-am0 @ 0.0 0.0 oscil
  3091. gen sbfm-car0 @ gen sbfm-mod0 @ modsig hilbert-transform 0.0 oscil f*
  3092. gen sbfm-am1 @ 0.0 0.0 oscil
  3093. gen sbfm-car1 @ gen sbfm-mod1 @ modsig 0.0 delay 0.0 oscil f* f+
  3094. ;
  3095. \ ;;; if all we want are asymmetric fm-generated spectra, we can just
  3096. \ ;;; add 2 fm oscil pairs:
  3097. struct
  3098. cell% field fm2-os1
  3099. cell% field fm2-os2
  3100. cell% field fm2-os3
  3101. cell% field fm2-os4
  3102. end-struct fm2%
  3103. : make-fm2 ( f1 f2 f3 f4 p1 p2 p3 p4 -- )
  3104. { f1 f2 f3 f4 p1 p2 p3 p4 }
  3105. fm2% %alloc { fm2 }
  3106. f1 p1 make-oscil fm2 fm2-os1 !
  3107. f2 p2 make-oscil fm2 fm2-os2 !
  3108. f3 p3 make-oscil fm2 fm2-os3 !
  3109. f4 p4 make-oscil fm2 fm2-os4 !
  3110. fm2
  3111. ;
  3112. : fm2 ( gen index -- val )
  3113. { gen index }
  3114. gen fm2-os1 @ gen fm2-os2 @ 0.0 0.0 oscil index f* 0.0 oscil
  3115. gen fm2-os3 @ gen fm2-os4 @ 0.0 0.0 oscil index f* 0.0 oscil f+ 0.25 f*
  3116. ;
  3117. \ ;;; rms gain balance
  3118. \ ;;; This is a translation of the rmsgain code provided by Fabio Furlanete.
  3119. : make-rmsgain <{ :optional hp 10.0 -- gen }>
  3120. doc" makes an RMS gain generator."
  3121. 2.0 two-pi mus-srate f/ hp f* fcos f- { b }
  3122. b b b f* 1.0 f- fsqrt f- { c2 }
  3123. 1.0 c2 f- { c1 }
  3124. #() :rmsg-c1 c1 array-assoc-set!
  3125. ( rmsg ) :rmsg-c2 c2 array-assoc-set!
  3126. ( rmsg ) :rmsg-q 0.0 array-assoc-set!
  3127. ( rmsg ) :rmsg-r 0.0 array-assoc-set!
  3128. ( rmsg ) :rmsg-avg 0.0 array-assoc-set!
  3129. ( rmsg ) :rmsg-avgc 0 array-assoc-set!
  3130. ( rmsg )
  3131. ;
  3132. : rmsgain-rms ( gen sig -- val )
  3133. doc" runs an RMS gain generator."
  3134. { gen sig }
  3135. gen :rmsg-c1 array-assoc-ref sig f* sig f*
  3136. gen :rmsg-c2 array-assoc-ref gen :rmsg-q array-assoc-ref f* f+
  3137. dup gen :rmsg-q rot array-assoc-set! drop ( val ) fsqrt
  3138. ;
  3139. : rmsgain-gain ( gen sig rmsval -- val )
  3140. doc" returns the current RMS gain."
  3141. { gen sig rmsval }
  3142. gen :rmsg-c1 array-assoc-ref sig f* sig f*
  3143. gen :rmsg-c2 array-assoc-ref gen :rmsg-r array-assoc-ref f* f+
  3144. dup ( val val ) gen :rmsg-r rot array-assoc-set! drop
  3145. ( val ) f0= if rmsval else rmsval gen :rmsg-r array-assoc-ref fsqrt f/ then { this-gain }
  3146. gen :rmsg-avg array-assoc-ref this-gain f+ gen :rmsg-avg rot array-assoc-set!
  3147. ( gen ) :rmsg-avgc array-assoc-ref 1+ gen :rmsg-avgc rot array-assoc-set! drop
  3148. sig this-gain f*
  3149. ;
  3150. : rmsgain-balance ( gen sig comp -- val )
  3151. doc" scales a signal based on a RMS gain."
  3152. { gen sig comp }
  3153. gen sig gen comp rmsgain-rms rmsgain-gain
  3154. ;
  3155. : rmsgain-gain-avg ( gen -- val )
  3156. doc" is part of the RMS gain stuff."
  3157. { gen }
  3158. gen :rmsg-avg array-assoc-ref gen :rmsg-avgc array-assoc-ref f/
  3159. ;
  3160. : rmsgain-balance-avg ( gen -- val )
  3161. doc" is part of the RM gain stuff."
  3162. :rmsg-avg array-assoc-ref
  3163. ;
  3164. : clm-ins-test <{ :optional start 0.0 dur 1.0 }>
  3165. start now!
  3166. now@ dur violin-test
  3167. now@ dur fm-violin-test
  3168. now@ dur pluck-test
  3169. now@ dur vox-test
  3170. now@ dur fofins-test
  3171. now@ dur fm-trumpet-test
  3172. now@ dur pqw-vox-test
  3173. now@ dur flute-test
  3174. now@ dur fm-bell-test
  3175. now@ dur fm-insect-test
  3176. now@ dur fm-drum-test
  3177. now@ dur gong-test
  3178. now@ dur attract-test
  3179. now@ dur pqw-test
  3180. now@ dur tubebell-test
  3181. now@ dur wurley-test
  3182. now@ dur rhodey-test
  3183. now@ dur hammondoid-test
  3184. now@ dur metal-test
  3185. now@ dur drone/canter-test
  3186. now@ dur reson-test
  3187. now@ dur cellon-test
  3188. now@ dur gran-synth-test
  3189. now@ dur touch-tone-test
  3190. now@ dur spectra-test
  3191. now@ dur two-tab-test
  3192. now@ dur lbj-piano-test
  3193. now@ dur resflt-test
  3194. now@ dur scratch-test
  3195. now@ dur pins-test
  3196. now@ dur zc-test
  3197. now@ dur zn-test
  3198. now@ dur za-test
  3199. now@ dur clm-expsrc-test
  3200. now@ dur exp-snd-test
  3201. now@ dur expfil-test
  3202. now@ dur graph-eq-test
  3203. now@ dur anoi-test
  3204. now@ dur fullmix-test
  3205. now@ dur bes-fm-test
  3206. ;
  3207. \ clm-ins.fs ends here