<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://nhaddal.info/feed.xml" rel="self" type="application/atom+xml" /><link href="https://nhaddal.info/" rel="alternate" type="text/html" /><updated>2024-11-26T22:54:55+00:00</updated><id>https://nhaddal.info/feed.xml</id><title type="html">Nicolai Haddal</title><subtitle>personal page for software developer, musician, and photographer nicolai haddal
</subtitle><author><name>Nicolai Haddal</name></author><entry><title type="html">In Memoriam: Keith Levene (The Clash, Public Image Limited)</title><link href="https://nhaddal.info/music/2022/11/13/keith_levene.html" rel="alternate" type="text/html" title="In Memoriam: Keith Levene (The Clash, Public Image Limited)" /><published>2022-11-13T00:00:00+00:00</published><updated>2022-11-13T00:00:00+00:00</updated><id>https://nhaddal.info/music/2022/11/13/keith_levene</id><content type="html" xml:base="https://nhaddal.info/music/2022/11/13/keith_levene.html"><![CDATA[<p>Yesterday I learned one of my favorite guitar players is gone: Keith
Levene, founding member of The Clash and Public Image Ltd, just <a href="https://www.rollingstone.com/music/music-news/keith-levene-the-clash-public-image-ltd-guitarist-dead-obit-1234630011/">died of
liver
cancer</a>,
at age 65. While I'm old enough to already have my share of dead
heroes, I find myself strangely affected by his death. Strange since
it's not like Levene has been on my mind constantly. I don't have his
poster on the wall. I don't think of him every time I pick up the
guitar. I hadn't even known he was a founding member of The Clash.</p>

<p>No, for years I've known Levene as the brilliant, abrasive guitarist
for Public Image Limited (PiL), the band he co-founded with John Lydon
(fka Johnny Rotten of the Sex Pistols) in 1978. Way more people know the
Sex Pistols, and a few might only know PiL as Johnny Rotten's other
band. But I'm certainly not alone in my belief that of the two,
Public Image Ltd was the one artistically worth a damn. As a few YouTube
commentators have pointed out: Public Image Ltd, at their early peak
before Levene left the band, sounded like the future. And I think Levene
is the reason why.</p>

<p>A note about the electric guitar: While revolutionary upon arrival, over
the decades the electric guitar has become nearly as ossified an
instrument as the violin or the cello. At first electric guitar players
were breaking all the rules, or rather making up new rules as they went
along: Slicing their speaker cones, using thinner strings to bend notes,
abusing tremolo bars. Think Hendrix.</p>

<p>But that's no longer the case. There is now the inevitable established
canon of tracks and styles to learn. There are agreed-upon rules for
approaching the guitar. Every time you play most people listening
already have a set of pre-conceived notions of how the guitar should
sound, and by extensions how <em>you</em> should sound. While it's especially
bad now, this was already the case in the 70s, after rock music had
spent over a decade as a dominant commercial force.</p>

<p>So to pick up the guitar and do something truly unique is a difficult
artistic feat. It's the Jackson Pollock thing: Anyone can splash paint
on a canvass, but only Pollock could make it work like he did,
developing an artistic language all his own.</p>

<p>I've been playing guitar for almost twenty years now. I'll let you in
on a secret: Playing conventional classic rock guitar isn't hard at
all. It's actually very fucking easy to learn the minor pentatonic
scale and scribble within the lines over any anonymous backing track on
YouTube. You can learn AC/DC riffs, Led Zeppelin, whatever, and impress
someone. Gratification is never far off. It's amusing for a while, and
if you're really good, you can become a street performer, or join a bar
band, or even tour with Wolfmother. But you're not going to become
Jackson Pollock. And at this point, you're even further away from being
an artist than before you learned to play guitar in the first place.</p>

<p>Keith Levene, though, could do something different with the guitar. No
small feat. To use this instrument to make sounds that are fresh and
mind-bending requires a degree of individualism, perseverance, and
discernment that I think is nearly extinct in the guitar-playing masses
of today and was always in short supply to begin with. The sounds Levene
made with the guitar were haunting, frightening, visceral. His tone was
ice-pick sharp, metallic. It's not technically difficult to play the
chords he played, but it's extremely difficult to play outside the
lines like he did. Levene chose the wrong notes on purpose, something
that guitar players like me spend a whole lifetime running away from.
And upon hearing him play many people, maybe even most people, would frown. 
But it gives a few of us an enormous smile.</p>

<p>Ok, so Levene played weird. Who cares? What good is it to try to play
the guitar differently, anyway? Indeed I think 90% of people would be
thrilled to play like Slash or John Frusciante. I think it comes down to
a fundamental choice: Do you want to be an entertainer? Or do you want
to be an artist? You can be both, of course. But which comes first?</p>

