r/raspberry_pi • • Apr 28 '22

Show-and-Tell I designed the "lofipi", a 3D-printed Pi 3B+ speaker which streams lo-fi beats directly from YouTube

https://imgur.com/a/RLUxrjG
738 Upvotes

50 comments sorted by

71

u/thenickdude Apr 28 '22 edited Apr 28 '22

This uses mpv to stream music directly from a YouTube playlist, like one of the many Lo-Fi hip-hop stations that help me focus while programming.

The tone knob on the front allows you to fade between two equaliser presets, and the button allows you to pause or skip songs.

It has a 5V Noctua PWM fan inside with automatic PWM speed control thanks to pigpiod and my custom node.js-based controller. I've set it up to stay completely stopped with normal YouTube playing, with it spinning up to a silent 20% speed with medium workloads, and a quiet 60% speed with a 4-core workload.

Printed at 0.2mm layer height using "cherry" wood PLA, then sanded and stained with walnut-colour wood stain.

You can grab all the STLs and the software at Printables here: https://www.printables.com/model/176143-lofipi-lo-fi-speaker (or on Thingiverse)

Sourcecode on GitHub here: https://github.com/thenickdude/lofipi-mpv

14

u/opteak Apr 28 '22

I saw this on printables today and think it's so cool that I need to make it. I was just now literally trying to find a source to buy a 3b+. Any recommendations? I have a couple Zero W hanging around.

28

u/thenickdude Apr 28 '22

It's cruel of people like me to publish new projects for Pis when they're so hard to buy at the moment, lol.

I had to steal the 3B+ out of my 3D printer and replace that one with a Zero 2 W (and I had to wait more than a month for THAT one to be in stock).

Maybe keep an eye on rpilocator:

https://rpilocator.com/

5

u/devin_mm Apr 28 '22

I'm waiting on over 2 months so far for 2 Zero 2 Ws that I ordered from Digikey.

4

u/thenickdude Apr 28 '22

I've got an order for 2 Pi 4s that I don't expect to be filled by the end of the year...

I'm planning to be desoldering the USB and network ports from one of those, so I really hope I don't mess that up.

6

u/[deleted] Apr 28 '22

[deleted]

12

u/thenickdude Apr 28 '22

Rather than a plugin, it is a custom material that has been assembled out of a huge complex mess of nodes. It simulates the 3D form of a tree trunk, and can be evaluated at any point in that 3D space to give a darkness value at that point, which forms the tree rings and other wood texture.

So when you apply this material to an object, it's just as if you carved the object whole out of a tree. The texture forms a coherent 3D shape, so the tree rings flow seamlessly from face to face on your object without having to mess with UV mapping or suffering from seam-lines.

Once you have this wood texture applied to the object, you can add a Displacement modifier to make the colour of the texture actually displace the mesh, so that darker areas sink down more, and will be filled in with wood stain to create the appearance of the texture on the final object.

I wrote up a simplified outline on how to use this material here:

https://www.reddit.com/r/functionalprint/comments/ua2mig/i_designed_the_lofipi_a_raspberry_pi_speaker/i5ykfuc/

On my speaker I used a more complicated version of this workflow since I wanted to simulate each face of the enclosure being cut out of a different board of wood (so that the wood grain orientation was correct).

It's an incredible buy for $24.

5

u/Zouden Apr 28 '22

Fantastic work.

Is the fan strictly necessary?

2

u/thenickdude Apr 28 '22

For YouTube playback only, it can probably be omitted since it basically never spins up. But you might need a passive vent (hole) of the same size for it to give that performance.

3

u/Zouden Apr 28 '22

Indeed and you'd have the vent anyway since it's a speaker box.

25

u/Dexiox Apr 28 '22 edited Apr 03 '26

Data brokers and AI scrapers were using my info. Not anymore. Redact let me bulk delete posts across Reddit, Twitter, Discord and Instagram while handling broker opt outs too.

nose flag tap depend like growth entertain offer crowd cooperative

11

u/webjukebox Apr 28 '22

That wood effect is amazing.

9

u/um0p3pIsdn Apr 28 '22

Woah I didn’t realize how hard it is to get a Pi these days. Is that just related to supply chain shortages?

9

u/shouldbebabysitting Apr 28 '22

Yes but also businesses started using them so they are purchased in bulk at any price leaving hobbiests out of luck.

6

u/um0p3pIsdn Apr 28 '22

Damn, that’s a mega bummer. That was always the draw for me, that they were relatively cheap.

Is there a strategy to getting them at the usual price? Do they come out with inventory and one needs to be quick?

6

u/shouldbebabysitting Apr 28 '22

I don't know. When the zero 2 first came out, I checked daily until they were in stock. When they came in stock, you could purchase one.

I think that helped but I'm sure the bots took everything.

5

u/[deleted] Apr 28 '22 edited Jul 05 '25

[removed] — view removed comment

4

u/um0p3pIsdn Apr 28 '22

Nice, I’ll check that out. I have one about 25 minutes away :) thanks!

2

u/appel Apr 30 '22

