4

I have abc notation file and I want to convert it to midi or mp3 format.

I did find music21 (docs) library to that says it can convert abc to midi but I could not figure out how.

I also found a website mandolintab that can convert the file below to midi. I am looking to do the same in python.

Can some one Help?

p6
  E  (G/A/) \
| eAFE ~Ez | D2 zB AG | E2  EE        ED   |
        EE   E2   | (EA) A2   | Ac          ef   | g2 fe         | (e3 d) ec |
d2 BA Bd | c2 BA ^c/d/ | e2 A/A/ cA/A/ | Ad     c2  ||
((3c/d/e/)) | f2 ff e2 dc | d^c de f2 (gf/e/) | f2 ed cAGE | F2 D2 D2 ((3ABc)|
          dcdA GFGB | Adfe   dcAc | dcde    fedc | A2 A>G A2    :|


X:1758
T:The Sirit Peallow
M:C|
L:1/8
N:"collected by J. O'Neill"
B:O'Neill's 1429
Z:"Transcribed by Bob Safranek, rjs@gsp.org"
K:D
(D | F)ABA    FAFD  | (F2{A}GF) DFAF | DEFE DEFD | EFAF DFAF |
dD ((3DDD) (FA) BcdF|   E2 ((3EFG) A2    ||
       d2  (fd) cBAG | F2 (AG) FDAD | ((3FED) (AD) CEEG    |    FEFG AB G2 :|
((3fgf) (df) (ed) B2 |  A2 (Ac)      BcdB   | Adfa    gfe^d | e2 (ae) fedc |
       BGDF   GABc  d2 (ga) | ((3fga) (fd) efge | ((3fga) (ec)
stha
  • 41
  • 1
  • 3

1 Answers1

4

In general if you have a file as xyz.abc, you can convert it to MIDI in music21 in python with:

from music21 import converter
s = converter.parse('xyz.abc')
s.show('midi')  # or s.write('midi', fp='output.mid')

or if it's a collection of abc scores, you can get a specific one with:

from music21 import converter
s = converter.parse('xyz.abc', number=1758)
s.show('midi')  # or s.write('midi', fp='output.mid')

and that will do it (and from there you can convert it to mp3.

Pieces in O'Neill's collection should already be in music21's corpus, but this piece seems to be absent in our version.

  • The above piece is generated using a ML Model. I tried your mentioned way and I get ABCHandlerException: no active default note length provided for note processing. tPrev: None, t: , tNext: Error – stha May 02 '21 at 11:41