PSG samples

Pagina 10/15
3 | 4 | 5 | 6 | 7 | 8 | 9 | | 11 | 12 | 13 | 14 | 15

Van NYYRIKKI

Enlighted (5918)

afbeelding van NYYRIKKI

04-06-2005, 00:13

	out (#A0),a		;play as fast as possible
	out (c),b
	inc a


I still would really swap 2nd and 3rd line...

Van Grauw

Ascended (10581)

afbeelding van Grauw

04-06-2005, 00:27

Good idea! Done.

What do you think of my ld h,b optimisation? I’m very proud of it ^_^.

Van dvik

Prophet (2200)

afbeelding van dvik

04-06-2005, 00:46

If you want to speed it up a tiny little bit more you can create the PSG_SAMPLE_TABLE so that the first 256 values are for channel 1, the next 256 for channel 2 and the last for channel 3. Then you get something like (I havent tested it in this form yet):

;-------------------------------------
PLAYSAMPLE:
; IN   HL - Sample Start address
;      DE - Sample length
;-------------------------------------
        dec de
        ld b,e
        inc b
        inc d
        exx
        ld      b,0
        exx
.LOOP:
        ld      a,[hl]
        inc     hl
        exx
        ld      c,a
        ld      hl,PSG_SAMPLE_TABLE
        add     hl,bc
        ld      b,[hl]
        inc     h
        ld      d,[hl]
        inc     h
        ld      e,[hl]
        ld      c,$a1
        ld      a,8
        out     [$a0],a
        inc     a
        out     (c),b
        out     [$a0],a
        out     (c),d
        inc     a
        out     [$a0],a
        out     (c),e
        
        ld b,8
.WAIT:  
        djnz .WAIT

        exx
        dec     d
        jp      nz,.LOOP
        ret

The way the PLAYSAMPLE method is used here (playing a full sample with a delay in betweeen each sample) it doesn't matter I guess but the part inside the .LOOP will be a bit faster. It may give some extra if the .WAIT part is taken out....

Van ARTRAG

Enlighted (6844)

afbeelding van ARTRAG

04-06-2005, 01:15

@dvik
Actually I think that

dec d
jp nz,.LOOP

in you code bust become

DEC DE
LD A,D
OR E
JP NZ,LOOP

Moreover you do not need the
dec de
ld b,e
inc b
inc d
at the begining

Van ARTRAG

Enlighted (6844)

afbeelding van ARTRAG

04-06-2005, 01:20

@dvik
this is the best table you can get :-) as it is customized on you PSG
Sorry if columns are in the old order but my i need to change my sw
(for the moment try those)

