[Cs-dev] Csound5 MIDI changes - some testing needed
Date | 2005-02-21 18:39 |
From | Istvan Varga |
Subject | [Cs-dev] Csound5 MIDI changes - some testing needed |
I have made some changes to real time MIDI in Csound5, to allow modularization, and remove static variables (the latter is not entirely done yet, but I have made some progress). Real time MIDI is now handled very similarly to real time audio: the low level functions are loaded as a plugin (currently there is only one module, libpmidi.so): -+rtmidi=name 'name' defaults to PortMIDI (aliases are portmidi and pm). The only other choice is 'null' for now, which requests the use of a dummy MIDI implementation. The PortMIDI module implements both MIDI input (-M) and output (-Q), and accepts device numbers starting from zero to select MIDI device. To get a list of available devices, use some high value like -M 100 or -Q 100. Since the new modular implemetation also allows MIDI output, system dependent functions in midisend.c are no longer needed and have been removed (the file is much smaller and simpler now). The old system dependent low level code in mididevice.c is removed; at this time, Csound5 requires PortMIDI for real time MIDI I/O, but once the core implementation is stable enough, system specific modules can be added again. I have run a few simple tests, and file input, device input, and device output seems to work, but more extensive tests are welcome. Here are the interface functions from csound.h (also, it may be worth having a look at the pmidi.c file which implements the PortMIDI plugin): /** * Open MIDI input device 'devName', and store stream specific * data pointer in *userData. Return value is zero on success, * and a non-zero error code if an error occured. */ int csoundExternalMidiInOpen(void *csound, void **userData, const char *devName); /** * Read at most 'nbytes' bytes of MIDI data from input stream * 'userData', and store in 'buf'. Returns the actual number of * bytes read, which may be zero if there were no events, and * negative in case of an error. Note: incomplete messages (such * as a note on status without the data bytes) should not be * returned. */ int csoundExternalMidiRead(void *csound, void *userData, unsigned char *buf, int nbytes); /** * Close MIDI input device associated with 'userData'. * Return value is zero on success, and a non-zero error * code on failure. */ int csoundExternalMidiInClose(void *csound, void *userData); /** * Open MIDI output device 'devName', and store stream specific * data pointer in *userData. Return value is zero on success, * and a non-zero error code if an error occured. */ int csoundExternalMidiOutOpen(void *csound, void **userData, const char *devName); /** * Write 'nbytes' bytes of MIDI data to output stream 'userData' * from 'buf' (the buffer will not contain incomplete messages). * Returns the actual number of bytes written, or a negative * error code. */ int csoundExternalMidiWrite(void *csound, void *userData, unsigned char *buf, int nbytes); /** * Close MIDI output device associated with '*userData'. * Return value is zero on success, and a non-zero error * code on failure. */ int csoundExternalMidiOutClose(void *csound, void *userData); /** * Returns pointer to a string constant storing an error massage * for error code 'errcode'. */ char *csoundExternalMidiErrorString(void *csound, int errcode); /* Set real time MIDI function pointers. */ PUBLIC void csoundSetExternalMidiInOpenCallback(void *csound, int (*func)(void*, void**, const char*)); PUBLIC void csoundSetExternalMidiReadCallback(void *csound, int (*func)(void*, void*, unsigned char*, int)); PUBLIC void csoundSetExternalMidiInCloseCallback(void *csound, int (*func)(void*, void*)); PUBLIC void csoundSetExternalMidiOutOpenCallback(void *csound, int (*func)(void*, void**, const char*)); PUBLIC void csoundSetExternalMidiWriteCallback(void *csound, int (*func)(void*, void*, unsigned char*, int)); PUBLIC void csoundSetExternalMidiOutCloseCallback(void *csound, int (*func)(void*, void*)); PUBLIC void csoundSetExternalMidiErrorStringCallback(void *csound, char *(*func)(int)); ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2005-02-21 20:30 |
From | Istvan Varga |
Subject | Re: [Cs-dev] Csound5 MIDI changes - some testing needed |
Dave Phillips wrote: > csound --expression-opt -odac2 -d -m0 -Q/dev/snd/midiC1D0 midi-out.csd You may have old CVS code. The public CVS server has a few hours of lag compared to developer access, but the new sources should appear soon. > I assume it can eventually be set as an environment variable ? Maybe, although with working $HOME/.csoundrc this is not as important. > Play by MIDI file seemed fine too. I see that Type 1 files apparently > are still unsupported. Yes, a Type 1 file will only play if it has no more than 1 track. ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2005-02-21 20:32 |
From | Dave Phillips |
Subject | Re: [Cs-dev] Csound5 MIDI changes - some testing needed |
Istvan Varga wrote: > I have made some changes to real time MIDI in Csound5, to allow > modularization, and remove static variables (the latter is not > entirely done yet, but I have made some progress). > Real time MIDI is now handled very similarly to real time audio: > the low level functions are loaded as a plugin (currently there > is only one module, libpmidi.so): > -+rtmidi=name > 'name' defaults to PortMIDI (aliases are portmidi and pm). > The only other choice is 'null' for now, which requests the use > of a dummy MIDI implementation. PortMIDI is already installed here, I checked out the new stuff. > The PortMIDI module implements both MIDI input (-M) and > output (-Q), and accepts device numbers starting from zero > to select MIDI device. To get a list of available devices, > use some high value like -M 100 or -Q 100. That doesn't seem to work here: csound --expression-opt -odac2 -d -m0 -Q0 midi-out.csd [snip] Can't open MIDI device Same error for -Q100. However, this works: csound --expression-opt -odac2 -d -m0 -Q/dev/snd/midiC1D0 midi-out.csd It routes Csound output right to my ALSA virmidi device, so I can drive any ALSA sequencer client with Csound. I also tested it for /dev/snd/C0D0, the hardware MIDI interface on my SBLive, same results, worked perfectly. I checked MIDI input performance a bit, just wiggling fingers on keys, but it seemed as responsive as previously. MIDI performance has been pretty good for Linux Csound, it seems to be unimpaired by PortMIDI, so perhaps PortMIDI can resolve MIDI performance issues across the various Csound platforms ? > Since the new modular implemetation also allows MIDI output, > system dependent functions in midisend.c are no longer needed > and have been removed (the file is much smaller and simpler now). > The old system dependent low level code in mididevice.c is > removed; at this time, Csound5 requires PortMIDI for real time > MIDI I/O, but once the core implementation is stable enough, > system specific modules can be added again. > I have run a few simple tests, and file input, device input, and > device output seems to work, but more extensive tests are welcome. I assume it can eventually be set as an environment variable ? Play by MIDI file seemed fine too. I see that Type 1 files apparently are still unsupported. I'll keep testing things on the MIDI side, but so far it seems perfectably usable at the scale tested. I think Iain has some strenuous tests for Csound MIDI, perhaps he's tested it already ? Thanks, Istvan, and thanks also to the PortMIDI people. Cool stuff here. Best, dp > > Here are the interface functions from csound.h (also, it may be > worth having a look at the pmidi.c file which implements the > PortMIDI plugin): > > /** > * Open MIDI input device 'devName', and store stream specific > * data pointer in *userData. Return value is zero on success, > * and a non-zero error code if an error occured. > */ > int csoundExternalMidiInOpen(void *csound, void **userData, > const char *devName); > > /** > * Read at most 'nbytes' bytes of MIDI data from input stream > * 'userData', and store in 'buf'. Returns the actual number of > * bytes read, which may be zero if there were no events, and > * negative in case of an error. Note: incomplete messages (such > * as a note on status without the data bytes) should not be > * returned. > */ > int csoundExternalMidiRead(void *csound, void *userData, > unsigned char *buf, int nbytes); > > /** > * Close MIDI input device associated with 'userData'. > * Return value is zero on success, and a non-zero error > * code on failure. > */ > int csoundExternalMidiInClose(void *csound, void *userData); > > /** > * Open MIDI output device 'devName', and store stream specific > * data pointer in *userData. Return value is zero on success, > * and a non-zero error code if an error occured. > */ > int csoundExternalMidiOutOpen(void *csound, void **userData, > const char *devName); > > /** > * Write 'nbytes' bytes of MIDI data to output stream 'userData' > * from 'buf' (the buffer will not contain incomplete messages). > * Returns the actual number of bytes written, or a negative > * error code. > */ > int csoundExternalMidiWrite(void *csound, void *userData, > unsigned char *buf, int nbytes); > > /** > * Close MIDI output device associated with '*userData'. > * Return value is zero on success, and a non-zero error > * code on failure. > */ > int csoundExternalMidiOutClose(void *csound, void *userData); > > /** > * Returns pointer to a string constant storing an error massage > * for error code 'errcode'. > */ > char *csoundExternalMidiErrorString(void *csound, int errcode); > > /* Set real time MIDI function pointers. */ > > PUBLIC void csoundSetExternalMidiInOpenCallback(void *csound, > int (*func)(void*, > void**, > const > char*)); > > PUBLIC void csoundSetExternalMidiReadCallback(void *csound, > int (*func)(void*, void*, > unsigned > char*, > int)); > > PUBLIC void csoundSetExternalMidiInCloseCallback(void *csound, > int (*func)(void*, > void*)); > > PUBLIC void csoundSetExternalMidiOutOpenCallback(void *csound, > int (*func)(void*, > void**, > const > char*)); > > PUBLIC void csoundSetExternalMidiWriteCallback(void *csound, > int (*func)(void*, > void*, > unsigned > char*, > int)); > > PUBLIC void csoundSetExternalMidiOutCloseCallback(void *csound, > int (*func)(void*, > void*)); > > PUBLIC void csoundSetExternalMidiErrorStringCallback(void *csound, > char > *(*func)(int)); > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Csound-devel mailing list > Csound-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/csound-devel > ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2005-02-21 20:35 |
From | Oeyvind Brandtsegg |
Subject | [Cs-dev] negative fractional instr numbers |
there seems to be an issue with negative fractional instr numbers when used in connection with the xtratim opcode. A score event with negative fractional instr number will not turn of the (indefinite duration) event, if xtratim is used within the instrument. A simple csd showing the behaviour is attached. The manual says that the xtratim opcode is meant to be used in connection with midi generated events, but it could be very useful for score generated events too. Or, rather than score generated events, I mean orchestra generated events by means of the event opcode. The reason why xtratim is useful is because it coud facilitate writing of instruments that can be triggered from the event opcode, with indefinite duration. When doing polyphonic event handling, one needs to use fractional instr numbers to be able to turn off the correct event. best Oeyvind |
Date | 2005-02-21 21:44 |
From | Istvan Varga |
Subject | Re: [Cs-dev] Csound5 MIDI changes - some testing needed |
Istvan Varga wrote: > Dave Phillips wrote: > > > csound --expression-opt -odac2 -d -m0 -Q/dev/snd/midiC1D0 midi-out.csd > > You may have old CVS code. The public CVS server has a few hours of lag > compared to developer access, but the new sources should appear soon. The new files have now appeared in the web based CVS archive, so anonymous pserver access is probably up to date too. I get errors when I try to connect to the server, though, not sure if you also run into similar problems. ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2005-02-21 21:59 |
From | jpff@codemist.co.uk |
Subject | Re: [Cs-dev] Csound5 MIDI changes - some testing needed |
> Play by MIDI file seemed fine too. I see that Type 1 files apparently > are still unsupported. I could not find a library to deal with MIDI files (an equivalent to libsndfile). Do you know one Dave? ==John ffitch ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2005-02-21 23:31 |
From | Dave Phillips |
Subject | Re: [Cs-dev] Csound5 MIDI changes - some testing needed |
Hi Istvan: Cool, here's what I got with -Q1000: *** PortMIDI: error: device number is out of range The available MIDI out devices are: 0: EMU10K1 MPU-401 (UART) (ALSA) 2: Emu10k1 Port 0 (ALSA) 3: Emu10k1 Port 1 (ALSA) 4: Emu10k1 Port 2 (ALSA) 5: Emu10k1 Port 3 (ALSA) 6: VirMIDI 1-0 (ALSA) 8: VirMIDI 1-1 (ALSA) 10: VirMIDI 1-2 (ALSA) 12: VirMIDI 1-3 (ALSA) 14: qjackctl (ALSA) 15: Synth input port (17276:0) (ALSA) 16: Control (ALSA) *** error opening MIDI out device: -1 (Unknown MIDI error) That's just too cool. With -M1000 I got this: *** PortMIDI: error: device number is out of range The available MIDI in devices are: 1: EMU10K1 MPU-401 (UART) (ALSA) 7: VirMIDI 1-0 (ALSA) 9: VirMIDI 1-1 (ALSA) 11: VirMIDI 1-2 (ALSA) 13: VirMIDI 1-3 (ALSA) 17: Control (ALSA) *** error opening MIDI in device: -1 (Unknown MIDI error) Neat, thanks for that assistance. Someone needs to design a Csound configuration utility... ;) Best, dp Istvan Varga wrote: > Istvan Varga wrote: > >> Dave Phillips wrote: >> >> > csound --expression-opt -odac2 -d -m0 -Q/dev/snd/midiC1D0 >> midi-out.csd >> >> You may have old CVS code. The public CVS server has a few hours of lag >> compared to developer access, but the new sources should appear soon. > > > The new files have now appeared in the web based CVS archive, so > anonymous pserver access is probably up to date too. I get errors > when I try to connect to the server, though, not sure if you also > run into similar problems. > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Csound-devel mailing list > Csound-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/csound-devel > ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2005-02-21 23:54 |
From | steven yi |
Subject | Re: [Cs-dev] Csound5 MIDI changes - some testing needed |
Shouldn't be too hard, what would be needed in such a utility? I imagine whipping one up in python shouldn't be too much work. -show settings for OPCODEDIR, SFDIR, SADIR, INCDIR, etc. -check .csoundrc, if available, show what's there -show available midi in/outs by number -show available audio in/outs by numbers I can create a standalone python script and check one into cvs (will experiment a little tonight). steven Dave Phillips wrote: > Someone needs to design a Csound configuration utility... ;) > > Best, > > dp > ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2005-02-22 00:26 |
From | Dave Phillips |
Subject | Re: [Cs-dev] Csound5 MIDI changes - some testing needed |
Hi Steven: Yes, that's what I was thinking of. All the variables could be declared in one pass. Perhaps it can churn out a .csoundrc file on request ? Best, dp steven yi wrote: > Shouldn't be too hard, what would be needed in such a utility? I > imagine whipping one up in python shouldn't be too much work. > > -show settings for OPCODEDIR, SFDIR, SADIR, INCDIR, etc. > -check .csoundrc, if available, show what's there > -show available midi in/outs by number > -show available audio in/outs by numbers > > I can create a standalone python script and check one into cvs (will > experiment a little tonight). > > steven > > Dave Phillips wrote: > >> Someone needs to design a Csound configuration utility... ;) >> >> Best, >> >> dp >> > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Csound-devel mailing list > Csound-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/csound-devel > ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2005-02-26 11:57 |
From | Istvan Varga |
Subject | Re: [Cs-dev] Csound5 MIDI changes - some testing needed |
jpff@codemist.co.uk wrote: > > Play by MIDI file seemed fine too. I see that Type 1 files apparently > > are still unsupported. > > > I could not find a library to deal with MIDI files (an equivalent to > libsndfile). Do you know one Dave? I have written and committed the files H/midifile.h and InOut/midifile.c, that can read a MIDI file in format 0 or 1 with any number of tracks. I also modified midirecv.c to use the new interface, so Csound should now be able read MIDI files with more than one track. ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2005-02-26 12:50 |
From | Dave Phillips |
Subject | Re: [Cs-dev] Csound5 MIDI changes - some testing needed |
Hi Istvan: At last, Type 1 MIDIfile support ! I'll test it later this weekend, I'm at Ivy's place now and she has only a 28.8 dialup. S-L-O-W connection.... Best, dp Istvan Varga wrote: > jpff@codemist.co.uk wrote: > >> > Play by MIDI file seemed fine too. I see that Type 1 files >> apparently > are still unsupported. >> >> >> I could not find a library to deal with MIDI files (an equivalent to >> libsndfile). Do you know one Dave? > > > I have written and committed the files H/midifile.h and InOut/midifile.c, > that can read a MIDI file in format 0 or 1 with any number of tracks. > I also modified midirecv.c to use the new interface, so Csound should > now be able read MIDI files with more than one track. > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Csound-devel mailing list > Csound-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/csound-devel > ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |