VOGONS


First post, by 8bitbubsy

User metadata
Rank Member
Rank
Member

I'm trying to port ProTracker to MS-DOS (386+, Sound Blaster 2.0/ Pro / 16).
This is just a proof of concept for now, so the only thing that works is to load a module through Disk Op, then press Play or Stop (or change the BPM).

It won't be "just another .MOD player" though, as the goal here is playback accuracy. I've ported the ProTracker replayer from 68k asm to i386 asm, and I've written a Paula (Amiga sound chip) system, that sort of works like Paula in the way it handles looping and register updating (DAT/LEN). I don't think there's a single ProTracker player for MS-DOS that does "live sample-swapping" correctly, but this one does. This tecnique was used in several chiptune-styled .MODs to simulate SID PWM. The swapping shouldn't happen instantly (many players do this, it's wrong), but rather at the next "sample end" point inside the mixer.

The mixer runs at 43.5kHz (SB 2.0/Pro) or 45.5kHz (SB16). 16-bit mixing, 8-bit/16-bit output, no resampling interpolation.

Minimum system requirements:
- Intel 386SX processor @ 20MHz (486 recommended)
- At least 2MB RAM
- Sound Blaster 2.0 / Pro / 16 (earlier SB cards not supported as output rate must be >32kHz)
- NOTE: Audio might have occasional buffering issues under DOSBox

A 486+ w/ SB16 is going to give the best experience and sound quality.

Download: https://16-bits.org/etc/pt4dos.zip
Source code: https://16-bits.org/etc/pt4dos_src.zip (tabsize = 8 for the .asm files)

pt4dos.png

Last edited by 8bitbubsy on 2023-11-21, 14:38. Edited 16 times in total.

386:
- CPU: 386DX-40 (128kB external L1 cache)
- RAM: 8MB (0 waitstates at 40MHz)
- VGA: Diamond SpeedSTAR VGA (ET4000AX 1MB ISA)
- Audio: SB Pro 2.0 + GUS 1MB
- ISA PS/2 mouse card + ISA USB card
- MS-DOS 6.22 + Win 3.1
- MR BIOS

Reply 2 of 32, by 8bitbubsy

User metadata
Rank Member
Rank
Member
Rawit wrote on 2022-07-12, 20:00:

Sweet! Going to give this a spin soon. How "Amiga" like does it sound?

I guess it's wrong of me to say that it sounds like Amiga. It does nearest-neighbor resampling with no interpolation, so there's a ton of aliasing in the sound. To many people, this is considered awful and lo-fi like, but at the same time, linear interpolation would make many of the lo-fi Amiga samples sound too flat and low-pass filtered.

However, it's an extremely accurate ProTracker player, so it's still worth a shot if you like to play 4 channel .MODs on MS-DOS.

386:
- CPU: 386DX-40 (128kB external L1 cache)
- RAM: 8MB (0 waitstates at 40MHz)
- VGA: Diamond SpeedSTAR VGA (ET4000AX 1MB ISA)
- Audio: SB Pro 2.0 + GUS 1MB
- ISA PS/2 mouse card + ISA USB card
- MS-DOS 6.22 + Win 3.1
- MR BIOS

Reply 3 of 32, by FreddyV

User metadata
Rank Oldbie
Rank
Oldbie

Hi,

Interresting, i never heard about the live sample swap.
Do you have files using it ?

There are différent version of tracker on the amiga, with différence between them. Then I am not convinced there is only one way to play music.

Sometimes, musician use tracker bugs to do a different effect.

Reply 4 of 32, by 8bitbubsy

User metadata
Rank Member
Rank
Member
FreddyV wrote on 2022-07-13, 20:00:
Hi, […]
Show full quote

Hi,

Interresting, i never heard about the live sample swap.
Do you have files using it ?

There are différent version of tracker on the amiga, with différence between them. Then I am not convinced there is only one way to play music.

Sometimes, musician use tracker bugs to do a different effect.

Sure. Though the ProTracker replayer changed very little during the different versions. Except the ProTracker 3.x series, where they broke some things by fixing other things.

Here's an example module using sample-swapping (changing the sample without entering a note next to it): http://modland.com/pub/modules/Protracker/4-M … hymenu%2011.mod
Here's one using the EFx (invert-loop) effect, which I don't think DOS module players support either: http://modland.com/pub/modules/Protracker/Ema … i-encounter.mod
(that last tune also uses sample-swapping for the arpeggio channel)

386:
- CPU: 386DX-40 (128kB external L1 cache)
- RAM: 8MB (0 waitstates at 40MHz)
- VGA: Diamond SpeedSTAR VGA (ET4000AX 1MB ISA)
- Audio: SB Pro 2.0 + GUS 1MB
- ISA PS/2 mouse card + ISA USB card
- MS-DOS 6.22 + Win 3.1
- MR BIOS

Reply 5 of 32, by FreddyV

User metadata
Rank Oldbie
Rank
Oldbie

A-mat anarche menu, I am not surprized 😀
I just released a video with one of these music.
https://youtu.be/o3Okc0zqJZU

If you check, at 1:32, it is used during vibration (Change sample name)

It spent a big amount of time trying to understand what to do when there is a sample name and no note.
I wrote on my MOD player since >30 years and never heard about it, I never found it documented somewhere.

So, I am sure that most of the PC player play it wrong, just because nobody did know this.

Regarding the invert Loop, it is an effect never supported because it is slower to mix and need aditionnal code for almost no module using it.
It is not because it is impossible.

About the GUS support in your software. Honestly, don't support GUS at all if you want to do a software mixing on it.

Reply 6 of 32, by 8bitbubsy

User metadata
Rank Member
Rank
Member

Sample swap works like this: When the current playing sample reaches its end (either loop-end or the end of the non-looping sample), it changes to the new sample. So the swap should be delayed to the end of the current sample cycle. In other words, this has to be done on a mixer level, and not in the replayer. PT4DOS gets this 100% right.

Invert loop is not as rare as you think, and it's not slow at all. You invert one sample point in the effect routine itself per tick (if the invert loop counter reaches its target speed). Then the invert pointer increases by one.

EDIT: Updated PT4DOS now with some bugfixes etc. Removed GUS driver from source code, as I was not satisfied with it anyway (too many bugs and too much frametime used for DMA acknowledging, for some reason).

386:
- CPU: 386DX-40 (128kB external L1 cache)
- RAM: 8MB (0 waitstates at 40MHz)
- VGA: Diamond SpeedSTAR VGA (ET4000AX 1MB ISA)
- Audio: SB Pro 2.0 + GUS 1MB
- ISA PS/2 mouse card + ISA USB card
- MS-DOS 6.22 + Win 3.1
- MR BIOS

Reply 8 of 32, by 8bitbubsy

User metadata
Rank Member
Rank
Member
Rawit wrote on 2022-07-18, 12:48:

[...] Will there be support for other codecs like WSS, ESS or PAS16?

I don't own any of these cards, so I can't write a driver for them as it needs extensive testing.

386:
- CPU: 386DX-40 (128kB external L1 cache)
- RAM: 8MB (0 waitstates at 40MHz)
- VGA: Diamond SpeedSTAR VGA (ET4000AX 1MB ISA)
- Audio: SB Pro 2.0 + GUS 1MB
- ISA PS/2 mouse card + ISA USB card
- MS-DOS 6.22 + Win 3.1
- MR BIOS

Reply 9 of 32, by pan069

User metadata
Rank Oldbie
Rank
Oldbie
8bitbubsy wrote on 2022-07-18, 12:50:
Rawit wrote on 2022-07-18, 12:48:

[...] Will there be support for other codecs like WSS, ESS or PAS16?

I don't own any of these cards, so I can't write a driver for them as it needs extensive testing.

Maybe introduce a driver model, that way the community can add support for hardware you can't add yourself?

Reply 10 of 32, by 8bitbubsy

User metadata
Rank Member
Rank
Member

That's a possibility, but I don't like the feeling of having to not touch too much code because I can't test the drivers. All in all, I think Sound Blaster (and compatibles) is the most important sound card to support for now.

386:
- CPU: 386DX-40 (128kB external L1 cache)
- RAM: 8MB (0 waitstates at 40MHz)
- VGA: Diamond SpeedSTAR VGA (ET4000AX 1MB ISA)
- Audio: SB Pro 2.0 + GUS 1MB
- ISA PS/2 mouse card + ISA USB card
- MS-DOS 6.22 + Win 3.1
- MR BIOS

Reply 11 of 32, by 8bitbubsy

User metadata
Rank Member
Rank
Member

Bump.

Binary + code updated (in first post).

Small optimization for pattern drawing, and the replayer has been re-ported in i386 asm instead of C, for even less overhead.
The speed difference is very small, but it's there. 😀

386:
- CPU: 386DX-40 (128kB external L1 cache)
- RAM: 8MB (0 waitstates at 40MHz)
- VGA: Diamond SpeedSTAR VGA (ET4000AX 1MB ISA)
- Audio: SB Pro 2.0 + GUS 1MB
- ISA PS/2 mouse card + ISA USB card
- MS-DOS 6.22 + Win 3.1
- MR BIOS

Reply 12 of 32, by 8bitbubsy

User metadata
Rank Member
Rank
Member

Bump (again), new test version.

* PT4DOS now runs at 320x240 60Hz (UI redesigned, looks more like original ProTracker)
* Fixed weird behavior/crashes on some systems (was trashing some memory by accident)
* Fixed potential lock-up on exit when using certain non-Creative Sound Blaster compatibles (Crystal)
* Disk Op. now lists disk drives
* You can now press F12 to change tempo mode between CIA (BPM based) and VBL (fixed at ~49.92Hz, some modules need this. Also changes Fxx effect behavior.)
* Fixed rare clicks/pops in the audio (buffering issues)
* Fixed possible stuck ctrl/shift/alt states after exiting to DOS
* PT4DOS can now run without a sound card (pointless right now, but useful after the tracker is fully implemented)
* Other minor bugfixes

Binary + source code updated (links are in first post).
Keep in mind that this is just a player for now, the tracker is lacking almost all of its features!

386:
- CPU: 386DX-40 (128kB external L1 cache)
- RAM: 8MB (0 waitstates at 40MHz)
- VGA: Diamond SpeedSTAR VGA (ET4000AX 1MB ISA)
- Audio: SB Pro 2.0 + GUS 1MB
- ISA PS/2 mouse card + ISA USB card
- MS-DOS 6.22 + Win 3.1
- MR BIOS

Reply 13 of 32, by Rincewind42

User metadata
Rank Member
Rank
Member

Congratulations, my friend; this is the only MOD player in existence on MS-DOS that plays ProTracker chiptunes as god intended! Every single one of the other players butcher them to various degrees, and I've tried them all, believe me (all versions of Cubic, CapaMod, XTC-Play, MultiModulePlayer, FastTracker II, N-Play, Vplay (they boast a "perfect" playroutine in the README; well, it's far from it and it's clicky as hell...)).

A perfect example for sample swapping is "Back again" by 4-Mat; all the other players omit the PWM emulation which makes the lead tones sound flat, lifeless and annoying.
http://modland.com/pub/favourites/Protracker/ … ack%20again.mod

You need to have really good ears to get these nuances right, then a few hundred hours of obsessive tweaking and testing; it just won't happen without that, I guarantee it... I've been there. But this player of yours is a work of art!

A couple of minor issues and suggestions to make this THE undisputed king of DOS ProTracker MOD players:

- The intro of "Back again" (linked above) sounds a little bit out of tune. Ironically, your cross-platform ProTracker clone gets it right 😀 Just compare the first pattern played by this and your PT clone and you'll hear it (you can also try how XTC-Play tries to deal with it; it's comically out of tune...)
- Now everything is mono; could you please add a command-line switch to set the channel pannings from 0 to 100 or something? Just like your PT clone does.
- Similarly, an "amp gain" command-line setting would be nice; the volume could be boosted by 20-30% at least without causing clipping in most tunes.
- An option to quit immediately by pressing Esc would be welcome as this is basically a player with a PT skin 😀
- As a stretch goal you could consider adding a very simple and gentle 6dB per octave low-pass filter at around 10-12kHz (optional, of course). We need the aliasing to "approximate" the Paula sound, but it's a little bit too much; the gentle filter would keep the majority of the desirable overtones while taming the high-frequency fizz which is just unwanted semi-constant extra noise.

