Ok, here are some next steps.  Only dealing with specifying pitch so far. 
The number of notes and their duration are both still hard-coded...
-Paul


\version "2.18.0"

% use this to see what the end result should look like:
% \displayMusic { c'4 d e f }
% ===>

% Here it is:
{
  #(make-music
    'SequentialMusic
    'elements
    (list (make-music
           'NoteEvent
           'duration
           (ly:make-duration 2 0 1)
           'pitch
           (ly:make-pitch 0 0 0))
      (make-music
       'NoteEvent
       'pitch
       (ly:make-pitch -1 1 0)
       'duration
       (ly:make-duration 2 0 1))
      (make-music
       'NoteEvent
       'pitch
       (ly:make-pitch -1 2 0)
       'duration
       (ly:make-duration 2 0 1))
      (make-music
       'NoteEvent
       'pitch
       (ly:make-pitch -1 3 0)
       'duration
       (ly:make-duration 2 0 1))))
}

% a function that accepts three arguments that are used to determine pitch: 
% octave note and alteration:

makeFourQuarterNotes =
#(define-music-function (parser location oct nt alt)
   (number? number? number?)
   (make-music
    'SequentialMusic
    'elements
    (list (make-music
           'NoteEvent
           'duration
           (ly:make-duration 2 0 1)
           'pitch
           (ly:make-pitch oct nt alt))
      (make-music
       'NoteEvent
       'pitch
       (ly:make-pitch oct nt alt)
       'duration
       (ly:make-duration 2 0 1))
      (make-music
       'NoteEvent
       'pitch
       (ly:make-pitch oct nt alt)
       'duration
       (ly:make-duration 2 0 1))
      (make-music
       'NoteEvent
       'pitch
       (ly:make-pitch oct nt alt)
       'duration
       (ly:make-duration 2 0 1)))))

{
  \makeFourQuarterNotes #1 #1 #0
  \makeFourQuarterNotes #1 #2 #0
  \makeFourQuarterNotes #0 #1 #-1/2
  \makeFourQuarterNotes #0 #2 #1/2
}




--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Help-with-music-function-generating-music-tp160833p160861.html
Sent from the User mailing list archive at Nabble.com.

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to