DEV Community

Cover image for baby steps...
Michael Tharrington
Michael Tharrington

Posted on • Updated on

baby steps...

I got a Raspberry Pi 2 for Christmas... 2 years ago. And, I've not touched it since. 🙈

collecting dust.

I had aspirations to code then, but lost interest and willpower. Just kept saying, I'll get to that eventually.

Well, guess what? It's 2019 🥳, eventually is here, and I'm going to get somewhat serious! I'm going to learn to code something for my pi in Python. 🐍

But... I could probably use a hand here. I'm new to programming and don't exactly know where to start, just know that I need to start. I chose Python because I have a friend that lives nearby who codes regularly and suggested it. I figured we could do a bit of paired work and perhaps that'd help with learning.

I also stumbled upon this recent helpful discussion here:


... which points to some great resources for beginner-level Python projects.

🐍 🐍 🐍

As well as this post here:


... that seems to scratch my itch for some basic "just getting started" with coding in Python information.

I'm wondering is this the right way to go about it? If I plan on learning to code, do I just pick a lang and go for it? Should I backstep a bit and look at the fundamentals more? I guess I can just start flipping through these resources and Googling things when I get confused, right? Is there any one perfect place to begin?

My ultimate goal is to code a white noise machine for my pi. I've been using this really awesome site for years and would love to recreate something like this.

I also stumbled upon this repo:

GitHub logo scivision / soothing-sounds

Demo several ways of making sound from Numpy arrays in Python, white noise

Soothing Sounds Generator

DOI PyPi Download stats

An acoustically pleasing Python code, targeted initially for Raspberry Pi, but should run almost anywhere. Uses lightweight, pure Python SoundDevice to generate sounds. Optionally, other sound playback Python packages can be used.

I have used the outputs of this program written to SD cards, played on media players in multiple locations for a few years.

pip install -e .
Enter fullscreen mode Exit fullscreen mode

Usage

The noise color option is one of

white pink blue violet brown

the examples will use pink noise.

Play sound from speakers

python soothing.py pink
Enter fullscreen mode Exit fullscreen mode

save sound to disk

  1. generate raw sound file: python soothing.py pink -o pink.raw
  2. convert raw to lossless FLAC (playable in almost all media players, computer, phone etc.)
    ffmpeg -f s16le -ar 16000 -ac 1 -i pink.raw pink.fla
    Enter fullscreen mode Exit fullscreen mode

Notes

The core noise generation code is almost entirely from Python Acoustics

optional high performance Python FFTW install:

apt install libfftw3-dev
Enter fullscreen mode Exit fullscreen mode





... that looked quite promising.

But for now, baby steps. Or slithers. 🐍

One of the reasons I'm writing this post is so that I actually commit to creating something. If I can code my pi into a rain-making noise machine, I'll be pretty dang happy and will definitely take you all along for the ride.

Any words of wisdom, advice, or recommendations—feel free to leave them in the comments.

Now, please don't let me drop the ball on this resolution again! 🤞

Oldest comments (4)

Collapse
 
goyo profile image
Grzegorz Ziemonski

Just noticed this post, I'm gonna (ir)regularly ask you about the progress from now, so better get started!

As for the best place to start, I think it's... whatever you come across first. Getting started in a suboptimal place is far better than not getting started because you're researching which book to pick or which framework to learn first. At least that's the case for me.

Collapse
 
michaeltharrington profile image
Michael Tharrington • Edited

Oh jeez! 😅

But seriously, I need the push, so do check in on me.

And good advice! My starting point is here - learnpythonthehardway.org/python3/... and I'm enjoying it thus far. Bout to install Python and get set up. Wish me luck!

Collapse
 
bigredcode profile image
Jerry Hulscher

I am starting myself in python as well. I am in the same boat as you, I need to hold myself accountable on this to get myself going.

Chin up and just start writing.

Collapse
 
michaeltharrington profile image
Michael Tharrington

Appreciate ya sayin' so! And cool to hear you're at the start of your journey, too.

Every message I get on this post gives me that extra little kick pat on the back to start going, haha! It's awesome how encouraging everybody is here. Right now, I'm just trying to learn some Command Line basics—not even any real programming yet—but hey, it's a start.

Anyway, this weekend I'm headed into deeper waters... python-infested ones! 🐍🐍 If I say it here, I'd better do it, right? Haha!

Best of luck to ya in your own python studies. Let me know how it goes!