Pi-NoiseScope: Exploring the Colors of Sound (and Noise) With a Raspberry Pi

by DaniloR29 in Teachers > University+

63 Views, 0 Favorites, 0 Comments

Pi-NoiseScope: Exploring the Colors of Sound (and Noise) With a Raspberry Pi

Pi-NoiseScopeLogo.jpg
Noise comes in colors,
Pink and brown,
blue, and purple,
velvet, and gray,
and, of course, the white one,
which contains them all.


These picturesque names describe types of sound that differ not in loudness but in their frequency composition. Sounds are produced by mechanical vibrations that propagate through a medium such as air or water. When a vibration is regular, we perceive it as a tone. When it is an irregular mixture of many frequencies, it becomes noise. But even noise is not all the same — it can have its own texture, warmth, or brightness, depending on how the sound energy is distributed across frequencies.

For instance, white noise has a flat spectrum — its power is constant across all frequencies — resulting in equal energy per unit bandwidth. This uniform distribution makes it sound bright and hiss-like. Pink noise follows a 1/f spectral slope, meaning its power decreases by about 3 dB per octave; lower frequencies dominate slightly, producing a warmer and more natural sound, similar to rainfall. Brown (or red) noise falls off even more steeply, approximately as 1/f^2, giving it a deep, rumbling character comparable to distant thunder. In contrast, blue noise and violet (or purple) noise exhibit rising spectra, with power increasing with frequency as f and f^2, respectively. These have a sharp, treble-rich quality due to their emphasis on higher frequencies. Finally, velvet noise is spectrally shaped to match the equal-loudness contours of human hearing (as described by the Fletcher–Munson curves). Its energy distribution is adjusted so that it sounds perceptually uniform across frequencies — what most listeners perceive as acoustically “neutral” noise.

More than 250 years ago, the French mathematician and physicist Joseph Fourier discovered that any complex vibration can be represented as the sum of simple sine waves of different frequencies and amplitudes. This principle, known as the Fourier Transform, allows us to “see” the spectrum of a sound — to understand which frequencies are present and how strong they are.


In this project, we’ll build a Sound Analyzer and Generator using a Raspberry Pi. This small device, the Pi-NoiseScope, can:

  1. Record ambient sounds and show their frequency spectra
  2. Generate artificial noises of different “colors” (white, pink, brown, blue, violet, etc.)
  3. Display real-time information on a small TFT screen

It lets you explore the beautiful world of sound — revealing that even noise, often thought of as random, hides structure and harmony.

Supplies

To build your own Pi-Noise — the little box that explores the colors of sound, you’ll need:

  1. Raspberry Pi Zero W – the heart of the project
  2. External USB Audio Card (with USB adapter for Raspberry Pi Zero) – provides microphone input and speaker output
  3. Microphone with 3.5" jack – plugged into the USB sound card
  4. Headphones or a small amplified speaker with 3.5" jack– for playback, also plugged into the USB sound card.
  5. Rotary Encoder with Push Button – used for navigating the on-screen menu
  6. 1.8” ST7735 TFT Display (128 × 160, SPI interface) – for visual feedback and menus
  7. Jumper wires – for all the necessary connections
  8. Empty square-shaped shampoo bottle (with rounded corners) – becomes the project’s enclosure
  9. Thick cardboard – to make a removable lid or front panel
  10. Scissors and a knife cutter – to cut the cardboard and the plastic bottle.
  11. Paper glue or hot glue – to fix the parts together
  12. Printed “Pi-Noise” splash image – to decorate the front panel
  13. Small power bank.
  14. 1 Push Button.

Connecting the Raspberry Pi

RaspPiConnections1.jpg
RaspPiConnections2.jpg
IMG_1219.JPG

To connect your Raspberry Pi Zero to the TFT display and the rotary encoder module, refer to the two figures below. These diagrams illustrate how the modules are wired to the Raspberry Pi pins.

The Raspberry Pi Zero does not include an integrated audio card. Therefore, in this prototype, we used a USB sound adapter with a 3.5 mm jack connected to the Raspberry Pi’s micro-USB port. In keeping with the spirit of upcycling, a microphone salvaged from an old headset was attached to the adapter, and the audio output was provided through a pair of old earbud headphones.

The last Figure shows the complete setup before boxing.

As I’ll explain later, I’ve also added a push button (not shown in the previous figure) to restart the Raspberry Pi using the RUN pin on the RasPi board.

Boxing the Pi-Noise Device

RaspPiCase.jpg
IMG_1232.JPG

I built the container of the prototype by upcycling a square shampoo bottle with rounded corners and — by lucky coincidence — pink colour, perfectly matching the colour of one common type of noise!

