Friday, March 12, 2010

another mobile wifi router

a free one, link
reboot the mobile after installation, then find the program at setting -> connection.

Thursday, March 11, 2010

3dB cutoff frequency

Lp = 10 * log10 (1/2) = -3 dB
Lp = 10 * log10 (2) = +3 dB
The power (energy) drops to half (1/2).
For voltage, it is sqrt(1/2) = 0.707. When the voltage drops to 0.707*peak_voltage, the power drops to half (-3dB), since the power is proportional to the square of voltage.

Let's say lowpass filter, cutoff frequency is the boundary between the passband and stopband.

Monday, March 08, 2010

Priority inversion, priority inheritance, and priority ceiling

Remember polycom?

Priority inversion: a high priority task is indirectly preempted by a medium priority task. (a medium priority task preempts a low priority task, the low priority task is using a shared resource on which the high priority task is pending). The process from wiki is:
  • There are 3 tasks A, B, and C, with priority from high to low. A and C share the resource
  • C successfully locks the resource
  • A attempts to acquire resource, being blocked and wait for C to release resource
  • B became runnable before C release resource
  • Now you don't know when C can release resource, and A is still blocked
  • reversion happens: B is running and A is not
Solution 1: Priority inheritance - make the low priority task inherit the priority of any high task pending on a resource they share. This priority change should take place as soon as the high priority task begins to pend. It should end when resource is released.

Solution 2: Priority ceiling - each resource is assigned a priority ceiling, which equals to the highest priority of an task which may lock the resource. Once a task finishes with the resource, its priority returns to normal.

The link is a good read for this topic.

Difference between mutex and binary semaphore

I have some notes about semaphore at former post (especially at the end of that post).
Now what is the different between mutex and binary semaphore?
  • If mutex is locked by some thread, only that thread can unlock it. The binary semaphore can be unlocked by any other threads. For instance, if thread A locks the mutex and returns before release the lock, then you are in a deadlock and cannot recover it (in C). With semaphore it is a bit different. You can still release the lock even the thread A leaves early.
  • You can use recursive mutex (although you may not want to use it). This feature is not available in semaphore.
  • Priority inversion (see last post) is possible with mutex, but not applicable in binary semaphore ( I think is similar with the 1st listed item).
When using a binary semaphore to serialize the access to resource, you have to initialize it with the value 1, which means the resource is available.

Synchronization

In common use, it means making two things happen at the same time.
It multithreading programming, it refers to relationships among threads: any number of threads, and any kind of relationship (before, after, during). Such like:
Serialization - thread A must happen before thread B.
Mutual exclusion - thread A and B must not happen at the same time.

Tuesday, March 02, 2010

Request user input in MATLAB

Wait for typing from keyboard

var = input('what is the value:\n');
filename = input ('what is the name?', 's');

 

if isempty(filename)

filename = 'default.dat'
end


Tuesday, February 23, 2010

Neural Network Basic

---Input ------- Layer

It includes weight(w), sum, shift(b) and transfer function(f).



Back-Propagation (BP). Usually the output transfer function is Sigmoid function f(x)=1/(1+e^(-x))

Monday, February 22, 2010

Run Multiple Dropbox in Mac

Instruction in following link: http://bit.ly/cae6u5

Tuesday, February 16, 2010

Spectral Centroid in Audio

The center of mass of the spectrum.

x(n) is the magnitude of bin number, f(n) is the center frequency of that bin. The following MATLAB function is from the exchange website;

function C = SpectralCentroid(signal,windowLength, step, fs)
signal = signal / max(abs(signal));
curPos = 1;
L = length(signal);
numOfFrames = floor((L-windowLength)/step) + 1;
H = hamming(windowLength);
m = ((fs/(2*windowLength))*[1:windowLength])';
C = zeros(numOfFrames,1);
for (i=1:numOfFrames)
window = H.*(signal(curPos:curPos+windowLength-1));
FFT = (abs(fft(window,2*windowLength)));
FFT = FFT(1:windowLength);
FFT = FFT / max(FFT);
C(i) = sum(m.*FFT)/sum(FFT);
if (sum(window.^2)<0.010)
C(i) = 0.0;
end
curPos = curPos + step;
end
C = C / (fs/2);

Monday, February 15, 2010

Mel-frequency cepstrum coefficients (mfcc) in audio

The word 'cepstrum' reverses the first 4 letters of 'spectrum', it takes Fourier transform to the decibel of spectrum. The process is:
signal -> FFT -> abs()&square -> log -> FFT -> abs()&square -> spectrum

MFCC is a nonlinear "spectrum-of-a-spectrum". It represents the short-term power spectrum of a sound.

The MFCC procedure is:
audio signal -> FFT -> map to mel scale -> log -> DCT -> MFCC (the amplitudes of the result spectrum)

The matlab code of MFCC is in following links: link0, link1, link2, Auditory Toolbox

Friday, February 12, 2010

Synergy

A good one to replace KVM switch. So I can use the same mouse/keyboard between two Windows and Mac machine. You can ever use text copy/paste. link

The ‘server’ is your main machine with mouse/keyboard, you can use the same mouse/keyboard in ‘client’

The new version Synergy Plus is at: [update:3/10/10]
http://code.google.com/p/synergy-plus/