Tag Archives: HackSpace magazine

RetroPie Cyberdeck | HackSpace #47

via Raspberry Pi

You know we love a good cyberdeck around here, and we think you’ll love this video game emulator fresh from the latest issue of HackSpace magazine, out now.

We’ve only just finished printing a series on building a games cabinet using the RetroPie games emulator on a Raspberry Pi… and now something comes along that makes our plywood, full-size arcade machine look old hat. 

hackspace cyberdeck

This mostly 3D-printed cyberdeck features a 5-inch 800 × 480 touchscreen display, as well as the usual ports available through the Raspberry Pi 3 Model B+ that powers it. Quite how useful the screen’s portrait orientation will be for Sonic The Hedgehog is anyone’s guess, but if you’re playing any sort of top-down shooter, you’re laughing. The maker describes this project as a “video game emulator with some edge” – we think it’s pretty impressive for a project that began as an excuse to learn 3D design.

hackspace cyberdeck

HackSpace magazine issue 47 out NOW!

Each month, HackSpace magazine brings you the best projects, tips, tricks and tutorials from the makersphere. You can get it from the Raspberry Pi Press online store or your local newsagents.

hackspace 47 cover

As always, every issue is free to download in PDF format from the HackSpace magazine website.

The post RetroPie Cyberdeck | HackSpace #47 appeared first on Raspberry Pi.

Meet Anna Ploszajski: Where making and materials meet

via Raspberry Pi

In the latest issue of HackSpace magazine, Andrew Gregory meets Anna Ploszajski to explore the bit of the Venn diagram where making and materials meet.

Anna Ploszajski (pronounced Por-shy-ski) is a cross-channel swimmer, a materials scientist, a writer, and a breaker-down of barriers to scientific understanding. 50% of the HackSpace editorial team listen to her podcast, Handmade, from which has arisen a book: Handmade: A scientist’s search for meaning through making. Naturally, we wanted to talk to her to find out why we humans do what we do when we turn object A into object B. That’s a pretty big question, but if anyone can answer it for us, Anna can.

anna ploszajski glass blowing
Anna’s journey into making began with watching a bit of broken glassware getting fixed
(Image: Charlie Murphy)

HackSpace: Hi Anna! You’ve written a book about making. Before we get on to that, though, we’d like to ask you about something you’ve been working on in your non-writing life – 4D printing. A while ago we saw a box with a hinged lid; the hinges were fabric, and the box was PLA, so you get the benefits of two types of material in one object. I guess what you’re doing is rather more advanced than that?

Anna Ploszajski: You say that, but I’ve been doing quite a lot of experiments in 3D printing onto fabric to try and make a 4D thing, because PLA has a kind of shape memory. I was wanting to do the experiment that I was doing (which actually I described at the end of the book). I’m trying to draw a conclusion about how my adventures in craft had also impacted my scientific research life. And the example that I use is this experiment that I did 3D printing onto fabrics. 

What I was doing began with  sort of pre-stressing, just normal textiles. I think there was a cotton, linen, pre-stressing it, just stretching them out with my hands, and then attaching them onto the print bed. And so, you already put in a kind of internal strain into the fabric, then 3D-print a very simple design that was either a circle, or just simple lines. And then obviously, when you print onto it, then the PLA plastic is bonded onto the textile. My idea was that if you then heated that material up, then it would soften, and that tension that you’d put into the fabric would be released. So that was my idea. 

anna ploszajski with woollen materials
Anna’s mission is to make science available to non-scientists
(Image: Steve Cross)

My project was all to do with exploring this idea of 4D printing. So printing, using 3D printing, to make objects that move in some way after you’ve printed them. The thing about it is, it’s adjacent to this topic of smart materials. There’s a family of materials that have some kind of smart property, usually it’s colour-changing or shape-changing in response to an external stimulus. So, that could be temperature change, or light levels or moisture levels. 

And those smart materials are not actually that smart, it turns out, because what they do is really simple. Let’s take the example of a really simple shape change: wood is a really good example. It expands when it gets wet. And it contracts when it dries out. By our definition of a smart material, that is a smart material because it changes shape when there’s a change in environment. And that’s a very simple  movement. And these smart materials tend to just have this kind of flip-flopping between two simple states – either, you know, an expanded state or a contracted state in this example. That’s not actually that useful, unless you can do a clever design to use that movement to form a clever kind of motion. 

A really good example in nature is the pine cone; the spines of a pine cone have this really ingenious bi-layer structure, where one side of them has a very hygroscopic wood – it expands a lot when it gets wet. And the other side doesn’t expand a lot when it gets wet. So, when the pine cone gets wet, it’s that bi-layer structure that causes that movement. The wood itself is just expanding. But the contrast between the two is what causes that motion. So I was trying to get inspired by that and combine, using clever design, a quite simple, smart material with some design that would combine it with a non-smart material that would cause some kind of motion.

It’s all to do with stored tension, and  triggering that tension release. And to be honest with you, I didn’t get very far with it. I understand the material side; that was fine. And I could do all my experiments in the lab, and I could characterise the materials fine, but I just don’t have a designer’s brain. 

And that is what the book is about in a way: trying to access or tap into these other skills that designers and makers and craftspeople have which I don’t.

hand made bookcover
Anna’s book Handmade: A scientist’s search for meaning through making is available to buy now

HS: How much have you learned over the course of writing the book? You must have had to speak to all sorts of people to research it.

AP:  I think that meeting all those craftspeople, and getting a view into their world, really gave me an appreciation for exactly how much work and time and skill and practice goes into really honing these skills. Wood is a really good example: when I did the wood carving workshop with Barn the Spoon, it took hours trying to make a spoon, but when I did it, mine didn’t look anything like 
his spoons. 

The skills themselves are often not that complicated or difficult to do. It’s the constant practice in refinement and design, which are the skills that I didn’t necessarily have.

HS: What led you to write the book? 

AP:  A few things. Firstly, I wanted to write a popular science book that didn’t cater to the normal popular science audience, by which I mean people who are already relatively interested in science, the types of people who would browse the popular science sections in a bookshop and pick things up about space, or the gut, or whatever. I feel like that audience is already very well catered for.

What I wanted to do was try and write a popular book that would be read by someone who would never normally read a science book – that’s the whole of the rest of the population. So you’ll notice in   the book that there are a lot of scientific analyses and explanations, but they’re all quite short. And my hope was that, if someone’s coming at this with not very much prior knowledge of science, they 
get to a description of the quantum mechanics behind why glass is transparent. But on the next page, we’re back to the story. And it’s really those stories that were the most important thing to me.

anna ploszajski
Like the sound of a materials scientist on a journey into making? Listen to Anna’s excellent Handmade podcast
(Image: Steve Cross)

And so, in each of the ten chapters on different materials, the story isn’t the story of the material – it’s the story of something else. So in Plastics, it’s the story of my Polish grandad and, you know, his life story throughout the 20th century, which intertwines with the story of the rise and fall of plastics. 

I wanted to draw all these other audiences in by storytelling, and then hopefully, sneak the science in when they weren’t looking. 

The story of the book itself is to do with feeling very inadequate, I suppose. I had this realisation, having walked into the Institute of Making for the first time, that I was supposedly this expert in materials, having studied the science of it, having studied all on paper, but actually, there were all of these different people that had so much more in-depth knowledge than me. The craftspeople and the makers and the artists and the historians and the designers and the architects… And so it was them that I really wanted to spend time with and learn from. 

That was four years ago. That was when I started my podcast, which is also called Handmade. And that was where I started interviewing makers and craftspeople. And the book just grew from that. Quite a few of the people that I interviewed on the podcast have ended up being featured in the book as the very, very, very kind craftspeople that took me under their wing and showed me the ropes of what they do.

To take blacksmithing as one example – I thought I was an expert in materials, but I had never felt metal softening under my fingers. Yes, I knew the theory, I could draw you the iron-carbon phase diagram, I could talk about the phases and melting, and all of the ways that carbon and iron interact at the atomic level inside steel. But I’ve never done it. And I didn’t know how hard you had to hit it to make it change shape. Agnes, the blacksmith who taught me, is just so, so brilliant. I’m such a huge fangirl of her. And it was very humbling, actually, to spend time with people like that. 

anna ploszajski mug from ceramic materials
It’s one thing to understand the molecular changes that occur when you fire clay; it’s another thing entirely to be able to make a pot

HS: Getting to touch and feel the materials rather than study them, was there any one in particular that you gained an appreciation of? 

AP:  My favourite chapter in the book is Sugar, because it was the most fun story to write. And it’s the story of my English Channel swim. [Yes, you read that right – Anna has swum the English Channel.] One of the reasons was, I think, it already is one of the strongest chapters for storytelling. Because it is this kind of archetypal physical journey from A to B, but also a journey of discovery about yourself. And intertwined in that story is the story of sugar, and all its different forms, and how it affects the body and the mind. 

In terms of the crafts, it was really wool that caught my imagination, and I’ve stuck with it. The story of wool is the story of my camper-van trip around Scotland and the north of England. I acquired wool from all these different places that I went to on my trip, and then knitted a patchwork blanket with all the wool I got from the different places. And through doing that, I taught myself how to knit and I met all of these kinds of amazing knitters and wool-craft people throughout Scotland and the north of England, and chatted to them and got an insight into this amazing world of women who knit – and they were all women – and what it means to them, and how it connects them. And it’s very meditative, I find, and that’s the craft that I’ve taken through since finishing the book a year ago. That’s the craft that I’ve continued with. 

anna ploszajski made a blanket from wool materials
Knitting contains loads of mathematical patterns, which knitters seem to understand intuitively

I don’t know what it is about it. It just feels so nice to create something, you know, especially in the last year when we were all sitting at home watching Netflix and trawling through the movies and TV shows on there. Although that felt like perhaps a bit of a waste of time, actually, if I was knitting while watching TV, it wasn’t all a waste of time; I had something to show for it at the end. And I think that’s what craft gives us – it’s a sense of purpose almost, and a sense of achievement at the end. 

You know, to have that sense of achievement of ‘I’ve made this’ and now I can wear it, or now I can use it. I haven’t had that in science before. I only got that when I started entering this world 
of craft. 

HS: It sounds like you see a disconnect between science and making. Is that fair to say?

AP:  I’ve thought a lot about this: this kind of compartmentalising of making and science, or art and science as I talk about in the book (and I know that art and making are absolutely not the same thing). And I think there are a lot of reasons why the arts and sciences have been sort of severed from each other. In formal education, we separate them. At school, we have to often choose between those types of subjects. I ended up going down the science route, but I did A-level music. I love writing and music and history, and I was always crap at art, but I enjoy it. I think it’s really unhelpful that   we do that, because it means that we brand people as ‘you’re a scientist’, or ‘you’re more of an artist’. And actually, I think the majority of people are probably somewhere in the middle. Actually, they have interest in both. 

anna ploszajski socks
Wool was hugely important for England’s development into a major mediaeval power. It’s also good for keeping your feet warm

It’s a real shame that we often get siphoned off into these different camps, and often don’t get the chance to rediscover the other one. As someone who was siphoned off into the scientific track, it was really liberating to be able to discover the craft and artistic world. It was, like I say, very humbling. It was also really nice to be a complete beginner again at something, to be able to ask the silly questions from a place of curiosity, with no pressure, no educational pressure. I wasn’t trying to achieve anything apart from trying to make a spoon, or forge a knife, or throw a pot, or whatever it was. 

