Skip to main content

Ralsina.Me — Roberto Alsina's website

Schizo Desktop IV: Audio

I have an of­­fice. It's like a home of­­fice but it's in an­oth­er place. It's just mine, so I get the peace and qui­et of a home of­­fice but al­­so get to go out­­­side to get there. It's a good set­up.

BUT I have two com­put­ers there. Well, ac­­tu­al­­ly I have like 10, but I in­­ter­act with two. One is my per­­son­al desk­­top com­put­er, the oth­­er is my work lap­­top. and I want to use the same pe­­riph­er­als in the same way with both of them. That's why I have the world's most com­­pli­­cat­ed schizo desk­­top set­up.

This se­ries of posts will doc­u­­ment it, the why and how of it, and the var­i­ous things I've learned along the way, along with mak­ing you want to buy weird chi­­nese gad­get­s.

Today: Audio

As in the rest of this se­ries, some­thing that usu­al­ly is very sim­ple be­comes a bit com­pli­cat­ed be­cause I want to use the same pe­riph­er­als with two com­put­er­s.

In the case of au­dio it's even worse be­cause I want to use dif­fer­ent de­vices de­pend­ing on con­tex­t.

The Requirements

  • I want to list­ed to both com­put­ers with­out head­set­s, be­cause I don't like wear­ing head­sets for long.
  • I want to be able to lis­ten us­ing head­sets if I want to, to take ad­van­tage of noise can­celling and to be qui­eter.
  • I have a good mi­cro­phone, I want to use. I don't want to use the bad ones, like my we­b­cam's, or my note­book's.

The Hardware

  • Speak­er: a lar­gish speak­er with a 3.5mm jack, hang­ing from the bot­tom of my desk, in­vis­i­ble.
  • Mi­cro­phone: a XLR con­denser mi­cro­phone (means it needs 48v phan­tom pow­er!)
  • Head­set: Blue­dio Hur­ri­cane H2 (with ca­ble!)

The head­set and mi­cro­phone switch com­put­ers as de­scribed in a pre­vi­ous post BUT how does a XLR mi­cro­phone con­nect to a com­put­er?

You need an au­dio in­ter­face. I have a su­per cheap chi­nese one:

The v8 live sound card

This plugs to a com­put­er via USB and works as a sound card, with in­put and out­put.

BUT it's not just a sound card, it's a mix­er. It has con­nec­tors for:

  • 2 Con­denser mi­cro­phones (yes, with phan­tom pow­er)
  • 2 "Ac­com­pa­ny" in­put­s, which are stereo line in­puts
  • Blue­tooth in­put
  • Mon­i­tor: this is a stereo out­put that is a mix of all in­put­s, so you can lis­ten to ev­ery­thing that's go­ing on.

It has vol­ume con­trols for "ac­com­pa­ny" / "mic" / "mon­i­tor" and a cou­ple nice LED feed­back light­s.

It al­so has a bunch of ef­fect­s, like re­ver­b, echo, sil­ly sound­s, etc. which I don't use.

That au­dio in­ter­face is the hub of my au­dio set­up. Usu­al­ly it's con­nect­ed to my work com­put­er with the mi­cro­phone, but I can switch it over to my per­son­al PC.

My per­son­al PC is con­nect­ed to it via BT, and the mon­i­tor out­put is con­nect­ed to the speak­er.

The head­set is a sep­a­rate usb de­vice for per­son­al pref­er­ence.

The Software

Not much need to do any­thing spe­cial with two ex­cep­tion­s:

  1. Dis­able all the au­dio in­ter­faces I don't want to ev­er use.
    • HD­­MI au­­dio out­­puts
    • We­b­­cam's mi­cro­­phone
    • Head­­set's mi­cro­­phone
  2. Use rofi-­sound-pick­er to choose where the sound goes. I use it most­ly to switch from speak­er to head­phones.

Rofi Sound Picker

The Routing

In work mod­e:

  • Both PCs sound via the au­dio in­ter­face and the speak­er con­nect­ed to its mon­i­tor out­put:
    • Per­­son­al PC via BT
    • Work PC via USB
  • Mi­cro­phone is con­nect­ed to the au­dio in­ter­face and is used by the work PC (and se­lect­ed in team­s/­zoom/etc as in­put)
  • Head­set is con­nect­ed to the work PC and I can change to it us­ing the rofi-­sound-pick­er

In Per­son­al mod­e:

The same as work mod­e, un­less I want to record some­thing, in which case I switch all the au­dio to the per­son­al PC and just pick and choose.

Conclusion

This is worth it even if all I got was both PCs com­ing out of the speak­er. The rest is good and a bonus.

Schizo Desktop III: Monitors

I have an of­fice. It's like a home of­fice but it's in an­oth­er place. It's just mine, so I get the peace and qui­et of a home of­fice but al­so get to go out­side to get there. It's a good set­up.

