sabato 23 maggio 2015

Send program change on track selection with Bitwig Studio 1.1

Today I decided that I really wanted to be able to change the effects in rakarrack on track selection in Bitwig. This is far easier than imagined, but requires a controller script and a naming convention for tracks. Here it is. The instructions below are for ubuntu, but I am sure the script will work fine on other platforms.

loadAPI(1.0);
host.defineController("Generic","Program changer","1.0","7ab8d8ee-fd26-11e4-a322-1697f925ec7b");
host.defineMidiPorts(0,1);

function init()
{
    function nameObserver(arg){
name=arg;
res = name.match(/.*PC#([0-9]+).*/);
if (res!=null)
   if (!(res[1] === undefined)){
program = parseInt(res[1]);
if (program != null){
   println(program);
   sendProgramChange(0,program);
}
   }
    }
    var cursorTrack = host.createCursorTrack(0,0);        
    cursorTrack.addNameObserver(255,"",nameObserver);

}


Save the script in your bitwig controller scripts path (see below for downloadable file), add a Generic->Program changer controller in bitwig, and connect the midi output port of the controller script to your hardware or software emulation. In my case I selected Virtual Raw MIDI/1 (I use ubuntu, so I added  modprobe snd-virmidi to my /etc/rc.local file, and I can connect to rakarrack this way). 




Note: you also have to connect rakarrack to the same virtual alsa port (e.g. using patchage), and check "midi program change table" in rakarrack midi preferences, but this is not the main topic of this post.

Next, change the name of some bitwig track so that it contains the string PC#nn, where nn is a controller number. The precise string may be changed by changing the regular expression used in the script. I have two tracks using two different programs.



As you can see, PC#nn is just a sub-string of the track name, which may still be descriptive. Now select one such track and watch your program change event to happen!

You can find the complete script here:

https://github.com/vincenzoml/vincenzomlBitwig

And in case you're wondering, here's some music I make, mostly with Bitwig on Linux nowadays.

https://soundcloud.com/vincenzoml

giovedì 22 gennaio 2015

Why I do not support ind.ie anymore

Some time ago, I started sharing and "liking" links from ind.ie. This is because I totally agree with the motivations and the goals of the project, relating to provably private social networking, file sharing, and communication. Now I have to do an unpleasant thing: RETRACT my recommendation.

The reason is, they decided to start by focusing on a single platform, and a proprietary one, which is only supported on proprietary hardware. This decision is not just questionable, or debateable, in the context. It's wrong.

Software aimed at being a private communication platform must first of all be open source, and that's what they are doing, but second, it must be portable. This is because if you find out, or believe, that your hardware or operating system is bugged (on purpose or not) and leaks your private conversations, you must be able to go to a different vendor, chose a product that you consider better, and recompile the product in order to access your data and contacts again. That's not ideology; that's what you technically need, to decentralise power and be on the safe side of things. If their software is not portable, I don't see why I should even consider using it in the future.

Giving money or effort to an open source project is an investment of the whole society, and I think we all should do it more often, but what do I do with the source, if I can't even compile it, since it's written for a proprietary hardware/software combination? I can imagine parts of the software will be portable, so we all could hack alternative interfaces for a product. But why should I accept to be on the wrong side of the technological gap, that is, be unsupported from the maker, when I am supporting the product as an user? In other words, why should I invest in a maker which is not investing in me as an user?

Since ind.ie recently referenced the Paris deaths and freedom of speech, which I found untasteful from the start, I'll add that if we all want to be Carlie Hebdo -- and I'm not claiming I do -- we must start from having the courage to say unpleasant things to people, and to put our face, name and reputation on it. I am doing this now, with my 29/37 coding/life ratio (TM ;-) ) and my 18 years (half of my life) of formal computer science education and academic research activity, which I think gives me some authority on what is correct and what is not correct in designing a secure, private, decentralised software.

So: my not-so-politically-correct statement is "what ind.ie is proposing to do with the money of their donors is totally wrong".

For the time being, I advice my friends to keep using dropbox, google, facebook, whatever centralised product you use, it's just safer. It's one player less in the game, more mature products, less potential bugs. If you really want to have something like what ind.ie promised, you can fork their code, or fork somebody else's code, or start over from scratch, or support someone else in doing that. I'll be glad to support and even contribute work to any future project along the same lines, who also shares with me the values and reasons I explained above.

Let me conclude by saying that: 1) I am writing this only because I am sorry for the false advertising I unwantedly did when sharing links to ind.ie, but 2) that I want to leave a positive note too, because the effort, dedition, and communication abilities of the ind.ie team have been really great; it's unfortunate that I can't agree with the direction they took, but at least I can say they worked very hard, and maybe in the end they will change their mind. I'll be glad to change my mind in turn in that case.

Vincenzo

lunedì 26 agosto 2013

LG L9 Unbrick script

Here is a script I make to unbrick LG L9. This uses some custom firmware downloaded from random web sites so YMMV. This should automatically unbrick your LG L9.

