Saturday, 29 October 2016

Tabla (Treetaal / Teentaal) Live coding on Sonic Pi.


Tabla Live coding on Sonic Pi.

  1. Download Sonic PI software by googling for it.
  2. Install Sonic PI. I've done this on a Windows machine. Linux installs on my laptops were going to need more work to make the software work so decided to do it on Windows.
  3. Make sure the tabla samples are available. Try typing "sample :tabla" you should see the auto fill for the tabla bol. If you do you have the tabla samples otherwise not.
  4. Created the following code for the Lehra sath in Raag Bhinna Shadaj and the very preliminary kayda in Treetal.
  5. Copy the following in the buffer and play.
  6. Watch it on Youtube -- here --.
  7. Did you ever think these two skills will come together?

#Treetal using Sonic PI
#Rajendra Sathe

#use_bpm 128
thamb1 = 0.250
x = -10

use_synth :piano

live_loop :lehra do
  raag_bhinna_shadja_lehra_1
end

live_loop :kayda do
  sync :lehra
  1.times do
   treetal
  end
  treetal_dha_dha_tee_tuu_kayda
end



#==========Definitions Start=================#
define :z1 do
  sleep thamb1
end

define :z2 do
  sleep thamb1 / 2
end

define :dha do
  sample :tabla_na
  sample :tabla_ghe1
end

define :dhin do
  sample :tabla_tas1
  sample :tabla_ghe3
end

define :ta do
  sample :tabla_na
end

define :tin do
  sample :tabla_tas1
  sample :tabla_ke1
end

define :tee do
  sample :tabla_te1
end

define :tuu do
  sample :tabla_tas1
end

define :too do
  sample :tabla_tas2
end

define :na do
  sample :tabla_na
end

define :treetal do
  2.times do
    dha
    sleep thamb1
    dhin
    sleep thamb1
    dhin
    sleep thamb1
    dha
    sleep thamb1
  end
  1.times do
    dha
    sleep thamb1
    tin
    sleep thamb1
    tin
    sleep thamb1
    ta
    sleep thamb1
  end
  1.times do
    ta
    sleep thamb1
    dhin
    sleep thamb1
    dhin
    sleep thamb1
    dha
    sleep thamb1
  end
end

define :raag_bhinna_shadja_lehra_1 do
  play 60 + x , sustain: 3, amp: 1.5
  #play 62, sustain: 3, amp: 1.5
  z1
  play 64 + x , sustain: 3, amp: 0.5
  z1
  play 65 + x , sustain: 3, amp: 0.5
  z1
  play 69 + x , sustain: 3, amp: 0.5
  z1
  play 65 + x , sustain: 3, amp: 0.5
  z1
  play 69 + x , sustain: 3, amp: 0.5
  z1
  play 71 + x, sustain: 3, amp: 0.5
  z1
  play 72 + x, sustain: 3, amp: 0.5
  z1
  play 71 + x, sustain: 3, amp: 0.5
  z1
  play 69 + x, sustain: 3, amp: 0.5
  z1
  play 65 + x, sustain: 3, amp: 0.5
  z1
  play 64 + x, sustain: 3, amp: 0.5
  z1
  play 69 + x, sustain: 3, amp: 0.5
  z1
  play 65 + x, sustain: 3, amp: 0.5
  z1
  play 64 + x, sustain: 3, amp: 0.5
  z1
  play 60 + x, sustain: 3, amp: 0.5
  z1
end



define :treetal_dha_dha_tee_tuu_kayda do
  dha
  z1
  dha
  z1
  tee
  z1
  tuu
  z1
  
  dha
  z1
  dha
  z1
  too
  z1
  na
  z1
  
  ta
  z1
  ta
  z1
  tee
  z1
  tuu
  z1
  
  dha
  z1
  dha
  z1
  dhin
  z1
  na
  z1
  #============================#
  2.times do
    dha
    z2
    dha
    z2
    tee
    z2
    tuu
    z2
    
    dha
    z2
    dha
    z2
    too
    z2
    na
    z2
    
    ta
    z2
    ta
    z2
    tee
    z2
    tuu
    z2
    
    dha
    z2
    dha
    z2
    dhin
    z2
    na
    z2
  end
  #============================#
  #========palta 1 ==start=====#
  dha
  z2
  dha
  z2
  tee
  z2
  tuu
  z2
  
  dha
  z2
  dha
  z2
  tee
  z2
  tuu
  z2
  
  dha
  z2
  dha
  z2
  tee
  z2
  tuu
  z2
  
  dha
  z2
  dha
  z2
  too
  z2
  na
  z2
  
  ta
  z2
  ta
  z2
  tee
  z2
  tuu
  z2
  
  ta
  z2
  ta
  z2
  tee
  z2
  tuu
  z2
  
  dha
  z2
  dha
  z2
  tee
  z2
  tuu
  z2
  
  dha
  z2
  dha
  z2
  dhin
  z2
  na
  z2
  #========palta 1 ==end=====#
  
  #========palta 2 ==start=====#
  dha
  z2
  dha
  z2
  dha
  z2
  dha
  z2
  
  tee
  z2
  tuu
  z2
  dha
  z2
  dha
  z2
  
  dha
  z2
  dha
  z2
  tee
  z2
  tuu
  z2
  
  dha
  z2
  dha
  z2
  too
  z2
  na
  z2
  
  ta
  z2
  ta
  z2
  ta
  z2
  ta
  z2
  
  tee
  z2
  tuu
  z2
  ta
  z2
  ta
  z2
  
  ta
  z2
  ta
  z2
  tee
  z2
  tuu
  z2
  
  dha
  z2
  dha
  z2
  dhin
  z2
  na
  z2
  #========palta 2 ==end=====#
  
  #========palta 3==start=====#
  dha
  z2
  dha
  z2
  tee
  z2
  tuu
  z2
  
  z2
  z2
  tee
  z2
  tuu
  z2
  
  dha
  z2
  dha
  z2
  tee
  z2
  tuu
  z2
  
  dha
  z2
  dha
  z2
  too
  z2
  na
  z2
  
  ta
  z2
  ta
  z2
  tee
  z2
  tuu
  z2
  
  z2
  z2
  tee
  z2
  tuu
  z2
  
  ta
  z2
  ta
  z2
  tee
  z2
  tuu
  z2
  
  dha
  z2
  dha
  z2
  dhin
  z2
  na
  z2
  #========palta 3 ==end=====#
  
  
  #========Tihaee ==start=====#
  2.times do
    dha
    z2
    dha
    z2
    tee
    z2
    tuu
    z2
    
    dha
    z2
    dha
    z2
    too
    z2
    na
    z2
    
    dha
    z2
    z2
    z2
    z2
  end
  dha
  z2
  dha
  z2
  tee
  z2
  tuu
  z2
  
  dha
  z2
  dha
  z2
  too
  z2
  na
  z2
  #========Tihaee ==start=====#
end

Friday, 20 November 2015

Mount iPhone onto Ubuntu

1. Prerequisite - Install ifuse

2. Connect the iPhone  to the computer using USB.

3. Click Allow / Trust on the iPhone when asked to Allow access or Trust the computer.

4. Following command will display the information about all devices connected to the computer through the USB. The information of our interest is the "Serial number".

$usb-devices

T:  Bus=02 Lev=01 Prnt=01 Port=03 Cnt=01 Dev#=  2 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  4
P:  Vendor=xyz ProdID=xyz Rev=xyz
S:  Manufacturer=Apple Inc.
S:  Product=iPhone
S:  SerialNumber=
C:  #Ifs= 3 Cfg#= 4 Atr=c0 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=06(still) Sub=01 Prot=01 Driver=(none)
I:  If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=fe Prot=02 Driver=usbfs
I:  If#= 2 Alt= 1 #EPs= 2 Cls=ff(vend.) Sub=fd Prot=01 Driver=iphe

5. Create a directory - mount point for the iPhone.
$mkdir /media/iPhone

6. Now mount the iphone using the following
$sudo ifuse /media/iPhone/ -u -o rw,allow_other

7. All done. List, copy files from iPhone.
$ls /media/iPhone/


Wednesday, 6 May 2015

Turning on Sony Bravia TV from a computer terminal

Sony Bravia TV allows one to wake it up using (WoL) Wake On LAN. Look for settings on your respective models.

$ sudo apt install wakeonlan 

wakeonlan is a script/utility which allows sending magic packets to networked devices which allow WoL.

The IP address can be found from modem admin utility which also shows the mac address for the TV.

Following command will turn the TV on.

$ wakeonlan -i "IP address of the TV" "Mac address of the TV"


Thursday, 11 September 2014

Recovering photos from iPOD. (convert ITHMB files to *.png)

Used the following method to recover photos stuck in first generation ipod.

Had lost the originals but found the photos safe in the ipod. iPod converts the originals to small size and stores. Apple does not support this. Asked in 2 different stores.

