Category Archives: Music

I bought a radio … an old one.

Browsing though secondhand shops, and retro art shops, I came across a cool old piece of history.

I was planning to remove the internals (first checking if its really broken .. it is), and make a radio which plays audio fragments from the 50-60s.
(Music and News)

  • Playing old media using a raspberry
  • Using the original knobs and lights (more on this later)
  • While tuning in on channels, static sound will be heard and country selection will be a used also for music/news selection
  • Maybe I’ll use one of the turning knobs as decade selector (like the old band selector 25m/31m etc)
Back of the radio

Type H265A01.
This one was made in de 50s in Nederlandsche Seintoestellen Fabriek (N.S.F.).
This factory was standing within 100 meters where I currently live

Another interesting thing: It has a Magic Eye (Philips MiniWatt EM4)!
This little thingy works like a mini CRT device.

A magic eye EM4 is a vintage vacuum tube (introduced around 1938–1939) used as a visual tuning indicator in old European radios and test equipment. It glows with a green or yellow-green phosphor pattern that narrows or expands based on signal strength, helping users find the exact radio frequency

Due too the high voltages needed for this device, I’ll be storing this in a safe place, and make a modern alternative using a microcontroller and a round display.

Onkyo old to new

Our Onkyo was giving problems, some channels are breaking up.
To have some channels back, we needed to crank up the volume for a few seconds.

So I thought .. preamps!

So I opened the Onkyo and started investigating.

We used it as a 5.1 surround sound system. So I’ve got PreAmp channels to spare, so lets switch the boards!


Well, that didn’t work.
Reading forums, it COULD be the sound chip, on the main board.
Because of the heat over the years, it could losing contact with the main PCB.

So I put my heatgun to work, but to no avail.
One of the square chips on the right in first photo.

The AMP being 15+ years old, we decided to get a new one.
Researching best amp’s in 2026 … in our price range.

Onkyo TX-RZ50

Amazing …

Using the DIRAC sound setup, perfect again.

Using the same IP, our Home Assistant setup mostly worked without changing much.

PDF generate for CD covers (for my RFID player)

Running this thing for a while now.

New covers to be printed …

I wanted to automatically generate PDFs to print 3×4=12 covers (70mm x 70mm)

So put cover art in a subdir and run below. (See also Cover Art extractor on this site)

CODE

#!/bin/bash
set -e
#set -x
# NOTE .. some vibecoding used

find covers -type f | head -12 > images.txt 

LIST="${1:-images.txt}"

DPI=300
A4_W=2480
A4_H=3508
SIZE=827          # 70 mm @ 300 DPI

COLS=3
ROWS=4

mapfile -t images < "$LIST"

if [ "${#images[@]}" -ne 12 ]; then
    echo "12 images in $LIST please, found ${#images[@]}"
    exit 1
fi

GRID_W=$((COLS * SIZE))
GRID_H=$((ROWS * SIZE))

LEFT=0
TOP=0

cmd=(
    convert
    -size "${A4_W}x${A4_H}"
    xc:white
)

for ((i=0; i<12; i++)); do
    col=$((i % COLS))
    row=$((i / COLS))

    x=$((LEFT + col * SIZE))
    y=$((TOP + row * SIZE))

    cmd+=(
        "(" "${images[$i]}"
        -resize "${SIZE}x${SIZE}!"
        -background white
        -extent "${SIZE}x${SIZE}"
        ")"
        -geometry "+${x}+${y}"
        -composite
    )
done

cmd+=(output.pdf)

"${cmd[@]}"

echo "Created output.pdf"

Listening music genres from all over the place

I listen to all kinds of music, metal till classical.

Mostly Celtic/Irish/Scottish/Bagpipes.
But i’ve listen to below also.

In the summer I often listen to Cuban/Latin music when outside.

Most of what I listen too, has to have some technical or difficult hints to get me interested.

Master of puppets metallica

“La campanella” is a revision of an earlier version from 1838, the Études d’exécution transcendante d’après Paganini, S. 140. Its melody comes from the final movement of Niccolò Paganini‘s Violin Concerto No. 2 in B minor (yeah as mentioned in another post, I am a Paganini fan)

Very nice technique on Guzheng using two slides, key change and vibrato.

Some classic composers ( When I’m in the mood, these will be played )

