Thursday 26 July 2012

Bluetooth headphones in linux

I obtained a relatively cheap pair of 'laser' bluetooth headphones today. It's lightweight, colorful, has a built in mic for calls and claims to have up to 10 hours of play time. But best of all it accomplishes all this without wires.

Getting this to work with android 2.3 was easy enough. During pairing just hold the power switch for 6 seconds. You hear a cute little tone and off you go.

To get this to work in slackware 13.37 required a little bit more work, but not much.

The steps to make it work were:

1) charge up the headphones until the light turns blue

2) in linux, start bluetoothd:
#/usr/sbin/bluetoothd

3) run blueman-manager
$ blueman-manager

4) make sure the device is on then hit search, if everything is configured okay then the headset device should appear

5) start the pairing process and hold the power switch for 6 seconds

6) after it has successfully paired it may still not be connected, so hit the trust button to trust the device

7) then run the 'Setup' on the device and choose A2DP Sink (Send Audio)

8) right click on the device and the option for 'audio sink' should appear. click on that to enable sending audio to the device. now leave blueman-manager open for the next step...

9) now, as root, edit /etc/asound.conf by adding the lines below. Make sure to substitute the XX:XX.. numbers with the address of the device which is visible in the blueman-manager window.

you may also replace pcm.btheadset with pcm.!default if you wish to make it the default device. alsa will need to be restarted with # /etc/rc.d/rc.alsa restart or similar

# /etc/asound.conf

pcm.btheadset {
   type plug
   slave {
       pcm {
           type bluetooth
           device XX:XX:XX:XX:XX:XX 
           profile "auto"
       }   
   }   
   hint {
       show on
       description "BT Headset"
   }   
}
ctl.btheadset {
  type bluetooth
} 


 
10) Save the file then type $ aplay -L to check the btheadset device is recognized

11) run mplayer or player of your choice with the device set to btheadset..

$ mplayer -ao alsa:device=btheadset ~/miku-hatsune-i-wanna-be-your-world.mp3


You might be wondering how do they sound? To be honest they sound a lot better than what I was expecting.


References:
https://wiki.archlinux.org/index.php/Bluetooth_Headset#Headset_and_Alsa_Devices

Friday 22 June 2012

Using ffmpeg to convert to Audio CD tracks

Sometimes you may want to convert a video or audio file to CD Audio format.

You can do this with the swiss army knife of media converters, ffmpeg!

First thing, we must remember the cd audio format:

PCM signed 16-bit little endian stereo

So you simply use the following format for converting with ffmpeg

$ ffmpeg -i input.xxx -acodec pcm_s16le -ac 2 -f wav output.wav

And bob's your aunt :)



-------------------------------------------
http://ffmpeg.org
http://www.gentoo-wiki.info/HOWTO_Create_an_Audio_CD#FFmpeg_.28many_common_formats.29

Thursday 21 June 2012

Amazon S3 + Cloudfront notes

Basic Amazon S3 storage estimates without content delivery network. (all rates are per month)


Moderate usage: 

Storage: 100GB
Reduced Redundancy: 0GB
Data Transfer In: 50GB
Data Transfer Out: 900GB
PUT/COPY/POST/LIST Requests: 100K
GET + others: 1 million

Total:
Asia Pacific (Singapore): $182.39/mo
US-East: $119.46/mo

Conservative: 

Storage: 10GB
Reduced Redundancy: 0GB
Data Transfer In: 5GB
Data Transfer Out: 500GB
PUT/COPY/POST/LIST Requests: 100K
GET + others: 100K

Total:
Asia Pacific (Singapore): $95.14
US-East: $59.31/mo


Very Conservative:  (Initial and testing)

Storage: 5GB
Reduced Redundancy: 0GB
Data Transfer In: 2.5GB
Data Transfer Out: 100GB
PUT/COPY/POST/LIST Requests: 100K
GET + others: 100K

Total:
Asia Pacific:  $17.61/mo
US-East: $10.68/mo




*Also "PUT/COPY/POST" rates apply if an Amazon CDN is used


References:

Amazon's calculator
http://calculator.s3.amazonaws.com/calc5.html?key=a-simple-3-tier-web-app

Optimization tips:
http://www.admon.org/5-tips-on-amazon-s3-hosting-optimization/
http://www.lalit.org/lab/setting-cache-headers-files-in-amazon-s3/

Kevin McKillop's tutorial on setting up S3 and cloudfront:
http://www.freedomtarget.com/how-to-use-amazon-s3-cloudfront-for-video

Sunday 17 June 2012

SBAGen Brainwave Generator

 

I have been using this little program on and off for a while. I have found it
sometimes useful when I really need to focus. It is also opensource and runs
on every system imaginable today.

The idea is that the more a person listens to certain frequencies, the more
their mind will be attuned to  that frequency. The brain normally functions in
one of 4 frequency bands (Delta: deep sleep, Theta: dream-states and
intuition, Alpha: alert and inner focus, and Beta: alert and externally
focussed).

The program comes with a variety of preset sounds to make it easier to get
started.

Compiling is pretty straightforward. On linux systems, run the mk script:

$ ./mk

On a 64 bit linux system, first edit the mk script by removing the -m32
compiler flag.



http://uazu.net/sbagen/

http://en.wikipedia.org/wiki/Brainwave_entrainment

[ Sample of delta brainwave image courtesy Hugo Gamboa CC Creative Commons License]

Thursday 14 June 2012

Netwalker PC-T1



While trying to do updates in synaptic and refreshing the packages I was getting 404's for the http://ports.ubuntu.com source repositories.

To fix this i had a look at this forum

https://forums.ubuntulinux.jp/viewtopic.php?id=12133

There they have updated /etc/atp/sources.list to use a different repository. I have chosen:


http://jp.archive.ubuntu.com/ports

Netwalker PC-T1 Recovery Notes


After trying to revert to an older kernel, 2.6.28-15-sendai, bluetooth and wifi had stopped working. Thankfully I had an old recovery microsd handy. Please see section below "Setting up recovery Micro SD" for a quick description on how to setup a recovery microsd.

Recovery process is quite simple, put the microsd in the netwalker, turn it on and hold both L/R mouse buttons on the bezel. This may take a few tries to get right, you know it is working when you see a black cursor box on the top left hand corner of the white sharp screen. When you see the black box, release the buttons.

Then you will be presented with some japanese text. It says to continue press the left mouse button. Press the L button and it will start installing (note: it may take half an hour or so, be patient) If everything is working you will start seeing progress dots appear a few minutes after pressing the L button.

Now I think I will stick to this default kernel as the 2.6.28-19-sendai update seemed to have caused more problems!

Stylus input seems to crash with the motorola softstylus, although it has sometimes happened with the matchbox-keyboard as well. There might be a bug in how softstylus receives or sends input events within X


-----------------------------------------------------------------------------------------------------------

Setting up recovery Micro SD

To create a recovery micro sd, first you need a 2GB microsd card and an
internet connection for the script to download. Take caution that it will wipe any existing data on the microsd card. When finished the recovery system will use about 1.6gb of storage.

1) Download the following http://www.sharp.co.jp/support/ex-data/recovery.sh.tar.gz

2) Open the terminal and decompress the file:
    $ tar -zxvf  ./recovery.sh.tar.gz

3) Run the script $ sudo ./recovery.sh and wait for the script to download and copy the contents of the recovery system to your microsd card.



Resource:

http://www.sharp.co.jp/support/mit/doc/install.htm

http://www.sharp.co.jp/netwalker/pct1/index.html