[CM] pops when sample == 1.0?

Alan Grover awgrover at msen.com
Wed Nov 11 06:23:18 PST 2009


I was programmatically generating some waveforms, and got some pops in
the middle of them.

I tracked it down to samples whose value is 1.0, or more specifically,
when a sample goes from <1.0 to 1.0, and from 1.0 to <1.0.

Since I'm using make-oscil, I would assume that a pop is not to be
expected. I'm new to snd, so, am I missing something?

;; This chunk produces a pop
(close-sound #t)
(new-sound "click")
(define (sine-portion duration-secs start-phase duration-phase)
    "start a sine-wave at start-phase, for duration-phase wave-lengths,
lasting duration-secs"
    (let* (
            (full-wave-duration (* duration-secs (/ 1 duration-phase)))
            (sine-hz (/ 1 full-wave-duration))
            (full-sine
                (vct-map!
                    (make-vct (+ 1 (* (srate) duration-secs)) 0.0)
                    (make-oscil sine-hz :initial-phase (* 2 pi start-phase))
                    )))
        full-sine))

; a "hump", start at zero, up to max, back down to zero
(vct->channel (sine-portion 1 0 .5))
; this will produce a click at the peak of the hump
(play)


;; This chunk makes the pop go away
; replace the peak with slightly smaller value:
(let* (
        (has-click (vct->vector (sine-portion 1 0 .5)))
        (unpeaked (vector->vct
                (map
                    (lambda (a)
                        (if (= a 1.0) ; nb: those samples that are
"exactly" 1.0
                            0.9999  ; change 1.0's into .99999's
                            a))
                    has-click)))
        )
    (close-sound #t)
    (new-sound "click")
    (vct->channel unpeaked))
; no click:
(play)

-- 
Alan Grover
awgrover at mail.msen.com
+1.734.476.0969

(The "email signature" and/or digital-signature
are only for informational and integrity purposes
and does not constitute a legal signature)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 253 bytes
Desc: OpenPGP digital signature
Url : http://ccrma-mail.stanford.edu/pipermail/cmdist/attachments/20091111/7f20391a/attachment.bin 


More information about the Cmdist mailing list