Skip to content

Commit bf3c63b

Browse files
committed
Use midi2abc again
When a path to the midi2abc executable exists then use midi2abc. Else use the internal midi to abc conversion from midi2abc.py
1 parent 9e4a22e commit bf3c63b

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ An open source ABC editor for Windows, OSX and Linux. It is published under the
99
- Good ABC standard coverage thanks to internal use of abcm2ps and abc2midi
1010
- Syntax highlighting
1111
- Zoom support
12-
- Import MusicXML, MIDI and Noteworthy Composer files (the midi to abc translator is custom made in order to produce legible abc code with more sensible - beams than the typical midi2abc output).
12+
- Import MusicXML, MIDI and Noteworthy Composer files.
1313
- Export to MIDI, SVG, PDF (single tune or whole tune book).
1414
- Select notes by clicking on them and add music symbols by using drop-down menus in the toolbar.
1515
- Play the active tune as midi (using SoundFont)

easy_abc.py

+20-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
program_name = 'EasyABC 1.3.8.2'
3+
program_name = 'EasyABC 1.3.8.3'
44

55
# Copyright (C) 2011-2014 Nils Liberg (mail: kotorinl at yahoo.co.uk)
66
# Copyright (C) 2015-2021 Seymour Shlien (mail: [email protected]), Jan Wybren de Jong (jw_de_jong at yahoo dot com)
@@ -6102,7 +6102,7 @@ def OnShowSettings(self, evt):
61026102
def OnShowMidiFile(self, evt):
61036103
midi2abc_path = self.settings['midi2abc_path']
61046104
if hasattr(self.current_midi_tune, 'midi_file'):
6105-
MidiToMftext (midi2abc_path, self.current_midi_tune.midi_file)
6105+
MidiToMftext(midi2abc_path, self.current_midi_tune.midi_file)
61066106
else:
61076107
wx.MessageBox(_("You need to create the midi file by playing the tune"), _("Error") , wx.ICON_ERROR | wx.OK)
61086108

@@ -7877,8 +7877,23 @@ def update_statusbar_and_messages(self):
78777877
else:
78787878
self.statusbar.SetStatusText('')
78797879

7880-
78817880
def handle_midi_conversion(self, filename=None, notes=None):
7881+
global execmessages
7882+
midi2abc_path = self.settings.get('midi2abc_path')
7883+
if midi2abc_path and os.path.exists(midi2abc_path):
7884+
cmd = [midi2abc_path, '-f', filename]
7885+
execmessages += '\nMidiToAbc\n' + " ".join(cmd)
7886+
stdout_value, stderr_value, returncode = get_output_from_process(cmd)
7887+
execmessages += '\n' + stdout_value + stderr_value
7888+
if returncode != 0:
7889+
execmessages += '\n' + _('%(program)s exited abnormally (errorcode %(error)#8x)') % { 'program': 'MidiToAbc', 'error': returncode & 0xffffffff }
7890+
return None
7891+
if stdout_value:
7892+
self.AddTextWithUndo('\n' + stdout_value + '\n')
7893+
else:
7894+
self.internal_midi_conversion(filename, notes)
7895+
7896+
def internal_midi_conversion(self, filename=None, notes=None):
78827897
metre1, metre2 = [int(x) for x in self.settings['record_metre'].split('/')]
78837898
metre = Fraction(metre1, metre2)
78847899
abcs = [midi_to_abc(filename=filename, notes=notes, metre=metre, default_len=df) for df in [Fraction(1,16), Fraction(1,8)]]
@@ -7907,9 +7922,7 @@ def handle_midi_conversion(self, filename=None, notes=None):
79077922
try:
79087923
result = dlg.ShowModal() == wx.ID_OK
79097924
if result:
7910-
self.editor.BeginUndoAction()
7911-
self.editor.AddText('\n')
7912-
self.editor.AddText(midi_to_abc(filename=filename, notes=notes,
7925+
abc = midi_to_abc(filename=filename, notes=notes,
79137926
key=dlg.key.GetValue(),
79147927
metre=str2fraction(dlg.metre.GetValue()),
79157928
title=dlg.title.GetValue(),
@@ -7922,9 +7935,7 @@ def handle_midi_conversion(self, filename=None, notes=None):
79227935
slur_16th_pairs=dlg.slur_16ths.GetValue(),
79237936
slur_triplets=dlg.slur_triplets.GetValue(),
79247937
index=self.index)
7925-
)
7926-
self.editor.AddText('\n')
7927-
self.editor.EndUndoAction()
7938+
self.AddTextWithUndo('\n' + abc + '\n')
79287939
self.index += 1
79297940
finally:
79307941
dlg.Destroy() # 1.3.6.3 [JWDJ] 2015-04-21 always clean up dialog window

0 commit comments

Comments
 (0)