TABLE_dvik:
db 0, 0, 0; 0
db 0, 0, 1; 0.0061
db 0, 0, 3; 0.0117
db 0, 2, 2; 0.0156
db 1, 1, 2; 0.02
db 1, 2, 3; 0.0256
db 0, 1, 5; 0.03
db 3, 3, 3; 0.0351
db 0, 4, 5; 0.0398
db 1, 1, 6; 0.045
db 1, 3, 6; 0.0506
db 1, 6, 4; 0.0548
db 1, 1, 7; 0.0599
db 4, 4, 6; 0.0646
db 1, 7, 4; 0.0697
db 3, 4, 7; 0.0753
db 0, 6, 7; 0.0805
db 0, 2, 8; 0.0836
db 1, 2, 8; 0.0897
db 2, 3, 8; 0.0953
db 0, 5, 8; 0.0997
db 5, 6, 7; 0.1044
db 0, 0, 9; 0.1108
db 1, 6, 8; 0.1147
db 3, 6, 8; 0.1203
db 1, 2, 9; 0.1247
db 2, 3, 9; 0.1303
db 3, 7, 8; 0.1352
db 4, 7, 8; 0.1394
db 5, 9, 3; 0.1464
db 1, 6, 9; 0.1497
db 3, 6, 9; 0.1553
db 4, 9, 6; 0.1595
db 0, 0, 10; 0.1653
db 7, 9, 3; 0.1702
db 5, 8, 8; 0.1755
db 2, 2, 10; 0.1809
db 2, 3, 10; 0.1848
db 0, 5, 10; 0.1892
db 1, 5, 10; 0.1953
db 3, 5, 10; 0.2009
db 4, 5, 10; 0.2051
db 3, 6, 10; 0.2098
db 4, 6, 10; 0.214
db 2, 7, 10; 0.2208
db 3, 7, 10; 0.2247
db 2, 9, 9; 0.2294
db 7, 8, 9; 0.2343
db 0, 8, 10; 0.2411
db 5, 9, 9; 0.2455
db 2, 8, 10; 0.2489
db 6, 9, 9; 0.2544
db 1, 11, 2; 0.2604
db 5, 8, 10; 0.265
db 2, 4, 11; 0.2702
db 0, 9, 10; 0.2761
db 0, 6, 11; 0.2793
db 1, 6, 11; 0.2854
db 3, 6, 11; 0.291
db 4, 6, 11; 0.2952
db 1, 7, 11; 0.3003
db 3, 11, 7; 0.3059
db 4, 11, 7; 0.3101
db 8, 8, 10; 0.3169
db 0, 8, 11; 0.3223
db 7, 9, 10; 0.3238
db 2, 8, 11; 0.3301
db 3, 8, 11; 0.334
db 7, 7, 11; 0.3419
db 0, 2, 12; 0.3446
db 1, 12, 2; 0.3507
db 8, 11, 6; 0.3551
db 3, 3, 12; 0.3602
db 2, 9, 11; 0.3651
db 7, 8, 11; 0.37
db 1, 6, 12; 0.3757
db 5, 9, 11; 0.3812
db 4, 6, 12; 0.3855
db 6, 9, 11; 0.3901
db 7, 12, 3; 0.3962
db 4, 7, 12; 0.4004
db 7, 11, 9; 0.405
db 0, 10, 11; 0.4118
db 7, 12, 6; 0.4173
db 8, 12, 2; 0.4204
db 3, 8, 12; 0.4243
db 4, 8, 12; 0.4285
db 5, 10, 11; 0.4357
db 9, 10, 10; 0.4414
db 8, 12, 6; 0.4454
db 0, 9, 12; 0.4476
db 2, 9, 12; 0.4554
db 7, 12, 8; 0.4603
db 4, 9, 12; 0.4635
db 5, 9, 12; 0.4715
db 5, 9, 12; 0.4715
db 6, 9, 12; 0.4804
db 8, 10, 11; 0.4876
db 8, 8, 12; 0.4884
db 7, 9, 12; 0.4953
db 2, 11, 11; 0.5008
db 11, 11, 3; 0.5047
db 2, 10, 12; 0.5099
db 3, 10, 12; 0.5138
db 0, 2, 13; 0.52
db 6, 11, 11; 0.5258
db 1, 3, 13; 0.53
db 3, 3, 13; 0.5356
db 7, 11, 11; 0.5407
db 0, 6, 13; 0.545
db 7, 10, 12; 0.5498
db 3, 6, 13; 0.5567
db 5, 13, 5; 0.56
db 1, 7, 13; 0.566
db 3, 7, 13; 0.5716
db 4, 7, 13; 0.5758
db 8, 10, 12; 0.5779
db 5, 7, 13; 0.5838
db 2, 11, 12; 0.5911
db 3, 11, 12; 0.595
db 3, 8, 13; 0.5997
db 4, 8, 13; 0.6039
db 5, 8, 13; 0.6119
db 11, 12, 6; 0.6161
db 6, 13, 8; 0.6208
db 0, 9, 13; 0.623
db 2, 9, 13; 0.6308
db 7, 8, 13; 0.6357
db 4, 9, 13; 0.6389
db 5, 9, 13; 0.6469
db 5, 9, 13; 0.6469
db 6, 9, 13; 0.6558
db 8, 11, 12; 0.6591
db 8, 8, 13; 0.6638
db 7, 9, 13; 0.6707
db 0, 12, 12; 0.6736
db 1, 12, 12; 0.6797
db 2, 10, 13; 0.6853
db 4, 12, 12; 0.6895
db 9, 11, 12; 0.6941
db 5, 10, 13; 0.7014
db 6, 12, 12; 0.7064
db 6, 10, 13; 0.7103
db 0, 0, 14; 0.7162
db 7, 12, 12; 0.7213
db 7, 10, 13; 0.7252
db 1, 2, 14; 0.7301
db 2, 3, 14; 0.7357
db 0, 5, 14; 0.7401
db 1, 5, 14; 0.7462
db 8, 12, 12; 0.7494
db 1, 6, 14; 0.7551
db 3, 6, 14; 0.7607
db 4, 14, 6; 0.7649
db 3, 11, 13; 0.7704
db 3, 7, 14; 0.7756
db 4, 7, 14; 0.7798
db 9, 12, 12; 0.7844
db 6, 13, 11; 0.7915
db 7, 14, 6; 0.7967
db 2, 8, 14; 0.7998
db 11, 13, 7; 0.8064
db 7, 14, 7; 0.8116
db 5, 8, 14; 0.8159
db 8, 14, 6; 0.8248
db 6, 8, 14; 0.8248
db 11, 11, 12; 0.8298
db 2, 9, 14; 0.8348
db 7, 8, 14; 0.8397
db 4, 9, 14; 0.8429
db 5, 9, 14; 0.8509
db 1, 12, 13; 0.8551
db 3, 12, 13; 0.8607
db 4, 12, 13; 0.8649
db 9, 11, 13; 0.8695
db 7, 9, 14; 0.8747
db 0, 10, 14; 0.8815
db 1, 10, 14; 0.8876
db 2, 10, 14; 0.8893
db 7, 12, 13; 0.8967
db 8, 9, 14; 0.9028
db 5, 10, 14; 0.9054
db 6, 10, 14; 0.9143
db 6, 10, 14; 0.9143
db 11, 12, 12; 0.9201
db 8, 12, 13; 0.9248
db 7, 10, 14; 0.9292
db 9, 9, 14; 0.9378
db 9, 9, 14; 0.9378
db 9, 9, 14; 0.9378
db 8, 10, 14; 0.9573
db 8, 10, 14; 0.9573
db 9, 12, 13; 0.9598
db 0, 11, 14; 0.9627
db 2, 14, 11; 0.9705
db 3, 14, 11; 0.9744
db 4, 11, 14; 0.9786
db 5, 11, 14; 0.9866
db 9, 10, 14; 0.9923
db 6, 11, 14; 0.9955
db 0, 0, 15; 1
db 11, 11, 13; 1.0052
db 7, 11, 14; 1.0104
db 2, 2, 15; 1.0156
db 2, 3, 15; 1.0195
db 0, 13, 13; 1.0244
db 1, 13, 13; 1.0305
db 3, 5, 15; 1.0356
db 2, 6, 15; 1.0406
db 10, 10, 14; 1.0468
db 4, 6, 15; 1.0487
db 2, 15, 7; 1.0555
db 2, 12, 14; 1.0608
db 6, 6, 15; 1.0656
db 5, 7, 15; 1.0716
db 0, 8, 15; 1.0758
db 6, 7, 15; 1.0805
db 12, 14, 6; 1.0858
db 4, 8, 15; 1.0917
db 11, 12, 13; 1.0955
db 7, 12, 14; 1.1007
db 6, 8, 15; 1.1086
db 0, 9, 15; 1.1108
db 1, 9, 15; 1.1169
db 3, 9, 15; 1.1225
db 4, 9, 15; 1.1267
db 8, 12, 14; 1.1288
db 9, 13, 13; 1.1352
db 6, 9, 15; 1.1436
db 6, 9, 15; 1.1436
db 8, 8, 15; 1.1516
db 7, 9, 15; 1.1585
db 7, 9, 15; 1.1585
db 0, 10, 15; 1.1653
db 1, 10, 15; 1.1714
db 3, 10, 15; 1.177
db 4, 10, 15; 1.1812
db 12, 12, 13; 1.1858
db 10, 13, 13; 1.1897
db 6, 10, 15; 1.1981
db 6, 10, 15; 1.1981
db 11, 11, 14; 1.2092
db 11, 11, 14; 1.2092
db 12, 14, 10; 1.2183
db 9, 9, 15; 1.2216
db 0, 13, 14; 1.2284
db 0, 13, 14; 1.2284
db 2, 13, 14; 1.2362
db 8, 10, 15; 1.2411
db 0, 11, 15; 1.2465
db 5, 13, 14; 1.2523
db 2, 11, 15; 1.2543
db 6, 13, 14; 1.2612
db 4, 11, 15; 1.2624
db 11, 13, 13; 1.2709
db 7, 13, 14; 1.2761

