2010-04-27
Using Trackball on Linux
It works great, it has drivers for windows and OS X, the navigation mode is quite good (in this mode, you can roll the trackball to scroll in the page), though it only support very few applications.
On my Ubuntu system, after some tweak, it actually works better, here is what I did:
xinput set-int-prop "Kensington Kensington Slimblade Trackball" "Evdev Wheel Emulation" 8 1
xinput set-int-prop "Kensington Kensington Slimblade Trackball" "Evdev Wheel Emulation Button" 8 8
xinput set-int-prop "Kensington Kensington Slimblade Trackball" "Evdev Wheel Emulation Axes" 8 6, 7, 4, 5
xinput set-button-map "Kensington Kensington Slimblade Trackball" 1 2 3 4 5 6 7 10 9 8 11 12
xinput set-int-prop "Kensington Kensington Slimblade Trackball" "Evdev Wheel Emulation Button Toggle" 8 1
In current Ubuntu (mine is 9.10), there is no need to change setup in xorg.conf, the system just detected all the buttons of the trackball, the above lines are just for the navigation mode to work.
You need to run these commands after start X server (there is a way to save the settings permanently, though I didn't try it). You can use "xinput list" to find the name of your device.
The first line is telling the xinput system to enable the mouse wheel emulation (similar to the navigation mode)
The second line is to use the upper-right button to trigger the navigation mode.
the third line make it work for both vertical and horizontal scroll.
The forth line remap the buttons a little bit, since firefox will use button 8 as back button, that's not what I want.
The fifth line is a bit tricky, in the default implementation of current mouse wheel emulation, you need to hold the button for triggering the emulation (I think it's from the thinkpad's way of using the trackpoint), though for the trackball, it feels awkward if need to keep the navigation button pressed all the time, so I made a patch on it, then it works like under the OS X(one click to switch to navigation mode, another click back to normal mode, also clicking any other button in navigation mode will switch back to normal mode too).
If you want to try the extra feature, you have to build it manually, the package name is xserver-xorg-input-evdev in ubuntu, or from git://anongit.freedesktop.org/git/xorg/driver/xf86-input-evdev
patch for ubuntu's version (1:2.2.5-1ubuntu6): https://sites.google.com/site/yjpark/downloads (ubuntu-9.10-toggle_button.diff)
patch for latest version: https://sites.google.com/site/yjpark/downloads (xf86-input-evdev-toggle_button.diff)
2009-11-28
XBMC over Jack (Revisited)
This time I decide to use the version in PPA's karmic release instead the svn version (the previous one on svn was not very stable, crash now and then), first add xbmc and nvidia-vdpau repositories (xbmc depends on nvidia-190-libvdpau-dev, though I am still using 185 since the 190 version crash with tv-out, might goes to another post)
sudo add-apt-repository ppa:team-xbmc/ppa
sudo add-apt-repository ppa:nvidia-vdpau/ppa
You still need to add the source part into apt source list, (add-apt-repository can get the key for you, which is convenient, wish it can support an option to add the source part too). Add this line to /etc/apt/sources.list.d/team-xbmc-ppa-karmic.list
deb-src http://ppa.launchpad.net/team-xbmc/ppa/ubuntu karmic main
Then install the needed libraries for building xbmc, and download the source codes.
sudo apt-get build-dep xbmc
apt-get source xbmc
sudo apt-get install libbio2jack0-dev libjack-dev libjack0.100.0-dev libjackasyn-dev
You should have the source codes ready after a while. As a comments in my previews post said, the audio interface was changed a little bit in the new xbmc source, though fortunately it's not a big change, so the previous patch can works just fine after some minor changes. get the patch from this address.
* https://sites.google.com/site/yjpark/downloads (xbmc-9.11~beta1-jack.patch)
patch -p0 < xbmc-9.11~beta1-jack.patch
Then do the normal configure, before make, please add "-ljack" into Makefile, (search the line LIBS=..., add it to the end of the line will be fine), after that make should work.
One important thing to note, to make the audio matching video, you probably should change the delay constant in xbmc/cores/AudioRenderers/JackDirectSound.cpp.
float CJackDirectSound::GetDelay()
{
Update();
return m_timePerPacket * (float)m_packetsSent + 0.4;
}
Just play an correct video file, adjust audio delay to make it sync, then add the value you used into the end of the return line will be ok (ahead means plus)
Note: C++ library for Jack is from Jack_CPP (http://x37v.info/jack_cpp/doc/index.html) (by Alex Norman, with pretty good documetation and examples, thanks again), I included the needed files in the patch, though suggest you to look at the documents on his site for more information.
What's next
Currently this is not working if enabling real time support in jackd, probably will do some research on this part.
Also plan to find a way to deal with the ugly delay part, ideally can calculate the delay, if too hard, probably will retrieve the value from config, then won't need rebuild for it.
And make the library detecting with the proper way, both in code and also in configure process (not a c/cpp programmer, so might need some time), then no manual change needed.
If I can finish all these, then will try to commit the patch to xbmc.
2009-11-18
Install SVN 1.6.5 in Debain Etch
wget http://www.sqlite.org/sqlite-amalgamation-3.6.13.tar.gzYou may also want to upgrade pysvn to pysvn-1.7.1
tar xzf sqlite-amalgamation-3.6.13.tar.gz
wget http://subversion.tigris.org/downloads/subversion-1.6.5.tar.bz2
tar xjf subversion-1.6.5.tar.bz2
sudo apt-get install build-essential
sudo apt-get install libapr1-dev
sudo apt-get install libaprutil1-dev
sudo apt-get install libneon26-dev
cd subversion-1.6.5
mkdir sqlite-amalgamation
cp ../sqlite-3.6.13/sqlite3.c sqlite-amalgamation/
./configure
make
sudo make install
wget http://pysvn.barrys-emacs.org/source_kits/pysvn-1.7.1.tar.gz
tar xzf pysvn-1.7.1.tar.gz
cd pysvn-1.7.1/Source/
python setup.py backport
python setup.py configure
make
sudo cp pysvn/* /usr/lib/python2.4/site-packages/pysvn/
2009-07-31
XBMC over JACK
While now the XBMC is available on most platform: Windows, OS/X (Plex is better IMO, which is based on XBMC, http://www.plexapp.com/), and Linux.
XBMC works fine on ubuntu through ALSA, though I am using JACK (http://jackaudio.org/) for better sound quality, so I have to stop JACK before start XBMC which is quite annoying.
After some research on the web, I decide to implement JACK audio bridge for XBMC, which is quite easy, here is how I did it:
First, get the source code
* http://xbmc.org/development/svn/XBMC already has a flexible structure to support different audio interfaces, under linuxport/XBMC/xbmc/cores/AudioRenderers, there are a bunch of supported interfaces: ALSA, PulseAudio, Windows Direct sound.
Seconds, get the library
JACK comes with C library, it's asynchronus and need some time to learn it, did some research, found out there is a good C++ library at http://x37v.info/jack_cpp/doc/index.html (by Alex Norman, with pretty good documetation and examples, thanks a lot)Now, link them together
To make it simple, I just put all the files from jackcpp under AudioRenderers, then write a simple wrapper to let them talk with each other.There is a NullDirectSound.cpp there, which is a very good example to learn how to write a new interface.
In AudioRendererFactory.cpp, a quick hacky way to use the JACK interface:
--- AudioRendererFactory.cpp (revision 19572)
+++ AudioRendererFactory.cpp (working copy)
@@ -22,6 +22,7 @@
#include "stdafx.h"
#include "AudioRendererFactory.h"
#include "NullDirectSound.h"
+#include "JackDirectSound.h"
#ifdef HAS_PULSEAUDIO
#include "PulseAudioDirectSound.h"
@@ -59,10 +60,14 @@
{
IAudioRenderer* audioSink = NULL;
+//For Jack
+ audioSink = new CJackDirectSound();
+ ReturnOnValidInitialize();
+
Then create JackDirectSound.cpp and JackDirectSound.h (I just copied from NullDirectSound.cpp and NullDirectSound.h)
if you see the diff from JackDirectSound.cpp and NullDirectSound.cpp, you will find out most of them are same except for the change of name, the only logic I added are these lines (full version below):
In Initialize():
I am using blocking interface here, since it's very simple to use.
jackBuffer = new JackCpp::BlockingAudioIO("XBMC.Jack", iChannels, iChannels);
jackBuffer->start();
for(int i = 0; i <>connectToPhysical(i,i);
}
m_uiChannels = iChannels;
In Deinitialize():
if (jackBuffer) {
for(int i = 0; i <>disconnectOutPort(i);
}
jackBuffer->close();
//TODO: Cannot delete jackBuffer, otherwise will crash.
//delete jackBuffer;
}
jackBuffer = 0;
And in AddPackets():
CLog::Log(LOGERROR,"Jack.AddPackets() len=%d, add=%d", len, add);
if (jackBuffer){
short* pSamples = (short*)data;
for (int i=0; i< j =" 0;">write(j, (float) pSamples[i*m_uiChannels + j] / 32768.0);
}
}
}
The logic to convert the data chunks here cause me some trouble, had to do some search and experiments before get the sound right, but before that some result sound were quite interesting.
The last thing in GetDelay():
return m_timePerPacket * (float)m_packetsSent + 0.325 + 0.075;
To be honest, I don't know how to calculate the correct delay value here, this value here was the delay I found out on my machine, just try to play some movie, then try to match the audio to the video, then it's done. (I know, it's very hacky and not the right way, but since the constant value seems to solve my problem perfectly, don't feel pressure to dig into it anymore :) )
Put everything together and make it
Now every thing is ready, you can set it up and make it.I suppose you have enough knowledge about how to compile XBMC on your system, this page http://xbmc.org/wiki/?title=Installing_XBMC_for_Linux has all the information you need.
Modify linuxport/XBMC/xbmc/cores/AudioRenderers/Makefile.in to include the new files (both jack_cpp and my codes)
--- Makefile.in (revision 19572)
+++ Makefile.in (working copy)
@@ -4,11 +4,17 @@
ifeq ($(findstring osx,$(ARCH)), osx)
SRCS = \
+ jackaudioio.cpp \
+ jackblockingaudioio.cpp \
+ JackDirectSound.cpp \
NullDirectSound.cpp \
AudioRendererFactory.cpp \
PortaudioDirectSound.cpp
else
SRCS = \
+ jackaudioio.cpp \
+ jackblockingaudioio.cpp \
+ JackDirectSound.cpp \
NullDirectSound.cpp \
AudioRendererFactory.cpp \
ALSADirectSound.cpp \
And also add jack lib into XBMC/Makefile, search for "-lasound" add "-ljack" the the same line. (Again, this is my hacky and improper way)
Now you are ready to compile it and enjoy the two fantastic software working together!
Download the Patch:
xbmc-jack.tgz
2008-02-19
Better Audio Under Linux with TerraTec DMX6Fire (ICE1712 based)
Some background
The sound quality is ... POOL
How to make it better
How to get digital and make the sound quality even better
Using envy24control to direct digital output from s/pdif out (on Patchbay/Router tab), can use iec958 as alsa output, but you need to make sure the internal clock is same with the sound you're playing, otherwise it will be too fast or too slow. you can use envy24control's Hardware Settings to change it.
Note: Be careful about the combinations with Professional/Consumer and different clock rate, I found out that Professional+44100 and Consumer+48000 works best, other combinations will cause problems. (Noise on coaxial, or wrong clock display on my amplifier). My amplifier doesn't support higher clock rate, so I don't know how that works.
There is a good post about ALSA's sample rate converter in dmix, and how to improve it, I followed it, feels that the sound is a bit better, but not very sure about the actual effect
* http://www.hydrogenaudio.org/forums/index.php?showtopic=47591
Then I decide to give JACK a try, according to it's website at http://jackaudio.org/
JACK is a low-latency audio server, written for POSIX conformant operating systems such as GNU/Linux and Apple's OS X. It can connect a number of different applications to an audio device, as well as allowing them to share audio between themselves. Its clients can run in their own processes (ie. as normal applications), or can they can run within the JACK server (ie. as a "plugin").
JACK was designed from the ground up for professional audio work, and its design focuses on two key areas: synchronous execution of all clients, and low latency operation.
Sounds pretty good to me, and I found some guy saying that it's sound quality is pretty good on the web, after several hours of using it, I will say, it's a very cool and very good stuff, I will stick using it for a quite long time I think. The sound quality over JACK is noticeable better, make me very satisfied, and seems with JACK, can do low latency audio/midi/synth stuffs under Linux too (you can install some good musical software with package ubuntustudio-audio and ubuntustudio-audio-plugins), I haven't tried them yet, but some of them seems pretty nice.
I will leave the JACK related stuffs in another post, includes some experiments about JACK, how to use ALSA over JACK.
2006-09-07
Setup ssh to use public key authentication (without input password)
First you need to generate a public/private key pair to identify yourself, use 'ssh-keygen -t rsa'
Then you need to add the generated public key to the remote host, here is how I do it
At Local Machine
At Remote Machine:scp id_rsa.pub yjpark@exobox:
ssh-add
That's Allmkdir .ssh
chmod 600 .ssh
cd .ssh
cat ../id_rsa.pub >> authorized_keys
chmod 600 authorized_keys
make sure that .ssh and authorized_keys is not accessed by anyone except the owner, otherwise it will not work
How to setup window's background color under Gnome
I really don't like white background, I want the background gray, so I setup some applications's background manually, but some application do not have background color setting(e.g. some versions of Eclipse), and it's not a good way to do that, so I spent little time on it.
First I tried some themes, some of them has gray background, while I don't like there colors setting, so what I need to do is to modify some themes to fit my requirement.
In gnome's theme setting -> Theme Details, you can choose different setting of Controls, window Border or Icons, window's background belongs to Controls, I picked up !LighthouseBlue as a base setting.
The themes file are under /usr/share/themes, I only modified gtk-2.0/gtkrc
bg[NORMAL] = "#D0D0D0" //background color of window
base[NORMAL] = "#CCCCC0" //background color or controls
That make me quite happy. I didn't find good tool for editing theme, there is a definition of the values: http://developer.gnome.org/doc/API/gtk/gtk-resource-files.html