So had to rely on online help. imageMagick utility converts the photos from uyvy format to png. The only thing required is to get individual photos from the big ITHMB files. The following JAVA code did that.

The ITHMB file name and image sizes are as below:

 1019_*.ithmb offset: 7603200, imgsize: 691200 
 1020_*.ithmb offset: 851840, imgsize: 77440
 1009_*.ithmb offset: 27720, imgsize: 2520
 1015_*.ithmb offset: 251680, imgsize: 22880

We use the 1019_*.ithmb file as its meant for TV output. (720x480 interlaced UYVY (YUV 4:2:2) - used for TV output - 691200 bytes each single thumbnail)

Read details here.
Step 1: The following program will read the ITHMB file and separate out the photos into *.uyvy format.
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.Paths;

public class ReadITHMBfile {

static int count = 1,fileCount = 1;
static byte[] intFis = new byte[1];
static BufferedInputStream fis = null;
static BufferedOutputStream fos = null;
static String ithmbExt = ".ithmb", pngExt = ".png";
static Path startingDir;
static private final PathMatcher matcher = null;

public static void main(String[] args)   // unit testing
{
/*if (args[0].length() == 0 )
{
throw new IllegalArgumentException("Pass Directory containing .ITHMB files as Argument");
}

startingDir = Paths.get(args[0]);


matcher = FileSystems.getDefault().getPathMatcher(startingDir+ITHMBFileName);
        Files.walkFileTree(startingDir, matcher);
        finder.done();*/
String ITHMBFileName = "F1019_2";

File fInput  = new File("/home/raj/Pictures/"+ ITHMBFileName + ithmbExt);
File fOutput = new File ("/home/raj/Pictures/FromiPOD/"+ ITHMBFileName +"_"+ fileCount + ".uyvy");

try { 

fis = new BufferedInputStream(new FileInputStream(fInput),2048);
fos = new BufferedOutputStream(new FileOutputStream(fOutput));

while ( fis.read(intFis) >= 0)

{
if (count <= (720 * 480 * 2))
{
//StdOut.print(new Character((char)(intFis[0])) + " in Ascii ");
//StdOut.print(intFis[0] + " in Hex ");
//StdOut.println(new Integer(intFis[0]).toHexString(intFis[0]));
fos.write(intFis);
count=count+1;
}
else
{
fos.close();
fileCount++;
fOutput = new File ("/home/raj/Pictures/FromiPOD/"+ ITHMBFileName +"_"+ fileCount + ".uyvy");
fos = new BufferedOutputStream(new FileOutputStream(fOutput));
fos.write(intFis);
count = 2;
}
}
}
catch (IOException e) 

e.printStackTrace(); 
System.err.println("Error generating uyvy file"); 
}

finally {

try {
fis.close();
fos.close();
} catch (IOException e) {
e.printStackTrace();
}

}

}

}



Step 2: Download and install the imageMagick utility.
Step 3: Create a mask.png file using the following command. (convert is an imageMagick utility)
convert xc:black xc:white -append -write mpr:m +delete -size 720x400 tile:mpr:m mask.png

Step 4: Using the mask now convert each *.uyvy file to *.png file.
On Linux
for i in {1..759};
 do
 convert -size 720x480 -depth 16 -sampling-factor 4:2:2 F1019_2_$i.uyvy -crop 100%x50% -filter Point -resize 100%x200% mask.png -composite F1019_2_$i.png
done


Tuesday, 22 February 2011

Eclipse change required after Ubuntu upgraded the JRE

Did yet another update for Ubuntu 10.04. It installed JRE 1.6 when earlier had JRE 1.5

As a result Eclipse could not find the required JRE system library. As a result the project gave compilation errors "import java.util.*" cannot be resolved etc.

Eclipse picks up these libraries from the installed JREs. This can be changed from the Project (right click)--> Properties --> Libraries .

So removed the flagged library and added the JRE system library from the installed JRE.

Monday, 31 January 2011

State of internet 2010

Windows7 theme wallpapers on Ubuntu.

1. Windows 7 compresses its themes in a compression other than .zip/.rar etc. Windows 7 themes can be downloaded from

2. Download the theme. The filename will be *.themepack

3. Install 7zip - Go to Ubuntu Software centre >> Accessories >> look for 7zip and install.

4. 7zip can be invoked using 7za/7z.

5. $7za e
will unzip the themepack in the folder specified.

6. Use to have windows7 theme wallpapers on ubuntu.