First time listening to classical music, was in 6 grade (8 nowadays).
The Four Seasons by Vivaldi, another great composer

  • Moonlight sonata – 3rd movement
    The original title is “Quasi Una Fantasia” or “In the Manner of a Fantasy” https://www.youtube.com/watch?v=zucBfXpCA6s
  • Flight of the Bumble bee
  • Fantasy Impromptu by Chopin
  • Alkan Grand Etude “Hands Reunited” Op 76
  • Some parts of Mahler
  • Caprice #24 Paganini
  • Carmina Burana – Carl Orff
  • Toccata and Fugue in D Minor – Bach
    Above music used in an Amiga demo from long time ago.
    https://youtu.be/nGBkAPAyxv0
  • Tartini Violin Sonata in G minor ”Devil’s Trill Sonata”

Something else … Mein herz brennt .. piano version (Rammstein)
Look at the slomo parts filming Lindemann

Another one I often listen to: Lukhash

Cool Pocket Operator PO-28 ‘Robot’ above.
I made a Mothsynth a while ago

Richard Wagner – Götterdämmerung
And
Neodämmerung – Matrix OST …
If you know you know.

And listen to Eddie van Halen, the classical influences are obvious.
(at 5:20 for example)

And … don’t forget these

Software i use(d)

My much used set of tools (old draft I edited)

File managers

  • Midnight Commander
  • Thunar
  • Nautilus
  • nnn
  • Dolphin

Generic tools

  • rsync
  • dcfldd – an enhanced version of dd
  • screen/tmux
  • fdupes
  • ghex / xxd

Connecting/networking tools

  • mosh – roaming, faster, using ssh
  • sshfs – mount remote filesystems over ssh (see ssh tricks)
  • wavemon – wifi info
  • GNS3 – Graphical Network Simulator-3
  • Wireshark
  • PHPIpam
  • Homelable

Encryption

  • Luks
  • ecryptfs

Graphical/Photo

  • Gimp
  • Eog
  • rawtherapee
  • Inkscape
  • Darktable
  • PureRef
  • digiKam
  • Krita
  • Hugin
  • ImageMagick

Documents/Notekeeping

  • Vim
  • Joplin
  • Paperless-ngx
  • DrawIO – For network drawings
  • LibreOffice/OnlyOffice -> EuroOffice
  • Scribus

3D Print/Lasercutting

  • Cura
  • Orcaslicer
  • Bambuddy
  • LightBurn
  • Model editors: Blender and OpenScad, Meshroom, Sketchup

Coding

  • Mostly CLI
  • PlatformIO
  • Arduino IDE
  • VSCodium (stripped Visual Studio)

Electronics

  • Fritzing
  • Kicad
  • Logic

Ebook / Comic readers

  • Calibre
  • FBReader

GFX/Video

  • Blender
  • kdenlive
  • OBS Studio
  • Shotwell
  • Handbrake
  • ffmpeg
  • VLC
  • Kodi/Libreelec

Music

  • CLI abc tools
  • Musescore
  • Bagpipe Music Player
  • Audacity (after removing all bad things be-ing added in 2021)
  • LMMS
  • Ardour

Virtualisation/Emulation

  • proxmox
  • libvirt
  • ovirt
  • guestfish
  • dosbox
  • pcem
  • Martypc

Password management

  • Keepass / KeepassXC

API

  • Postman
  • Flask (Python) see ledserver

Beamer

  • Mapmap
  • LPMT
  • Qprompt

Brewing

  • Brouwhulp
  • Brewfather (web)

Web/App alternatives for bad companies (Mostly own hosted)

  • Gmail – Hosted elsewhere – Thunderbird + web
  • Google Drive – Nextcloud
  • Spotify – Navidrome
  • Google Photos (I never used this, i used Gallery2/3/Wipigo ) – Immich
  • Youtube – Jellyfin for own movies
  • Whatsapp/Google Chat – My own mattermost server, signal and IRC
  • Teams – Ownhosted jitsi
  • Teamviewer – Rustdesk
  • Google Timeline – Dawarich

