DFPlayer Based Audio Sampler With Capacitive Sensors
by Oficina de Sonido in Circuits > Audio
2273 Views, 10 Favorites, 0 Comments
DFPlayer Based Audio Sampler With Capacitive Sensors
Introduction
After experimenting with the construction of different synthesizers, I set out to build an audio sampler, which was easily replicable and inexpensive.
To have good audio quality (44.1 kHz) and sufficient storage capacity, the DFPlayer module was used, which uses micro SD memory cards to store up to 32 gigabytes of information. This module is only capable of playing one sound at a time, so we will use two.
Another requirement for the project is that the circuit can be adaptable to different interfaces, which is why we chose capacitive sensors instead of buttons.
Capacitive sensors can be activated with just the hand contact with any metal surface connected to the sensor.
For the reading of the sensors we will use an Arduino nano, due to its capabilities and small size.
characteristics
6 different sounds
Activated by capacitive sensors.
Polyphony of 2 sounds at once.
Materials and Tools
Materials
Arduino Nano https://www.taydaelectronics.com/nano-3-0-control...
2x DFPlayer https://www.ebay.com/itm/DFPlayer-Mini-TF-Card-U-...
2x micro SD https://www.ebay.com/itm/New-8GB-Micro-SD-High-Sp...
3.5 Audio Jack https://www.taydaelectronics.com/3-5mm-stereo-enc...
2.1 DC Jack https://www.taydaelectronics.com/dc-power-jack-2-1mm-barrel-type-pcb-mount.html
10x10 copper board https://www.taydaelectronics.com/copper-clad-boar...
Ferric Chloride https://www.ebay.com/itm/Ferric-Chloride-Etching-...
Solder wire https://www.ebay.com/itm/Fine-Solder-Wire-0-6mm-6...
PCB transfer papper https://www.ebay.com/itm/10PCS-White-A4-Heat-Tone...
Tools
Solder Iron
Component lead cutter
Computer
Iron
Software
Arduino Ide https://www.arduino.cc/en/Main/Software
Kicad https://kicad-pcb.org/download/
ADTouch Librarie https://playground.arduino.cc/Code/ADCTouch/
Fast DFPlayer Librarie https://github.com/PowerBroker2/DFPlayerMini_Fast
How Does It Work
The sampler works as follows, using the ADTouch library we convert 6 of the analog ports of the Arduino Nano into capacitive sensors.
As a sensor we can use any piece of metal connected to one of these pins by means of a cable.
You can read more about the library and capacitive sensors at the following link https://playground.arduino.cc/Code/ADCTouch/
When one of these sensors is touched, the arduino detects a capacitance change and thereafter sends the order to execute the sound corresponding to that sensor to the DFPlayer modules.
Each DFPlayer module can only play one sound at a time, so to have the possibility of executing 2 sounds at a time the instrument uses 2 modules.
Schematic
In the diagram we can see how the arduino and the two DFPlayer modules are connected
R1 and R2 (1 k) are to connect the modules to the DFPlayers.
R 3 4 5 and 6 (10k) are for mixing the outputs of channels l and r of the modules.
R 7 (330) is the protection resistance of a LED that will be used as an indicator that the arduino is being energized.
Build the PCB
Next we will manufacture the plate using the heat transfer method, which is explained in this instructable: https://www.instructables.com/id/Cheap-and-Easy-Toner-Transfer-for-PCB-Making/
6 pads have been placed on the board that allow the sampler to be used without the need for external sensors.
Downloads
Soldering the Components
Next we will solder the components.
First the resistors.
It is recommended to use headers to mount the Arduino and the modules without soldering them directly.
To solder the headers start with a pin, then check that it is well located, and then solder the rest of the pins.
Finally we will solder the connectors
Install the Libraries
In this project we will use three libraries that we need to install:
SoftwareSerial.h
DFPlayerMini_Fast.h
ADCTouch.h
In the following link you can see in detail how to install libraries in Arduino
https://www.arduino.cc/en/guide/libraries
Code
Now we can upload the code to the Arduino board.
For this we must select the Arduino Nano board.
#include
#include #include
int ref0, ref1, ref2, ref3, ref4, ref5; int th ;
SoftwareSerial mySerial(8, 9); // RX, TX DFPlayerMini_Fast myMP3;
SoftwareSerial mySerial2(10, 11); // RX, TX DFPlayerMini_Fast myMP32;
void setup() { int th = 550; // Serial.begin(9600); mySerial.begin(9600); mySerial2.begin(9600); myMP3.begin(mySerial); myMP32.begin(mySerial2); myMP3.volume(18); ref0 = ADCTouch.read(A0, 500); ref1 = ADCTouch.read(A1, 500); ref2 = ADCTouch.read(A2, 500); ref3 = ADCTouch.read(A3, 500); ref4 = ADCTouch.read(A4, 500); ref5 = ADCTouch.read(A5, 500);
}
void loop() {
int total1 = ADCTouch.read(A0,20); int total2 = ADCTouch.read(A1,20); int total3 = ADCTouch.read(A2,20); int total4 = ADCTouch.read(A3,20); int total5 = ADCTouch.read(A4,20); int total6 = ADCTouch.read(A5,20);
total1 -= ref0; total2 -= ref1; total3 -= ref2; total4 -= ref3; total5 -= ref4; total6 -= ref5; // // Serial.print(total1 > th); // Serial.print(total2 > th); // Serial.print(total3 > th); // Serial.print(total4 > th); // Serial.print(total5 > th); // Serial.println(total6 > th);
// Serial.print(total1); // Serial.print("\t"); // Serial.print(total2); // Serial.print("\t"); // Serial.print(total3); // Serial.print("\t"); // Serial.print(total4); // Serial.print("\t"); // Serial.print(total5); // Serial.print("\t"); // Serial.println(total6); if (total1 > 100 && total1 > th ) { myMP32.play(1); // Serial.println("o1"); }
if (total2 > 100 && total2 > th ) { myMP32.play(2); //Serial.println("o2"); }
if (total3 > 100 && total3 > th ) {
myMP32.play(3); //Serial.println("o3");
}
if (total4 > 100 && total4 > th ) {
myMP3.play(1); //Serial.println("o4");
}
if (total5 > 100 && total5 > th ) {
myMP3.play(2); //Serial.println("o5");
}
if (total6 > 100 && total6 > th ) {
myMP3.play(3); //Serial.println("o6");
} // do nothing delay(1); }
Downloads
Load the Sounds Into Memory Cards.
Now you can load your sounds in the micro SD cards
The format must be 44.1 kHz and 16 bit wav
You must upload 3 sounds on each SD card.
The Interface
At this time you can already run your sampler with pads in the PCB, but you still have the possibility to customize it, choosing a case and different objects or metal surfaces to use as sensors.
In this case I used 3 wrist heads to which I put metal screws as a metal contact sound.
For this, connect the screws to the pins of the board by means of cables.
You can use any metallic object, conductive tape or experiment with conductive ink.