OLD | NEW |
1 #!@TARGET_PYTHON@ | 1 #!@TARGET_PYTHON@ |
2 # | 2 # |
3 # midi2ly.py -- LilyPond midi import script | 3 # midi2ly.py -- LilyPond midi import script |
4 | 4 |
5 # This file is part of LilyPond, the GNU music typesetter. | 5 # This file is part of LilyPond, the GNU music typesetter. |
6 # | 6 # |
7 # Copyright (C) 1998--2015 Han-Wen Nienhuys <hanwen@xs4all.nl> | 7 # Copyright (C) 1998--2015 Han-Wen Nienhuys <hanwen@xs4all.nl> |
8 # Jan Nieuwenhuizen <janneke@gnu.org> | 8 # Jan Nieuwenhuizen <janneke@gnu.org> |
9 # | 9 # |
10 # LilyPond is free software: you can redistribute it and/or modify | 10 # LilyPond is free software: you can redistribute it and/or modify |
(...skipping 14 matching lines...) Expand all Loading... |
25 TODO: | 25 TODO: |
26 ''' | 26 ''' |
27 | 27 |
28 import os | 28 import os |
29 import sys | 29 import sys |
30 | 30 |
31 """ | 31 """ |
32 @relocate-preamble@ | 32 @relocate-preamble@ |
33 """ | 33 """ |
34 | 34 |
35 import midi | |
36 import lilylib as ly | 35 import lilylib as ly |
37 global _;_=ly._ | 36 global _;_=ly._ |
38 | 37 |
39 ################################################################ | 38 ################################################################ |
40 ## CONSTANTS | 39 ## CONSTANTS |
41 | 40 |
42 | 41 |
43 LINE_BELL = 60 | 42 LINE_BELL = 60 |
44 scale_steps = [0, 2, 4, 5, 7, 9, 11] | 43 scale_steps = [0, 2, 4, 5, 7, 9, 11] |
45 global_options = None | 44 global_options = None |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 return Clef (3) | 915 return Clef (3) |
917 return Clef (2) | 916 return Clef (2) |
918 | 917 |
919 class Staff: | 918 class Staff: |
920 def __init__ (self, track): | 919 def __init__ (self, track): |
921 self.voices = track.get_voices () | 920 self.voices = track.get_voices () |
922 def dump (self, i): | 921 def dump (self, i): |
923 return dump_track (self.voices, i) | 922 return dump_track (self.voices, i) |
924 | 923 |
925 def convert_midi (in_file, out_file): | 924 def convert_midi (in_file, out_file): |
| 925 global midi |
| 926 import midi |
| 927 |
926 global clocks_per_1, clocks_per_4, key | 928 global clocks_per_1, clocks_per_4, key |
927 global start_quant_clocks | 929 global start_quant_clocks |
928 global duration_quant_clocks | 930 global duration_quant_clocks |
929 global allowed_tuplet_clocks | 931 global allowed_tuplet_clocks |
930 global time | 932 global time |
931 | 933 |
932 str = open (in_file, 'rb').read () | 934 str = open (in_file, 'rb').read () |
933 clocks_max = bar_max * clocks_per_1 * 2 | 935 clocks_max = bar_max * clocks_per_1 * 2 |
934 midi_dump = midi.parse (str, clocks_max) | 936 midi_dump = midi.parse (str, clocks_max) |
935 | 937 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 o = global_options.output | 1186 o = global_options.output |
1185 (outdir, outbase) = os.path.split (o) | 1187 (outdir, outbase) = os.path.split (o) |
1186 | 1188 |
1187 if outdir and outdir != '.' and not os.path.exists (outdir): | 1189 if outdir and outdir != '.' and not os.path.exists (outdir): |
1188 os.mkdir (outdir, 0777) | 1190 os.mkdir (outdir, 0777) |
1189 | 1191 |
1190 convert_midi (f, o) | 1192 convert_midi (f, o) |
1191 | 1193 |
1192 if __name__ == '__main__': | 1194 if __name__ == '__main__': |
1193 main () | 1195 main () |
OLD | NEW |