Materials is a really interesting subject because it can sit at this intersection between the artistic world and the scientific world. Materials, perhaps uniquely in the sciences, is a really lovely way to explore the more artistic side. And what I’ve discovered through the book and through the podcast, is that we all understand these materials, maybe in slightly different ways. But quite often, it’s just that we use different language to talk about them. I remember interviewing a silversmith on my podcast called John Cussell, who described cold-working silver metal to me as making the atoms angry. So, when you cold-work silver, it becomes more and more stiff. I would describe that as putting dislocations into the material and putting internal stresses and strains to make them more brittle. We’re both talking about the same thing in different ways. And I think that, really, the wonderful thing that I love about materials is that it can be this  common substance, literally, through which all sorts of different people can talk to each other. 

anna ploszajski smiling in a blue top
We’re fascinated by the idea of 4D printing – printing an object that’s designed to move
(Image: Steve Cross)

HS: Citizen science has taken huge steps forward recently in broadening access to scientific research, but very often it’s locked away inside university buildings and it’s a real shame. What do you think can be done about that?

AP:  That’s my life’s mission, to try and break science out of universities through doing things like writing the book and the podcast, and the talks that I give. I really want to invite people in and show them that science – it’s a huge cliché but science really is everywhere. It’s never been more important than in the last 18 months to understand science, virology, how contagions spread – that’s all science. And the science communication that’s going on around that has been mixed. Some of it’s been really good, but some of it’s been really damaging. That’s what’s important to me is to break science out of these institutions, because a lot of people are turned off science at a very early age. And unlike a lot of other areas, it’s impossible to turn back. If you go down a non-scientific route, through school, and then maybe through university or through a job, it’s impossible to go back on that and pick it up again later. I feel like subjects like history and literature are much more accessible to everybody. Whereas science is considered to be more for a select few, you know, a chosen few who are allowed to do it. And that’s really not fair. 

HS: Are craftspeople scientists? There must be a lot of crossover in terms of learning, experimentation, and so on. 

AP:  I think you’d have to ask them, but whatever it is they do is experimentation, right? And they do experiments all the time – what temperature do I need to make my steel to make it do X? Or, what composition do I need my clay to be to make it do Y? How do I do the settings on my furnace to make sure that my pots don’t explode? And that is exactly the sort of stuff that we would do in the lab, you know: methodical experimentation. So in that way, definitely. I can’t see that there’s any difference at all between that. And in terms of the way that craftspeople and scientists think, that’s much more difficult to answer. 

Most science has arisen from craftspeople and early experimenters. The subject of material science arose out of the subject of metallurgy, which arose out of blacksmiths like Agnes. If you go back far enough, it’s all the same thing.

HackSpace magazine issue 46 out NOW!

Each month, HackSpace magazine brings you the best projects, tips, tricks and tutorials from the makersphere. You can get it from the Raspberry Pi Press online store or your local newsagents.

hackspace front cover red and yellow graphics featuring a spanner and test tube

As always, every issue is free to download from the HackSpace magazine website.

The post Meet Anna Ploszajski: Where making and materials meet appeared first on Raspberry Pi.

Add 57,600 pixels to your Raspberry Pi Pico

via Raspberry Pi

In the latest issue of HackSpace magazine, Ben Everard tests whether a bit of kit from Spotpear can turn Raspberry Pi Pico into a games machine.

The snappily named Raspberry Pi Pico display 1.54-inch LCD by Spotpear ($11.89) brings in a 240×240 pixel IPS screen and ten buttons in a joypad-like arrangement. There’s four for direction, four for action, a select, and a start. At least, they’re labelled like this. You can use them for anything you like.

Spot pear Pico screen front
The buttons are just a bit too small and fiddly for us

To help you get started, there’s a short manual, which includes example code for MicroPython and C.

This example code is easy enough to use, but it is a little messy. The mechanism for controlling the hardware isn’t separated into its own module, so you’re left with either the task of building the library yourself or having slightly untidy code. Not the biggest inconvenience, but compared to how neatly some maker hardware companies manage their code, we found ourselves off to a disappointing start.

There are also some sample UF2 files included along with the C example code, but these appear to have been built for different hardware and work either partially or not at all. The actual example code did compile and work properly.

