PSG samples

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

Van Grauw

Ascended (10581)

afbeelding van Grauw

04-06-2005, 13:47

@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

No, that is a very important speed optimization.

djnz Loop
dec d
jp nz,Loop

is much faster than

dec de
ld a,d
or e
jp nz,Loop

dvik: Nice optimisation! I’ll remember that Smile. It’ll make a bit of a mess of the table though ^_^.

~Grauw

Van Grauw

Ascended (10581)

afbeelding van Grauw

04-06-2005, 14:01

Dvik: I’ll update the MAP with that, but not right now because I’m at my parent’s house and I don’t have my project files overhere (and doing everything through FTP and manually adapting the sample table is such a bother).

By aligning the table on a multiple of 256 you can make it even a little faster by replacing that bc stuff with ld h,PSG_SAMPLE_TABLE/256 : ld l,a, but it depends on whether you think that is still worth the effort, it is already pretty fast.

And yeah, because the loop is now optimized you play at higher sample rates. Besides, small and optimized code looks better, and crafty too Smile.

~Grauw

Van NYYRIKKI

Enlighted (5918)

afbeelding van NYYRIKKI

04-06-2005, 16:26


No, that is a very important speed optimization.

djnz Loop
dec d
jp nz,Loop

is much faster than

dec de
ld a,d
or e
jp nz,Loop

You are right about the speed, but that will also make sample bitrate to vary, so it is not a good idea in this case. I think, that limited memory of MSX makes the speed optimization not important.

Van NYYRIKKI

Enlighted (5918)

afbeelding van NYYRIKKI

04-06-2005, 16:32

Dvik: Very nice demo! oO Pixel accurate scroll, sample playback, screen split and animation is very impressive combination on MSX1!

I also got greetings... that was very nice from you. Smile

Van dvik

Prophet (2200)

afbeelding van dvik

04-06-2005, 19:23


You are right about the speed, but that will also make sample bitrate to vary, so it is not a good idea in this case. I think, that limited memory of MSX makes the speed optimization not important.

Then I think the best way is to do as ARTRAG suggested, i.e. do a dec de, ld a, d, or e, jp nz .LOOP thing

Van ARTRAG

Enlighted (6844)

afbeelding van ARTRAG

04-06-2005, 21:04

@dvik
Do you have any measurs of the spikes ?
Are they proportional to the volume changes?

I have developed a program to process the PCM samples in order to extract the succession of the 3 volumes
Each sample I minimize a "metric" that is function of the current sample level and of the volumes I was playing for the previous sample

Sorry for the matlab I try to explay the most uclear passages
The cost for choosing the levels has a term

|x(i)-QQ(:,1)|.^2

that take into account the distortion : QQ(:,1) is the vector of 4096 allowed values

and a term

sum(abs(Q(1+kron(QQ(n,2:4),ones(4096,1)))-Q(1+QQ(:,2:4))).^2,2))

that represents the sum on the three channel of the squared differences between the old levels and the new possible levels (4096)

Actually the matlab expression is ugly and not readable but does what I said.
I assumed that a volume change on channel A gives

|Q(a(n-1))-Q(a(n))|^2

where Q(Smile is the 16 elemets vector with the DAC response and n is the time

Thus on 3 channels I have

|Q(a(n-1))-Q(a(n))|^2 + |Q(b(n-1))-Q(b(n))|^2 + |Q(c(n-1))-Q(c(n))|^2

the expression

sum(abs(Q(1+kron(QQ(n,2:4),ones(4096,1)))-Q(1+QQ(:,2:4))).^2,2))

compute a vector of 4096 elements with all the values for [a,b,c]
QQ(n,2:4) is the past vector of values

The matlab final expression is

min( abs(x(i)-QQ(:,1)).^2 + 0.7*sum(abs(Q(1+kron(QQ(n,2:4),ones(4096,1)))-Q(1+QQ(:,2:4))).^2,2)) ;

I used a parameter to weigth the sum: 0.7 was empirical
The matlab SNR is 25dB
The MSX play is still far noisier than the PC play but goes better than before (as far as I can hear)
In any case the volumes tend to have less changes than before as you can see from the plot (each color is a channel)

Probably, a part from the weigth factor, the shape of the second part of the cost function could be improved,
but to do this I need measurs of the behaviour of the PSG for each jump between two levels.

If you want the asm and the data send me an email

Van dvik

Prophet (2200)

afbeelding van dvik

04-06-2005, 22:16

Please send it to: daniel at vik dot cc
I'm very interested in hearing the difference

Van ARTRAG

Enlighted (6844)

afbeelding van ARTRAG

05-06-2005, 00:35

Done!

Do you have a measure of spikes?

Van ARTRAG

Enlighted (6844)

afbeelding van ARTRAG

06-06-2005, 01:07

About the pre procesing of the samples:
If I get the psg values of the regisers by processing the samples with a cost function that minimize the level transitions in the same channel
the result can be RLE encoded. A play routine can cope easily with RLE and the data are easily converted as (by definition) there are few
transitions.

What do you think about a PC program that does the conversion of 8bit PCM wav files in PSG volumes RLE encoded ?

Van dvik

Prophet (2200)

afbeelding van dvik

06-06-2005, 02:30

If the sample player is good enough to use in games/demos I think it is a great idea to have a PC tool to do the conversion. The PC tool could then take any type of wav file (44.1kHz, 22kHz, 16bit, 8bit,...) and generate a nice RLE encoded file. That would be useful.

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