 Hello there and welcome to the show. It's me, John Park and this is John Park's workshop here on Adafruit Industries, YouTube and other places. And we have confirmation from the good people over in our chat that we are live on YouTube. We should be on Twitch and LinkedIn live and Facebook and gosh, all sorts of places. Yes, confirming bleeps and bloops. Thanks so much. Hello Rich Sad, hello C Grover and to Callaway. Look, these are all the people that are hanging out over here in our Discord right there. And hi Mr. Certainly. Nice to see you Gary Z. So, hey Andy Callaway, let's see what have we got in store for today. I am excited, really excited about today's project. It involves our macro pad, our little Adafruit macro pad as well as some MIDI coding in Circuit Python to be able to talk to and listen to Ableton Live, which is some music software. So that's going to be a lot of fun to dig into. And what else? We've got, I'm going to talk about the jobs board, we've got an upcoming Adabox I want to mention. We'll take a look at the last product pick of the week as well as do a new Circuit Python parsec. And of course I'll take any and all questions over in the YouTube chat. I'll keep an eye out there. And on our Discord chat, hey Stuart Riggs, hey UNESCO, Johnny Bergdahl, Meridian Prime, hello, hello. So let's get started. First of all, I don't have a graphic for this, I forgot to add one, but Adabox is coming. So if you are interested in getting the next Adabox and you are not subscribed, head to Adabox.com. You can sign up or you can sign someone up as a gift to them. And you will receive, if you get within the next hundred or so, I think we have about a hundred slots left. Tell me in the chat if I'm wrong on that, but I think we have a few slots left where you can go and sign up and get this upcoming Adabox, which is Adabox 19. I think I got that right. I think it's 19. We've been doing these for a long time now, four a year, Adabox 19. That's almost five years worth, right? According to my math. And that one will be shipping soon in the next few weeks, I think. And I'll be targeting doing a live unboxing on roughly the last week of July, maybe first week of August. That's kind of what we have in the works right now. Things can change. Of course we're like anyone else out there dealing with parts shortages and shipping delays and all those sorts of things. So it could change. But that is our thought right now is last week of August, sorry, last week of July, first week of August, roughly in there, is what we're targeting. And so I need to start getting my costumes together. It should be fun. I'm looking forward to it. Next up, Help Wanted. We've got a jobs board. Did you know that? That's right. If you head over to, let me switch to my browser here, the jobs.adafruit.com. That's it right there. And I've clicked on one of the many jobs available. If you go to jobs.adafruit.com, you can see these are the search jobs section. And I clicked on this one here, Circuit Python Project. It is a freelance gig. Someone is looking for consultation and help with some Circuit Python and possibly designing a PCB and a PID controller. So if you're looking for some freelance work, go to the jobs board and check that out. We vet them all so that these are what we consider to be good quality, non-scammy job openings and freelance and contract jobs. Part-time, full-time, the works. And you can also post your resume on there if you head up to the available for hire section. If you log in to Adafruit, you can go and it's entirely free. So I recommend you go check that out if you're looking for work, if you're looking to hire someone. That's jobs.adafruit.com. And let's see. Next up, the, that's not the new water. I forget my new water. Oh, there it is. There's a new one. Yeah, someone mentioned that Lars looks like he might be falling asleep over there. What's up, Lars? What's up with that guy? All right, what's next? I will mention the show that I do on Tuesdays, which is my product pick of the week. Each week, each week, I pick a new product. Usually something brand new. Sometimes it's a revision of something. Sometimes it's just because I feel like it. But this one is a 2.13 inch e-ink display breakout. And it has a nice high resolution of 250 by 122 pixels. You can control it from circuit Python. You can control it from Arduino. You can control it from Python on your computer using Blinka through a microcontroller. And during the show, the product pick of the week is on a deep discount, usually 50% off. So it's a great time to get the product. And I like to do about a 20 minute, half hour show going into some of the details of the product, doing a project or two with it, showing you some of the code. And then I do a little one minute recap. So this is the recap from this week's product pick. Check it out. The 2.13 inch monochrome e-ink display breakout. You can see here this is a really gorgeous display. It's nice and high resolution. So you're going to see it's going to do a little refresh. There it kind of inverts the screen, does black, does white, and then it displays it. What I wanted to do is actually set this up as sort of a page a day calendar. I'm going to run a little Python script. It's now updated it with today's day and date. And that's grabbing it from my computer, which is what that Python script does. And so every hour, both my Python script and the circuit Python script running on this little microcontroller will go and check, essentially the computer will check and see, hey, what's today's date, day and date. And then it's going to send that over serial on the USB over to the itsy-bitsy M4 circuit Python software there is waiting for input. And when it grabs that input, it then displays it up there. The monochrome 2.13 inch e-ink display breakout. Let me see. There we go. Got the sound back. Keeping an eye on that. I want to get caught out. Next thing I wanted to do, let me get some things set up and we'll take a look at this week's circuit Python Parsec. All right. So, I'm going to don some glasses here so I can see the code and get my code window set up. There it is right there. Okay. For the circuit Python Parsec today, what I wanted to talk about is formatting strings along with numbers inside of your code. Sometimes you want to just simply print out to the serial or the REPL or to a display some information and you want to format it nicely. So, here are a couple of ways that you can do it. Right now, what I have going on in the code is I'm importing time so I can do a little pause. I'm importing board so I have pin definitions. I actually don't need those in this case. And I'm importing random so that I can generate some random numbers just to make it more interesting. Then in the main loop of the program, what I'm doing is I am creating three variables named number one, number two, and number three. And those are numbers that are created using this random dot rand int and then a range. So, I'm saying zero to 39. So, it can be any integer between zero and 39. Those get generated each loop of the program. Then the next thing that happens is I go ahead and I print out the phrase that you see here below, random combo is and then a number like 29 left, 15 right, 6 left as if we're generating numbers for a combination lock. I'll go ahead and run that so that it is updating real time. So, you can see it waits four seconds and then it's going to go ahead and repeat that, except this time it's generated a new number. Now, what you can see about the way I am formatting this print statement is that it is kind of long and a bit confusing to deal with sometimes, especially when you look at all these commas. I wanted to do things like have the word random combo is, then a number, then the word left, then a comma, then quotes, and then another comma. So, it's totally doable, but it can get a little confusing. So, here's an alternate method. And this right here I think is a little more manageable sometimes. Here you can see I have the whole phrase as I want to see it right here says random combo is and then I'm using this percent D, which means we're going to go outside these quotes and grab the first variable as an integer number and plop that in. Then I have the word left, then I go and do the same for the next one. I grab this number two, then the word right, comma, and then the third one. And I go and grab number three. So, you can see if I save the code right now, it's going to refresh and it looks the same. It actually prints out the same type of statement, but it's really nice and clear and concise both the way it prints out but also the way we deal with it. If you have to change any variables here later, it's nice and neat and easy to understand. And that is one way that you can format your print statements inside of CircuitPython. And that is your CircuitPython parsec. All right. Well, I hope that's helpful for you. And of course, formatting is one of those things that can get really complicated really quickly. You can do a lot with it. There are ways to convert things and as you can see in some of the code there, I have some carriage returns going on. This little slash n here gives me essentially a return or line return. So, there's a lot that you can do, but these are two methods that I think are helpful. And then you can always go online and find lots and lots of advice for string formatting in Python. Let's see. The next thing I want to do is jump into a little gear report thing, actually. You can see it right here on the screen. It's this little helping hand. And this one is a new one I just got. Let me go full screen with this. Let me try to refocus a little bit so you can see the helping hand a little better. There it is. So, this one, it was new to me. I haven't seen this style before and it is reminiscent a little bit of the type of machining that you see in stop motion puppet armatures. It's really nicely machined with these little ball and socket joints. It's actually similar to the very, very cheap magnifying glass third arm helping hands that you find, except it's not really, really cheap and so everything actually cranks down nice and tight and gives you a solid fix once you've cranked it in there. In fact, rather than having sort of wing nuts on either side, it uses a little screw with an allen or a hex head on it so you have to get a tool out and really crank it down if you want. You can also kind of loosen it by hand a little bit and move it around here. And it's of course not made for holding very heavy things, but it does seem to be with this nice heavy base and this really precision made clamp here. Let me give you some better focus. It gives a nice steady hold so you can see if you're soldering something onto a thing like that. We can clamp into there, put it where we want it, do our soldering, look at it under microscope, whatever you're doing. This can also be screwed down into a work surface if you need or something heavier. This I think is, I haven't checked, but I think it should be ferrous. Let me get a magnet. Any of it? Nope. It's not ferrous. Okay. I was hoping this would be. It is not. Sometimes you'll find some parts are. Nope. Okay, that is, but only mildly so. And this is just a section of the arms that are on. Actually, let me up to my workbench. You may find these elsewhere. Let me pop a camera up in here. I don't know if these were made by Meritac themselves. This was the little box that came in. This is Meritac on there. These are some of the extras for it so you can see you could really extend the heck out of this thing. I'm not sure what situation you'd get into where you needed that much, that many joints, that many points of articulation, but I don't know, I might do some stop motion animation with it just because it's so cool. And these are little extras of the little clamps. I may have, here's a cheap one. These are some of the remaining parts of a cheap one. And these, there are probably good versions of them. This one is one of these cheap ones that just doesn't grip after a while. These actually, I don't think they deburred the edges there so they actually have a little bite to them, which may be intentional just to give it some good grip. So that was, that's Meritac is the brand behind that and you might just look online to find that it was sent to me by Countycom. And this one they sent me for free, by the way, I buy a lot of stuff from them. Sometimes they send me something. So I just wanted to be upfront about that that I didn't buy this set, but I think it was not expensive. I think it was in the 20 something dollar range. So let's go in and out of stock. I don't think it's in stock right now, but just want to show that off because I thought it was cool and you might dig it. Yeah, the hobby hand by Meritac is in the discord chat there it says. Yeah, and Stuart Riggs said you could three print some TPU on the end clamps for insulation. Absolutely. I often have put just some heat shrink on on my helping hands. So there you go. And Mr. certainly found some links that you can go to in the discord if you're wondering about it. All right, let's see. Then what do we do? Let's let's dive into the project this week. So a little setup on this, the project I've got, I said it's using the macro pad. And you can see here, a couple things going on. This is the windowed keycaps that that Adafruit has now. I've just gotten a set of those they're not cheap. As someone pointed out, they're they're four dollars and 50 cents each. So it is an investment. If you're going to get out a whole macro pad like this. But it is really cool. It looks great. It makes less of a sort of wash of light. And instead you get some very nice sort of focused little buttons on here. And you won't see them yet because I haven't hit any buttons to light it up, but you will in a moment. In fact, if I if I hit reset, you'll see during reset, there's one that this one blinks right here. Big, big, big. So let me set up my camera focus on this guy a little better now. And bear with me. I'll point that. Whoops. And now I've done it. I've launched some music. Sorry about that. Jumping the gun. The next. Okay, so the next thing I want to do is introduce Ableton live a little bit, which is what I'm setting this macro pad up as a as a launcher for. So there's my get a better view of that with less glare. There is a lot of glare. Okay, at least it's oh, whoa, way out of focus. All right, there we go. Phew. So I'm gonna let me hide some windows here for a second so that you can see just Ableton first. And okay, so the way Ableton works is that it's it's music software. It has a few different ways of working. You can use it to record like a sort of somewhat typical digital audio workstation or DAW or DAW. It is also used the the name of Ableton. It's called Ableton live and it's often used as a live performance tool for live looping. And what you're looping is little clips that are either some set of MIDI notes that are playing through an instrument, a software instrument built into it, or a wave file, a sample. So most of the things actually all the things in here, these are these are samples. So it's music that's been produced in little loopable sections that work together. They're in the same key, they're in the same tempo. And typically, you saw over here actually typically people use instead of clicking on things in the software, which we can do if I click play here, I'm playing just this first drum track. Now I'll add to it sort of horizontal things work together. So there comes the bass in. And here's a little synth line. Now you can launch all of those together, or you can move down to the next section, and so on. So go ahead and stop that. And one way that Ableton is often used is with some sort of a control surface. So this is a launch pad from Novation. And these are really popular for playing back the different clips because these are neopixel or RGB LED lit pads, which when you plug this in, will conform to the session that you have running. So we'll get LEDs lit up that match each of those columns and rows. And they're really great. A lot of fun. Somewhat customizable, but not a micro controller that you can actually code yourself. And so what I wanted to do is create a similar type of launch pad or launch controller using our macro pad here, and be able to press a button on my launch pad here, or on my macro pad. Oh, I've broken something. What have I done? Let's let's reset. I may have angered it. Like I said, I might have some setup to do. Okay, it's working. I think it's working. Yeah. So here's a couple things you'll notice. First of all, when I start up the macro pad, I've got a little display that I've created here that tells me the names of the instrument tracks, these vertical tracks of clips. And I have indicators with these little dots of which one is currently armed and playing. And I also have a little knob. You can see here, look at my focus. I have a little knob there with a number that's changing, which says cutoff. I'm going to use that to change the cutoff frequency of a filter. And I also have this is a push encoder so we can click it and you'll see it changes something on the display there. It changes that little circle to a dot. And I just chose to use text for this rather than graphics. You could use graphics, but so my text of a lowercase o is a clip that's playing and a dot is one that's not. But you'll notice my LEDs there, the neopixels under these caps are not lit up right now. But watch what happens here. I'm going to go to Ableton and I'm going to click on hopefully you can see it. It's just the upper right corner. I'm just going to click on a button that you use, whoops, there we go, that you use to set things up in MIDI. And that is one of many ways that you can refresh your controller. Another is just to open a new scene. So if I have nothing loaded and then I open this new session, this new Ableton session, it will light up all these LEDs. And what you'll notice is let me, let me mess with my exposure a little bit here to darken it. So what you'll notice is those colors actually match the colors in my clips here. So I have a sort of light blue, a purple, a blue, a dark blue as the first set of clips running vertically in this drums column, then these different yellows and oranges, and then these reds and magentas. So those correspond to the buttons here. And in fact, if I change one, let's, we'll take this bottom right one, and I'm just going to change its color, we'll change it to blue. You'll see that just change on my macro pad, which is really, really cool. It's actually the kind of one of my, my favorite parts of this whole project is the fact that we've got this back and forth between the hardware and the software, which sometimes you take for granted with sort of coupled integrated hardware software solutions. But this is the case where we're doing a DIY project that's ostensibly just a MIDI device just sends out MIDI messages over USB to the software. But the real magical thing is that Abled and Live is set up to send its own MIDI messages back to the controller to tell it what to do as far as its lights go. So if you, if you watch here, what I'll do is I'll arm some clips, means they're going to play, they will turn green, whichever ones that I've, that I've got playing. They'll turn green and when I play a different clip in that column, it will turn green, but it will set the last button that was pressed to its original color. So you'll see here, this first one is blue. Play that. And now it's green. Now play the next one below it. And you'll see this one turn blue again. Let me do it over here in the, I'll rearm that first one. And you'll notice my display is updating as well. Now in the last column here, I'm going to play the synth line. See that turn green. Now play the next one down. And again, you'll see the color swap. Now when I'm done playing them, what I'm doing is I'm holding down this modifier, which is what I'm considering that knob to be, you'll see it dims my, all of my LEDs, which is an indication to me that this is used to sort of mute something essentially. And I'm also changing the little indicator on the screen there. Then I can press pretty much any button in a column, and it's going to mute that whole column in essence. So if I'm playing this drum beat, and then mute it, it stops all of them. If I play this first drum beat again, I can actually mute anything in the column. And it stops those. One thing also you'll notice if you're not familiar with these types of looping software is that they don't immediately respond to what you're doing because they are essentially quantizing your time to a measure or a few measures or a certain number of notes so that the timing you can say, hey, go ahead and bring the basin. It won't just bring it in in a way that clashes with the actual beat of the song. It waits until you reach the next bar typically. So that's why you'll see sometimes there'll be a couple buttons lit up green until it switches into the next measure. And then it turns off the previous one. Now I also mentioned I've got the this cutoff value. So let me I'm gonna play a whole section here. And then I will turn this up and you'll hear essentially the low tones drop out. So this will use a filter to cut away. It's a low pass filter, it's going to cut away some of the lower frequencies as I increase that value. That is the sort of demo of it doing what it does. But now I want to talk about how it does this, how these things actually work. So this is the part that I got really excited about working with this what I'm going to do is I'm going to turn on a display here of let's see, there we go. I'm going to display my MIDI monitor. So there are versions of this on any operating system. There's even ones that work inside of browsers inside of Chrome browsers and others that allow USB MIDI. And what this is doing is this is essentially spying on the traffic going on. So what I'll do is I'll actually set this up to just spy on my macro pad here. When I press a key and just so yeah, I guess I'll just turn the volume down a little bit so you'll still hear the music but not as loudly. So here I go I'm going to press this first button. So what you can see here is it sent four actually it sent two messages ignore these invalid ones we have an extra byte right now that's being sent in USB MIDI this is being fixed I think in tiny USB. The two messages that are being sent are note on over channel one so MIDI has 16 channels. The MIDI note number MIDI note numbers exist from zero to 127. And those those represent typically the pitches on your keyboard or piano or whatever however you want to consider it but the musical pitches. And in this case, though, that's not not how it's used that note on message is actually being used to just tell the clip in the upper left cell of what you consider a essentially a spreadsheet of clips. The first upper that upper left one is considered number 81. I think the bottom left one is on on a pad like this I think is 11. So they started 11 and they go over to what 18 and up to 88. So that's the grid we're working with. So we send a note on message and the number 127 you see here that is the velocity. A velocity 127 means you've hit it full hard in case you're used to MIDI controllers that let you hit something softly or hard. But again, it's just used in this case to reinforce the notion of we're playing that clip, sending I believe sending anything other than zero would probably turn the clip on. Then it sends a note off message. So this is like you've pressed something and released it. Now, in some cases, if that were a synthesizer, it would play a note until you released it if that's if that note had built in sustain. In this case, it's just flicking that state of that clip to the on position releasing doesn't turn it off. So note on note off, that's how you tell one of these cells to start playing. If I switch to the next note below it, that's note 71 on off, and so on. But now, interestingly, that's not the only messages that are happening here, I'm only looking at those. So if I turn that off for a second, so I'm going to tell MIDI monitor don't show me when I press a note. Okay, I'm not looking at that that data flowing by just to clean things up. But what I will look at is it I've got this great. This is MIDI monitor, it has this little option called spy on output to destinations. So I'm gonna spy on the traffic that's going from Ableton live on my computer over to this MIDI controller. So right now, you can see this first upper left button here is green. I think it is yeah, it's green. So that's the one that's playing right now. And you can see there's a little green arrow on that cell in Ableton. When I press the next one, you're going to see, even though we're not watching the traffic go from my mic, my macro pad to the computer, what we will see is that traffic flows back this way. And we'll take a look at what that is. Okay, so I pressed the second key. Then some information came back at my controller from Ableton that said this note on on note 71 at a value of velocity 69, then note off, then on the second MIDI channel. So that was channel one, channel two, it did a note on same note, but a different number for the velocity and then a note off on channel one channel one again. Then it repeats this, then it sends on channel three, the same note, the data, the velocity is 21. And then finally, the last thing it did was it sent over channel one to note 81. That was that first button, if you remember, the value of 33. So what the heck is all this? Actually, we'll start with that bottom one. If you watch when these change, let me clear this again. Last thing that happens is the top button turned back to its original color. And so that is how Ableton is sort of co-opting MIDI messages, essentially to use them as RGB LED data control protocol. So everything you see here is messages about lighting up the LEDs. So let me pause or stop that. So what I figured out, and it's a bit of a chicken and the egg thing, you can look in the manual, there's a developer's guide from Novation for their launch pad, which there are about six or seven different versions of this kind of thing now going back many years. And if you look in the developer's guide there, or if you have one and you spy on the traffic, what you learn is they actually use three MIDI channels, one, two and three, to mean different animation states of the LEDs. So sending something on channel one is an on and off. Sending something on channel two, I think is a blink. Sending something on channel three is a breathing, like a soft fade up fade down. Now, I don't have the macro pad set up to use the animation state stuff right now, so it just doesn't do any of that. That could be something we add. So a lot of those messages kind of don't matter. But the last one is that it turns it on and off to green. So again, if I press that, let's say button two there, that's this number 71, and it goes to velocity 21 on channel three, that channel is the, or sorry, that that velocity value 21 is the color index for green. And I'll show you show you the color index list in a second. The, in this case, sending note 81 to color 33, that's just because 33 was its original color that we picked. So as I go through these, you'll see that final message will vary depending on what color we're getting something to land on. So you can see lands on 33, lands on color 69, lands on 78. So those are all different indexes for these blue colors. So let me show you some code. So let me open up my code that I have running on here, bring that up. And let's make that a little bigger, actually, one second. So I will kind of obscure some stuff for a minute while we do that. Go, open it so I can see it. Okay, so let's let's dive into this a bit. Here is the code that's running on this macro pad. And I'm going to open up a screen session, so that we can also see some of the print statements that I'm doing here. So what's happening here? The imports here for a bunch of libraries. Nothing you'll find surprising. It's it's keypad, it's display IO, it's the font with terminal IO, neopixel, rotary IO, using simple math constrain library to keep some numbers within a certain range using display text label, the debouncer, and then all this USB MIDI stuff. So USB MIDI and Adafruit MIDI for control change, which is the knob dial stuff, note on note off as well as MIDI message, which lets us capture unknown events in case we need to see some messages coming from the controller that don't fit one of those other categories. Next thing I've got going on here is that I'm setting up some variables that we'll use in a few places. So live launcher 2040 is what I'm calling it. And that is both what gets printed to the screen here and also gets printed down in the serial. I print it right here. Then this is one of the very few things that I've hard coded. Unfortunately, the so far I've not found a way to, I don't believe Ableton is sending things like the track name over to the device in the case of this launchpad. The one exception is maybe the Ableton push and push to which are some more sophisticated devices that have a screen on them. And there may be some others that have screens. So it might be worth looking at those. I think they may be using the Cissex messages, which are another type of MIDI message that can be used for kind of anything you can dream of. So that's possible that we could grab names of things and put them the screen. But right now I'm just punting on that. And I've just named my three track sections, their drum bass and synth. And then also hard coding. You could maybe create a configuration on the macro pad to decide this at the beginning, but I've just decided that I'm using MIDI CC number 74, which is often used for filter cutoff. And I'm naming the text that shows up here cutoff. Ideally, you'll set this up once and not change it much, at least that part of it. Then I'm setting up MIDI and these are being set up on USB both as an in on USB port zero and an out on USB port one that also travels over one cable. And since I'm reading on three channels, I've got it set up as zero one and two, which is translated from circuit Python zero one two to MIDI one two three. Same with this out channel, I'm actually sending out over MIDI channel one, which is specified here as zero. Then I am setting up the keypad to use these keys, which are from the upper left corner one through 12. And then creating my keypad object. And then here's my big huge list of colors. So that is the official list from the manufacturer of this particular controller. They have some software that you can use to use this controller with pure data, which is free and open source equivalent of max for max MSP. And so I believe you could use this macro pad with some alterations inside of pure data as well as inside of max and probably max for live and live. So there's a lot of options there because they're all sort of living in the same world together. This is this list of the colors you can see color index zero is off is black. And then the rest of these are all the rainbow colors that we can use. And again, you can let me open up the developer guide. I think I saw a link to it in the discord that someone posted. If not, I will bring it up myself. Let's see. No. Okay, yeah, let me let me bring that up myself real quick. So let me go here, here. Oops, go back to that. So if we do novation, launch pad, I think it's called programmers reference. That looks good. Sure. So that is actually what I was using, or maybe the mini mark three one, which has one fewer set of buttons around the edges there. But this is terrific resource. It tells you everything you want to know about how to interact with the device via MIDI. So really cool that everything is done with MIDI. So you don't have to worry about a particular weird new protocol or a which programming language you're using so long as you can send MIDI messages, you can talk to this thing. And here's the color palette. It wasn't listed in here as their hex or RGB values. But I did find that in our cycle, which is this pure data library or patch collection that was created by novation. So going through this thing is really interesting. And you'll learn a lot about how it uses the different MIDI channels and the different velocities to specify different animations and so on. So jumping back in here, let me get back to my code. And let me know if you have questions, I'm keeping one eyeball on the on the chat there in in both the YouTube and on the discord. Someone asked, if you're left handed, can you have the potentiometer on the left side? So this is an encoder. And the one thing you could do is rotate the whole device this way, and then use left handed encoder and get the screen in the lower right. And we have some some code for doing that rotation to flip the screen and flip the button order. So let's see. Next thing I do is I set up the pads. So since live talks to the the pads of the keys with those MIDI note numbers, 81, 82, 83, 45, 78, across the top, and so on. I'm just three wide and four high. So I've set up a little, little dictionary here for correlating MIDI note numbers like 81 to physical keys on this the key switches, which in this case would be zero through 11. Then I have the notes that I can read so that I can again check and see which index I get when a note comes in or when I send a note out. I had to offset my CC values, I can't remember why, by 20. Why did that? Oh, I think I just didn't want to start at zero. The software initializes at zero. And I didn't want to send my CC all the way to the to the basement. So I just pushed it up by 20. It's a hack. The modifier is the state that I'm using to read when I press that in and out. So initially false. And then again, speaking of hacks, the way that I'm actually turning off notes is there may be a better way to do this. But the sort of simplest way I found was inside of live. When you are playing any notes in these any clips in these rather, if you want to turn them off, you can just hit the stop button, which appears in any empty cell. You can also press the stop button down here. But I forget what the deal was with that like it didn't send MIDI when we did that. In fact, we can spy right now. So that's what happens when I play when I hit stop here. Yeah, didn't send the same data that this stop here did. So those you have to set up that's the that's the main thing you can have a big huge session with with clips everywhere won't bother anything but you do need one set of blanks here that we can go to for essentially hitting stop on a clip. Because I didn't find it easier way to do that. So if you do, let me know, I'll be putting out a guide. The code is now in our learn guide repo inside of GitHub. So you can go check it out now and start start having a look. Oh, I'm sorry, I didn't know if I pushed that screen change. So you might not have seen that. So let's see next thing in the code. Yeah, not sure what you're clicking enabled and sorry, let me let me move this screen out of the way and actually send you there you go now you can see it. So in Ableton, any of these blank clips are in this particular row. And that's what I'm telling the macro pad to send. So it's essentially trying to send to a fifth row that doesn't exist. Those are blank. That that and that work great. This this and this did not work great for I think didn't send the MIDI colors back that I needed or something like that. So bring this back here. Make sure update there you go. And so next thing I do is some encoder setup, some neopixel setup, display setup, I'm going to cruise through this stuff because it's really similar to stuff we've done before. Got my little label names for the tracks, setting up the display with all the display IO stuff. And then here's what's happening in the code and the main loop message in MIDI receive, that's the most important thing for that bidirectional for the stuff coming from your computer back to the macro pad, just receive MIDI messages. Then what do we do with them? If the message is a message in note on and the message velocity isn't zero, then I am going to switch the colors on a pad using this array of pixels that I have. So the the 12 pixels of the display and this big array that we saw of colors. So if the velocity is velocity zero, we would be playing that first color there, which would be black if it was a velocity of 127, we would grab this reddish color here, that is the last one in the in the list, if that makes sense. So that's how we're grabbing the taking the data that comes over MIDI and then applying it to setting the colors. Then if the message was a velocity 21, that's the green that shows that that's the pad playing. So we set the pixel to that color, but that's also a little bit of code that I'm using to change the display to whichever ones are playing having those little O's on there. So as I change these around, you'll see pixels go green, because they're the ones playing, but also my little dots turn into O's on the display. If it's a note off message, or it's a note on with velocity zero, they both mean the same thing, then I am. What am I doing here? I guess I'm just printing. I don't need this. Yeah, I'm just printing that out to the display. This is a little just a little more useful for the debug here. If it's a control change that's coming in, we're again just printing it. I don't think I'm doing anything in Ableton right now that's sending control changes right now, but I did see them. So I have that instance taken care of in case you do something more sophisticated in live. Or if you're using other controllers, so that's one of the things you can do is have multiple controllers hooked up to your session, and you may want to keep these in sync with each other. So Ableton uses these MIDI messages to send that info around among machines. And that's kind of just as an aside, kind of cool because MIDI, it was developed as back in 1983 as a musical instrument, digital interchange, I think, or digital interface, that isn't specifically limited to notes. It's anything from one machine telling another that they're syncing up their clocks so they stay in time to having a controller tell a synthesizer switch to a different preset to, like I said, showing a display on a little text showing up on a display. So this is not actually really an off-label use of MIDI. This is kind of what it was made for. It's somewhat funny to see note on messages and velocities used to say colors and channels used to say which animations, but not strictly forbidden, I don't believe. Then let's see the keypad event. This is part of the keypad library. This event is we're checking to see if keys have been pressed. If none of them have been pressed, this is the loop of the program that we've checked for any MIDI messages. Now we're checking for any knob stuff in here. So this is when I'm changing the encoder position, I'm sending the CC values, as you can see they're changing. And then this is my little modifier of clicking the button there. Changes this modifier state to true, which changes what happens when we press keys, which is the last section, kind of maybe the most important section here for actually playing with the thing. When there is a MIDI event or rather a keypad event, we grab the number of the keypad and that can be a bunch of them. But we will then go and check for any of those that have been pressed. If it's been pressed, and I don't have this little modifier held, then we're just going to simply send the note that's correlated to that index. So if you remember, let's say it's the one, two, three, fourth one here, that's going to send, where is it? One, two, three, four, right there. So that's going to send number 71. So that gets that gets sent to live, which tells it what clip to play. If I have the modifier, then I send those modifier notes, which essentially is playing that blank set of keys that don't exist. When I release, we send the note off message, which it doesn't probably strictly matter because it's not a momentary thing, but it is how the protocol works. And same with if we're holding the modifier, it sends to the modified list. And then we show the pixels. So hope that made some sense. And you can get what I'm going on about and what's exciting I think about working with this and sort of reverse engineering this. Not even reverse engineering that much because Novation puts out the guide to tell you how to use it. So it's really just implementing this thing. But it felt sure felt fun and hackerish to get in there and get it to do here the things that were meant for other types of controllers. I will show you let's see if I can share the let me go into the preferences in live. I'll probably have to open a new window share for this. I don't think that'll show up for you. Will it? No. Okay. So let me let me add a window to share here real quick on top. Bear with me. It's going to go into a black hole for a second. This is a dicey thing to do. It's going to make my broadcast software choke for a moment. Almost there. All right. I did it. Shoot. Sorry about that yet. It made my broadcast software think real hard. So if you look at the preferences here in Ableton under this MIDI section here you can see the the way that I'm telling it what kind of messages to send out are by saying OK send out with the protocol for and then pick your device. These are all different manufacturers devices that you can send out from from Ableton. Since the Adafruit Macro Pad is not listed as an official device that's OK. We just pick one that we want to sort of mimic the protocol. So I went with this launch pad mini mark 3 which happens to be the one I have. And then as the input that just says what sort of protocol surface protocol we're using as the input then I'm picking my my Macro Pad for both the input and the output. I'm going to do something funny here and I'm going to say let's make the output be my MIDI monitor. So I can say act as a destination for other programs. Now I can tell this to output straight to MIDI monitor and let's say I may have to close that preference. Let's see if we do. Oh no so it's working OK. So now you can see we can spy on all the traffic that this pairing of live and that control surface want to send out. So if I hit a clip here or a few of them you don't even need to have the device itself to see those messages and you can see what messages come from a device into into the software as well. So pretty cool that it's that that open and I think that's going to do it. So let me know if you have any questions in the chat. That was someone said that was an intense project. Yes that was a lot. But again I hope you dig it. And one thing actually I wanted to show is if we if we plug in the actual device here for a moment I'm going to unplug my macro pad you'll see that there are some things that I didn't yet implement. Let's go to the down camera. So there you can see sorry it's a bit washed out. So there you can see again that's going to do the same stuff. Right. It's going to launch. There you can see the animations. Right. So they do so pulsing and that's because that message came on Channel 3 I believe. And there's me just picking a blank row. One thing you can do is you can scroll. So if you have a bigger session inside of Ableton let me hide some things here in this layout again. Hide Adam and me monitor. Shoot that over there. OK. So you can see that. If you come over here and let's say should be able to copy and paste that and then we'll just change all these colors on this on this one here. So we see the change. So the launch pad here since it has more than 12 that showed this extra column. But if you go wider than the device you can actually scroll through and you can even see in Ableton it's got some little highlight yellow around the section that's linked to the view here. And I did I did set that up briefly just to see it's guess what another MIDI message. So let's see how that works. If I look at my MIDI sources of the launch pad here. DAW out. It has actually two MIDI channels that it can use. If we use the DAW out and I press this right scroll button. Hey look it sends a MIDI CC message. Oh sorry I'm not showing you that. Hold on. Bring that back up. There we go. So watch that MIDI monitor when I use the little scroll button. What's it send. It sends. That wasn't the. Sorry. That wasn't the scroll. There's the scroll. When I scroll sideways it sends a MIDI CC message MIDI control not a not a note on or note off. On channel one. On MIDI. Number ninety four and it's a velocity of one twenty seven followed by a velocity of zero. So that is what has been co-opted for the. Right arrow. Is data channel ninety four or CC channel or CC number ninety four. And ninety three is the left so you could use the left arrow right arrow down arrow up arrow. And those are all just these. Midi CC's being used to scroll around. So you can imagine if you wanted to. Not worry about the knob is a CC and instead use it to scroll sideways and maybe while you've got it clicked you can scroll up and down. You can move around a huge map of of. Info. One of the reasons I didn't implement that is that I'm not able to get info back about the names and then my screen will be lying lying to me so not as interested in that. But it's definitely a possibility. And I'd be interested to see if anyone digs deeper in and finds a way to make that happen. Last thing I'll say is that. I specifically was using the launchpad mini mark three but if you went and. Tried something like the push. Push to that's probably the most sophisticated controller it's made by able in themselves. If you're sending messages back and forth to the push that's where you may see some of these sysx messages that tell you things like names. So if I spy on that stuff. And set my output to be. Mitty monitor. And now come over here and I think I can right arrow. And left arrow is that going to work now. I don't know if you can do that scrolling how you can do that scrolling I don't know Ableton very well by the way so. I just see you know. Not sure what messages it sends. Hey I'm not seeing any messages all right that's not sure why there but I'm going to get out of my depth quickly so. So we'll we'll end it there but thank you thanks for for playing along with me as I do. Funky live stuff inside of circuit python using our little macro pad. And that's going to do for today so thanks for stopping by I will hang out in the chat for a little bit if you have other thoughts and questions. Be sure to tune in for all of our live streams that we have. We've got the 3d print three hangouts we've got ask an engineer we have desk of lady Aida will probably be on the Sunday those generally happen on Sundays. I think Scott has a show and tell or a deep dive tomorrow but I'm not sure so check check the blog for that. And if anyone knows you can mention it in the chat and yeah look our chat even has a little little bot where you can type in question mark showtimes and let you know what's happening. So I'll jump in the in the chat and hang out for a little bit. And I am gonna hang up this phone so thanks everyone for stopping by and I will see you next time bye bye.