Skip to content

Commit f071c15

Browse files
committed
Updated xml2abc and abc2xml
- Updated xml2abc and abc2xml - sorting of tunes is now case insensitive
1 parent 7a71416 commit f071c15

8 files changed

+436
-115
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ Temporary Items
4747

4848
# Compiled Python
4949
*.pyc
50+
*.pyd
51+
52+
# Executables/DLL
53+
*.exe
54+
*.dll
5055

5156
abc_styler - geen succes.py
5257
*.stackdump
58+
build
59+
dist

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"python.pythonPath": "C:/Python27/python.exe",
2+
//"python.pythonPath": "C:/Python27/python.exe",
3+
"python.pythonPath": "C:/Python36-32/python.exe",
34

45
"files.exclude": {
56
"**/*.pyc": true,

abc2xml.py

+152-44
Large diffs are not rendered by default.

easy_abc.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/python2.7
22
#
33

4-
program_name = 'EasyABC 1.3.7.8 2018-01-04'
4+
program_name = 'EasyABC 1.3.7.8 2018-04-23'
55

66
# Copyright (C) 2011-2014 Nils Liberg (mail: kotorinl at yahoo.co.uk)
77
# Copyright (C) 2015-2018 Seymour Shlien (mail: [email protected]), Jan Wybren de Jong (jw_de_jong at yahoo dot com)
@@ -673,7 +673,7 @@ def sort_abc_tunes(abc_code, sort_fields, keep_free_text=True):
673673
preceeding_lines.append(line)
674674

675675
def get_sort_key_for_tune(tune, sort_fields):
676-
return tuple([tune.header.get(f, '') for f in sort_fields])
676+
return tuple([tune.header.get(f, '').lower() for f in sort_fields])
677677

678678
tunes = [(get_sort_key_for_tune(t, sort_fields), t) for t in tunes]
679679
tunes.sort()
@@ -2084,7 +2084,8 @@ def __init__(self, parent, settings, statusbar):
20842084
PathEntry('midi2abc', _('midi2abc executable:'), _('This executable is used to disassemble the output midi file'), True),
20852085
PathEntry('gs', _('ghostscript executable:'), _('This executable is used to create PDF files'), False),
20862086
PathEntry('nwc2xml', _('nwc2xml executable:'), _('For NoteWorthy Composer - Windows only'), False),
2087-
PathEntry('midiplayer', _('midiplayer:'), _('Your preferred MIDI player'), False)
2087+
PathEntry('midiplayer', _('midiplayer:'), _('Your preferred MIDI player'), False),
2088+
PathEntry('soundfont', _('soundfont:'), _('Your preferred Sound Font (.sf2)'), False)
20882089
]
20892090

20902091
if wx.Platform == "__WXMSW__":
@@ -4204,11 +4205,9 @@ def play():
42044205
self.mc.Seek(0) # When using wx.media.MEDIABACKEND_QUICKTIME the music starts playing too early (when loading a file)
42054206
time.sleep(0.5) # hopefully this fixes the first notes not being played
42064207
self.play()
4207-
print('blabla')
42084208
wx.CallAfter(play)
42094209

