Low latency sound recording - Linux RT Kernel

Here is a nice intro on how to set-up near real time components in the Linux kernel. In this specific demonstration the author demonstrates how to get less then 3ms latency on audio recording - something Operating Systems for home users can not generally do.

Also make sure to read the comments from Dave Phillips at the bottom of the page...


Python tip: base conversions

Sometimes you may require to convert between base systems, for example from Octal to BASE10, as may be required when you use the os.mkdir or os.makedirs functions.

Here is a simple script demonstrating a possible implementation:


BASE2 = "01"
BASE8 = "01234567"
BASE10 = "0123456789"
BASE16 = "0123456789ABCDEF"
BASE62 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"

def baseconvert(number,fromdigits,todigits):

""" converts a "number" between two bases of arbitrary digits

The input number is assumed to be a string of digits from the
fromdigits string (which is in order of smallest to largest
digit). The return value is a string of elements from todigits
(ordered in the same way). The input and output bases are
determined from the lengths of the digit strings. Negative
signs are passed through.

decimal to binary

binary to decimal

integer interpreted as binary and converted to decimal (!)

base10 to base4

base4 to base5 (with alphabetic digits)

base5, alpha digits back to base 10

decimal to a base that uses A-Z0-9a-z for its digits

..convert back

binary to a base with words for digits (the function cannot convert this back)


if str(number)[0]=='-':
number = str(number)[1:]


# make an integer out of the number

for digit in str(number):

x = x*len(fromdigits) + fromdigits.index(digit)

# create the result in base 'len(todigits)'
while x > 0:
digit = x % len(todigits)

res = todigits[digit] + res
x /= len(todigits)

if neg:
res = "-"+res

return res

print "'700' octal (base8) is '" + str( baseconvert( 700, BASE8 ,BASE10 ) ) + "' in base10"

If you now want to make a directory with a create mode of 700 (octal) you will call
os.makedirs( "/tmp/test/path", baseconvert( 700, BASE8 ,BASE10 ) )
Until next time then... Need to get back to some coding :-)



Fix for mod_bw when getting an error "undefined symbol: apr_atomic_cas"

I downloaded the Apache module mod_bw to see if I could simulate some "slow" connections. To compile the package you need to run the following command as root:
# apxs -i -a -c mod_bw.c

That will install the module correctly, but when you add the configuration option to your vhost configs you might get an error "undefined symbol: apr_atomic_cas". When that happens, open the file mod_bw.c and change the following:

/* Compatibility for ARP < 1 */
#define apr_atomic_inc32 apr_atomic_inc
#define apr_atomic_dec32 apr_atomic_dec
#define apr_atomic_add32 apr_atomic_add
#define apr_atomic_cas32 apr_atomic_cas
#define apr_atomic_set32 apr_atomic_set


/* Compatibility for ARP < 1 */
#define apr_atomic_inc32 apr_atomic_inc
#define apr_atomic_dec32 apr_atomic_dec
#define apr_atomic_add32 apr_atomic_add
#define apr_atomic_cas32 apr_atomic_cas
#define apr_atomic_set32 apr_atomic_set



Why you can't trust Wikipedia...

It's amazing how wrong data can be on the WWW, yet most people belief everything they read :-) Wikipedia is often criticized for it's inaccurate information, yet it is used in many academic references.

Take this entry on the DNA Computer on Wikipedia as an example: the author claims that the "field was initially developed by Leonard Adleman of the University of Southern California, in 1994."

But, if you wonder of to the National Geographic web site, you will discover an article dated 23 Feb 2003: "Israeli scientists have devised a computer that can perform 330 trillion operations per second, more than 100,000 times the speed of the fastest PC. The secret: It runs on DNA."

I think that proofs the theory that you should NOT trust anything on Wikipedia. Do much more research on your subject then just Wikipedia!



Oracle install HOWTO

I finally completed the detailed Oracle install HOWTO as described in an earlier post.



Oracle 11g Enterprise on Ubuntu

Took me the whole of 1 day and lot's of reading :-)

I first tried to play with Oracle in VMWare, but it was DOG SLOW !!! To give you an idea, my Laptop is a dual core 2.4GHz with 4GB RAM, and it becomes virtually unusable after running in a CentOS VMWare session, where the session was allocated 1.5GB RAM and some RAW disk.

The thing is I don't want to mess anything up, so if I can't use a Virtual Machine, I guessed I could do it using something like debootstrap.

I ended up combining these two resources for the final solution:

  1. https://wiki.ubuntu.com/DebootstrapChroot - To get my chroot environment up and running
  2. http://www.pythian.com/blogs/968/installing-oracle-11g-on-ubuntu-804-lts-hardy-heron - To install Oracle 11g on my new Ubuntu Hardy chroot environment
Well - it works! There was some quirks obviously, but I have detailed notes which I will publish as soon as I recover :-)

In terms of system usage, it's still heavy but at least my Laptop is still very responsive. I found that one CPU Core is always at 100% usage, with 45% of time in IO WAIT state - so not ideal really, but ok for a experiment/learning environment. BTW: I use the Dell XPS m1530...

This page is powered by Blogger. Isn't yours?