VOGONS


First post, by Dark Defender

User metadata
Rank Newbie
Rank
Newbie

I'm wondering if it would be possible to configure dosbox to connect to timidity directly like you can do with scummVM? : http://www.4front-tech.com/wiki/index.php/Con … r_OSSv4#scummvm
As you can guess by looking at the link above I use OSS4 and it seems, after some quick googling, that it doesn't have any "native" midi support yet. I.E you have to use timidity to play midi music.
So is there any way you can connect dosbox to the timidity server?

Reply 1 of 12, by boyofdestiny

User metadata
Rank Newbie
Rank
Newbie

In your dosbox.conf or .dosboxrc (I prefer the latter)

[midi]
# mpu401 -- Type of MPU-401 to emulate: none, uart or intelligent.
# device -- Device that will receive the MIDI data from MPU-401.
# This can be default,alsa,oss,win32,coreaudio,none.
# config -- Special configuration options for the device. In Windows put
# the id of the device you want to use. See README for details.

mpu401=intelligent
device=default
config=128:0

Assuming your timidity server is on port 128, you are golden. I also recommend trying fluidsynth as an alternative (as timidity is a bit old now)

Reply 2 of 12, by Dark Defender

User metadata
Rank Newbie
Rank
Newbie

Yeah fluidsynth seem to be much nicer now that I've tried it out, thank you! 😉 However it doesn't solve my problem unfortunately.
I've mapped fluidsynth to my midi device "/dev/midi00" but I have no idea if you can pass this on to dosbox. And it seems like dosbox uses the deprecated /dev/sequencer (from oss v3) after I looked though the sourcecode... I've found the new API documentation to /dev/midi however: http://manuals.opensound.com/developer/MIDI.html. But as I've just programmed some basic java apps I don't really know if you just can easily patch/replace the current code... As the oss midi portion of the code seems to be just one short header file (.h) maybe not that hard 😀
Or perhaps I'm mistaken. A word from the devs (or anyone else for that matter) would be greatly appreciated 😉

Reply 3 of 12, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

try config=/dev/midi00

didn't know people still used oss. though alsa was the standard nowadays

Water flows down the stream
How to ask questions the smart way!

Reply 4 of 12, by Dark Defender

User metadata
Rank Newbie
Rank
Newbie

No dice 🙁

DOSBox version 0.72
Copyright 2002-2007 DOSBox Team, published under GNU GPL.
---
CONFIG:Loading primary settings from config file dosbox.conf
Maximum memory size is 63 MB
MIDI:Can't open device:oss with config:/dev/midi00.
MIDI:Opened device:none

Yeah ALSA is the standard because what happened with OSS3 (the one still in the kernel). But with OSS4 it became GPL and people (like me) with cards that doesn't work that well with ALSA (missing features etc.) have jumped on the OSS4 bandwagon 😜
And most applications work because they still have OSS support (thank you for that)! The only problem I've had so far is midi because of the reworked interface i.e /dev/sequencer != /dev/midi.
I've looked at how scummvm does it to get some clues how to get it working. But it seems like it doesn't use ports at all. If I understand the code correctly then scummvm runs fluidsynth "in the background" and passes the notes onto it:
ScummVM -> softsynth
While dosbox does something like this:
Dosbox -> the soundcards midi interface -> softsynth

Perhaps we can workaround this problem by somehow make dosbox output the midi events to a dummy midi device that I map fluidsynth to instead?

Reply 5 of 12, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

I don't know. DOSBox it's oss interface is really only that one header. It very simple. not sure how OSS4 wants to be addressed though

Water flows down the stream
How to ask questions the smart way!

Reply 7 of 12, by Dark Defender

User metadata
Rank Newbie
Rank
Newbie

Got it to kind of work by changing the "/dev/sequencer" in the midi_oss.h file to my midiloopback device (/dev/midi03) and connecting it fluidsynth. I get sound and notes but they seem to be assinged to the wrong instruments or badly distorted or both.
Edit: I think this have to do with the api change between /dev/sequencer and /dev/midi 🙁

Edit2: This sample program http://manuals.opensound.com/developer/midi.c.html plays like it should it seems. Outputs a note and it isn't distorted or anything. But as my programming skills is limited I don't really know how to "convert" the notes that dosbox output to this new format... I'm getting lost in the sourcecode 😜

Edit3: If I understand the code example above correctly then all you need to do is to send the raw midi data. Doesn't the games already do this? If that's the case then all you need to do is to reroute them to the output device. Or am I missing something here?

Reply 8 of 12, by Dark Defender

User metadata
Rank Newbie
Rank
Newbie

Found this example that explains the difference between /dev/midi and /dev/sequencer http://ccrma.stanford.edu/~craig/articles/lin … t/section1.html
I've complied the examples on that page and besides having to add a sleep(1); before the "close" call, they work. Now the /dev/sequencer example has the same problem as dosbox has IE dissorted sound and wrong notes while the /dev/midi example plays as it should.

And that web page explains it quite well:

Output Method 1: for sending raw MIDI bytes with the write() function, using the devices "/dev/midi??", where ?? is the numb […]
Show full quote

Output Method 1:
for sending raw MIDI bytes with the write() function, using the devices "/dev/midi??", where ?? is the numbering from "00" to "04" usually. "/dev/midi" is a device which is a symbolic link to one of the midi?? devices (usually to "/dev/midi00") intended as a default MIDI device.

Output Method 2:
for sending raw MIDI bytes via packets with the write() function using the device "/dev/sequencer". The packet for sending a MIDI byte with "/dev/sequencer" consists of four unsigned characters

So I ask again: Is there anyway to output just the raw MIDI bytes? And not in packages... The midi.cpp seem already to have a method (void MIDI_RawOutByte) for this...

Reply 9 of 12, by Dark Defender

User metadata
Rank Newbie
Rank
Newbie

YAY by looking at the to examples above i've managed to get it to work! 😁
The songs play and they sound like they should. However seems like the only instruments is drums and piano...
I've must have done something wrong... Can someone help me?
Altered code: http://pastebin.com/m6684b70d

Edit: Seems like I only get the notes and not what instruments they should be played with...

Edit2: Seem like I want for example: 0xc0, 8, 0x90, 60, 60 but I only get: 0x90, 60, 60
Were the "8" is what instrument should be played. And because of this all channels defaults to instrument nr 0 which is piano

Reply 10 of 12, by Dark Defender

User metadata
Rank Newbie
Rank
Newbie

YES!!! I've solved it completely! 😁
Here is the source code: http://pastebin.com/m66560ea8
Now I get the correct notes and instruments! I haven't tested it much yet so perhaps there are some more bugs. And I need to make /dev/midiXX configurable in dosbox.conf.

Reply 12 of 12, by Dark Defender

User metadata
Rank Newbie
Rank
Newbie

Hmm there is some skipping of midi data when I'm playing some games. I managed to fix it by adding usleep(2); after the write call.
There is a much better way to do it though: http://manuals.opensound.com/developer/SNDCTL … DI_SETMODE.html
But I can't get it to work! :<
The ioctl call fails saying that there is no such device. But as the write call can use it to output the data I don't see the problem 😖