Konami SCC playback sample code?

Page 1/2
| 2

Par zPasi

Champion (471)

Portrait de zPasi

24-08-2019, 18:54

I'm looking for simple SCC sample / music / sfx playback code. I've found TriloTracker source but it doesn't quite look simple...

I have made some music with Arkos 2 tracker, and I'd like to utilise also SCC but don't want to remake my songs. But it is possible to add PSG channels. So I think a code that plays PSG data on the SCC would do?

!login ou Inscrivez-vous pour poster

Par zPasi

Champion (471)

Portrait de zPasi

29-08-2019, 07:35

No help? Damn.

Ok, there is SCC detection routine in the Wiki. Then, playing with the thing is documented well enough elsewhere. And simple enough, I just have to set some waveforms and play with the registers. Are the frequencies the same than with PSG? Even if they aren't, should not be too hard.

I think I'll test that TriloTracker also.

Par ro

Guardian (4118)

Portrait de ro

29-08-2019, 08:07

Hai zPasis, I'm not aware of such program or source code that plays Arkos files on SCC.
There's not much conversion software, but plenty of dedicated trackers.

Perhaps the TriloTracker folks could look into AT files import Smile I'd might do the same for Oracle, but that's PSG and FM, no SCC (yet/its in planning for 20 years..heh)

Par NYYRIKKI

Enlighted (5382)

Portrait de NYYRIKKI

29-08-2019, 08:14