Server generic

  • Databases : mariadb/mongodb/influxdb/sqlite
  • Grafana
  • NodeRed
  • gitea
  • HomeAssistant
  • Bookstack
  • Librenms
  • Check_mk (i’ve started with Netsaint (1999), Nagios,Icinga,
  • Mosquitto

Unsorted stuff

  • vimperator (old)
  • links/curl/dsniff/urlsnarf
  • Databases (mariadb/mongodb/influxdb/sqlite)
  • Metabase
  • Adminder
  • Scrot (snapshot tool)
  • Luminace-hdr
  • GDlib
  • Dia (old)
  • Blackmagic Fusion
  • gcalcli
  • Gcalcron
  • Domoticz
  • MQTT-Explorer
  • Android studio
  • Nextion IDE
  • Irssi
  • Mutt
  • Mailcow
  • Tinymediamanager
  • Cacti (old)
  • Winbox (Mikrotik)
  • iptraf
  • ntopng
  • Twiki/Foswiki (old)
  • Digikam
  • My own photo manager
  • Cewe Photobooks
  • qdlsrdashboard
  • gphoto2
  • Ktechlab
  • Ardour5
  • Puredata
  • Cadence
  • Natron
  • yt-downloader
  • 4k downloader
  • Taggers
  • Mp3tag
  • Tinymediamanager
  • MusicBrainz Picard
  • Beets
  • Music players
  • MOC
  • SoftSqueeze
  • Clementine
  • My Badly Designed Sound Machine
  • Server stuff
  • Namazu2
  • Netdata
  • Ntopng
  • Snort/Snortsam
  • Virtualisation

Window managers (See other post)

  • Xmonad (current)
  • Gnome (current)
  • Enlightenment (old)
  • Compiz (old)
  • Fluxbox (old)
  • Ratpoison (tried)
  • Twm (tried)
  • Xfce (old)
  • Window Maker(old)
  • Sawfish (old)
  • Kde (old)
  • i3 (old)
  • IceWM (old)
  • Motif (old)
  • Flwm (old)
  • Fvwm (old)
  • Ximian desktop (bought) (old)

  • Home Drawing
    • Sweethome3D
    • Blender
    • Sketchup
    • Drawio
  • Old but cool
    • Mainactor
    • Appleshake
    • Zbruch
    • Povray
    • Lightzone

Other tools:

Git, tig, xdotool, nmon, ntop, iotop, etc etc (lijstje genereren)

New own-hosted spotify alternative

I’ve tested many opensource tools to have a personal own hosted spotify.
Now I have migrated to navidrome.

List of alternatives i’ve used:

  • …. to be filled in

I can access this with a browser or an android app named amcfy music.

Why?

  • I like self hosting stuff
  • I’ve got a lot of obscure music, which can’t be found on main streaming services
  • Our folkband stuff is for personal use only (Tapsalteerie/NaeBother)

I don´t have time posting other stuff, I’m balancing almost 10 projects at the same time ….

Strudel and Hydra

(Live real time using text (code) to make music and visuals)

Last week, I discovered Strudel.
I was playing around with it and thought: “This would be perfect for Tyrone”.
He is/was the main musical artist in our Group.

Strudel REPL is a web-based, live coding environment for creating music, based on the Tidal Cycles pattern language. It allows users to write and edit code in a browser to instantly hear the music it produces, with features like visual feedback and an interactive tutorial to help beginners and experts. The “REPL” stands for Read-Eval-Print Loop, a common term for interactive programming environments where you can type code, and the system immediately evaluates it and prints the result. 

Check it out on : https://strudel.cc/

Below a strudel example

I can make some simple patterns, but I discovered that it can be used multiuser with realtime synthesizer named Hydra.
I’m better doing visuals, than creating realtime digital music.
Check out https://www.henriaanstoot.nl/?s=shaders – for my previous shader programming posts.
(I love playing real instruments, let’s keep it that way.)

Hydra video synth is a free, open-source, live-coding environment for creating real-time visuals that runs in a web browser. It uses JavaScript and WebGL to allow users to “patch” together different visual sources and transformations, similar to an analog modular synthesizer, to generate effects like video feedback, generative patterns, and audio-reactive visuals. 

It is JavaScript being compiled to WebGL

So using https://flok.cc we can start a multiuser session with realtime live coding.

So the first test session, learning to use Hydra and Strudel together over the internet. Plan is to do a live session for others using a screen projector.

Left Tyrone (Strudel) right me with Hydra.

In the last few days, I made some examples using hydra.

These examples use Microphone for sound reactive, and Webcam for embedded effects.
NOTE: These are only in your browser session, nothing is being recorded/stored.

You can check some examples here :

https://media.henriaanstoot.nl/hydra/

UPDATE : Controlling Hydra input using my DIY Midi Controller (see other post) (Music is NOT related, no microphone input)

Strudel midi input with lpf volume and room controls.

let cc = await midin(1)
note("c a f e").lpf(cc(7).range(0, 1000)).room(cc(3).range(0, 10)).sound("sawtooth")

Avond van de Filmmuziek

4th time we’ve been

  • Also sprach Zarathustra, op. 30,(Richard Strauss cover)
  • Back to the Avond van de Filmmuziek,(intro film)
  • Back to the Future,(Alan Silvestri cover)
  • The Strength of the Righteous (main title),(Ennio Morricone cover) (from ‘The Untouchables’)
  • Downton Abbey: The Suite,(John Lunn cover)
  • Succession (Main Title Theme),(Nicholas Britell cover)
  • Renaissance (Main Title Theme),(Cristobal Tapia de Veer cover) (from ‘The White Lotus’)
  • This Is Berk,(John Powell cover) (with Anna Lapwood) (from ‘How to Train Your Dragon’)
  • Hymn to the Fallen,(John Williams cover) (from ‘Saving Private Ryan’)
  • La vita è bella,(Nicola Piovani cover)
  • I Could Use a Boost,(Kris Bowers cover) (from ‘The Wild Robot’)
  • Suite from ‘De Wilde Noordzee’,(Sven Figee cover) (with Sven Figee)
  • Mission: Impossible,(Lalo Schifrin cover)
  • Superdaan,(intro film)
  • Superman March,(John Williams cover)
  • Out of Africa,(John Barry cover)
  • 20th Century Fox Fanfare,(Alfred Newman cover)
  • American Beauty,(Thomas Newman cover) (with Sven Figee)
  • Mad World,(Tears for Fears cover) (with Gary Jules)
  • Of Separation,(Elliot Goldenthal cover) (from ‘Heat’)
  • Solomon,(Hans Zimmer cover) (from ’12 Years a Slave’)
  • Mommy’s Dollhouse,(Cristobal Tapia de Veer cover)
  • Chevaliers de Sangreal,(Hans Zimmer cover) (from ‘The Da Vinci Code’)
  • Suite from Interstellar,(Hans Zimmer cover) (with Anna Lapwood)
  • The Raiders March,(John Williams cover)
  • No One Mourns the Wicked,(Stephen Schwartz cover) (with Vajèn van den Bosch)
  • Defying Gravity,(Stephen Schwartz cover) (with Vajèn van den Bosch)

Other concerts we’ve been to, movie music related.

  • Hans Zimmer in Concert
  • Star Wars Suite
  • War of the worlds (Jeff Wayne)
  • ?? Forgot what it was called.

Mini midi monitor

Two versions of a mini monitor

A version using a Arduino and a Midi shield (Yellow wires are for display)
D0 (RX) is used for the Midi IN signal.

10K pullups SDA/CLK

Above a Teensy 4.0 version. This one uses MIDI over USB.

Next to add: Rotary encoders, to select a CC Channel and display values graphically

CODE for Teensy version

#include <U8g2lib.h>
#include <Wire.h>
#include <MIDIUSB.h>   // Teensy's built-in USB MIDI

// SH1106 128x64 I2C constructor
U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);

