baby steps...

Michael Tharrington - Jan 3 '19 - - Dev Community

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! 🤞

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .