pyampact.symbolic.insertAudioAnalysis

pyampact.symbolic.insertAudioAnalysis(piece, output_path, data, mimetype='', target='', mei_tree=None)[source]

Insert a <performance> element into the MEI score given the analysis data (data) in the format of a json file or an nmat dictionary with audio data already included. If the original score is not an MEI file, a new MEI file will be created and used. The JSON data will be extracted via the .nmats() method. If provided, the mimetype and target get passed as attributes to the <avFile> element. The performance element will nest the DataFrame data in the <performance> element as a child of <music> and a sibling of <body>. A new file will be saved to the output_filename in the current working directory.

<music>
    <performance xml:id="pyAMPACT-1">
        <recording xml:id="pyAMPACT-2">
            <avFile mimetype="audio/aiff" target="song.wav" xml:id="pyAMPACT-3" />
            <when absolute="00:00:12:428" xml:id="pyAMPACT-4" data="#note_1">
                <extData xml:id="pyAMPACT-5">
                    <![CDATA[>
                        {"ppitch":221.30926295063591, "jitter":0.7427361, ...}
                    ]]>
                </extData>
            </when>
            <when absolute="00:00:12:765" xml:id="pyAMPACT-6" data="#note_2">
            ...
        </recording>
    </performance>
    <body>
        ...
    </body>
</music>
Parameters:
  • output_filename – The name of the output file.

  • data – Path to a JSON file containing analysis data or an nmats dictionary.

  • mimetype – Optional MIME type to be set as an attribute to the <avFile> element.

  • target – Optional target to be set as an attribute to the <avFile> element.

  • mei_tree – Optional ElementTree object to use as the base for the new file.

Returns:

None but a new file is written

See also

nmats(), toKern(), toMEI()