 Let's see you all. Oh, gosh, I think I was only live on Twitch, so let me hit Go on YouTube, and there it is. Hey, that should be live now. You may also be watching over on Facebook or the Periscope. Where else? Twitch. So if you're wondering, yeah, who am I talking to? It's these good folks right here in our Discord. So head over to Discord for the chat. The Adafruit Live broadcast chat channel on our server. That's where you want to be. So let's see. Let's get going. I was off last week. It was very nice to get a little time off, see my family, see my parents out on the East Coast. But now I'm here. I'm back in California. Hey, Todd Bot. Todd is watching on Vine. Yeah, every seven seconds we upload a news little slice of this to Vine. And Todd is watching it there because Todd is a Weisenheimer. Hi, Todd. Hey, Mark. Nice to see you. Live on YouTube, because you just turned it on. Well, that's perfect. All right, so a couple things to say. First of all, I've got an Adabox coming up. So if you're interested in subscribing, I believe we have some slots open. So head on over to adabox.com or go to adafruit.com slash adabox. And you can subscribe to the next Adabox. It comes out in July. So this one's coming pretty quick. And it's going to be a super great one. And I believe we opened up a few extra slots because we are jiggering things to deal with the new realities of international shipping. So I believe these are only shipping to a limited number of countries, possibly US and Canada. I could be wrong on that. Someone may know over in the chat. Let me know. Maybe it's just US, but I know that that shift, unfortunate for people who are in those countries where we're not shipping currently, but that did open up more slots to subscribe. So you can also subscribe to someone else. If you want someone to get the gift of a subscription to an Adabox, then you should go ahead and do that because it's usually got a number of learn guides and tutorials that'll tell you how to use the stuff that's in the box. We have a fun unboxing that'll be coming up later in July, I believe. That's our plan currently. So that's going to be Adabox 19. Can you believe that? Show of hands. How many people have been collecting these Adaboxes since the beginning? I have a big wall of them over here. I don't know if my collection's complete, but it's a lot of Adaboxes. Yeah, Mark Gambler says that we do still get it in Canada. We are still sending to Canada. So Canada and the US for sure. Mr. certainly gave us a little raise of the hand saying, yeah, he's been collecting them since the beginning. Amazing. Thank you for your support. That's fantastic. All right, what else? We have a jobs board. You can head on over to jobs.adafruit.com and you can look at open positions. You can also post your own resume if you're looking to get picked up for some work. Just head on over to jobs.adafruit.com. In fact, I'm heading over there right now in my browser. Let's have a look. There's what you can expect to find. If you head on over to jobs.adafruit.com, we have a little explainer there. You can filter the types of jobs you're looking for. Let's say you're looking for some freelance work. You might hit that. I think you can just hit search there and it'll filter that now to freelance. These are all freelance positions, including someone's looking for a tutor for our family in anywhere online, United States. Check it out. Family's looking for some help with some basic Adafruit projects and associated coding. Very cool. And they have Adabox 16 and 18 and want to get started. Well, that's a pretty cool little thing. So if you're looking for some fun side work, that could be the thing for you. So head on over to jobs.adafruit.com and check it out, would you? Let's see, what else is going on? I've got a little show I do on Tuesdays it's called JP's product pick of the week. And on that show, it's usually about 15, 20 minute show. I go into some detail on a product pick. We even do a discount, usually a hefty one, usually about 50% off during the live stream. And it looks like this. This was this week's, which was this NeoKey one by four cutie. And then I like to do a little minute, one minute long recap. So here it is. In case you missed the show, here's the recap. NeoKey one by four cutie, I squared C mechanical key switch board. It has four sockets for placing your mechanical key switches and it has four underlit NeoPixels. So you can plug this into any board that has I squared C and particularly convenient when you have STEMI QT connectors. This is plugged in over I squared C to a feather board. I've set this up to be a little keyboard shortcut board for use inside of Photoshop. If I press this first button, I switch back over to a brush, switch to the eyedropper. This is the eraser tool and here is a gradient tool. I've also set up my little rotary encoder to be a brush size. I can paint in blue, I can hit my eyedropper, switch over to this pink, switch to a different brush, maybe change the size of that, paint in there a little bit. And we can go in a race. So I'll switch over to that eraser with this little shortcut and then we can start erasing. The product pick of the week is the NeoKey one by four cutie. Almost tricked myself there. Yeah, that's right. That's the product pick of the week for this week. And if you head on over there and you ever find that it is sold out, which I believe we may have sold through all of those. I'm gonna head to Adafruit and I'll just type in one by four. That's a quick way to get there. So those are out of stock right now. This is back to full price in 9.95. You can hit the little notify me, type in your email address and hit notify me and you will get an email when those come back in stock. So we're making them as fast as we can. They're really popular. We also have a lot of key switch options now, a lot of key cap options. So head over there to check all that out if you're interested in that product pick of the week. All right, so let's see. The next thing I wanna do, let me head on over to another little screen setup here and we're gonna do our good friend, the Circuit Python Parsec. There I am. For the Circuit Python Parsec today, I want to talk about playing a wave file, an audio wave file inside of Circuit Python on a microcontroller. So we don't need any extra hardware enabled to decode. Say that again. We don't need any extra hardware in order to decode and play back a wave file. Actually, it's not even decoding. It's just a playback a wave file because they're generally not encoded. It's an easy one to play back. And the key here, I'm gonna jump over to Adam here. The key here is that we have this library called AudioCore and from there we can import the wave file. And once we have that, we can go ahead and open up a wave file that's on disk. So you can see here, I've got four wave files loaded onto my little QT Pi sitting right there. And then I have a little macro keyboard. Actually, that's that one by four plugged in there. So I can pick some different samples. So I open those wave files, I assign them to the wave file object. And then I am actually gonna do something fun here. I'm gonna play them back at different sample rates which will speed up and slow down the samples. So next thing I'm doing is setting up I squared C so that I can use my little one by four Neo key here. And then playing back wave files once you have them opened is as easy as audio.play and then the name of the wave object that you created. So in this case I have audio.play, wave zero, wave one, wave two, and wave three. Now when I click on these keys, you're gonna hear... So I have those playing back in the different frame rates. It's kind of this computer-y voice samples that I got off of a synthesizer of my actually the 1010 black box. And by playing those back with just this simple audio.play, I'm not waiting for them to finish. I'm not stopping or starting. I'm actually able to do this kind of re-triggering thing. And I'm able to interrupt them with the other samples. So it's great for just being able to play back the samples at your fingertips. And that is how easy it is to play back a wave file inside of Circuit Python. And that is your Circuit Python Parsec. Yes, so someone mentioned in the chat, Jim Hendrickson said, I like those retro keycaps. So these are actually, I'll show you the full board. These are some keycaps that I got for a keyboard. I'm building for my mother. I saw my parents when I was away on vacation last week. And I was talking to my mother about what I'm up to, including mechanical keyboards. And she said, I want one. Cause she has a little chicklid-y keyboard from Apple, one of the little iMac keyboards. I shouldn't like it at all. And so she wanted something with some nice tactile keycaps. So we got her Cherry MX Browns. And she really liked the color blue and the look of these really clear legends. These in fact, these are a very, very, very, a particular manufacturing method and a particular, let me take that key off of there from the hot socket and then pull the key off of the stem. These are particular manufacturing technique that's called a double shot. So you can see this uses two different injection molds with two different colors of plastic. So there is not a label that's printed or disublimated or lasered. That is actually two pieces of plastic and you'll never wear those off. So that's one of the nice things about this type of a keycap. And then the profile of this is a really deep one with a, it's tall and it has a deep finger recess here, sometimes called a spherical layout. These are from signature, a design by Signature Plastics that is called SA profile. And I believe Colin Cunningham did a video on TikTok, one of his short videos about different keycap profiles. But I'll show you the full board over at the work bench because it's pretty cool. This is gonna, let's see, will that play? No, I've turned down the volume. Before I do that, also I wanted to mention that I didn't have time to make this before the product pick of the week show yesterday, or on Tuesday rather, but right after the show I decided I wanted to make a little 3D printable switch plate type of thing that keeps the keys from kind of wobbling. So it locks the keys in and I've made the design pretty dead simple so that I can just print two of them. So there it is, duplicated at the bottom and then drive a little M2.5 screw through there with some spacers or washers as spacers just to give myself a quick and easy little type of sort of case for this. And I'll post this up on Thing Aversive if people are interested. So it's a very minimalist thing. So let's, oh yeah, comment from the chat. Todd Bott mentions that if you're looking for free, freely licensable samples, a good site to go to is freesound.org. So if you head there, type in a search and you'll find there are public domain and free to use in Creative Commons, licensing, different types of licensing where you can use the sounds that you find in other projects. Question from WagonLoads over on YouTube is do you have any old metal rim style typewriter keys? Yeah, let's see, where are they? I have three or four typewriters here on a shelf somewhere. I think they're packed away so I can't grab them. One of them was mine that was actually my dad's and my mom's, they both used it. She's probably why my mom wanted some tactile keys on her keyboard, all mechanical keyboards I have that are really long throw. I really got to press them to type on them. Three of them I got for a project I built a few years ago. One of them has just been in my family and one of those is plastic keys and I think the others are like that metal rim which is pretty cool. So this actually, this profile was based on an IBM Beanspring terminal keyboard I believe. And actually I'll go to, let me go to a website here to look at this real quick. Since we're all mech keyboard cuckoo right now, let's go to, if you go to Signature Plastics, they are the ones who created this SA profile. Let's see, they got any keycaps 101. Yeah, that's a good place to learn about the different profiles of keycaps. So we use these little, these kind of uniform flat ones on a lot of projects because they can go on an ortho linear grid. They don't have different heights from each other so they work well for macro pads. In fact, that's what I've got here on this little MIDI keyboard that we're going to talk about today. And they've also got sort of your standard OEM they're called and Cherry profile which is really similar to OEM. It's kind of your standard keycap. And then there's these SA profile which are a very swoopy kind of profile. In fact, I'm not seeing a lot about it on their site. So let's head over to the workbench and I'll show you, this is the keyboard that I'm making for my mom to use. Let me zoom that in real quick. Let me focus that, should be something like that. Let's head over there. So move that blue tack out of the way. So this had different, this is a keyboard I got for my mom that had some of the particular requirements she was looking for. She wanted the Cherry MX key switches on it which have a little bit of a tactile feel to them, a little bump but they don't click. And it had other keycaps we got rid of those and I ordered these nice double shot blue ones. And if I turn this here you can see, try to zoom in and focus. You can see that they have a pretty distinct profile. So these two rows are actually the same shape and I'm gonna get these wrong but I think this might be R4, R4, R3, R2, R1, R2, something like that. And those shapes kind of give you a curvature that's I think meant to be ergonomic, meant to match sort of curvature of your fingers and they have nice deep wells. So they're kind of feel good to type on. So that's the story behind those. And like I said, these are these double shot plastics so they have, she wanted really high legibility because the Apple board she had looked kind of like this old one I have here but even less legible. It was like a light gray on white. I think they were backlit which is when you have backlit keys you end up with this sort of translucent gray but she's not working at night, she's working during the day with lights on and wanted something highly legible. And so this has this huge typeface, huge font on here and I think it just looks great. The only thing I'm waiting on on this one is some alternate keycaps I got which will give us instead of windows, it'll be a command logo, the little cloverleaf and instead of alt, it'll be the option logo which is that weird diagonal slash horizontal thingy. The rest of them are all good to go. And that keyboard, this is a keycron is the brand and they're one of the few that make a Bluetooth she wanted a BLE keyboard wireless and Mac has a little switch on the side for Mac slash iOS versus Windows slash Android. And that means you don't have to do any reconfiguring on the computer, you just flip it to that mode and this works as the command key and these work as the option key. So that's the keyboard that those keycaps came from. And if you'll notice here since that keyboard is a 10 keyless layout which means it has pretty much the standard layout of keys except for it does not have the number pad off to the side sometimes called the 10 key. So it does have the arrow pads and this little cluster here. Since it's got no number pad, the only row of numbers is the sort of typical one across the top there. And that means there were, I'd love to know how long ago my audio died. The batteries on my transceiver receiver just went out. So did you hear anything I said? Well, I was over on the workbench, let me know. I'd love to find out how much of that just was empty space. It was off for a few moments. Oh yay, that's good. So I was saying that yeah, that's a 10 keyless layout for the keyboard for my mom and so it does not need the extra set of numbers and a few others that come in sort of a full set and if my mom doesn't mind, I'm gonna keep them because they're awesome and I wanna make a little number pad like a straight up using for entering figures and doing a calculator, calculation kinds of things. Yeah, sorry, I see also over on YouTube people were yelling at me, no audio, no audio. So it looks like it didn't miss out for more than a couple minutes according to Todd. So thank you. So that's the story behind those keycaps. And so speaking of keycaps, I know it's keycaps, keycaps, keycaps but we're gonna move on to what I wanted to talk about today is actually an extension of the project from my last show before I went out on vacation and let me do a little setup here. The project that I worked on that last show was a, I used a different, I have two of these Pico keypads that I built, little macro pads that I built back when I did that project. And this one I think was particularly neat to use for the MIDI project, the modal MIDI project. So I showed this off a little bit but I had just kind of come up with the concept and got it working as a prototype and then actually on the airplane to and from my vacation, I worked on the code and then a little bit too once I got home. And I just committed that code to our Learn Guide repo on GitHub and I'm going to write a guide on creating this MIDI controller. Let me focus a little bit on this, I think it's up. Creating this little MIDI controller that prevents you from ever pressing a bad note, playing a bad note. So the concept behind it, sort of rehashing a little bit from last time, is that we can play three octaves of different modes or one mode and one key in three different octaves. And what a mode is, is essentially a scale, a subset of your typical chromatic scale that is just often like triads or notes that sound good together without any of the maybe bad half steps between them. For example, it could be a major which is all white notes in the key of C on a typical keyboard. And so what I want to do is allow you to do a bit of a setup when you start this or reset this. So if you add power to the board or you reset it, what it's going to do is it's going to allow you to pick your key first of all. So that means we want to be able to hit any of the first 12 keys on this and I'm starting at the top here like this. And that means we can press C, C sharp D, D sharp E, F and so on. And then I'm going to use this as the enter key which means I'm going to stamp down my choice there and you can do this by ear this way. You don't have to go in and type some new code. You can plug this into the REPL so that you can see your serial output and you'll see the note name. Once we pick which key we're using, then you get to pick one of, I think I have seven modes as choices. So again, we can press any of these first keys and I wanted to preview those scales or those modes. So let me take you through a demo of that first of all. What I'll do is I'm going to reset the board. So I just pressed, I have a little extended a long button there on the side of my little PCB. And so that's reset the board. So now it's in a mode where it wants us to pick a note that's going to be the root note of the key that we're using. And I'm going to turn that volume up a little bit. Hopefully this isn't echo-y. Okay, so those are from C to B what notes that we can pick for our key to be in. And what I'll do is actually I'm going to open up my code editor here and let's open the code that's running on that board. I'm going to pick that Pico MIDI and I'm also going to open up my serial output. And I may have to unplug my little camera switcher that I, oh, you know what? No, I didn't need to. That's the one that I set up to not need to be unplugged. Whoops. USB. Okay. So actually I'll do the restart here and we can do that just by hitting, I'll just resave the file. That's one way to do it. Okay, so here's the little feedback we get. It says Pico MIDI modal mech keyboard. Pick the root using the top 12 keys, then press the bottom right key to enter. And I did a little graphic there so you can see the pressed keys or the dots and the not pressed keys are the letter O, they're the circles. So now it's telling me what root note we're picking. I'll go with C. By the way, why are we hearing something? That's because we're sending a, I have this plugged into my computer and I'm running a piece of synthesizer software that is receiving MIDI commands from this keyboard. So this on its own, if you're curious, this does not have any sound playing capabilities on its own. And you know what, let me move, let's see, I'm gonna switch to that layout. Yeah, that'll make it nice and easy. Yeah, we can see everything now. So now if I like that key, what I'll do is I'll press my little enter, bottom right, it says okay, your root is picked. It's the last one that we saw there. Pick the mode with the top seven keys then press bottom right key to enter. So when I pick one of these, it's gonna tell me the name of that mode and it's gonna play through all of the notes of it. Okay, so that's a major scale, also called an Ionian scale. And now the same pattern of intervals between notes is gonna exist in this minor scale, which is next except for one note, which is gonna be a half step smaller of an interval. So if you look there, if we scroll up, we can see the C major goes C-D-E-F-G-A-B-C and the minor scale goes C-D-D-Sharp, F-G-G-Sharp, A-Sharp, C. So we get a slightly different pattern there for a different mode. And I can now go through and try others. That's a Dorian mode. Whoops. That's a Dorian mode again. Phrygian, Lydian, Mixolydian, and everyone's favorite weird mode, Locrian, which I think my son said is the mode that sounds evil. So once we pick a mode, so let's go ahead and we'll do Mixolydian. Now I'm going to enter that in and it says, okay, Mixolydian mode is picked, ready, set, play. So now these rows will each play seven keys. I don't actually get all the way up to the next octave until we jump to the next row because this is only a seven by three keyboard, seven wide, three high. But you can see I've got the three octaves of the same notes and I'm also sending a little bit of feedback to the serial port there telling you the name of the note. So we can play a whole column of these and you'll get essentially three octaves of the same note. Also this synth patch that I'm using in the synth software, this is Helm that I'm running right here. You can see this guy. This one happens to have some glide in it, which is why we're hearing those notes sort of allied or slide into each other. So let's see, I think I might be able to, is that the portamento? Let me turn that off. I like that better. I didn't really want, I didn't intend to have that glide there. So now we can play not only chords and we'll let that resolve. So I don't know what the heck I'm doing. I don't really know the music theory behind these. There's not a chance that I would be able to play those properly on a regular keyboard, but not only can I sort of noodle around in a way that sounds pleasing and is fun, I can also do it in different keys. Again, it's gonna be the same stuff. So if you end up with a pattern you like, if we go ahead and restart this, let's say, I'll just resave and pick a different key. We'll actually use the same notes on here. So the interface allows you to remember the same things, the same fingerings of chords and so on without worrying about what key you're in. So if you're trying to play along with someone else who's in a particular key, you can agree, okay, we'll be in D now and same mode, let's say, is it right there? Okay, and now, so now I'm playing the same sort of patterns, but I'm in a different mode, which rather I'm in a different key, which is terrific. And that's sort of the power of a electronic music instrument is that we don't have physics in the way. You couldn't hold the same holes down on a clarinet, let's say, and get the same mode in different keys. You'd have to actually adjust and learn some different fingerings of that. I studied clarinet briefly back when I was a kid and I was terrible at it, so that's why I really like these types of interface myself. Not to say one is better than the other. There's a lot of really impressive skills that people gain playing real instruments or traditional instruments. My daughter plays piano and keyboards and is terrific at it, but I just don't have that skill set and I haven't put in the hours, so I love relying on something like this to noodle around in a pleasing way. So let's talk about, let me just check in on Discord actually to make sure you can all still hear me. Yeah, good. Todd Bob asked if I have a Depeche Mode. We should make one. The code, let's have a look at now, so I'm gonna hide this a little bit. So here's what's going on in this one. This one's actually interesting because a lot of the times when I create some code here, this is in Circuit Python, I will essentially have two sections of my code. I'll have set up things and then I will have the code running and the set up things usually just take care of themselves. So it's stuff like initializing this keyboard to have 21 keys using the debouncer and setting which notes will correspond to which keys and then the main loop of the program is just watching for keys to get pressed and sending out MIDI notes. This one is unique because I wanted to create this sort of configuration mode. So since I've used up pretty much all the GPIO on this Pico here, I didn't use a matrix for the keypad scanning. I'm actually just one to one GPIO to button. So I basically have no spare GPIO. This one GPIO I have spared that you could use if you had to but that one's a little funny, that's GPIO 15. I think that works now. I think that was some stuff that got funky at the beginning and might've been fixed in Circuit Python 7 I think. But so since I didn't have GPIO leftover, I couldn't really create let's say a couple rotary switches or encoders and a screen to say, hey, I'm gonna pick a mode and use some buttons and have a user interface. So what I wanted to do is just have an on startup. It waits for you to do something which is pick your key and then press enter. And then it kind of does another chunk of code where it's gonna wait for you to pick your mode and it allows you to sample those modes like you've seen me do. And then again, hit the enter key and we get the chunk of code to say great, we'll move forward and then we run the main loop of the program. And so what I'd like to do is talk about that a little bit. In the code here you can see what I do is import a bunch of libraries including time, board, so we get the pin definitions, digital IO, that's how I'm setting the pins to be input pins so we can read them with a built in pull down resistor. So they go high when we click them. I'm importing USB MIDI and Adafruit MIDI and then I'm bringing in note on and note off as well as the Adafruit debouncer and this is something I updated. Last time I showed this I wasn't using the debouncer but I like it and it makes my code a little neater and easier to deal with. Next we can pick our MIDI channel. So when you're working with MIDI there's 16 different channels that are usually referred to by the device and the user as MIDI channels one through 16. So I allow you to pick that based on those sort of normal conventions and then when we set up the MIDI object we subtract one from that because the library actually is gonna consider those to be zero through 15, it's zero indexed. So we just subtract one from what the user sets but you could go in and say, okay, I'm gonna be on channel seven and that'll set that up properly for you. Quick question over from the chat. Is there free MIDI synth software I can play with if someone literally wants to play with it? Yeah, for sure, I really like this one that I've been showing here that's called Helm. Look for Helm, it is I believe open source and free and the creator has another synth out. It came out recently that does FM synthesis and I'm blanking on the name right now but go look for Helm, that's a really good choice and pretty straightforward. You can start playing immediately. There's a lot of preset patches so you can get different sounds and then you can go in and start noodling with modulators and different settings as you like. So let's see, the next thing I do is I create a little function here that's called send MIDI panic. And the reason I do this is sometimes a bit of communication gets interrupted, particularly if you, let's say unplug a device while you're still holding a note down then that note just holds forever because the MIDI synth is waiting, the synth is receiving MIDI is waiting for a note off or a note on with a velocity of zero in order to stop playing a note that's playing. And so when that happens, I wanna be able to send MIDI panic which is really nothing more than a brute force note off for all MIDI notes and MIDI accepts notes from zero to 127. So there's 128 messages that just get sent really quickly in this little function and that stops the madness. And I can actually demonstrate this, let's see, let me put helm in front here real quick and move it and I'll scale it up a little bigger and shoot that over. So what you'll see here is helm has a little virtual keyboard down here. So if I hold one of those and keep that held down that's the kind of thing that happens when there's a problem with MIDI and suddenly a note is, you can't be released until you press it and release it again. So what I can do now is I have this, let's see if I can do it. I have a five finger death grip, let's see. Okay, so the four corners and the center button when I press those, that's the condition that sends MIDI panic and that just, you can see it, I didn't let go of the mouse, it was still held, it was trying to play that and then it just cut it all off and it won't re-trigger until you re-click it. So MIDI panic is super helpful. I've built MIDI controllers before and microcontrollers that are doing MIDI things before without it and you usually regret it because sometimes a note gets played that is super high and you can't even get to it on the device, it could be beyond the range of what you're gonna do. Wagonloads on YouTube chat asks where can I get a complete list of MIDI commands? You can go to the MIDI organization, it might be at midi.org, I can't remember and they have the full spec, like hundreds of pages of white papers on MIDI or you can just kind of Google for, I've often found like music departments at universities will have nice, easier to read versions of the sort of parts of the MIDI spec that you care about. As far as the MIDI commands that I'm using here, these are part of the Adafruit MIDI library and for that you can go to our read the docs. If you Google circuit Python, MIDI, read the docs, you will find the full documentation for that or check on the learn guide section of the Adafruit website. If I have time, I'll go pull that up so you can see that. All right, so let's see, next in our code after creating this function then I can call it later which I'll show you but right now it just sort of sets that function up so that it's something that we can ask for later just by saying send MIDI panic parentheses that will send that rip through all those notes and turn them all off. Then I turn on the little LED that's on the Pico there so that I know that I'm in startup mode. I decided I didn't want that LED in my face when I'm playing the thing so it only comes on during startup and then it turns off but you could probably also do things like have it blink when you press a note, that sort of thing. So then I set up this list of pins that I'm using which is basically zero through 21 except for I don't use GP 15 in there. That's the one that's a little funny. Then I'm creating an empty list here for keys and then populating it with the pins that I'm using. So that essentially puts all of those pins numbers into a zero through 20 list. So key zero ends up being GPIO zero and on through except for the last one which is 20 instead of 21. When I'm in the config I wanted to play the sort of lowest octave and one thing you'll notice when I play notes is that not only am I saying what note I'm playing by note name but I'm also putting a number after that and that indicates the octave. So depending on the key that we pick at the beginning the middle row will be the three which is sort of the center middle C sort of section of the keyboard and then an octave lower, octave higher. So you'll see those numbers listed after there. So when we're doing setup I think I'm picking the lowest octave here. So these are MIDI notes by number 48, 49, 50, 51. So that's the chromatic scale when we pick what we wanna play. Then I create a full list of the note numbers. So that's just straight on through three octaves and I create a list of note names that's in the same order and that is what I'm gonna use later to be able to know when I press a note and it sends a MIDI key number I can also print the name of it which was just helpful for me in debugging and looking at the thing. Some people have also mentioned using this as a note trainer or an ear trainer learning how to do recognition of notes and you might wanna look up occasionally see did I hear that note right? Is that enough sharp and this will be helpful for those kind of cases. Then I create this variable scale root which is the root note, the first root note. And in case we don't pick anything if you don't type in anything and just hit the enter key twice you'll get a C, you'll get that C2 as your root and you'll get I think mixolydian is what I picked as your default scale. If the root is picked or not and if the mode is picked or not these are the variables that I'm using as a state to hold the code in that config section so it doesn't move on until those become true and I'll show you those in a moment. And then my mode choice, which mode are we picking? Zero through six. So then I print to the user this little helpful thing if I hit save it'll just restart it and you'll see okay Pico modelled my keyboard pick the root using the top 12 keys and then I sweep through the 12 keys so for I in range 12 actually I think that could be 11, couldn't it? I think I can, I think I have one too many there. If keys are updated is this line here is gonna look through zero through, I guess that's zero through 11, right? That's correct. It's gonna look through each of those to see using the debouncer that's what this update is has a key been pressed. If a key has been pressed which is the spell condition then the scale root becomes whatever note that is whichever key is being played. We send that note that's how we're previewing it and then we print that out. So that's, so let's say I pick A there. When the key rises I just send the note off and that turns off the note. Oh, I can get rid of this. This is, I commented that out and it was before I had added a bunch more to the code. And then I, after running through all of those to find have we pressed a key then I check for the enter key which is this key 20 and that's us just sitting there waiting. Since this says while not root picked and if you remember up here, root picked equaled false. So this essentially means this chunk of code, this little loop hangs, the just sits there waiting. It's just hanging on until nothing else is gonna happen. It doesn't look further. It doesn't run any further code. So that's how I'm able to have a little configuration that happens in multiple steps. So it's essentially waiting for user input there. So when I press this enter key that is what created this condition that allows us to get out of this loop and move to the next thing. So once I did that, I then am moving on to the modes. So here I've listed all of the modes that I wanna use and there are others that exist but these are the ones that I wanted to use. So major minor Dorian, Phrygian, Lydian, Mixolydian, Locrian. And what I did here is I defined the intervals that are relative to the root note. So if the root is C then the intervals are C and then it skips C sharp because that would be one above it, but it goes to D and then it skips D sharp and it goes to E and then it goes to F and then it skips F sharp and goes to G. So that's that all white keys in the key of C major scale are these intervals based on the root note. Often this is, if you look at this, the way this is taught or you look at this online is often expressed as whole, whole, half, whole, whole, whole, half, that kind of a relative to the previous key but for when my brain works and the way I was coding this it seemed easier to just base it on the root and then what notes are in that are gonna be the root plus two, plus four, plus five, seven, nine, 11 and that gets us the major scale. So those are all the different modes with all their different sets of intervals. Then I create a list here for modes and I append to the minor, major, Dorian, so on and then I also created a similar list for their names so that I can print those easily and then I take whatever intervals that we're using and that becomes a copy of at first Mixolydian just because that's my default but later if we pick a different set of intervals using those seven keys then that changes what this intervals variable list is. Then I print out this that you see here which says pick those top modes and then this is the same thing as before except instead of just one note it's gonna play through the full scale it's gonna hang out while not mode picked which means any key I press plays a thing for me but it doesn't move on because it hasn't changed the fact that mode picked is false until I hit this last key. So when I press that now it moves forward in life and it says okay we're gonna create the scale we're gonna go and grab the root note let's say it was 48 and then we're gonna create that list seven it's gonna loop through it seven times and it's gonna add whatever those intervals that I showed before two, four, five, seven, nine and so on and since I want a list of three sets of octaves I go ahead and create this MIDI notes list and I append to it three sets of that same set of notes but the top one gets two octaves added to it so I add 24 to each value and then I add 12 to each value for the middle one and then the bottom row is the one that I already had the numbers for. That is the setup so that's how we have these two config things that happen and now we're in this play mode and so this is what we're used to seeing as the sort of main loop of the program which is while true so it just runs that continuously because true is true it's the most philosophical part of the code here. What happens in this is we do this one thing which is run through all of the keys that we can press through all checks all 21 keys to say I have these been pressed this is using the debouncer here keys I update and then we check if something's been if we hit a button so it fell that edge detection of it going from high to low then we're gonna play the note of whatever key that is and we also print the note name out here this here note index this is where I'm comparing the note that's played which item in the list so if it's the say the first item in the list then I grab the first item in the note names list and this is just how I'm able to grab a name and print the proper name here and then this try accept here is to deal with the six key limit which I've mentioned before I think we can Dan Halbert's been working on a lot of stuff where we'll be able to pretty much press all these keys at once without a problem but right now I'm avoiding an issue with hitting a seventh key simultaneously by having this try accept and then the same sort of thing happens when a key goes from low to high that's the rise state of the debouncer it plays sends a note off for whatever key that is so it sends note 48 off velocity of zero and then we grab the name by correlating that index and then same thing here with the try accept and then the last thing I have here is this is my little key combo for the MIDI panic so it's the four corners and the center if you press all those boom it just said all MIDI notes off it just ran through and played my MIDI panic which runs from zero to 127 turning them all off and this is how I check for that I just am checking for the value of those using the debouncer again is key zero, six, 10, 14 and 21 pressed and then we have a little sleep there so that is how it works let me know if you have questions I can see over in the chat there's philosophical conversations going on about zero equaling one and that just blew my mind the question over in YouTube wagonloads asks can it be set up to record MIDI sequences so you can play with music arrangements not with the code that I have here it's definitely conceivable that you could create a mode where you are generating sequence lists and then saying okay I've pressed these five notes in a certain order maybe even the timing of it and then hit a button and it'll loop that but that gets complicated quickly and timing becomes really, really important so it's nothing that I'm attempting with this I have a friend, our good friend Steve Nureco who creates the OMX 27 which is a little mechanical keyboard MIDI keyboard and sequencer and that does, it's written in Arduino and it does a ton of sophisticated sequencing things so that code is open source it's on GitHub, it's called OMX 27 look that up and you'll see a little bit behind the scenes of what it takes to create a sequencer basically from scratch which is really cool and let's see, I think yeah, doctor said oh helm is multi-platform I believe it runs on iOS, Linux, Mac, Windows and maybe Android I'm not sure about that that last one but yeah, helm is cool it's a really nice intro to synthesis and it kind of does everything you want right there it's got arpeggios I know someone was asking about arpeggios yeah, you could definitely use this for as an arpeggiator you could code it I should say to be an arpeggiator you can also use arpeggiation in your software so if I, let me pop helm up here for you for a second again if I go into helm and pick the different patches I'm going to filter by arpeggios let's find a more traditional one right, so I'm just playing individual notes I'm only sending a note on messages note off messages just like before but the software is handling the arpeggiation so it's kind of a neat thing arpeggios can be done in the device itself which you'll see in a lot of MIDI controllers they'll have arpeggio modes and you can pick things like when I hold three notes play them ascending or play them descending or play them ping-ponging or play them randomly so there's a lot of neat stuff you can do on the device that might be a cool next project for this and I'm planning to do a version of this with our macro pad if you haven't seen this we have a really cool new macro pad on the way let me go to ate a fruit and if you look at this this is an RP2040 based macro pad again you can sign up to get emailed when it's in stock we had about 50 of them I think yesterday that we sold through really quickly but we'll have more coming this has an OLED screen on it and it has a push encoder so it's a rotary encoder that also has a click button that would be great for setting up a more sophisticated version of this software because it gives us an interface for doing things like picking a key picking a mode picking an arpeggiation style picking a tempo so one of the intrinsic things about an arpeggio is that it's playing a pattern so what's the tempo it's 120 beats per minute, it's 80 you'd want a UI for that and I think we would pretty quickly grow annoyed trying to adjust that without a screen and without a knob in sight on my little macro pad here if you are curious I mentioned this last week but if you're curious about the macro pad that I'm using here I wrote a learn guide on it and it is the Pico mechanical keyboard with fritzing and circle python so this goes over how to build it bring that up there I show what the schematics look like for it it's super straight forward because it's just using straight GPIO no matrix and I also go into some detail about how to build a PCB so I show you the schematic of it and how to create that in fritzing but then I went step further and created the PCB inside of fritzing as well so that'll give you a little bit idea about this and like I said we've got lots of cool mechanical key switch stuff coming including our little friend here this little one by four you could use that for a very similar type of program and that actually segues a little bit into a question from our discord which is, Mr. Certainly asks where did you get those awesome blue tone double shot key caps those came from a company called Max Keys M-A-X-K-E-Y-S and I ordered them through a website called Keyboard Fans I'll bring that up if you look at Keyboard Fans website I've searched based on the profile so this really cool IBM Beam Spring Reminiscent Key Switch Profiles called SA Profiles so you can search based on that profile and then this set was the I think it's called Ocean I think it's on page two and I think that's it right there so he has Max Keys the company SA is the profile Ocean is the color they're not cheap these are $100 but they're super nice and you might be able to buy them other places I think AliExpress sells them as well basically the same price and it came pretty quickly too within about a week coming from I believe Taiwan maybe China, not sure so that's those key caps but in case you were wondering yeah the keyboard hobby is a money pit you can hand wire stuff you can 3D print stuff so you can make it cheap if you want but it can get expensive quickly especially with these nicer double shot key caps alright I think that's it our peggios are fun so that's my little keyboard project there for the week and the code is out I hope you found it helpful to do a little walkthrough of it if you want to check out the code I don't have a learn guide for it yet but I did commit the code to the Adafruit Learn system so if you head over to GitHub and go to the Adafruit GitHub so github.adafruit and then click on the Adafruit Learning Systems Guide repo in here you will find if you search for the word MIDI or let's see there we go MIDI modal keyboard we have a lot of MIDI projects that's the code right there that we just went through today and you can get started with that right away so I think that's gonna do it for today any other questions Keith Schlattauer says we are divo that's right we are not men we are divo yeah that's gonna do it also doctor said the helm hates me so if you have any problems with the helm look I think if you search just for the word helm in the Adafruit Learn system there's a MIDI project I did a couple years ago in which I list a bunch of free and open source as well as paid for synth software for your computer you might want to look into some different options if you want to get a modular synthesis on the computer I recommend VCV Rack which you can control with MIDI as well and then you can get into more of a sort of traditional synthesis with modules plugged into modules plugged into modules that each do discrete things alright that's gonna do it for today thanks for hanging out and I will see you next Tuesday for another JP's product pick of the week I will see you next Thursday for another John Park's workshop this thing right here and then we have a whole bunch of other things in the mix there I believe the Reese Brothers will be back with their 3D Hangouts next Wednesday we'll have a Descalady Aida I think this weekend they tend to happen on Sunday nights but your mileage may vary and someone tell me I believe Scott might not be on tomorrow I think he's still out but he's usually on Fridays with his deep dives if he is then awesome and then of course Wednesday is our big big day with not only 3D Hangouts but also show and tell and ask an engineer so go do that go sign up for Adabox if you haven't and go have fun making stuff would you alright I'm gonna play some music and get out of here bye