VocalEasel/mma/MMA/gbl.py

193 lines
5.8 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
2011-07-26 22:49:39 +00:00
version = "1.7" # Version -- Nov/2010
""" A few globals are actually set in the calling stub, mma.py.This is
done to make future ports and platform specific settings a bit easier.
The following variables are imported from mma.py and stored here:
platform - host platform, Windows, Linux, etc.
MMAdir - the home directory for mma stuff
The above variables can be accessed from the rest of the mma modules in
the form "gbl.MMAdir", etc.
"""
from __main__ import MMAdir, platform
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
"""
2009-05-17 22:34:44 +00:00
midiAvail = [ 0 ] * 17 # slots 0..16, slot 0 is not used.
2006-11-10 08:07:56 +00:00
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
"""
2009-05-17 22:34:44 +00:00
midiChPrefs = {}
2006-11-10 08:07:56 +00:00
2009-05-17 22:34:44 +00:00
""" Is the -T option is used only the tracks in this list
are generated. All other tracks are muted (OFF)
2006-11-10 08:07:56 +00:00
"""
2009-05-17 22:34:44 +00:00
muteTracks = []
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
2009-05-17 22:34:44 +00:00
QperBar = 4 # Beats/bar, set with TIME
tickOffset = 0 # offset of current bar in ticks
2007-04-29 06:47:40 +00:00
tempo = 120 # current tempo
2009-05-17 22:34:44 +00:00
seqSize = 1 # variation sequence table size
seqCount = 0 # running count of variation
2006-11-10 08:07:56 +00:00
2009-05-17 22:34:44 +00:00
totTime = 0.0 # running duration count in seconds
2006-11-10 08:07:56 +00:00
2009-05-17 22:34:44 +00:00
transpose = 0 # Transpose is global (ignored by drum tracks)
2006-11-10 08:07:56 +00:00
2009-05-17 22:34:44 +00:00
lineno = -1 # used for error reporting
2006-11-10 08:07:56 +00:00
2009-05-17 22:34:44 +00:00
barNum = 0 # Current line number
2007-04-29 06:47:40 +00:00
2011-07-26 22:49:39 +00:00
barPtrs = {} # for each bar, pointers to event start/end
2009-05-17 22:34:44 +00:00
synctick = 0 # flag, set if we want a tick on all tracks at offset 0
endsync = 0 # flag, set if we want a eof sync
2006-11-10 08:07:56 +00:00
2009-05-17 22:34:44 +00:00
############# Path and search variables. #############
2011-07-26 22:49:39 +00:00
# In mma.py we checked for known directories and inserted the
# first found 'mma' directory into the sys.path list and set MMAdir.
# Assume that this is where the rest of mma's configuration file
# live. If mma runs but can't fine includes, etc. look in mma.py
# and add the proper paths.
2009-05-17 22:34:44 +00:00
2006-11-10 08:07:56 +00:00
2011-07-26 22:49:39 +00:00
libPath = os.path.join(MMAdir, 'lib')
if not os.path.isdir(libPath):
print "Warning: Library directory not found."
incPath = os.path.join(MMAdir, 'includes')
if not os.path.isdir(incPath):
print "Warning: Include directory not found."
# Set up autolib defaults. We start with MMALIB/stdlib and append
# any other directories we find in MMALIB. Note, the order of
# libs after stdlib is alphabetical.
# User can change the libs with SetAutoLibPath dir1 dir2 etc.
autoLib=['stdlib']
dirs = sorted(os.listdir(libPath))
for d in dirs:
if os.path.isdir(os.path.join(libPath, d)) and d not in autoLib:
autoLib.append(d)
2006-11-10 08:07:56 +00:00
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
2009-05-17 22:34:44 +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
"""
2011-07-26 22:49:39 +00:00
barRange = [] # both -B and -b use this
# the Lxxx values are the previous settings, used for LASTDEBUG macro
debug = Ldebug = 0
pshow = Lpshow = 0
seqshow = Lseqshow = 0
showrun = Lshowrun = 0
noWarn = LnoWarn = 0
noOutput = LnoOutput = 0
showExpand = LshowExpand = 0
2007-04-29 06:47:40 +00:00
showFilenames = LshowFilenames = 0
2011-07-26 22:49:39 +00:00
chshow = Lchshow = 0
plecShow = LplecShow = 0 # not a command line setting
rmShow = LrmShow = 0 # not command
2007-04-29 06:47:40 +00:00
outfile = None
infile = None
2009-05-17 22:34:44 +00:00
createDocs = 0
2007-04-29 06:47:40 +00:00
maxBars = 500
makeGrvDefs = 0
cmdSMF = None
2006-11-10 08:07:56 +00:00
2009-05-17 22:34:44 +00:00
playFile = 0 # set if we want to call a player
2011-07-26 22:49:39 +00:00
2006-11-10 08:07:56 +00:00