Hacker News new | past | comments | ask | show | jobs | submit login

I wonder if using RLE encoding would not have been but vastly simpler and more compact that the huffman encoding used. Just frequency + duration.



> I wonder if using RLE encoding would not have been but vastly simpler and more compact...

No, mate - it wouldn't. Don't be confused by the "printf"-dump; the Python script processed it into pairs of (frequency,delay). That is, when you see...

    989 Hz @ 15209
    989 Hz @ 15213
    989 Hz @ 15218
    784 Hz @ 15222
    784 Hz @ 15226
...the data actually generated are:

    (989, 15222-15209), 
    (784,  ... -15222),
Simply put: RLE can't do anything on them. The repetition has already been "cleaned out".

I wouldn't have gone to Huffman compression if I had a simpler choice.


The notes were already encoded as frequency and duration. The Huffman coding was required to get that down to an even smaller size.

RLE might have helped for repeated notes - but I guess Huffman coding kinda compensates for that anyway, in the repeated notes will probably end up with shorter bit strings.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: