It may seem a little strange when you first look at impromptu that there are no “musical” functions provided for you.  This is a conscious decision.  While it is impossible to provide a “tool” that does not in some way influence its user my goal with impromptu is to provide a framework without any prescribed musical features.  Of course this is somewhat of a ridiculous goal given that straight out of the gate impromptu’s use of MIDI strongly preferences a traditional diatonic tonal system (I should point out that MIDI does not enforce this - quarter tone composers don’t despair, I’ll do a quarter tone example!).  Nevertheless my aim with impromptu is primarily to provide a shell that takes care of the “low level” details and leaves the creative/representational details to the user (as much as practicable).
 
So with these thoughts in mind I want to stress that these music tutorials show some ways of representing musical processes/data not the way.  For example, MIDI pitch numbers are certainly not the only way to represent or control pitch in impromptu - you are just as free to use a function to continuously control the Hz value of a Reaktor patch parameter (as I often do).  I designed impromptu so you don’t have to think about how to write scheduling engines and garbage collectors - you do have to think about writing useful musical processes/representations!
 
One last thing.  Make sure you have read the impromptu basics tutorial before you begin these tutorials.
 
So enough with the lecture already!!  Let’s start by looking at how we can play a sequence of notes.  First, let’s implement a simple iterative process. Remember that 60 is middle C, 61 is C#, 62 is D etc...
 
;; iterative sequence
(dotimes (i 8)
   (play-note (+ (now) (* i 5000)) piano (+ 60 i) 80 4000))
 
Simple enough.  But there is a problem here.  we don’t have any control over dotimes iterator i.  What if we want to play a whole tone scale.  Let’s use recursion to try to solve this problem.  Ok all you scheme newbies it’s time time find out about named lets :)
 
;; recursive whole-tone scale
(let loop ((i 0))
   (play-note (+ (now) (* i 2500)) piano (+ 60 i) 80 4000)
   (if (< i 9) (loop (+ i 2))))
 
I’m sure there are a few people whispering - he could have done that with dotimes - but this is scheme and well frankly the quicker we move onto recursion the better ;)
 
So, linear sequences don’t seem to present a problem.  How about a major scale.  Well, our recursion should handle this for us.
 
;; recursive major scale
(let loop ((scale '(0 2 4 5 7 9 11 12))
           (time 0))
   (play-note (+ (now) time) piano (+ 60 (car scale)) 80 4000)
   (if (not (null? (cdr scale)))
       (loop (cdr scale) (+ time 5000))))
 
We also added a second argument to loop - time.  Let’s use that time argument to add changing durations to our scale.  
 
;; recursive major scale with rhythm
(let loop ((scale '(0 2 4 5 7 9 11 12))
           (dur '(22050 11025 11025 22050 11025 11025 44100 44100))
           (time 0))
   (play-note (+ (now) time) piano (+ 60 (car scale)) 80 (car dur))
   (if (not (null? (cdr scale)))
       (loop (cdr scale) (cdr dur) (+ time (car dur)))))
 
Ok now that we have pitches and rhythms mastered how do we go about playing a chord.  The new time argument from the previous examples should give you a pretty good clue.  Just lose the time argument!
 
;; recursive chord
(let loop ((chord '(0 4 7)))
   (play-note (now) piano (+ 60 (car chord)) 80 44100)
   (if (not (null? (cdr chord)))
       (loop (cdr chord))))
 
;; we could also write this
(let loop ((scale '(0 4 7)))
   (cond ((null? scale) 'finished)
         (else (play-note (now) piano (+ 60 (car scale)) 80 44100)
               (loop (cdr scale)))))
 
C Major, nice!  We seem to be using lists a lot and I know that all you newbie scheme programmers are just dying to use map so here goes.
 
;; map calls lambda for each argument of list
(map (lambda (p)
        (play-note (now) piano p 80 44100))
     (list 60 63 67))
 
Wow, C minor, nice!  That’s much shorter, why don’t we always use map.  There are a couple of reasons why sometimes it’s better not to use map but we’ll come to those soon enough.  For the moment let’s look at how we can use map to play a broken chord.
 
;; map broken chord
(map (lambda (p d)
        (play-note (+ (now) d) piano p 80 (- 88200 d)))
     (list 60 64 67)
     (list 0 22050 44100))
 
One small thing to keep in mind.  map is designed to return a new list of values to you.  The process of creating this list makes map slightly less efficient than the function for-each which is not specified to return a list but is instead designed for it’s side effects (i.e. playing notes in this instance).  So if you don’t need to return a list use for-each instead of map.
 
;; for-each broken chord with volumes
(for-each (lambda (p d v)
             (play-note (+ (now) d) piano p v (- 88200 d)))
          (list 60 64 67)
          (list 0 22050 44100)
          (list 90 50 20))
 
Ok, now we’ve covered the basics before we move on if you haven’t read the time tutorial it’s time to go and read it now.