lkubuntu

A listing of random software, tips, tweaks, hacks, and tutorials I made for Ubuntu

Category Archives: free

Injecting code into running process with linux-inject

I was about to title this “Injecting code, for fun and profit”, until I realized that this may give a different sense than I originally intended… :P

I won’t cover the reasons behind doing such, because I’m pretty sure that if you landed on this article, you would already have a pretty good sense of why you want to do this …. for fun, profit, or both ;)

Anyway, after trying various programs and reading on how to do it manually (not easy!), I came across linux-inject, a program that injects a .so into a running application, similar to how LD_PRELOAD works, except that it can be done while a program is running… and it also doesn’t actually replace any functions either (but see the P.S. at the bottom of this post for a way to do that). In other words, maybe ignore the LD_PRELOAD simile :P

The documentation of it (and a few other programs I tried) was pretty lacking though. And for good reason, the developers probably expect that most users who would be using these kinds of programs wouldn’t be newbies in this field, and would know exactly what to do. Sadly, however, I am not part of this target audience :P It took me a rather long time to figure out what to do, so in hopes that it may help someone else, I’m writing this post! :D

Let’s start by quickly cloning and building it:

git clone https://github.com/gaffe23/linux-inject.git
cd linux-inject
make

Once that’s done, let’s try the sample example bundled in with the program. Open another terminal (so that you have two free ones), cd to the directory you cloned linux-inject to (e.g. cd ~/workspace/linux-inject), and run ./sample-target.

Back in the first terminal, run sudo ./inject -n sample-target sample-library.so

What this does is that it injects the library sample-library.so to a process by the -name of sample-target. If instead, you want to choose your victim target by their PID, simply use the -p option instead of -n.

But … this might or might not work. Since Linux 3.4, there’s a security module named Yama that can disable ptrace-based code injections (or code injections period, I doubt there is any other way). To allow this to work, you’ll have to run either one of these commands (I prefer the second, for security reasons):

echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope # Allows any process to inject code into any other process started by the same user. Root can access all processes
echo 2 | sudo tee /proc/sys/kernel/yama/ptrace_scope # Only allows root to inject code

Try it again, and you will hopefully see “I just got loaded” in-between the “sleeping…” messages.

Before I get to the part about writing your own code to inject, I have to warn you: Some applications (such as VLC) will segfault if you inject code into them (via linux-inject, I don’t know about other programs, this is the first injection program that I managed to get working, period :P). Make sure that you are okay with the possibility of the program crashing when you inject the code.

With that (possibly ominous) warning out of the way, let’s get to writing some code!

#include <stdio.h>

__attribute__((constructor))
void hello() {
    puts("Hello world!");
}

If you know C, most of this should be pretty easy to understand. The part that confused me was __attribute__((constructor)). All this does is that it says to run this function as soon as the library is loaded. In other words, this is the function that will be run when the code is injected. As you may imagine, the name of the function (in this case, hello) can be whatever you wish.

Compiling is pretty straightforward, nothing out of the ordinary required:

gcc -shared -fPIC -o libhello.so hello.c

Assuming that sample-target is running, let’s try it!

sudo ./inject -n sample-target libhello.so

Amongst the wall of “sleeping…”, you should see “Hello world!” pop up!

There’s a problem with this though: the code interrupts the program flow. If you try looping puts("Hello world!");, it will continually print “Hello world!” (as expected), but the main program will not resume until the injected library has finished running. In other words, you will not see “sleeping…” pop up.

The answer is to run it in a separate thread! So if you change the code to this …

#include <stdio.h>
#include <unistd.h>
#include <pthread.h>

void* thread(void* a) {
    while (1) {
        puts("Hello world!");
        usleep(1000000);
    }
    return NULL;
}

__attribute__((constructor))
void hello() {
    pthread_t t;
    pthread_create(&t, NULL, thread, NULL);
}

… it should work, right? Not if you inject it to sample-target. sample-target is not linked to libpthread, and therefore, any function that uses pthread functions will simply not work. Of course, if you link it to libpthread (by adding -lpthread to the linking arguments), it will work fine.

However, let’s keep it as-is, and instead, use a function that linux-inject depends on: __libc_dlopen_mode(). Why not dlopen()? dlopen() requires the program to be linked to libdl, while __libc_dlopen_mode() is included in the standard C library! (glibc’s version of it, anyways)

Here’s the code:

#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <dlfcn.h>

/* Forward declare these functions */
void* __libc_dlopen_mode(const char*, int);
void* __libc_dlsym(void*, const char*);
int   __libc_dlclose(void*);

void* thread(void* a) {
    while (1) {
        puts("Hello world!");
        usleep(1000000);
    }
}

__attribute__((constructor))
void hello() {
    /* Note libpthread.so.0. For some reason,
       using the symbolic link (libpthread.so) will not work */
    void* pthread_lib = __libc_dlopen_mode("libpthread.so.0", RTLD_LAZY);
    int(*pthread_lib_create)(void*,void*,void*(*)(void*),void*);
    pthread_t t;

    *(void**)(&pthread_lib_create) = __libc_dlsym(pthread_lib, "pthread_create");
    pthread_lib_create(&t, NULL, thread, NULL);

    __libc_dlclose(pthread_lib);
}

