Python suitable for Midi ?

Discussion in 'Python' started by Protocol, Oct 28, 2008.

  1. Protocol

    Protocol Guest

    Hello all

    Is Python suitable for building a multi-track midi sequencer (with a
    gui), that would run on windows / mac ? I fail to find sufficient
    information on this, being a newbie and all. Furthermore, i found
    references on Python not being really able of multi-threading, that
    further adds to the confusion.

    Please assist.

    Panos
    Protocol, Oct 28, 2008
    #1
    1. Advertising

  2. I'm writing a sequencer in Python, although it's microtonal and not
    MIDI. I'm using the Python bindings for the Csound API, all the
    timing, MIDI, OSC, etc. stuff, essentially all but the GUI
    capabilities, having been done by the Csound developers already.
    Documentation is here and there, and Csound is another language to
    learn, but it's one way to go about it.
    I'm about to try to recode my app to calculate tempo and note timing
    internally and send real-time notes to Csound, instead of having
    Csound do it all.
    The problem I've run into is that I can't set the audio to a higher
    priority than the GUI (Tkinter). If I move the mouse over the app, no
    matter what, I get audio dropouts. AFAICT this is the same for all
    Python, regardless of what modules one uses: you can't assign system
    priorities to different threads. If you're planning to pipe MIDI to
    another app for playback, maybe it won't be an issue for you.
    Good luck!

    -Chuckk

    On Tue, Oct 28, 2008 at 11:26 AM, Protocol <> wrote:
    > Hello all
    >
    > Is Python suitable for building a multi-track midi sequencer (with a
    > gui), that would run on windows / mac ? I fail to find sufficient
    > information on this, being a newbie and all. Furthermore, i found
    > references on Python not being really able of multi-threading, that
    > further adds to the confusion.
    >
    > Please assist.
    >
    > Panos
    >
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >




    --
    http://www.badmuthahubbard.com
    Chuckk Hubbard, Oct 28, 2008
    #2
    1. Advertising

  3. Protocol

    Derek Martin Guest

    On Tue, Oct 28, 2008 at 06:54:57PM +0200, Chuckk Hubbard wrote:
    > The problem I've run into is that I can't set the audio to a higher
    > priority than the GUI (Tkinter). If I move the mouse over the app, no
    > matter what, I get audio dropouts. AFAICT this is the same for all
    > Python, regardless of what modules one uses: you can't assign system
    > priorities to different threads. If you're planning to pipe MIDI to
    > another app for playback, maybe it won't be an issue for you.


    FWIW... You could take your own advice, and devide your application
    in two: one process manages the GUI, and the second is a back-end
    process that plays the MIDI. Your GUI can even launch the back end,
    which will inherit the priority of the GUI, after which the GUI can
    reduce its own priority (the priority of the back end will not be
    affected by the change)...


    --
    Derek D. Martin
    http://www.pizzashack.org/
    GPG Key ID: 0x81CFE75D


    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.1 (GNU/Linux)

    iD8DBQFJB0gudjdlQoHP510RAvKGAJ4lWErDALJSACes5O4OqASoSlYuFgCgvTNx
    Li051e8NyguC8YpbDHvqhBA=
    =nKYZ
    -----END PGP SIGNATURE-----
    Derek Martin, Oct 28, 2008
    #3
  4. Derek Martin <> writes:

    > On Tue, Oct 28, 2008 at 06:54:57PM +0200, Chuckk Hubbard wrote:
    >> The problem I've run into is that I can't set the audio to a higher
    >> priority than the GUI (Tkinter). If I move the mouse over the app, no
    >> matter what, I get audio dropouts. AFAICT this is the same for all
    >> Python, regardless of what modules one uses: you can't assign system
    >> priorities to different threads. If you're planning to pipe MIDI to
    >> another app for playback, maybe it won't be an issue for you.

    >
    > FWIW... You could take your own advice, and devide your application
    > in two: one process manages the GUI, and the second is a back-end
    > process that plays the MIDI. Your GUI can even launch the back end,
    > which will inherit the priority of the GUI, after which the GUI can
    > reduce its own priority (the priority of the back end will not be
    > affected by the change)...
    >
    >
    > --
    > Derek D. Martin
    > http://www.pizzashack.org/
    > GPG Key ID: 0x81CFE75D


    One also has access to nice-levels on unix systems.
    J Kenneth King, Oct 29, 2008
    #4
  5. On Wed, Oct 29, 2008 at 10:32 PM, J Kenneth King <> wrote:

    >
    > One also has access to nice-levels on unix systems.


    True enough, but it's not so much a problem for me, as I'm pretty okay
    at tuning my own system, but I believe most of the people who'd be
    interested in my app (if any) are not *nix users. At any rate, it's
    one option for those who are, and thanks for reminding me.

    -Chuckk

    --
    http://www.badmuthahubbard.com
    Chuckk Hubbard, Oct 30, 2008
    #5
  6. En Thu, 30 Oct 2008 16:50:22 -0200, Chuckk Hubbard
    <> escribió:
    > On Wed, Oct 29, 2008 at 10:32 PM, J Kenneth King <>
    > wrote:
    >>
    >> One also has access to nice-levels on unix systems.

    >
    > True enough, but it's not so much a problem for me, as I'm pretty okay
    > at tuning my own system, but I believe most of the people who'd be
    > interested in my app (if any) are not *nix users. At any rate, it's
    > one option for those who are, and thanks for reminding me.


    On Windows you can set the application global priority (SetPriorityClass)
    and each thread's priority related to other threads (SetThreadPriority) -
    either using pywin32 or the ctypes module.

    --
    Gabriel Genellina
    Gabriel Genellina, Oct 30, 2008
    #6
  7. On Tue, Oct 28, 2008 at 7:13 PM, Derek Martin <> wrote:
    > On Tue, Oct 28, 2008 at 06:54:57PM +0200, Chuckk Hubbard wrote:
    >> The problem I've run into is that I can't set the audio to a higher
    >> priority than the GUI (Tkinter). If I move the mouse over the app, no
    >> matter what, I get audio dropouts. AFAICT this is the same for all
    >> Python, regardless of what modules one uses: you can't assign system
    >> priorities to different threads. If you're planning to pipe MIDI to
    >> another app for playback, maybe it won't be an issue for you.

    >
    > FWIW... You could take your own advice, and devide your application
    > in two: one process manages the GUI, and the second is a back-end
    > process that plays the MIDI. Your GUI can even launch the back end,
    > which will inherit the priority of the GUI, after which the GUI can
    > reduce its own priority (the priority of the back end will not be
    > affected by the change)...


    Thanks, Derek! It took me some looking and experimenting, but this is
    a great idea. I see now that os.nice() works for Mac too, and Gabriel
    has some suggestions for Windows. So simple- I was thinking I needed
    superuser access to set priority to real-time, but I don't need it to
    raise the priority of a running process. I never would have thought
    of that on my own.

    -Chuckk


    --
    http://www.badmuthahubbard.com
    Chuckk Hubbard, Oct 31, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hugo Villeneuve

    Java MIDI output device to MIDI Yoke.

    Hugo Villeneuve, Jul 4, 2003, in forum: Java
    Replies:
    0
    Views:
    924
    Hugo Villeneuve
    Jul 4, 2003
  2. Ton K.
    Replies:
    0
    Views:
    348
    Ton K.
    Jul 28, 2003
  3. Max M

    Python Midi package 0.1

    Max M, Aug 26, 2003, in forum: Python
    Replies:
    0
    Views:
    472
    Max M
    Aug 26, 2003
  4. Gilly
    Replies:
    6
    Views:
    409
    Ken Starks
    May 4, 2008
  5. Asbjørn Bjørnstad
    Replies:
    0
    Views:
    422
    Asbjørn Bjørnstad
    Oct 9, 2008
Loading...

Share This Page