void setup() {
  u8g2.begin();
  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_6x12_tf);
  u8g2.drawStr(0,12,"MIDI Monitor Ready");
  u8g2.sendBuffer();
}

void loop() {
  // Check for incoming MIDI

  while (usbMIDI.read()) {
  u8g2.clearBuffer();
  u8g2.setFont(u8g2_font_6x12_tf);
  u8g2.drawStr(0,12,"MIDI Monitor Ready");
  u8g2.sendBuffer();
    byte type = usbMIDI.getType();
    byte channel = usbMIDI.getChannel();
    byte data1 = usbMIDI.getData1();
    byte data2 = usbMIDI.getData2();

    int y = 24;

    if (type == usbMIDI.NoteOn && data2 > 0) {
      u8g2.setCursor(0, y);      u8g2.print("Note ON     "); // pad
      u8g2.setCursor(0, y+12);   u8g2.printf("Ch:%-3d", channel);  // pad width 3
      u8g2.setCursor(0, y+24);   u8g2.printf("Note:%-3d", data1);
      u8g2.setCursor(0, y+36);   u8g2.printf("Vel:%-3d", data2);
    } 
    else if (type == usbMIDI.NoteOff || (type == usbMIDI.NoteOn && data2 == 0)) {
      u8g2.setCursor(0, y);      u8g2.print("Note OFF    "); // pad
      u8g2.setCursor(0, y+12);   u8g2.printf("Ch:%-3d", channel);
      u8g2.setCursor(0, y+24);   u8g2.printf("Note:%-3d", data1);
    } 
    else if (type == usbMIDI.ControlChange) {
      u8g2.setCursor(0, y);      u8g2.print("Control Chg ");
      u8g2.setCursor(0, y+12);   u8g2.printf("Ch:%-3d", channel);
      u8g2.setCursor(0, y+24);   u8g2.printf("CC#:%-3d", data1);
      u8g2.setCursor(0, y+36);   u8g2.printf("Val:%-3d", data2);
    } 
    else {
      u8g2.setCursor(0, y);      u8g2.print("Other MIDI  ");
      u8g2.setCursor(0, y+12);   u8g2.printf("Type:%-3d", type);
    }

    u8g2.sendBuffer();
  }
}