Van ARTRAG

Enlighted (6844)

afbeelding van ARTRAG

04-06-2005, 01:24

@WYZ
Could you send me back at my email @fastweb the sample sequence I have sent to you?

Van dvik

Prophet (2200)

afbeelding van dvik

04-06-2005, 01:30

ATRAG, The changes you've made to the code makes sense. I'll try it tonight. I took the core part of the code from the demo I'm working on but it has a method to play only one sample and then return so the loops may not be correct.

I'll try your new table on my F1-A1WSX when I get home.

Btw, Can anyone run the little Basic test I did on a real MSX, sample it and check what the amplitude of the different PSG channels are. I'm pretty sure you'll get different results.

Van dvik

Prophet (2200)

afbeelding van dvik

04-06-2005, 01:35


@dvik
Actually I think that

dec d
jp nz,.LOOP

in you code bust become

DEC DE
LD A,D
OR E
JP NZ,LOOP

Moreover you do not need the
dec de
ld b,e
inc b
inc d
at the begining

I accidently removed a very important line close to the end. As in Grauws code, it should be a
' djnz .LOOP 'in between the exx and the dec d statement.

The idea is to load b with the value of e at the beginning (which will be used in this djnz) and when it wraps around it will become 0xff and the code will run the loop again as long as d is greater than zero. The increments and decrements in the beginning is to adjust for the behavior of the djnz instruction.

