write("----- ARPEG.SAL ------"); write("Dieses Demoprogramm enthält zwei "); write("Arpeggiogeneratoren: up, sweep"); (* us-------------------------- This program includes two arpeggio-functions up( scale, top note, number of loops) example: up([c/32 e g],[c4],10) sweep(scale, top note, bottom note, number of loops) exapmle: sweep([c/32 e g],[c0],[c4],20) *) (* ---- Arpeggio-Generator up ---- Generiert aus einer Skala ein Arpeggio in Aufwärtsrichtung. Aufruf: up( Skala, höchster Ton, Anzahl wiederholungen ) Beispiel: up([c/32 e g],[c4],10) *) up := FUNC( 3,` scale := $1; maxnote := $2; maxpitch := absPitch(maxnote); count := $3; result := scale; temp := scale; step := #scale; loopn( count,` if(`max(temp)<=maxpitch ´,` temp:=transpTonal( temp, temp, step ); ´, `temp:=scale´); result := result + temp; ´); play(result); return(result); ´); (* ---- Arpeggio-Generator sweep ---- Generiert aus einer Skala ein Arpeggio in Auf- und Abwärtsrichtung. Aufruf: sweep( Skala, tiefster Ton, höchster Ton, Anzahl wiederholungen ) Beispiel: sweep([c/32 e g],[c0],[c4],20) *) sweep := FUNC( 4,` scale := $1; minnote := $2; minpitch := absPitch( minnote); maxnote := $3; maxpitch := absPitch( maxnote ); count := $4; step := #scale; temp := scale; result := scale; loopn( count,` if(`step > 0´,` if( `max(temp) < maxpitch´, ` temp := transpTonal(temp,temp,step) ´, `temp := retro(temp); step := -1*step ´ )´,` if( `min(temp) > minpitch´, `temp := transpTonal(temp,temp,step)´, `temp := retro(temp); step := -1*step´); ´); result := result + temp; ´); play(result); return( result ); ´); (*------ Hilfsfunktionen für Arpeggiator -----*) absPitch := FUNC(1 ,` ton := $1(1,1); pitch := getPitch(ton); abspitch := pitch@1 + (pitch@2 * 12 ); return( abspitch ); ´); min := FUNC( 1,` scale := $1; minpitch := absPitch(scale); minpos := 1; pos := 2; loopn( #scale-1,` abspitch := absPitch( scale(pos,1) ); if(`abspitch < minpitch ´ ,` minpitch := abspitch; minpos := pos ´); pos := pos+1; ´); return( absPitch(scale(minpos,1)) ); ´); max := FUNC( 1,` scale := $1; maxpitch := absPitch(scale); maxpos := 1; pos := 2; loopn( #scale-1,` abspitch := absPitch( scale(pos,1) ); if(`abspitch > maxpitch ´ ,` maxpitch := abspitch; maxpos := pos ´); pos := pos+1; ´); return( absPitch(scale(maxpos,1)) ); ´); write("Aufrufbeispiel: up([c/32 e g],[c3],15) "); up([c/32 e g],[c3],15);