Docsity

Hellodrum cod Example, Exercises of Computer science

Toggle sidebar
bg1
/*
EXAMPLE - 2 Zone Cymbal Sensing
This sample code is tesed with YAMAHA PCY135/PCY155.
https://github.com/RyoKosaka/HelloDrum-arduino-Library
*/
////////////////////////////////////////// SETTING VALUE
////////////////////////////////////////////
//Determine the setting value.
//By changing the number in this array you can set sensitivity, threshold and so on.
byte CRASH[8] = {
100, //sensitivity
10, //threshold
10, //scan time
30, //mask time
5, //edge Threshold
1, // curve type(0-4)
49, //note of bow
55 //note of edge
};
////////////////////////////////////////////////////////////////////////////////////////////////////
/////
#include <hellodrum.h>
//Using MIDI Library. If you want to use USB-MIDI, comment out the next two lines.
#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();
pf3

Partial preview of the text

Download Hellodrum cod Example and more Exercises Computer science in PDF only on Docsity!

EXAMPLE - 2 Zone Cymbal Sensing This sample code is tesed with YAMAHA PCY135/PCY155. https://github.com/RyoKosaka/HelloDrum-arduino-Library */ ////////////////////////////////////////// SETTING VALUE //////////////////////////////////////////// //Determine the setting value. //By changing the number in this array you can set sensitivity, threshold and so on. byte CRASH[8] = { 100, //sensitivity 10, //threshold 10, //scan time 30, //mask time 5, //edge Threshold 1, // curve type(0-4) 49, //note of bow 55 //note of edge }; //////////////////////////////////////////////////////////////////////////////////////////////////// ///// #include <hellodrum.h> //Using MIDI Library. If you want to use USB-MIDI, comment out the next two lines. #include <MIDI.h> MIDI_CREATE_DEFAULT_INSTANCE();

//Uncomment the next two lines for using USB-MIDI with atmega32u4 or Teensy //#include <USB-MIDI.h> //USBMIDI_CREATE_DEFAULT_INSTANCE(); //Please name your cymbal. //The cymbal named "crash" is connected to the A0 pin (piezo) and A1 pin (edge sensor). HelloDrum crash(0, 1); void setup() { //If you use Hairless MIDI, you have to comment out the next line. //MIDI.begin(10); //And uncomment the next two lines. MIDI.begin(); Serial.begin(38400); //Set Curve Type crash.setCurve(CRASH[5]); } void loop() { //Piezo sensing is done in this line. And it is returned as a velocity of 127 stages. //For each pad, one line is required. //So, you need the same number of lines as the number of pads or controller. crash.cymbal2zone(CRASH[0], CRASH[1], CRASH[2], CRASH[3], CRASH[4]); //cymbal2zone(byte sens, byte thre, byte scan, byte mask, byte edgeThre); //MIDI signals are transmitted with this IF statement.