Another trick (also ksmps > 1) sr = 44100 ksmps = 64 nchnls = 1 0dbfs = 1 opcode rec, 0, Sai Sfname, aout, iframes xin setksmps 1 kcount init 0 if kcount < iframes then fout, Sfname, 6, aout ; float32 endif kcount = kcount+1 endop instr 1 iframes = int(p3*sr) arnd rand 0.5 rec "wow.wav", arnd, iframes endin t0 [44100*60] i1 0 12345 e csound -d test.wav ... sndfile-info $SFDIR/wow.wav |grep ^Frames Frames : 12345 tito On Sat, Jun 23, 2012 at 01:24:54PM -0400, Ralph Bluecoat wrote: > Thanks! That should do the trick, though I may have to play around with the > control rate. I never realized the resolution of the score was based on > ksmps. This might explain the deviations I was getting when I was trying to > get the period lengths of waveforms in samples in an audio editor. > > You may have guessed that I've been playing around with your Csound > implementation of the one-line 8-bit patterns in C. It's been good fun > trying to break down those equations and figure out how they work! > > -P > > On Sat, Jun 23, 2012 at 1:06 PM, Tito Latini wrote: > > > Here is the trick (but only ksmps=1) > > > > > > > > > > sr = 44100 > > ksmps = 1 > > nchnls = 1 > > 0dbfs = 1 > > > > instr 1 > > aout rand 0.5 > > out aout > > endin > > > > > > > > t0 [44100*60] > > i1 0 12345 ; duration is 12345 samples > > e > > > > > > > > > > csound -d test.csd > > ... > > > > sndfile-info $SFDIR/test.wav |grep ^Frames > > Frames : 12345 > > > > The grid for the score time is ksmps. The result of the previous > > example with ksmps=64 is 12352 because > > > > 64 * 192 = 12288 < 12345 > > 64 * 193 = 12352 = 12345 + 7 > > > > therefore the maximum error is (ksmps - 1) samples. > > > > tito > > > > On Sat, Jun 23, 2012 at 10:44:14AM -0400, Ralph Bluecoat wrote: > > > Hello again, > > > > > > I'm currently playing around with some low-level algorithms whose notes > > and > > > durations are based on sample rate and control rate. Is there a way in > > > Csound that I could write to an audio file and specify amount of samples > > I > > > want to write to disk? > > > > > > Thanks, > > > > > > Paul