CODE for Arduino plus shield

#include <U8g2lib.h>
#include <Wire.h>
#include <MIDI.h>   // FortySevenEffects MIDI library

// SH1106 128x64 I2C (page buffer, low RAM)
U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);

// MIDI on hardware Serial (RX=D0)
MIDI_CREATE_INSTANCE(HardwareSerial, Serial, MIDI);

char line[12];  // small buffer for formatting

void setup() {
  u8g2.begin();
  u8g2.setFont(u8g2_font_6x12_tf); // proportional font, small size

  // Initial message
  u8g2.firstPage();
  do {
    u8g2.setCursor(0, 12);
    u8g2.print("MIDI Monitor Ready");
  } while (u8g2.nextPage());

  MIDI.begin(MIDI_CHANNEL_OMNI);  // listen to all channels
}

void loop() {
  if (MIDI.read()) {
    byte type    = MIDI.getType();
    byte channel = MIDI.getChannel();
    byte data1   = MIDI.getData1();
    byte data2   = MIDI.getData2();

    // Page buffer redraw
    u8g2.firstPage();
    do {
      // Title
      u8g2.setCursor(0, 12);
      u8g2.print("MIDI Monitor");

      int y = 24; // start lower down

      if (type == midi::NoteOn && data2 > 0) {
        u8g2.setCursor(0, y);      
        u8g2.print("Note ON   ");

        snprintf(line, sizeof(line), "Ch:%-3d", channel);
        u8g2.setCursor(0, y+12);   u8g2.print(line);32

        snprintf(line, sizeof(line), "Note:%-3d", data1);
        u8g2.setCursor(0, y+24);   u8g2.print(line);

        snprintf(line, sizeof(line), "Vel:%-3d", data2);
        u8g2.setCursor(0, y+36);   u8g2.print(line);
      } 
      else if (type == midi::NoteOff || (type == midi::NoteOn && data2 == 0)) {
        u8g2.setCursor(0, y);      
        u8g2.print("Note OFF  ");

        snprintf(line, sizeof(line), "Ch:%-3d", channel);
        u8g2.setCursor(0, y+12);   u8g2.print(line);

        snprintf(line, sizeof(line), "Note:%-3d", data1);
        u8g2.setCursor(0, y+24);   u8g2.print(line);
      } 
      else if (type == midi::ControlChange) {
        u8g2.setCursor(0, y);      
        u8g2.print("Control Chg");

        snprintf(line, sizeof(line), "Ch:%-3d", channel);
        u8g2.setCursor(0, y+12);   u8g2.print(line);

        snprintf(line, sizeof(line), "CC#:%-3d", data1);
        u8g2.setCursor(0, y+24);   u8g2.print(line);

        snprintf(line, sizeof(line), "Val:%-3d", data2);
        u8g2.setCursor(0, y+36);   u8g2.print(line);
      } 
      else {
        u8g2.setCursor(0, y);      
        u8g2.print("Other MIDI");

        snprintf(line, sizeof(line), "Type:%-3d", type);
        u8g2.setCursor(0, y+12);   u8g2.print(line);
      }
    } while (u8g2.nextPage());
  }
}