If you haven’t used the dl* functions before, this code probably looks absolutely crazy. I would try to explain it, but the man pages are quite readable, and do a way better job of explaining than I could ever hope to try.

And on that note, you should (hopefully) be well off to injecting your own code into other processes!

If anything doesn’t make sense, or you need help, or just even to give a thank you (they are really appreciated!!), feel more than free to leave a comment or send me an email! :D And if you enjoy using linux-inject, make sure to thank the author of it as well!!

P.S. What if you want to change a function inside the host process? This tutorial was getting a little long, so instead, I’ll leave you with this: http://www.ars-informatica.com/Root/Code/2010_04_18/LinuxPTrace.aspx and specifically http://www.ars-informatica.com/Root/Code/2010_04_18/Examples/linkerex.c . I’ll try to make a tutorial on this later if someone wants :)

Why Openlux instead of Redshift?

First, I want to clarify that this is not a post trying to show that one is better than the other unequivocally. This is, instead, a post trying to show my reasons for writing openlux, and the differences between both softwares. I’m sure that many people will prefer the way that redshift works, over the way that openlux works, and that’s awesome!! The purpose of this post is, mainly, to show the differences, and hopefully help you decide which is better for your circumstance :)

My initial reason for writing openlux was because f.lux didn’t work for me, for various reasons (as I outlined in the first post about it) … I was actually unaware of redshift. There were a few people who linked me to it, and I immediately felt slightly disappointed that I hadn’t done my research before (would have saved me quite a bit of work!). Looking into it though, it’s not what I was looking for, and it has some of the issues that made me switch away from f.lux.

Redshift’s mode of operation is different than openlux’s. It primarily functions as a daemon, changing the color temperature automagically, depending on your timezone. This is a really handy feature, however, you don’t have much ability to configure the times. If you don’t have insomnia, and have a regular sleeping schedule, this is probably perfect. You tell it where you live, and it will change the screen color temperature throughout the day, in order to match the light you would receive if you were outside at that time (except at night, of course =P). But in my case, I can stay up until 4-5am, unable to sleep at all. Having the screen automatically change to a higher color temperature when I’m trying to go to sleep is most definitely not what I need. Now I could change the timezone every so often, but I’d rather have something in which I control when the screen color changes, instead of having to work against the program. I am aware that redshift has an option for manually changing the color temperature, but you don’t have much control over other options (such as animating to it, or individual control over RGB channels).

Redshift also uses color tables in order to compute the RGB values from kelvin temperatures. This allows for maximum accuracy within the range it provides (1000-25100K), however, it doesn’t allow anything outside of the range. On the other hand, openlux, works using Tanner Helland‘s algorithm, which allows for a theoretically infinite (practically 0-232, because it’s stored in a 32-bit integer), but less accurate result. Personally, I prefer using an algorithm, but there are definitely things to say about using a color table instead. The algorithm is pretty accurate (I think it’s a maximum of ~3-5% off of the original value), but if you’re within the range that redshift provides, it’s always nice to have 100% accuracy!

The main philosophical difference (that influences how the programs evolve) between redshift and openlux is the goal: redshift is more oriented towards being a standalone, fully-featured program, while openlux is oriented towards being a program that only does one task (change the screen color temperature), and focuses on that one task. It leaves tasks such as changing the color temperature in accordance with the timezone to other programs specialized for this (such as cron), or manually. Redshift tends to go more on the side of “run it, and forget about it”, while openlux leans more on giving the user maximum control and flexibility.

There’s definitely something to be said about both philosophies, and different users will appreciate different philosophies. I personally prefer the one of having full control at all times, but there are many users who would prefer to just have the program manage it for them automagically.

If you’re not sure which to use, try both! See which one works best for you. After all, GNU/Linux is all about choice :)

If I’ve made any mistake in this article, please let me know. This post is most definitely not about saying that one software is better than the other. While I, of course, prefer openlux, I want this to be a fair comparison of both softwares, so that users can better decide which software they want to use for themselves.

Openlux 0.2 beta – Animations, iOS port

I wrote openlux around 2 and a half weeks ago, as a simple, libre alternative to f.lux that addresses a few issues I’ve encountered with it. I’ve since used it everyday, and I’ve actually noticed an improvement in my sleep!

However, my iPad still uses f.lux (or, until today, at least). No, in this case, I’m not worried about the fact that f.lux is proprietary (it’s an iPad), but earlier, when my sleep was really messed up (and by messed up, I mean, I was going to sleep at 7-8am), f.lux would automatically switch to 3400K (instead of 2300K), which definitely didn’t have a positive impact on my sleep. Also, it only goes down to 2300K, doesn’t allow much customizability, and doesn’t always work how I want it to work, etc.

So after spending quite a long time (basically ever since I released the first version of openlux) working on the port, it finally works!!! It doesn’t work as well as I wanted it to (multiple colors output the same value, compressing the color range … I tried lerping values, but it ended up giving garbage), but at least it works!

Animations literally took about the last hour of developing this version (in other words, barely any time at all, compared to the time needed to develop the iOS port), since, luckily, I only encountered one bug while making it. The point of animations is not for visual bling, but rather to make it easier on the eyes if it’s run automatically (e.g. via cron).