Van dvik

Prophet (2200)

afbeelding van dvik

04-06-2005, 07:33

Ok, here is a beta of the demo I'm working on: www.bluemsx.com/demos/waves-beta-01.zip

It is a MSX1 demo curreny running best in a 60Hz MSX1 but any MSX1,2,2+,TR works fine. I haven't done 50hz synched graphics yet.

To run the demo do one of the following:

1. blueMSX: Load the rom and manually select ASCII16 rom mapper (the auto detection seems to be broken in the emulator)

2. openMSX: Load the rom and run it

3. Real MSX: ESE-RAM is what I use and it works fine. If anyone have other ways of running it I'd be happy to hear. If someone knows how to make it runnable in Mega-RAM I'd be happy to support that too but I need some help or example code then.

I've tried the demo in other emulators but only the two above are able to run it.

The main purpose of showing it here is of coures to show the sample player but if you have any comments or ideas on the rest of the demo I'd be happy to hear about it as well.

The demo really runs best on a real MSX. openMSX and blueMSX does a decent job emulating it but the sound is a bit more noisy and some parts of the video flickers a bit.

Anyways, let me know what you think :)

Van dvik

Prophet (2200)

afbeelding van dvik

04-06-2005, 10:31

I fixed the 50/60Hz issue in the demo. You can get an update at www.bluemsx.com/demos/waves-beta-02.zip

Pagina 10/15
3 | 4 | 5 | 6 | 7 | 8 | 9 | | 11 | 12 | 13 | 14 | 15