Hi, Yes. Snd's make-square-wave works great. I took another look at my code and figured out the problem was not reading from make-sampler, but my trying to get the maxval of the sampler's output to see what was going wrong.
I was using (set! maxval (float-vector-max (float-vector-abs! im))) and didn't realize float-vector-abs! was setting all the values to absolute value. I thought it was just getting the abs value. So for a square wave that's deadly. My fault. Thank you, Jim ________________________________ From: cmdist-boun...@ccrma.stanford.edu <cmdist-boun...@ccrma.stanford.edu> on behalf of cmdist-requ...@ccrma.stanford.edu <cmdist-requ...@ccrma.stanford.edu> Sent: Thursday, December 7, 2023 10:00 AM To: cmdist@ccrma.Stanford.EDU <cmdist@ccrma.Stanford.EDU> Subject: Cmdist Digest, Vol 187, Issue 1 Send Cmdist mailing list submissions to cmdist@ccrma.stanford.edu To subscribe or unsubscribe via the World Wide Web, visit https://cm-mail.stanford.edu/mailman/listinfo/cmdist or, via email, send a message with subject or body 'help' to cmdist-requ...@ccrma.stanford.edu You can reach the person managing the list at cmdist-ow...@ccrma.stanford.edu When replying, please edit your Subject line so it is more specific than "Re: Contents of Cmdist digest..." Today's Topics: 1. make-sampler vs. open (James Hearon) ---------------------------------------------------------------------- Message: 1 Date: Thu, 7 Dec 2023 18:12:56 +0000 From: James Hearon <j_hea...@hotmail.com> To: "cmdist@ccrma.Stanford.EDU" <cmdist@ccrma.Stanford.EDU> Subject: [CM] make-sampler vs. open Message-ID: <sn7pr07mb9651b77f7dc22e6f046b1521e5...@sn7pr07mb9651.namprd07.prod.outlook.com> Content-Type: text/plain; charset="iso-8859-1" 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-0001.html> ------------------------------ _______________________________________________ Cmdist mailing list Cmdist@ccrma.stanford.edu https://cm-mail.stanford.edu/mailman/listinfo/cmdist End of Cmdist Digest, Vol 187, Issue 1 **************************************
_______________________________________________ Cmdist mailing list Cmdist@ccrma.stanford.edu https://cm-mail.stanford.edu/mailman/listinfo/cmdist