本文整理汇总了Python中views.HomeView.loadSample方法的典型用法代码示例。如果您正苦于以下问题:Python HomeView.loadSample方法的具体用法?Python HomeView.loadSample怎么用?Python HomeView.loadSample使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类views.HomeView
的用法示例。
在下文中一共展示了HomeView.loadSample方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: homeAction
# 需要导入模块: from views import HomeView [as 别名]
# 或者: from views.HomeView import loadSample [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)
#.........这里部分代码省略.........