[Impromptu] problem using two metres
Andrew Sorensen
andrew at moso.com.au
Thu Mar 12 00:29:15 GMT 2009
Hi Michele,
You've run into ye oldie play-note vs play trap. This happens to me
all the time :)
The duration of play-note is in samples and the duration of play is in
beats. So at 120bpm 10000 beats is equal to 5000 seconds - more than
an hour. *second*, depending on your hardware, probably equals 44100,
48000 or 96000 so that's going to be many hours :)
So basically you're killing the audio because you're not releasing any
of your notes (i.e. polyphony problems). Change *second* to 1 and
10000 to 1 and youre code works fine.
If you are using single metre's (i.e. not needing a 2 followed by a 3
followed by a 2 for example) then you could just use modulo directly.
Also remember that make-metre is currently "broken" - see Glen's post
from a couple of days ago.
;; using modulo directly
(define loop
(lambda (beat)
(case (modulo beat 8)
((0)
(play piano 60 120 1)
(play piano 36 120 1))
((1 2 3)
(play piano 36 120 1))
((4 5 6 7)
(play piano 40 120 1)))
(callback (*metro* (+ beat (* .5 1/2))) 'loop (+ beat 1/2))))
(loop (*metro* 'get-beat 4))
On 11/03/2009, at 9:06 PM, Michele Pasin wrote:
>
> Hi dear Impromptu-fellows,
>
> would you have a go with the code below?
> On my machine the audio constantly disappears after exactly 1 minute
> and 33 seconds (I know, the melody sounds awful, it's because I
> stripped it down to the bare basics for making my point).
>
> If you're wondering what kind of thing I was trying to do... well
> basically I wanted to make a piece by organizing it into various
> 'patches' of 4/4, and call them from a 'master' patch of 8/4 (or 16/4
> or more..).
> It was just an idea, maybe this approach is totally wrong since
> conception! In such case, how would you approach it instead?
>
>
> tx a lot!
>
> mik
>
>
>
>
>
> ===================================================
>
> (au:clear-graph)
>
> (define piano (au:make-node "aumu" "dls " "appl"))
> (define *mixer* (au:make-node "aumx" "smxr" "appl"))
>
> (au:connect-node piano 0 *mixer* 1)
> (au:connect-node *mixer* 0 *au:output-node* 0)
>
> (au:update-graph)
> (au:print-graph)
>
> ;;; times
>
> (define *metro* (make-metro 120))
> (define metre (make-metre '(4) 1)) ;; a classic 4/4
> (define metre2 (make-metre '(8) 1))
>
> ;;;;;;;;;
> ;;
> ;;; this crashes the sound output ... I timed it, always after 1:33
>
> (define mel1
> (lambda (beat)
> (if (metre beat 1)
> (play piano 60 60 *second*))
> (if (metre2 beat 1 )
> (play piano 48 60 *second*))
> (if (metre2 beat 1 )
> (mel2 beat 36))
> (if (metre2 beat 5 )
> (mel2 beat 40))
> (callback (*metro* (+ beat .4)) 'mel1 (+ beat .5))))
>
>
> (define mel2
> (lambda (beat note)
> (if #t
> (play piano note 50 10000))
> (if (not (metre beat 4))
> (callback (*metro* (+ beat .4)) 'mel2 (+ beat 1) note))))
>
>
>
> (mel1 (*metro* 'get-beat))
>
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> Impromptu mailing list
> Impromptu at lists.moso.com.au
> http://lists.moso.com.au/mailman/listinfo/impromptu
More information about the Impromptu
mailing list