VOGONS


MT-32 emulation

Topic actions

Reply 40 of 148, by canadacow

User metadata
Rank Member
Rank
Member

I had an epiphany today. I realized I might be going about this thing all wrong. I've been using DosBox as a starting point for my MT-32 because it’s a convenient interface to work with. This may not be the best way to go about it because I seem to keep running out of CPU cycles to do the audio processing. As such, I think I'm going to work the code out of DosBox and into a multimedia device driver for Windows and Linux. This way, I'll be able to guarantee my code a certain time slice and at the same time I should be free to use MMX/3Dnow/SSE/SSE2 instructions in my source code as well. So, for the next incarnation of my MT-32 emulator, expect a virtual MIDI device rather than the DosBox specific code now. Anyway, I’m saying all of this because I’m soliciting help in writing the Linux side of the multimedia driver. I’m not very experienced with writing such things for Linux so I’ll very much welcome anyone who wants to help.

Reply 41 of 148, by vladr

User metadata
Rank Oldbie
Rank
Oldbie

DosBox can also guarantee timing, which is good.
Why not use a MIDI player in DosBox instead of the full, graphics- and CPU-intensive game with the SysEx and MIDI files from QuestStudios?
Under both Windows and Linux you will very likely have to play the audio data from user-land, so having the code inside DosBox or outside won't really make any difference.
As for performance in general, look at the AdLib emulation, it works pretty well. You can perhaps optimize a bit your resampling and TVF convolution code at some point, but I strongly doubt that *that* is the issue.
V.

Reply 42 of 148, by canadacow

User metadata
Rank Member
Rank
Member

True... though I've been looking into Window's DirectMusic interface and it looks relatively easy enough. The real advantage of having it outside of DosBox is that I can thread the sound generation routines and have them double buffer the sound outside of the audio callback routine.

Reply 43 of 148, by vladr

User metadata
Rank Oldbie
Rank
Oldbie

You don't need to do that as long as you can guarantee a timer with periodicity of half or less of the sound buffer, which should be quite easy to do within DosBox. Then, whenever (1) a MIDI event is written or (2) the timer triggers you can compute and write some more to the buffer (effectively achieving "double-buffering", so to speak, from within DosBox). The newer SDL libs may actually even be using the DirectSound 9 "notification" feature (had to be manually enabled at SDL build-time a year or so ago when I checked), in which case you don't even need the timer as long as you're in sync with the SDL mixer's callbacks (without DS9 support SDL starts its own crappy timer to emulate buffer notifications, IIRC).

Also, under Linux, since you don't need any k-mode stuff, you may use a named pipe in conjunction with a user-land "server" process (man mkfifo == http://www.opengroup.org/onlinepubs/007908799 … xsh/mkfifo.html), and have DosBox write to it as a regular MIDI device while having your MT-32 code read from it. Latency over the pipe may, of course, be a (somewhat small) issue, but anyway.

Cheers,
V.

Reply 44 of 148, by HunterZ

User metadata
Rank l33t++
Rank
l33t++

I like the Windows driver idea better because it would allow people to use a virtual MT-32 with *any* software, such as old games running with VDMSound instead of DOSbox.

Reply 45 of 148, by Snover

User metadata
Rank l33t++
Rank
l33t++

The sound that the emulator makes amuses me to no end. It sounds like it's not even using the correct samples??

Yes, it’s my fault.

Reply 46 of 148, by Nicht Sehr Gut

User metadata
Rank l33t
Rank
l33t

Originally posted by Snover The sound that the emulator makes amuses me to no end. It sounds like it's not even using the correct samples??

Still sounds better than your emulator... ;p

Reply 47 of 148, by canadacow

User metadata
Rank Member
Rank
Member
Snover wrote:

The sound that the emulator makes amuses me to no end. It sounds like it's not even using the correct samples??

Yes, that's what the thread between Vladr and me that started "Its really been bothering me that the partial numbers don't match up with their order in the ROM. Could you record the PCM partials by themselves without any envelope, pitch modification or TVF? From there, could you send me the sample files you generate? This would be the biggest help I could imagine at this point." was all about. It is a very unfortunately coincidence that the partial numbers do not match up with the order they appear in the ROM. Interestingly, besides this one aspect, my emulator is coming along very nicely. I just posted my new version that is very much improved. Though its still not exactly MT-32 quality, its no longer painful to listen to.

Last edited by canadacow on 2003-05-21, 17:08. Edited 1 time in total.

Reply 48 of 148, by Snover

User metadata
Rank l33t++
Rank
l33t++

Did you decide to make a virtual device through DirectMusic or are you sticking with the DOSBox hooks?

Hey, you can hear the drums correctly now, and at the right pitch. (Although not at the correct volume.) They don't seem to cut off at the right points though. Nifty nifty. 😀

Yes, it’s my fault.

Reply 49 of 148, by canadacow

User metadata
Rank Member
Rank
Member

I have a new version in the works that uses an FFT to correctly adjust the pitch of the samples without changing their size. Unfortunately, I know of no other way to do it besides generating a very large table (about 21MB) in size when the MT-32 starts up. Despite this, it sounds pretty good. I'm getting really close now! (And my latest bid on an MT-32 on eBay seems to be sticking)

Oh.. for now, I'm staying in DosBox, but I'm coding it with the future intent of making it a WDM/DirectMusic device.

