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
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
He my MSX could play 42 seconds on 44.1Khz
But it would sound very good Almost like an Ipod. Only a bit heavier to carry arround.
But it would sound very good Almost like an Ipod. Only a bit heavier to carry arround.
Especially since you need 2 MSXs to be able play stereo
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...
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!!!
Maybe before any public release of the encoder, the next setp should be
to move to Truncated Viterbi optimization.
To whom is interested in Viterbi optimization
http://www.brianjoseph.com/viterbi/workshop.htm
(you need Java)
First of all sorry if I ask a madness, I can only code in Basic.
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.
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