VOGONS


First post, by superfury

User metadata
Rank l33t++
Rank
l33t++

What happens on the Adlib when you set the frequency bits to 0? I've read at a document on using PCM on an Adlib card, that the Adlib keeps outputting the current signal voltage(I don't know if this is on the Carrier only) and that you can sound 6-bit PCM (Ammount of output volumes) by changing the Output level to the PCM sample (and delaying for the next sample using a timer like the PIT). But according to documentation on the Adlib, when you set the Output volume to 0, you actually select a value of arround 60dB? So when you send a sample with value 0 (which is supposed to become 0 Volts), you get the maximum voltage (Which is the maximum output voltage the Adlib supports)? Is this correct? Or is the value of 0 actually giving a 0dB signal (in which case it's correct to use this method to output mono PCM on the channel using the Adlib Output volume)?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 1 of 16, by Scali

User metadata
Rank l33t
Rank
l33t

I don't think this is entirely correct.
There are some sound chips where you can indeed play a frequency of 0 to play samples, but the Adlib is not one of them.
The technique for playing samples on Adlib is to generate a note at a frequency where you are exactly in phase with the DAC, resulting in emitting the same sample at every output, which effectively is like a frequency of 0, so playing PCM samples is as simple as modifying the volume from there on (same trick as used on eg SN76489 chips, which DO accept a frequency of 0).

The volume may be 'inverted', so that higher volume values result in softer output, with value 0 being the maximum (it's like that on SN76489), but I'm not sure which way the volume goes on an Adlib. At any rate, it doesn't matter, because it's easy to invert your sample values to compensate.
Another thing you may want to compensate for is that the volume may not be on a linear scale, where PCM samples are. On SN76489 the volume scale is more or less logarithmic, so you want to perform a remapping fron linear to the SN76489 volume scale on your samples before playing them.

http://scalibq.wordpress.com/just-keeping-it- … ro-programming/

Reply 3 of 16, by Jepael

User metadata
Rank Oldbie
Rank
Oldbie

The PCM is really played when frequency is set to zero. As zero stops the selected waveform like sine from advancing, you need to start playing a sine wave at some nonzero rate and stop it at maximum amplitude which just needs somewhat accurate timing.

Then, the volume register can be set according to played PCM. But as said before 0 is max volume and 63 is min volume and it is logarithmic, and real OPL2 can only accept register writes at a max rate of about 27kHz, there are not much tricks to improve the sound quality. But it really does not matter if you map from 0 to 63 or from 63 to 0, the other way around its just like the sample values were multiplied by -1, or inverted 180 degrees in phase if you want to think that way. Mono PCM will still sound the same, and the logarithminess makes it still sound like garbage. But it will work if you want to try it.

Reply 4 of 16, by superfury

User metadata
Rank l33t++
Rank
l33t++

It's just that I want to implement this in my Adlib emulation if needed. If this technique is actually used by software, I'm want to implement it eventually, but since it seems like the technique probably won't be used by software(since it doesn't work that way), I think I wont implement it after all.

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 5 of 16, by Jepael

User metadata
Rank Oldbie
Rank
Oldbie

Some MOD player used it. Inertia or Cubic. I don't know if they need a 386 CPU. At least the Adlib output did work poorly on DosBox the last time I tried.

I don't know about games though.

Reply 6 of 16, by Harekiet

User metadata
Rank DOSBox Author
Rank
DOSBox Author

dosbox should be able to do it if it just did better on demand mixing when registers change. But for all general things the millisecond accuracy dosbox uses sounds decent enough.

Reply 8 of 16, by superfury

User metadata
Rank l33t++
Rank
l33t++

Just thought about something: If you stop all operators at maximum volume(all 18 operators) and have the chip in Additive Synthesis mode, you'll get 18 crude '6-bit' audio channels using PCM audio! That's about 16 Covox Speech Things at 49kHz right there! Is this actually workable on those old PCs(8086 etc.)? What about the slightly faster ones (8086@10MHz, 80286@14MHz, 80386@33MHz)?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 9 of 16, by Jepael

User metadata
Rank Oldbie
Rank
Oldbie
superfury wrote:

Just thought about something: If you stop all operators at maximum volume(all 18 operators) and have the chip in Additive Synthesis mode, you'll get 18 crude '6-bit' audio channels using PCM audio! That's about 16 Covox Speech Things at 49kHz right there! Is this actually workable on those old PCs(8086 etc.)? What about the slightly faster ones (8086@10MHz, 80286@14MHz, 80386@33MHz)?

In theory yes, but in practice there's quite many limitations.

-at maximum volume, only 8 operators can fit into output without clipping (but of course not all channels would be at maximum value at the same instant so in practice you can play more channels without clipping depending on what you play).
-the 6-bit volume register is logarithmic, so it is very bad for playing linear PCM. It would sound much more crude than simple 8-bit Covox DAC, or even a 6-bit linear DAC. I haven't done the maths, but I assume it would equal to something like 4-bit linear PCM.
-OPL2 needs so long delays between port writes that you can only write theoretically maximum of 37287 different registers per second, regardless of what CPU drives it. So even with two channels would be 18.6 kHz, and four channels would be 9.3 kHz - hardly enough for 4 channel MOD playing.

Reply 10 of 16, by superfury

User metadata
Rank l33t++
Rank
l33t++

You say 8 operators. Isn't this actually 9 operators? There's 9 melodic channels(or 6 with 3 drum channels), so why 8 operators?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 11 of 16, by Jepael

User metadata
Rank Oldbie
Rank
Oldbie

I think the numbers have been discussed in other threads already, but I'll mention the specs again:

-In melodic mode, OPL2 has 9 channels with 2 operators each, so 18 operators in total.
-Maximum amplitude of a single operator is 4084
-Maximum value you can fit into 16-bit signed integer is +32767
-8*4084 will fit without problems
-9*4084 does not fit and there will be clipping distortion

So yes, if you lower the volume of each operator into half, you get double the amount of operators without clipping.

Reply 12 of 16, by superfury

User metadata
Rank l33t++
Rank
l33t++

So the adlib has 9 channels, but you ordinarily can't use them at full volume all 9 at once without clipping?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 13 of 16, by Jepael

User metadata
Rank Oldbie
Rank
Oldbie
superfury wrote:

So the adlib has 9 channels, but you ordinarily can't use them at full volume all 9 at once without clipping?

No, not the amount of channels, but the amount of operators producing output. You can have two sound producing operators per channel.

Of course it is possible that playing normal music with 9 FM channels at full volume does not clip, but if you play a sine wave on 9 operators simultaneously with the same phase, their peaks happen at the same time.

Reply 14 of 16, by superfury

User metadata
Rank l33t++
Rank
l33t++

So actually starting the same sine wave on all 9 channels with maximum volume on each operator will result in the output clipping? Or won't it clip, as long as you use FM sythesis mode for all channels?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 15 of 16, by Jepael

User metadata
Rank Oldbie
Rank
Oldbie

-8 channels in FM mode -> 8 operators -> cannot clip
-9 channels in FM mode -> 9 operators -> can clip

-4 channels in AM mode -> 8 operators -> cannot clip
-5 channels in AM mode -> 10 operators -> can clip

Reply 16 of 16, by superfury

User metadata
Rank l33t++
Rank
l33t++

OK. Just readjusted the emulation to fit in only 8 channels worth (before clipping) of FM data(or 4 of AM data if all used.

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io