I've just completed some more adjustments to the emulator. Its starting to sound half-decent. Its starting to get embarassing though how the partials don't match up right. Now its seriously degrading the quality of the sound. I'm going to focus on figuring out the correct matching. Hopefully I'll win that bid and I'll be able to use my own MT-32 to do the matching.

Last edited by canadacow on 2003-05-23, 02:56. Edited 1 time in total.

Reply 50 of 148, by Nicht Sehr Gut

User metadata
Rank l33t
Rank
l33t

Originally posted by canadacow I have a new version in the works that uses an FFT to correctly adjust the pitch of the samples without changing their size.

So is there a compiled binary of DosBox with this emulation available for us "non-compiling" types?

Reply 51 of 148, by canadacow

User metadata
Rank Member
Rank
Member

Well... I've considered making a binary but have chosen not to for the following reasons:

1. It still doesn't sound good enough yet for general use.(specifically, I don't want to get a billion emails telling me what already know... that it doesn't sound right!)

2. This code is insanely pre-alpha. This means that if I were to release a binary with some hapazard code that by some freak of nature causes damage to someone's computer, they may hold me responsible.

3. My source code is already posted to my site and if anyone wishes to help me with specifics (i.e. refining my IIR filter code or something) they can. Again, I don't want the kind of people who help just by saying "It doesn't sound right!"

4. I've been updating my code at such a freakish pace that any binary I post will be obsolete within the next 24 hours. At this stage I would rather devote my time to improving my code rather than making binaries.

Last edited by canadacow on 2003-05-23, 06:16. Edited 1 time in total.

Reply 52 of 148, by Nicht Sehr Gut

User metadata
Rank l33t
Rank
l33t

Originally posted by canadacow Well... I've considered making a binary but have chosen not to for the following reasons:...
4. I've been updating my code at such a freakish pace that any binary I post will be obsolete within the next 24 hours. At this stage I would rather devote my time to improving my code rather than making binaries.

Yeah, well...don't make it six months from now, OK? I mean, what happens if you get run over by a truck or something in the meantime? I'd be really upset.

...err...about you I mean...*pause* yeah, that's it. about you.

Reply 53 of 148, by HunterZ

User metadata
Rank l33t++
Rank
l33t++

*lol* Nicht, as long as he releases the complete sources, anyone can compile a binary for you who knows how to do that.

Reply 54 of 148, by Nicht Sehr Gut

User metadata
Rank l33t
Rank
l33t

Originally posted by HunterZ ... as long as he releases the complete sources, anyone can compile a binary for you who knows how to do that.

Yeah, yeah, "famous last words". Jump on over to 3DRealms forums and look at some of the grumbling about the Duke3D source code.

Just because the source makes sense to the original programmer, doesn't mean it will compile nicely for just anyone. And if canadacow is programming this the way he seems to be describing it...

Reply 55 of 148, by HunterZ

User metadata
Rank l33t++
Rank
l33t++

Hence the "anyone...who knows how to do it" 😜 I agree that it seems that he's going about it in a strange way for someone who is eliciting feedback from other programmers. It would be better to slow down and document everything, as people have previously suggested, so that others can follow the work better and offer more meaningful feedback. I'm not complaining though because I'm just happy that someone is finally making headway on MT-32 emulation 😁

Reply 56 of 148, by canadacow

User metadata
Rank Member
Rank
Member
HunterZ wrote:

strange way for someone who is eliciting feedback from other programmers. It would be better to slow down and document everything

True, but what I'm struggling with is not the semantics of programming in C. I don't need help with the actual coding. I need help with the algorithms used in the synthesis. Does anyone on this forum know how to implement a fast, integer based FFT and iFFT? What's the most optimized implementation of a lowpass resonant filter? Using an IIR filter, how do I make a sawtooth wave out of a square wave? Why is it that some programs will disable certain midi channels only to use them later in the musical composition (i.e Space Quest 3 only enables MIDI channels 1-4 but then uses those and channels 12,14,16). Is there an integer base phase vocoder I can use? Exactly what does one unit of envelope time mean in terms of sample time or real time?

Reply 57 of 148, by Nicht Sehr Gut

User metadata
Rank l33t
Rank
l33t

Originally posted by HunterZ It would be better to slow down and document everything, as people have previously suggested,...

*ack* That's precisely what killed me about COBOL...documentation. He's probably like me, "forget the documentation...just work! WORK!!"

Anything more tedious than "properly document the code" is to "properly document the code" and it still doesn't work. I want it work before I start documenting. Of course, once it's working, I usually don't feel like documenting it. This is probably why I've yet to learn to program.

Reply 58 of 148, by canadacow

User metadata
Rank Member
Rank
Member

Great news everyone! I'm getting closer than ever. Check out my website for the latest sound rendering!

http://www.artworxinn.com/alex

I've got the filter correctly implemented and the waveforms all being generated to spec. Though they may see a little more tweaking in the future, this is more or less it. The only things missing now are reverb and chorus, which when complete, should reproduce the authentic MT-32 sound! Whoohoo! Stay tuned!

Reply 59 of 148, by Snover

User metadata
Rank l33t++
Rank
l33t++

*boggles*
Dude, it sounds, quite frankly, still extremely horrendous. From your enthusiasm I thought it would've sounded much...less..bad.

Why are the first notes so nasty on the emulator?

Yes, it’s my fault.