Auto-aligning Csound scores using "column"

2014-12-13

Column is a command I wished I had learned about many years ago when I first started using Csound, because it can automatically align csound score files.

Here is a score file with unaligned p-values. It is very difficult to read:

i1 0 0.25 64
i1 0.25 0.25 64
i1 0.75 0.25 64
i1 1.25 0.25 60
i1 1.5 0.25 64
i1 2 0.25 67
i1 3 0.25 55

If we were to save this to a file called unaligned.sco, we could generated a an aligned score file with the command:

column -t unaligned.sco > aligned.sco

The produced file aligned.sco would look like this:

i1       0     0.25  64
i1       0.25  0.25  64
i1       0.75  0.25  64
i1       1.25  0.25  60
i1       1.5   0.25  64
i1       2     0.25  67
i1       3     0.25  55

Since column can read from standard input, it can be also be used to modify scores inside of vim, which can be helpful if you are working with .csd files. Inside of vim, select the score you want to be aligned using visual mode (shift+v) and then type :!column -t. This will pipe the text selection to column, and then be returned as an aligned column.

Happy Csounding!

-P