Cynthcart (c64) midi control

I bought a teensyrom a while ago.

UPDATE 20250712 : Display
UPDATE 20250904 : Added PitchBend and stabilized potmeters.

Tyrone and I wanted to control the settings using potmeters.
So I grabbed a Teensy 4.1 controller and some 10K potmeters, and worte some code

Code for 12 pots, pitch bend and display, don’t forget to set your USB mode to midi!
Schematic soon, also all tweaks and note sending.

Todo: Nice 3D printed Pitch Bend wheel, rest of display code and extra buttons!

Let’s use an old box to hold the pots!

3D printed wooden knobs (Yes wood filament)
Unstable release pot due too bad wires. Cynthcart has no decay and hold (hold is how long you are pressing key)

Knob 1 = volume now, and left of box has centering Pitch Bend.


CODE

#include <MIDIUSB.h>
#include <ResponsiveAnalogRead.h>

const int pitchbend = A14;
const int filterresonance = A0;
const int filtercutoff = A1;
const int voicemode = A2;
const int modulationmode = A3;
const int attack = A4;
const int release = A5;
const int pulsewidth = A6;
const int tremolodepth = A7;
const int tremolospeed = A8;
const int oscwave = A9;
const int oscvoice2 = A10;
const int oscvoice3 = A11;
const int volume = A12;

ResponsiveAnalogRead analogpitchbend(pitchbend, true);

ResponsiveAnalogRead analogfilterresonance(filterresonance, true);
ResponsiveAnalogRead analogfiltercutoff(filtercutoff, true);
ResponsiveAnalogRead analogvoicemode(voicemode, true);
ResponsiveAnalogRead analogmodulationmode(modulationmode, true);
ResponsiveAnalogRead analogattack(attack, true);
ResponsiveAnalogRead analogrelease(release, true);
ResponsiveAnalogRead analogpulsewidth(pulsewidth, true);
ResponsiveAnalogRead analogtremolodepth(tremolodepth, true);
ResponsiveAnalogRead analogtremolospeed(tremolospeed, true);
ResponsiveAnalogRead analogoscwave(oscwave, true);
ResponsiveAnalogRead analogoscvoice2(oscvoice2, true);
ResponsiveAnalogRead analogoscvoice3(oscvoice3, true);
ResponsiveAnalogRead analogvolume(volume, true);


// A0 -> A3, A6 -> A13
const int numPots = 12;


int lastfilterresonance = -1;
int lastfiltercutoff = -1;
int lastvoicemode = -1;
int lastmodulationmode = -1;
int lastattack = -1;
int lastrelease = -1;
int lastpulsewidth = -1;
int lasttremolodepth = -1;
int lasttremolospeed = -1;
int lastoscwave = -1;
int lastoscvoice2 = -1;
int lastoscvoice3 = -1;
int lastvolume = -1;


// CC 7 ff niet

// Custom mappings:
const int potPins[numPots]     = {A0, A1, A2, A3, A6, A7, A8, A9, A10, A11, A12, A13};  // Analog pins
const int ccNumbers[numPots]   = {0,1,2,3,4,5,6,8,9,13,14,15};             // CC numbers
const int midiChannels[numPots]= {1,1,1,1,1,1,1,1,1,1,1,1};                // MIDI channels (1–16)

int lastValues[numPots];  // Store last values to reduce redundant MIDI messages


void setup() {
  Serial.begin(9600);
  for (int i = 0; i < numPots; i++) {
    pinMode(potPins[i], INPUT);
    lastValues[i] = -1;
  }
  pinMode(pitchbend, INPUT);
}

