Csound Csound-dev Csound-tekno Search About

Re: [Cs-dev] Csound5 MIDI changes - some testing needed

Date2005-02-21 19:28
From"Art Hunkins"
SubjectRe: [Cs-dev] Csound5 MIDI changes - some testing needed
I hope this fixes the -M0 problem, for which CS5 used to interpret as MIDI
*output* rather than the first input device. So, now does -M0 "default" to
the first MIDI input device?

(Hopefully so, as this was the behavior of Csound4.)

Art Hunkins

----- Original Message -----
From: "Istvan Varga" 
To: 
Sent: Monday, February 21, 2005 1:39 PM
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
> 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

Date2005-02-21 20:25
FromIstvan Varga
SubjectRe: [Cs-dev] Csound5 MIDI changes - some testing needed
Art Hunkins wrote:

> I hope this fixes the -M0 problem, for which CS5 used to interpret as MIDI
> *output* rather than the first input device. So, now does -M0 "default" to
> the first MIDI input device?

-M0 is interpreted as the first PortMIDI device, which may be input or
output depending on your system. With some effort it may be changed to
skip numbers of devices of the wrong type, although there are also more
important issues to deal with right now.
What you are asking for is mapping device numbers as shown below:

INPUT
    1: EMU10K1 MPU-401 (UART) (ALSA)     => -M 0
    7: VirMIDI 1-0 (ALSA)                => -M 1
    9: VirMIDI 1-1 (ALSA)                => -M 2
   11: VirMIDI 1-2 (ALSA)                => -M 3
   13: VirMIDI 1-3 (ALSA)                => -M 4

OUTPUT
    0: EMU10K1 MPU-401 (UART) (ALSA)     => -Q 0
    2: Emu10k1 Port 0 (ALSA)             => -Q 1
    3: Emu10k1 Port 1 (ALSA)             => -Q 2
    4: Emu10k1 Port 2 (ALSA)             => -Q 3
    5: Emu10k1 Port 3 (ALSA)             => -Q 4
    6: VirMIDI 1-0 (ALSA)                => -Q 5
    8: VirMIDI 1-1 (ALSA)                => -Q 6
   10: VirMIDI 1-2 (ALSA)                => -Q 7
   12: VirMIDI 1-3 (ALSA)                => -Q 8


-------------------------------------------------------
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