Re: [CM] map-channel with dsp

2018-02-10 Thread bil
(map-channel func) calls func on every sample; the value returned by the 
function
is the new sample if that value is a number, but your do loop just 
returns #t
(the value of the multiply in the loop body is simply thrown away), so 
the
map-channel operation quits, leaving zeros in the new sound.  I think 
you intend:


(let ((i 0))
  (map-channel (lambda (y)
 (let ((result (* (amplitude-modulation 0.5) (im i
   (set! i (+ i 1))
   result


___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



[CM] map-channel with dsp

2018-02-09 Thread James Hearon
Hi,

I'm really stuck on trying to use map-channel to replace a newly created snd 
file with a dsp modified version of it.  I've been looking at snd-test.scm for 
examples but still don't have it right yet and not sure how to craft the 
let/map-channel/lambda to make it work.  All I get is a flat line so far.

I'm trying to place values in a float-vector, then modify those values and 
output to the editor.  I know

(float-vector->channel im 0 fsize 0) works,

and I also tried sample (but very slow):

 (do ((i 0 (+ i 1)))

  ((= i fsize))

  (set! (sample i) (im i)))

Wondering if there's an example someplace I haven't found yet for how to 
dsp modify a vector of values and use map-channel to output to the editor?


Thank You,

Jim


I’ve been trying something like below…

but cannot seem to get the map-channel/let/lambda part right.



  (let*  ((fsize 22050)

 (increment (/ (* 440.0 2.0 pi) fsize))

 (im (make-float-vector fsize)) ;empy vector

 (current-phase 0.0)

 (val 0.0) );init var

  (new-sound "test.snd" :size fsize)  ;creates a new snd in editor

;place values in a vector

   (do ((i 0 (+ i 1)))

  ((= i fsize))

   (set! val (* .1 (sin current-phase)))

   (set! current-phase (+ current-phase increment))

   (set! (im i) val)

;(format #t "~%i: ~F  ~0,6F\t " i (im i) )

  )

  (map-channel (lambda (y)

  (do ((i 0 (+ i 1)))

  ((= i fsize))

  (* (amplitude-modulation 0.5) (im i0 fsize))

___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist