# Musician turned Programmer turned Musician

## Метаданные

- **Канал:** ThePrimeagen
- **YouTube:** https://www.youtube.com/watch?v=taoAAcS5PSw
- **Просмотры:** 137,205
- **Источник:** https://ekstraktznaniy.ru/video/20740

## Описание

I made music... with crows, neovim, javascript and teej.

Don't forget, check out our coffee shop if you live in the US!
ssh terminal.shop

We have more goodies and more ideas coming soon. Hope you enjoyed the video. See you all in the next one.

Thank You DJ Dave for the inspiration!
https://linktr.ee/dj_dave

Twitch : https://twitch.tv/ThePrimeagen
Discord: https://discord.gg/ThePrimeagen
Support me (by becoming a backend dev): https://boot.dev/prime

📌 Chapters:

00:00:00 - From Gaming to Programming
00:00:35 - High School Reality Check
00:01:02 - The Social Network Effect
00:01:27 - 16 Years of Pure Programming Life
00:01:59 - The Algorithm Strikes: Discovering Strudel
00:02:20 - JavaScript Music Programming
00:02:53 - Playwright + Neovim
00:03:25 - Building a DSL and Making First Sounds
00:03:41 - Understanding Strudel Cycles and Mini Notation
00:04:24 - Adding Bass, Structure, and Effects
00:05:25 - Creating Musical Arrangements with Ranges
00:06:07 - The Full Song Creation Proce

## Транскрипт

### From Gaming to Programming []

The year is 1999 and this is the year that my life changed completely because I was like every kid in the 90s, right? I loved Nintendo 64. I would play 27 hours of Perfect Dark and Turok Rage Wars of which to this day, 30 years later, I am still upset about the black cartridge monkey bug. Somehow in my gaming stuper, I stumbled upon the game called Grail. And inside Grail, it had a level editor. And the level editor allowed you to do some basic programming. This is where I learned about if statements and while loops and of course cosine, the greatest of all the waves. Fast forward a couple years.

### High School Reality Check [0:35]

I'm in high school and I discover what is known to be women and they were not impressed with my coding skills. Okay, if statements, not doing it. So, I did what everybody else did. I learned the acoustic guitar. It turns out that coding wasn't the only reason the women didn't like me. Uh, but as much as the women didn't like me, I fell in love with music. I would love to play music. I played hours every day and this kept up for about a decade until 2010 when I

### The Social Network Effect [1:02]

watched the social network and I decided that my friendship with music was over and programming was the only thing I cared about. And this is just like a normal part of every programmer's tale which is they watched the social network and then ruined their entire life. And for what? A chance to be able to betray your best friend and make hundreds of millions of dollars and become a Chad later in life. That's just the dream of the Silicon Valley. And for the next 16

### 16 Years of Pure Programming Life [1:27]

years, I just programmed. And I was okay with music taking a backseat in my life. It just felt like I needed to grow up. I needed to have children, become a better husband, become a better father, really just become the provider. And honestly, I was really never that great at music to begin with. And programming has always been more my style. I was always really awesome with Vim. Vim is my instrument, and the keys are where I make the music. is how It's how I blow that horn, baby.

### The Algorithm Strikes: Discovering Strudel [1:59]

But the algorithm got me. And I was exposed to this. Look at that. That's programming. Listen to this. That's music. That means my prowess in programming can be combined with my skill issues in music. I can finally become the 2010s LinkedIn wet dream of a programming rockstar. So, what is this magical program? Well, this is called Strudel. It's JavaScript. Now hold on be

### JavaScript Music Programming [2:20]

hold on before you get upset about JavaScript. Okay, the magical part about Strudel is that it has a ripple. You can make music instantly in the browser. To make the simplest sound, just type out sound hh whoa whoa whoa. It's one thing to program JavaScript. It's another thing to use an editor that's written in JavaScript. Okay, I use Vim. This is a browser. My personality is Vim. It's not JavaScript. Prime, what if we use Playright to control the browser?

### Playwright + Neovim [2:53]

— Perfect idea, best friend. I'll definitely never betray you for hundreds of millions of dollars. — Why does he keep saying that? — So, I'm just going to launch a bun server that uses Playright, then have a curl command from inside Vim to be able to take whatever file I'm working in, shoot it through the curl to my server into Playright, and write it to Strudel. Now, we're on my home turf. Let's see what we can cook up. Hey, this is Future Prime. Turns out I forgot to add in a section where I talk about how TJ made it so that we could bring in Twitch chat. Enjoy Twitch chat.

### Building a DSL and Making First Sounds [3:25]

That was a dumb idea, so I wrote it myself instead. Obviously, the first thing we should cook up is a DSL. So now that I can take this file and I can import it in this file. Boom. Save. It's up on Strudel. So to make your first sound in Strudel, just type in sound h. And that's going to make a high hat sound. It's going to play it over and over again. Strudel runs on cycles. Now

### Understanding Strudel Cycles and Mini Notation [3:41]

you're probably thinking, "Hey, that's kind of like an event loop, right? " Wrong. It's nothing like an event loop. It's like music, okay? It runs in cycles. It runs on timing. But this, it's boring. You're never going to get a beat placement. So, we need more high hat. Let's put four high hats. And now we have four high hats per cycle. Okay, sounds a little bit better. This still doesn't sound interesting. There's a lot of things Strudel allows you to do. It's called their mini notation. It allows you to put in rest. You can put in subgrouping. If you wrap it with carrots, each one of the subgroups will be played for one cycle. That means you can make way more interesting patterns like this. Now, let's use that DSL and bring in some bass drums. Better. Bring in the

### Adding Bass, Structure, and Effects [4:24]

bass. Ooh, that's better. But drums. Drums are boring. I want to see music. So, bam. Music. All right. But that doesn't that doesn't sound good either. Okay. It kind of sounds like Doom. So, what we're going to do is we're going to add a little bit of structure to it. Okay. All right. A little bit of syncupation, but now we're going to randomly clip out some of the sounds. Okay. It sounds better. Let's add a little bit of extra strumming, reverberation, low pass filter. It's kind of starting to sound sexy. Super saw and delay that changes based on the shape of the sine wave. All right, we got a clear board. Do high hat, bass drum, baseline. But the thing is that sometimes you don't want them all to play at the exact same time. you kind of want to actually like make a bit of music, right? So, let's use a range. I can take a range and I can go like this. Okay, we're just going to play the baseline for two cycles.

### Creating Musical Arrangements with Ranges [5:25]

Next, we're going to play the baseline plus the bass drum for two cycles. Next, we're going to play the bass drum, the baseline, and the high hat for four cycles. We got ourselves a jam here. Something's missing. There's just not enough crow crow. I think I could actually make a full song out of this.

### The Full Song Creation Process [6:07]

Not going to be active on Discord tonight. I'm meeting a girl, a real one, in half an hour. Wouldn't expect a lot of you to understand anyway. So, please don't DM me asking me where I am. I'm with the girl. Okay, you'll most likely get aired because it'll be with the girl again. And I don't expect you to understand. She's actually really interested in me. And it's not a situation I can pass up for some meaningless discord degenerates because he'll be meeting a girl. Not that you really are going to understand Randall. Hey. Randall. Hey, — have you ever had a dream that you um you had you could you'll do you want you could do so you'll do you could want you wanted them to do you so much could do you anything Shut up. Code girl. — Hey.

### Terminal Coffee [7:56]

Look at me. I'm at Open Sauce. By the way, I sell coffee in the terminal. SSH terminal. shop. shop. — Terminal coffee in hand. Living the dream.
