From d5b64c8dc71bb22216594bd683095ee32201626f Mon Sep 17 00:00:00 2001 From: JotaChina Date: Fri, 18 Apr 2025 09:18:36 -0300 Subject: [PATCH] Enviar arquivos para "/" --- audiofileprocessor.py | 96 +++++++++++++++++++++++++++++++++++++++++++ freeboy.py | 88 +++++++++++++++++++++++++++++++++++++++ sfxr.py | 88 +++++++++++++++++++++++++++++++++++++++ sid.py | 88 +++++++++++++++++++++++++++++++++++++++ tripleoscilator.py | 86 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 446 insertions(+) create mode 100644 audiofileprocessor.py create mode 100644 freeboy.py create mode 100644 sfxr.py create mode 100644 sid.py create mode 100644 tripleoscilator.py diff --git a/audiofileprocessor.py b/audiofileprocessor.py new file mode 100644 index 0000000..3896152 --- /dev/null +++ b/audiofileprocessor.py @@ -0,0 +1,96 @@ +import xml.etree.ElementTree as ET + +def parse_mmp_file(file_path): + try: + tree = ET.parse(file_path) + root = tree.getroot() + bpm = root.find('./head').attrib.get('bpm', 'N/A') + tracks = root.findall('./song/trackcontainer/track') + track_info = [] + + for track in tracks: + track_name = track.attrib.get('name', 'N/A') + track_type = track.attrib.get('type') + instruments = [] + + # Para cada faixa, processar seus instrumenttracks + for instrumenttrack in track.findall('./instrumenttrack'): + instrument_info = {} + + # Extraindo os atributos do + instrument_info['instrumenttrack'] = { + 'pitch': instrumenttrack.attrib.get('pitch', 'N/A'), + 'pan': instrumenttrack.attrib.get('pan', 'N/A'), + 'pitchrange': instrumenttrack.attrib.get('pitchrange', 'N/A'), + 'basenote': instrumenttrack.attrib.get('basenote', 'N/A'), + 'vol': instrumenttrack.attrib.get('vol', 'N/A'), + 'fxch': instrumenttrack.attrib.get('fxch', 'N/A'), + 'usemasterpitch': instrumenttrack.attrib.get('usemasterpitch', 'N/A') + } + + # Adicionando suporte para o plugin "audiofileprocessor" + instrument = instrumenttrack.find('.//instrument') + if instrument is not None: + instrument_name = instrument.attrib.get('name', 'N/A') + instrument_info['instrument_name'] = instrument_name + + # Verificar se é o "audiofileprocessor" e extrair os atributos + if instrument_name.lower() == "audiofileprocessor": + audiofileprocessor = instrument.find('.//audiofileprocessor') # Buscando pelo plugin "audiofileprocessor" + if audiofileprocessor is not None: + instrument_info['audiofileprocessor'] = {} + for key, value in audiofileprocessor.attrib.items(): + instrument_info['audiofileprocessor'][key] = value + + # Verificar se é o "tripleoscillator" e extrair os parâmetros + elif instrument_name.lower() == "tripleoscillator": + tripleoscillator = instrument.find('.//tripleoscillator') + if tripleoscillator is not None: + instrument_info['tripleoscillator'] = {} + for key, value in tripleoscillator.attrib.items(): + instrument_info['tripleoscillator'][key] = value + + # Extraindo os dados do + eldata = instrumenttrack.find('.//eldata') + if eldata is not None: + instrument_info['eldata'] = { + 'fwet': eldata.attrib.get('fwet', 'N/A'), + 'ftype': eldata.attrib.get('ftype', 'N/A'), + 'fcut': eldata.attrib.get('fcut', 'N/A'), + 'fres': eldata.attrib.get('fres', 'N/A') + } + + # Extraindo os elementos , , + for el in ['elvol', 'elcut', 'elres']: + el_element = eldata.find('.//' + el) + if el_element is not None: + instrument_info[el] = {} + for key, value in el_element.attrib.items(): + instrument_info[el][key] = value + + # Extraindo dados do , , , + for tag_name in ['chordcreator', 'arpeggiator', 'midiport', 'fxchain']: + tag_element = instrumenttrack.find('.//' + tag_name) + if tag_element is not None: + instrument_info[tag_name] = {} + for key, value in tag_element.attrib.items(): + instrument_info[tag_name][key] = value + + instruments.append(instrument_info) + + # Adiciona a faixa com os instrumentos + track_info.append({ + 'track_name': track_name, + 'type': track_type, + 'instruments': instruments, + }) + + return { + 'file': file_path, + 'bpm': bpm, + 'tracks': track_info + } + + except ET.ParseError as e: + print(f'Erro ao analisar o arquivo XML {file_path}: {e}') + return None diff --git a/freeboy.py b/freeboy.py new file mode 100644 index 0000000..62b7de4 --- /dev/null +++ b/freeboy.py @@ -0,0 +1,88 @@ +import xml.etree.ElementTree as ET + +def parse_mmp_file(file_path): + try: + tree = ET.parse(file_path) + root = tree.getroot() + bpm = root.find('./head').attrib.get('bpm', 'N/A') + tracks = root.findall('./song/trackcontainer/track') + track_info = [] + + for track in tracks: + track_name = track.attrib.get('name', 'N/A') + track_type = track.attrib.get('type') + instruments = [] + + # Para cada faixa, processar seus instrumenttracks + for instrumenttrack in track.findall('./instrumenttrack'): + instrument_info = {} + + # Extraindo os atributos do + instrument_info['instrumenttrack'] = { + 'pitch': instrumenttrack.attrib.get('pitch', 'N/A'), + 'pan': instrumenttrack.attrib.get('pan', 'N/A'), + 'pitchrange': instrumenttrack.attrib.get('pitchrange', 'N/A'), + 'basenote': instrumenttrack.attrib.get('basenote', 'N/A'), + 'vol': instrumenttrack.attrib.get('vol', 'N/A'), + 'fxch': instrumenttrack.attrib.get('fxch', 'N/A'), + 'usemasterpitch': instrumenttrack.attrib.get('usemasterpitch', 'N/A') + } + + # Adicionando suporte para o plugin "papu" (FreeBoy) + instrument = instrumenttrack.find('.//instrument') + if instrument is not None: + instrument_name = instrument.attrib.get('name', 'N/A') + instrument_info['instrument_name'] = instrument_name + + # Verificar se é o "papu" (FreeBoy) e extrair os atributos + if instrument_name.lower() == "papu": + papu = instrument.find('.//papu') # Buscando pelo plugin "papu" + if papu is not None: + instrument_info['papu'] = {} + for key, value in papu.attrib.items(): + instrument_info['papu'][key] = value + + # Extraindo os dados do + eldata = instrumenttrack.find('.//eldata') + if eldata is not None: + instrument_info['eldata'] = { + 'fwet': eldata.attrib.get('fwet', 'N/A'), + 'ftype': eldata.attrib.get('ftype', 'N/A'), + 'fcut': eldata.attrib.get('fcut', 'N/A'), + 'fres': eldata.attrib.get('fres', 'N/A') + } + + # Extraindo os elementos , , + for el in ['elvol', 'elcut', 'elres']: + el_element = eldata.find('.//' + el) + if el_element is not None: + instrument_info[el] = {} + for key, value in el_element.attrib.items(): + instrument_info[el][key] = value + + # Extraindo dados do , , , + for tag_name in ['chordcreator', 'arpeggiator', 'midiport', 'fxchain']: + tag_element = instrumenttrack.find('.//' + tag_name) + if tag_element is not None: + instrument_info[tag_name] = {} + for key, value in tag_element.attrib.items(): + instrument_info[tag_name][key] = value + + instruments.append(instrument_info) + + # Adiciona a faixa com os instrumentos + track_info.append({ + 'track_name': track_name, + 'type': track_type, + 'instruments': instruments, + }) + + return { + 'file': file_path, + 'bpm': bpm, + 'tracks': track_info + } + + except ET.ParseError as e: + print(f'Erro ao analisar o arquivo XML {file_path}: {e}') + return None diff --git a/sfxr.py b/sfxr.py new file mode 100644 index 0000000..59cda96 --- /dev/null +++ b/sfxr.py @@ -0,0 +1,88 @@ +import xml.etree.ElementTree as ET + +def parse_mmp_file(file_path): + try: + tree = ET.parse(file_path) + root = tree.getroot() + bpm = root.find('./head').attrib.get('bpm', 'N/A') + tracks = root.findall('./song/trackcontainer/track') + track_info = [] + + for track in tracks: + track_name = track.attrib.get('name', 'N/A') + track_type = track.attrib.get('type') + instruments = [] + + # Para cada faixa, processar seus instrumenttracks + for instrumenttrack in track.findall('./instrumenttrack'): + instrument_info = {} + + # Extraindo os atributos do + instrument_info['instrumenttrack'] = { + 'pitch': instrumenttrack.attrib.get('pitch', 'N/A'), + 'pan': instrumenttrack.attrib.get('pan', 'N/A'), + 'pitchrange': instrumenttrack.attrib.get('pitchrange', 'N/A'), + 'basenote': instrumenttrack.attrib.get('basenote', 'N/A'), + 'vol': instrumenttrack.attrib.get('vol', 'N/A'), + 'fxch': instrumenttrack.attrib.get('fxch', 'N/A'), + 'usemasterpitch': instrumenttrack.attrib.get('usemasterpitch', 'N/A') + } + + # Adicionando suporte para o plugin "sfxr" + instrument = instrumenttrack.find('.//instrument') + if instrument is not None: + instrument_name = instrument.attrib.get('name', 'N/A') + instrument_info['instrument_name'] = instrument_name + + # Verificar se é o "sfxr" e extrair os atributos + if instrument_name.lower() == "sfxr": + sfxr = instrument.find('.//sfxr') # Buscando pelo plugin "sfxr" + if sfxr is not None: + instrument_info['sfxr'] = {} + for key, value in sfxr.attrib.items(): + instrument_info['sfxr'][key] = value + + # Extraindo os dados do + eldata = instrumenttrack.find('.//eldata') + if eldata is not None: + instrument_info['eldata'] = { + 'fwet': eldata.attrib.get('fwet', 'N/A'), + 'ftype': eldata.attrib.get('ftype', 'N/A'), + 'fcut': eldata.attrib.get('fcut', 'N/A'), + 'fres': eldata.attrib.get('fres', 'N/A') + } + + # Extraindo os elementos , , + for el in ['elvol', 'elcut', 'elres']: + el_element = eldata.find('.//' + el) + if el_element is not None: + instrument_info[el] = {} + for key, value in el_element.attrib.items(): + instrument_info[el][key] = value + + # Extraindo dados do , , , + for tag_name in ['chordcreator', 'arpeggiator', 'midiport', 'fxchain']: + tag_element = instrumenttrack.find('.//' + tag_name) + if tag_element is not None: + instrument_info[tag_name] = {} + for key, value in tag_element.attrib.items(): + instrument_info[tag_name][key] = value + + instruments.append(instrument_info) + + # Adiciona a faixa com os instrumentos + track_info.append({ + 'track_name': track_name, + 'type': track_type, + 'instruments': instruments, + }) + + return { + 'file': file_path, + 'bpm': bpm, + 'tracks': track_info + } + + except ET.ParseError as e: + print(f'Erro ao analisar o arquivo XML {file_path}: {e}') + return None diff --git a/sid.py b/sid.py new file mode 100644 index 0000000..035a258 --- /dev/null +++ b/sid.py @@ -0,0 +1,88 @@ +import xml.etree.ElementTree as ET + +def parse_mmp_file(file_path): + try: + tree = ET.parse(file_path) + root = tree.getroot() + bpm = root.find('./head').attrib.get('bpm', 'N/A') + tracks = root.findall('./song/trackcontainer/track') + track_info = [] + + for track in tracks: + track_name = track.attrib.get('name', 'N/A') + track_type = track.attrib.get('type') + instruments = [] + + # Para cada faixa, processar seus instrumenttracks + for instrumenttrack in track.findall('./instrumenttrack'): + instrument_info = {} + + # Extraindo os atributos do + instrument_info['instrumenttrack'] = { + 'pitch': instrumenttrack.attrib.get('pitch', 'N/A'), + 'pan': instrumenttrack.attrib.get('pan', 'N/A'), + 'pitchrange': instrumenttrack.attrib.get('pitchrange', 'N/A'), + 'basenote': instrumenttrack.attrib.get('basenote', 'N/A'), + 'vol': instrumenttrack.attrib.get('vol', 'N/A'), + 'fxch': instrumenttrack.attrib.get('fxch', 'N/A'), + 'usemasterpitch': instrumenttrack.attrib.get('usemasterpitch', 'N/A') + } + + # Adicionando suporte para o plugin "sid" + instrument = instrumenttrack.find('.//instrument') + if instrument is not None: + instrument_name = instrument.attrib.get('name', 'N/A') + instrument_info['instrument_name'] = instrument_name + + # Verificar se é o "sid" e extrair os atributos + if instrument_name.lower() == "sid": + sid = instrument.find('.//sid') # Buscando pelo plugin "sid" + if sid is not None: + instrument_info['sid'] = {} + for key, value in sid.attrib.items(): + instrument_info['sid'][key] = value + + # Extraindo os dados do + eldata = instrumenttrack.find('.//eldata') + if eldata is not None: + instrument_info['eldata'] = { + 'fwet': eldata.attrib.get('fwet', 'N/A'), + 'ftype': eldata.attrib.get('ftype', 'N/A'), + 'fcut': eldata.attrib.get('fcut', 'N/A'), + 'fres': eldata.attrib.get('fres', 'N/A') + } + + # Extraindo os elementos , , + for el in ['elvol', 'elcut', 'elres']: + el_element = eldata.find('.//' + el) + if el_element is not None: + instrument_info[el] = {} + for key, value in el_element.attrib.items(): + instrument_info[el][key] = value + + # Extraindo dados do , , , + for tag_name in ['chordcreator', 'arpeggiator', 'midiport', 'fxchain']: + tag_element = instrumenttrack.find('.//' + tag_name) + if tag_element is not None: + instrument_info[tag_name] = {} + for key, value in tag_element.attrib.items(): + instrument_info[tag_name][key] = value + + instruments.append(instrument_info) + + # Adiciona a faixa com os instrumentos + track_info.append({ + 'track_name': track_name, + 'type': track_type, + 'instruments': instruments, + }) + + return { + 'file': file_path, + 'bpm': bpm, + 'tracks': track_info + } + + except ET.ParseError as e: + print(f'Erro ao analisar o arquivo XML {file_path}: {e}') + return None diff --git a/tripleoscilator.py b/tripleoscilator.py new file mode 100644 index 0000000..6fef45f --- /dev/null +++ b/tripleoscilator.py @@ -0,0 +1,86 @@ +import xml.etree.ElementTree as ET + +def parse_mmp_file(file_path): + try: + tree = ET.parse(file_path) + root = tree.getroot() + bpm = root.find('./head').attrib.get('bpm', 'N/A') + tracks = root.findall('./song/trackcontainer/track') + track_info = [] + + for track in tracks: + track_name = track.attrib.get('name', 'N/A') + track_type = track.attrib.get('type') + instruments = [] + + # Para cada faixa, processar seus instrumenttracks + for instrumenttrack in track.findall('./instrumenttrack'): + instrument_info = {} + + # Extraindo os atributos do + instrument_info['instrumenttrack'] = { + 'pitch': instrumenttrack.attrib.get('pitch', 'N/A'), + 'pan': instrumenttrack.attrib.get('pan', 'N/A'), + 'pitchrange': instrumenttrack.attrib.get('pitchrange', 'N/A'), + 'basenote': instrumenttrack.attrib.get('basenote', 'N/A'), + 'vol': instrumenttrack.attrib.get('vol', 'N/A'), + 'fxch': instrumenttrack.attrib.get('fxch', 'N/A'), + 'usemasterpitch': instrumenttrack.attrib.get('usemasterpitch', 'N/A') + } + + # Extraindo o nome do instrumento + instrument = instrumenttrack.find('.//instrument') + if instrument is not None: + instrument_info['instrument_name'] = instrument.attrib.get('name', 'N/A') + + # Extraindo os parâmetros do + tripleoscillator = instrument.find('.//tripleoscillator') + if tripleoscillator is not None: + instrument_info['tripleoscillator'] = {} + for key, value in tripleoscillator.attrib.items(): + instrument_info['tripleoscillator'][key] = value + + # Extraindo os dados do + eldata = instrumenttrack.find('.//eldata') + if eldata is not None: + instrument_info['eldata'] = { + 'fwet': eldata.attrib.get('fwet', 'N/A'), + 'ftype': eldata.attrib.get('ftype', 'N/A'), + 'fcut': eldata.attrib.get('fcut', 'N/A'), + 'fres': eldata.attrib.get('fres', 'N/A') + } + + # Extraindo os elementos , , + for el in ['elvol', 'elcut', 'elres']: + el_element = eldata.find('.//' + el) + if el_element is not None: + instrument_info[el] = {} + for key, value in el_element.attrib.items(): + instrument_info[el][key] = value + + # Extraindo dados do , , , + for tag_name in ['chordcreator', 'arpeggiator', 'midiport', 'fxchain']: + tag_element = instrumenttrack.find('.//' + tag_name) + if tag_element is not None: + instrument_info[tag_name] = {} + for key, value in tag_element.attrib.items(): + instrument_info[tag_name][key] = value + + instruments.append(instrument_info) + + # Adiciona a faixa com os instrumentos + track_info.append({ + 'track_name': track_name, + 'type': track_type, + 'instruments': instruments, + }) + + return { + 'file': file_path, + 'bpm': bpm, + 'tracks': track_info + } + + except ET.ParseError as e: + print(f'Erro ao analisar o arquivo XML {file_path}: {e}') + return None