<p>I think the early Public Image Ltd albums rose to the level of art. And
truly unique art will reach into your heart and resonate with you in ways you
didn't know were even possible. This was the case for me when I first
discovered Public Image Ltd and Keith Levene's playing. It was the
winter of 2014. I was already out of college, and I had flown to Poland
to care for my dying grandfather. I couldn't tell you how I felt in my
own words. But you could hear how I felt if you listened to
'Annalisa', the driving, desperate fourth track on PiL's debut album
'First Issue'.</p>

<iframe width="560" height="315" src="https://www.youtube.com/embed/CIgRQP4Fa-o" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>

<p>Listen to the track once, and then listen to it again paying special
attention to the guitar. It's never in the 'right' place. The note
choices are seemingly arbitrary. It sounds like Levene doesn't care.
And maybe on some level he didn't, at least not the way Jimmy Page
would. But clearly, Levene cared that he sounded like <em>that</em>. And
thirty-five years later it meant a hell of a lot to me, scared and
bewildered in the middle of the Polish winter. There are some
experiences so uniquely difficult that you're bound to feel alone, even
if you're surrounded by people you love. In my life, I've found that
only art can close that gap. So I owe Levene a debt of gratitude.
Levene's tenure in the spotlight was relatively brief. Like so many
great artists he couldn't seem to have gotten out of his own way. I
hope he's at peace now.</p>

<p>Here are a few of my favorite Public Image Ltd tracks and clips:</p>

<h2 id="public-image-from-first-edition">'Public Image', from <em>First Edition</em></h2>

<p>U2's The Edge took the chiming, expansive guitar sound from this track
and used it to build a global rock empire.</p>

<iframe width="560" height="315" src="https://www.youtube.com/embed/ylOCIP54PIQ" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>

<h2 id="poptones-careering-shot-for-the-old-grey-whistle-test">'Poptones', 'Careering', shot for <em>The Old Grey Whistle Test</em></h2>

<p>Hendrix pioneered the effect you hear on the guitar here, the flanger.
Of course its use in a psychedelic context was trippy and ethereal.
Here, Levene turns his arpeggios into clouds that float by while you're
cradled by the bass and rhythm, until your attention is stolen by
Lydon's wailing.</p>

<iframe width="560" height="315" src="https://www.youtube.com/embed/aDKDc5zq53k" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>

<h2 id="the-flower-of-romance-from-the-flowers-of-romance">'The Flower of Romance', from <em>The Flowers of Romance</em></h2>

<p>Levene wasn't only a guitar player. PiL's last album with Levene, <em>The
Flowers of Romance</em>, hardly had any guitar at all. Instead Levene and
Lydon went nuts with synths, stringed instruments, and tribal
percussion. The result is one of the strangest albums put out by a major
label. One of my favorites.</p>

<iframe width="560" height="315" src="https://www.youtube.com/embed/bnF_TH57FA0" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>

<h2 id="poptones-careering-shot-for-american-bandstand">'Poptones', 'Careering', shot for <em>American Bandstand</em></h2>

<p>Here's the 'Poptones' and 'Careering' combo again, this time for an
incredible TV appearance that broke down the line between performer and
artist.</p>

<iframe width="560" height="315" src="https://www.youtube.com/embed/nIXBpwkvTUA" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>

<iframe width="560" height="315" src="https://www.youtube.com/embed/00fIPt-WARc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>]]></content><author><name>Nicolai Haddal</name></author><category term="music" /><summary type="html"><![CDATA[Yesterday I learned one of my favorite guitar players is gone: Keith Levene, founding member of The Clash and Public Image Ltd, just died of liver cancer, at age 65. While I'm old enough to already have my share of dead heroes, I find myself strangely affected by his death. Strange since it's not like Levene has been on my mind constantly. I don't have his poster on the wall. I don't think of him every time I pick up the guitar. I hadn't even known he was a founding member of The Clash.]]></summary></entry><entry><title type="html">Changing timestamps in a VTT file with Python</title><link href="https://nhaddal.info/blog/2022/05/08/vtt.html" rel="alternate" type="text/html" title="Changing timestamps in a VTT file with Python" /><published>2022-05-08T00:00:00+00:00</published><updated>2022-05-08T00:00:00+00:00</updated><id>https://nhaddal.info/blog/2022/05/08/vtt</id><content type="html" xml:base="https://nhaddal.info/blog/2022/05/08/vtt.html"><![CDATA[<p>Automation is one of the best reasons to learn to code, which is why Al Sweigart’s <a href="http://automatetheboringstuff.com/">Automate the Boring Stuff with Python</a> is such a great introduction to programming, especially for office workers without a CS degree. Completing about half of the course already armed me with enough knowledge to automate some seriously dull, repetitive tasks such as:</p>

<ul>
  <li>Converting file formats, e.g. M4A to MP3 files;</li>
  <li>Finding hyperlinks in text files and opening them in the browser;</li>
  <li>Naming files according to a convention, e.g. containing the date.</li>