This script is to be used ONLY when phone can't be booted in sw upgrade mode and everything else fails. Screen MUST be always black, otherwise other methods may give better results. When nothing else works, proceed at your own risk.

When screen is black with all possible key combos, connect your phone to a linux box using an USB data cable, without battery. Then run "lsusb". If you see a texas instrument device in the list, then proceed.

Before running the tool, you need to install the android-tools-fastboot package (read the comments in the script to know more).

Unzip the archive, cd to the obtained directory  and run "./lgL9FixBoot.sh".

You will first be asked to connect the phone without battery, then to insert the battery in a second step.

https://dl.dropboxusercontent.com/u/8112691/unbrick-LG-Optimus-L9.zip



venerdì 23 agosto 2013

Today I evolved the "hello world" example from the fuse library (http://fuse.sourceforge.net) in order to have a minimal read-write file system. The result is the following:


#define FUSE_USE_VERSION 26

#include <fuse.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <math.h>
#include <stdlib.h>

static char *file_str;
static size_t len = 0;
static size_t maxlen = 1024 * 1024;
static const char *file_path = "/file";

static int file_getattr(const char *path, struct stat *stbuf)
{
int res = 0;

memset(stbuf, 0, sizeof(struct stat));
if (strcmp(path, "/") == 0) {
stbuf->st_mode = S_IFDIR | 0755;
stbuf->st_nlink = 2;
} else if (strcmp(path, file_path) == 0) {
stbuf->st_mode = S_IFREG | 0644;
stbuf->st_nlink = 1;
stbuf->st_size = len;
} else
res = -ENOENT;

return res;
}

static int file_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi)
{
if (strcmp(path, "/") != 0)
return -ENOENT;

filler(buf, ".", NULL, 0);
filler(buf, "..", NULL, 0);
filler(buf, file_path + 1, NULL, 0);

return 0;
}

static int file_open(const char *path, struct fuse_file_info *fi)
{
if (strcmp(path, file_path) != 0)
return -ENOENT;

return 0;
}

static int file_read(const char *path, char *buf, size_t size, off_t offset,
     struct fuse_file_info *fi)
{
if(strcmp(path, file_path) != 0)
return -ENOENT;

if (offset < len) {
if (offset + size > len)
size = len - offset;
memcpy(buf, file_str + offset, size);
} else
size = 0;

return size;
}

static int file_write(const char *path, const char *buf, size_t size,
    off_t offset, struct fuse_file_info *fi)
{
if(strcmp(path, file_path) != 0)
return -ENOENT;

if (offset < maxlen) {
if (offset + size > maxlen)
size = maxlen - offset;
memcpy(file_str + offset, buf, size);
len = fmax(offset + size,len);
} else
size = 0;

return size;
}

static int file_truncate(const char *path, off_t size)
{
if(strcmp(path, file_path) != 0)
return -ENOENT;

len = size;
return 0;
}

static struct fuse_operations file_oper = {
.getattr = file_getattr,
.readdir = file_readdir,
.open = file_open,
.read = file_read,
.write = file_write,
.truncate = file_truncate
};

int main(int argc, char *argv[])
{
file_str = malloc(maxlen);
return fuse_main(argc, argv, &file_oper, NULL);
}

venerdì 26 luglio 2013

Using external SDCard as /data on cyanogenmod 10.1 (android jellybean)

Quick explanation on how I got my external SD to be the data partition in CyanogenMod 10.1. YOU NEED TO UNDERSTAND EVERY STEP YOURSELF OTHERWISE DON'T DO THIS.

Note: I managed to brick my LG Optimus L9 P760 the first time I erased partitions, so YMMV. Be prepared to unbrick.

*) we need to operate as root on the device; an easy way is to install ssh server, which is available in the app store. Install and configure it. When you are logged in on the phone, type "su" to become root; allow operation on the phone.

*) identify what is your sdcard. Mine is /dev/block/mmcblk1

*) umount any mounted partitions.

*) use fdisk to wipe all partitions and create an ext2 partition. Assign to it type 83 (linux)  # maybe brick in progress...

*) reboot if needed

*) mke2fs /dev/block/mmcblk1p1  # use your device! careful here, brick is coming!

*) mkdir /mnt/fuse/real_sdcard1  # from now on, especially if you rebooted fine before, no brick anymore I think

*) mount -t ext2 /dev/block/mmcblk1p1 /mnt/fuse/real_sdcard1   # use your device

*) cp -a /data /mnt/fuse/real_sdcard1

*) mount -o remount,rw /     # not sure if really needed, let me know

*) nano /data/local/userinit.sh  # this is called by /etc/init.d/90userinit

*) therein, we put:

    mkdir -p /mnt/fuse/real_sdcard1
    mount -t ext2 /dev/block/mmcblk1p1 /mnt/fuse/real_sdcard1
    mount -o bind /mnt/fuse/real_sdcard1/data /data

reboot, enjoy

vincenzoml