-
Notifications
You must be signed in to change notification settings - Fork 19
/
Cecilia5.py
executable file
·117 lines (95 loc) · 3.78 KB
/
Cecilia5.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#! /usr/bin/env python3
# encoding: utf-8
"""
Copyright 2019 iACT, Universite de Montreal,
Jean Piche, Olivier Belanger, Jean-Michel Dumas
This file is part of Cecilia 5.
Cecilia 5 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 3 of the License, or
(at your option) any later version.
Cecilia 5 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 Cecilia 5. If not, see <http://www.gnu.org/licenses/>.
"""
import os, sys, random
import wx
from Resources.constants import *
from Resources.Variables import loadBitmaps
from Resources import audio, CeciliaMainFrame
from Resources.splash import CeciliaSplashScreen
import Resources.CeciliaLib as CeciliaLib
class CeciliaApp(wx.App):
def __init__(self, *args, **kwargs):
wx.App.__init__(self, *args, **kwargs)
def MacOpenFiles(self, filenames):
if type(filenames) == list:
filenames = filenames[0]
if CeciliaLib.getVar("mainFrame") is not None:
CeciliaLib.getVar("mainFrame").onOpen(filenames)
def MacReopenApp(self):
try:
CeciliaLib.getVar("mainFrame").Raise()
except:
pass
def onStart():
ceciliaMainFrame = CeciliaMainFrame.CeciliaMainFrame(None, -1)
CeciliaLib.setVar("mainFrame", ceciliaMainFrame)
app.SetTopWindow(ceciliaMainFrame)
file = ""
if len(sys.argv) > 1:
file = sys.argv[1]
if os.path.isfile(file):
ceciliaMainFrame.onOpen(file)
elif CeciliaLib.getVar("lastCeciliaFile") != '' and os.path.isfile(CeciliaLib.getVar("lastCeciliaFile")):
ceciliaMainFrame.onOpen(CeciliaLib.getVar("lastCeciliaFile"),
MODULES_PATH in CeciliaLib.getVar("lastCeciliaFile"))
else:
categories = [folder for folder in os.listdir(MODULES_PATH) if not folder.startswith(".")]
category = random.choice(categories)
files = [f for f in os.listdir(os.path.join(MODULES_PATH, category)) if f.endswith(FILE_EXTENSION)]
file = random.choice(files)
ceciliaMainFrame.onOpen(os.path.join(MODULES_PATH, category, file), True)
if __name__ == '__main__':
audioServer = audio.AudioServer()
CeciliaLib.setVar("audioServer", audioServer)
try:
CeciliaLib.queryAudioMidiDrivers()
except:
pass
app = CeciliaApp(redirect=False)
loadBitmaps()
wx.Log.SetLogLevel(0)
if sys.version_info[0] < 3:
wx.SetDefaultPyEncoding('utf-8')
try:
display = wx.Display()
numDisp = display.GetCount()
if CeciliaLib.getVar("DEBUG"):
print('Numbers of displays:', numDisp)
displays = []
displayOffset = []
displaySize = []
for i in range(numDisp):
displays.append(wx.Display(i))
offset = displays[i].GetGeometry()[:2]
size = displays[i].GetGeometry()[2:]
if CeciliaLib.getVar("DEBUG"):
print('display %d:' % i)
print(' pos =', offset)
print(' size =', size)
print()
displayOffset.append(offset)
displaySize.append(size)
except:
numDisp = 1
displayOffset = [(0, 0)]
displaySize = [(1024, 768)]
CeciliaLib.setVar("numDisplays", numDisp)
CeciliaLib.setVar("displayOffset", displayOffset)
CeciliaLib.setVar("displaySize", displaySize)
sp = CeciliaSplashScreen(None, img=CeciliaLib.ensureNFD(SPLASH_FILE_PATH), callback=onStart)
app.MainLoop()