</ul>

<p>But in addition to automation, <em>text manipulation</em> is another great reason to learn even rudimentary coding. Say you have a Word doc open and you’re working on a research paper. It turns out some of the math you did was incorrect, say by a factor of 5. That’s not so bad if there’s two or three statistics to correct. But what if you’re working on something much more involved? What if you could perform math on all the integers in your file?</p>

<p>Here’s an example of a problem I recently solved using the kind of text manipulation Python excels at:</p>

<p>Good captions are a must for accessible video uploads. If you hire a captioning service for your videos, once your video is done, you’ll get what’s called a ‘WebVTT’ file along with your recording. It’s quite simple: A plain text file with time stamps, followed by a caption in the next line:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>WEBVTT


00:00:00.951 --&gt; 00:00:05.751
Here are some captions.
</code></pre></div></div>

<p>Adding this file to your YouTube upload is simple. Just upload the VTT when prompted by YouTube Studio, and be sure to check off the ‘with timings’ option.</p>

<p>Simple, right? But what if you need to edit your video before uploading? Say you need to chop off the first ten minutes. Easy enough to do with any video editing software. But if your video editing software doesn’t support importing and exporting VTT files, you now have a caption file that’s totally out of sync.</p>

<p>So here’s our problem: We’ve got a set of timestamps that require we perform some basic arithmetic. We need to replace the timestamp with the modified timestamp. And we need to loop through the file to take care of all the timestamps.</p>

<p>A caption file easily includes thousands of lines, so doing that manually is out of the question. You could potentially use a paid service, or even a free online tool. But a paid service would take time and money, and who knows what’s being done with your data when you use a free online service?</p>

<p>This is a really niche problem. But no matter how niche, nine times out of ten I’ve found there’s no problem too niche that someone hasn’t uploaded a script in Python online to deal with it. And indeed, it didn’t take long on DuckDuckGo to find an excellent resource: A WebVTT timestamp adjustment function written by Nat Dunn. See that script <a href="https://www.webucator.com/article/fixing-webvtt-times-with-python/">here</a>.</p>

<p>How does it work? You’ll notice the VTT file timestamps contain an arrow, ‘–&gt;’, so the lines with numbers we need to change are easily identifiable. Nat’s script loops through the file, does nothing to lines without the arrow, and converts timestamps in lines with the arrow to timedelta objects. You can do your math on that object - say, strip 300 seconds - and spit out the updated timestamp. Very cool trick.</p>

<p>This script worked for me in a pinch, but there was a slight problem: It spit out timestamps with three trailing zeros. YouTube didn’t like this. In a pinch I performed a global find/replace to strip out those three zeros in my text editor but that’s not a good solution. What if your captioner used the number ‘1,000,000’ during transcription? If you delete all groups of ‘000’ you’re now left with ‘1,,’.</p>

<p>The solution was simple - you can see my modified version of the script at my Github <a href="https://github.com/corgito/fix-vtt-times">here</a>. I tweaked the script to delete the last three characters of the time stamps:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>vtt_output += f"{start_time[:-3]} --&gt; {end_time[:-3]}\n"
</code></pre></div></div>

<p>And for the sake of convenience, instead of writing to a new file, I used the <a href="https://pypi.org/project/pyperclip/">pyperclip</a> module to copy the text of the new VTT file straight to my clipboard instead of writing to a new file. Now I could paste the output to a new file, and delete the caption text I don’t need.</p>

<p>This script could be much more sophisticated, e.g. it could be configured to output a new file that ignores the captions you don’t need. But I don’t work with these kinds of files often enough to really need anything more complicated than what I’ve got here.</p>

<p>So that’s how I solved my VTT file issue within about half an hour. I realize this is a super niche problem, but it’s just the sort of problem office workers tend to encounter constantly. It’s also the sort of problem that usually require a time-consuming solution: either waiting for someone else to fix the it or having to spend hours manually fixing the problem yourself.</p>

<p>Sometimes I wonder if learning to code was worth the time investment. Have I really saved time in the long run by automating repetitive tasks, given the hundreds of hours I’ve invested in learning Python so far? An objective comparison to the counterfactual situation where I never learned to code is impossible.</p>

<p>But the above example shows there are many great reasons to learn to code! At heart, programming puts you in control, and the more you invest in mastering a programming language, the more problems you can tackle. There’s really no feeling quite like it.</p>]]></content><author><name>Nicolai Haddal</name></author><category term="blog" /><category term="Python" /><summary type="html"><![CDATA[Automation is one of the best reasons to learn to code, which is why Al Sweigart’s Automate the Boring Stuff with Python is such a great introduction to programming, especially for office workers without a CS degree. Completing about half of the course already armed me with enough knowledge to automate some seriously dull, repetitive tasks such as:]]></summary></entry></feed>