FM PCM Player 1.0 released

FM PCM Player 1.0 released

by Grauw on 12-01-2020, 16:55
Обсуждение: Software
Теги: grauw, PCM, player, MSX-MUSIC
Языки:

Grauw released a PCM player for the YM2413 OPLL MSX-MUSIC.

Not only does it play PCM in high 8-bit quality, but it also shows a nice wave visualisation effect while doing so. It requires MSX2, MSX-DOS2, and several megabytes of memory is recommended.

It works by forcing the phase generator to hold on a specified phase using test register bit 2. This allows it to index into the sine table and produce accurate near 8-bit sample playback with a simple inverse lookup table.

The playback is timed by synchronizing to the VDP line drawing frequency, which provides a good high-frequency timer on MSX2 that is CPU speed independent. Additionally it lets it render the nice visualisation.

You can see the FM PCM player in action in this video (Youtube).

Relevant link: FM PCM Player project page
Relevant link: Forum thread

Media browser (2)

  • FM PCM Player 1.0 released
  • FM PCM Player 1.0 released

Комментарии (17)

By Pencioner

Scribe (1202)

Аватар пользователя Pencioner

12-01-2020, 22:59

Nice job! I would never expect that pure FM chip could do that Wink

I'm wondering how well does it work with the FPGA implementations of OPLL. Can't test myself right now as i'm packing stuff (moving to new apartment soon) but i'll do when i have a chance if nobody tries it before

By Giangiacomo Zaffini 2

Master (234)

Аватар пользователя Giangiacomo Zaffini 2

13-01-2020, 00:28

How long before cheap 8Mbytes-16Mbytes mapped RAM cartridges since they're becoming needed more and more? Tongue

Good work Grauw! (as always!) Big smile

By edoz

Prophet (2302)

Аватар пользователя edoz

13-01-2020, 09:26

Wow! How is this possible?! The sound is just very good! Nice!

By ericb59

Paladin (1015)

Аватар пользователя ericb59

13-01-2020, 13:52

Oh great.
Does it possible to use it to play samples stored in VRAM just like the PCMplay of the Turbo-R ?
If Yes, it will be good for my next upcoming project !

By msd

Paragon (1405)

Аватар пользователя msd

13-01-2020, 13:53

Very cool. Can this only be done with the YM2413?

By Parn

Hero (610)

Аватар пользователя Parn

13-01-2020, 14:21

Very nice, @Grauw!

msd wrote:

Very cool. Can this only be done with the YM2413?

Grauw's tool is specifically for the OPLL. But there are already other ways of playing 8-bit samples in MSX-Audio (it has PCM and ADPCM), SCC, PSG and of course OPL4 (which supports up to 16-bit 44.1kHz samples).

EDIT: Actually Grauw's tool also supports the turboR PCM, which means it also works in the latest OCM firmware, albeit in turboR PCM mode instead of OPLL mode, since current FPGA implementations don't support what's needed for this to work.

By Grauw

Ascended (9396)

Аватар пользователя Grauw

13-01-2020, 16:02

ericb59 wrote:

Does it possible to use it to play samples stored in VRAM just like the PCMplay of the Turbo-R ?
If Yes, it will be good for my next upcoming project !

Yes, that is a simple matter of replacing an ld a,(hl) by an in a,(98H).

msd wrote:

Very cool. Can this only be done with the YM2413?

In principle it can be done with all Yamaha OP* chips since all of them have the phase generator hold function in the test register.

However there is one catch; the OPLL has a 9-bit f-num, and by setting only the LSB you can reach the entire amplitude range quite easily. The OPL series however have a 10-bit f-num, and as a result the LSB only has half the range. It is preferred to only change one register because if you need to change multiple it will introduce noise. I think the LSB’s range can be increased by involving the modulator though.

I want to experiment with getting this to work on the OPL series as well, just for completeness’ sake. For OPL4 the benefit would be that this allows streaming PCM of arbitrary length, something which it normally can’t do. As for MSX-AUDIO and OPNA, they have a more direct register in their ADPCM unit that allows PCM output without silencing FM playback, so that is the more obvious option. Nevertheless it would also be interesting to try it out on the OPN series.

By msd

Paragon (1405)

Аватар пользователя msd

13-01-2020, 16:51

@Parn I mean.. Is the YM2413 the only FM chip used on MSX where you can use this method.

By Parn

Hero (610)

Аватар пользователя Parn

13-01-2020, 18:16

Sorry for not getting at first! As @Grauw said, it's not, but it's the one where it would be most useful at first.