Other than those, there are a few minor features, such as optional relative adjustment of colors (“-b 10” will set the blue channel to 10, “-b +10” will add 10 to the blue channel, and “-b -10” will remove 10), and saving/resetting gamma values (mainly just a by-product of working on the iOS port).

If anyone would be interested in testing this on their iDevices, I would really appreciate it ^^ Though it works fine on my 1st generation iPad, I don’t know if it will work on other devices too. I wrote instructions on how to compile and run it here: https://github.com/AnonymousMeerkat/openlux/wiki/Compiling-for-iOS :) I’m not aware of this being able to cause any permanent damage to your device (my device works fine now, even after the display being severely messed up multiple times), but if you’re scared, stick with f.lux for now. Quick note: it doesn’t work on iOS <4, since it needs to retrieve the gamma table (which iOS versions <4 don’t support).

To wrap up, here’s a few examples of the new features that come with openlux 0.2:

openlux -k 1000 -a 10000         # Animates to 1000K in 10 seconds (10000 milliseconds)
openlux -k 1000 -a 100000 -d 100 # Animates to 1000K in 100 seconds, with a delay of 100 milliseconds per "frame" (less CPU usage)
openlux -k 1000 -g +10           # Sets the color temperature to 1000K, but adds 10 to the green channel
openlux -R                       # Resets to the last saved gamma table (openlux automatically saves the gamma table the first time it's run per boot)
openlux -s                       # Saves the gamma table

Using Openlux to help your sleep and/or relax your eyes

If you are familiar with research suggesting that blue light affects your sleep, you might also be familiar with a (free!) software named f.lux. I use it on my iDevices (used to use it on my computers too), and it works great …. except for a few issues.

The first is CPU consumption. Seriously, this software takes up a lot of CPU. That was the main reason behind ditching xflux (the X11 edition of the software). It also doesn’t entirely block out blue light, even at the lowest color temperature it allows (this is true for the iOS version too). There were a number of other issues that became annoying over time (forced very long animations, a daemon that rarely ever works as intended, sometimes the software doesn’t even work at all, mouse cursor being left entirely out of the picture, etc.). These would (probably) all be simple to fix …. however, it’s free as in price, not as in freedom. The software is closed-source.

Openlux is a very simple open-source MIT-licensed clone I wrote that tries to address these issues (minus the mouse cursor issue, that one is a bit more complex). For now, it doesn’t contain as many features as xflux does, but it is only a first release. Animations and the lot will come later :)

I haven’t worked on packaging yet (if anyone wishes to spend some time doing this, that would be greatly appreciated!!), but for now, visit https://github.com/AnonymouMeerkat/openlux for download and compilation information (sorry for the mess in main.c, I will get to that later!).

Here are a few usage examples

openlux                      # Sets the screen color temperature to 3400K (the default)
openlux -k 1000              # Sets the color temperature to 1000K
openlux -k 2000 -b 0         # Sets color temperature to 2000K, but removes all blue light
openlux -k 2000 -b 255       # Ditto, but blue is set to 255 (maximum value, gives the screen a magenta-ish tone)
openlux -r 130 -g 150 -b 100 # Gives the screen a dark swamp green tint (Kelvin value is ignored)
openlux -k 40000             # Sets the screen color temperature to 40000K
openlux -i                   # Resets the screen color temperature

I personally like using openlux -k 10000 during the day (very relaxing for the eyes!), and openlux -k 2300 -b 40 during the night.

I hope this can be useful for you!! If you have any issues, suggestions, feedback, etc. (even if you just want to say thank-you — those are always appreciated ^^), feel free to write a comment or send me an email!

The importance of freedom in software

Software license agreements (EULA) are generally considered little more than a confirmation on whether or not the user really wants to install said software. Heck, for all that most users care, it could read “Do you wish to install this software?” and their overall reaction would be approximately the same. In fact, I often catch myself using the “I decline” button when I realize that this software is indeed useless.

Of course, in the back of our minds, we know that we really should read it …. but, come on, we have a life to live. We can’t spend it reading license agreements! YOLO.

Many software developers know this fact, and capitalize on it. One good example would be a company named after a fruit that develops smartphone specifications. Have any of you ever read the 60 page long license agreement on a tiny screen, just to install the next Flappy Bird?

I’m no different. I’ve probably only read 3 (proprietary) license agreements in my entire life… and I’ve installed hundreds of proprietary software.

I’ve also found myself accustomed to thinking it’s illegal to share software with my friends. The idea of inspecting or modifying how a proprietary software works (through reverse engineering) feels very risky and only borderline legal. And, actually, both are true in most cases.

For many users, this doesn’t seem like an issue. Most users, and in fact a lot of programmers too, wouldn’t check the source code of a program they are running. And, to be honest, most users would rather just link to the website of the software anyways, even if the software would allow itself to be shared.

However, just because these freedoms are rarely used, it doesn’t mean that they are useless. Think of a self defense class. Unless you’re in a more violent neighborhood, chances are that you will very rarely need to use it. But when you do, you will be really happy that you did invest the time to learn it. After the Snowden leaks, many people started accusing software of sending data to the NSA. Is this true? I don’t know. And that’s the issue: We are not legally allowed to know. We cannot inspect or modify the software in any way. We blindly trust what the developers say about their products.