I started by thoroughly cleaning and drying the empty bottle. Then, I carefully cut off one of its sides to create an open compartment. To form the missing panel, I cut a piece of thick cardboard to fit snugly into the opening and serve as a removable lid. On this lid, I glued a printout of the Pi-NoiseScope logo (attached as a PDF file), and then cut openings for the TFT display, the rotary encoder and a restart push button.

Next, I inserted all the electronics into the box:

  1. the Raspberry Pi Zero W,
  2. a small power bank (as a portable power source),
  3. the external USB audio card, and
  4. internal wiring connections.
I arranged the components to make the best use of space.* The microphone cable and headphone output come out through the original shampoo bottle openings, which conveniently act as ports. I also used a cork to make a lid for the bottle, through which the microphone and earphone cables pass, as shown in the photo.



*I won’t show the internal mess (sic!), but this is a prototype, so the internal layout is still a bit improvised. For a cleaner and sturdier version, you could design and 3D-print internal supports or brackets to hold everything more securely. I also used Scotch tape to secure the TFT display and the other elements to the lid as a temporary fix.

How It Works

Pi-NoiseScopeScreens.jpg
Pi-NoiseScopeImage.png

You need to copy on the Raspberry Pi Zero, the attached Python code.

The program performs several tasks:

  1. Recording:

Using the sounddevice library, it records sound through the USB microphone.

  1. Fourier Analysis:

It applies the Welch method from scipy.signal to calculate the Power Spectral Density (PSD) — showing how sound energy is distributed across frequencies.

  1. Noise Classification:

From the PSD shape, it can classify the noise as white, pink, brown, etc.

  1. Spectrogram Display:

The spectrogram visualizes how frequency content changes over time.

  1. Noise Generation:

You can generate synthetic noises (white, pink, brown, blue, violet) and listen to them through the speaker.

  1. Storage:

Recorded data and plots are saved to disk for later analysis.


To run correctly, the program requires the following libraries.

sudo apt update

sudo apt install python3-pip python3-pil python3-numpy python3-scipy python3-sounddevice python3-rpi.gpio

pip3 install st7735

Once you’ve installed all the libraries, you need to modify the variable at the beginning of the script:

BASE_SAVE_DIR = “/home/raspi/NOISE_PROJECT”

Replace “/home/raspi/NOISE_PROJECT” with your correct home folder path.


Copy the splash screen image “Pi-NoiseScopeImage.png” into the same folder as the script. Finally, you can run it from the command line.

python3 PiNoiseScope.py


If all the libraries are correctly installed and the audio card is recognised, you may need to restart the Raspberry Pi to enable it to work. Once it’s working, the model I have used will display an internal red LED that blinks. The splash screen file with the device’s name will then be visualised on the TFT card, and a menu controlled by the rotary encoder will appear.

> Record

Spectrogram

Play

Spectrogram

Generate Noise

Save

Settings

Shutdown

Rotating the encoder highlights menu items, and pressing the selected button activates them. The attached figure shows a snapshot of the TFT for each menu item.

The “save” menu item allows you to save data in the BASE_SAVE_DIR folder:

  1. Recorded sound as .wav
  2. Power Spectral Density as .png
  3. Spectrograms as .png
  4. Summary .txt with detected peaks and noise type

These files can be transferred to a PC for detailed analysis in Audacity, MATLAB, or Python.

The “settings” menu item allows you to change the recording duration and the generation of different noise types.

The final menu item, “Shutdown,” powers down the Raspberry Pi and puts it into standby mode. The push button can be used to restart the microcomputer.

To run the script at the start of the Raspberry Pi, use this setup.

sudo nano /etc/systemd/system/pinoisescope.service

[Unit]
Description=Pi NoiseScope
After=network.target sound.target

[Service]
ExecStart=/usr/bin/python3 /home/raspi/NoiseAnalyzerEncoderVers2.py
WorkingDirectory=/home/raspi
StandardOutput=inherit
StandardError=inherit
Restart=always
User=raspi

[Install]
WantedBy=multi-user.target

sudo systemctl daemon-reload
sudo systemctl enable pinoisescope.service

Conclusions

The Pi-NoiseScope | Exploring the Colours of Sound with a Raspberry Pi

In this Instructable, the Pi-NoiseScope device was presented — a project that transforms the Raspberry Pi into a portable audio laboratory. It allows you to see and hear the hidden patterns in sound, revealing that even noise — often dismissed as random — comes in many beautiful shades.

I hope you enjoy building your own Pi-NoiseScope! If you have any improvements or questions, please feel free to leave a message.