Again, great job!

DOS: Soyo SY-5TF, MMX 200, 128MB, S3 Virge DX, ESS 1868F, AWE32, QWave, S2, McFly, SC-55, MU80, MP32L
Win98: Gigabyte K8VM800M, Athlon64 3200+, 512MB, Matrox G400, SB Live
WinXP: Gigabyte P31-DS3L, C2D 2.33 GHz, 2GB, GT 430, Audigy 4

Reply 14 of 32, by 8bitbubsy

User metadata
Rank Member
Rank
Member

Thanks for the kind words!

The reason PT4DOS is so accurate is because it emulates the Amiga Paula chip (in a very simple way). I ported the original ProTracker player from Motorola 68000 assembly to i386 assembly , and replaced the Paula register writes with Paula emu calls.

1) I listened to "Back again" in PT4DOS just now, and it sounds fine here. Maybe it sounds out of tune to some ears because of all the distortion in the mixing. It's not as clean as an original Amiga with its high-bandwidth output.

2) This is tiresome to implement, I want it to be mono so that Sound Blaster 2.0 and Sound Blaster Pro can play at 44kHz. It already sounds quite bad, and I think you can imagine how bad it would sound at 22kHz... Also, stereo separation would slow down the code, making it even less appropriate for mid-end 386 systems.

