Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

I Tried Linux as My Main Dev Environment but Was Forced Back to Windows

i-tried-linux-as-my-main-dev-environment-but-was-forced-back-to-windows.jpg

For years I've been running Linux in VMs or WSL but I wanted to give native Linux a shot. It didn't work out due to audio issues.

Quick Jump:

Since about 2012 I’ve been running Windows but then running Linux in a VM or more recently with WSL, or even more recently with WSL 2.

The main things holding me back from native Linux were screencast editing tools and video games, but having discovered the power of KVM based VMs with a GPU passthrough, I think both problems can be solved which would allow me to run Linux natively, and then use a Windows 10 VM for editing videos and playing games.

So naturally I formatted my main desktop workstation even though my next course is about 80% done being planned out. I figured with this new Linux set up, I would finish the last 20% and then record it, and it would be glorious.

The last 20% would give me plenty of time to get used to the new environment. It was the best plan ever, but like Mike Tyson once said, “everyone has a plan until they get punched in the mouth”.

# The Linux Set up

I didn’t really get a chance to trick out everything, but here are the main components that I picked for my Linux based development environment.

Operating System

As you probably know I’m a huge fan of Debian, so I picked Debian unstable as my OS of choice. I went with unstable instead of stable because I wanted a rolling OS with up to date packages. Remember, this is for my dev box. In production I would always go with the latest Debian stable release (or Ubuntu LTS).

Window Manager

After witnessing i3wm in a screen sharing session with a friend, I was immediately hooked. i3 is exactly what I want to manage my windows.

i3 is a tiling window manager that also supports multiple workspaces. It gets out of your way but has a ton of useful features. I kept thinking to myself “I wonder if I can do…”, then I would check their docs, and yep, they had that feature.

If I were to develop my own GUI for managing windows from scratch it would be like 99% of what i3 is, which is really something else because I’m really picky with a lot of things.

Here’s a video someone else made which gives a nice overview of what i3 lets you do:

Everything about it is super streamlined:
  • Tiling windows by default but you can float them if you want.
  • Multiple workspaces that can be created and removed, and it’s really easy to move windows from 1 workspace to another, and it works flawlessly with multiple monitors.
  • Great status bar / task bar with a way to launch apps by searching.
  • Make it look however you want (many different color / layout choices).
  • Everything is controlled with a config file that is well documented.

I found myself setting up custom hotkeys to do all sorts of things. I had ffmpeg set up with a hotkey to where I would hit 1 key to start a recording and it would put a little microphone icon in my status bar and then if I hit another key, it would stop the recording.

Little things like that were really easy to set up with a few lines of Bash.

It really felt like a programmer’s dream environment. You could set up many custom things to help you get your work done. Where as with Windows, it feels like everything is super opinionated and tries to get in your way as much as possible.

Terminal

I went with the good old trusty xterm. With a little bit of configuration it looks great, it handles URL clicking, allows for hotkeys to control font size, has good Unicode support and it was faster than anything imaginable.

Opening a new terminal was under 250ms, and typing felt like you’re on air. I’ve written about input delay when comparing terminals on Windows. It is really important.

The default WSL terminal is almost as fast as xterm, but even after years of development it’s still missing critical features like not being able to invert the cursor color over text (so you can see the character under it), and I get a lot of visual bugs on a day to day basis, like sometimes after closing Vim the terminal screen will turn a different color.

This is a common theme with Windows. It’s like we have all of these things that almost work, but they have enough bugs to always make you want to look for something better instead of being very happy with what you have.

# Linux Is More Than Just Using Linux

That is a funny title but that’s how I feel. Your entire mindset changes. The Linux community is so open and helpful. You often have a direct link to the people who created the tools you use because most things are open source.

Not only that, but there’s this mentality of abundance. With Windows, most things are closed source and you have few options for many critical components of your OS, but with Linux, you can do pretty much anything you want.

But there’s also a different type of abundance vs scarcity at play here. With Windows, the entire OS slows down over time because of how the Windows registry works. Every time you install something, even if you uninstall it, it likely has a negative effect on your entire system.

