RT MIDI In -> both Csound and MIDI file?
Date | 1999-06-26 01:39 |
From | Larry Troxler |
Subject | RT MIDI In -> both Csound and MIDI file? |
This is one of those questions that's difficult to summarize in a Subject line! I would like to play around with real-time MIDI control of Csound. However, I would like to be able to be able re-create those performances without simply saving the sound-file outputs. I'm running Linux. On Windows, I think this could be done using any sequencer in combination with one of the available MIDI pipers a.k.a. multiplexers. One could set up the sequencer to send MIDI through to a virtual MIDI device which in turn would be what Csound is using for input. However, on Linux, I don't know of any such virtual MIDI devices (although it looks there are some possibilites still in development). Even if the sequencer approach could be used, I am at this stage more interested in setting up some sort of system using make, vcs, and the mixer utility, to be able to effectively overdub single parts using Csound, onto an existing sound-file, yet still be able to recreate other versions ("takes"). Sorry if this isn't too clear, but it would take a lot more space to fully explain it. But basically, I need to "tee" the Midi input to both Csound and to a MIDI file recorder, so that I can then tweak the orc or score (MIDI file in this case) post-performance. So, I thought I would send this out, in case any Linux people have any ideas. I suppose I could hack up some C utility that reads from the raw device and echoes to two pipes, one of which the MIDI recorder would read from, and the second which Csound would reead from. But I doubt that the problem is this simple, since I would have to deal with emulating all the ioctl()'s and blocking/non-blocking characteristics, etc. I don't think a generic pipe would work. An alternative would be to splice a MIDI file recorder into Csound itself. This might actually be the preferred solution. I just add a flag to make Csound echo whatever input it gets to a MIDI file. The timing info I'm sure is there, the MIDI receive code of course is there, so we just need to build a MIDI file as we receive the stuff. well, enough for now... Any ideas are welcome. Larry |
Date | 1999-06-26 04:50 |
From | Paul Barton-Davis |
Subject | Re: RT MIDI In -> both Csound and MIDI file? |
In message <37742157.444B4913@westnet.com>you write: >This is one of those questions that's difficult to summarize in a >Subject line! > >I would like to play around with real-time MIDI control of Csound. >However, I would like to be able to be able re-create those performances >without simply saving the sound-file outputs. dd if=/dev/midiNN bs=1 | tee my-midi-session | csound -M - ... ah, so close but yet so far. The -M flag doesn't accept "-" as a legal name for a MIDI interface. No reason why it couldn't. You wanted virtual MIDI devices - we've got 'em, at least if you use OSS rather than ALSA. OSS, at least the latest versions thereof (including the rather mutated form found in the 2.2 kernels) has support for a loopback MIDI device. Consider the situation where you have an existing MIDI interface, and you do: insmod vmidi You now have 2 more MIDI interfaces, each one effectively the ends of a MIDI pipe. Now you can do this: (dd if=/dev/midi00 bs=1 | tee /dev/midi01 | cat - my-midi-session) & csound -M /dev/midi02 That is, you are reading from MIDI interface 0, sending the input to tee(1), which splits into into two streams, one of which goes to /dev/midi01 (one end of the loopback MIDI device), and the other to stdout, whence to cat(1) which sticks it into my-midi-session. This runs in the background. Meanwhile, csound uses /dev/midi02 (the other end of the MIDI device) as its input MIDI interface. Caveat - although I've used the loopback MIDI device, I haven't tried the above trick. There may be some timing jitter caused by using dd and tee in a pipeline like this. However, there is an even *better* solution if you are using a current version of Csound. % mkfifo /tmp/csound-midi-fifo % dd if=/dev/midi00 bs=1 | \ tee my-midi-session > /tmp/csound-midi-fifo & % csound -M /tmp/csound-midi-fifo ... Again, I've never done the dd/tee splitter thing, but I *have* used Csound and other programs that use the raw midi interface with a FIFO instead of an device. >An alternative would be to splice a MIDI file recorder into Csound >itself. This might actually be the preferred solution. I don't think so, but thats because I prefer a 12" cooks knife to a 3" swiss army knife :) --p |