Here instrument 1 and instrument 2 is run with same frequencies. But with instrument 2, we add random values for envelope parameters. Rather than using csound macros I use a python string, with placeholder {}. There is also a tempo string and a reset clock; this due to fact that we use same times for second. Of course we could just have added {} for the start time, and added a format variable.
Python is a much better language at string manipulation than csound. It is better to use Python to write scores and only use csound opcodes for instruments. Also Python is much easier to debug.
# ex1D12.py # Humanising from moduleCsound import * tags(1) header(ksmps=32) # --- global add("giWave ftgen 0, 0, 2^10, 10, 1,0,1/4,0,1/16,0,1/64,0,1/256,0,1/1024") # --- instruments add(""" instr 1 ; an instrument with no 'humanising' inote = p4 aEnv linen 0.1,0.01,p3,0.01 aSig poscil aEnv,cpsmidinn(inote),giWave outs aSig,aSig endin instr 2 ; an instrument with 'humanising' inote = p4 ; generate some i-time 'static' random paramters iRndAmp random -3,3 ; amp. will be offset by a random number of decibels iRndNte random -5,5 ; note will be offset by a random number of cents ; generate some k-rate random functions kAmpWob rspline -1,1,1,10 ; amplitude 'wobble' (in decibels) kNteWob rspline -5,5,0.3,10 ; note 'wobble' (in cents) ; calculate final note function (in CPS) kcps = cpsmidinn(inote+(iRndNte*0.01)+(kNteWob*0.01)) ; amplitude envelope (randomisation of attack time) aEnv linen 0.1*ampdb(iRndAmp+kAmpWob),0.01+rnd(0.03),p3,0.01 aSig poscil aEnv,kcps,giWave outs aSig,aSig endin """) tags(2) scr = """ i {} 0 1 60 i . + 2.5 69 i . + 0.5 67 i . + 0.5 65 i . + 0.5 64 i . + 3 62 i . + 1 62 i . + 2.5 70 i . + 0.5 69 i . + 0.5 67 i . + 0.5 65 i . + 3 64 """ add("t 0 80") add(scr.format(1)) add("b 17") add(scr.format(2)) tags(3) writeRun(__file__)
No comments:
Post a Comment