maxim-zhao / pcmenc

Advanced PCM encoder for 8-bit sound chips
57 stars 4 forks source link

Viterbi algorithm #3

Open artrag opened 2 years ago

artrag commented 2 years ago

I'm the original author of the encoder. The optimisation is an implementation of the Viterbi algorithm able to tracks the state transitions of the output levels of the 3 channels of the PSG. The PSG is modelled as a state machine, all the possible state transitions are evaluated at each time step. All paths among states are stored until the end of the sequence, discarding those paths that reach the same PSG state with a worse overall error. At the ened of the encoding sequence, the best path among those survived till there is choosen.

maxim-zhao commented 2 years ago

Hi, and thanks for your release all those years ago. I understand how the code works, I just had a hard time linking it back to the probabilistic description at https://en.m.wikipedia.org/wiki/Viterbi_algorithm for example.

artrag commented 2 years ago

The cost function in my implementation is the mse, which is equivalent to maximize the conditional probability when the error is gaussian. It is a direct implementation of the Viterbi algorithm as described in many books on digital communications