3) The gain is selected in a way where no clipping can happen, and this increases the speed of the mixer. Having an amp feature would mean I'd have to do 32-bit mixing (instead of 16), which is slower on a 386SX... And I'd also have to do clamping in the last mixer stage, which is also slower. I want PT4DOS to be fast enough for a mid-end 386.

4) Fixed. Updated the ZIPs in the first post. I also removed the delay in the beginning, and the palette fade in/out. This causes the program to start/stop even faster.

5) I'm not sure if you knew this, but I did a crude one-pole implementation of the two-pole "LED" filter that the Amiga has, you can turn it on by pressing CTRL+F. It doesn't have the same timbre/resonance as the original filter since it's just one-pole. Having a filter like this running at all times would probably be too slow for my 386SX target. Anyway, I did make a new test version that runs a constant 6dB/oct f=~4421Hz low-pass to simulate that of Amiga 500. You can hear that the audio still has a lot of distortion: https://16-bits.org/etc/PT4DOSF.ZIP (CTRL+F / 'LED filter' is disabled in this version).
Maybe this is overall better?

You can press CTRL+R to see the frame time spent on mixing (doesn't work in DOSBox). The first bar is the time spent on rendering the graphics, and the second bar is the time spent on mixing audio.

386:
- CPU: 386DX-40 (128kB external L1 cache)
- RAM: 8MB (0 waitstates at 40MHz)
- VGA: Diamond SpeedSTAR VGA (ET4000AX 1MB ISA)
- Audio: SB Pro 2.0 + GUS 1MB
- ISA PS/2 mouse card + ISA USB card
- MS-DOS 6.22 + Win 3.1
- MR BIOS

Reply 15 of 32, by Rincewind42

User metadata
Rank Member
Rank
Member
8bitbubsy wrote on 2023-07-09, 11:51:

The reason PT4DOS is so accurate is because it emulates the Amiga Paula chip (in a very simple way). I ported the original ProTracker player from Motorola 68000 assembly to i386 assembly , and replaced the Paula register writes with Paula emu calls.

Very nice! I've discovered when writing my own player from scratch (not looking much at the original PT playroutine), that translating the original ASM sources is the Only True Way(tm). All other approaches are bound to fail sooner or later, as we can see in 90%+ of existing MOD players. I managed to achieve high degrees of accuracy, but yeah, the accuracy will "plateau" at some point if you're not re-creating the *exact* same playroutine with 100% bug-compatibility. We *want* those bugs! 😀

8bitbubsy wrote on 2023-07-09, 11:51:

1) I listened to "Back again" in PT4DOS just now, and it sounds fine here. Maybe it sounds out of tune to some ears because of all the distortion in the mixing. It's not as clean as an original Amiga with its high-bandwidth output.

