Jump to content

Anything wrong with this code, or is it a bug?


Recommended Posts

Hi,

I am encountering a funny problem with the following score. As shown in the comments, notes played in some bars are not as per the

supplied pitches list. Strangely, the musicxml notation and what is played agree!

 

Request your comment on what might be wrong.

 

;;; ---------------

;;; Notes played in the last 2 bars are not as per this list
(setf m1 '((c4) (e4) (b4) (d5) (g4) (g4) (c5 d4 c5 c5 c5) (a4 d4 a4 e5 a4)))
(setf rhy1 '((-w) (-w) (-w) (-w) (-w) (-w) (1/4 1/4 1/8 1/8 1/4) (1/4 1/4 1/8 1/8 1/4)))

 

;;; Notes played in the 6th and 8th bars are not as per this list
(setf m2 '((c4 g4 c4 f4 f4) (e4 d4 c4 d4 f4) (b4 a4 a4 d5 a4) (d5 d5 g4 g4 g4) (g4 d4 d4 g4 c4) 
           (g4 d4 f4 g4 e4) (c5 e5 a4 c5 d4) (a4 a4 e5 e5 a4)))
(setf rhy2 '((1/4 1/4 1/8 1/8 1/4) (1/4 1/4 1/8 1/8 1/4) (1/4 1/8 -1/8 1/4 1/4) 
             (1/4 1/4 1/8 1/8 1/4) (1/4 1/8 1/8 1/4 1/4) (1/4 1/8 -1/8 1/4 1/4) 
             (1/4 1/4 1/4 1/8 1/8) (1/8 1/8 1/4 -1/8 3/8)))

 

(def-score progression-example
           (
            :key-signature 'chromatic
            :time-signature '(4 4)
            :tempo 120
            )
  (instr1 :pitch m1 :length rhy1 :velocity '(f) :channel 1 :sound 'gm :program 'Glockenspiel)

  (instr2 :pitch m2 :length rhy2 :velocity '(f) :channel 2 :sound 'gm :program 'Flute)

)

;;; ------------------

 

Regards,

Rangarajan

Link to post
Share on other sites

it is normal, it play the notes you give. at the end, the last two bars play C4 and E4 and it is what you supply in m1.

it play this pitch because you made rest before, and by the way the system don't need any notes for rest, but when normal rhythm values arrives, it furnish the pitch as given.

 

You can achieve what you want this way:

(setf m1 '((c4) (e4) (b4) (d5) (g4) (g4) (c5 d4 c5 c5 c5) (a4 d4 a4 e5 a4)))
(setf rhy1 '((-w) (-w) (-w) (-w) (-w) (-w) (1/4 1/4 1/8 1/8 1/4) (1/4 1/4 1/8 1/8 1/4)))
 
(setf m1.omn (make-omn
              :pitch m1
              :length rhy1
              :swallow t
              ))
              
(setf m2 '((c4 g4 c4 f4 f4) (e4 d4 c4 d4 f4) (b4 a4 a4 d5 a4) (d5 d5 g4 g4 g4) (g4 d4 d4 g4 c4) 
           (g4 d4 f4 g4 e4) (c5 e5 a4 c5 d4) (a4 a4 e5 e5 a4)))
           
(setf rhy2 '((1/4 1/4 1/8 1/8 1/4) (1/4 1/4 1/8 1/8 1/4) (1/4 1/8 -1/8 1/4 1/4) 
             (1/4 1/4 1/8 1/8 1/4) (1/4 1/8 1/8 1/4 1/4) (1/4 1/8 -1/8 1/4 1/4) 
             (1/4 1/4 1/4 1/8 1/8) (1/8 1/8 1/4 -1/8 3/8)))

(setf m2.omn (make-omn
              :pitch m2
              :length rhy2
              :swallow t
              ))
 
(def-score progression-example
           (
            :key-signature 'chromatic
            :time-signature '(4 4)
            :tempo 120
            )
  (instr1 :omn m1.omn :channel 1 :sound 'gm :program 'Glockenspiel)
  (instr2 :omn m2.omn :channel 2 :sound 'gm :program 'Flute)
)

 

SB

Link to post
Share on other sites

Thanks very much S.B!

 

That seems neat, but tricky. I looked up the documentation of make-omn, but could not find any explanation of the :swallow option, but there was one example. Maybe for everyone's benefit, this could be elaborated in the documentation.

 

By the way, isn't each nested list mapped to one bar? When generating through a function, it was easy (and natural) to do it this way. Looks like I have to do more serious study!

 

Regards,

Rangarajan

Link to post
Share on other sites

you can also use some 'nil for the list corresponding to the rest lengths.

(setf m1 '(nil nil nil nil nil nil (c5 d4 c5 c5 c5) (a4 d4 a4 e5 a4)))
(setf rhy1 '((-w) (-w) (-w) (-w) (-w) (-w) (1/4 1/4 1/8 1/8 1/4) (1/4 1/4 1/8 1/8 1/4)))

but it is not easy, the :swallow way is the best.

 

What is important to understand is the fact that the system take the pitch one after the other.

 

Anyway, please, use the MAKE-OMN way because it is primary the way Opusmodus was thought and use :omn in DEF-SCORE accordingly.

SB

Link to post
Share on other sites

Here is the solution for use with you DEF-SCORE without MAKE-OMN use.

 

This solution is to use GEN-SWALLOW function:

;;; Notes played in the last 2 bars are not as per this list

(setf rhy1 '((-w) (-w) (-w) (-w) (-w) (-w) (1/4 1/4 1/8 1/8 1/4) (1/4 1/4 1/8 1/8 1/4)))
(setf m1 (gen-swallow rhy1 '((c4) (e4) (b4) (d5) (g4) (g4) (c5 d4 c5 c5 c5) (a4 d4 a4 e5 a4))))

;;; Notes played in the 6th and 8th bars are not as per this list

(setf rhy2 '((1/4 1/4 1/8 1/8 1/4) (1/4 1/4 1/8 1/8 1/4) (1/4 1/8 -1/8 1/4 1/4) 
             (1/4 1/4 1/8 1/8 1/4) (1/4 1/8 1/8 1/4 1/4) (1/4 1/8 -1/8 1/4 1/4) 
             (1/4 1/4 1/4 1/8 1/8) (1/8 1/8 1/4 -1/8 3/8)))

(setf m2 (gen-swallow rhy2 '((c4 g4 c4 f4 f4) (e4 d4 c4 d4 f4) (b4 a4 a4 d5 a4) (d5 d5 g4 g4 g4) (g4 d4 d4 g4 c4) 
           (g4 d4 f4 g4 e4) (c5 e5 a4 c5 d4) (a4 a4 e5 e5 a4))))
 
(def-score progression-example
           (
            :key-signature 'chromatic
            :time-signature '(4 4)
            :tempo 120
            )
  (instr1 :pitch m1 :length rhy1 :velocity '(f) :channel 1 :sound 'gm :program 'Glockenspiel)
  (instr2 :pitch m2 :length rhy2 :velocity '(f) :channel 2 :sound 'gm :program 'Flute)
)

Best

 

SB

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

Terms of Use Privacy Policy