void loop() {
  analogfilterresonance.update();
  if(analogfilterresonance.hasChanged()) {
    int analogValue = analogfilterresonance.getValue();
    int midiValue = analogValue / 8;  // Scale 0–1023 to 0–127
    if (abs(midiValue - lastfilterresonance) > 0){
    usbMIDI.sendControlChange(7, midiValue, 1);
    lastfilterresonance = midiValue;
    }
  }

  analogfiltercutoff.update();
  if(analogfiltercutoff.hasChanged()) {
    int analogValue = analogfiltercutoff.getValue();
    int midiValue = analogValue / 8;  // Scale 0–1023 to 0–127
    if (abs(midiValue - lastvoicemode) > 0){
    usbMIDI.sendControlChange(1, midiValue, 1);
    lastvoicemode = midiValue;
    }  
  }

  analogvoicemode.update();
  if(analogvoicemode.hasChanged()) {
    int analogValue = analogvoicemode.getValue();
    int midiValue = analogValue / 8;  // Scale 0–1023 to 0–127
    if (abs(midiValue - lastvoicemode) > 0){
    usbMIDI.sendControlChange(2, midiValue, 1);
    lastvoicemode = midiValue;
    }
  }

  analogmodulationmode.update();
  if(analogmodulationmode.hasChanged()) {
    int analogValue = analogmodulationmode.getValue();
    int midiValue = analogValue / 8;  // Scale 0–1023 to 0–127
    if (abs(midiValue - lastmodulationmode) > 0){
    usbMIDI.sendControlChange(3, midiValue, 1);
    lastmodulationmode = midiValue;
    }
  }


  analogattack.update();
  if(analogattack.hasChanged()) {
    int analogValue = analogattack.getValue();
    int midiValue = analogValue / 8;  // Scale 0–1023 to 0–127
    if (abs(midiValue - lastattack) > 0){
    usbMIDI.sendControlChange(4, midiValue, 1);
    lastattack = midiValue;
    }
  }


  analogrelease.update();
  if(analogrelease.hasChanged()) {
    int analogValue = analogrelease.getValue();
    int midiValue = analogValue / 8;  // Scale 0–1023 to 0–127
    if (abs(midiValue - lastrelease) > 0){
    usbMIDI.sendControlChange(5, midiValue, 1);
    lastrelease = midiValue;
    }
  }


  analogpulsewidth.update();
  if(analogpulsewidth.hasChanged()) {
    int analogValue = analogpulsewidth.getValue();
    int midiValue = analogValue / 8;  // Scale 0–1023 to 0–127
    if (abs(midiValue - lastpulsewidth) > 0){
    usbMIDI.sendControlChange(6, midiValue, 1);
    lastpulsewidth = midiValue;
    }
  }


  analogtremolodepth.update();
  if(analogtremolodepth.hasChanged()) {
    int analogValue = analogtremolodepth.getValue();
    int midiValue = analogValue / 8;  // Scale 0–1023 to 0–127
    if (abs(midiValue - lasttremolodepth) > 0){
    usbMIDI.sendControlChange(8, midiValue, 1);
    lasttremolodepth = midiValue;
    }
  }


  analogtremolospeed.update();
  if(analogtremolospeed.hasChanged()) {
    int analogValue = analogtremolospeed.getValue();
    int midiValue = analogValue / 8;  // Scale 0–1023 to 0–127
    if (abs(midiValue - lasttremolospeed) > 0){
    usbMIDI.sendControlChange(9, midiValue, 1);
    lasttremolospeed = midiValue;
    }
  }


  analogoscwave.update();
  if(analogoscwave.hasChanged()) {
    int analogValue = analogoscwave.getValue();
    int midiValue = analogValue / 8;  // Scale 0–1023 to 0–127
    if (abs(midiValue - lastoscwave) > 0){
    usbMIDI.sendControlChange(13, midiValue, 1);
    lastoscwave = midiValue;
    }
  }


  analogoscvoice2.update();
  if(analogoscvoice2.hasChanged()) {
    int analogValue = analogoscvoice2.getValue();
    int midiValue = analogValue / 8;  // Scale 0–1023 to 0–127
    if (abs(midiValue - lastoscvoice2) > 0){
    usbMIDI.sendControlChange(14, midiValue, 1);
    lastoscvoice2 = midiValue;
    }
  }


  analogoscvoice3.update();
  if(analogoscvoice3.hasChanged()) {
    int analogValue = analogoscvoice3.getValue();
    int midiValue = analogValue / 8;  // Scale 0–1023 to 0–127
    if (abs(midiValue - lastoscvoice3) > 0){
    usbMIDI.sendControlChange(15, midiValue, 1);
    lastoscvoice3 = midiValue;
    }
  }







// PITCHBEND!
  analogpitchbend.update();
  if(analogpitchbend.hasChanged()) {
    int pitchBend = map(analogpitchbend.getValue(), 0, 1023, 0, 16383); // Map to MIDI Pitch Bend range
    sendPitchBend(pitchBend, 0);
  }
  /*
  int potValue = analogRead(A14);         // Read pot (0–1023)
  int pitchBend = map(potValue, 0, 1023, 0, 16383); // Map to MIDI Pitch Bend range
  //pitchBend = pitchBend + 8192;


  if (abs(pitchBend - lastPitch) > 250) { // Send only on significant change
    sendPitchBend(pitchBend, 0); 
        Serial.println(pitchBend);

    lastPitch = pitchBend;
  }
  */


  delay(5);  // CPU-friendly update rate
}