Yes, probably the instruments are not out of tune with themselves (or just slightly), but I can consistently replicate the tuning discrepancy between PT4DOS and your cross-platform PT clone. This is a good test:

Test 1

- Load "Back again" in both.
- Just press enter once in both so row 0 of the start pattern starts playing — you'll hear the "frequency beating" familiar from chorus effects.
- Stop playback in one — the beating stops.

Test 2

- Prepare a variant of "Back again" where only the second track is playing in the starting pattern (it has a continuous stream of different-pitched notes).
- Start playing back this pattern in both — the frequency beating (chorus effect) will be very noticeable.

But I can hear this clearly just by playing the tune for a few seconds in one, then switching to the other. Mind you, I'm very sensitive to pitch differences; I'm one of those people for whom all guitars are constantly out of tune because of equal temperament. I do music production and I put chorus on pretty much all guitars to mask that, otherwise it's just too annoying for me 😀

I'm wondering if your performance optimisation in PT4DOS is the cause for this?

	; Trash lo-byte of 32-bit delta so that CL can be used for bitshifts.
; This saves two bytes of opcode data per iteration in the mixing loop.
; The voice frequency will be off by up to 0.0025Hz from this hack
; (i.e. you won't hear a difference).
mov cl,16

0.0025 Hz is a two and a half cents (1 cent = 1/100th of a Hz), and a 2-3 cent difference is definitely audible to me when tuning guitars and quite annoying! I'm not alone with this, e.g. check out this forum that even has a poll; some people are even more sensitive than me and can hear sub 1-cent discrepancies which is less than 1/100Hz!

https://www.kemper-amps.com/forum/index.php?t … need-to-retune/

Admittedly, if the pitch differences affected all notes and all instruments *globally*, this wouldn't be much of a problem. But I think this optimisation can introduce random, variable pitch drift depending on the note frequencies, which is more of a problem. Not a *huge* problem, but not perfect either.

8bitbubsy wrote on 2023-07-09, 11:51:

2) This is tiresome to implement, I want it to be mono so that Sound Blaster 2.0 and Sound Blaster Pro can play at 44kHz. It already sounds quite bad, and I think you can imagine how bad it would sound at 22kHz... Also, stereo separation would slow down the code, making it even less appropriate for mid-end 386 systems.

