A beginner -- I need to make a thing which is a (5x3) grid of buttons (or touch sensors) that play notes.

Thread Starter

Perizan

Joined Dec 29, 2024
1
I need to make a thing which is a (5x3) grid of buttons (or touch sensors) that play notes. You need to be able to play multiple notes at once, and attach headphones so you can play without everyone hearing the notes. Ideally you would also be able to change the “instrument” of the sounds (eg, a piano, a flute etc) but if this complicates it, I can do without.
The problem is, I am very much a beginner with this sort of stuff and have no idea how to actually do this. Does anyone know how I can make this with minimal complications. I know basic python and have a raspberry pi starter kit, but don’t know much about physical coding.
 

KeithWalker

Joined Jul 10, 2017
3,603
I could do this project. I have 70 years of accumulated electronic knowledge and experience, but as it is something I have not made before, I would have to start by learning, searching the internet and experimenting until I got it right. If you really want to do this, you are going to have to go the same rout. I don't think anyone here is going to volunteer to do it for you.
 

BobTPH

Joined Jun 5, 2013
11,463
That is a rather ambitious project for someone who is a beginner.

Like @KeithWalker, I have over 50 years experience, but unlike him, I have studied synthesizer techniques. I would expect to work full time for a year to prototype what you are proposing.
 

Ian0

Joined Aug 7, 2020
13,097
Needing to play multiple notes at once means you need 15 separate oscillators. To some extent it makes the project simpler as you just have to make the same circuit fifteen times and mix the outputs together.
 

MrChips

Joined Oct 2, 2009
34,626
A 5x3 grid of buttons means that the buttons will be accessed using a multiplexing technique. This means that multi-phonic output will be difficult to implement, if not impossible.
 

AnalogKid

Joined Aug 1, 2013
12,042
Agree with Ian on the physical layout vs electrical.

Three CD40106's gets you up to 18 independently adjustable square wave oscillators. Then, 15 switches and resistors sum the signals into an inverting summing opamp. A capacitor at the summing node can take some of the "edge" off of the audio.

If you want more stable note frequencies, such as piano notes, then I would hunt for an old keyboard synthesizer chip

What is the range of frequencies you want the circuit to cover?

ak
 

AnalogKid

Joined Aug 1, 2013
12,042
I was typing that idea while you posted. I used to have two, but I gave them away to someone about 20 years ago for a similar project.

ak
 

sparky 1

Joined Nov 3, 2018
1,218
Most computer keyboards are not easy to modify and difficult because of cost reduction methods of manufacturing.

Mechanical momentary switches could be mounted on plastic sheet in holes 5 x 3 arrangement. The through hole variety normally open momentary switch would make the job go easier, there would be at least 30 wires. A vero strip board could be useful for soldering and help organize the wires.
 

MisterBill2

Joined Jan 23, 2018
27,159
It all depends on additional information, as to how complex it would be. And certainly the concept of 15 different oscillators is the most flexible choice. Except use band pass filter for each tone so that they mix together in a nicer manner.
 

BobTPH

Joined Jun 5, 2013
11,463
15 different oscillators makes it hard to have multiple voices. I was thinking digital synthesis myself, using the Rpi he mentioned.

If done with hardware you would also need 15 envelope generators, VCAs etc if you really wanted it to sound anything like instruments.

Also, the number of unique tones is not the same as the number of simultaneous notes playing. My digital piano has 88 keys and 256 note polyphony. Which could happen when using the sustain pedal.
 
Python is great for this sort of project. You can generate tones in software based on which key combination is currently being pressed.

Here is a basic example that uses a keyboard as input on my windows machine. I'm using the winsound library to generate tones for generic windows soundcards so you'll have to figure out which library works for your hardware and goal. The example is limited to playing one note at a time for a set duration.

Python:
import winsound
import keyboard

# Direct key bindings
keyboard.add_hotkey('a', lambda: winsound.Beep(261, 500))  # C4
keyboard.add_hotkey('s', lambda: winsound.Beep(293, 500))  # D4
keyboard.add_hotkey('d', lambda: winsound.Beep(329, 500))  # E4
keyboard.add_hotkey('f', lambda: winsound.Beep(349, 500))  # F4
keyboard.add_hotkey('g', lambda: winsound.Beep(392, 500))  # G4
keyboard.add_hotkey('h', lambda: winsound.Beep(440, 500))  # A4
keyboard.add_hotkey('j', lambda: winsound.Beep(493, 500))  # B4
keyboard.add_hotkey('k', lambda: winsound.Beep(523, 500))  # C5

print("Press A-S-D-F-G-H-J to play notes. Press 'Esc' to exit.")
keyboard.wait('esc')
It's also worth noting I used AI to generate this code. It doesn't work great but it works and serves as a good example of what you need to do. I recommend using https://perplexity.ai to help you with coding. It's one of the better ones that's available for free. It will give you a lot of bad code but you'll learn a lot.

Frequencies-of-musical-notes.png
 

MisterBill2

Joined Jan 23, 2018
27,159
The scheme of using a hex CMOS inverter IC to generate frequencies seems like the most reasonable for a beginner, and probably by far the least complex. And certainly with a simple RC filter some of the higher order harmonics can be reduced.
Consider also that the TS has admitted to being a beginner. THAT MEANS NOT an expert!! several of the suggestions are complicated and a few are very complex.
consider also that the request was for "minimum complications." The hex inverters option allows for creating the oscillators one at a time, or probably six at a time, with a minimum of components, complexity, and not much soldering. It could even be built up on an experimenter's plug-in board. AND it can be powered by a 9 volt battery or 4 AA cells. And with square waves, a lot of different voicing can be developed..

NO, it would not be "a precision musical instrument"! BUT consider that a 3 by 5 arrangement is not likely to be a standard musical instrument at all.
 
Last edited:

MrChips

Joined Oct 2, 2009
34,626
Why do the buttons have to be laid out in a 5 x 3 grid pattern?
Why not 15 buttons in a row?

Here are 8 touch contacts in a row.
1735517671273.png
 

drjohsmith

Joined Dec 13, 2021
1,548
The scheme of using a hex CMOS inverter IC to generate frequencies seems like the most reasonable for a beginner, and probably by far the least complex. And certainly with a simple RC filter some of the higher order harmonics can be reduced.
Consider also that the TS has admitted to being a beginner. THAT MEANS NOT an expert!! several of the suggestions are complicated and a few are very complex.
consider also that the request was for "minimum complications." The hex inverters option allows for creating the oscillators one at a time, or probably six at a time, with a minimum of components, complexity, and not much soldering. It could even be built up on an experimenter's plug-in board. AND it can be powered by a 9 volt battery or 4 AA cells. And with square waves, a lot of different voicing can be developed..

NO, it would not be "a precision musical instrument"! BUT consider that a 3 by 5 arrangement is not likely to be a standard musical instrument at all.
Could you expand on how to use a CMOS inverter to make audio frequency tones ,
 
Top