本文整理匯總了Python中models.Config.getEffectOptions方法的典型用法代碼示例。如果您正苦於以下問題:Python Config.getEffectOptions方法的具體用法?Python Config.getEffectOptions怎麽用?Python Config.getEffectOptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Config
的用法示例。
在下文中一共展示了Config.getEffectOptions方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: homeAction
# 需要導入模塊: from models import Config [as 別名]
# 或者: from models.Config import getEffectOptions [as 別名]
class HomeController:
homeView = None
#Called to generate the first window of the program
def homeAction(self):
self.pyo = Server(audio="offline", nchnls=1, sr=44100).boot()
self.pyo.recordOptions(dur=5, filename=None, fileformat=0, sampletype=3)
self.config = Config()
root = Tk()
self.samples = []
self.sampleCnt = 0
self.homeView = HomeView(root, self)
self.effect1 = 'None'
self.effect2 = 'None'
self.tempo = 10
root.mainloop()
def loadSample(self, sample):
self.homeView.loadSample(sample)
def getConfig(self):
return self.config
def startRec(self, file):
self.pyo.recstart(file)
def stopRec(self):
self.pyo.recstop()
def upload(self):
initDir = '/'
dirName = tkFileDialog.askdirectory(title="Please select the root directory of the MPC device")
if not dirName:
print 'None selected'
return
cnt = 0
for sample in self.samples:
sampleModel = sample.getSample()
if sampleModel is not None:
sampleModel.export(self, cnt, dirName)
cnt += 1
self.generateConfig(dirName)
def registerUISample(self, sample):
self.samples.append(sample)
def generateConfig(self, path):
data = []
sActive = 0
val = 0
for sample in self.samples:
val = 0
sampleModel = sample.getSample()
if sample.getActive():
val = 1
if sample.getLatch():
val = val | 2
data.append(val)
data.append(int(self.tempo))
data.append(self.getEffectIndex(self.effect1))
data.append(self.getEffectIndex(self.effect2))
print data
filePath = path + '/mpc/mpc.txt'
f = open(filePath, 'w+')
f.write(pack('19B', *data))
f.close()
def setEffect(self, pos, value):
if pos == 0:
self.effect1 = value
if pos == 1:
self.effect2 = value
def getEffectIndex(self, value):
cnt = 0
for effect in self.config.getEffectOptions():
if effect == value:
return cnt
cnt += 1
return 0
def loadConfig(self):
fileOptions = {}
fileOptions['filetypes'] = [('MPC config', 'mpc.txt')]
fname = tkFileDialog.askopenfilename(**fileOptions)
print fname
if not fname:
print 'None selected'
return
f = open(fname, 'r')
data = f.read(19)
#.........這裏部分代碼省略.........