Fair enough, and I saw the explanation in amixer.asm why you need to keep the mixing frequency above 22kHz.

The reason I'm asking is because I'm putting a "demoscene pack" together aimed at DOSBox users primarily so old-timers like me can re-experience the glory days with minimal fuss, and perhaps introduce a few newcomers to the wonderful world of the 80s/90s scene. A very important piece of the puzzle is the ability to play back various module formats true to the intention of the composer. So naturally that disqualifies most of the players; XM *must* be played in FT2 (Multi Module Player (MMP) does a reasonably good job, though; it's 90-95% there), S3M in ScreamTracker, and IT in ImpulseTracker. No surprises there 😀

But MOD files written on the Amiga pose a problem. CapaMod is reasonably accurate (but not perfect), and, of course, the linear interpolation of the GUS makes modules sound different. In most cases this is not worse, just a bit different, so it's OK. There's variation in the fixed filter behaviour between the OCS and AGA Amigas too (not the same, I know, but somewhat comparable). But for chiptunes written on the Amiga, the linear interpolation robs you of 30-50% of the overtones, which is a big problem. This makes many chiptunes not enjoyable to listen to. MMP with nearest-neighbour interpolation would be a good solution... except it doesn't implement sample swapping correctly, plus there are other subtle bugs in the playroutine too.

So long story short, PT4DOS is the *only* DOS player in existence that I wholeheartedly recommend for playing back Amiga chiptunes as nothing else is good enough. I will definitely include it in my pack, but stereo would be nice as everything downconverted to mono sounds a bit one-dimensional; that's not really the Amiga experience either.

You would not have to touch the carefully optimised mixing routine in asmixer.asm at all. You would simply need to write a second mixer that supports stereo separation at the same 44kHz mixing rate which would be less optimal, and would require 486+, but the user could select between the two mixer implementations via a command line switch.

Actually, given that you have released the source code (and thanks for that, everybody should do that!), I might write such a stereo mixer myself at some point. Very nice clean code with nice explanatory comments!

...of course, why complicate life when you could just use your PT clone natively on the host OS to play back these modules with almost 100% accuracy. Well, that's true, but this is going to be a DOS demoscene pack intended for DOSBox users. Playing chiptunes in the DOS environment will be part of the experience. And my not-too-disguised-goal with this is that for some people perhaps this will act as a "gateway drug" to go and explore the Amiga and maybe even the C64 demoscene 😀 So I need to represent Amiga ProTracker music in the best possible form, this is important for me.

8bitbubsy wrote on 2023-07-09, 11:51:

3) The gain is selected in a way where no clipping can happen, and this increases the speed of the mixer. Having an amp feature would mean I'd have to do 32-bit mixing (instead of 16), which is slower on a 386SX... And I'd also have to do clamping in the last mixer stage, which is also slower. I want PT4DOS to be fast enough for a mid-end 386.

