CoCalc
Sharedsupport / 2015-12-08-141248-music21.sagewsOpen in CoCalc
Description: Examples for support purposes.
Authors: Harald Schilly, ℏal Snyder, William A. Stein
import music21

p = music21.converter.parse("tinynotation: 3/4 c4 d8 f g16 a g f#")

p.show('text')

{0.0} <music21.stream.Measure 1 offset=0.0> {0.0} <music21.clef.TrebleClef> {0.0} <music21.meter.TimeSignature 3/4> {0.0} <music21.note.Note C> {1.0} <music21.note.Note D> {1.5} <music21.note.Note F> {2.0} <music21.note.Note G> {2.25} <music21.note.Note A> {2.5} <music21.note.Note G> {2.75} <music21.note.Note F#> {3.0} <music21.bar.Barline style=final>
print (music21.serial.rowToMatrix([2,1,9,10,5,3,4,0,8,7,6,11]) )

0 11 7 8 3 1 2 10 6 5 4 9 1 0 8 9 4 2 3 11 7 6 5 10 5 4 0 1 8 6 7 3 11 10 9 2 4 3 11 0 7 5 6 2 10 9 8 1 9 8 4 5 0 10 11 7 3 2 1 6 11 10 6 7 2 0 1 9 5 4 3 8 10 9 5 6 1 11 0 8 4 3 2 7 2 1 9 10 5 3 4 0 8 7 6 11 6 5 1 2 9 7 8 4 0 11 10 3 7 6 2 3 10 8 9 5 1 0 11 4 8 7 3 4 11 9 10 6 2 1 0 5 3 2 10 11 6 4 5 1 9 8 7 0
p.show()

Error in lines 1-1 Traceback (most recent call last): File "/projects/sage/sage-6.9/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 905, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> File "/projects/sage/sage-6.9/local/lib/python2.7/site-packages/music21/base.py", line 2376, in show **keywords) File "/projects/sage/sage-6.9/local/lib/python2.7/site-packages/music21/converter/subConverters.py", line 725, in show self.launch(returnedFilePath, fmt=fmt, app=app) File "/projects/sage/sage-6.9/local/lib/python2.7/site-packages/music21/converter/subConverters.py", line 147, in launch self.registerFormats[0], self.launchKey)) SubConverterException: Cannot find a valid application path for format musicxml. Specify this in your Environment by calling environment.set(None, 'pathToApplication')