Skip to main content

Posts

Showing posts from March, 2020

Ansible: how to read a data file

Let's say I have a data file, each line contains several columns. I want to read the file line per line, select the columns. My data file abc 123 def 32 alice ghi 12345 alice bob The idea is to loop on the file line per line with the splitlines function: loop: "{{ lookup('file', '/path/to/file').splitlines() }}" Then, for each line, we split the columns based on a separator, and we put the result in a variable: myvar: "{{ item.split( sep , maxcol ). index }}" Where: sep is the separator maxcol is the maximum number of columns you want to use. If a line contains more columns that maxcol , the last column contains the rest of the line. index is the index of the current column. So the overall playbook will looks like: - name: ... vars: A: "{{ item.split(' ',3).0 }}" B: "{{ item.split(' ',3).1 }}" C: "{{ item.split(' ',3).2 }}" function: ... loop: "...

MIDI for Linux

I want to drive MIDI with my Ubuntu. The context I play MIDI with Atari since 1986; at first a STF (1MB RAM), now a STe maxed to 4MB. Four megabytes of RAM may seems ridiculous by today's standards, but MIDI is extremely compact and use very few memory. Moreover, on the Atari, the operating system is in ROM, which limits the footprint on RAM to variables; hence, 4MB is actually plenty of room. The Atari has a built-in MIDI interface (1 In, 1 Out) driving 16 channels. However, in my case, 16 channels is not enough, so I purchased a MIDI interface (Soundpool MO4) which adds 4 outs, allowing to drive 80 channels. Unfortunately, 2-3 years ago, the MO4 has stopped working: still recognized by the Atari, but no output. Ok, well, this is another topic... In the past, I also got an old Toshiba Elite laptop running Windows XP. I tried to play MIDI with it. I first purchased a E-MU 2x2 interface (1 in, 1 out). Then I had the opportunity to buy a Midiman Midisport 4x4 (4 ins, 4 outs)...