musicaiz.converters.MusaJSON

class musicaiz.converters.MusaJSON(musa_obj)[source]

This class converst a musicaiz Musa() object into a JSON format. Note that this conversion is different that the .json method of Musa class, since that is intended for encoding musicaiz objects and this class here can be encoded and decoded with other softwares since it does not encode musicaiz objects.

Examples

>>> file = Path("../0.mid")
>>> midi = Musa(file, structure="bars", absolute_timing=True)
>>> musa_json = MusaJSON(midi)

To add a field inside an instrument:

>>> musa_json.add_instrument_field(
        n_program=0,
        field="hello",
        value=2
    )

Save the json to disk:

>>> musa_json.save("filename")
__init__(musa_obj)[source]

Methods

__init__(musa_obj)

add_bar_field()

add_header_field()

add_instrument_field(n_program, field, value)

Adds a new key - value pair to the instrument which n_program is equal to the input n_program.

add_note_field()

delete_bar_field()

delete_header_field()

delete_instrument_field()

delete_note_field()

save(filename[, path])

Saves the JSON into disk.

to_json(musa_obj)