Ah nice, wasn't sure about the gain scaling, but then you've done what's best. Yes, 32-bit mixing would be probably overkill.

8bitbubsy wrote on 2023-07-09, 11:51:

4) Fixed. Updated the ZIPs in the first post. I also removed the delay in the beginning, and the palette fade in/out. This causes the program to start/stop even faster.

Thanks for that, the removal of the fades is a welcome addition as well. Works great!

8bitbubsy wrote on 2023-07-09, 11:51:

5) I'm not sure if you knew this, but I did a crude one-pole implementation of the two-pole "LED" filter that the Amiga has, you can turn it on by pressing CTRL+F. It doesn't have the same timbre/resonance as the original filter since it's just one-pole. Having a filter like this running at all times would probably be too slow for my 386SX target. Anyway, I did make a new test version that runs a constant 6dB/oct f=~4421Hz low-pass to simulate that of Amiga 500. You can hear that the audio still has a lot of distortion: https://16-bits.org/etc/PT4DOSF.ZIP (CTRL+F / 'LED filter' is disabled in this version).
Maybe this is overall better?

You can press CTRL+R to see the frame time spent on mixing (doesn't work in DOSBox). The first bar is the time spent on rendering the graphics, and the second bar is the time spent on mixing audio.

Cool, this filter sounds very much like the Amiga 500 anti-aliasing filter. It would be great if this would be toggleable at startup with a command-line switch. I've realised many chiptunes actually sound better without this, which is pretty much the A1200 filter behaviour (virtually no filtering), so it's better not to hardcode it, but make it user-selectable.


Thanks again, hope my big wall of text hasn't bored you too much. I really appreciate your efforts, you clearly have as much love and passion for accurate XM and Amiga MOD reproduction as me! And extra bonus points for including the source code.

DOS: Soyo SY-5TF, MMX 200, 128MB, S3 Virge DX, ESS 1868F, AWE32, QWave, S2, McFly, SC-55, MU80, MP32L
Win98: Gigabyte K8VM800M, Athlon64 3200+, 512MB, Matrox G400, SB Live
WinXP: Gigabyte P31-DS3L, C2D 2.33 GHz, 2GB, GT 430, Audigy 4

Reply 16 of 32, by 8bitbubsy

User metadata
Rank Member
Rank
Member

Trashing the least significant byte of a 32-bit fractional value shouldn't be audible at all. That lower byte is ~0.000006% of the whole 2^32 fractional range. It doesn't translate to an error of 2-3 musical cents (1/100th of a semitone), not even remotely close.

Let's do a test to prove this.

C-1 finetune 0 (in PT) = 4143.56892523Hz. Since we mix at 45454.54¯ recurring Hz (SB16), this gives us a delta/ratio of 4143.56892523 / 45454.54¯ = 0.09115851635.
Since we work with 32.32fp precision, we need to multiply that by 2^32, so the 32.32fp delta value is: round[(4143.56892523 / 45454.54¯) * 2^32] = 391522846.

Ok, so our 32.32fp delta value is 391522846. To convert this back to note Hz, we do this:
(391522846 / 2^32) * 45454.54¯= 4143.56891992Hz. That's already very close to the input 4143.56892523Hz note.

Now, let's set the lower byte of this value to 16 to simulate the micro-optimization: (391522846 & ~255) + 16 = 391522832.
And let's convert this new 32.32fp delta value back to note hertz: (391522832/ 2^32) * 45454.54¯ = 4143.56877176Hz.

After the "16 optimization", we have an additional error of ~0.00015Hz... If my calculations are correct, that would translate to a difference of a whopping 0.000062 cents!

Anyway, in case you still think this is the problem, I removed the hack and uploaded a test binary here: https://16-bits.org/etc/PT4DOS3.ZIP
I'm pretty sure the pitch error has to come from something else, and I'm out of ideas right now.

I assume you don't use DOSBox-X? It has a pitch problem in its SB16 emulator when the output frequency is set to 45454Hz.

386:
- CPU: 386DX-40 (128kB external L1 cache)
- RAM: 8MB (0 waitstates at 40MHz)
- VGA: Diamond SpeedSTAR VGA (ET4000AX 1MB ISA)
- Audio: SB Pro 2.0 + GUS 1MB
- ISA PS/2 mouse card + ISA USB card
- MS-DOS 6.22 + Win 3.1
- MR BIOS

Reply 17 of 32, by Rincewind42

User metadata
Rank Member
Rank
Member
8bitbubsy wrote on 2023-07-10, 11:13:
Trashing the least significant byte of a 32-bit fractional value shouldn't be audible at all. That lower byte is ~0.000006% of t […]
Show full quote

Trashing the least significant byte of a 32-bit fractional value shouldn't be audible at all. That lower byte is ~0.000006% of the whole 2^32 fractional range. It doesn't translate to an error of 2-3 musical cents (1/100th of a semitone), not even remotely close.

Let's do a test to prove this.

C-1 finetune 0 (in PT) = 4143.56892523Hz. Since we mix at 45454.54¯ recurring Hz (SB16), this gives us a delta/ratio of 4143.56892523 / 45454.54¯ = 0.09115851635.
Since we work with 32.32fp precision, we need to multiply that by 2^32, so the 32.32fp delta value is: round[(4143.56892523 / 45454.54¯) * 2^32] = 391522846.

Ok, so our 32.32fp delta value is 391522846. To convert this back to note Hz, we do this:
(391522846 / 2^32) * 45454.54¯= 4143.56891992Hz. That's already very close to the input 4143.56892523Hz note.

Now, let's set the lower byte of this value to 16 to simulate the micro-optimization: (391522846 & ~255) + 16 = 391522832.
And let's convert this new 32.32fp delta value back to note hertz: (391522832/ 2^32) * 45454.54¯ = 4143.56877176Hz.

After the "16 optimization", we have an additional error of ~0.00015Hz... If my calculations are correct, that would translate to a difference of a whopping 0.000062 cents!

Anyway, in case you still think this is the problem, I removed the hack and uploaded a test binary here: https://16-bits.org/etc/PT4DOS3.ZIP
I'm pretty sure the pitch error has to come from something else, and I'm out of ideas right now.

I assume you don't use DOSBox-X? It has a pitch problem in its SB16 emulator when the output frequency is set to 45454Hz.

Yeah, I missed the decimals... 1/100 is 0.01, indeed, my bad 😀

I'm using DOSBox Staging (I'm one of the maintainers) and we're rendering at proper SB rates, so 45454 in this case, then resample with a high-quality resampler (SpeeX) to whatever output rate (48kHz in my case). So yeah, maybe something goes slightly wrong there, although if the resampler introduces slight pitch variations that's kind of unacceptable. Anyway, I'll look into it!

