Skip to content

Commit

Permalink
update for 0.7.7
Browse files Browse the repository at this point in the history
  • Loading branch information
RyoKosaka committed Nov 1, 2020
1 parent f833801 commit bcbc704
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 48 deletions.
73 changes: 66 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# HelloDrum Arduino Library
[![arduino-library-badge](https://www.ardu-badge.com/badge/Hello%20Drum.svg?)](https://www.ardu-badge.com/USB-MIDI)
This is a library for making E-Drum with Arduino.
**Ver.0.7.6(5/1/2020) Work in progress.**
**Ver.0.7.7(11/1/2020) Work in progress.**

## Description

Expand All @@ -19,6 +20,7 @@ Use at your own risk.

- Single piezo pad, Dual piezo pad, 2-Zone cymbal, 3-Zone cymbal
- Compatible with Roland's 2 zone pads (PD Series)
- Compatible with YAMAHA's 3 zone pads (XP Series)
- Compatible with YAMAHA's 3 zone cymbal(PCY135/PCY155) and Roland's 2 zone cymbals(CY12C/CY5/CY8)
- Compatible with SoftPot, FSR and Optical(TCRT5000) type hi-hat controllers and Roland's hihat(VH10/VH11)
- Sensing with MUX(4051 and 4067)
Expand All @@ -27,18 +29,20 @@ Use at your own risk.
- Sensitivity, Threshold, Scan Time, Mask Time, Note Number, Velocity Curve can be set with each pad
- Save setting values with EEPROM
- Works with ESP32 and Teensy and AVR boards such as UNO and MEGA.
- Works with [MIDI Library](https://github.com/FortySevenEffects/arduino_midi_library), [BLE-MIDI Library](https://github.com/lathoub/Arduino-BLE-MIDI), [USB-MIDI library](https://github.com/lathoub/Arduino-USBMIDI).

## How to Use
- **Install**
Use Arduino's Library Manager to install the library. Search for “hellodrum ”.
If you use MIDI, also install the MIDI Library.
If you use MIDI, also install the [MIDI Library](https://github.com/FortySevenEffects/arduino_midi_library). Or [BLE-MIDI Library](https://github.com/lathoub/Arduino-BLE-MIDI) or [USB-MIDI library](https://github.com/lathoub/Arduino-USBMIDI).

<img src="https://open-e-drums.com/images/ide.png" width="800px">

- **Initialize EEPROM**
If you want to use EEPROM to store the settings, you will need to initialize the EEPROM.
Please write the sample code, example > EEPROM > InitializeEEPROM > InitializeEEPROM.ino, to your Arduino. Once it's written, the initialization is complete.

- **Coding**:
- **Coding**
```cpp
#include <hellodrum.h>
#include <MIDI.h>
Expand Down Expand Up @@ -122,11 +126,64 @@ Please write the sample code, example > EEPROM > InitializeEEPROM > InitializeEE
}
```

[Check instruction.md](https://github.com/RyoKosaka/HelloDrum-arduino-Library/blob/master/instruction.md)
[Check instruction.md](https://github.com/RyoKosaka/HelloDrum-arduino-Library/blob/master/instruction.md)

## Using Arduino MIDI Library

[FortySevenEffects Arduino MIDI Library](https://github.com/FortySevenEffects/arduino_midi_library)
There are three ways to communicate with a PC using MIDI with an arduino.

1. Rewrite arduino's USB chip (UNO,MEGA only)
- https://www.arduino.cc/en/Hacking/DFUProgramming8U2
- http://morecatlab.akiba.coocan.jp/lab/index.php/aruino/midi-firmware-for-arduino-uno-moco/?lang=en
2. Using Hairless MIDI (Easiest way)
- https://projectgus.github.io/hairless-midiserial/
- https://open-e-drums.tumblr.com/post/171304647319/using-hairless-midi
3. Using a MIDI terminal and a MIDI-USB cable
- https://www.arduino.cc/en/Tutorial/Midi
- https://open-e-drums.tumblr.com/post/171168448524/using-midi-socket-with-arduino


```cpp
#include <hellodrum.h>
#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();

//...
```

## Using USB-MIDI Library

[lathoub Arduino-USBMIDI](https://github.com/lathoub/Arduino-USBMIDI)
If you are using atmega32u4 (Arduino Leonardo, Arduino Micro, Arduino Pro Micro...), you can use USB-MIDI library. No additional software is needed, the 32u4 is recognized as a MIDI device.

```cpp
#include <hellodrum.h>
#include <USB-MIDI.h>
USBMIDI_CREATE_DEFAULT_INSTANCE();

//...
```

## Using BLE-MIDI Library with ESP32

[lathoub Arduino-BLE-MIDI](https://github.com/lathoub/Arduino-BLE-MIDI)
It is very easy to use BLE-MIDI with ESP32.
You can find a device named "BLE-MIDI".

```cpp
#include <hellodrum.h>
#include <BLEMIDI_Transport.h>
#include <hardware/BLEMIDI_ESP32.h>
BLEMIDI_CREATE_DEFAULT_INSTANCE();

//...
```
Please check the KORG's documentation for instructions on how to connect.
[KORG Bluetooth MIDI Connection Guide](https://cdn.korg.com/us/support/download/files/7c456d3daad3b027197b3fda1f87dce7.pdf?response-content-disposition=inline%3Bfilename%3DBluetooth_MIDI_SettingG_E1.pdf&response-content-type=application%2Fpdf%3B)

## Sensing and Setting Values
- Single Piezo Sensing
<img src="https://open-e-drums.com/images/sensing/single.png" width="800px">
- Single Piezo Sensing <img src="https://open-e-drums.com/images/sensing/single.png" width="800px">
If the value of the piezo exceeds the threshold, the scan will start. The scan will be done for the scantime you set. The highest piezo value during the scan is the peak. The peak value is converted to a velocity of 0-127. The peak is converted to velocity with the sensitivity value as the maximum value and the threshold value as the minimum value. In other words, if you set the threshold value to the same value as the sensitivity, the velocity will be constant.
Depending on the rigidity of the pad, the piezo vibrates for a while. So, you can set a mask time to prevent retriggering. If you are in mask time, the scan will not start even if the piezo value exceeds the threshold.

Expand Down Expand Up @@ -240,7 +297,9 @@ The STL data of pads from 6 inches to 12 inches, hi-hat controllers(<https://www

## Release History


* 0.7.7
- Bug fix for ESP32
- Add and Update sample codes about BLE-MIDI, USB-MIDI
* 0.7.6
- Bug fix for LCD and buttons
- Add and Update sample codes
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Hello Drum
version=0.7.6
version=0.7.7
author=Ryo Kosaka
maintainer=Ryo Kosaka <[email protected]>
sentence=Arduino Library for piezo sensing
Expand Down
70 changes: 47 additions & 23 deletions src/hellodrum.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
"HELLO DRUM LIBRARY" Ver.0.7.6
"HELLO DRUM LIBRARY" Ver.0.7.7
by Ryo Kosaka
Expand All @@ -8,7 +8,7 @@
*/

//#define DEBUG_DRUM //<-- uncomment this line to enable debug mode with Serial.
//#define PULLUP //<-- uncomment this line to enable pullup mode.
//#define PULLUP //<-- uncomment this line to enable pullup mode (UNTESTED).

#include "hellodrum.h"
#include "Arduino.h"
Expand Down Expand Up @@ -142,11 +142,11 @@ HelloDrumKnob::HelloDrumKnob(byte pin1)
void HelloDrum::singlePiezoSensing(byte sens, byte thre, byte scanTime, byte maskTime)
{
#ifdef ESP32
piezoValue = piezoValue / 4;
piezoValue = 1023 - piezoValue / 4;
#endif

#ifdef PULLUP
piezoValue = (1024 - piezoValue);
piezoValue = (1023 - piezoValue);
#endif

int Threshold = thre * 10;
Expand Down Expand Up @@ -175,6 +175,9 @@ void HelloDrum::singlePiezoSensing(byte sens, byte thre, byte scanTime, byte mas
//peak scan start
if (loopTimes > 0)
{
#ifdef DEBUG_DRUM
Serial.println(piezoValue);
#endif
if (piezoValue > velocity)
{
velocity = piezoValue;
Expand Down Expand Up @@ -220,13 +223,13 @@ void HelloDrum::dualPiezoSensing(byte sens, byte thre, byte scanTime, byte maskT
{

#ifdef ESP32
piezoValue = piezoValue / 4;
RimPiezoValue = RimPiezoValue / 4;
piezoValue = 1023 - piezoValue / 4;
RimPiezoValue = 1023 - RimPiezoValue / 4;
#endif

#ifdef PULLUP
piezoValue = (1024 - piezoValue);
RimPiezoValue = (1024 - RimPiezoValue);
piezoValue = (1023 - piezoValue);
RimPiezoValue = (1023 - RimPiezoValue);
#endif

int Threshold = thre * 10;
Expand Down Expand Up @@ -257,6 +260,11 @@ void HelloDrum::dualPiezoSensing(byte sens, byte thre, byte scanTime, byte maskT
//peak scan start
if (loopTimes > 0)
{
#ifdef DEBUG_DRUM
Serial.print(piezoValue);
Serial.print(", ");
Serial.println(RimPiezoValue);
#endif
if (piezoValue > velocity)
{
velocity = piezoValue;
Expand Down Expand Up @@ -344,8 +352,8 @@ void HelloDrum::cymbal2zoneSensing(byte sens, byte thre, byte scanTime, byte mas
{

#ifdef ESP32
piezoValue = piezoValue / 4;
sensorValue = sensorValue / 4;
piezoValue = 1023 - piezoValue / 4;
sensorValue = 1023 - sensorValue / 4;
#endif

#ifdef PULLUP
Expand Down Expand Up @@ -381,6 +389,13 @@ void HelloDrum::cymbal2zoneSensing(byte sens, byte thre, byte scanTime, byte mas
//peak scan start
if (loopTimes > 0)
{
#ifdef DEBUG_DRUM
Serial.print(piezoValue);
Serial.print(", ");
Serial.print(sensorValue);
Serial.print(", ");
Serial.println(abs(piezoValue - sensorValue));
#endif
if (abs(piezoValue - sensorValue) > velocity)
{
velocity = abs(piezoValue - sensorValue);
Expand All @@ -394,6 +409,7 @@ void HelloDrum::cymbal2zoneSensing(byte sens, byte thre, byte scanTime, byte mas
//scan end
if (millis() - time_hit >= scanTime)
{
velocity = velocity - firstSensorValue;

#ifdef DEBUG_DRUM
int prevVel = velocity;
Expand Down Expand Up @@ -456,7 +472,7 @@ void HelloDrum::cymbal2zoneSensing(byte sens, byte thre, byte scanTime, byte mas
}

//choke
else if (lastSensorValue > edgeThreshold && firstSensorValue > edgeThreshold)
else if (lastSensorValue > edgeThreshold && firstSensorValue > edgeThreshold && lastSensorValue >= firstSensorValue)
{

#ifdef DEBUG_DRUM
Expand All @@ -482,8 +498,8 @@ void HelloDrum::cymbal3zoneSensing(byte sens, byte thre, byte scanTime, byte mas
{

#ifdef ESP32
piezoValue = piezoValue / 4;
sensorValue = sensorValue / 4;
piezoValue = 1023 - piezoValue / 4;
sensorValue = 1023 - sensorValue / 4;
#endif

#ifdef PULLUP
Expand Down Expand Up @@ -521,6 +537,13 @@ void HelloDrum::cymbal3zoneSensing(byte sens, byte thre, byte scanTime, byte mas
//peak scan start
if (loopTimes > 0)
{
#ifdef DEBUG_DRUM
Serial.print(piezoValue);
Serial.print(", ");
Serial.print(sensorValue);
Serial.print(", ");
Serial.println(abs(piezoValue - sensorValue));
#endif
if (abs(piezoValue - sensorValue) > velocity)
{
velocity = abs(piezoValue - sensorValue);
Expand All @@ -535,6 +558,7 @@ void HelloDrum::cymbal3zoneSensing(byte sens, byte thre, byte scanTime, byte mas
//scan end
if (millis() - time_hit >= scanTime)
{
velocity = velocity - firstSensorValue;

#ifdef DEBUG_DRUM
int prevVel = velocity;
Expand Down Expand Up @@ -617,7 +641,7 @@ void HelloDrum::cymbal3zoneSensing(byte sens, byte thre, byte scanTime, byte mas
}

//choke
else if (firstSensorValue > edgeThreshold && lastSensorValue > edgeThreshold)
else if (firstSensorValue > edgeThreshold && lastSensorValue > edgeThreshold && lastSensorValue >= firstSensorValue)
{
#ifdef DEBUG_DRUM
Serial.print("[Choke] firstSensorValue : ");
Expand Down Expand Up @@ -749,11 +773,11 @@ void HelloDrum::TCRT5000Sensing(byte sens, byte thre1, byte thre2, byte scanTime
void HelloDrum::FSRSensing(byte sens, byte thre, byte scanStart, byte scanEnd, byte pedalSens)
{
#ifdef ESP32
fsr = fsr / 4;
fsr = 1023 - fsr / 4;
#endif

#ifdef PULLUP
fsr = (1024 - fsr);
fsr = (1023 - fsr);
#endif

int sensRaw = sens * 10;
Expand Down Expand Up @@ -1889,7 +1913,7 @@ void HelloDrum::settingEnable()
}
#endif

void HelloDrum::settingName(char *instrumentName)
void HelloDrum::settingName(const char *instrumentName)
{
//Store the name of the pad in the array.
showInstrument[nameIndex] = instrumentName;
Expand Down Expand Up @@ -2771,11 +2795,11 @@ bool HelloDrumButton::GetPushState()
{
return push;
}
char *HelloDrumButton::GetPadName()
const char *HelloDrumButton::GetPadName()
{
return showInstrument[nameIndex];
}
char *HelloDrumButton::GetSettingItem()
const char *HelloDrumButton::GetSettingItem()
{
if (padType[nameIndex] == Dnum)
{
Expand Down Expand Up @@ -2806,7 +2830,7 @@ char *HelloDrumButton::GetSettingItem()
return item[itemNumberShow];
}
}
char *HelloDrumButton::GetHitPad()
const char *HelloDrumButton::GetHitPad()
{
return showInstrument[padIndex];
}
Expand Down Expand Up @@ -2846,11 +2870,11 @@ bool HelloDrumButtonLcdShield::GetPushState()
{
return push;
}
char *HelloDrumButtonLcdShield::GetPadName()
const char *HelloDrumButtonLcdShield::GetPadName()
{
return showInstrument[nameIndex];
}
char *HelloDrumButtonLcdShield::GetSettingItem()
const char *HelloDrumButtonLcdShield::GetSettingItem()
{
if (padType[nameIndex] == Dnum)
{
Expand Down Expand Up @@ -2881,7 +2905,7 @@ char *HelloDrumButtonLcdShield::GetSettingItem()
return item[itemNumberShow];
}
}
char *HelloDrumButtonLcdShield::GetHitPad()
const char *HelloDrumButtonLcdShield::GetHitPad()
{
return showInstrument[padIndex];
}
Expand Down
Loading

0 comments on commit bcbc704

Please sign in to comment.