Crystal clean PCM 8bit samples on the poor PSG

Page 5/10
1 | 2 | 3 | 4 | | 6 | 7 | 8 | 9 | 10

By ARTRAG

Enlighted (6329)

ARTRAG's picture

25-01-2006, 17:45

Since you still have two empty bits ber byte, you could use them to indicate if there is more data needed to complete the sample transition. I don't know if it's worthwhile though, but I suppose you don't always need a triplet to change volume from one sample to another.

More PSG transitions => better sample accuracy

Or even better:
first byte: bit 6-7 is indicates first channel, bit 4-5 indicates second channel. bit 0-3 is volume data for first channel change
next byte: contains volume data for the other channels.

I should have a more aggressive compression : even assumig perfect bit packing you have 4+2=6 bit per PSG level, 3*6=18bit per input sample, 793800bit/sec or 99225
byte/sec for inputs a 44,1KHz.
It is 100kbyte per second!!! No MSX has enough ram for this replayer!!


You could also use the value of bit4-5 to indicate you only need to change the volume of one channel (probably doesn't happen alot though...). If it's value is 11, no more data is needed to complete the sample transition.

IMHO variable number of transitions per sample increases complexity and doesn't help

By dvik

Prophet (2200)

dvik's picture

25-01-2006, 18:49

Yeah, playing a 44.1kHz sample that requires 3 PSG channel updates per sample is impossible on an MSX. A 44.1kHz replayer with one channel update per sample for the above encoding uses almost all available CPU time:

;-------------------------------------
; Plays one sample
; IN   HL - Encoded sample start address
;      DE - Sample length (#pcm samples)
;-------------------------------------
PLAY_SAMPLE:
        ld      b,e
        inc     d
        ld      c,$a1
PsgLoop:
        ; Output one channel
        ld      a,(hl)      ; 8
        rlca                ; 5
        rlca                ; 5
        and     3           ; 8
        add     8           ; 8
        out     ($a0),a     ; 12
        nop                 ; 5
        outi                ; 18
        jr      nz,PsgLoop  ; 8/13  Total: 82 (81 is best fit)  3579545/82 => 43653Hz
        dec     d           ; 5
        jp      nz,PsgLoop  ; 11
        ret

By msd

Paragon (1375)

msd's picture

25-01-2006, 18:57

He my MSX could play 42 seconds on 44.1Khz Tongue

By dvik

Prophet (2200)

dvik's picture

25-01-2006, 19:05

But it would sound very good Smile Almost like an Ipod. Only a bit heavier to carry arround.

By AuroraMSX

Paragon (1901)

AuroraMSX's picture

26-01-2006, 10:05

But it would sound very good Smile Almost like an Ipod. Only a bit heavier to carry arround.
Especially since you need 2 MSXs to be able play stereo Tongue

By NYYRIKKI

Enlighted (5441)

NYYRIKKI's picture

26-01-2006, 10:32


The only unsolved problem is to find the initial state of the PSG
that in any case becomes irrelevant in 6-8 steps!!

Ok, I've been lost few months ago, but maybe you can get something out of this idea: Take few bytes from start of the sample. Make them negative and turn the sample around (first byte is last byte) Now use your algorithm to this new sample and use result as initial state.

Edit: Hmm... works only if sample is starts from 0-level. Not very usefull, eh...

By ARTRAG

Enlighted (6329)

ARTRAG's picture

26-01-2006, 15:49

I have found that my pcmenc implementation in matlab needs 42Mb of
free ram on my PC to optimize an input wav of about 6000 samples....

A wav file of 50 sec @44KHz would require the RAM of a NASA supercomputer!!!
Crying

Maybe before any public release of the encoder, the next setp should be
to move to Truncated Viterbi optimization.
Wink

By ARTRAG

Enlighted (6329)

ARTRAG's picture

03-02-2006, 20:44

To whom is interested in Viterbi optimization

http://www.brianjoseph.com/viterbi/workshop.htm

(you need Java)

By PAC

Guardian (5433)

PAC's picture

24-01-2007, 11:39

First of all sorry if I ask a madness, I can only code in Basic.Crying
It would be possible to use this PSG samples under Basic? Do
you plan make a Basic routine? I would like use PSG samples
with my Basic programs but only little samples for effects non for
run big samples of music. Long time ago I played Samurai
King Megazone of Compile (Megaz Monkey Do on the MSX
Generation). This game uses a lot of PSG samples for effects
and the game atmosphere is better. The game is made in Basic.

By ARTRAG

Enlighted (6329)

ARTRAG's picture

24-01-2007, 12:14

Well, everything can be done, but you need
1) a megarom for storing the samples
2) devolop a small interface for calling the code from basic and selecting the samples

As an option, on a 128Kram msx2, you could use 96K ram but this needs even more
devlopment to adapt the replayer to work with ram

Page 5/10
1 | 2 | 3 | 4 | | 6 | 7 | 8 | 9 | 10