DOS: Soyo SY-5TF, MMX 200, 128MB, S3 Virge DX, ESS 1868F, AWE32, QWave, S2, McFly, SC-55, MU80, MP32L
Win98: Gigabyte K8VM800M, Athlon64 3200+, 512MB, Matrox G400, SB Live
WinXP: Gigabyte P31-DS3L, C2D 2.33 GHz, 2GB, GT 430, Audigy 4

Reply 18 of 32, by Rincewind42

User metadata
Rank Member
Rank
Member

Ok, so I've tried your new executable with the optimisation hack removed, but it makes no difference.

I've done another quick round of tests: I've compared the same tune in FT2 with GUS and SB16, in CapaMod (GUS) and in MMP (SB16), all in DOSBox of course (all these other players are not accurate, of course, but I assume they at least get the pitches and fine-tuning right, and they do, as it turns out). I've done the tests both with 44.1kHz and 48kHz host sample rates. The results are interesting: basically the pitches match in all variations, so that's in multiple programs using multiple playroutines and two different audio drivers (both in the DOS program *and* also in DOSBox!), and they all match with your PT clone. The only outlier is PT4DOS; yep, the pitch is a bit lower, I can clearly hear it. If interested, I can create recordings for you, but I'd be surprised if this was a problem that only manifested on my system, given I've tried with all these other player & output driver combinations.

