VocalEasel/mma/MMA/gbl.py

172 lines
4.7 KiB
Python
Raw Normal View History

2006-11-10 08:07:56 +00:00
# globals.py
"""
This module is an integeral part of the program
MMA - Musical Midi Accompaniment.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2007-04-29 06:47:40 +00:00
Bob van der Poel <bob@mellowood.ca>
2006-11-10 08:07:56 +00:00
"""
import os
2007-04-29 06:47:40 +00:00
version = "1.1" # Version -- March 7/2007
2006-11-10 08:07:56 +00:00
""" mtrks is storage for the MIDI data as it is created.
It is a dict of class Mtrk() instances. Keys are the
2007-04-29 06:47:40 +00:00
midi channel numbers. Ie, mtrks[2] is for channel 2,
etc. mtrks[0] is for the meta stuff.
2006-11-10 08:07:56 +00:00
"""
mtrks = {}
""" tnames is a dict of assigned track names. The keys are
the track names; each entry is a pattern class instance.
2007-04-29 06:47:40 +00:00
We have tnames['BASS-FOO'], etc.
2006-11-10 08:07:56 +00:00
"""
tnames = {}
""" midiAssigns keeps track of channel/track assignments. The keys
are midi channels (1..16), the data is a list of tracks assigned
2007-04-29 06:47:40 +00:00
to each channel. The tracks are only added, not deleted. Right
now this is only used in -c reporting.
2006-11-10 08:07:56 +00:00
"""
midiAssigns={}
for c in range(0,17):
2007-04-29 06:47:40 +00:00
midiAssigns[c]=[]
2006-11-10 08:07:56 +00:00
""" midiAvail is a list with each entry representing a MIDI channel.
As channels are allocated/deallocated the appropriated slot
2007-04-29 06:47:40 +00:00
is inc/decremented.
2006-11-10 08:07:56 +00:00
"""
midiAvail=[ 0 ] * 17 # slots 0..16, slot 0 is not used.
2007-04-29 06:47:40 +00:00
deletedTracks = [] # list of deleted tracks for -c report
2006-11-10 08:07:56 +00:00
""" This is a user constructed list of names/channels. The keys
are names, data is a channel. Eg. midiChPrefs['BASS-SUS']==9
"""
midiChPrefs={}
""" Groove storage. Each entry in settingsGroove{} has a keyname
of a saved groove.
2007-04-29 06:47:40 +00:00
lastGroove and currentGroove are used by macros
2006-11-10 08:07:56 +00:00
"""
2007-04-29 06:47:40 +00:00
settingsGroove = {}
2006-11-10 08:07:56 +00:00
lastGroove = ''
currentGroove = ''
""" SeqRnd variable is a list. The first entry is a flag:(0, 1 or x):
0 - not set
2007-04-29 06:47:40 +00:00
1 - set
2 - set for specific tracks, track list starts at position [1]
2006-11-10 08:07:56 +00:00
"""
2007-04-29 06:47:40 +00:00
seqRnd = [0] # set if SEQRND has been set
2006-11-10 08:07:56 +00:00
############# String constants ####################
2007-04-29 06:47:40 +00:00
ext = ".mma" # extension for song/lib files.
2006-11-10 08:07:56 +00:00
############## Tempo, and other midi positioning. #############
2007-04-29 06:47:40 +00:00
BperQ = 192 # midi ticks per quarter note
QperBar = 4 # Beats/bar, set with TIME
tickOffset = 0 # offset of current bar in ticks
tempo = 120 # current tempo
seqSize = 1 # variation sequence table size
seqCount = 0 # running count of variation
2006-11-10 08:07:56 +00:00
2007-04-29 06:47:40 +00:00
transpose = 0 # Transpose is global (ignored by drum tracks)
2006-11-10 08:07:56 +00:00
2007-04-29 06:47:40 +00:00
lineno = -1 # used for error reporting
2006-11-10 08:07:56 +00:00
swingMode = 0 # defaults to 0, set to 1 for swing mode
swingSkew = None # this is just for $_SwingMode macro
barNum = 0 # Current line number
2007-04-29 06:47:40 +00:00
synctick = 0 # flag, set if we want a tick on all tracks at offset 0
2006-11-10 08:07:56 +00:00
############# Path and search variables. #############
libPath = ''
2007-04-29 06:47:40 +00:00
for p in ( "c:\\mma\\lib", "/usr/local/share/mma/lib", "/usr/share/mma/lib", "./lib"):
if os.path.isdir(p):
libPath=p
break
2006-11-10 08:07:56 +00:00
incPath = ''
for p in ( "c:\\mma\\includes", "/usr/local/share/mma/includes",
2007-04-29 06:47:40 +00:00
"/usr/share/mma/includes", "./includes"):
if os.path.isdir(p):
incPath=p
break
2006-11-10 08:07:56 +00:00
autoLib = 'stdlib'
2007-04-29 06:47:40 +00:00
outPath = '' # Directory for MIDI file
mmaStart = [] # list of START files
mmaEnd = [] # list of END files
mmaRC = None # user specified RC file, overrides defaults
inpath = None # input file
2006-11-10 08:07:56 +00:00
2007-04-29 06:47:40 +00:00
midiFileType = 1 # type 1 file, SMF command can change to 0
runningStatus = 1 # running status enabled
2006-11-10 08:07:56 +00:00
############# Options. #############
""" These variables are all set from the command line in MMA.opts.py.
It's a bit of an easy-way-out to have them all here, but I don't think
2007-04-29 06:47:40 +00:00
it hurts too much.
2006-11-10 08:07:56 +00:00
"""
2007-04-29 06:47:40 +00:00
debug = Ldebug = 0
pshow = Lpshow = 0
seqshow = Lseqshow = 0
showrun = Lshowrun = 0
noWarn = LnoWarn = 0
noOutput = LnoOutput = 0
showExpand = LshowExpand = 0
showFilenames = LshowFilenames = 0
chshow = Lchshow = 0
outfile = None
infile = None
docs = 0
maxBars = 500
makeGrvDefs = 0
cmdSMF = None
2006-11-10 08:07:56 +00:00