That’s why after a few years, you typically need to format your box. With Debian (and other distros), it’s a different story. There’s no centralized registry like Windows. In the worst case scenario you have some config files laying around that do no harm to the efficiency of how the OS runs.

With Windows, I find myself not wanting to try out software because I know anything I install is negatively impacting the health of my system even if I remove it.

Your OS Molds You as a Person

This is going to sound crazy but I think if I were using Linux for the last 10 years I would be a totally different person. Almost everything about it promotes certain traits that make you a better human being. Not only to others, but yourself too.

If you’re constantly making scarcity driven decisions, such as being forced to use Window’s choices for certain things, or accepting bugs because “that’s the way it is”, then I think it eventually molds you into a person who has these traits outside of computing.

Maybe I’m reading into it too deeply but if you constantly surround yourself with people who are positive and promote a certain type of behavior then you will very likely mold into that type of person over time.

I don’t think it’s any different with using computers.

If you spend 8 hours a day working in an environment where you’re constantly having to compromise, settle for something worse, knowingly use something that is violating your privacy and always think “is there something better?” – that’s not a healthy lifestyle.

After having used Linux natively, I feel like I’ve been made aware of the Matrix.

Your OS Becomes Your Friend, Not Your Dictator

With Windows, it always feels like you need to work around its rules and limitations. It’s not really there to help YOU get YOUR work done. It’s there to generate revenue for Microsoft and Microsoft’s partners while being general and stable enough to not be total garbage.

Where as with Linux, you get a totally different vibe from the OS. Like with the i3 set up, I found myself adding in little shortcuts and scripts to help me make things more efficient for the work I do. I felt like I was designing OS features for me, which is a great feeling to have.

For example, I’ve been blogging for years, but my Windows work flow for creating a new draft involved opening up Windows explorer, navigating to my site’s drafts folder, right clicking inside of Windows explorer, creating a new file, naming that file, opening that file in VSCode, and then writing down the idea I had for a post.

That is one hell of an annoying work flow just to create a file in a specific folder, but when your OS is based on using windows and the terminal is really just a slap-on attachment, that’s how you think about things.

It literally took me 1 day of using i3 to think to myself. What the heck am I doing? Why not just make a 15 line bash script where I can type drafts some cool idea and have it create the file in a specific folder?

So that’s what I did. 10 minutes later I had this:

#!/bin/bash
# Create a dated Markdown file at a specific location.
#
# Usage:
#   $ drafts some post idea
#
# Produces:
#   YYYY-MM-DD-some-post-idea.md in your $DRAFTS_DIRECTORY (this is set below).

set -e

# Edit this to match your environment.
readonly DRAFTS_DIRECTORY="/d/src/sites/nickjanetakis/_drafts"

readonly DRAFTS_FILE="$(date +%Y-%m-%d)-${*}.md"
readonly DRAFTS_PATH="${DRAFTS_DIRECTORY}/${DRAFTS_FILE// /-}"