Impressive quality

When we ran the example code, we were impressed with the quality of the screen. With 240×240 pixels in just 1.54 inches, there’s a high pixel density that can give crisp graphics. Obviously, high pixel densities are a double-edged sword. While they can look great, it does mean higher RAM use, more time transferring data, and more data to process.

Fortunately, Pico is well-suited to the task of driving screens. Each pixel can take 16 bits of colour data, so a full-frame buffer is just 115,200 bytes. The display data is transferred by SPI, and Pico has a maximum SPI frequency of half the clock speed. For MicroPython, that means 62.5MHz. The actual data transfer rate is a little less than this because of overhead of the protocol, but we were able to drive full-frame refreshes at over 40 fps, which is plenty for smooth animations.

Spot pear Pico screen back
Pico slots in the back, which is perfect for space-constrained builds

Obviously, if you’re looking to do animations, sending the data is only half the story. You also need to calculate the frame before it’s displayed. If you’re using MicroPython, you are quite limited by the amount of processing you can do and still keep a high frame rate (though you could use the second core to offload some of the processing). With C, you’ve got much more scope, especially as you could potentially offload the data transfer using direct memory access (DMA).

Battery-sucking light

The one disappointing thing about the screen is that there’s no control over the backlight. According to the documentation, it should be attached to pin 13, but it isn’t. You can’t turn it on or off – it’s just permanently on, and quite bright. That’s a deal-breaker for anything running off battery power, as it will suck up a lot of power. However, if you want a display permanently on, this might be perfectly acceptable.

While we were quite impressed by the screen, we can’t say the same for the other part of the hardware – the buttons. They’re small, stiff, and have very little movement. The end result is a button that is hard to press, and hard to know if you’ve pressed it. They’re the sort of buttons that are commonly used as reset buttons as they’re hard to accidentally press.

We had hoped that this screen would make a good base for a games console, but unfortunately these buttons would just make for a frustrating experience. They might be OK for a menu-driven user interface, but that’s about it.

Another minor annoyance in this is the lack of any mounting holes. This makes it hard to embed into a project as the user interface.

We wanted to like this project. It’s got a good, high-res screen and a nice layout of buttons. However, the choice of components makes it hard to see how we’ll use this in our projects. We’re considering removing the surface-mount buttons and soldering wires onto them to make a more useful device, but if you’re going to go to that level of surgery, it’s probably better to start with a plain screen and work your way up from there.

Verdict

5/10

Good screen, but awful buttons

Price: $11.89

HackSpace magazine issue 46 out NOW!

Each month, HackSpace magazine brings you the best projects, tips, tricks and tutorials from the makersphere. You can get it from the Raspberry Pi Press online store or your local newsagents.

hackspace front cover red and yellow graphics featuring a spanner and test tube

As always, every issue is free to download from the HackSpace magazine website.

The post Add 57,600 pixels to your Raspberry Pi Pico appeared first on Raspberry Pi.

Archimedes the AI robot | HackSpace #45

via Raspberry Pi

When we saw Alex Glow’s name in the latest issue of HackSpace magazine, we just had to share their project. HackSpace #45 celebrates the best Raspberry Pi builds of all time, and we remembered spotting Alex’s wearable robotic owl familiar back in the day. For those of you yet to have had the pleasure, meet Archimedes…

archimedes owl on maker's shoulder
Archimedes taking a perch on his maker’s shoulder

Back in 2018, Hackster’s Alex Glow built Archimedes, an incredible robot companion using a combination of Raspberry Pi Zero W and Arduino with the Google AIY Vision Kit for its ‘brain’.

An updated model, Archie 2, using Raspberry Pi 3B, ESP32-powered Matrix Voice, and an SG90 micro-servo motor saw the personable owl familiar toughen up – Alex says the 3D-printed case is far more durable – as well as having better voice interaction options using Matrix HAL (for which installer packages are provided for Raspberry Pi and Python), plus Mycroft and Snips.ai voice assistant software.

