Csound Csound-dev Csound-tekno Search About

[Csnd] Csound play a midi file via mido

Date2019-05-20 17:04
FromRichard
Subject[Csnd] Csound play a midi file via mido

I found a surprising simple way to play a midi file as input to Csound, via the mido Python library.

Here's the code:

from mido import MidiFile, open_output

port = open_output('NewPort', virtual=True)
mid = MidiFile('midis/moonlight_sonata.mid')

for message in mid.play():
   print(message)
   port.send(message)

The only thing is, the port must be open before you start Csound, but that is not really a problem, because you can start Csound from python after open_output.
A nice application could be in a GUI to show a list of midifiles and another list of csd's to be played by them.

Richard



Date2019-05-21 09:51
FromRory Walsh
SubjectRe: [Csnd] Csound play a midi file via mido
That's neat.

On Mon, 20 May 2019 at 17:04, Richard  wrote:
>
> I found a surprising simple way to play a midi file as input to Csound, via the mido Python library.
>
> Here's the code:
>
> from mido import MidiFile, open_output
>
> port = open_output('NewPort', virtual=True)
> mid = MidiFile('midis/moonlight_sonata.mid')
>
> for message in mid.play():
>    print(message)
>    port.send(message)
>
> The only thing is, the port must be open before you start Csound, but that is not really a problem, because you can start Csound from python after open_output.
> A nice application could be in a GUI to show a list of midifiles and another list of csd's to be played by them.
>
> Richard
>
>
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2019-05-31 15:24
FromRoger Kelly
SubjectRe: [Csnd] Csound play a midi file via mido
I am using Mido to host Midi...then routing to various csound instruments over OSC.  Makes a nice midi host.

On Tue, May 21, 2019 at 3:51 AM Rory Walsh <rorywalsh@ear.ie> wrote:
That's neat.

On Mon, 20 May 2019 at 17:04, Richard <zappfinger@gmail.com> wrote:
>
> I found a surprising simple way to play a midi file as input to Csound, via the mido Python library.
>
> Here's the code:
>
> from mido import MidiFile, open_output
>
> port = open_output('NewPort', virtual=True)
> mid = MidiFile('midis/moonlight_sonata.mid')
>
> for message in mid.play():
>    print(message)
>    port.send(message)
>
> The only thing is, the port must be open before you start Csound, but that is not really a problem, because you can start Csound from python after open_output.
> A nice application could be in a GUI to show a list of midifiles and another list of csd's to be played by them.
>
> Richard
>
>
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2019-05-31 19:34
FromRichard
SubjectRe: [Csnd] Csound play a midi file via mido

I tried to do that to..mido/midi to OSC. But I got stuck at running status, or in other words: converting midi chords to OSC.
It seemed that OSC could not handle this very well (multiple messages coming in at the same time). That is why I fell back to a pure midi solution..
Did you solve this, and if so I am curious how?


On 31/05/2019 16:24, Roger Kelly wrote:
I am using Mido to host Midi...then routing to various csound instruments over OSC.  Makes a nice midi host.

On Tue, May 21, 2019 at 3:51 AM Rory Walsh <rorywalsh@ear.ie> wrote:
That's neat.

On Mon, 20 May 2019 at 17:04, Richard <zappfinger@gmail.com> wrote:
>
> I found a surprising simple way to play a midi file as input to Csound, via the mido Python library.
>
> Here's the code:
>
> from mido import MidiFile, open_output
>
> port = open_output('NewPort', virtual=True)
> mid = MidiFile('midis/moonlight_sonata.mid')
>
> for message in mid.play():
>    print(message)
>    port.send(message)
>
> The only thing is, the port must be open before you start Csound, but that is not really a problem, because you can start Csound from python after open_output.
> A nice application could be in a GUI to show a list of midifiles and another list of csd's to be played by them.
>
> Richard
>
>
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here