remove MIDI support (RIP)

This commit is contained in:
cidoku 2025-10-08 00:35:52 -03:00
parent 20f5e8d3ed
commit f3e66b0efa
6 changed files with 7 additions and 82 deletions

View File

@ -22,7 +22,6 @@ Features added since the last commit of [Headshot's AO2XP](https://github.com/he
- Playing music over HTTPS (on systems where the BASS library can't do it on its own) - Playing music over HTTPS (on systems where the BASS library can't do it on its own)
- Connections over secure websockets (wss) - Connections over secure websockets (wss)
- FLAC music support - FLAC music support
- MIDI music support (needs a soundfount file named `gm.sf2` in the root AO2XP directory)
- Module music support (MOD, XM, IT, S3M) - Module music support (MOD, XM, IT, S3M)
- Unicode support everywhere - Unicode support everywhere

View File

@ -8,23 +8,19 @@ dll = None
dllf = "" dllf = ""
opus = "" opus = ""
flac = "" flac = ""
midi = ""
use_ctypes = False use_ctypes = False
if platform.system() == "Windows": if platform.system() == "Windows":
dllf = "bass.dll" dllf = "bass.dll"
opus = "bassopus.dll" opus = "bassopus.dll"
flac = "bassflac.dll" flac = "bassflac.dll"
midi = "bassmidi.dll"
elif platform.system() == "Darwin": elif platform.system() == "Darwin":
dllf = "libbass.dylib" dllf = "libbass.dylib"
opus = "libbassopus.dylib" opus = "libbassopus.dylib"
flac = "libbassflac.dylib" flac = "libbassflac.dylib"
midi = "libbassmidi.dylib"
else: else:
dllf = "libbass.so" dllf = "libbass.so"
opus = "libbassopus.so" opus = "libbassopus.so"
flac = "libbassflac.so" flac = "libbassflac.so"
midi = "libbassmidi.so"
def checkAvailable(): def checkAvailable():
""" """
@ -34,11 +30,9 @@ Returns string with dll name if it's missing, empty if all DLLs are in place
one = os.path.exists(os.path.abspath(dllf)) one = os.path.exists(os.path.abspath(dllf))
two = os.path.exists(os.path.abspath(opus)) two = os.path.exists(os.path.abspath(opus))
three = os.path.exists(os.path.abspath(flac)) three = os.path.exists(os.path.abspath(flac))
four = os.path.exists(os.path.abspath(midi))
if not one: return dllf if not one: return dllf
if not two: return two if not two: return two
if not three: return three if not three: return three
if not four: return four
return "" return ""
@ -62,13 +56,6 @@ Initialize BASS and the opus plugin
print "[audio] Opus plugin failed to load. Error", getBassError() print "[audio] Opus plugin failed to load. Error", getBassError()
if not dll.BASS_PluginLoad(os.path.abspath(flac), 0): if not dll.BASS_PluginLoad(os.path.abspath(flac), 0):
print "[audio] FLAC plugin failed to load. Error", getBassError() print "[audio] FLAC plugin failed to load. Error", getBassError()
if not dll.BASS_PluginLoad(os.path.abspath(midi), 0):
print "[audio] MIDI plugin failed to load. Error", getBassError()
if os.path.exists(os.path.abspath("gm.sf2")):
dll.BASS_SetConfigPtr(bassmidi.BASS_CONFIG_MIDI_DEFFONT, "gm.sf2");
else:
print "[audio] Soundfont not fount. MIDI files will not play."
def free(): def free():
""" """

View File

@ -1622,7 +1622,7 @@ class GUI(QtGui.QWidget):
self.notGuiltySfx = 0 self.notGuiltySfx = 0
self.stream = 0 self.stream = 0
self.specialStream = 0 self.specialStream = False
self.downloadThread = None self.downloadThread = None
self.tcp = None self.tcp = None
self.demoPlayer = None self.demoPlayer = None
@ -3787,12 +3787,10 @@ class GUI(QtGui.QWidget):
else: else:
error = audio.getBassError() error = audio.getBassError()
#print "[audio] Couldn't play music. Error", error #print "[audio] Couldn't play music. Error", error
# Here comes the evil HTTPS hack for XP systems, but it also allows us to download and play modules and midis, because, why not? # Here comes the evil HTTPS hack for XP systems, but it also allows us to download and play modules, because, why not?
musext = os.path.splitext(basename(musl))[-1] musext = os.path.splitext(basename(musl))[-1]
if musext in ['.mid', '.midi']: if musext in ['.xm', '.mod', '.mo3', '.it', '.s3m', '.mtm', '.umx']:
self.specialStream = 1 self.specialStream = True
elif musext in ['.xm', '.mod', '.mo3', '.it', '.s3m', '.mtm', '.umx']:
self.specialStream = 2
if (musl.startswith("https") and error == 2) or self.specialStream: if (musl.startswith("https") and error == 2) or self.specialStream:
print "[audio] Downloading music with urllib2" print "[audio] Downloading music with urllib2"
self.downloadThread = MusicDownloadThread(self, mus) self.downloadThread = MusicDownloadThread(self, mus)
@ -3804,9 +3802,8 @@ class GUI(QtGui.QWidget):
if audio.handleIsActive(self.music): if audio.handleIsActive(self.music):
audio.stopHandle(self.music) audio.stopHandle(self.music)
if self.specialStream: if self.specialStream:
if self.specialStream == 2: audio.freeMOD(self.music)
audio.freeMOD(self.music) self.specialStream = False
self.specialStream = 0
else: else:
audio.freeHandle(self.music) audio.freeHandle(self.music)
if self.stream: if self.stream:
@ -3820,9 +3817,7 @@ class GUI(QtGui.QWidget):
def playDownloadedMusic(self, file_length): def playDownloadedMusic(self, file_length):
# Part of the evil HTTPS music download hack for XP systems # Part of the evil HTTPS music download hack for XP systems
print "[audio] Done downloading; playing stream" print "[audio] Done downloading; playing stream"
if self.specialStream == 1: if self.specialStream:
self.music = audio.loadMIDI(True, self.stream, 0, file_length, BASS_SAMPLE_LOOP)
elif self.specialStream == 2:
self.music = audio.loadMOD(True, self.stream, 0, file_length, BASS_SAMPLE_LOOP) self.music = audio.loadMOD(True, self.stream, 0, file_length, BASS_SAMPLE_LOOP)
else: else:
self.music = audio.loadHandle(True, self.stream, 0, file_length, BASS_SAMPLE_LOOP) self.music = audio.loadHandle(True, self.stream, 0, file_length, BASS_SAMPLE_LOOP)

View File

View File

@ -37,8 +37,6 @@ BASSOPUSZIP = "bassopus24.zip"
BASSOPUSDLL = "bassopus.dll" BASSOPUSDLL = "bassopus.dll"
BASSFLACZIP = "bassflac24.zip" BASSFLACZIP = "bassflac24.zip"
BASSFLACDLL = "bassflac.dll" BASSFLACDLL = "bassflac.dll"
BASSMIDIZIP = "bassmidi24.zip"
BASSMIDIDLL = "bassmidi.dll"
if platform.system() == "Darwin": if platform.system() == "Darwin":
BASSZIP = "bass24-osx.zip" BASSZIP = "bass24-osx.zip"
BASSDLL = "libbass.dylib" BASSDLL = "libbass.dylib"
@ -46,8 +44,6 @@ if platform.system() == "Darwin":
BASSOPUSDLL = "libbassopus.dylib" BASSOPUSDLL = "libbassopus.dylib"
BASSFLACZIP = "bassflac24-osx.zip" BASSFLACZIP = "bassflac24-osx.zip"
BASSFLACDLL = "libbassflac.dylib" BASSFLACDLL = "libbassflac.dylib"
BASSMIDIZIP = "bassmidi24-osx.zip"
BASSMIDIDLL = "libbassmidi.dylib"
elif platform.system() == "Linux": elif platform.system() == "Linux":
BASSZIP = "bass24-linux.zip" BASSZIP = "bass24-linux.zip"
BASSDLL = "libbass.so" BASSDLL = "libbass.so"
@ -55,9 +51,6 @@ elif platform.system() == "Linux":
BASSOPUSDLL = "libbassopus.so" BASSOPUSDLL = "libbassopus.so"
BASSFLACZIP = "bassflac24-linux.zip" BASSFLACZIP = "bassflac24-linux.zip"
BASSFLACDLL = "libbassflac.so" BASSFLACDLL = "libbassflac.so"
BASSMIDIZIP = "bassmidi24-linux.zip"
BASSMIDIDLL = "libbassmidi.so"
print "downloading", BASSZIP print "downloading", BASSZIP
filedata = urllib2.urlopen('http://us.un4seen.com/files/'+BASSZIP) filedata = urllib2.urlopen('http://us.un4seen.com/files/'+BASSZIP)
datatowrite = filedata.read() datatowrite = filedata.read()

View File

@ -1,49 +0,0 @@
"""
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
"""
from setuptools import setup
APP = ['AO2XP.py']
DATA_FILES = []
OPTIONS = dict(
iconfile = "AO2XP.icns",
includes = [
"PyQt4.QtCore",
"PyQt4.QtGui",
],
excludes = [
"PyQt4.QtDesigner",
"PyQt4.QtNetwork",
"PyQt4.QtOpenGL",
"PyQt4.QtScript",
"PyQt4.QtSql",
"PyQt4.QtTest",
"PyQt4.QtWebKit",
"PyQt4.QtXml",
"PyQt4.phonon",
],
resources = [
"AO2XPbase",
"libbass.dylib",
"libbassopus.dylib",
"mod_call.wav",
"placeholder.png",
"word_call.wav",
],
argv_emulation = False
)
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)