void sendPitchBend(int value, byte channel) {
  byte lsb = value & 0x7F;
  byte msb = (value >> 7) & 0x7F;

  midiEventPacket_t pitchBendPacket = {0x0E, 0xE0 | (channel & 0x0F), lsb, msb};
  MidiUSB.sendMIDI(pitchBendPacket);
  // Needed? 
  MidiUSB.flush();
}

CODE for display

#include <MIDIUSB.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET 4
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

// A0 -> A3, A6 -> A13
const int numPots = 12;

// A14 - Pitch bend!
int lastPitch = -1;

//A4 A5 I2C display


// Custom mappings:
const int potPins[numPots]     = {A0, A1, A2, A3, A6, A7, A8, A9, A10, A11, A12, A13};  // Analog pins
const int ccNumbers[numPots]   = {0,1,2,3,4,5,19,7,8,9,13,14};             // CC numbers
const int midiChannels[numPots]= {1,1,1,1,1,1,1,1,1,1,1,1};                // MIDI channels (1–16)

int lastValues[numPots];  // Store last values to reduce redundant MIDI messages

void setup() {
  for (int i = 0; i < numPots; i++) {
    pinMode(potPins[i], INPUT);
    lastValues[i] = -1;
  }
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.clearDisplay();
  display.display();
}

void loop() {
  for (int i = 0; i < numPots; i++) {
    int analogValue = analogRead(potPins[i]);
    int midiValue = analogValue / 8;  // Scale 0–1023 to 0–127

    if (abs(midiValue - lastValues[i]) > 1) {
      usbMIDI.sendControlChange(ccNumbers[i], midiValue, midiChannels[i]);
      lastValues[i] = midiValue;
    }
  }
  int potValue = analogRead(A12);         // Read pot (0–1023)
  int pitchBend = map(potValue, 0, 1023, 0, 16383); // Map to MIDI Pitch Bend range

  if (abs(pitchBend - lastPitch) > 5) { // Send only on significant change
    sendPitchBend(pitchBend, 0); // Channel 1
    lastPitch = pitchBend;
  }

  displayInfo();


  delay(5);  // CPU-friendly update rate
}

void sendPitchBend(int value, byte channel) {
  byte lsb = value & 0x7F;
  byte msb = (value >> 7) & 0x7F;

  midiEventPacket_t pitchBendPacket = {0x0E, 0xE0 | (channel & 0x0F), lsb, msb};
  MidiUSB.sendMIDI(pitchBendPacket);
  // Needed? 
  MidiUSB.flush();
}

void displayInfo(){
 byte x0, y0, x1, y1;     // start/end coordinates for drawing lines on OLED
  display.clearDisplay();
  display.setCursor(0, 0);
  display.print("Attack / Release");

  // draw attack line
  x0 = 0;
  y0 = 63;
  x1 = map(attackParam, 0, 127, 0, ((SCREEN_WIDTH / 4) - 1));
  y1 = 20;
  display.drawLine(x0, y0,  x1,  y1, SH110X_WHITE);

   // draw release line
  x0 = x1;  // start line from previous line's final x,y location
  y0 = y1;
  x1 = x0 + map(releaseParam, 0, 127, 0, ((SCREEN_WIDTH / 4) - 1));
  y1 = 63;
  display.drawLine(x0, y0,  x1,  y1, SH110X_WHITE);

  display.display();

}