if [[ $# -eq 0 ]]; then
    ls "${DRAFTS_DIRECTORY}"
    exit 0
fi

if [ -e "${DRAFTS_PATH}" ]; then
    eval "${EDITOR}" "${DRAFTS_PATH}"
else
    touch "${DRAFTS_PATH}"
fi

So now whenever I have a new blog post idea, I just run the script and I get a nicely dated and titled file in the correct directory. This isn’t disruptive at all. It encourages me to make more drafts because creating the draft isn’t annoying.

It also encourages me to share code because maybe with a bit of clean up, that could end up in a git repo and placed onto Github so others can use it.

And on top of all of that, I also got a chance to improve my Bash skills.

Not only that but it’s a superior solution to what I was doing in Windows because knowing when I made the draft is beneficial because I never thought to even add the date to the file before. Just switching my brain to think “how can I automate this?” made me think of that.

Don’t get me wrong. Now I use this drafts script in WSL with Windows but I didn’t even think to make it before because I saw the WSL terminal as just another window, not the lifeblood of my desktop environment.

So then I thought to myself. What if I were using Linux for the last 10 years? And the answer to that was, I would probably have over 500 little tweaks and scripts customized for my work flow, and 100+ projects open sourced.

And having that could have lead to opportunities that had major benefits in my life. Friendships, work, interesting experiences, etc.. Who knows!

Long story short, Linux feels like your OS is your friend. It helps you get the things you care about done in a way that works best for you, and it doesn’t require a crazy amount of prior knowledge to do all of this.

There’s no massive SDKs to learn. It’s literally opening a text editor and writing some Bash, or perhaps Python or Ruby if you prefer that. It’s up to you. Tools like i3 (and its supporting tools like dmenu) help you wire it all up and has a bunch of useful batteries included.

I felt more productive with i3 in 2 days than I ever did using Windows and that was being thrown into the deep end with a completely new environment I never used before (including using Vim haha). That says a lot in my opinion.

# So Why Am I Back on Windows?

After all of that, you must think I’m a madman for going back to Windows, but it’s not by choice, and it’s not because I like being tortured.

Since I record screencast videos, audio is very important to me. I’ve invested hundreds of dollars into my audio set up just to record my voice while recording my screen.

To prepare recording my next course I bought a Scarlett 2i2, which is a USB audio interface, and I also have a DBX 286s to act as a pre-amp, noise gate, compressor and EQ. Then for the microphone, I have an Audio Technica AT2005 connected over XLR to the Scarlett 2i2.

With all of this connected, it means I can just hit record and have my audio sound good without having to send it through a DAW like REAPER, process it with software and redirect it out to whatever app happens to need it.

From my computer’s point of view, it only knows about the Scarlett 2i2 since it’s the only thing directly connected over USB to the machine. Everything else is “behind” it. You can think of the Scarlett as nginx. It’s acting as a proxy to a web back-end (which are the DBX and microphone). The computer (internet) only knows about the Scarlett (nginx).

I saw a few people using this Scarlett 2i2 on Linux before I even installed Debian, and it sounded like it worked great for them. They just plugged it in, and it worked.

Consistent but Random Pops and Cracks When Recording Audio

On Linux, it works in the sense that the device is recognized but whenever I record anything I get various pops and cracks in the audio. At least 2 per minute, and sometimes it comes in spurts, like it will do it 3-4 times in a row.

These pops and cracks sound like the audio is being dropped out and then picked up. It is a very noticeable / distinct sound. It isn’t background noise, it’s like the signal disappears and comes back in.

I would also get these pops and cracks during playback, but only occasionally, such as opening a Youtube page, it would pop when it first loads. It would also pop a lot as I change the volume.

This is what ultimately made me go back to Windows. Having my recordings get corrupted with these pops and cracks isn’t good. I can’t put out material with that happening.

Back Story on the Pops and Cracks (on Windows)

I remember having this problem on Windows too before I had the DBX 286s. I used to use REAPER to process my sound in real time and then used another tool to redirect REAPER’s sound output to other applications (such as Camtasia’s recorder).

I remember experimenting with ASIO4All and a bunch of other drivers and tools.

The issue had to do with audio latency. I’m not a hardcode audio person but it seemed related to the buffer size and latency. On Windows if I set 256 for the buffer I get pops and cracks when recording. If I set it to 1024 I get continuous pops and cracks even during audio playback of everything, but at 512 I get smooth recordings and playback.

If you want to hear an example of the audio without pops and cracks on Windows with the hardware described above, here’s a somewhat recent recording.

I’m not an audiophile but if you asked me to describe that video’s audio characteristics, I would say it sounds pretty warm and smooth. If you have a highly trained ear, you might hear the DBX’s noise gate clamping down on lower frequencies but it’s really subtle.

There’s also a bit of overcooked high ends there but that’s just how the AT2005 microphone sounds combined with my voice. I think my voice teeters towards being more on the mid / high end vs low and deep.

Trying to Troubleshoot the Issue on Linux

So naturally I tried setting the same set up on Linux. I explored all of the ALSA and Pulseaudio settings but couldn’t find anything to allow me to tweak the buffer size in a way that changed the result.

Without doing anything, I was getting pops and clicks. I would also describe the audio quality as sounding very metallic. Not so much like a robot, but it sounded like it was on the brink of “breaking”. It’s very hard to describe. It just sounded very blocky and dirty.

But then I discovered Jack and I used the Jack module plugin for Pulseaudio, which seemed to solve a non-recording issue I had on Linux.

The Scarlett would often produce little cracks and pops even during playback of anything. For example if I opened a Youtube video, it would pop. If I adjusted the volume it would pop and it would also do occasional pops during playback as well.

However, with Jack, those pops went away for playback. I even had no pops when opening pavucontrol which was riddled with pops before Jack.

So then I double fist pumped thinking I solved the problem, but the pops still happened during recordings. I tried every buffer size and frame amount too. It had no difference.

I also toggled the realtime option on and off with Jack. No difference.

I also tried recording with ffmpeg using alsa and pulse, and even tried OBS with its Jack client. It was the same popping and cracking with every set up, even if I disabled video and recorded only the audio. My CPU load was only 20-30%.

I also tweaked a bunch of ALSA / Pulseaudio related settings with no difference. Things like setting tsched=0 with Pulseaudio, etc..

After extensive research, I discovered that these pops are usually described as xruns and qjackctl had a message window which counted xruns but it was always 0, even during a recording that had dozens of these pops.

I also tried the following hardware changes, and I couldn’t find anything that worked:

  • Scarlett plugged into a USB 3.0 port
  • Scarlett plugged into another USB 3.0 port
  • Scarlett plugged into a USB 2.0 port
  • AT2005 mic plugged directly into any of the above USB ports (bypassing the Scarlett)

It’s worth pointing out even on Windows I get pops and cracks with the Scarlett unless it’s plugged into a specific USB 3.0 port.

So then I took my Chromebook which was formatted to run GalliumOS directly, which is a fork of xubuntu 16.04. There’s no VMs here, and I’m not using crouton.

Both the Scarlett and AT2005 plugged into a USB 3.0 port has the pops and clicks, and it was a lot worse than my desktop workstation.

Then I tried the Chromebook’s built-in microphone and there were no pops. Then I took a spare Blue Yeti USB mic and plugged it into the Chromebook’s USB 3.0 port and it worked without pops. That was without Jack too. It was with an untouched Pulseaudio setup.

Unfortunately I only did that today and didn’t do it on my workstation so I’m not sure if the Yeti would have been clean on my workstation, but I do plan to try again on my workstation after I finish this next course.

My desktop workstation (the one running Debian unstable and is now running Windows) is an i5 3.20ghz quadcore, 16GB of RAM, SSD / HDD, GeForce 750ti with an ASRock H97 Pro4 motherboard. All of the hardware was picked up by Linux without issues.

The BIOS version on the motherboard is the original. There are 10 newer versions.

I also happen to have the following USB devices hooked up:

  • Wired keyboard and mouse
  • Logitech C920 webcam
  • External HD
  • Huion stylus / drawing pad

It’s also worth pointing out my internet is a wired connection straight to my router.

I should have had the foresight to remove all of the USB devices while recording but alas in a fit of rage and impending deadlines for both my course and contract work, I couldn’t go more than a week without my main workstation so I didn’t think about it then.

But I did leave a 30GB partition available to dual boot Linux, so I can experiment with potential suggestions on how to fix this issue.

I’m not sure what to test next. The fact that the AT2005 was connected directly to the machine over USB and XLR to the Scarlett and produced the same pops leads me to think that the USB cable isn’t faulty.

The Yeti happens to have a different USB connector so it was using a different USB cable, and speaking of the Yeti, the fact that it worked on the Chromebook on the same motherboard USB port makes me think the USB port itself is also ok.

The Linux kernel on Debian unstable at the time was 4.19.x too.

Lastly, it might be worth mentioning, on my workstation I had set up LVM and had my root and home partitions on the SSD and put /var on my HDD. I tried recording to the SSD, HDD and even /tmp which was mounted as a RAM drive. It made no difference in the end.

I had noatime set in /etc/fstab on the SSD and relatime on the HDD.

I’m writing this post to document what happened, but it’s also a request for help. What can I do to make this work besides building a completely new computer?

Never Miss a Tip, Trick or Tutorial

Like you, I'm super protective of my inbox, so don't worry about getting spammed. You can expect a few emails per year (at most), and you can 1-click unsubscribe at any time. See what else you'll get too.



Comments