archimedes owl insides laid out on table
Owl innards

Other refinements included incorporating compact discs into the owl’s wings to provide an iridescent sheen. Slots in the case allowed Alex to feed through cable ties to attach Archie’s wings, which she says now “provide a lively bounce to the wings, in tune with his active movements (as well as my own).”

archimedes owl wing detail
Raspberry Pi getting stuffed into Archimedes’ head

HackSpace magazine issue 45 out NOW!

Each month, HackSpace magazine brings you the best projects, tips, tricks and tutorials from the makersphere. You can get it from the Raspberry Pi Press online store or your local newsagents.

Hack space magazine issue 45 front cover

As always, every issue is free to download from the HackSpace magazine website.

The post Archimedes the AI robot | HackSpace #45 appeared first on Raspberry Pi.

Pico Pico Synth | HackSpace #44

via Raspberry Pi

In the latest issue of HackSpace magazine, Ben Everard shows us how to create a framework for building audio devices using Raspberry Pi Pico, called PicoPicoSynth.

Raspberry Pi Pico combines processing power with the ability to shuffle data in and out quickly. This makes it a good fit for a lot of different things, but the one we’ll be looking at today is sound synthesis.

There are a huge number of ways you can make sound on a programmable electronic device, but there’s always space for one more way, isn’t there? We set about trying to create a framework for building audio devices using Raspberry Pi Pico that we’ve called PicoPicoSynth, because it’s a small synth for Pico.

Pico audio hero image from HackSpace
We’re working on a DIY audio board to accompany this software. Hopefully, we’ll be able to show it off in a future issue

Sequencer magic

The program is powered by a sequencer. This is a structure that contains (among other things) a sequence of notes that it plays on a loop. Actually, it contains several sequences of notes – one for each type of noise you want it to play. Each sequence is a series of numbers. A -1 tells the sequencer not to play that note; a 0 or higher means play the note. For every point in time (by default, 24,000 times a second), the sequencer calls a function for each type of noise with the note to play and the time since the note first sounded. From these inputs, the callback function can create the position of the sound wave at this point, and pass this back to the sequencer. All the sounds are then mixed and passed on to the Pico audio system, which plays them.

Manipulating waveforms

This setup lets us focus on the interesting bit (OK, the bit this author happens to find interesting – other people may disagree) of making music. That is playing with how manipulating waveforms affects the sound.

You can find the whole PicoPicoSynth project at hsmag.cc/GitHubPPSynth. While this project is
ongoing, we’ve frozen the version used in this article in release 0.1, which you can download from hsmag.cc/PPSythV1. Let’s take a look at the example_synth file, which shows off some of the features.

github for the pico audio project
You can grab the latest version of this code from GitHub

You can create the sound values for PicoPicoSynth however you like, but we set it up with wavetables in mind. This means that you pre-calculate values for the sound waves. Doing this means you can do the computationally heavy work at the start, and not have to do it while running (when you have to keep data flowing fast enough that you can keep generating sound).

The wavetables for our example are loaded with:

low_sine_0 = get_sinewave_table(50,
24000);
low_sine_1 = get_sinewave_table(100,

24000);
bongo_table = create_wavetable(9054);
for (int i = 0; i < BONGOSAMPLES; i++) {
bongo_table->samples[i] =

bongoSamples[i] * 256;
}

The first two create sine waves of different frequencies. Since sine waves are useful, we’ve created a helper function to automatically generate the wavetable for a given frequency.

The third wavetable is loaded with some data that’s included in a header file. We created it by loading a bongo WAV file into hsmag.cc/WavetableEd, which converts the WAV file into a C header file. We just have to scale it up from 8 bits to 16 by multiplying it by 256. There’s no helper function to do the job here, so we have to load in the samples ourselves.

Callback functions

That’s the data – the other thing we need are the callback functions that return the values we want to play. These take two parameters: the first is the number of samples since the note was started, and the second is the note that’s played.