BUT I have two com­put­ers there. Well, ac­tu­al­ly I have like 10, but I in­ter­act with two. One is my per­son­al desk­top com­put­er, the oth­er is my work lap­top. and I want to use the same pe­riph­er­als in the same way with both of them. That's why I have the world's most com­pli­cat­ed schizo desk­top set­up.

This se­ries of posts will doc­u­ment it, the why and how of it, and the var­i­ous things I've learned along the way, along with mak­ing you want to buy weird chi­nese gad­get­s.

Today: Monitors

I have at least three mon­i­tors for my two com­put­er­s. It can get more com­pli­cat­ed than that, but let's just lim­it this to the "ba­sic­s".

Be­cause one of the com­put­ers (my work one) is a note­book, it has its own mon­i­tor. Then I have two reg­u­lar mon­i­tors, both 1080p, one of them land­scape and the oth­er por­trait.

This is how that look­s.

The three monitors described above

This would nor­mal­ly be just a mat­ter of plug­ging them in the right com­put­er, but ... in my case there is no right com­put­er!

When I am work­ing, I want the mid­dle mon­i­tor to be con­nect­ed to my work lap­top, and when I am not, I want it con­nect­ed to my desk­top.

The right­most mon­i­tor I al­ways want for my desk­top (usu­al­ly play­ing mu­sic or videos while I work) and of course the lap­top keeps con­trol of its own screen.

Ad­di­tion­al­ly I want to be able to spo­rad­i­cal­ly con­nect ran­dom com­put­ers (like rasp­ber­ry pis) and have them show up on a mon­i­tor.

Now it's not so ob­vi­ous, right?

Enter The HDMI Matrix

This is a 4x2 HD­MI ma­trix. It has 4 in­puts and 2 out­put­s. That means it can get 4 dif­fer­ent video sig­nals and will route them to 2 dif­fer­ent mon­i­tors in a com­plete­ly ar­bi­trary man­ner.

  • Want in­put 1 in both out­put­s? Sure.
  • Want in­put 1 in mon­i­tor 1 and in­put 2 in mon­i­tor 2? Sure.
  • Want it the oth­er way around? Sure.

It's to­tal­ly over­pow­ered for what I need, which could be done with a sim­pler 4x1 switch, but hey, it's nice.

So, I have 4 in­puts con­nect­ed:

  1. My desk­top com­put­er
  2. My desk­top com­put­er
  3. My work lap­top
  4. A ca­ble that I can reach un­der the desk­top

The out­puts are con­nect­ed to the mid­dle and right­most mon­i­tors in the desk re­spec­tive­ly.

When I work, the con­fig­u­ra­tion is in­put 3 in the mid­dle mon­i­tor, in­put 1 in the right­most mon­i­tor.

When I am not work­ing, it's in­put 2 in the mid­dle mon­i­tor, in­put 1 in the right­most mon­i­tor.

When I have a rasp­ber­ry I want to look at for a mo­men­t, that's in­put 4 to the mid­dle mon­i­tor.

Of course there is an­oth­er prob­lem:

The por­trait mon­i­tor does­n't know it's on its side. So ev­ery­thing is ro­tat­ed 90 de­grees when shown there.

Enter AutoRandr

Au­toRan­dr is one of those tools once you have it and use it you can't live with­out it.

It saves the cur­rent mon­i­tor con­fig­u­ra­tion and can re­store it when­ev­er it sees the same mon­i­tors plugged in­to the same out­put­s.

So, just make it look nicein "work mode", and configure all the monitor rotations and so on, then autorandr --save work.

Then, when you are not working, make it look nice again, and autorandr --save home.

Have to do that in both com­put­er­s, of course.

From then on, when­ev­er the switch changes things around, au­toran­dr au­to­mat­i­cal­ly re­con­fig­ures the mon­i­tors the right way on both com­put­er­s.

The on­ly prob­lem is that to switch from home con­fig to work I would have to do things like "click on the B but­ton of the ma­trix thing un­til is says "3", then click on the A but­ton un­til it says "1" and it's bor­ing.

Enter the Remote

As you can see in the pre­vi­ous pic­ture, the ma­trix has a re­mote. It's a sim­ple re­mote, with 8 but­ton­s, one for each in­put/out­put com­bi­na­tion.

I could just use the re­mote to switch be­tween work and home con­fig­u­ra­tions, but that's bor­ing too.

So, I use soft­ware to drive an in­frared emit­ter that switch­es things around when I click a but­ton in the macro key­board or flip a switch on a web­page.

But that's for an­oth­er post.

Schizo Desktop II: Keyboard and Mouse

I have an of­fice. It's like a home of­fice but it's in an­oth­er place. It's just mine, so I get the peace and qui­et of a home of­fice but al­so get to go out­side to get there. It's a good set­up.