I can also fire up my real Amiga 500 and real DOS PC, but to me it's enough proof that PT4DOS is a bit off. However, small issue, as I said — overall, it's great! Still the best MOD player on DOS, hands down; 1-2 Hz off or not 😀

DOS: Soyo SY-5TF, MMX 200, 128MB, S3 Virge DX, ESS 1868F, AWE32, QWave, S2, McFly, SC-55, MU80, MP32L
Win98: Gigabyte K8VM800M, Athlon64 3200+, 512MB, Matrox G400, SB Live
WinXP: Gigabyte P31-DS3L, C2D 2.33 GHz, 2GB, GT 430, Audigy 4

Reply 19 of 32, by 8bitbubsy

User metadata
Rank Member
Rank
Member

OK, maybe I'm off-by-one somewhere in the code, I don't know. Will investigate later.

BTW, comparing to FT2 makes no sense, as FT2 doesn't have the same middle-C tuning as ProTracker. ProTracker is more like A4=~436Hz, while FT2 is closer to 440Hz.

386:
- CPU: 386DX-40 (128kB external L1 cache)
- RAM: 8MB (0 waitstates at 40MHz)
- VGA: Diamond SpeedSTAR VGA (ET4000AX 1MB ISA)
- Audio: SB Pro 2.0 + GUS 1MB
- ISA PS/2 mouse card + ISA USB card
- MS-DOS 6.22 + Win 3.1
- MR BIOS