<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<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);">
Yes.&nbsp; Snd's make-square-wave works great.&nbsp;</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
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.</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 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.&nbsp; I thought it was just getting the abs value.&nbsp; So for a square wave that's deadly.</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);">
My fault.</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thank you,</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Jim<br>
</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> cmdist-bounces@ccrma.Stanford.EDU &lt;cmdist-bounces@ccrma.Stanford.EDU&gt; on behalf of cmdist-request@ccrma.Stanford.EDU &lt;cmdist-request@ccrma.Stanford.EDU&gt;<br>
<b>Sent:</b> Thursday, December 7, 2023 10:00 AM<br>
<b>To:</b> cmdist@ccrma.Stanford.EDU &lt;cmdist@ccrma.Stanford.EDU&gt;<br>
<b>Subject:</b> Cmdist Digest, Vol 187, Issue 1</font>
<div>&nbsp;</div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Send Cmdist mailing list submissions to<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmdist@ccrma.stanford.edu<br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://cm-mail.stanford.edu/mailman/listinfo/cmdist">https://cm-mail.stanford.edu/mailman/listinfo/cmdist</a><br>
or, via email, send a message with subject or body 'help' to<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmdist-request@ccrma.stanford.edu<br>
<br>
You can reach the person managing the list at<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmdist-owner@ccrma.stanford.edu<br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than &quot;Re: Contents of Cmdist digest...&quot;<br>
<br>
<br>
Today's Topics:<br>
<br>
&nbsp;&nbsp; 1. make-sampler vs. open (James Hearon)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Thu, 7 Dec 2023 18:12:56 +0000<br>
From: James Hearon &lt;j_hearon@hotmail.com&gt;<br>
To: &quot;cmdist@ccrma.Stanford.EDU&quot; &lt;cmdist@ccrma.Stanford.EDU&gt;<br>
Subject: [CM] make-sampler vs. open<br>
Message-ID:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;SN7PR07MB9651B77F7DC22E6F046B1521E58BA@SN7PR07MB9651.namprd07.prod.outlook.com&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
Content-Type: text/plain; charset=&quot;iso-8859-1&quot;<br>
<br>
Hi,<br>
I was trying to use make-sampler, but having a problem opening (read-sample) a non-bandlimited square wav effectively.&nbsp; 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.<br>
<br>
Instead I was tweaking this code below from spectrum as an fft filter for file based bandlimiting.&nbsp; Reason being most of what I was doing is outside the editor, or file-based manipulation before the sound gets opened in the editor.&nbsp; The result is better than
 before but I'm still not seeing anything resembling a square wav yet with make-sampler and read-sample.&nbsp; I also tried some peak limiting on amplitudes, but still no joy.<br>
<br>
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?<br>
<br>
(let* ((len (mus-sound-framples &quot;oboe.snd&quot;))<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (fsize (expt 2 (ceiling (log len 2))))<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (rdata (make-float-vector fsize))<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (idata (make-float-vector fsize)))<br>
&nbsp; (file-&gt;array &quot;oboe.snd&quot; 0 0 len rdata)<br>
&nbsp; (mus-fft rdata idata fsize 1)<br>
&nbsp; (let ((fsize2 (/ fsize 2))<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (cutoff (round (/ fsize 10))))<br>
&nbsp;&nbsp;&nbsp; (do ((i cutoff (+ i 1))<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (j (- fsize 1) (- j 1)))<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((= i fsize2))<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (set! (rdata i) 0.0)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (set! (idata i) 0.0)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (set! (rdata j) 0.0)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (set! (idata j) 0.0)))<br>
&nbsp; (mus-fft rdata idata fsize -1)<br>
&nbsp; (array-&gt;file &quot;test.snd&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (float-vector-scale! rdata (/ 1.0 fsize))<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; len<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (srate &quot;oboe.snd&quot;)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1)<br>
&nbsp; (let ((previous-case (find-sound &quot;test.snd&quot;)))<br>
&nbsp;&nbsp;&nbsp; (if (sound? previous-case)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (close-sound previous-case)))<br>
&nbsp; (open-sound &quot;test.snd&quot;))<br>
<br>
Regards,<br>
Jim<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: &lt;<a href="https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20231207/c01c70b0/attachment-0001.html">https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20231207/c01c70b0/attachment-0001.html</a>&gt;<br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
Cmdist mailing list<br>
Cmdist@ccrma.stanford.edu<br>
<a href="https://cm-mail.stanford.edu/mailman/listinfo/cmdist">https://cm-mail.stanford.edu/mailman/listinfo/cmdist</a><br>
<br>
<br>
End of Cmdist Digest, Vol 187, Issue 1<br>
**************************************<br>
</div>
</span></font></div>
</body>
</html>