This file is indexed.

/usr/bin/mup2mma is in mma 15.12-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#! /usr/bin/python

""" mup2mma extracts chords from a MUP music notation file and
    creates a MMA file. For this to work the MUP file must use
    the macro "C" for chord. In my MUP files I have the following:
    
        define C bold (11) chord above all: @
        
    This script just checks all input lines and assumes that anything
    starting with "C" is a chord line.

    Additional "features":
    
        Lines in the form "// TEMPO: xx" generate a Tempo entry
        "time =" lines are parsed for common time signatures
        repeats are inserted as comment lines

    0.3 - added options:
                 -m   add melody lines
                 -l     add lyrics
                 -o    overwrite

    0.4 - reformatted output
    
    0.5 - corrected melody/lyric notation.

    1.0 - converted to python 2 or 3 (March/2014)

    bvdp, Dec/2004
    
"""

import os
import sys
import getopt

# Useful functions

def error(m=''):
    print("Error: %s" % m)
    sys.exit(1)
    
def usage():
    print("""mup2mma - (c) Bob van der Poel
Extract MMA data from MUP file.
Options:
 -o   overwrite existing MMA file
 -m   extract melody data
 -l   extract lyric data
 -v   print version
""")
    sys.exit(0)

# Global variables

Version = '1.0'

overwrite = 0         # set if overwrite of old mma file okay
doLyric = 0           # set if we want lyrics output
doMelody = 0          #  set if we want melody output


# Parse command line, open files 
 
try:
    opts, args = getopt.gnu_getopt(sys.argv[1:],  "omlv")
except getopt.GetoptError:
    usage()

for o, a in opts:
    if o == '-o':
        overwrite = 1
    elif o == '-l':
        doLyric = 1
    elif o == '-m':
        doMelody = 1
    elif o == '-v':
        print(Version)
        sys.exit(0)
    else:
        usage()

if len(args) != 1:
    error("Exactly 1 filename is required.")

infile = args[0]

outfile = os.path.basename(infile)
if outfile.endswith('.mup'):
    outfile = outfile[:-4]
title = outfile.replace("-", ' ').title()
outfile += ".mma"

try:
    bars = open(infile)
except:
    error("Can't open input file '%s'." % infile)

if os.path.exists(outfile) and not overwrite:
    error("File '%s' already exists." % outfile)

try:
    out = open(outfile, "w")
except:
    error("Can't open output file '%s'." % outfile)

# Input and output files open, start processing

out.write( "// %s\n\n" % title)

bnum = 1

donebar = 0
melody = ''
lyric = ''
chordList = []

for b in bars:
    b = b.strip()
    if b == '':               # skip empty lines
         continue

    if b.startswith("// TEMPO:"):
        out.write("Tempo %s\n\n" % b.split()[2])
        continue

    # Parse out time sig from MUP
    
    ck = b.split("=")
    
    if len(ck) and ck[0].strip() == 'time':
        ts=ck[1].strip()
        if ts in ('common', '4/4'):
            beats = 4
            posStep = 1
            
        elif ts in ('cut', '2/4', '2/2'):
            beats = 2
            posStep = .5
            
        elif ts=='3/4':
            beats = 3
            posStep = 1
            
        elif ts=='6/8':
            beats = 6
            posStep = 1
        
        elif ts=='12/8':
            beats = 12
            posStep = 4
        elif ts=='5/4':
            beats = 5
            posStep = 1
        else:
            error("Unknown time sig, %s" % b)
    
    # Parse line number from MUP
    
    if b.startswith('// #') or b.startswith('//# '):
        bnum = b[4:]

    # Parse out melody, lyric and chords.
    #    Melody must be a line starting with "M:"
    #    Lyric must be a line starting with "L:"
    #    Chord must be a line starting with "C "

    key = b.split()[0]
            

    if key == 'M:' and doMelody:         
        melody = b.split(' ', 1)[1]
        
    elif key == 'L:' and doLyric:
        lyric = b.split(' ', 1)[1]

    elif key == 'C':
        ch = b[2:]
        ch=ch.replace ('"', ' ')
        ch=ch.replace('&', 'b')
        ch = ch[:-1]
        ch=ch.split(';')
        
        chordList = []
        pos = 1.0
        
        for c in ch:
            c = c.split()
            off = c[0]
            
            # Strip out printing offset from chord. Since the position
            # has been split off, we just strip out everything after the
            # inital '['. If this doesn't work, then the MUP is wrong as well
            #    eg:  1.5[-5]  becomes 1.5 
            
            if off.count('['):
                off=off[:off.index('[')]
            
            count = float(off)
            
            while pos < count:
                chordList.append('/')
                pos += posStep            
                
            chord=c[1]
            if chord.upper()=="TACET" or chord.upper()=='N.C':
                chord = 'z'
            
            chord = chord.replace('^', 'M')
            chord = chord.replace('o', 'dim')
            chord = chord.replace('\\(dim)', 'dim')
            chord = chord.replace('6/9', '6(add9)')

            chordList.append(chord )
            pos += posStep
        
    
    elif key in ('bar', 'repeatend', 'endbar', 'dblbar', '(dblbar)',
            'repeatstart', 'repeatboth' ):

        out.write('%-4s' % bnum)
        
        if not chordList:
            chordList = ['/'] 
        for a in chordList:
            out.write((' %6s' % a).rstrip())
            chordList = []
            
        if doMelody and melody:
            out.write(('  { %s }' % melody).rstrip())
            melody = ''
            
        if doLyric and lyric:
            out.write(('  [ %s ]' % lyric).rstrip())
            lyric = ''
        
        out.write('\n')

        try:
            if int(bnum) % 4 == 0:   # put in blank line every 4 bars
                out.write('\n')
        except:
            pass

        if key == 'repeatend':
            out.write( "\n// RepeatEnd\n\n")
        if key == 'repeatboth':
            out.write( "\n// RepeatEnd\n\n")
            out.write( "// Repeat\n\n")
        if key == "repeatstart" or key=='(dblbar)':
            out.write( "\n// Repeat\n\n")
            
        rpt = b.split()[1:]
        
        if len(rpt) and rpt[0] == "ending":
            out.write( '\n// RepeatEnding\n\n')

    else:
        pass     # Just ignore other MUP stuff
    
out.write('\n')
out.close()