Maybe this will help?
https://www.msx.org/news/software/en/psg2scc
(https://www.youtube.com/watch?v=0JTfDCyaJEE)

zPasi wrote:

Are the frequencies the same than with PSG?

Yes, frequencies are... Volumes need conversion table.

Par zPasi

Champion (471)

Portrait de zPasi

29-08-2019, 21:08

NYYRIKKI wrote:

Maybe this will help?

It might. With source could help even more.

Curious, in the video you demo that program with Basic play commands. I tried that with no success, and thought that your software doesn't work at all. But it works, at least with some software. I'll do some more tests.

But I also want some more channels. So 3 PSG channels plus a couple of SCC channels. Or all SCC channels and then a some PSG, or ...

Then I learned the main challenge probably is the Arkos player, understanding that code. It's well documented and all, but there is quite a lot of code. Maybe Targhan can help with that.

Par Grauw

Ascended (8442)

Portrait de Grauw

29-08-2019, 22:17

NYYRIKKI wrote:
zPasi wrote:

Are the frequencies the same than with PSG?

Yes, frequencies are... Volumes need conversion table.

They are almost the same, but not entirely; the SCC periods are 1 lower than the PSG. You gotta adjust for it or else the higher pitch tones sound out of tune with the PSG. Note that for both you specify a period (wave length) rather than a frequency.

The PSG frequency & period formulas:

tone_freq = clock / (32 × tone_period)
tone_period = clock / tone_freq / 32

The SCC frequency & period formulas:

tone_freq = clock / (32 × (tone_period + 1))
tone_period = clock / tone_freq / 32 - 1

Where clock = (315 / 88) × 10^6 = 3579545.45454545…

So a 440 Hz middle A has period 254 on the PSG, and period 253 on the SCC.

Here’s the PSG period table (indexed by MIDI note number), just subtract 1 for the SCC period:

    dw 4095  ; note 0
    dw 4095  ; note 1
    dw 4095  ; note 2
    dw 4095  ; note 3
    dw 4095  ; note 4
    dw 4095  ; note 5
    dw 4095  ; note 6
    dw 4095  ; note 7
    dw 4095  ; note 8
    dw 4095  ; note 9
    dw 4095  ; note 10
    dw 4095  ; note 11
    dw 4095  ; note 12
    dw 4095  ; note 13
    dw 4095  ; note 14
    dw 4095  ; note 15
    dw 4095  ; note 16
    dw 4095  ; note 17
    dw 4095  ; note 18
    dw 4095  ; note 19
    dw 4095  ; note 20
    dw 4068  ; note 21
    dw 3839  ; note 22
    dw 3624  ; note 23
    dw 3420  ; note 24
    dw 3229  ; note 25
    dw 3047  ; note 26
    dw 2876  ; note 27
    dw 2715  ; note 28
    dw 2562  ; note 29
    dw 2419  ; note 30
    dw 2283  ; note 31
    dw 2155  ; note 32
    dw 2034  ; note 33
    dw 1920  ; note 34
    dw 1812  ; note 35
    dw 1710  ; note 36
    dw 1614  ; note 37
    dw 1524  ; note 38
    dw 1438  ; note 39
    dw 1357  ; note 40
    dw 1281  ; note 41
    dw 1209  ; note 42
    dw 1141  ; note 43
    dw 1077  ; note 44
    dw 1017  ; note 45
    dw 960  ; note 46
    dw 906  ; note 47
    dw 855  ; note 48
    dw 807  ; note 49
    dw 762  ; note 50
    dw 719  ; note 51
    dw 679  ; note 52
    dw 641  ; note 53
    dw 605  ; note 54
    dw 571  ; note 55
    dw 539  ; note 56
    dw 508  ; note 57
    dw 480  ; note 58
    dw 453  ; note 59
    dw 428  ; note 60
    dw 404  ; note 61
    dw 381  ; note 62
    dw 360  ; note 63
    dw 339  ; note 64
    dw 320  ; note 65
    dw 302  ; note 66
    dw 285  ; note 67
    dw 269  ; note 68
    dw 254  ; note 69 - A4 440 Hz
    dw 240  ; note 70
    dw 226  ; note 71
    dw 214  ; note 72
    dw 202  ; note 73
    dw 190  ; note 74
    dw 180  ; note 75
    dw 170  ; note 76
    dw 160  ; note 77
    dw 151  ; note 78
    dw 143  ; note 79
    dw 135  ; note 80
    dw 127  ; note 81
    dw 120  ; note 82
    dw 113  ; note 83
    dw 107  ; note 84
    dw 101  ; note 85
    dw 95  ; note 86
    dw 90  ; note 87
    dw 85  ; note 88
    dw 80  ; note 89
    dw 76  ; note 90
    dw 71  ; note 91
    dw 67  ; note 92
    dw 64  ; note 93
    dw 60  ; note 94
    dw 57  ; note 95
    dw 53  ; note 96
    dw 50  ; note 97
    dw 48  ; note 98
    dw 45  ; note 99
    dw 42  ; note 100
    dw 40  ; note 101
    dw 38  ; note 102
    dw 36  ; note 103
    dw 34  ; note 104
    dw 32  ; note 105
    dw 30  ; note 106
    dw 28  ; note 107
    dw 27  ; note 108
    dw 25  ; note 109
    dw 24  ; note 110
    dw 22  ; note 111
    dw 21  ; note 112
    dw 20  ; note 113
    dw 19  ; note 114
    dw 18  ; note 115
    dw 17  ; note 116
    dw 16  ; note 117
    dw 15  ; note 118
    dw 14  ; note 119
    dw 13  ; note 120
    dw 13  ; note 121
    dw 12  ; note 122
    dw 11  ; note 123
    dw 11  ; note 124
    dw 10  ; note 125
    dw 9  ; note 126
    dw 9  ; note 127

About volumes, the PSG volume is logarithmic while SCC volumes are linear, so given that a volume of 15 is the max, a PSG volume of 13 equals an SCC volume of 7.5. The SCC is basically not very good at playing softly, logarithmic scale would’ve been better but alas. That’s also why fade-outs in Konami SCC games always sound a bit odd.

If you want more precise volume control on the SCC you could instead scale the waveform (255 linear steps instead of 15). For regular volume control it’s probably better to just work with the volume register and compose the music to match its characteristics, however if you want to balance the waves more precisely against each other and the PSG you could bake the base volume into the waveform.

Volume conversion table, from PSG to SCC volume:

    db 15  ; vol 15
    db 11  ; vol 14
    db 8  ; vol 13
    db 5  ; vol 12
    db 4  ; vol 11
    db 3  ; vol 10
    db 2  ; vol 9
    db 1  ; vol 8
    db 1  ; vol 7
    db 1  ; vol 6
    db 0  ; vol 5
    db 0  ; vol 4
    db 0  ; vol 3
    db 0  ; vol 2
    db 0  ; vol 1
    db 0  ; vol 0

Par ARTRAG

Enlighted (6243)

Portrait de ARTRAG

29-08-2019, 22:55

A complete SCC description is here
http://bifi.msxnet.org/msxnet/tech/scc

Par zPasi

Champion (471)

Portrait de zPasi

30-08-2019, 06:51

Thanks Grauw and ARTRAG!

Par KdL

Paragon (1227)

Portrait de KdL

30-08-2019, 17:01

Hi zPasi, Hi, take a look at this: https://gnogni.altervista.org/msx/bntplay.zip

Here are the file format specifications: https://www.msx.org/wiki/SCC_Blaffer_NT_file_format

Par zPasi

Champion (471)

Portrait de zPasi

01-09-2019, 22:35

KdL wrote:

Hi zPasi, Hi, take a look at this: https://gnogni.altervista.org/msx/bntplay.zip

Very interesting!

Par zPasi

Champion (471)

Portrait de zPasi

12-10-2019, 18:42

I have made some progress. I disassembled PSG2SCC and found everything needed to access SCC. In the interrupt (tsr) part there is a routine that peeks the PSG registers, converts the values for SCC and then sets them. The simplest way using that is to call it for every frame, right after calling PLY_AKG_PLAY.

BTW: PSG2SCC doesn't silence the PSG, so both PSG and SCC play the same notes.

A better way is to skip the PSG registers and transfer the OUT values from PLY_AKG_PLAY directly to a modified version of that PSG2SCC routine.

When Arkos 2 player is assembled with PLY_AKG_HARDWARE_MSX = 1 and PLY_AKG_Rom = 1, and then Disarked, we've got all the register OUTing nicely together after the label PLY_AKG_SENDPSGREGISTERS:

PLY_AKG_SENDPSGREGISTERS: ld b,a
    ld a,#7
    out (160),a
    ld a,b
    out (161),a
    ld hl,(49181)
    xor a
    out (160),a
    ld a,l
    out (161),a
    ld a,#1
    out (160),a
    ld a,h
    out (161),a
  ... etc

That helped me to better understand the original Arkos player code. I just have to search for the label PLY_AKG_SendPSGRegisters, and IFDEF PLY_AKG_HARDWARE_MSX after that. Not too hard.

But how to use more than three channels? Arkos 2 supports multiple PSGs, but the players don't. One solution could be playing three-channel music track with SCC and to use a separate PSG player for sound effects.

Page 1/2
| 2