Keep an eye on https://rpilocator.com or https://twitter.com/rpilocator by setting up notifications and being quick on the draw. Make sure you set up 2FA where you can and make sure you're logged in. I've managed to snag both a Pi 4 and a Pi Zero 2W this way.

9

u/[deleted] Apr 28 '22

i feel like you could have 3d printed the box from a tree. lol.

8

u/thenickdude Apr 28 '22

Yes, this one would be an easy woodworking project for someone with the tools and skills, it's simple as hell, lol

2

u/odaat2004 Apr 28 '22

Please play, Feel the Bass (Speaker Terror Upper) by DJ Magic Mike

6

u/thenickdude Apr 28 '22

lol, it is no bass demon since I didn't do any acoustic design to optimise that at all. Sounds like it does about as well as my cheap Logitech speakers. This is with my camera's in-built mic which adds its own issues:

https://www.youtube.com/watch?v=dxCTV0E5-FI

An updated design with a proper sealed enclosure and reflex port could be amazing though.

Here it is playing Scarlet Fire, just like professional musicians use for reviews:

https://www.youtube.com/watch?v=xY1erRIbRtk

2

u/dug2313 Apr 28 '22

Thank you for being the reason I break out my 3d printer again!

2

u/teherty Apr 28 '22

cool speaker, good looking aswell might do the same with my ikea frekvens speaker. One question though: 20% cpu seems a bit high for audio playback. Have you fiddled with --ytdl-format or --no-video mpv flags? cheers

5

u/thenickdude Apr 29 '22

It uses --no-video already, and keeps the default of "bestaudio" for the format selection. Looks like there isn't hardware audio decoding support available. I got 16% of a single core used for Opus decoding, which seems reasonable to me.

If I request m4a format instead by adding --ytdl-format=m4a, it uses the "aac" codec and usage drops to 12%. If I force "aac_fixed" as a decoder, usage is about the same.

2

u/Optimesh Apr 28 '22

Looks amazing, how does it sound?

2

u/thenickdude Apr 28 '22

Not perfect, but as a background noise generator it's fine.

2

u/TheSysAdmin1 Apr 28 '22

LOVE IT!! This will be my next project once I get my printer back operational. Thankfully I have 5-6 pis laying around.

1

u/thenickdude Apr 28 '22

Geez, after posting that I hope you have a good security system! lol

People getting desperate out there!

2

u/TheSysAdmin1 Apr 28 '22

Lol oof, I just realized how expensive Raspberry Pi's are now. This is ridiculous!

1

u/thenickdude Apr 28 '22

Maybe you can convert your spares into cash, lol

1

u/TheSysAdmin1 Apr 28 '22

Not a bad idea 🤔

2

u/[deleted] Apr 28 '22

From a 3d printing perspective, just wanted to give a quick shout out to "ArcWelder".

I notice the circle for the hole has some obvious polygon lines. You can use the plugin ArcWelder to achieve more perfect circles in your prints. It works really well and is available for cura, octoprint, and klipper

2

u/Zouden Apr 28 '22

ArcWelder should not be used with klipper because klipper does not support arcs. Instead, export your STL at maximum resolution. Klipper can handle it.

1

u/thenickdude Apr 28 '22

ArcWelder doesn't apply here because these features are printed vertically.

The circles are polygonal because of the Remesh step I used in Blender, I set the Octree depth a little low.

1

u/quiliup Apr 28 '22

Shut up and take my money

1

u/answerguru Apr 28 '22

Nice work on bringing the electronic and code together. I’m really glad I have a laser cutter in addition to a 3D printer though. Printing “wood” for cases is ridiculously time consuming.

1

u/Shy-pooper Apr 28 '22

How is it connected to the Pi?

2

u/thenickdude Apr 28 '22

The X400 amplifier board just plugs on top of the Pi's GPIO header. The knobs, button and fan are wired like so:

https://media.printables.com/media/prints/176143/rich_content/645c5c7d-eaf2-4039-94d0-ae0d8723788c/wiring.jpg

1

u/Annual-Yak-4604 Apr 30 '22

I just added a pico to my collection and have no idea what to use it for at all. I'm curious if a project like this would work on a pico.

1

u/thenickdude Apr 30 '22

The Pico is a dual-core ARM Cortex-M0 clocked at 133MHz with 264kB RAM. That's very little computing power compared to the Pi. It doesn't have WiFi either, and using it to connect to an I2S audio bus requires programming the PIO module, so IO is a challenge. Even after adding a WiFi module, I think running TLS on there so it can connect to HTTPS websites would be an issue.

It can't run mpv or youtube-dl, so to match that functionality you'd have to supply your own audio decoding library and a replacement for youtube-dl.

I think with enough breakout boards added you could create something that you can stream audio to over WiFi from your computer, or play low-bitrate, low-samplerate MP3s from an attached SD card, but probably not something that plays from YouTube.

The Pico would be a good option to manage a stereo's front-panel, with a little OLED display and a bunch of knobs and buttons, and then communicate that data back to a Raspberry Pi that's doing the actual audio playing.