BUT I have two com­put­ers there. Well, ac­tu­al­ly I have like 10, but I in­ter­act with two. One is my per­son­al desk­top com­put­er, the oth­er is my work lap­top. and I want to use the same pe­riph­er­als in the same way with both of them. That's why I have the world's most com­pli­cat­ed schizo desk­top set­up.

This se­ries of posts will doc­u­ment it, the why and how of it, and the var­i­ous things I've learned along the way, along with mak­ing you want to buy weird chi­nese gad­get­s.

Today: Keyboard and Mouse

I have 2 key­boards and no mouse. In­stead of a mouse I have a track­ball but for all prac­ti­cal pur­pos­es ... 1 mouse.

A keyboard, a mouse and a tiny keyboard

How do I use them with two computers?

The an­swer is Bar­ri­er which runs a serv­er in my per­son­al ma­chine and a client in my work lap­top.

With it run­ning, I can just slide my mouse to the edge of the screen of one com­put­er and it will ap­pear in the screen of the oth­er com­put­er. It's like mag­ic.

I can even copy­/­paste be­tween them trans­par­ent­ly, I just can't move win­dows across the fron­tier for ob­vi­ous rea­son­s.

How do I use them with random computers?

My key­board has 3 mod­es:

  • Wired (al­ways con­nect­ed to my per­son­al com­put­er)
  • Blue­tooth for up to 3 de­vices (not con­nect­ed to any­thing)
  • 2.4Ghz don­gle (not con­nect­ed to any­thing)

So, if I have a ran­dom com­put­er (say, a rasp­ber­ry pi I need to de­bug) I can just switch the key­board to use the 2.4Ghz don­gle, plug it in­to the com­put­er and use it that way.

What about the tiny keyboard?

That's macros. The wheel is vol­ume, and al­so con­trols my lights and oth­er things. The but­tons do things like con­trol my air con­di­tion­er.

It's a su­per cheap chi­nese one, and they have re­cent­ly be­come con­fig­urable in Lin­ux, which is al­ways nice.

Why a trackball?

Why not a track­bal­l?

Any special keyboard configuration?

Oh yes. because it's a 65% keyboard I have to choose between having an escape key or a ~ key.

So I chose both, and mapped escape to the caps lock key.

So when I start my ses­sion I run this:

# Map caps lock and esc to proper keys
xkeysnail --watch --devices "ROYUAN GamaKay 68" .config/xkeysnail/config.py &
sleep 1

setxkbmap -model pc104 -layout us -variant altgr-intl -option

The xkeysnail tool configures this keyboard (and only this keyboard) using this file:

from xkeysnail.transform import *

# define timeout for multipurpose_modmap
define_timeout(1)


# [Global modemap] Change modifier keys as in xmodmap
define_modmap({
    Key.CAPSLOCK: Key.ESC,
    Key.ESC: Key.GRAVE
})

So I get escape in the caps lock key, and ~ in the esc key.

Then setxkbmap configures a us international keyboard layout with the altgr-intl variant, which is the one I like.

Conclusions

This one is not very weird, oth­er than the re­liance in a sin­gle key­board and a track­bal­l. If you use mul­ti­ple com­put­ers in your set­up I rec­om­mend Bar­ri­er, it's a great tool.

New Project: FaaSO

Be­cause yes, all self­-host­ed FaaS so­lu­tions suck this week­end I wrote the be­gin­nings of a new one, called Faa­SO.

Is it go­ing to be great? Prob­a­bly not, but it's go­ing to do ex­act­ly what I need it to do. Be­cause the best part of rein­vent­ing the wheel is that by the sec­ond left el­bow of Kali, this wheel is go­ing to be ex­act­ly the shape I like.

Faa­SO has very strict de­sign con­straints:

  1. It needs to be easy to use. I need to be able to write a funko (func­tion in Faa­SO par­lance) in a minute and de­ploy it with one com­mand, and I won't have to con­fig­ure any­thing for that funko to work.
  2. It will run in a sin­gle ma­chine, it will de­ploy in a min­ute, and it will be ready to take new de­ploy­ment re­quests right away.
  3. It will have some sort of se­cret man­age­ment API
  4. It will sup­port mul­ti­ple lan­guages, be­cause I want to use dif­fer­ent lan­guages.
  5. It will have very lit­tle mag­ic. It will not lock you in­to need­ing it.
    • You should be able to take a funko and make it a sep­a­rate app in a minute
    • You should be able to con­trol what you are run­n­ing, and how it run­s, and mon­i­­tor it and so on with­­out go­ing through the tool if you wan­t.
  6. It will be small. My cur­rent goal is un­der 1500 LOC.
  7. It's aimed at de­ploy­ing one ten­ant. It will not pro­tect one funko from a hos­tile funko run­ning in the same sys­tem. It will not pro­tect you from your­self.
  8. In the same way, it will be as se­cure as I can make it against ex­ter­nal threat­s, but it's not go­ing to pro­tect you from some­one with ac­cess to the same sys­tem.
  9. It will be light. I am writ­ing it in Crys­tal so it's na­tive code and runs with very lim­it­ed de­pen­den­cies and lit­tle over­head.

Can I do all that? Maybe. The cur­rent pro­to­type does about half of what I wan­t, so there is on­ly an­oth­er 90% of the work left :-)

If you want to check the pro­to­type, it's here, I am not look­ing for con­trib­u­tors now be­cause I want a free hand on sud­den re­design.

There is some doc­u­men­ta­tion about how it works here and some brain­dump about the se­cret man­age­ment as well as the ini­tial brain­dump about de­sign

All Self-Hosted Faas Solutions Suck?

I have a few small projects where I need a serv­er as back­end. That means I need to run a server, which usu­al­ly means I need to do a lot of stuff. BUT these are as­ton­ish­ing­ly sim­ple back­end­s. Usu­al­ly just one end­point, which does one thing.

For ex­am­ple, con­sid­er nom­bres a web­site where you can ex­am­ine his­tor­i­cal in­for­ma­tion about names in Ar­genti­na. Like, how has the pop­u­lar­i­ty of the name "Juan" changed over time?

Like this:

The name Juan is the most popular male name in Argentina

That is lit­er­al­ly one func­tion that takes as ar­gu­ment names, does a cou­ple of queries to a database, builds a chart and re­turns that. De­ploy­ing that should not re­quire me set­ting up in­fra­struc­ture spe­cial­ly be­cause I have like 5 or 10 of those and they are ac­cessed 10 times a day or so.

If I were to use "the cloud" the so­lu­tion would be to use AWS Lamb­da, or the sim­i­lar clones in Azure or Google Cloud. But I don't want to pay for things, so I looked for a way to do that in my own server, which I al­ready have and has more than enough pow­er to han­dle it.

So, I did it! I used faasd which lead to a whole slew of prob­lems that you can see in this post.

Ba­si­cal­ly faasd hates shar­ing the ma­chine it's in with any­thing else, so I seg­re­gat­ed it to a VM us­ing Ig­nite. Now, I am con­sid­er­ing mov­ing to a new­er, more pow­er­ful serv­er (A Radxa Rock 5C) and I look at set­ting up Ig­nite and ... it's ob­so­lete.

It says the re­place­ment is Flint­lock­... which is "on hold", which means aban­doned.

So I try set­ting up a VM us­ing lib­virt, but since this is ar­m64, things are a bit com­pli­cat­ed, so I say, damn, let's just use QE­mu, which works ... as long as I don't use KVM, be­cause it makes the VM su­per flaky.

So I can choose a su­per flaky VM, or a very slow VM, or use ob­so­lete soft­ware, all be­cause I want to run a func­tion that takes a few sec­onds to run and is ac­cessed 10 times a day and faasd is needy.

So, I say­d, what the heck, faasd can't be the on­ly thing. Let's look again!

  • Open­Faas: by the same peo­ple as faas­d, needs ku­ber­netes, way overkill
  • Fx: looks good and sim­ple, lit­er­al­ly does­n't work.

You don't be­lieve me? Here is what hap­pens when I fol­low the in­struc­tions to run fx, on a nor­mal x86 ma­chine:

> curl -o- https://raw.githubusercontent.com/metrue/fx/master/scripts/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1471  100  1471    0     0   4138      0 --:--:-- --:--:-- --:--:--  4143
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  8635  100  8635    0     0  17948      0 --:--:-- --:--:-- --:--:-- 17914
Downloading fx from https://github.com/metrue/fx/releases/download/0.9.48-alpha.d91a7a0/fx_0.9.48-alpha.d91a7a0_Tux_64-
Download complete, saved to /home/ralsina/fx/fx.tar.gz
Installing fx to /home/ralsina/fx
fx
fx installed successfully at /home/ralsina/fx
fx version 0.9.48
Cleaning up /home/ralsina/fx/fx.tar.gz

> cat > func.js
module.exports = (ctx) => {
  ctx.body = 'hello world'
}

> ./fx up -p 8080 func.js
2024/06/28 10:52:54  info provisioning localhost ...
*****************
exit status 125
*****************

I spent an hour or so on it, it just does­n't work.

What else is out there?

  • Apache Open­Whisk looks promis­ing, I will try it out nex­t, need to see if it works in my re­source-lim­it­ed serv­er.

If it does­n't work out I swear I am rolling my own.

UP­DATE: Looks like I am rolling my own:

it needs kafka and couchdb?


Contents © 2000-2024 Roberto Alsina