Kara-Moon Forum

Developers & Technology => Musical MIDI Accompaniment (MMA) => Topic started by: bvdp on June 03, 2021, 02:05:27 AM



Title: Fix for AFTER command?
Post by: bvdp on June 03, 2021, 02:05:27 AM
I noticed the other day that a command like:

   
Code:
   After Repeat=1 Print Here we go again
   Am * 4

did not work. Nothing printed at all. I spent way to many hours tracking this down and have come up with a fix. In parse.py at line 346 I changed the code to read:
Code:
           if rpt:
                gbl.barNum -= 1
                if MMA.after.needed():
                    MMA.after.check(recurse=True)
                gbl.barNum += 1

I think it is working now. But really do want some verification before I lock it in.

Thanks.
 
   


Title: Re: Fix for AFTER command?
Post by: bvdp on June 03, 2021, 06:27:10 PM
Okay, okay ... it still is not working  ::) I will do more work on this as whip it into submission.


Title: Re: Fix for AFTER command?
Post by: bvdp on June 03, 2021, 07:03:19 PM
I think I have it now :) The problem was my choice of variable to see if a repeat was active. So, let's try this again. In the module parse.py we need to change 2 occurrences of "rpt" to "rptcount > 1". These occur at lines 343 and 350.

Code:
            # if repeat count is set with dupchord we push
            # the chord back and get lyric.extract to add the
            # chord to the midi file again. A real lyric is
            # just ignored ... 2 reasons: the lyric is mangled and
            # and it makes sense to only have it once!
            if rptcount > 1 and lyric.dupchords:
                _,lyrics = lyric.extract(' '.join(l), 0)

            # The barNum and other pointers have been incremented
            # and a bar of data has been processed. If we are repeating
            # due to a "*" we do a AGAIN test. Without a rpt this would
            # be done at the start of a data line.
            if rptcount > 1 and  MMA.after.needed():
                MMA.after.check(recurse=True)


Again, I'm hoping someone can test this and let me know!


Title: Re: Fix for AFTER command?
Post by: sciurius on June 05, 2021, 01:28:30 PM
I get "here we go again" 4 times, while I would expect it to print only once...

Test file t.mma:

Code:
After Repeat=1 Print Here we go again
Am * 4

Before the fix (mma as distributed):

Code:
Opening file 't.mma'.
After: Added event 'Print Here we go again' at bar 1.
File 't.mma' closed.
No data created. Did you remember to set a groove/sequence?

After the fix:

Code:
Opening file 't.mma'.
After: Added event 'Print Here we go again' at bar 1.
Opening file '/tmp/MMA_xovzel1t.mma'.
Here we go again
File '/tmp/MMA_xovzel1t.mma' closed.
Opening file '/tmp/MMA_53imszoy.mma'.
Here we go again
File '/tmp/MMA_53imszoy.mma' closed.
Opening file '/tmp/MMA_lnwkn0_m.mma'.
Here we go again
File '/tmp/MMA_lnwkn0_m.mma' closed.
Opening file '/tmp/MMA_9nwtq1dl.mma'.
Here we go again
File '/tmp/MMA_9nwtq1dl.mma' closed.
File 't.mma' closed.
No data created. Did you remember to set a groove/sequence?


Title: Re: Fix for AFTER command?
Post by: bvdp on June 05, 2021, 03:45:33 PM
why would you only expect it to print one time? The idea behind AFTER is that it does "something" after creating/processing each bar of music. Have a go with pre/post fix versions with this:

   After Repeat=4 Print Printing a silly comment
   Am * 24



Title: Re: Fix for AFTER command?
Post by: sciurius on June 07, 2021, 06:24:16 AM
I think I got confused. I've only user "After Count" once in a while...


Title: Re: Fix for AFTER command?
Post by: bvdp on June 07, 2021, 03:47:40 PM
No worries ... I was confused by whole mess as well. But, I think it is solid now!