int16_t bongos(int posn, int note) {

if (note == 0 ) {
return no_envelope(bongo_table,

1, posn);
}
if (note == 1 ) {
return no_envelope(bongo_table,

0.5, posn);
}
else {
return 0;
}
}

int16_t low_sine(int posn, int note) {
if (note == 0 ) {
return bitcrush(envelope(low_

sine_0, 1, posn, posn, 5000, 10000, 15000,
40000),32768,8);
}
if (note == 1 ) {
return bitcrush(envelope(low_

sine_1, 1, posn, posn, 5000, 10000, 15000,
40000),32768,8);
}
else {
return 0;
}
}

The note is 0 or higher – it corresponds to the number in the sequence, and you can use this however you like in your program. As you can see, both of our functions play sounds on notes 0 and 1.

The library includes a few functions to help you work with wavetables, the main two being
no_envelope and envelope. The no_envelope function also takes a multiplier – it’s 1 in the first instance and 0.5 in the second. This lets us speed up or slow down a sample, depending on what we want to play.

pico audio HAT
We used Pimoroni’s Pico Audio Pack, but other forms of audio output should be possible

Attack, decay, sustain, and release

An envelope may be familiar to you if you’ve worked with synths before, and it’s used to convert a constant tone into something that sounds a bit like an instrument being played. You supply four values – the attack, decay, sustain, and release times. During the attack phase, the volume ramps up. During the decay phase, it partially drops to a level that it holds during the sustain phase, and finally it drops to 0 during the release phase. This gives a much more natural sound than simply starting or stopping the sample.

The envelope function also has a multiplier, so we could use the same wavetable for both, but it’s more accurate to generate a specific wavetable for each note if you’ve got the space to store it.

There are also a few sound effects in the synth library that you can apply – BitCrunch, for example. This compresses the sample bit depth down to give the sine wave a distorted sound.

These callbacks don’t have to be sound. You could equally use them to co-ordinate a lighting effect, control physical hardware, or do almost anything else.

Last coding stretch

Now we’ve got the sounds set up, it’s time to link them all together. This is done with the code below.

int bongo_sequence[] = {1, 1, -1, -1, -1,
0, -1, -1};
int low_sine_sequence[] = {-1, -1, 1, -1,

-1, -1, 0, -1};

struct sequencer main_sequencer;
init_sequencer(&main_sequencer, BEATNUM,

BEATFREQ);

//add up to 32 different sequences here
add_sequence(&main_sequencer, 0, bongo_

sequence, bongos, 0.5);
add_sequence(&main_sequencer, 1, low_

sine_sequence, low_sine, 0.5);

Sequences are stored as int arrays that have to be the same length as the sequencer (stored in the BEATNUM macro). This can be any integer up to 32. The numbers in here can be anything you like, as they’re just passed back to the callback functions defined above. The sole limitation being that only numbers 0 or greater are played. We also pass the BEATFREQ value which contains the number of samples per beat.

The final step in setting up the sound is to add up to 32 different sequences to your sequencer.

With everything set up, you can set the music playing with:

    while (true) {

     //do any processing you want here
     give_audio_buffer(ap, fill_next_

buffer(&main_sequencer, ap, SAMPLES_PER_BUFFER));
    }

Each time this loops, it calculates the next 256 (as stored in the SAMPLES_PER_BUFFER macro) and passes them to the audio system. You can do any other processing you like in the loop, provided it can run fast enough to not interrupt the sound playing.

code block for pico audio project
The envelope function creates a donk, bong, bing, or other sound from a note with a constant volume

That’s all there is to it. Set this code running on a Pico that’s plugged into a Pimoroni Audio Pack (you should be able to make it work with other audio systems – see the ‘Audio output’ box, overleaf) and you’ll hear some strange bumps and wobbles.

Of course, it’s unlikely that you’ll want to listen to exactly this strange combination of distorted sine waves and low bitrate bongos. You can take this base and build your own code on top of it. The callback functions can do anything you like, provided they run quickly enough and return a 16-bit integer. How you use this is up to you.

