Previous topic

music21.webapps

Next topic

music21.webapps.commands

Table Of Contents

Table Of Contents

This Page

music21.webapps.apps

Webapps is a module designed for using music21 with a webserver.

This file includes application-specific components of the webserver.

It includes a set of applicationInitializers which augment agendas with data and commands specific to a given application as well as a set of commands specific to the various applications.

Functions

music21.webapps.apps.setupCognitionApp(agenda)
music21.webapps.apps.setupConverterApp(agenda)

Augments an agenda with the data and commands related to the Converter App demoed at the Digital Humanities conference in Hamburg Germany The converter app takes as query values:

source: a source compatible with converter.parse in quotes (e.g. “tinyNotation:C2 D E F...”) output: an output format (musicxml, vexflow, braille...)

Example: http://ciconia.mit.edu/music21/webinterface?appName=converterApp&source=“tinynotation:F4 A- B- B c e f2”&output=vexflow

>>> agenda = webapps.Agenda()
>>> agenda.addData('source','tinynotation:F4 A- B- B c e f2')
>>> agenda.addData('output',"musicxml")
>>> webapps.apps.setupConverterApp(agenda)
>>> processor = webapps.CommandProcessor(agenda)
>>> processor.executeCommands()
>>> (responseData, responseContentType) = processor.getOutput()
>>> responseContentType
'application/vnd.recordare.musicxml+xml; charset=utf-8'

Python 3 conversion first...

>>> if ext.six.PY3:
...     responseData = responseData.decode('utf-8')
>>> print(responseData)
<?xml version="1.0" ...?>
<!DOCTYPE score-partwise
  PUBLIC '-//Recordare//DTD MusicXML 2.0 Partwise//EN'
  'http://www.musicxml.org/dtds/partwise.dtd'>
<score-partwise>
  <movement-title>Music21 Fragment</movement-title>
  <identification>
    <creator type="composer">Music21</creator>
  </identification>
  <defaults>
    <scaling>
      <millimeters>7</millimeters>
      <tenths>40</tenths>
    </scaling>
  </defaults>
  <part-list>
...
>>> converter.parse(responseData).flat.notes[0].ps
53.0
music21.webapps.apps.setupURLCorpusParseApp(agenda)

Augments an agenda with the data and commands related to the URL Corpus Parse App.

ResponseData is returned as a bytes object in Python3

>>> agenda = webapps.Agenda()
>>> agenda.addData('measureEnd','4')
>>> agenda.addData('workName',"'bwv7.7'")
>>> agenda.addData('command',"commands.reduction")
>>> agenda.addData('output',"musicxmlDownload")
>>> webapps.apps.setupURLCorpusParseApp(agenda)
>>> processor = webapps.CommandProcessor(agenda)
>>> processor.executeCommands()
>>> (responseData, responseContentType) = processor.getOutput()
>>> responseContentType
'application/vnd.recordare.musicxml+xml; charset=utf-8'

Python 3 conversion first...

>>> if ext.six.PY3:
...     responseData = responseData.decode('utf-8')
>>> converter.parse(responseData).flat.highestOffset
16.5
music21.webapps.apps.setupZipfileApp(agenda)