<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi,</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
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. </div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
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.</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
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?</div>
<pre><div><span style="font-size: 10pt; color: rgb(0, 0, 0);">(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)
(<i>mus-fft</i> 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)))
(<i>mus-fft</i> 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"))</span></div></pre>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Regards,</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Jim<br>
</div>
</body>
</html>