By Giangiacomo Zaffini 2

Master (234)

Аватар пользователя Giangiacomo Zaffini 2

13-01-2020, 19:30

@Grauw: I read from You that the same technique should work on OPN chip? Did I read it right?

By Pac

Guardian (5924)

Аватар пользователя Pac

13-01-2020, 20:00

Excellent work! Wink I didn't follow the forum thread (sorry), is this solution suitable for games?

By Grauw

Ascended (9396)

Аватар пользователя Grauw

13-01-2020, 21:24

Giangiacomo Zaffini 2 wrote:

@Grauw: I read from you that the same technique should work on OPN chip? Did I read it right?

I haven’t confirmed it yet, but I think it should work since on the OPN series register 21H (test) bit 3 has the PG reset/hold function. Then the same principles should apply. If we’re unlucky though it freezes the count but does not reset, I do read something along those lines in some of the notes, but they may have misinterpreted their measurements.

For the OPL series I’m pretty confident it will work like the OPLL (the test register bit is also the same).

PAC wrote:

Excellent work! Wink I didn't follow the forum thread (sorry), is this solution suitable for games?

Well not during live gameplay since it takes 100% CPU while the sample is playing. But you can have quick attack samples like in Rune Master 2, or ones like in the Fray turboR version intro.

By Grauw

Ascended (9396)

Аватар пользователя Grauw

15-01-2020, 00:35

Grauw wrote:

In principle it can be done with all Yamaha OP* chips since all of them have the phase generator hold function in the test register.

I tried it tonight and I can confirm that indeed this can also work on MSX-AUDIO and MoonSound.

Quote:

However there is one catch; the OPLL has a 9-bit f-num, and by setting only the LSB you can reach the entire amplitude range quite easily. The OPL series however have a 10-bit f-num, and as a result the LSB only has half the range. It is preferred to only change one register because if you need to change multiple it will introduce noise. I think the LSB’s range can be increased by involving the modulator though.

I can also confirm this is indeed the case. Tonight’s test therefore used carrier multiplier 8 (instead of 4 on the OPLL) to index in a quarter sine. I can double the amplitude by selecting the additive algorithm but it does have DC offset. I will fiddle around with modulator settings next to get rid of the DC offset.

By msd

Paragon (1405)

Аватар пользователя msd

15-01-2020, 11:18

Quote:

. It is preferred to only change one register because if you need to change multiple it will introduce noise.

Isn't update of the f-num completed by writing to the low byte of the f-num (or the other way around). So I think it shouldn't introduce noise

By Grauw

Ascended (9396)

Аватар пользователя Grauw

15-01-2020, 14:36

I don't think so, it is like that on the OPN series but not on OPL.

But, for implementing this technique on OPN that is actually an interesting observation.

By mohai

Paladin (899)

Аватар пользователя mohai

17-01-2020, 13:55

Nice ! Big smile
It is really impressive.
I am not very skilled in sound generation. Would it be possible to replay more than one sample at once?
Maybe lowering the sample rate a little?
I am thinking about mod-like player.
... and regarding mod player: Could the old mod-player for Turbo R be modded to get full stereo using both PCM and your OPLL routine?

By Grauw

Ascended (9396)

Аватар пользователя Grauw

17-01-2020, 20:38

mohai wrote:

Nice ! Big smile It is really impressive. I am not very skilled in sound generation. Would it be possible to replay more than one sample at once? Maybe lowering the sample rate a little?

Thanks! The number of channels can be up to 9, however since the YM2413 has a wait requirement of 96 cycles per access, the maximum frequency for >1 channels is determined by the formula 3579545 / 96 / <channel-count>. E.g. for 2 channels the maximum is 18643 Hz and for 4 channels it is 9322 Hz.

However instead of using multiple channels you might as well add all the samples together and play them on a single channel. The downside is a small reduction in bit-depth but on the upside you can have a higher frequency which in my opinion is more important for good sound quality.

Bit-depth affects the noise floor, which isn’t audible during loud music, while frequency determines whether it sounds bright or muffled overall.

mohai wrote:

I am thinking about mod-like player.
... and regarding mod player: Could the old mod-player for Turbo R be modded to get full stereo using both PCM and your OPLL routine?

For turboR the answer is simple since a MOD player has been done before Smile. The FM method doesn’t really add significant overhead compared to the internal DAC, so it should work equally well. However since its MSX-MUSIC and DAC are output through the same mono jack, you won’t get any stereo, so you might as well just use the internal DAC.