VOGONS


Reply 20 of 28, by OPLx

User metadata
Rank Member
Rank
Member
ViTi95 wrote on 2021-09-13, 14:32:

This is great! The code looks very simple and sounds pretty decent, maybe I can add support for FastDoom with this technique.

One little question, what's the maximum frequency the GameBlaster supports?

EDIT: Another question, does this work on DosBox?

The SAA1099s on the GameBlaster are clocked at 7.15909 MHz, so the highest frequency the tone generators can reach is about 6.99 kHz. Since the technique stefan mentioned doesn't use the envelope generators, it should work. Sadly, I don't have any time to try to verify this myself.

Reply 21 of 28, by ViTi95

User metadata
Rank Member
Rank
Member
Tiido wrote on 2021-03-13, 16:44:
SAA output should be logarithmic as is AY and the Ti PSG. You will need to take this into account for a decent sound quality. He […]
Show full quote

SAA output should be logarithmic as is AY and the Ti PSG. You will need to take this into account for a decent sound quality. Here are two examples I have done on Sega Master System, one without taking the log scale into account and one that does :
http://www.tmeeco.eu/BitShit/SMSPCM0.SMS
http://www.tmeeco.eu/BitShit/SMSPCM1.SMS

And here is one that has double sample rate + log compensation : http://www.tmeeco.eu/BitShit/SMSPCM.SMS

A good emulation is necessary for good sound, or actual hardware off flashcart.

Another question, is there any formula that allows to convert regular 8-bit PCM audio to any logarithmic scale? I'm trying to make an OPL2 play PCM sounds, and it works but the sound isn't as good as it should. The main issue is the same, the volume scale is logarithmic and it should be taken into account (6-bits available, ranging from 0,75db to 24db), but I don't know exactly how to solve this problem.

Reply 22 of 28, by Tiido

User metadata
Rank l33t
Rank
l33t

I only have a partial answer, I got some linear to variable log transform going as part of PCM playback on a log space such as YM chips and TI PSG but I don't know why exactly the code does what it does anymore
Ratio is the change between levels that is entered. 0.5 would mean -6db so this is something I calculated out first in some way. I think I used some online web calculator that told the ratio when you entered db. It shouldn't be too hard to find how it is defined and calculate it yourself from the db figure alone.

Here is the code (for FreeBASIC) :

DIM LogSteps!(255), LogTable%(255)
CLS
PRINT "Tiido's kick„ss WAV to YM PCM converter v0.1 !": PRINT

SamOffs% = 7
HeaderSize& = 46

'Ratio! = .917275935389# '-0.75db
Ratio! = .963274358699# '-0.325db

LogSteps!(255) = 127
FOR i% = 254 TO 0 STEP -1
LogSteps!(i%) = (LogSteps!(i% + 1) * Ratio!)
NEXT i%

LogTable%(0) = 0
FOR i% = 1 TO 255
LogTable%(i%) = LogSteps!(i%)
NEXT i%


OPEN "GREENSXG.WAV" FOR BINARY AS #1
FileSize& = LOF(1) - HeaderSize&
REDIM FileBuffer(FileSize&) AS UBYTE
GET #1,HeaderSize&,FileBuffer()
CLOSE #1

FOR i& = 0 TO FileSize&
FileBuffer(i&) = LogTable%(FileBuffer(i&))
NEXT i&

OPEN "YMPCM.BIN" FOR BINARY AS #1
PUT #1,1,FileBuffer()
CLOSE #1

It may be useful to get going with a superior solution ~

T-04YBSC, a new YMF71x based sound card & Official VOGONS thread about it
Newly made 4MB 60ns 30pin SIMMs ~
mida sa loed ? nagunii aru ei saa 😜

Reply 23 of 28, by bakemono

User metadata
Rank Oldbie
Rank
Oldbie

attenuation = log (PCM / 255) * 20

(log base 10 that is)

255 = 0dB
254 = -0.034dB
253 = -0.068dB
...
129 = -5.919dB
128 = -5.986dB

yet another retro game on itch: https://90soft90.itch.io/super-wild-war-22

Reply 25 of 28, by ViTi95

User metadata
Rank Member
Rank
Member

Huge thanks Tiido and bakemono, I've been able to add OPL2 PCM support to FastDoom!!!. Now I understand much better how it works, next step will be adding CMS PCM support (but first I need a compatible sound card ^^).

Reply 26 of 28, by Tiido

User metadata
Rank l33t
Rank
l33t

Congrats, I hope it sounds good ~

T-04YBSC, a new YMF71x based sound card & Official VOGONS thread about it
Newly made 4MB 60ns 30pin SIMMs ~
mida sa loed ? nagunii aru ei saa 😜

Reply 27 of 28, by ViTi95

User metadata
Rank Member
Rank
Member

Hi again! I've been able to add C/MS support to FastDoom thanks to your code @Tronix (although I'm using only CH2 from the SAA1099 in a simpler way). But here is a question, I cannot find specific information about the amplitude register, the datasheets don't explain if it is linear or logarithmic nor the number of dB used between steps. Is there any information available about this?

Reply 28 of 28, by Tiido

User metadata
Rank l33t
Rank
l33t

It should be logarithmic and same step size as AY but I am not 100% sure either.

EDIT: MAME source suggests it is using a linear scale, dividing full scale into 15 steps.

T-04YBSC, a new YMF71x based sound card & Official VOGONS thread about it
Newly made 4MB 60ns 30pin SIMMs ~
mida sa loed ? nagunii aru ei saa 😜