Issue 44 of HackSpace magazine is on sale NOW!

Each month, HackSpace magazine brings you the best projects, tips, tricks and tutorials from the makersphere. You can get it from the Raspberry Pi Press online store or your local newsagents.

HackSpace 44 cover

As always, every issue is free to download from the HackSpace magazine website.

The post Pico Pico Synth | HackSpace #44 appeared first on Raspberry Pi.

Make a Raspberry Pi Pico-based Midi Fighter | HackSpace 43

via Raspberry Pi

MIDI Fighter-style controllers (MIDI controllers with grids of arcade buttons) have been a staple of the DIY MIDI controller community for years. This project, featured in the latest issue of HackSpace magazine, continues that tradition with the Raspberry Pi Pico. A grid of 16 arcade buttons lets you play MIDI notes faster than you can yell “Hadouken!”, either live with hardware or with your digital audio workstation (DAW) of choice.

Do you think they painted the studio bright pink especially? Perfect match for the purple MIDI
Do you think they painted the studio bright pink especially? Perfect match for the purple MIDI

The Pico is the perfect board for a project like this. With all the GPIO pins, you can directly wire your inputs and outputs without issue. The copious GPIO also allows this MIDI controller to have some special features. There is a screen with a GUI representing the 4×4 button grid, along with the assigned MIDI note numbers. Below the screen is a five-way navigation switch that allows you to select the individual buttons and adjust their MIDI note number on the fly rather than having to adjust the code.

Need more buttons? Add a GPIO expander
Need more buttons? Add a GPIO expander

Finally, there is an AW9523 expander board for control over the arcade buttons’ LEDs. Both the screen and AW9523 are Adafruit STEMMA boards, which means they can be chained together to work over I2C.

Of course, there are some parts of this project that are optional, like the buttons’ LEDs and the screen. Feel free to use this build as a jumping-off point for a simpler MIDI controller or change up some of the features to better suit your needs.

All the grounds get connected together
All the grounds get connected together

Inspiration

Noé Ruiz and I love to collaborate on projects together. We’ve worked on a few MIDI projects in the past, and had discussed wanting to do a MIDI Fighter at some point. The MIDI Fighter-style controller also has a special place in my maker heart, since it was my very first DIY MIDI project that I worked on a few years ago. It had code written with Arduino, and was one of my first big soldering projects as well.

When the Raspberry Pi Pico came out, Noé and I thought it would be perfect for a MIDI Fighter, since it had so many GPIO. Noé also wanted to add another feature: the ability to change MIDI notes on the fly instead of having to edit the code. Noé is an accomplished beat drummer and felt that this feature would streamline his live drumming process when working on a beat with his DAW and software instruments. I was excited for the challenge to implement that feature and code up a user-friendly GUI. I think that it really makes this version of the classic MIDI Fighter-style controller stand out from the crowd.

Usage

The Raspberry Pi Pico MIDI Fighter has features that make it ideal for both playing live and noodling at home working on a track. You can use it with your computer’s DAW over USB and change the assigned MIDI notes on the fly for different settings or to different note input options. The fast and accurate nature of the arcade buttons makes them great candidates for live beat making and performance.

3D printed standoffs make assembly easy
3D printed standoffs make assembly easy

For more on this project’s 3D-printed case, assembly and code, head to page 52 of the latest issue of HackSpace magazine.

And an in-depth, step-by-step tutorial by Liz Clark and Noé Ruiz is available on the Adafruit Learning System.

Issue 43 of HackSpace magazine is on sale NOW!

Each month, HackSpace magazine brings you the best projects, tips, tricks and tutorials from the makersphere. You can get it from the Raspberry Pi Press online store or your local newsagents.

HackSpace issue 43 cover

As always, every issue is free to download from the HackSpace magazine website.

The post Make a Raspberry Pi Pico-based Midi Fighter | HackSpace 43 appeared first on Raspberry Pi.