[PD] Problem with Commercial OSS and PD

Joseph A. Sarlo jsarlo at mambo.peabody.jhu.edu
Sat Jan 12 17:52:13 CET 2002


I don't have the original so I can't make a diff, but I've attached a file
that has the changed linux_open_midi function from s_linux.c (version
0.34-2, I think).  It basically just checks to see that you are only
opening one midi device and that that device is the same. If so, it opens
it O_RDWR. Otherwise it falls back to the normal PD behavior.

PS This is a quick and dirty hack I did for myself and is not meant as a
   real solution.

--
 ______________________________
|
| Joseph A. Sarlo
|
| jsarlo at mambo.peabody.jhu.edu
|______________________________


On Fri, 11 Jan 2002, Timothy Rolls wrote:

> Hi Joseph,
>     I was wondering if you could explain your hack of s_linux.c? Or maybe
> e-mail me the file so I could look at it. I'd be really interested in trying
> this before I write to OSS tech support. I'm not too sure on doing this
> myself with out some instruction since I haven't done any C programing in
> about 15 years. Thanks.
>
> Regards,
> Tim
>
> ----- Original Message -----
> From: "Joseph A. Sarlo" <jsarlo at mambo.peabody.jhu.edu>
> To: "Timothy Rolls" <trolls at binghamton.edu>
> Cc: <msp at ucsd.edu>; "Ben Bogart - FMPM/F1999" <bbogart at acs.ryerson.ca>;
> "Pure Data" <pd-list at iem.kug.ac.at>
> Sent: Thursday, January 10, 2002 6:54 PM
> Subject: Re: [PD] Problem with Commercial OSS and PD
>
>
> > I don't know if this issue is related, but I experienced identical
> > symptoms.  My problem turned out to be that PD makes two separate calls to
> > open(), once for read and once for write when opening the MIDI device. My
> > driver (serial midi) apparently didn't support this. I just hacked
> > s_linux.c to use one open with O_RDRW and everything has been fine.
> >
> > --
> >  ______________________________
> > |
> > | Joseph A. Sarlo
> > |
> > | jsarlo at mambo.peabody.jhu.edu
> > |______________________________
> >
> >
> > On Thu, 10 Jan 2002, Timothy Rolls wrote:
> >
> > > Ok, I've found something interesting. I can either have a MIDI in or
> MIDI
> > > out in PD. If I open with pd -midiindev 0 -midioutdev 1, then I can play
> > > midi out, but not in. If I do the reverse, then I get midi in but no
> midi
> > > out.If I try -midiindev 1 -midioutdev1, I get a message that midiout
> could
> > > not be opened.
> > >
> > > I still question their claim of 100% compatibility with OSS/Free.
> > >
> > > Tim
> > >
> > > ----- Original Message -----
> > > From: "Miller Puckette" <mpuckett at man104-1.ucsd.edu>
> > > To: "Timothy Rolls" <trolls at binghamton.edu>
> > > Cc: "Ben Bogart - FMPM/F1999" <bbogart at acs.ryerson.ca>; "Pure Data"
> > > <pd-list at iem.kug.ac.at>
> > > Sent: Thursday, January 10, 2002 12:36 PM
> > > Subject: Re: [PD] Problem with Commercial OSS and PD
> > >
> > >
> > > > Hmm, I've been getting MIDI out on Free OSS, funny it doesn't work
> > > > on commercial...
> > > >
> > > > cheers
> > > > Miller
> > > >
> > > > On Thu, Jan 10, 2002 at 01:17:35PM -0800, Timothy Rolls wrote:
> > > > > Well, I guess that explains it. But I am curious about the
> legitimacy of
> > > > > their claim that it is 100% compatible with OSS/Free
> > > > > (http://www.opensound.com/linux.html). I am still glad I got it. The
> > > audio
> > > > > quality on my SB PCI 128 is greatly improved. Thanks for the reply.
> > > > >
> > > > > Regards,
> > > > > Tim
> > > > >
> > > > > ----- Original Message -----
> > > > > From: "Ben Bogart - FMPM/F1999" <bbogart at acs.ryerson.ca>
> > > > > To: "Timothy Rolls" <trolls at binghamton.edu>
> > > > > Cc: "Pure Data" <pd-list at iem.kug.ac.at>
> > > > > Sent: Thursday, January 10, 2002 5:59 AM
> > > > > Subject: Re: [PD] Problem with Commercial OSS and PD
> > > > >
> > > > >
> > > > > > I'm using OSS/Commercial and I too only have MIDI In and no MIDI
> out.
> > > > > > This is because OSS does not support MIDI out because most card do
> not
> > > > > > have hardware MIDI out. If MIDI out works with your card with
> other
> > > > > > programs thats because the MIDI translation is done in software,
> not
> > > > > > by the card. This is what I got from OSS/Commercial documentation.
> > > > > >
> > > > > > no sure about a fix, I only use MIDI in.
> > > > > >
> > > > > > Ben
> > > > > >
> > > > > >
> > > > > >
> > > > > > On Thu, 10 Jan 2002, Timothy Rolls wrote:
> > > > > >
> > > > > > > Greetings,
> > > > > > >     Yesterday I upgraded from OSS/Free to commercial OSS. Now
> MIDI
> > > > > doesn't
> > > > > > > work in PD, and apparently only PD. All other programs with MIDI
> > > still
> > > > > work
> > > > > > > (Brahms, Jazz, Csound). Is there anyone else using commercial
> OSS
> > > and PD
> > > > > > > with this problem? BTW, I get the message "opened 1 MIDI input
> > > device
> > > > > and 0
> > > > > > > MIDI output devices." This never happened under OSS/Free.
> Thanks.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Tim
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > B. Bogart
> > > > > > ---------
> > > > > >
> > > > > >
> > > > >
> > >
> > >
> >
> >
>
-------------- next part --------------
void linux_open_midi(int nmidiin, 
                     int *midiinvec, 
                     int nmidiout, 
                     int *midioutvec)
{
    /* Joe's code, to open with 0_RDRW flag */
    if (nmidiin == 1 && nmidiout == 1 && midiinvec[0] == midioutvec[0])
    {  
        int fd = -1;
	char namebuf[80];
        int devno = midiinvec[0];
        if (devno == 1)
	{
      	    sys_setalarm(500000);
	    fd = open("/dev/midi", O_RDWR | O_NDELAY);
            if (sys_verbose)
        	fprintf(stderr, 
			"device 1: tried /dev/midi; returned %d\n", 
			fd);
        }
    	if (fd < 0)
    	{
            sys_setalarm(500000);
    	    sprintf(namebuf, "/dev/midi%2.2d", devno-1);
    	    fd = open(namebuf, O_RDWR);
    	    if (sys_verbose)
    	    	fprintf(stderr, 
			"device %d: tried %s; returned %d\n",
			devno,
			namebuf,
			fd);
    	}
        if (fd < 0)
    	{
            sys_setalarm(500000);
    	    sprintf(namebuf, "/dev/midi%d", devno-1);
    	    fd = open(namebuf, O_RDWR);
    	    if (sys_verbose)
    	    	fprintf(stderr, 
			"device %d: tried %s; returned %d\n",
			devno, 
			namebuf, 
                        fd);
    	}
    	if (fd >= 0)
    	{
    	    oss_midiinfd[oss_nmidiin++] = fd;	    
    	    oss_midioutfd[oss_nmidiout++] = fd;
    	}
        else post("couldn't open MIDI device %d", devno);
    }   
/* End Joe's code */
    
    else
    {
        int i;
        for (i = 0, oss_nmidiin = 0; i < nmidiin; i++)
        {
            int fd = -1;
    	    char namebuf[80];
    	    int devno = midiinvec[i];
    	    if (devno == 1)
	    {
		sys_setalarm(1000000);
		fd = open("/dev/midi", O_RDONLY);
		if (sys_verbose)
		    fprintf(stderr,
			    "device 1: tried /dev/midi; returned %d\n",
			    fd);
	    }
	    if (fd < 0)
	    {
		sys_setalarm(1000000);
		sprintf(namebuf, "/dev/midi%2.2d", devno-1);
		fd = open(namebuf, O_RDONLY);
		if (sys_verbose)
		    fprintf(stderr,
			    "device %d: tried %s; returned %d\n",
			    devno,
			    namebuf,
			    fd);
	    }
	    if (fd < 0)
	    {
		sys_setalarm(1000000);
		sprintf(namebuf, "/dev/midi%d", devno-1);
		fd = open(namebuf, O_RDONLY);
		if (sys_verbose)
		    fprintf(stderr,
			    "device %d: tried %s; returned %d\n",
			    devno,
			    namebuf,
			    fd);
	    }
	    if (fd >= 0)
		oss_midiinfd[oss_nmidiin++] = fd;	    
	    else post("couldn't open MIDI input device %d", devno);
        }
        for (i = 0, oss_nmidiout = 0; i < nmidiout; i++)
        {
            int fd = -1;
    	    char namebuf[80];
    	    int devno = midioutvec[i];
    	if (devno == 1)
    	{
            sys_setalarm(1000000);
    	    fd = open("/dev/midi", O_WRONLY);
    	    if (sys_verbose)
    	    	fprintf(stderr,
			"device 1: tried /dev/midi; returned %d\n",
			fd);
    	}
        if (fd < 0)
    	{
            sys_setalarm(1000000);
    	    sprintf(namebuf, "/dev/midi%2.2d", devno-1);
    	    fd = open(namebuf, O_WRONLY);
    	    if (sys_verbose)
    	    	fprintf(stderr,
			"device %d: tried %s; returned %d\n",
			devno,
			namebuf,
			fd);
    	}
        if (fd < 0)
    	{
            sys_setalarm(1000000);
    	    sprintf(namebuf, "/dev/midi%d", devno-1);
    	    fd = open(namebuf, O_WRONLY);
    	    if (sys_verbose)
    	    	fprintf(stderr,
			"device %d: tried %s; returned %d\n",
			devno,
			namebuf,
			fd);
    	}
    	if (fd >= 0)
    	    oss_midioutfd[oss_nmidiout++] = fd;	    
    	else post("couldn't open MIDI output device %d", devno);
        }
    }
    if (oss_nmidiin < nmidiin || oss_nmidiout < nmidiout || sys_verbose)
    	post("opened %d MIDI input device(s) and %d MIDI output device(s).",
	     oss_nmidiin,
	     oss_nmidiout);
}


More information about the Pd-list mailing list