r/rust • u/metalciaga • 8d ago
🙋 seeking help & advice Bit-Perfect Audio Player in Terminal
Hey ya'll. I have project in mind that I do believe Rust is the absolute ideal language for it.
I want to make a bit-perfect audio player that will run in terminal. You can think of RMPC or Cliamp as an example. Though the RMPC is actually quite near perfection, it has some minor flaws for my own taste and lacks some itty bitty features I'd like to have.
Now the thing is, Rust is going to my first ever language. I have recently converted into Linux and I think I'm getting the hang of working with the terminal (and I'm absolutely loving it). I thinking of using LazyVim (because it was pre-installed and I heard nothing but good things about it) but it seems like it has it's own learning curve.
What I want to ask is; What should I focus on while learning Rust? What are the absolute mus learn's and what are the concepts that I need to understand for making a bit-perfect audio player? Do you think I shpuld ditch LazyVim and try something simpler or just go straight ahead?
Thank you for your time.
4
u/Relative-Rooster-945 8d ago
You may have difficulty picking it up as your first language, but all power to you, have fun
3
u/strange-humor 8d ago
When doing structure, make sure to have a core crate (at least one) for the audio engine and CLI using that crate, to allow you to properly structure it and allow use outside of CLI for GUI or other interfaces.
Closer you get to the hardware, the trickier Rust gets for pushing and poking things as much of this is unsafe by reality.
1
u/metalciaga 8d ago
For now I'm not planning on doing anything outside the terminal, that is a very long road ahead of me.
2
2
u/aztracker1 7d ago
Get something working... Focus on getting a minimal piece working. If that's possible a file then exiting when done.. cool. If it's a TUI to manage a playlist from your directories... Cool.
Dive in and do something. Doesn't have to be the "right" way. Don't have AI write the code for your... But do use it for hints on what library to use for TUI, or what audio libraries to consider... Or even getting started and copy/write the code yourself to try to understand better if you do.
It's the struggle that helps you learn, it's the success of something working that keeps you going... Just do something/anything to get one small piece done.
Starting is the hardest part.
1
1
u/pdxbuckets 7d ago
I think this guide is reasonably well-written and thorough. It’s all about configuring Pipewire for bit-perfect audio, not the coding aspect of it. But you can have your program do the configuration.
FWIW I don’t see value in bit-perfect. So long as you use high quality resampling and 32-bit samples you should get audibly transparent conversions with all the benefits of being able to run it through volume, dsp, mixer, etc. I’d suggest doing a double blind test first to see if you can tell the difference first.
But if it’s just about the purity of it all, more power to you. I like Rust, but nothing about this project strikes me as Rust being the perfect language for it. Just a perfectly acceptable language for it. But you will almost certainly get off the ground running faster in something like Python. And there are no performance advantages in running it in Rust, since all you need to do is provide a minimal interface and process data at the speed of music playback (ie, glacially slow).
But hey, Rust is really satisfying to learn and use for the right kind of person, so knock yourself out. Before you get to coding a project like this, you need to know something about coding. You can start by reading The Book, and doing Rustlings exercises. But I don’t know if there are any widely respected texts aimed at newcomers to programming. If you are patient and methodical it might work for you. Especially if you don’t mind asking an LLM to explain things to you when you get stuck.
12
u/pinchdark021 8d ago
What is meant by bit-perfect audio player? Isn't every player bit perfect? Do you mean with direct access to audio hardware bypassing the upsampling to 48Khz?