Of course, there are also more everyday usages of being able to inspect, modify, or share. I’ll use Studio One as an example. It’s a proprietary software. Its bugs have lead me to immense data losses (due to a really badly functioning “Undo” button that can occasionally screw up the entire project file). If I had the source code handy it would be possible to fix this (probably a bit difficult, yes, but possible). But I can’t fix it, because the EULA doesn’t allow me to inspect and modify.

What about sharing software? Because I cannot share the software I use with others, it makes it entirely impossible for me to create truly “open source” music (I’m not sure if the term applies to music, but I think you get the idea). I make breakdown videos, where I show how I made the music, but as far as I know, I cannot legally go any further than that.

This is not because these software developers are evil. They do this to maximize their profits, and that’s understandable. However, the cost of this is our freedom.


Now that I’ve spent some time criticizing proprietary software, I’ll take a bit of time promoting free (as in freedom) software.

First the term, Free Software. “Free” has multiple meanings (in the coincidentally named “thefreedictionary.com”, it lists 38 different meanings for the word “free”), but there are 2 major ones: free as in no price (gratis), and free as in freedom (libre). In order to distinguish between them, I’ll use “gratis” and “libre” instead.

Both the terms gratis and libre can be used to describe software. Hence, using the term “free” can be very ambiguous; “does this specific software respect my freedom? or is it just that my wallet is unnecessary?”. In many software circles, “free software” simply means gratis. In these circles, Skype could be considered free software (even though it doesn’t respect your freedom, among other issues). However, in other circles (generally among libre software developers), “free software” qualifies as “libre”, not “gratis” (and therefore, Skype would not be considered free software).

So what is the purpose of free software? Basically, depending on the license, it enables you to do what proprietary software forbids you from doing. You can share the software with anyone, you can inspect how the program works, you can modify it, and you can redistribute the modified versions too! It allows for an incredible eco-system in which programmers around the world can create new features, fix bugs and security leaks, then submit it back to the project leader for integration with the software. Or, if someone has a wildly different goal than the team who develops the project, they can fork it and create a new project, using a modified codebase of the original!

What does this mean to users who don’t know how to program? Well, okay, sure, not as beneficial to them. However, practically speaking, since an unlimited amount of programmers can get involved, libre software (especially larger ones) have a much lesser chance of having bugs, security leaks, viruses, or spyware. It can also include many more features than proprietary software does. Libre software is also often updated much more frequently than proprietary software, since any developer can contribute.

It is also possible for users to hire a programmer to make a change for them, in the same way that home owners may hire a plumber to fix a leak (except that, generally speaking, programmers would probably take more time to make the change than a plumber would to fix the leak).


Since the first part talked about the idea of proprietary software, and the second about free/libre software, the third will look at practical usage: How to switch over to libre software.

It can be difficult to switch to libre software, especially when you have proprietary software that you use a lot and/or really like. For example, if you use Skype, it may be difficult to ask your Skype contacts to switch over to Ekiga or some other libre VoIP software. In my case, a surprising number of my contacts were thankfully flexible enough to switch over to some other communication method. However, everyone is individual, and your friends might find it difficult to migrate over (even after explaining why not to use Skype).

However, luckily, most proprietary software have libre equivalents. It is beyond the scope of this post to list these, but, with a bit of research, you can find some online (I would link a list, however, I can’t find any lists that only include truly libre software). I would be happy to help find an alternative if you want too! (just leave a comment or send me an email)

Sometimes though, there are no alternatives. This is especially relevant in the field of modern video games, or music production. It is also relevant with drivers for parts of your system that do not have a libre driver written for it. So what do you do? This is really up to you. Are you okay with using proprietary software for this one purpose? Should you avoid using it period?

For me, I use proprietary software for both music production, and a few video games. I don’t like the fact that I’m using either, but I currently value the features that it provides over what it can control (when using proprietary software, I ensure that internet is turned off, and I don’t have any other software open). Later, once I find OSS alternatives for the music software I’m using, and when I detach myself from video games (I only really play Deus Ex Human Revolution …. it’s a good game, with an amazing soundtrack xD), I will probably finally use 100% libre software (minus the BIOS) on all of my machines.


Lastly, I would like to address the fact that libre software is only one part of the issue in having control over your computer. While it is possible to have full freedom in every single way for software, there are two other major issues: Hardware, and Internet.

Hardware is very difficult, since you can’t easily change the hardware. And, in fact, even if you knew the source code (HDL) of the hardware, it would be very very difficult to reverse engineer it in order to make sure that the hardware is indeed following the source code. There are even theories that Intel and AMD CPUs are sending information to the NSA (evasively worded responses from the companies give credence to this theory). Whether or not this is true is outside the scope of this article, but the point is, hardware is a very big issue, and I think the only true answer that would guarantee that the source code truly is the hardware, would be to create your own hardware. I think it goes without saying that this would be very very difficult. Maybe with the rise of 3D printers this will someday change … who knows!

Internet is the other issue. The internet is a way to access ports from foreign computers. Unless you own the foreign computer, there is no way of guaranteeing that your data will be safe with them. They can do anything they want with the data you send. Getting away from services that are known to spy on you and otherwise harm you (such as Facebook) can be a difficult task, depending on how connected you are with the service. In Facebook’s case, everyone is on Facebook, because everyone is on Facebook. Leaving it can be difficult, since you have to sometimes migrate family members and friends to other websites (same point as I made with Skype).


I hope that you found this post useful! I’m sure a lot of points in here may be wrong (please correct me!!), but I have tried my best in order to make sure that this can be as informative and accurate as possible to those that are new to the concept of software freedom. I know I have missed a lot of other important points in here, but I’m not sure where, or if they should be mentioned, so I will link articles containing those below.

If you have any questions, comments, corrections, or anything else (as long as it is constructive, of course!), please feel free to leave a comment or send me an email!


Further reading:

http://www.gnu.org/philosophy/free-sw.en.html (a very good explanation on what the Free Software Foundation considers libre software)
https://www.youtube.com/watch?v=Ag1AKIl_2GM (a talk by Richard Stallman, founder of the GNU project, about software freedom)
http://www.gnu.org/distros/free-distros.en.html (a list of completely libre GNU/Linux distributions)
https://libreplanet.org/wiki/List_of_software_that_does_not_respect_the_Free_System_Distribution_Guidelines (a list of software that are free and open-source, but not libre … yes, Linux contains non-free code!)

Creating an orchestral track under Ubuntu – Part 4: Designing the track

Part 5: Upcoming

This is by far the hardest/most time consuming part of creating, well, any kind of track (okay, almost any kind…). So without further ado, let’s dive into it! Oh yeah, quick note, I have next to no knowledge whatsoever in music theory, so if I use the wrong terms and such, please forgive me! The advice I’m giving here is mostly from my own observation of “epic” orchestral/soundtracky tracks I’ve listened to, so, well, don’t expect a perfect guide here :P

The first part you should always start with is to figure out the big picture of the track… or, if you want, the “outline”. The most common outlines (that I observed) would be:

  1. ABA – Two sections, A, and B. You should be able to tell where you run the sections from the name XD . This is the one I used in Muffin Factory (though the last A section was very short).
  2. Theme, slowly “crescendoing” to the climax? – Not sure how to call this, but AFAIK, this technique is probably the most used by Clint Mansell (the musician who made the Requiem for a Dream theme). Or rather, Mansell uses it in nearly all of his soundtracks lol. This technique, as you can probably tell, is very powerful when used well (and when you have the appropriate breaks, because if it simply crecendoes without any kind of break, it becomes extremely boring).
  3. AB – Two sections, A being the intro, and B being the actual track itself. This is probably the most standard one used

Okay, let’s assume we have an outline now. So now we have to get a musical seed/theme (though for some, it may be better to do this before figuring out the outline). Since this tutorial is for creating “epic” orchestral tracks (i.e. more like battle scene-type stuff than emotional or classical stuff), I will only focus on a couple. I know that my suggestions are not too helpful, but this is because seeds are the most subjective parts of creating a track. It’s very hard to create guidelines for seeds.

  1. Battle theme. The musical seed should be short, suspenseful, and should NOT be in major. This will repeat a lot, with variations, so make sure that it’s not ultra complex either (in “epic” orchestral music, simplicity is key). Remember that what makes a battle theme “epic” is almost always the percussion element, so the seed is less important than the percussion itself.
  2. Victory battle theme. This is NOT a victory theme, this is a victory battle theme. The difference, put in movie terms, is that a victory theme is AFTER the battle, and a victory battle theme is IN the battle, but the good guys are obviously going  to win (Listen to “I am the Doctor” to see what I mean). Okay, enough talk. Basically, this is usually in the major key (but can be in the minor key if you know what you’re doing), and short (but it doesn’t have to be as short as a pure battle theme). It doesn’t have to be too suspenseful either (for rather obvious reasons). Also, though percussion is still very important here, it’s much less of a key element than in a battle theme, so do spend more time making sure the theme is good.
  3. Theme song. This is my favourite, as you’re really not limited to anything! This can be almost literally whatever you want (FINE, I take that back, you’re NOT allowed to use a happy hardcore melody … geesh). So no guidelines here, just what you think is best for the theme you’re trying to make (e.g. don’t use a major key on a dark theme XD). Actually, I’ll take that back too… there is still one guideline: Don’t make it complex. Adding complexity to it will really degrade the quality of the theme itself, and will stop you from being able to further develop it throughout the track.

