Skip to content

Instantly share code, notes, and snippets.

@Agnostic
Last active August 29, 2015 14:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Agnostic/d9b59cd73ff97847c1a8 to your computer and use it in GitHub Desktop.
Save Agnostic/d9b59cd73ff97847c1a8 to your computer and use it in GitHub Desktop.
C Major Chord in Impromptu
; C Major Chord
; By Gilberto Avalos
; Clear all
(au:clear-graph)
; Define piano instrument
(define piano (au:make-node "aumu" "dls " "appl"))
(au:connect-node piano 0 *au:output-node* 0)
(au:update-graph)
; Variables
(define initialNote 48)
(define scales 3)
; Internal Variables
(define note initialNote)
(define notes 0)
; Play function
(define play
(lambda ()
(if (and (= notes 0) (> note 48) )
(set! note (+ note 1))
)
(if (= notes 2)
(set! notes -1)
)
(print "Play Note" note notes)
; Play note
(play-note (now) piano note 100 10000)
(if (< notes 1)
(set! note (+ note 4))
)
(if (= notes 1)
(set! note (+ note 3))
)
(set! notes (+ notes 1))
)
)
; Loop function
(define loop
(lambda ()
; Call Play
(play)
; If note < max scales
(if (< note (+ initialNote (* 12 scales) ) )
(callback (+ (now) (* 0.20 *second*)) loop)
)
; End of scale
(if (= note (+ (+ initialNote (* 12 scales) 4) ))
(print "Fin")
)
)
)
; Call loop
(loop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment