sunnuntai 24. lokakuuta 2010

Programming: The Ranger class

I felt the need for a c++ class which would enable me to do the following:
- Define a finite range of numbers from 0 to N
- Exclude ranges from this range so that the remaining ranges would be accessible as a list
- Reset the range back to full range

Thus came forth the Ranger class.

Files for the project:
- interface header: http://koti.kapsi.fi/~isoa/files/src/ranger/ksym_ranger.h
- implementation: http://koti.kapsi.fi/~isoa/files/src/ranger/ksym_ranger.cpp
- interactive test program: http://koti.kapsi.fi/~isoa/files/src/ranger/ksym_ranger_test.cpp

License is http://evvk.com/evvktvh.html so feel free to stuff this project up your ass.

You can compile the test program with a standards compliant c++ compiler. An example compilation with GNU compiler is as follows:
- c++ -I path_to_ksym_ranger.h ksym_ranger.cpp ksym_ranger_test.cpp

To get an idea what this piece of shit does, check out this example test run (user input in cursive):

$ a
0 -> 100
20 30

0 -> 19
31 -> 100
40 50

0 -> 19
31 -> 39
51 -> 100
60 70

0 -> 19
31 -> 39
51 -> 59
71 -> 100
15 80

0 -> 14
81 -> 100

perjantai 15. lokakuuta 2010

Real Freedom

http://www.youtube.com/watch?v=I-YMMd1xKIM

Real freedom is
... personal, not political
... lived, not talked about
... shown, not debated
... under your control, not dependent on others
... an inspiration to others, not something you can argue them into wanting

keskiviikko 22. syyskuuta 2010

The argument for religious faith

1. Argue that a spesific religion is true
2. Argue that religion is useful
3. Argue that atheism is intolerant, elitist and corrosive of basic human values

Strawmen can't die. Just push the "I WIN" button.

tiistai 17. elokuuta 2010

Surround sound with FreeBSD 8.x and snd_hda

The snd_hda driver is really a sweet piece of software. It allows FreeBSD to utilize many HDA-compatible sound chips. Most new motherboards have HDA compatible integrated sound.

Although to get more than two channels to play one has to make some minor adjustment to system settings.

Do this as root:
# kldload snd_hda
# sysctl dev.pcm.0.play.vchanformat=s16le:5.1

The above command sets the hda codec's first playback device to use 5.1 speaker setting as output. If you have 7.1 setup, use s16le:7.1 instead. Etc. Use brain.

If you need multiple applications to access sound simultaneously:
# sysctl dev.pcm.0.play.vchans=3

Normally one would connect green, yellow and black connectors to the speaker system as front, center/lfe and rear respectively. However, some hda chip's default configuration use the gray output plug as for rear speakers.

To test your surround setup:
1. Install VLC or MPlayer from ports or packages
2. Download the AC3 version of "Surround sound test" from http://www.lynnemusic.com/surround.html
3. Make your media player use OSS as sound output backend. RTFM if you must.
4. Play the "Surround sound test" file to see wether you get the samples out of the right speakers
5. Adjust plugs accordingly

Okay, some ppl might argue that configuring snd_hda to use correct output pins would be better than just adjusting plugs, but that's just a waste of time. In the long run it is better to cope with the codec's default configuration. Only attempt your codec's reconfiguration if some of the output pins are not associated etc.

I've tried this approach and managed to get VLC play the "Surround sound test" AC3 file with all samples in the correct channels. In my case, I had to relocate the black plug (rear speakers) to grey plug. Live and learn.

If your media player application does not support the official OSS multichannel playback the the app sucks balls. I heartily recommend VLC.

To make your configuration permanent, edit /etc/rc.local and add the above commands there. Works like a charm.

PS. rtfm$ man snd_hda

EDIT: I've tested the following players to support multichannel OSS playback:
- multimedia/vlc
- multimedia/mplayer
* with: -ao oss -channels 6

lauantai 23. tammikuuta 2010

Tein tänään kiinalaista possupataa!

Viljapossunsuikalepaketin etiketissä oli ohje. Kaupassa se teki minuun vaikutuksen koska siinä oli myös erittäin houkutteleva kuva ruoka-annoksesta. Ostin sitten ohjeen mukaiset aineet. Unohdin ostaa desimitan. Joten vieläkin arvioin silmämääräisesti, tosin en läheskään aina pieleen.

Tein jänskän hapanimeläkastikkeen ohjeen mukaan. Oli viljapossunsuikaleet marinoidut kyllä, mutta sopi se oma litku siihen todella hyvin. Semmosta jännää tummaa ihmekonkoottia. Haudutin 50% pidempään kuin ohjeessa. Wokvihannekset kruunasi koko hommelin.

Kiinalaiset on jänskiä. Kiinalaiset ruoat vielä jänskempiä!

Hyvää oli. Vieläkin tuossa annoksia jäljellä. Huomennakin saa syödä hyvää ruokaa.