Bingo, we now have our musical seed! Or at least, we should have a seed. Now time to figure out the accompaniment! These are the basically the elements you may want to have for the accompaniment:

  • Driver. No idea what’s the correct term for this, but I like to call it a driver, because it drives the track forwards (and, of course, lets you plug in your graphics card as well!). This is usually done in percussion:But it can also be done harmonically (sorry, the sound isn’t too good on this one):
    When done in either (percussive or melodic), it can’t be too interesting or complex, but at the same time, it can’t be too repetitive or boring. Remember, the point is to drive the track forward, and not to direct attention to it (if it’s too interesting/complex, or repetitive/boring, it’ll drive attention to it, and away from the track itself)
  • Basslines. Seriously, this is not only for rock tracks! Use cellos, violas, and basses for this (octaves are very useful when you need to make it “bigger” too).
  • Counter melody. I haven’t really experimented myself in this section, but from what I noticed, it’s very useful for transitions or fillers. I generally shy away from it, due to it sometimes making the melodic part of the track more complicated than necessary (and trust me, you don’t want that in “epic” tracks, it pretty much removes everything that’s “epic” about the track), but it can be useful when used well.
  • Choir. You won’t always want to have this, but if you use it well, it can add a lot to the track. If you don’t use it well (like I did :( ), it’ll make the track sound cheesy. The creation of the choir part is similar to basslines, except that you specify it in chords, not in octaves or single notes (usually).
  • Percussion. Yes, I did talk about this under “Driver”, and it should usually stay there, but sometimes the need for percussion is elevated (e.g. a battle theme), and then percussion becomes as much (if not more) of a key element than the melodic seed itself. So then, it has to try to attract attention to it (as compared to it being a driver, where it tries to attract attention away).

Great! Now that we have all of that sorted out, it’s time to work on the track itself :D

Notice that I didn’t go into any kind of detailed explanation about how you must develop it. That’s for later, for now we just have to “design” the track, not implement it. Put in programming terms, what we’re doing is this: “I’ll make a calculator written in C++, using Qt, and will use standard menubars, and standard buttons for each of the mathematical operators”, NOT this: “I’ll have a file menu, with Save and Quit, an Edit menu containing Cut, Copy, Paste, and Preferences, (insert more talk about menus here), the buttons will be arranged in a grid layout (more talk about layouts), (etc…)”.

P.S. Sorry for posting this so late, I’ve had personal issues lately that kind of made it harder for me to write this.


Part 5: Upcoming

Creating an orchestral track under Ubuntu – Part 3: Setting up your orchestra


This part isn’t really hard, but it takes a lot of time to find good orchestral samples, so I’ll simply list some that I’ve used, or heard good reviews about (and good music from):

  • 3.5GB collection of orchestral soundfonts: Seriously, this is a must-have, even if you have better alternatives! Though it is only 3.5GB (unpacked), it contains a LOT of soundfonts. And I mean, a LOT. And not only orchestral soundfonts (though it is mostly orchestral), so if you need to integrate other types of instruments, it does have some interesting non-orchestral ones in there.
    • Pros:
      • Free!
      • Some of them are somewhat HQ, or at least sampled (Bellatrix, (S)GM, Gothic harp, Hades strings, to list a few… you can easily find which ones are sampled by looking at the filesize (and dividing it by the number of instruments available) )
      • Easy to setup, all you need is a soundfont player (except for Bellatrix, you’ll need to install an sfark extractor)
      • A LOT of soundfonts
      • It’s non-HQ-ness and lack of a rich sound actually makes it a really handy tool when you really don’t need a rich sound.
    • Cons:
      • Most (if not all) of them aren’t HQ
      • None of them have a very rich sound (seriously, though it may sound okay to you, after you use something that’s actually HQ, you’ll see the difference… big time)
      • A LOT of soundfonts … yeah, I copied that over. That’s because of the problem with having too much choice. That’s why I just check the filesize, and get the one with the biggest, since it’s much more likely to be better quality :P
  • ProjectSAM Orchestral Essentials: I don’t really know what to say… the sound quality is amazing, but it’s seriously overpriced. Look, you can barely customize which instruments you’ll use (they come in bundles, which is seriously annoying when you’re trying to have fine-grained control over your track), the settings/effects are not very powerful, and Kontakt (it’s a VST that is needed so that you can use it) takes hours to load under LMMS, plus, the demo version (of Orchestral Essentials) expires after 15 …. MINUTES. Of course, all you have to do is to reload the library from Kontakt (by removing it, then adding it back, which actually takes about 20-50 seconds), but really… I personally don’t find any appeal at all to this one.
    • Pros:
      • Amazing sound quality (probably the best I’ve ever heard)
    • Cons:
      • Totally overpriced
      • Kontakt takes a long time to load under LMMS
      • Demo only runs for 15 minutes before requiring you to manually reload the library
      • No good effects, and those that are included don’t work too well (from my experience)
      • Instruments are pretty much bundled up, no real way to get individual instruments and build a hand-picked “orchestra”
      • Not too many instruments are available either
  • EWQL Orchestra: Please understand that I have never tried this! This review is only from what I’ve heard, both reviews and, well, music XD The sound quality doesn’t seem to be as good as ProjectSAM’s quality (the richness of the tone seems to have been diminished a bit, though I could be wrong), but (I’m not sure if it’s only because of the artists I listened to though) it seems to be able to have more “emotion” to it. Reason why I say that, is that it seems to be able to have different styles of how the instruments are played… I wasn’t really able to get this from Orchestral Essentials, or, for that matter, anything else that I’ve tried. So it may be some kind of technique that I’m not aware of, but it seems to be good in that section. Also, it’s MUCH more reasonably priced than ProjectSAM (their smallest package costs $145, and is 11GB, compared to ProjectSAM’s Orchestral Essentials which costs ~$360, and is 6GB, AND you can customize each instrument individually).
    • Pros:
      • Great sound quality
      • Reasonable price
      • Possible different styles(?)
    • Cons:
      • Still costs a lot
      • The only way to get really good sound quality is to go for platinum (24-bit depth is actually noticeably better quality than 16-bit), which costs a lot
      • No idea if it works on WINE well or not (not a con exactly, but it could be :P)
  • Miroslav Philharmonik: This is the one I use. Why? The sound quality is perfectly decent (not as good as EWQL or ProjectSAM though), it’s rather small (7GB), it contains a complete orchestra (including coughing & sneezing sounds… I’m not kidding!), a decent choir, the VST takes anywhere from 2-5 seconds to load on LMMS (a HUGE reason to use it for me), and the VST itself is very powerful.
    • Pros:
      • Decent sound quality
      • Reasonable price (the demo’s timeout is not too short either)
      • Complete orchestra
      • Small
      • Decent choir
      • VST is very fast to load (and quite responsive too)
      • VST is very powerful (you can layer 16 different instruments, apply 4 effects per each instrument, and each effect, all 20 of them, work very well)
      • Easy to use
    • Cons:
      • Still costs money
      • The choir sounds like as if they just copied over soundfonts from that 3.5GB orchestral soundfont link I shared above. Seriously, they sound very similar, AND, sometimes, it seems like as if they’re just repeating the same choirs, but under different names (for example, FA and AH sound identical… I don’t hear the F at all)!
      • The sound quality could be improved
      • Some of the “solo” instruments are unavailable as an ensemble (e.g. the tuba… yeah, I know, I’m stupid for wanting a tuba ensemble :P)
      • Rather high CPU usage is constant, even when no sounds are being played

I hope this can help someone! I strongly encourage you to do your own research before buying any of these though.

If you use anything else, or have another pro/con for an existing product, let me know, I’d love to make this list more complete!


SythOS – An experimental collaborative OS

A rather long time ago (around a year and a half), I wrote a post about a system I was making which was supposed to be a cloud-based OS, named CosmOS. I didn’t really develop it that much, as I had a rather vague sense of what I wanted to do with it, and I immediately had problems with implementing the most basic concepts. Most of the idea was actually quite boring, and had already been developed by others. But since I had gone through all the trouble of making a tool for creating it (relinux), I decided to try it anyways, and just radically changed the whole design. And I did. I also found that I couldn’t have used the same name, as CosmOS was already the name of at least two different OS’s, and it was also the name of a directory of linux OSs (among other unrelated usages), so I kind of got that I had to change the name.

The name is actually based on two words, Synergy and Lithosphere (I was going to call it LithOS, but it sounded like some kind of boring scientific and/or business-oriented OS, if you know what I mean). I know, kind of an odd combination, and the reasoning for it is a quite far-fetched, but heck, it’s an unused name, and it sounds cool! Lithosphere was used as a creative way to say “ground”, because it’s not cloud-based (unlike CosmOS, in fact), and it’s also designed to be “down to the ground” with you. Instead of you adapting to the OS, the OS adapts to you (will explain how this works later). Also, the Synergy part is because since it’s completely with you, it allows nearly everything to be done much easier and simpler, reducing the amount of time both the users AND the developers need to do nearly everything (except for the engine… :-/).

The OS itself is principally designed under the following goals:

  • Help the user to become more productive within it
  • Extremely intuitive
  • Extremely easy to collaborate on anything
  • Extremely customizable
  • Fun

There is only one software that I’m aware of that does this well: Minecraft (creative mode). Okay, forget the productive element, but still, anyone can pick up the pace on how to use minecraft extremely quickly. Also, if you’ve ever played it, you’ll know how easy it is to collaborate on building something. You don’t need to use a VCS like git or mercurial to build something. Just get someone else on your server, and build together!

That’s kind of my idea with SythOS. You are inside a 3D environment, windows are mapped to 3D surfaces (I had this idea from Wolfenstein Qt, but it appears to already have been implemented: http://www.youtube.com/watch?v=_FjuPn7MXMs), and the environment is modifiable, using a minecraft-like in-game “level editor”. Other people can connect to your computer (if you allow them, of course), and then you can work together on projects (such as coding, audio, video, or even games) at the same time! Of course, for this to be effective, you have to have somewhat compatible software (you can’t both work on the same window for rather obvious reasons), but even if the software you use isn’t “compatible”, taking turns, and being able to see what the other is doing real-time is still way easier than using some kind of VCS or worse, emailing files back and forth, right? Also, with the chat and mic/audio features that are planned, you can also make meetings and/or “calls” (kind of like skype does, except without the video) within it.

Here’s a list of features that are definite:

  • 3D virtual world
  • Windows mapped to the world
  • MMO-like online presence
  • World is Minecraft-like
  • Different tools and blocks (inspired by minecraft)
    • Hand tool: Allows you to do basic edits to windows (such as moving, resizing, and closing), and allows you to use windows, plus allows you to remove blocks
    • Kill tool: Allows you to kill processes, based on the windows you hit, and, of course, allows you to remove blocks
    • Various blocks, which allows you to place them, and remove other blocks, plus allows everything the hand tool allows you to do
    • Portal tool: Allows you to create portals to different rooms, so as to decrease the time needed to go between two different “workspaces”
  • Whitelist, Blacklist and “Asklist” for everything (great for multiple user computers, and/or online interaction)
  • Chat
  • Quake-like terminal with multiple tabs, but it can be used to place any kind of windows, not only terminals

Other features that are planned, but not definite would be:

  • Mic/Audio
  • Some kind of game engine, so you can create 3D objects that interact with the world (though it’s definitely not limited to games, it could even be used to create fancy movie creation software, or 3D modeling software)
  • Facial expression recognition, so your character’s face will match your expression. This is definitely not an important feature, and if it is ever implemented, it will probably be quite far-future.
  • Video… somehow… (no idea how to elegantly do this though)

Now for the point of this post (the reason why I’m writing it): Would you use something like this? If so, or if not, why? Any ideas and/or comments on this?

About the possibility of it being implemented, I know that it is possible, but I’m not sure how much time it’ll take me to do all of this (and I’m not sure if I’ll have the stamina needed to do this). I’m planning on releasing a prototype by the end of this summer (2013) though.

Relinux – An easy way to create a Linux distro

Note: I know this post is a mess, I’m sorry. I’ll try to fix it sometime soon

Note #2: Relinux is now dead: https://lkubuntu.wordpress.com/2014/09/14/im-quitting-relinux/

Remastersys has been around for a long time, and though it hasn’t been updated in a long time (EDIT: It was dead, but now he is maintaining it), many people still use it. Remastersys is very closed in what you can do with it (for example, it’s hard to change the splash image), and sometimes you have to edit the code just to be able to change more options that what is given in the remastersys.conf file.

I created 2 systems with it (one personal and one public), and I didn’t like the lack of options, so I decided to make my own script based on it, to give much more customization. Though it is still at a beta stage, it gives many more options, and much more usability.

The goal for relinux is to let someone make his own Linux distro easily, while the goal for remastersys is to make personal distros and backups.

To install, download the latest tar.gz file at https://launchpad.net/relinux. Untar it, and follow the instructions in the INSTALL file.

You can customize the system as much as you would like, except for these limitations (most of which will be removed in a future release):

  • It only supports GRUB2, so no BURG or GRUB-Legacy
  • It must have an X11 display, since Ubiquity (the installer) requires X11 to run
  • You cannot use another installer than Ubiquity
  • The compressed filesystem size must be below 4GB (no workaround). It will tell you if it’s over 4GB (compressed), but I recommend that you keep your system size below 6GB (uncompressed).
  • It will install metacity, but in 0.3, this is removed.
After you have customized your system at your liking, you will need to create a configuration file. To do this, simply type in a Terminal window:
cp /etc/relinux/relinux.conf ./relinux.conf
sed -i 's:EXCLUDES="\(.*\)":EXCLUDES="\1 '`readlink -f ./relinux.conf`'":g' ./relinux.conf
readlink -f ./relinux.conf

The last command will tell you where the configuration file is located. Edit that file to your liking. Some splash screens are located in /etc/relinux/relinux/splash.
Before you start editing, if you want to save your settings/themes, do this (replace USERNAME by your actual username):
  1. Press CTRL+ALT+F3
  2. Log in as your normal user
  3. Type: sudo passwd
  4. Enter a password for root
  5. Type: exit
  6. Log in as root (with the password you gave for root)
  7. Type: usermod -d /etc/skel USERNAME; chown -R USERNAME /etc/skel
  8. Reboot your system (can be done with the reboot command)
Then you can log into your normal user, and all of your changes to the theme, desktop background, panel configuration etc… will be saved.
Once you have finished editing it, you will want to create the ISO file, so type this into the Terminal window:
sudo relinux fullclean ./relinux.conf
sudo relinux iso ./relinux.conf
The last (and final) step will take a while.
Simply follow the directions (if there are any).

I decided to make a comparison chart with Relinux and Remastersys:

Relinux Remastersys
Actively Developed T T
DIST/ISO mode T T
Backup mode T (will be removed in 0.4, as remastersys is good for the backup mode, relinux is not) T
Splash Image Customization T F
Can use T T
GUI F (will add in 0.4) T
WUBI T F
Language BASH (will be Python in 0.4) BASH
If you have any questions/comments, feel free to leave a comment on here!

Make XFCE4 Bottom Dock look like Docky/AWN

I recently installed XFCE 4.8, and I was happy with it, except that I didn’t like that the top panel had the window list, and the bottom dock was just a launcher.

I decided to move the window list at the top to the bottom panel, and remove the launchers.

Screenshot: http://img24.imageshack.us/img24/4427/panel20screenshot.png

To change your panel configuration to the one that the screenshot shows:

  1. Type this into a Terminal window
    xfce4-panel -q
    killall -KILL xfconfd
    killall -KILL xfsettingsd
    cd ~/.config/xfce4/xfconf/xfce-perchannel-xml/
    mv xfce4-panel.xml xfce4-panel.xml.bak
    wget http://dl.dropbox.com/u/21016209/xfce4-panel.xml
  2. Log out and log back in (killall -KILL xfce4-session)

If you have any problems, feel free to comment below.