<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 style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
Hi,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
I've been using the generators in generators.scm for a while, and enjoy making sound with them, but for the life of me I cannot seem to understand how they work. I'm confused about the lambda part and the use of fm. What is fm doing? I'd be grateful if someone
could explain that.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
Such as in nxycos, It seems like (set! angle (+ angle fm frequency)) is critical, but is (+ angle fm frequency), simply the sum of those variables, such as (+ 3 1 2), > 6? Or does the fm part contribute to the radians value of angle in some other way in that
bit of code. I've tried using display and formatted output to look at output values such as x, y, den, angle in radians in lambda, but nothing is really making sense to me yet. I've also experimented with input of different values and viewing the fft outputs
to see the frequency in hz, ratio, n, and also angle or phase start in the waveform view of snd.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
For ex. if I do something like:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
...</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
<span class="Apple-converted-space" style="font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400;">(outa
i (* .5 (nxycos gen 0.1))))))</span><br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
such as adding a value for fm, then the frequency really takes off, so I'm not sure I'm understanding what fm does in the generator or how it's supposed to be used. </div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
Thank you,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
Jim</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
span.Apple-tab-span {white-space:pre}
</style>
<p class="p1">(defgenerator (nxycos :make-wrapper convert-frequency)</p>
<p class="p1"><span class="Apple-converted-space"> </span>(frequency 0.0) (ratio 1.0) (n 1) (angle 0.0) fm)</p>
<p class="p2"><br>
</p>
<p class="p1">(define nxycos<span class="Apple-converted-space"> </span></p>
<p class="p2"><br>
</p>
<p class="p1"><span class="Apple-converted-space"> </span>(let ((+documentation+ "(make-nxycos frequency (ratio 1.0) (n 1)) creates an nxycos generator. (nxycos gen (fm 0.0))<span class="Apple-converted-space"> </span></p>
<p class="p1">returns n cosines from frequency spaced by frequency * ratio."))</p>
<p class="p2"><br>
</p>
<p class="p1"><span class="Apple-converted-space"> </span>(lambda* (gen (fm 0.0))
<span class="Apple-converted-space"> </span></p>
<p class="p1"><span class="Apple-converted-space"> </span>(let-set! gen 'fm fm)</p>
<p class="p1"><span class="Apple-converted-space"> </span>(with-let gen</p>
<p class="p1"><span class="Apple-tab-span"></span>(let* ((x angle)</p>
<p class="p1"><span class="Apple-tab-span"></span><span class="Apple-converted-space">
</span>(y (* x ratio))</p>
<p class="p1"><span class="Apple-tab-span"></span><span class="Apple-converted-space">
</span>(den (sin (* y 0.5))))</p>
<p class="p1"><span class="Apple-tab-span"></span><span class="Apple-converted-space">
</span>(set! angle (+ angle fm frequency))</p>
<p class="p1"><span class="Apple-tab-span"></span><span class="Apple-converted-space">
</span>(if (< (abs den) nearly-zero)</p>
<p class="p1"><span class="Apple-tab-span"></span><span class="Apple-converted-space">
</span>1.0</p>
<p class="p1"><span class="Apple-tab-span"></span><span class="Apple-converted-space">
</span>(/ (* (cos (+ x (* 0.5 (- n 1) y)))</p>
<p class="p1"><span class="Apple-tab-span"></span><span class="Apple-tab-span"></span><span class="Apple-converted-space">
</span>(sin (* 0.5 n y)))</p>
<p class="p1"><span class="Apple-tab-span"></span><span class="Apple-tab-span"></span>(* n den)))))))) ; n=normalization</p>
<p class="p2"><br>
</p>
<p class="p1">#|</p>
<p class="p1">(with-sound (:clipped #f :statistics #t :play #t)</p>
<p class="p1"><span class="Apple-converted-space"> </span>(let ((gen (make-nxycos 300 1/3 3)))</p>
<p class="p1"><span class="Apple-converted-space"> </span>(do ((i 0 (+ i 1)))</p>
<p class="p1"><span class="Apple-tab-span"></span>((= i 20000))</p>
<p class="p1"><span class="Apple-converted-space"> </span>(outa i (* .5 (nxycos gen))))))</p>
<p class="p1">|#</p>
</div>
</body>
</html>