42104210
def OnAfterStop(self):
4211-
print('OnAfterStop')
42124211
# 1.3.6.3 [SS] 2015-05-04
42134212
self.flip_tempobox(False)
42144213
self.stop_playing()
@@ -5007,7 +5006,8 @@ def export_tune(self, tune, file_type, extension, convert_func, path, show_save_
50075006
finally:
50085007
dlg.Destroy() # 1.3.6.3 [JWDJ] 2015-04-21 always clean up dialog window
50095008

5010-
filepath = filepath.encode('utf-8')
5009+
if not PY3:
5010+
filepath = filepath.encode('utf-8')
50115011
if convert_func(tune, filepath):
50125012
execmessages = execmessages + u'creating '+ filepath + u'\n'
50135013
# 1.3.6 [SS] 2014-12-08
@@ -7542,10 +7542,10 @@ def OnDropFile(self, filename):
75427542
global execmessages, visible_abc_code
75437543
info_messages = []
75447544
# [SS] 2014-12-18
7545-
options = namedtuple ('Options', 'u m c d n b v x p j t v1 ped') # emulate the options object
7545+
options = namedtuple ('Options', 'u m c d n b v x p j t v1 ped s') # emulate the options object
75467546
options.m = 0; options.j = 0; options.p = []; options.b = 0; options.d = 0 # unused options
75477547
options.n = 0; options.v = 0; options.u = 0; options.c = 0; options.x = 0 # but all may be used if needed
7548-
options.t = 0; options.v1 = False; options.ped = True
7548+
options.t = 0; options.v1 = False; options.ped = True; options.s = 0
75497549
if self.settings['xmlunfold']:
75507550
options.u = 1
75517551
if self.settings['xmlmidi']:

midiplayer.py

+15-11
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def Load(self, path):
3333
def Length(self):
3434
return 0
3535

36-
def Tell():
36+
def Tell(self):
3737
return 0
3838

3939
@property
@@ -64,7 +64,7 @@ def __init__(self, parent_window, backend=None):
6464
parent_window.Bind(wx.media.EVT_MEDIA_STOP, self.OnMediaStop)
6565

6666
def Play(self):
67-
print('Play')
67+
# print('Play')
6868
if wx.Platform != "__WXMAC__":
6969
try: self.mc.Volume = 0.9
7070
except: pass
@@ -75,7 +75,7 @@ def Play(self):
7575
self.is_really_playing = True
7676

7777
def Stop(self):
78-
print('Stop')
78+
# print('Stop')
7979
self.is_really_playing = False
8080
self.mc.Stop()
8181
self.mc.Load('NONEXISTANT_FILE____.mid') # be sure the midi file is released 2014-10-25 [SS]
@@ -113,12 +113,12 @@ def is_paused(self):
113113
return self.mc.GetState() == wx.media.MEDIASTATE_PAUSED
114114

115115
def OnMediaLoaded(self, evt):
116-
print('OnMediaLoaded')
116+
# print('OnMediaLoaded')
117117
if self.OnAfterLoad is not None:
118118
self.OnAfterLoad()
119119

120120
def OnMediaStop(self, evt):
121-
print('Media stopped')
121+
# print('Media stopped')
122122
# if media is finished but playback as a loop was used relaunch the playback immediatly
123123
# and prevent media of being stop (event is vetoed as explained in MediaCtrl documentation)
124124
if self.loop_midi_playback:
@@ -127,25 +127,29 @@ def OnMediaStop(self, evt):
127127
wx.CallAfter(self.play_again)
128128

129129
def OnMediaFinished(self, evt):
130-
print('Media finished')
130+
# print('Media finished')
131131
# if media is finished but playback as a loop was used relaunch the playback immediatly
132132
# (OnMediaStop should already have restarted it if required as event STOP arrive before FINISHED)
133133
self.is_really_playing = False
134134
if self.loop_midi_playback:
135135
self.play_again()
136136
elif self.OnAfterStop is not None:
137-
print('Media OnAfterStop')
137+
# print('Media OnAfterStop')
138138
self.OnAfterStop()
139139

140140
def play_again(self):
141-
if self.is_playing():
141+
if self.is_playing:
142142
self.Seek(0)
143143
else:
144144
self.Seek(0)
145145
self.Play()
146146
self.set_playback_rate(self.last_playback_rate)
147147
#self.update_playback_rate()
148148
self.is_really_playing = True
149+
150+
def set_playback_rate(self, playback_rate):
151+
if self.mc and (self.is_playing or wx.Platform != "__WXMAC__"): # after setting playbackrate on Windows the self.mc.GetState() becomes MEDIASTATE_STOPPED
152+
self.mc.PlaybackRate = playback_rate
149153

150154

151155

@@ -179,7 +183,7 @@ def set_soundfont(self, sf2_path): # load another sound font
179183
def load(self, path): # load a midi file
180184
self.reset() # reset the player, empty the playlist
181185
self.pause_time = 0 # resume playing at time == 0
182-
self.p.add(fnm) # add file to playlist
186+
self.p.add(path) # add file to playlist
183187
self.p.load() # load first file from playlist
184188
self.dur = max ([self.p.get_length (i) for i in range (16)]) # get max length of all tracks
185189
if self.p.get_status() == 2: # not a midi file
@@ -188,9 +192,9 @@ def load(self, path): # load a midi file
188192

189193
def reset(self): # the only way to empty the playlist ...
190194
self.p.delete() # delete player
191-
self.p = F.Player(s.fs) # make a new one
195+
self.p = F.Player(self.fs) # make a new one
192196

193-
def play(s):
197+
def play(self):
194198
if self.playing:
195199
self.pause_time = self.p.stop()
196200
self.playing = 0

requirements.txt

-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
pywin32
2-
cx_Freeze
3-
mechanize

0 commit comments

Comments
 (0)