Select Git revision
Rp2040.ino 26.75 KiB
#include <hardware/pwm.h>
#define MODESWITCH_PIN_A 0
#define MODESWITCH_PIN_B 1
#define PUSHBUTTON_PIN 6
#define VOCT_PIN 26
#define FREQ_POT_PIN 27
#define INVERSION_PIN 28
#define CHORD_POT_PIN 29
// 0-4=chord osc , 5=bass osc , 6=arpeggio osc
float osc_progress[6];
int osc_inverse[4];
float osc_scale_rate[5]; // 0~3=chord osc , 6=arpeggio osc
int slice_num = 0;
float osc_freq = 0;
int wavetable[256]; // 1024 resolution , 256 rate
float calb = 1.11; // calibration for reduce resistance error
int adc, freq_pot;
int waveform_selection = 0;
int f0 = 35; // base osc frequency
int j = 0;
int select_mode = 0; // 0=chord without root , 1=chord with root,2=arpeggio
int inversion = 0; // 0-7
int old_invAD = 0; // countermeasure of input ADC noise
int new_invAD = 0; // countermeasure of input ADC noise
bool push_sw, old_push_sw;//push sw
int qnt[32];
int thr=0; // threshold number
// Quantization values for the Major Scale
const static int majqnt[32]={
0, 34, 68, 85, 119, 153, 205, 239, 273, 290, 324, 358, 409, 443, 477, 494, 529, 563, 614, 648, 682, 699, 733, 767, 818, 853, 887, 904, 938, 972, 1023
};
// Quantizer Threshold values for the Major Scale
const static int majthr[32]={
0, 17, 51, 85, 102, 136, 171, 222, 256, 290, 307, 341, 375, 426, 460, 494, 512, 546, 580, 631, 665, 699, 716, 750, 784, 835, 870, 904, 921, 955, 989,1024
};
// Quantization values for the Minor Scale
const static int minqnt[32]={
0, 34, 51, 85, 119, 136, 205, 239, 256, 290, 324, 341, 409, 443, 460, 494, 529, 546, 614, 648, 665, 699, 733, 750, 818, 853, 870, 904, 938, 955, 1023
};
// Quantizer Threshold values for the Minor Scale
const static int minthr[32]={
17, 43, 68, 102, 128, 171, 222, 248, 273, 307, 333, 375, 426, 452, 477, 512, 538, 580, 631, 657, 682, 716, 742, 784, 836, 862, 887, 921, 947, 989, 1024
};
//------------chord------------
float freq_rate[61]={
1, 1.059, 1.122, 1.189, 1.26, 1.335, 1.414, 1.498, 1.587, 1.682, 1.782, 1.888, 2, 2.059, 2.122, 2.189, 2.26, 2.335, 2.414, 2.498, 2.587, 2.682, 2.782, 2.888, 3, 3.059, 3.122, 3.189, 3.26, 3.335, 3.414, 3.498, 3.587, 3.682, 3.782, 3.888, 4, 4.059, 4.122, 4.189, 4.26, 4.335, 4.414, 4.498, 4.587, 4.682, 4.782, 4.888, 5, 5.059, 5.122, 5.189, 5.26, 5.335, 5.414, 5.498, 5.587, 5.682, 5.782, 5.888, 6
};
int chord_mode = 2;//0=maj 3chord,1=min 3chord,2=tension maj 4chord,3=maj 4chord,4=min 4chord,5=tension min 4chord
int chord_3[3][3]={
{0,4,7},//maj
{0,3,7},//min
{0,3,6}//dim
};
int chord_4[6][4]={
{0,4,7,11},//maj+M7
{0,2,4,7},//maj+add9
{0,4,7,10},//maj+7
{0,3,7,10},//min+7
{0,4,7,9},//maj+6
{0,3,6,10}//dim+7
};