[Flac-dev] pcspkr wave encoding
Josh Coalson
xflac at yahoo.com
Wed Aug 15 15:21:52 PDT 2007
--- Jan Engelhardt <jengelh at computergmbh.de> wrote:
> Hi,
>
>
> there is an interesting case when the FLAC encoder (using 1.2.0) is
> given simple waves. Simple waves means: I have a list of {frequency,
> duration, pause} tuples that define the monophonic tune. In other
> words, exactly one frequency is played at a time.
>
> This is the original dataset from 1989 (driving a PC speaker back
> then):
>
> $ ls -l ihold.sd
> -rw-r--r-- 1 jengelh users 20616 Aug 14 00:57 ihold.sd
>
> Since driving the PC speaker is mostly a privileged operation these
> days, one would just convert it to PCM and use soundcard output. The
> program "sd" I have written does just that. The two numerical
> parameters a and b denote the square and sine rate.
>
> # 0:1 rate <=> 0% square, 100% sine generation
> $ ./sd ihold.sd 0 1 | sox -r48000 -s -w -t raw - ihold-sine.wav
>
> # 1:2 rate <=> 33% square, 66% sine generation
> $ ./sd ihold.sd 1 2 | sox -r48000 -s -w -t raw -
> ihold-square1-sine2.wav
>
> # 1:0 rate <=> 100% square, 0% sine generation
> $ ./sd ihold.sd 1 0 | sox -r48000 -s -w -t raw - ihold-square.wav
>
> Now this is what happens when encoding to FLAC:
>
> $ flac -8 ihold-sine.wav
> ihold-sine.wav: wrote 2422225 bytes, ratio=0.353
>
> $ flac -8 ihold-sine2-square1.wav
> ihold-sine2-square1.wav: wrote 5474921 bytes, ratio=0.798
>
> $ flac -8 ihold-square.wav
> ihold-square.wav: wrote 5573016 bytes, ratio=0.813
>
> As soon as square waves are mixed in, the FLAC compression ratio
> drops rapidly up to the point where it equals the ratio of typical
> day-to-day music.
>
> While I do not request FLAC to compress the wave back to its original
> 20KB, I think it could improve on the sine and square compression.
> Are there any plans to address this?
hard to say what is happening without seeing the files. FLAC does
have a run-length encoding mode so with pure square waves it is
possible to get very high compression with a custom encoder.
Josh
____________________________________________________________________________________
Got a little couch potato?
Check out fun summer activities for kids.
http://search.yahoo.com/search?fr=oni_on_mail&p=summer+activities+for+kids&cs=bz
More information about the Flac-dev
mailing list