[CM] make-sampler vs. open
James Hearon
j_hearon at hotmail.com
Thu Dec 7 10:12:56 PST 2023
Hi,
I was trying to use make-sampler, but having a problem opening (read-sample) a non-bandlimited square wav effectively. Snd's Open menu function works fine, but the make-sampler approach gives a max'd out flat line which seems like it might be an aliasing problem? I tried low-pass filtering with make-sample without much success.
Instead I was tweaking this code below from spectrum as an fft filter for file based bandlimiting. Reason being most of what I was doing is outside the editor, or file-based manipulation before the sound gets opened in the editor. The result is better than before but I'm still not seeing anything resembling a square wav yet with make-sampler and read-sample. I also tried some peak limiting on amplitudes, but still no joy.
I'm wondering what might be the difference with Snd's file Open and why it works so well vs. the lower level approach of make-sampler, and read-sample, or what might be a better way to approach those pesky non-bandlimited snds?
(let* ((len (mus-sound-framples "oboe.snd"))
(fsize (expt 2 (ceiling (log len 2))))
(rdata (make-float-vector fsize))
(idata (make-float-vector fsize)))
(file->array "oboe.snd" 0 0 len rdata)
(mus-fft rdata idata fsize 1)
(let ((fsize2 (/ fsize 2))
(cutoff (round (/ fsize 10))))
(do ((i cutoff (+ i 1))
(j (- fsize 1) (- j 1)))
((= i fsize2))
(set! (rdata i) 0.0)
(set! (idata i) 0.0)
(set! (rdata j) 0.0)
(set! (idata j) 0.0)))
(mus-fft rdata idata fsize -1)
(array->file "test.snd"
(float-vector-scale! rdata (/ 1.0 fsize))
len
(srate "oboe.snd")
1)
(let ((previous-case (find-sound "test.snd")))
(if (sound? previous-case)
(close-sound previous-case)))
(open-sound "test.snd"))
Regards,
Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20231207/c01c70b0/attachment.html>
More information about the Cmdist
mailing list