omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    MIDI in Python 3.

    Pythonista
    pythonista 3 midi sequencer
    5
    8
    9593
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • laszlo.j.hermann
      laszlo.j.hermann last edited by

      Hallo, is there any posibily to reand and write MIDI files in Pythonista 3.
      In Pythonista 2 there was the midiutil.MIDIFILE to crate MIDI Files. In 3 is no midiutil module.

      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        class sound.MIDIPlayer(file_path[, sound_bank_path])
        A MIDIPlayer provides simple playback functions for MIDI (.mid) files, using either the built-in “Merlin Silver” sound bank or one that you provide. If you provide a custom sound bank, it must be in sf2 format.

        Also, midiutil is included with the python 2 interpreter in Pythonista3. I am guessing @omz either forgot to include it in the 3 site packages, or else it is not py3 compatible.

        You could either use #!python2, or try copying the file from the python2 pylib site-packages to your own site-packages, and see if it works in py3.

        #!python2
        import os, midiutil,shutil
        shutil.copytree(os.path.split(midiutil.__file__)[0],os.path.expanduser('~/Documents/site-packages-3/midiutil'))
        
        1 Reply Last reply Reply Quote 0
        • omz
          omz last edited by

          The midiutil module isn't compatible with Python 3, but as @JonB pointed out, you can still use Python 2 in Pythonista 3 (which is what the included "Random MIDI Melody" example does).

          1 Reply Last reply Reply Quote 0
          • dgelessus
            dgelessus last edited by

            @omz Are you sure about that? In the Python 2 site-packages midiutil folder there is a MidiFile3.py that looks like it's meant to be compatible with Python 3...

            1 Reply Last reply Reply Quote 0
            • laszlo.j.hermann
              laszlo.j.hermann last edited by laszlo.j.hermann

              Many thanks for the answers. I would need a module to Read and Write/ Manipulate. Midiutil is only for writing/creating MIDI files.
              https://github.com/vishnubob/python-midi/ has the necessary functionality but it has a hardware binding and I'm not so deep in Python to easily port it to Pythonista.
              Any suggestion?

              1 Reply Last reply Reply Quote 1
              • ccc
                ccc last edited by

                The current midiutil supports both Python 2 and Python 3.

                1 Reply Last reply Reply Quote 0
                • omz
                  omz last edited by

                  @ccc Good to know, thanks!

                  1 Reply Last reply Reply Quote 0
                  • laszlo.j.hermann
                    laszlo.j.hermann last edited by

                    OK mido helps.

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    Powered by NodeBB Forums | Contributors