def testDemoMIDI(self): 'test all midi demos, without writing event lists' from athenaCL.libATH import athenaObj ao = athenaObj.AthenaObject() for fp in ao.external.getFilePathDemo(['midi', 'csound'], ['.py']): #ath = athenaObj.Interpreter() #ao = ath.ao #ath.cmd('aorm confirm') #ath.proc_AOrm(None) # for now, need to manually call aorm # best to get a new interpreter ath = athenaObj.Interpreter() ath.cmd('apr off') fpDir, fn = os.path.split(fp) modName = fn.replace('.py', '') environment.printDebug(['processing:', fp]) file, pathname, description = imp.find_module(modName, [fpDir]) module = imp.load_module(modName, file, pathname, description) # pass command lines to main function for line in module.cmd: #environment.printDebug(['line:', line]) ath.cmd(line)
def testDemoWriteMIDI(self): from athenaCL.libATH import athenaObj ao = athenaObj.AthenaObject() for fp in ao.external.getFilePathDemo(['midi'], ['.py']): environment.printDebug(['processing:', fp]) fpDir, fn = os.path.split(fp) modName = fn.replace('.py', '') file, pathname, description = imp.find_module(modName, [fpDir]) module = imp.load_module(modName, file, pathname, description) # pass command lines to main function fpDst = os.path.join(fpDir, modName + '.xml') module.main(module.cmd, fp=fpDst, hear=False)
def __init__(self, fpDocDir=None): """ >>> a = InfoManager() """ self.ao = athenaObj.AthenaObject() if fpDocDir == None: fpDocDir = self.ao.external.fpDocDir if (os.path.exists(fpDocDir) == 1 and os.path.isdir(fpDocDir) == 1): pass else: # this will fail, but usefull for getting info raise ValueError('bad path') environment.printWarn(fpDocDir) self.fpDocDir = fpDocDir self.athVersion = athenaObj.__version__ #self.athRevision = athenaObj.athRevision # info file for fink packages #self.fnInfo = 'athenacl-%s-%s.info' % (self.athVersion, # self.athRevision) #self.fpInfo = os.path.join(self.fpDocDir, self.fnInfo) # bbedit man page in man1, assume this is good. self.manGroup = MANGROUP self.fnMan = MANFILE self.fpMan = os.path.join(self.fpDocDir, self.fnMan) self.fnReadme = 'README.txt' self.fpReadme = os.path.join(self.fpDocDir, self.fnReadme) # for decorative elements self._divChar = ['='] * 24 self._divWidth = 68
def __init__(self, cmdObj=None, srcSize=2, dstSize=2, fmt='pil', master=None): # bar height is the height of texture in pixels. the total height of a # of a window is determined by the number of textures if cmdObj == None: from athenaCL.libATH import athenaObj # update need for color prefs update = athenaObj.External() update.updateAll('noMessages') ao = athenaObj.AthenaObject() self.scObj = SC.SetClass() mcObj = MC.MapClass() else: ao = cmdObj.ao self.scObj = cmdObj.scObj update = ao.external # rename update from AO # this is not necesssary, and thwarts manual-pref loading #update.updatePrefs() # get new settings mcObj = cmdObj.mcObj fontTitle = 'micro' fontText = 'micro' COLORfgMain = update.getPref('gui', 'COLORfgMain') COLORfgAlt = update.getPref('gui', 'COLORfgAlt') COLORbgMargin = update.getPref('gui', 'COLORbgMargin') COLORbgGrid = update.getPref('gui', 'COLORbgGrid') COLORtxTitle = update.getPref('gui', 'COLORtxTitle') COLORtxLabel = update.getPref('gui', 'COLORtxLabel') COLORtxUnit = update.getPref('gui', 'COLORtxUnit') COLORbgAbs = update.getPref('gui', 'COLORbgAbs') rowAxisSets = self.scObj.getAllScTriples(srcSize, ao.tniMode) columnAxisSets = self.scObj.getAllScTriples(dstSize, ao.tniMode) if srcSize == dstSize: self.totalSets = len(rowAxisSets) # ignoring col for now self.masterSetList = rowAxisSets else: self.totalSets = len(rowAxisSets) + len(columnAxisSets) self.masterSetList = rowAxisSets + columnAxisSets if (srcSize, dstSize) in list(self.fixedPosChart.keys()): self.mapPostitionType = 'fixed' else: self.mapPostitionType = 'perimeter' if self.mapPostitionType == 'fixed': sideUnits = self.fixedPosChart[(srcSize, dstSize)]['side'] area = pow(sideUnits, 2) elif self.mapPostitionType == 'perimeter': for side in range(1, 100): area = pow(side, 2) circumSquar = (side * 4) - 4 # units the fill outer perimeter if self.totalSets <= circumSquar: sideUnits = side break self.areaKeys = list(range(0, area)) # list to get a point for all area self.noGutters = sideUnits + 1 self.mapGUTTER = 3 # in pixels self.nodeWidth = 46 self.nodeRadius = 16 #self.yMarginShift = 0 #entryHeadHeight #self.xMarginShift = 23 #boundary on left self.rMarginSize = 4 self.tMarginSize = 4 self.lMarginSize = 24 self.bMarginSize = 4 self.cordDict = {} # used to hold info on each position xCord = 0 yCord = 0 for x in self.areaKeys: # initialize with empty dicts self.cordDict[(xCord, yCord)] = {} xCord = xCord + 1 if xCord == sideUnits: xCord = 0 yCord = yCord + 1 cordKeys = list(self.cordDict.keys()) cordKeys.sort() # this calculate the height of the entire window self.winHEIGHT = ((sideUnits * self.nodeWidth) + (self.noGutters * self.mapGUTTER) + self.tMarginSize + self.bMarginSize) self.winWIDTH = ((sideUnits * self.nodeWidth) + (self.noGutters * self.mapGUTTER) + self.lMarginSize + self.rMarginSize) self.mapHEIGHT = self.winHEIGHT - (self.tMarginSize + self.bMarginSize) self.mapWIDTH = self.winWIDTH - (self.lMarginSize + self.rMarginSize) self.heightAllGutters = self.mapGUTTER * self.noGutters self.heightAllEntries = self.mapHEIGHT - self.heightAllGutters # create canvas self.c = imageTools.Canvas(fmt, self.winWIDTH, self.winHEIGHT, COLORbgAbs, 'MCnet', master) # draw margin rectangles self.c.rectangle(0, 0, self.winWIDTH, self.tMarginSize, COLORbgMargin, None, 0) self.c.rectangle(0, 0, self.lMarginSize, self.winHEIGHT, COLORbgMargin, None, 0) self.c.rectangle(0, self.tMarginSize + self.mapHEIGHT, self.winWIDTH, self.winHEIGHT, COLORbgMargin, None, 0) self.c.rectangle(self.mapWIDTH + self.lMarginSize, 0, self.winWIDTH, self.winHEIGHT, COLORbgMargin, None, 0) # fill coord dict with coords for square, center xPos = self.lMarginSize + self.mapGUTTER yPos = self.tMarginSize + self.mapGUTTER xCord = 0 yCord = 0 for x in self.areaKeys: self.cordDict[(xCord, yCord)]['set'] = None # empty self.cordDict[(xCord, yCord)]['box'] = (xPos, yPos, (xPos + self.nodeWidth), (yPos + self.nodeWidth)) centerX = (xPos + (.5 * self.nodeWidth)) centerY = (yPos + (.5 * self.nodeWidth)) self.cordDict[(xCord, yCord)]['center'] = (centerX, centerY) xPos = xPos + self.nodeWidth + self.mapGUTTER if xPos >= (self.winWIDTH - self.nodeWidth): yPos = yPos + self.nodeWidth + self.mapGUTTER # rest to first x position xPos = self.lMarginSize + self.mapGUTTER xCord = xCord + 1 if xCord == sideUnits: xCord = 0 yCord = yCord + 1 # assign sets to area positions if self.mapPostitionType == 'fixed': setLoc = self.fixedPosChart[(srcSize, dstSize)]['setLoc'] # assign sets to coords for node in list(setLoc.keys()): position = setLoc[node] self.cordDict[position]['set'] = node # counter = counter + 1 elif self.mapPostitionType == 'perimeter': # use parimiter method # get perimeter points locations = list(self.cordDict.keys()) tempLocs = [] for node in locations: if node[0] == 0 or node[1] == 0: tempLocs.append(node) elif node[0] == sideUnits - 1 or node[1] == sideUnits - 1: tempLocs.append(node) # sort perimter clockwise perimeterLocs = [] usedList = [] rowList = [] for node in tempLocs: # do top if node[1] == 0 and node not in usedList: rowList.append(node) usedList.append(node) rowList.sort() perimeterLocs = perimeterLocs + rowList rowList = [] for node in tempLocs: # down right side if node[0] == (sideUnits - 1) and node not in usedList: rowList.append(node) usedList.append(node) rowList.sort() perimeterLocs = perimeterLocs + rowList rowList = [] for node in tempLocs: # across bottom if node[1] == (sideUnits - 1) and node not in usedList: rowList.append(node) usedList.append(node) rowList.sort() rowList.reverse() perimeterLocs = perimeterLocs + rowList rowList = [] for node in tempLocs: # across bottom if node[0] == 0 and node not in usedList: rowList.append(node) usedList.append(node) rowList.sort() rowList.reverse() perimeterLocs = perimeterLocs + rowList # assign sets to coords xCord = 0 yCord = 0 counter = 0 for node in self.masterSetList: position = perimeterLocs[counter] self.cordDict[position]['set'] = node counter = counter + 1 # read coords, create boxes only when there is a sset xCord = 0 yCord = 0 for x in self.areaKeys: if self.cordDict[(xCord, yCord)]['set'] != None: x1, y1, x2, y2 = self.cordDict[(xCord, yCord)]['box'] self.c.rectangle(x1, y1, x2, y2, COLORbgAbs, COLORfgAlt, 1) xCord = xCord + 1 if xCord == sideUnits: xCord = 0 yCord = yCord + 1 # create line nets #netList = [((0,2),(1,2)),((0,1),(2,0)),((0,0),(0,1))] netList = [] for colEntry in columnAxisSets: # 10 for leftmost column for rowEntry in rowAxisSets: srcSet = self.scObj.pcs(colEntry) dstSet = self.scObj.pcs(rowEntry) a = mcObj.displacement(srcSet, dstSet, 1) minDispl, maxDispl, orderedResults, counter = a if minDispl == 1: # find sets in grid lineCords = [] # clear before finding two points for node in list(self.cordDict.keys()): if self.cordDict[node]['set'] == colEntry: lineCords.append(node) if self.cordDict[node]['set'] == rowEntry: lineCords.append(node) if lineCords == []: pass elif lineCords in netList: pass elif (lineCords[1], lineCords[0]) in netList: pass else: netList.append(lineCords) # draw lines for net in netList: a, b = net x1, y1 = self.cordDict[a]['center'] x2, y2 = self.cordDict[b]['center'] self.c.line(x1, y1, x2, y2, COLORfgMain, 1) # read coords, create circles and labels xCord = 0 yCord = 0 for x in self.areaKeys: if self.cordDict[(xCord, yCord)]['set'] != None: setStr = self.scObj.scToStr(self.cordDict[(xCord, yCord)]['set']) centerX, centerY = self.cordDict[(xCord, yCord)]['center'] self.c.oval(centerX - self.nodeRadius, centerY - self.nodeRadius, centerX + self.nodeRadius, centerY + self.nodeRadius, COLORbgAbs, COLORfgMain, width=2) if len(setStr) <= 3: # smallest centerShift = 7 elif len(setStr) <= 4: centerShift = 10 else: # 5 or greater centerShift = 12 xLabel = centerX - centerShift yLabel = centerY - 3 self.c.gridText(xLabel, yLabel, 'nw', setStr, fontTitle, COLORtxTitle) xCord = xCord + 1 if xCord == sideUnits: xCord = 0 yCord = yCord + 1