Csound Csound-dev Csound-tekno Search About

problem: realtime MIDI-in with sb16, linux using devaudio out

Date1997-02-10 06:57
FromBradley James Lindseth
Subjectproblem: realtime MIDI-in with sb16, linux using devaudio out
Is anyone else using the SB16 on linux with realtime MIDI-in and sound out
successfully?  What is your configuration?

Csound itself is working fine (I think).  I'm having trouble with the
system drivers.  plain realtime sound output works fine.  MIDI-in isn't
working for me yet.

two things I've tried so far:

1.  Using OSS/Free MIDI driver: It does input MIDI, but I couldn't 
figure out the complicated ioctls to make it work with the -M/dev/midi00
switch.  I would ioctl it so it would poll the MIDI device, but then I
would only hear sound sputtered every 3-5 seconds or so.

2.  Using the tclmidi driver: Can't get the module to load for the SB16 at
0x300 and IRQ 3,5,7, or -1.

This is what it says in dmesg after I try the insmod.

midi.c: init_module called
mpu401_probe failed
Couldn't init MIDI dev 7 at 0x330, IRQ 7


Any help is much appreciated.

							Brad Lindseth


# Brad Lindseth, EE Undergrad Student	    Mail:  6515 Wydown Boulevard 
# 		 Washington University	 	   Box 3895 
# E-mail:  bjl1@cec.wustl.edu			   Saint Louis, MO 63105
# Web:     http://cec.wustl.edu/~bjl1/	    Phone: (314) 935-1287
# Amateur Radio:  N0UAG

Date1997-02-10 16:42
FromLawrence Troxler
SubjectRe: problem: realtime MIDI-in with sb16, linux using devaudio out
On Mon, 10 Feb 1997, Bradley James Lindseth wrote:

> two things I've tried so far:
> 
> 1.  Using OSS/Free MIDI driver: It does input MIDI, but I couldn't 
> figure out the complicated ioctls to make it work with the -M/dev/midi00
> switch.  I would ioctl it so it would poll the MIDI device, but then I
> would only hear sound sputtered every 3-5 seconds or so.

The OSS/Free MIDI driver ignores the O_NODELAY ioctl parameter and blocks
on every read. Hannu S. suggests using the select() call to first make
sure there is data in the buffer before calling read(). If there is data
in the buffer, the read() will return immediately.

I haven't tried this yet.

> 
> 2.  Using the tclmidi driver: Can't get the module to load for the SB16 at
> 0x300 and IRQ 3,5,7, or -1.
> 
> 
This is the one I'm using. Works for me with a real MPU-401 at 0x330/9.
I did have to recompile OSS to not include MIDI support, however. Doesn't
sound like this is your problem, though.

BTW in CSound 3.44, I needed to change the parmeter to the block size
ioctrl for the sound driver to use only two buffer fragments for real-time
performance. The code as is, uses all available fragments.

Larry

--  Larry Troxler  --  lt@westnet.com  --  Patterson, NY USA  --
  

Date1997-07-31 12:44
FromLaszlo Vecsey
SubjectRealtime Linux MIDI->dac - solutions.
On Mon, 10 Feb 1997, Lawrence Troxler wrote:

> On Mon, 10 Feb 1997, Bradley James Lindseth wrote:
> 
> > two things I've tried so far:
> > 
> > 1.  Using OSS/Free MIDI driver: It does input MIDI, but I couldn't 
> > figure out the complicated ioctls to make it work with the -M/dev/midi00
> > switch.  I would ioctl it so it would poll the MIDI device, but then I
> > would only hear sound sputtered every 3-5 seconds or so.
> 
> The OSS/Free MIDI driver ignores the O_NODELAY ioctl parameter and blocks
> on every read. Hannu S. suggests using the select() call to first make
> sure there is data in the buffer before calling read(). If there is data
> in the buffer, the read() will return immediately.
> 
> I haven't tried this yet.
> 

I have, and unfortunately it doesn't work. I tried on Linux 2.0.30 and
2.1.47, select() fails to return the proper status and neither does poll()

I found a pretty decent solution though. Since I wanted to keep the
OSS/Free driver I just hacked out the blocking code in
/usr/src/linux/drivers/sound/midibuf.c. The changes I made included
commenting the midi_parms structure, the prech_timeout statement in
MIDIbuf_open, and the other prech_timeout statement and its associated
block of code (first if statement) in MIDIbuf_read. You could probably
just alter that single if statement, but I felt like getting rid of all
the related code.

With these changes, read() returns immediately whether or not there is
data waiting, corresponding with the way csound expects it to work.

I suppose it might break the functionality of other midi programs on
Linux, but I dont know; csound is all I plan on using. Lemme know if
anyone has any success with the modified midibuf and realtime csound, 

- lv