(define *srate* 44100)
(definstrument (fm-simple start-time duration carrier-frequency modulator-frequency modulation-index amplitude-envelope)
    (let* ((start-sample (* start-time *srate*))
           (end-sample (+ start-sample (* duration *srate*)))
           (carrier (make-oscil :frequency carrier-frequency))
           (modulator (make-oscil :frequency modulator-frequency))
           (index (hz->radians (* modulation-index modulator-frequency))) 
           (amp-env (make-env :duration duration :envelope amplitude-envelope)))
      (do ((sample-number  start-sample (+ sample-number  1)))
         ((> sample-number  end-sample)) 
            (outa sample-number (* (env amp-env)
                                   (oscil carrier (* index (oscil modulator))))))))

#|
; simple harmonic ratio                                        
(with-sound (:srate 44100 :statistics #t :output "fm-simple1.aiff") 
  (fm-simple 0 10 440 220 1 '(0 0 0.5 1 1 0)))
; stranger harmonic ratio = virtual fundamental
(with-sound (:srate 44100 :statistics #t :output "fm-simple2.aiff") 
  (fm-simple 0 10 440 330 1 '(0 0 0.5 1 1 0)))
; inharmonic ratio
(with-sound (:srate 44100 :statistics #t :output "fm-simple3.aiff") 
  (fm-simple 0 10 440 130 2 '(0 0 0.5 1 1 0)))
|#