nested MERGEs

GeoDanCor@aol.com GeoDanCor@aol.com
Sun, 2 Mar 1997 07:59:24 -0500 (EST)


> create a file cminit-lisp ... with the following lines: (IN-PACKAGE :CM)
(STELLA)) ... in for some reason that doesnt work...
Thanks, it's OK: CM loads the cminit.lsp file under DOS/WIN95. 

- I wish put ALGs in different MERGEs (m1, m2 ...), which I work separately,
evtl. on different 
- channels, then only set them in a finale MERGE (m) ...
- The times of ALGs in MERGE m1, m2... are not correctly worked, so the
result is
- unforeseeable. It seems, this times interact free between different MERGEs.

- Here the simplest example to prove that: 
- (merge m ()
-	(merge m1 ()		  
-		(algorithm a1 midi-note (start 0 end 8 amplitude .5 channel 0)			
-           (setf note (item (steps 1 -1 2 -2 in random initially-from 'a4)))
-			(setf rhythm (item (rhythms 16 32)))   	))		 				 
-	(merge m2 ()
- 			(algorithm a2 midi-note (start 13 end 21 amplitude .2 channel 1)
-				(setf note (item (notes bf3 gf ef in random)))
-				(setf rhythm (item (rhythms 16 8)))  ))   )
-
> im not sure what you mean -- your example works correctly from cm's point
> of view. note that except for the top level merge you dont need to name the
> internal ones. also your example really doesnt need the internal merges. it
> could be more simply written so:
> (merge m ()
>  (algorithm nil midi-note (start 0 end 8 amplitude .5 channel 0)
>    (setf note (item (steps 1 -1 2 -2 in random initially-from 'a4)))
>    (setf rhythm (item (rhythms 16 32)))   	)
>  (algorithm nil midi-note (start 13 end 21 amplitude .2 channel 1)
>    (setf note (item (notes bf3 gf ef in random)))
>   (setf rhythm (item (rhythms 16 8)))  )   )

Well, my example was not good - but as it was, it can show the times errors
in nested MERGEs by writing MIDI-files (proved on WIN95 and MAC). Here is a
better one: 

(merge m ()
	(setf zv 0)

	(merge m1 ()				  
	  (dotimes (i 144) 	
		(setf x0 (+ 1 (random 8)))		
		(case x0
			(1	(setf dv (item (items 1 2 3 2 in heap))) 
				(setf x1 (+ 1 (random 3)))
				(case x1
					(1	 (algorithm (name 'nva1- T) midi-note 
							(start zv end (+ zv (- dv .125)) amplitude .5 channel 0)
							(setf note (item (steps 1 -1 2 -2 3 -3 
								in random initially-from 'a6)))
  							(setf rhythm (item (rhythms 32)))	))
 					(2	 (algorithm (name 'nva2- T) midi-note 
							(start zv end (+ zv (- dv .125)) amplitude .5 channel 0)
							(setf note (item (steps 1 -1 2 -1 
								in random initially-from 'fs6))) 	 	
							(setf rhythm (item (rhythms 32)))	))
					(3	 (algorithm (name 'nva3- T) midi-note 
							(start zv end (+ zv (- dv .125)) amplitude .5 channel 0)
							(setf note (item (steps 1 -1 2 1 -2 
								in random initially-from 'cs6))) 	 	
							(setf rhythm (item (rhythms 32)))	)) 		))	 	
			(2	(setf dv (item (items 1 2 in heap)))
				(setf x2 (+ 1 (random 2)))
				(case x2
					(1  (algorithm (name 'nvb- T) midi-note 
							(start zv end (+ zv (- dv .125)) amplitude .8 channel 0)			
							(setf note (item (notes [af3 ef4] r)))
							(setf rhythm (item (rhythms 16 16 
										(rhythms 16/3 16/3 16/3)
										(rhythms 32 32 32 32)			
										(rhythms 16 16) 
										(rhythms 32 32 32 32 32 32)
										in random traversing breadth)))  ))
					(2  (algorithm (name 'nvb- T) midi-note 
							(start zv end (+ zv (- dv .125)) amplitude .8 channel 0)			
							(setf note (item (notes [af3 ef4] r)))
							(setf rhythm (item (rhythms 16 16 16
										(rhythms 32 32 32 32 32 32 32 32 32 32)
										in random traversing depth)))  ))		))									 
			(3 (setf dv (item (items 2 3 4 3 2 in heap)))
				(setf x3 (+ 1 (random 3)))
				(case x3
					(1  (algorithm (name 'nvc1- T) midi-note 
							(start zv end (+ zv (- dv .125)) amplitude .5 channel 0)
								(setf note (item (notes 
									a5 g f e f d e f  gs a f g  
									a gn f e  d e f g  f e d  a a4 a	
									d5 e f gs a e gn  f e d  cs 
									d e f gs a e gn  f e d a a4 a ))) 	 
								(setf rhythm (item (rhythms 
									16 16 16 16 16 16 16 16 16 16 16 16
									16 16 16 16 16 16 16 16 16 16  8  4 8 8 	
									16 16 16 16 16 16 16 16 16 16 16 16 
									16 16  8 16 16 16 16  8  4  8  8 ))) ))						
					(2  (algorithm (name 'nvc2- T) midi-note 
							(start zv end (+ zv (- dv .125)) amplitude .5 channel 0)
								(setf note (item (notes 
								 r 	d5 e f gs a e gn  f e d cs d e f gs 
							  		a e gn f e d  a a4 a ))) 	 
								(setf rhythm (item (rhythms 
								8	16 16 16 16 8 16 16 16 16 16 16 16 
									16 16 16 8 16 16 16 16 8 4 8 8 ))) ))							
					(3  (algorithm (name 'nvc3- T) midi-note 
							(start zv end (+ zv (- dv .125)) amplitude .5 channel 0)
								(setf note (item (notes 
								r	f5 d e f gs a f gs  a gn f e  
									d e f g  f e d  a a4 a	
									d5 e f gs a e gn  f e d cs 
									d e f gs a e gn  f e d a a4 a ))) 	 
 								(setf rhythm (item (rhythms 
 								16	16 16 16 16 16 16 16 16 16 16 16 16 16 
 									16 16 16 16 16 8 4 8  	
									16 16 16 16 8 16 16 16 16 16 16 16 16 
									16 16 8 16 16 16 16 8 4 8 8 ))) ))	))		
			(4	  (setf dv (item (items 1 2 3 4 3 2 in heap)))
				  (algorithm (name 'nve- T) midi-note	
					(start zv end (+ zv (- dv .125)) amplitude .5 channel 0)
						(setf note (item (notes cs4)))
						(setf rhythm (item (rhythms 8 16 16 32)))  ))	 		
			(5	(setf dv (item (items 3 4 5 4 3 2 in heap)))
				(algorithm (name 'nvf- T) midi-note	
					(start zv end (+ zv (- dv .125)) amplitude .5 channel 0)
						(setf note (item (notes g3)))
						(setf rhythm (item (rhythms 1 2 4 16 16))) ))				
			(6	(setf dv (item (items 1 2 3 2 in heap)))
				(algorithm (name 'nvg- T) midi-note 
					(start zv end (+ zv (- dv .125)) amplitude .5 channel 0)
						(setf note (item (notes [b4 fs5] r)))
						(unless-chording
						(setf rhythm (item (rhythms 8 16)))) 	 ))		
			(7	(setf dv (item (items 1 2 3 4 3 2 in heap)))
				(setf x7 (+ 1 (random 3)))
				(case x7
					(1  (algorithm (name 'nvh1- T) midi-note 
							(start zv end (+ zv (- dv .125)) amplitude .5 channel 0)
  							(setf note (item (notes 
	  						r	 g6 f e f d e f  gs a f gn  
  								a g f e  d e f g  f e d  a a4 a	
								d5 e f gs a e gn  f e d cs d e f gs 
								a e gn  f e d a a4 a ))) 	 
 							(setf rhythm (item (rhythms 
 							16	 16 16 16 16 16 16 16 16 16 16 16 
 								16 16 16 16 16 16 16 16	16 16 8 4 8 8 	
 								16 16 16 16 8 16 16 16 16 16 16 16 
	 							16 16 16 8 16 16 16 16 8 4 8 8 ))) ))							
 					(2 (algorithm (name 'nvh2- T) midi-note 
							(start zv end (+ zv (- dv .125)) amplitude .5 channel 0)
  							(setf note (item (notes 
  								d5 e f gs a e gn  f e d cs d e f gs 
  								a e gn f e d  a a4 a ))) 	 
	 						(setf rhythm (item (rhythms 
 								16 16 16 16 8 16 16 16 16 16 16 16 
 								16 16 16 8 16 16 16 16 8 4 8 8 ))) ))			
 					(3  (algorithm (name 'nvh3- T) midi-note 
							(start zv end (+ zv (- dv .125)) amplitude .5 channel 0)
  							(setf note (item (notes 
  								f gs  a gn f e  d e f g  f e d  a a4 a	
								f5 e d cs d e f gs a e gn  f e d a a4 a ))) 	 
 							(setf rhythm (item (rhythms 
 								16 16 16 16 16 16 16 16 16 16 16 
 								16 16 8 4 8 16 16 16 16 16 16 16 8 
 								16 16 16 16 8 4 8 8 ))) )) 	))					 
 			(8			(setf dv (item (items 1 2 3 4 5 4 3 2 in heap)))
				(setf x8 (+ 1 (random 3)))
					(case x8
						(1  	(thread (name 'nvd- T) 	(start zv)
								(object rest rhythm 4)	))	
	 					(2 	(thread (name 'nvd- T) 	(start zv)
								(object rest rhythm 2)	))
						(3		(thread (name 'nvd- T) 	(start zv)
								(object rest rhythm 8)	))	 )	)	)	
				(setq zv (+ zv dv)))
 
(merge m2 ()			 
	(loop for zp1 in	'(13 21  34  55  121)
			for dp1 in	'(8  13   13  21  13)
			do
			(algorithm (name 'npa- T) midi-note
				(start zp1 end (+ zp1 (- dp1 .125)) amplitude .2 channel 6)
				(setf note (item (notes (notes bf6 gf ef in cycle)
										(notes bf6 gf df in cycle) in random)))
				(setf rhythm (item (rhythms 16 16 16)))	))					

	(loop for zp2 in	'(21 26 34 55 89 121)
			for dp2 in 	'(13 5  13 21  8    )
			do
			(algorithm (name 'npb- T) midi-note
				(start zp2 end (+ zp2 (- dp2 .125)) amplitude .02 channel 7)
				(setf note (item (notes [a2 b c3 d e])))
    			(setf rhythm (item (rhythms 1 2))) 	))	) 
(merge m3 () .... )
(merge m4 () .... )   ;;; and so on!
)

Please don't care the details, the problem is not how much ALGs or how
complex are they, but: 
how can I use nested MERGEs? I wish work them complete separately, then load
and mix them free, eventually reuse in other combinations. 	
Thank you!

Regards,
Corneliu Dan