On 01/16/2013 07:28 PM, Kjetil Matheussen wrote:
> James Harkins:
>> FWIW, this task is incredibly easy in SuperCollider:
>
> Perhaps it's easier than writing C, but there
> should be many alternatives that are easier than your example.
>
> For instance SND:
>
> (define reader (make-readin "filename.wav"))
> (call-with-output-file "outfile.txt"
> (lambda (out)
> (let loop ((i 0))
> (if (< i (mus-length reader))
> (begin
> (format out "~A\n" (readin reader))
> (loop (1+ i)))))))
>
I would debate that SND is "easier." Mine appeared to be more verbose
because I commented heavily to explain everything. Without comments:
f = SoundFile.openRead(Platform.resourceDir +/+ "sounds/a11wlk01.wav");
f.seek(4410); // 0.1 seconds in
f.readData(d = FloatArray.newClear(50));
f.close;
o = File("~/samples.txt", "w");
d.do { |sample| o << sample << Char.nl };
o.close;
... SC actually clocks in with one less line.
Not many people use SC for commandline scripting, but it is possible
(attached).
sclang sf-to-text.scd ~/share/SC/sounds/drums/kix/aphexbd.aif
~/tmp/testout.txt 100 50
hjh
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-user
This archive was generated by hypermail 2.1.8 : Thu Jan 17 2013 - 08:15:02 EET