The 3HP Paperface Euro Modules

PaperfaceFlyer

If anyone remembers my dsp-Host with a 8-pin DIP socket on the panel the Paperface DSP works in the same way. You make your own modules.

modules

They are built on the ATtiny85 and uses the TinyAudioBootloader.

The name “Paperface” comes from the classic Serge look with white panels.

CamelionPDosc2

The TinyAudioBootloader makes it possible to upload new firmware through the audio out port without a programmer just replaying a wavefile at startup.

PaperfaceSch

The module has 3 Analog CV jacks, 2 with attenuators and an audio out jack.

If you want to build it yourself there is a PCB for it:

Order the Paperface PCB $10

 

PDosc1

The PCB and BOM:

PCB

IC1 ATtiny85
IC2 78L05
R1 1Kohm
R2, R3, R4 22Kohm
R5, R6 10Kohm
C1 100nF
C2, C3 10uF
D1 1N4148
POT1, POT2 10Kohm Alpha 9mm
CN1, CN2, CN3, CN4 3.5mm mono switch Thonkiconn jack

You’ll find all the modules as kits at:

http://www.dspsynth.eu

At powerup the module waits for 5 seconds for an audio signal with firmware on the output jack. If nothing is input it starts normal operation. Otherwise it updates its firmware. No programmer required.

Here is a link for downloading the HEX file for the TinyAudioBootloader:

TinyAudioBoot.hex

This HEX uses PB1, pin6 for the programming audio signal input.
The pin should be lifted to Vcc/2 with a resistor divider.

Set the fuses to 0xE1, 0xDD, 0xFE when programming.

More info on the TinyAudioBootloader can be found here:
https://github.com/ChrisMicro/TinyAudioBoot

If you are unable to program the ATtiny85 yourself you can also have the preprogrammed chip here:

Order the TinyAudioBootloader ATtiny85 chip $10

If nothing is plugged in to the CV1/CV2 jack the knobs works as parameter dials. If they are jacked the knobs work as attenutators for any signal plugged in.

The CV3 jack can be used to input both digital and analog signals and output a digital signal.

All inputs are protected against euro voltages and the power has a reverse protection diode.

The Paperface line is of course open-source so the disclaimer:

My work on these free synthesizers is based on donations from people.
If you find the code useful, please consider a $3 donation to keep future developments open source.

Donate $3

The Phase Distortion Oscillator

The PD oscillator works like the classic Casio CZ synthesizer. In essence it is really a form of FM. At the time Yamaha had patent on their FM (or PM) synthesis so Casio had to come up with a workaround.

It works by modulating a cosine wave by a modulation index and enveloping it with a slope to remove the nasty level jump.

CZ1pd

So it really simulates a saw wave run through a resonant lowpass filter.

The modules CV1 input is Pitch 1V/Octave and the CV2 input is the modulation index, 0.125 – 16x

The CV3 input is an audio gate input that allows you to run it with for example the Beatstep Pro without having a VCA module for some Acid patterns.

CZ1modindex

Here is the source-code for the PD module code.
The code is the same used in my CZ1 chip and the CZ-VCO module.

Download PDVCO.INO

// (*) All in the spirit of open-source and open-hardware
// Janost 2017 Sweden
// The 3HP Paperface Euro Modules
// https://janostman.wordpress.com/the-3hp-paperface-euro-modules/
// Copyright 2017 DSP Synthesizers Sweden.
//
// Author: Jan Ostman
//
// This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

//Set Fuses to E1 DD FE for PLLCLK 16MHz

#include <avr/interrupt.h>

#include <avr/io.h>

#include <avr/pgmspace.h>

 

#ifndef cbi

#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))

#endif

#ifndef sbi

#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))

#endif

 

uint8_t phase;

uint8_t otone1;

uint8_t otone2;

 

volatile uint8_t level1;

volatile uint8_t PDmod;

 

volatile uint8_t level3;

volatile uint8_t level4;

volatile uint8_t level5;

 

uint8_t MUX;

volatile uint16_t pitch;

uint16_t phacc;

uint16_t pdacc;

uint8_t dac;

 

const uint8_t sinetable[256] PROGMEM = {

0,0,0,0,1,1,1,2,2,3,4,5,5,6,7,9,10,11,12,14,15,16,18,20,21,23,25,27,29,31,

33,35,37,39,42,44,46,49,51,54,56,59,62,64,67,70,73,76,78,81,84,87,90,93,96,99,102,105,108,111,115,118,121,124,

127,130,133,136,139,143,146,149,152,155,158,161,164,167,170,173,176,178,181,184,187,190,192,195,198,200,203,205,208,210,212,215,217,219,221,223,225,227,229,231,233,234,236,238,239,240,

242,243,244,245,247,248,249,249,250,251,252,252,253,253,253,254,254,254,254,254,254,254,253,253,253,252,252,251,250,249,249,248,247,245,244,243,242,240,239,238,236,234,233,231,229,227,225,223,

221,219,217,215,212,210,208,205,203,200,198,195,192,190,187,184,181,178,176,173,170,167,164,161,158,155,152,149,146,143,139,136,133,130,127,124,121,118,115,111,108,105,102,99,96,93,90,87,84,81,78,

76,73,70,67,64,62,59,56,54,51,49,46,44,42,39,37,35,33,31,29,27,25,23,21,20,18,16,15,14,12,11,10,9,7,6,5,5,4,3,2,2,1,1,1,0,0,0

};

 

const uint16_t SAMPLEfreq[1024] PROGMEM ={

1024,1027,1030,1034,1037,1041,1045,1048,1052,1055,1059,1062,1066,1070,1073,1077,

1080,1084,1088,1092,1095,1099,1103,1106,1110,1114,1118,1121,1125,1129,1133,1137,

1141,1145,1148,1152,1156,1160,1164,1168,1172,1176,1180,1184,1188,1192,1196,1200,

1204,1208,1212,1216,1221,1225,1229,1233,1237,1241,1246,1250,1254,1258,1263,1267,

1271,1275,1280,1284,1288,1293,1297,1302,1306,1310,1315,1319,1324,1328,1333,1337,

1342,1346,1351,1356,1360,1365,1369,1374,1379,1383,1388,1393,1398,1402,1407,1412,

1417,1421,1426,1431,1436,1441,1446,1451,1456,1460,1465,1470,1475,1480,1485,1490,

1495,1501,1506,1511,1516,1521,1526,1531,1537,1542,1547,1552,1557,1563,1568,1573,

1579,1584,1589,1595,1600,1606,1611,1617,1622,1628,1633,1639,1644,1650,1655,1661,

1667,1672,1678,1684,1689,1695,1701,1707,1712,1718,1724,1730,1736,1742,1747,1753,

1759,1765,1771,1777,1783,1789,1795,1802,1808,1814,1820,1826,1832,1839,1845,1851,

1857,1864,1870,1876,1883,1889,1895,1902,1908,1915,1921,1928,1934,1941,1947,1954,

1961,1967,1974,1981,1987,1994,2001,2008,2014,2021,2028,2035,2042,2049,2056,2063,

2070,2077,2084,2091,2098,2105,2112,2119,2127,2134,2141,2148,2156,2163,2170,2178,

2185,2192,2200,2207,2215,2222,2230,2237,2245,2253,2260,2268,2276,2283,2291,2299,

2307,2314,2322,2330,2338,2346,2354,2362,2370,2378,2386,2394,2402,2410,2419,2427,

2435,2443,2452,2460,2468,2477,2485,2493,2502,2510,2519,2527,2536,2545,2553,2562,

2571,2579,2588,2597,2606,2614,2623,2632,2641,2650,2659,2668,2677,2686,2695,2704,

2714,2723,2732,2741,2751,2760,2769,2779,2788,2798,2807,2817,2826,2836,2845,2855,

2865,2874,2884,2894,2904,2914,2923,2933,2943,2953,2963,2973,2983,2993,3004,3014,

3024,3034,3045,3055,3065,3076,3086,3097,3107,3118,3128,3139,3149,3160,3171,3182,

3192,3203,3214,3225,3236,3247,3258,3269,3280,3291,3302,3313,3325,3336,3347,3359,

3370,3381,3393,3404,3416,3428,3439,3451,3463,3474,3486,3498,3510,3522,3534,3546,

3558,3570,3582,3594,3606,3618,3631,3643,3655,3668,3680,3693,3705,3718,3730,3743,

3756,3768,3781,3794,3807,3820,3833,3846,3859,3872,3885,3898,3911,3924,3938,3951,

3965,3978,3991,4005,4019,4032,4046,4060,4073,4087,4101,4115,4129,4143,4157,4171,

4185,4199,4214,4228,4242,4257,4271,4286,4300,4315,4329,4344,4359,4373,4388,4403,

4418,4433,4448,4463,4478,4494,4509,4524,4539,4555,4570,4586,4601,4617,4633,4648,

4664,4680,4696,4712,4728,4744,4760,4776,4792,4808,4825,4841,4857,4874,4890,4907,

4924,4940,4957,4974,4991,5008,5025,5042,5059,5076,5093,5110,5128,5145,5162,5180,

5198,5215,5233,5251,5268,5286,5304,5322,5340,5358,5376,5395,5413,5431,5450,5468,

5487,5505,5524,5543,5562,5580,5599,5618,5637,5656,5676,5695,5714,5734,5753,5773,

5792,5812,5831,5851,5871,5891,5911,5931,5951,5971,5992,6012,6032,6053,6073,6094,

6114,6135,6156,6177,6198,6219,6240,6261,6282,6304,6325,6346,6368,6390,6411,6433,

6455,6477,6499,6521,6543,6565,6587,6609,6632,6654,6677,6700,6722,6745,6768,6791,

6814,6837,6860,6883,6907,6930,6954,6977,7001,7025,7049,7072,7096,7120,7145,7169,

7193,7217,7242,7267,7291,7316,7341,7366,7391,7416,7441,7466,7491,7517,7542,7568,

7593,7619,7645,7671,7697,7723,7749,7775,7802,7828,7855,7881,7908,7935,7962,7989,

8016,8043,8070,8098,8125,8153,8180,8208,8236,8264,8292,8320,8348,8377,8405,8433,

8462,8491,8520,8548,8577,8606,8636,8665,8694,8724,8753,8783,8813,8843,8873,8903,

8933,8963,8994,9024,9055,9085,9116,9147,9178,9209,9240,9272,9303,9335,9366,9398,

9430,9462,9494,9526,9559,9591,9624,9656,9689,9722,9755,9788,9821,9854,9888,9921,

9955,9989,10022,10056,10090,10125,10159,10193,10228,10263,10298,10332,10367,10403,10438,10473,

10509,10544,10580,10616,10652,10688,10724,10761,10797,10834,10871,10907,10944,10981,11019,11056,

11094,11131,11169,11207,11245,11283,11321,11360,11398,11437,11475,11514,11553,11593,11632,11671,

11711,11751,11790,11830,11871,11911,11951,11992,12032,12073,12114,12155,12196,12238,12279,12321,

12363,12404,12447,12489,12531,12574,12616,12659,12702,12745,12788,12832,12875,12919,12962,13006,

13051,13095,13139,13184,13228,13273,13318,13363,13409,13454,13500,13546,13591,13638,13684,13730,

13777,13823,13870,13917,13965,14012,14059,14107,14155,14203,14251,14299,14348,14396,14445,14494,

14543,14593,14642,14692,14742,14792,14842,14892,14943,14993,15044,15095,15146,15198,15249,15301,

15353,15405,15457,15509,15562,15615,15668,15721,15774,15828,15881,15935,15989,16043,16098,16152,

16207,16262,16317,16372,16428,16484,16540,16596,16652,16708,16765,16822,16879,16936,16993,17051,

17109,17167,17225,17283,17342,17401,17460,17519,17578,17638,17698,17758,17818,17878,17939,18000,

18061,18122,18184,18245,18307,18369,18431,18494,18557,18620,18683,18746,18810,18873,18937,19002,

19066,19131,19195,19261,19326,19391,19457,19523,19589,19656,19722,19789,19856,19924,19991,20059,

20127,20195,20264,20332,20401,20470,20540,20609,20679,20749,20820,20890,20961,21032,21104,21175,

21247,21319,21391,21464,21537,21610,21683,21756,21830,21904,21978,22053,22128,22203,22278,22353,

22429,22505,22582,22658,22735,22812,22889,22967,23045,23123,23201,23280,23359,23438,23518,23597,

23677,23758,23838,23919,24000,24081,24163,24245,24327,24410,24492,24575,24659,24742,24826,24910,

24995,25080,25165,25250,25336,25421,25508,25594,25681,25768,25855,25943,26031,26119,26208,26297,

26386,26475,26565,26655,26745,26836,26927,27018,27110,27202,27294,27387,27479,27573,27666,27760,

27854,27948,28043,28138,28234,28329,28425,28522,28619,28716,28813,28911,29009,29107,29206,29305,

29404,29504,29604,29704,29805,29906,30007,30109,30211,30313,30416,30519,30623,30727,30831,30935,

31040,31145,31251,31357,31463,31570,31677,31784,31892,32000,32109,32218,32327,32436,32546,32657

};

 

 

 

void setup() {

// Enable 64 MHz PLL and use as source for Timer1

PLLCSR = 1<<PCKE | 1<<PLLE;

 

// Set up Timer/Counter1 for PWM output

TIMSK = 0; // Timer interrupts OFF

TCCR1 = 1<<PWM1A | 2<<COM1A0 | 1<<CS10; // PWM A, clear on match, 1:1 prescale

//GTCCR = 1<<PWM1B | 2<<COM1B0; // PWM B, clear on match

OCR1A = 128; //OCR1B = 128; // 50% duty at start

 

pinMode(1, OUTPUT); // Enable PWM output pin

pinMode(2, INPUT);

 

// Set up Timer/Counter0 for 66979Hz interrupt to output samples.

TCCR0A = 3<<WGM00; // Fast PWM

TCCR0B = 1<<WGM02 | 2<<CS00; // 1/8 prescale

TIMSK = 1<<OCIE0A; // Enable compare match, disable overflow

OCR0A = 29; // 66979Hz

 

uint16_t dummy=analogRead(0);

}

 

void loop() {

if (digitalRead(2)) level1=255; //Test for Gate VCA

if (!digitalRead(2)) level1=0;

 

//————— ADC block ————————————-

if (!(ADCSRA & 64)) {

uint16_t level=((ADCL+(ADCH<<8)));

if (MUX==3) pitch=(pgm_read_word_near( SAMPLEfreq + level));

if (MUX==2) PDmod=(level>>3)+1;

MUX++;

MUX&=3;

ADMUX = MUX; //Select MUX

sbi(ADCSRA, ADSC); //start next conversation

}

//—————————————————————

}

ISR(TIMER0_COMPA_vect) {

phacc+=pitch;

if (phacc & 0x8000) {

phacc &= 0x7FFF;

otone1+=1;

uint8_t env=(255-otone1);

pdacc+=PDmod;

if (!otone1) pdacc=0;

otone2=(pdacc>>3)&255;

dac=((pgm_read_byte(&sinetable[otone2])+pgm_read_byte(&sinetable[(otone2+(127-env))&255]))>>1);

OCR1A = dac&level1; //Gate the signal

}

//—————————————————————–

}

 

The Paperface drums

You can also program the Paperface to be a 8-voice polyphonic drum sampler.

Here CV1 selects among 8 available drums sounds and CV2 adjusts the pitch.
CV3 is used as a rising edge trigger.

It is polyphonic so changing the drum sound after a trigger and retriggering wont cut out the playing drum sound.

It sounds like this:

 

You can use the wav2c utility for creating the arrays with the drum sounds so you can have custom sounds.

And here is the code:

Download DRUM8.INO

// Copyright 2016 DSP Synthesizers Sweden.

//

// Author: Jan Ostman

//

// This program is free software: you can redistribute it and/or modify

// it under the terms of the GNU General Public License as published by

// the Free Software Foundation, either version 3 of the License, or

// (at your option) any later version.

// This program is distributed in the hope that it will be useful,

// but WITHOUT ANY WARRANTY; without even the implied warranty of

// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

// GNU General Public License for more details.

 

 

 

#include <avr/interrupt.h>

#include <avr/io.h>

#include <avr/pgmspace.h>

 

#ifndef cbi

#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))

#endif

#ifndef sbi

#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))

#endif

 

 

//——— Ringbuf parameters ———-

uint8_t Ringbuffer[256];

uint8_t RingWrite=0;

uint8_t RingRead=0;

volatile uint8_t RingCount=0;

//—————————————–

 

 

const uint8_t drum1[] PROGMEM =

{

128,129,129,129,129,130,130,131,132,132,137,132,126,100,140,249,79,164,144,144,113,142,125,114,123,73,116,66,83,55,79,59,67,60,70,63,72,66,86,94,101,116,107,136,182,141,158,223,186,199,207,227,237,239,239,240,235,223,198,196,188,183,171,168,156,150,141,132,124,120,105,100,89,75,71,70,56,46,44,33,29,29,28,25,22,23,22,23,25,28,32,39,48,51,57,66,

71,79,87,97,105,112,119,128,134,141,151,156,168,168,188,181,201,196,227,221,238,235,234,238,238,235,234,229,224,212,207,193,188,184,177,170,165,158,151,142,137,128,121,113,108,102,95,88,84,77,75,67,65,57,56,49,49,44,43,42,34,36,32,35,37,36,33,40,38,43,42,48,48,52,54,55,63,69,70,74,80,84,89,92,98,104,107,111,115,119,120,129,123,134,137,140,144,144,147,150,

154,152,155,158,157,162,158,159,162,161,160,160,162,162,161,162,163,164,163,168,167,169,169,173,171,174,171,176,176,177,175,179,176,175,174,173,172,172,166,166,162,158,156,152,148,143,140,134,131,125,121,117,113,108,104,100,95,91,87,82,80,74,72,67,64,60,55,54,51,49,46,42,44,43,43,41,42,43,45,46,48,49,51,55,58,61,66,72,76,81,86,92,100,104,112,116,123,128,135,140,

145,150,155,160,163,168,171,176,178,180,182,185,187,188,189,190,188,190,189,188,186,188,183,184,180,179,175,174,169,168,165,160,158,155,151,148,145,142,138,135,132,129,126,124,121,118,116,114,112,110,109,106,106,104,104,103,103,102,102,102,102,103,103,104,105,105,106,106,108,109,111,112,113,114,115,116,118,119,121,121,123,124,125,126,127,128,129,130,131,132,132,133,133,134,134,134,135,134,134,134,

134,134,133,133,133,132,132,132,131,131,130,130,130,129,129,128,128,128,128,128,127,127,127,127,127,127,127,127,127,127,127,128,128,128,128,129,129,130,130,130,131,131,132,132,133,133,134,134,135,135,135,136,136,136,136,136,136,136,136,136,136,136,136,136,136,135,135,135,135,134,134,134,134,134,134,133,133,133,133,133,133,133,133,133,133,133,132,132,132,132,132,132,132,132,131,131,131,131,131,131,

130,130,130,130,130,130,129,129,129,129,129,129,129,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,129,129,129,129,129,129,130,130,130,130,131,131,131,131,131,132,132,132,132,132,132,133,133,133,133,133,133,133,133,133,134,134,134,134,134,134,134,134,134,134,134,134,134,134,134,134,134,134,134,134,133,133,133,133,133,133,133,133,133,132,132,132,132,

132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,

131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,130,130,130,130,130,130,130,130,130,131,131,131,131,131,130,130,130,130,130,130,130,130,130,130,130,130,130,130,129,

129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,128,128,128,128,128,128,128,128,128,128,128,128,128

};

 

const uint8_t drum2[] PROGMEM =

{

128,164,168,168,163,142,145,75,24,39,25,39,51,76,78,90,103,129,149,163,194,207,213,177,181,178,194,185,231,220,227,225,210,161,150,151,133,119,110,87,75,62,49,22,20,10,35,18,16,21,19,21,31,60,66,73,87,108,117,134,155,169,234,237,255,242,238,243,240,231,222,175,182,163,147,122,104,96,87,78,58,37,13,26,20,27,18,25,18,31,44,88,111,109,114,152,

194,171,150,194,239,213,238,232,216,225,236,208,151,164,129,125,97,100,81,81,73,48,19,44,57,22,40,22,41,28,59,49,85,72,93,120,129,134,128,151,169,184,165,170,172,175,172,157,148,142,145,175,141,137,140,122,119,112,96,99,73,50,71,29,44,41,30,28,58,60,83,95,113,103,97,110,118,131,154,160,151,150,177,163,186,187,196,208,233,195,218,164,144,144,130,128,114,89,68,93,

68,44,73,41,30,61,47,74,95,80,108,90,134,112,139,126,137,165,161,157,176,174,173,157,150,179,171,145,158,143,149,143,104,122,106,96,89,99,108,97,75,65,103,106,93,93,125,104,114,112,105,116,132,126,162,129,106,129,137,140,130,145,128,151,134,145,175,166,174,168,169,153,145,154,148,128,130,110,111,96,100,76,89,77,75,81,89,82,101,92,113,101,125,137,144,137,160,153,147,153,

149,149,197,182,167,159,176,161,146,147,147,131,130,128,100,114,117,100,109,82,104,90,76,73,101,97,96,107,116,128,127,148,149,141,164,155,164,152,157,156,154,148,148,152,129,154,142,136,147,132,126,140,128,131,126,118,120,116,105,120,111,112,115,109,118,111,111,106,129,112,129,127,123,125,132,127,129,140,139,131,140,136,154,142,135,146,150,151,148,152,147,138,142,144,134,129,131,128,113,113,

117,111,108,104,98,106,99,109,101,114,123,118,142,133,133,138,144,147,137,142,154,142,142,159,138,145,150,148,139,136,133,128,118,122,125,122,120,112,115,111,115,112,99,114,109,126,125,120,125,140,136,136,144,135,133,142,146,146,146,134,145,132,133,134,131,131,127,134,127,129,124,136,132,128,140,132,131,131,128,133,129,124,127,121,130,126,125,122,124,127,128,128,124,127,130,130,129,128,127,136,

131,139,143,142,141,138,141,145,141,141,141,139,140,131,131,126,128,123,121,125,118,117,120,117,120,117,114,121,121,130,121,132,128,131,132,140,136,140,138,145,137,138,139,138,135,134,132,128,129,125,125,125,126,123,126,120,124,120,131,124,124,128,131,132,129,130,135,132,144,136,137,134,141,136,132,133,136,136,130,128,127,129,123,132,128,126,131,129,129,128,132,130,132,134,133,131,134,132,130,134,

134,131,133,130,134,126,129,128,132,128,129,128,122,127,129,122,128,131,129,132,134,134,135,135,136,138,137,138,139,142,139,134,135,134,133,131,133,127,124,127,126,123,123,126,120,123,127,125,127,128,129,130,133,132,139,134,137,135,134,134,135,130,132,131,131,129,128,130,126,127,124,127,126,125,128,129,127,126,128,129,131,131,134,132,133,131,134,134,135,130,134,131,131,134,131,131,130,128,129,128,

127,128,124,126,127,128,128,129,128,132,131,133,135,132,134,138,137,136,134,134,134,134,132,130,130,131,129,129,127,127,128,128,126,129,130,128,128,129,131,131,130,131,133,133,133,134,134,131,133,132,130,130,129,130,129,128,127,128,126,126,125,127,127,126,127,128,129,129,131,130,131,131,132,131,132,131,131,130,130,130,129,129,129,128,126,128,128,127,127,127,127,127,127,128,128,128,128,128,128,129,

129,129,130,130,130,130,130,130,130,129,129,128,128,128,128,128,128,128,128,127,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128

};

 

const uint8_t drum3[] PROGMEM =

{

128,187,132,118,145,112,103,172,95,106,37,137,114,109,133,148,103,148,107,135,58,154,114,117,92,174,181,119,152,175,122,130,146,108,96,121,110,107,66,74,111,61,110,105,134,85,121,141,125,136,203,130,141,124,159,165,171,149,110,153,99,108,104,184,115,28,87,94,27,43,115,130,148,94,137,148,97,134,150,127,83,180,107,200,115,112,87,159,97,144,44,148,84,128,70,136,

108,114,134,80,155,110,103,150,127,136,70,101,72,140,146,109,87,110,24,142,109,99,160,152,98,186,71,160,116,166,19,211,113,147,83,181,115,130,84,128,101,127,131,116,98,139,67,143,148,142,140,125,103,166,123,114,91,116,137,146,64,104,81,198,93,134,110,93,126,154,128,149,108,116,130,129,116,116,123,127,173,109,99,114,113,120,146,120,82,144,35,120,105,120,124,137,74,146,98,121,

122,98,154,120,99,114,145,77,125,152,58,72,106,64,145,178,112,89,84,113,131,99,136,143,120,194,118,132,130,127,118,82,77,134,41,138,96,170,20,130,110,150,105,149,164,116,108,143,112,107,88,111,98,108,81,152,85,107,126,171,67,126,161,164,138,121,79,156,102,188,37,145,71,172,67,170,58,123,99,168,124,173,102,170,115,138,96,101,84,121,90,87,99,132,82,142,85,184,32,146,

117,195,109,119,160,113,126,113,82,125,141,186,122,134,82,82,185,115,110,157,127,130,127,155,160,133,105,111,126,89,46,161,104,146,108,108,102,161,100,160,125,152,199,126,94,128,103,184,86,79,116,65,135,142,103,147,103,140,112,108,111,144,110,116,132,124,93,112,115,104,130,114,103,172,171,135,98,133,92,137,90,121,113,137,197,110,108,104,117,128,128,85,111,149,104,122,95,145,172,130,

44,145,110,186,140,154,127,44,112,124,80,142,119,114,66,122,140,209,89,123,132,140,86,151,98,128,138,113,103,140,155,118,104,131,183,94,136,128,109,116,75,136,161,102,82,128,114,133,134,169,75,141,145,110,90,199,86,207,92,107,125,112,167,129,115,75,86,149,142,124,106,99,86,126,169,119,110,135,155,130,102,143,127,123,106,65,116,79,143,151,186,90,142,139,73,157,160,138,117,122,

91,155,49,163,78,87,118,122,182,127,109,112,158,79,155,135,122,157,162,118,131,138,136,143,118,143,100,76,153,136,128,64,120,86,161,122,164,212,114,117,154,107,153,120,149,82,105,119,129,107,155,86,131,86,130,108,158,147,116,98,107,99,109,145,135,108,132,89,109,143,97,109,122,139,130,157,127,162,152,122,94,135,166,133,153,131,95,124,132,120,103,128,132,126,217,95,134,120,128,108,

126,185,138,126,106,84,141,108,132,137,115,100,104,184,179,101,192,104,115,157,146,119,129,91,131,120,105,159,140,79,139,78,136,131,164,143,112,121,150,138,134,151,147,88,121,124,140,106,92,133,119,87,188,114,154,104,125,147,129,139,157,146,137,104,121,136,112,120,135,71,115,112,154,111,118,87,171,94,200,127,137,81,154,156,92,117,144,133,147,90,175,99,116,161,152,79,97,120,146,126,

152,132,133,127,189,158,162,95,200,117,120,92,141,83,133,118,193,66,131,164,129,105,158,126,129,109,111,140,106,154,132,131,88,117,148,143,108,147,142,120,98,141,117,92,119,126,194,125,152,133,151,94,122,106,141,116,137,111,74,119,167,133,129,160,135,122,121,209,82,103,87,124,150,97,161,144,94,141,175,107,141,148,163,81,109,138,141,91,139,119,156,113,133,155,114,86,137,100,151,105,

181,112,103,164,141,107,132,70,147,88,143,108,136,92,129,101,130,112,173,154,131,106,148,134,119,95,111,55,157,102,151,119,160,138,162,91,179,148,144,110,155,106,124,98,208,92,133,67,160,114,114,134,129,62,153,127,144,146,148,150,158,109,130,146,146,156,122,112,71,88,133,112,130,138,116,118,158,158,129,96,179,110,122,111,120,131,143,57,161,125,109,158,206,128,118,111,141,134,146,134,

138,94,139,155,163,154,115,127,68,100,130,160,115,143,167,127,113,175,169,116,124,128,139,111,116,134,132,74,125,131,115,114,191,123,148,139,148,122,151,142,132,94,117,109,154,82,135,117,110,135,189,155,121,116,144,104,130,113,148,138,153,145,161,105,115,120,146,78,137,129,91,107,146,127,102,136,146,131,127,118,161,150,117,121,115,91,114,181,145,96,175,157,121,127,144,110,138,114,137,151,

137,138,153,97,91,132,162,136,129,128,135,57,145,116,86,119,113,146,157,128,141,178,93,134,152,118,132,128,129,120,92,139,120,133,151,126,114,114,158,148,118,119,159,148,73,160,162,149,104,149,172,169,95,147,126,90,120,139,147,116,115,160,134,131,145,172,117,147,173,97,129,121,133,143,50,151,164,125,131,165,113,133,120,145,122,97,147,153,108,146,123,146,149,155,213,145,107,184,162,123,

145,151,129,97,100,121,152,83,167,142,95,125,129,165,137,127,171,147,101,169,152,141,115,152,136,125,134,180,131,90,135,86,133,118,137,148,137,151,150,123,135,162,150,111,156,148,131,116,113,122,103,126,149,140,118,137,147,138,132,142,138,139,101,143,143,128,136,94,116,130,107,133,141,111,111,117,139,147,112,143,114,132,148,163,142,178,126,155,124,102,125,132,118,130,149,117,129,153,105,131,

84,159,162,133,144,134,132,131,105,144,106,158,128,139,122,153,159,141,127,112,101,143,120,151,118,144,153,132,144,132,154,149,108,154,105,137,132,146,97,93,124,128,134,151,124,156,125,143,127,124,141,143,149,138,125,140,126,115,127,141,112,157,142,136,157,104,139,146,108,151,137,137,144,121,144,158,108,142,109,120,121,165,133,118,125,127,144,127,137,140,131,153,127,139,92,119,127,124,120,129,

115,134,144,141,130,134,126,136,116,134,162,117,152,113,126,137,118,137,129,127,129,125,115,132,131,130,126,152,131,154,121,161,136,126,128,143,119,131,125,113,121,118,113,130,113,137,145,117,161,129,148,135,127,124,131,130,131,127,130,124,119,137,125,130,126,127,123,140,113,137,137,125,129,140,120,133,139,128,122,124,127,125,126,121,129,118,126,131,134,137,126,140,133,129,131,131,126,128,129,126,

117,139,121,127,123,133,128,130,132,134,127,136,126,134,130,126,127,128,126,130,135,125,126,130,121,133,125,130,128,131,129,128,130,132,128,132,127,130,125,130,127,128,126,127,126,130,127,129,126,130,129,130,128,128,131,128,128,128,128,128,127,128,128,128,128,128

};

 

const uint8_t drum4[] PROGMEM =

{

128,142,62,59,95,60,79,91,166,123,135,161,238,246,165,189,136,154,183,89,63,96,94,45,83,59,59,78,74,84,99,95,111,108,139,130,130,176,182,186,218,222,249,158,162,214,237,214,223,201,174,178,106,156,131,108,84,119,30,21,38,17,40,44,98,40,49,57,71,86,93,110,103,145,157,162,143,176,161,182,200,214,198,206,178,159,169,145,135,116,129,88,101,81,54,15,

26,18,10,29,41,30,47,62,64,87,88,94,105,120,122,162,162,243,186,195,190,209,196,191,172,173,165,159,146,130,111,88,96,122,76,34,39,49,26,28,31,36,44,58,66,83,94,101,125,135,130,161,183,186,190,192,219,197,190,185,189,185,177,166,160,145,141,108,107,95,73,59,23,42,50,38,41,42,56,65,71,87,102,101,118,136,146,142,166,177,188,220,242,212,232,233,194,187,184,176,

169,156,147,138,120,111,58,68,59,46,37,31,42,38,49,53,64,71,83,96,97,114,130,136,143,159,166,181,182,198,221,218,228,215,190,186,179,173,159,150,141,124,108,92,90,65,54,48,46,39,41,43,52,59,68,73,85,94,108,112,125,134,144,148,163,183,184,183,189,214,194,200,199,186,178,172,161,153,139,124,123,104,76,76,67,47,44,45,45,44,50,59,64,74,82,90,100,106,117,130,

143,148,157,168,184,186,183,187,209,191,188,184,183,173,168,156,144,133,122,113,87,71,74,66,59,50,53,52,55,58,67,72,83,90,98,110,116,122,133,148,149,166,171,165,181,182,183,196,190,186,185,184,179,171,158,143,141,124,110,100,91,79,72,77,67,59,59,57,62,68,73,83,88,100,105,114,124,131,136,143,151,162,171,178,181,186,189,197,188,184,187,182,173,163,155,150,140,126,111,106,

93,89,75,71,64,65,63,66,66,73,80,83,93,103,112,118,123,130,142,147,155,160,168,178,184,181,194,190,192,182,182,178,174,165,160,148,144,129,115,105,102,94,88,76,81,71,67,68,70,71,78,84,92,100,108,116,124,135,138,145,155,161,165,168,176,176,187,188,185,185,179,180,178,170,160,155,147,137,132,119,108,100,95,85,75,75,71,79,72,73,77,84,91,96,104,112,116,124,132,140,

147,152,156,161,172,170,175,178,179,181,181,181,179,175,170,158,156,149,143,134,123,113,104,100,93,81,85,78,76,77,78,80,86,89,95,100,108,116,125,128,138,143,145,152,154,160,166,171,172,176,180,174,176,176,170,168,165,156,153,144,138,130,123,113,111,101,96,90,87,88,83,82,83,83,85,90,98,104,110,116,122,127,134,140,146,148,153,162,164,165,171,168,171,173,172,171,170,169,165,161,

152,147,137,136,128,119,111,103,101,96,91,88,86,86,86,85,88,91,97,102,107,113,119,123,130,136,140,148,152,155,157,161,166,167,168,168,168,169,167,163,164,160,157,151,144,139,133,126,122,116,104,100,101,92,93,89,88,87,84,88,92,97,103,108,112,117,122,132,134,136,144,148,153,155,159,160,162,166,166,165,164,164,163,160,158,153,150,145,139,134,127,122,118,114,107,108,104,97,98,96,

95,97,96,98,102,104,109,112,118,120,125,129,135,139,142,144,147,151,152,153,152,156,158,157,158,156,154,152,152,149,145,140,136,134,130,124,121,118,112,109,105,104,105,105,102,103,104,104,107,108,111,114,119,123,125,129,134,136,139,141,142,144,145,148,149,148,148,149,148,147,147,148,146,144,142,140,137,133,130,128,124,122,119,116,112,111,111,110,110,109,109,109,112,113,114,117,120,123,125,127,

129,131,134,134,139,139,140,141,142,143,143,144,143,142,142,142,141,141,140,139,136,134,132,129,127,125,122,120,118,118,116,116,116,116,117,116,116,116,117,118,120,122,124,125,126,128,130,131,133,134,136,136,136,138,137,138,137,138,138,137,137,137,136,136,135,134,132,131,130,128,126,126,125,124,123,122,121,122,120,121,121,121,121,122,122,123,124,125,126,127,128,129,129,130,131,131,131,132,132,132,

133,133,133,133,133,133,132,132,132,132,131,131,130,129,129,128,128,127,126,126,126,126,125,125,125,125,125,125,125,125,125,126,126,127,127,127,128,128,128,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128

};

 

const uint8_t drum5[] PROGMEM =

{

128,122,164,121,123,49,34,101,250,246,152,60,49,111,58,167,243,126,103,68,138,107,113,121,135,96,147,138,114,110,115,90,125,85,53,91,165,246,143,91,89,70,97,54,129,241,102,103,167,113,90,131,147,149,117,81,111,112,35,94,196,103,158,168,112,44,120,56,138,226,108,107,61,99,147,82,54,129,13,101,250,184,82,140,81,179,56,81,80,147,198,98,141,18,46,56,

189,254,168,36,66,79,53,144,253,192,89,10,140,167,53,77,163,202,164,73,29,98,165,119,18,91,84,89,98,209,192,61,73,25,142,237,166,219,135,97,74,22,152,180,84,79,18,108,145,178,100,41,146,158,198,133,92,93,131,73,58,131,142,158,70,82,91,188,156,136,81,54,175,172,64,165,89,15,71,219,174,86,127,159,67,84,121,151,250,145,96,44,75,132,128,74,133,184,107,138,

209,148,138,62,135,120,24,69,192,204,112,29,122,86,128,134,172,133,145,122,85,108,151,111,72,82,88,200,163,106,52,120,196,196,130,46,103,187,156,56,110,116,180,116,99,118,142,140,110,102,162,175,128,62,104,183,143,61,154,175,142,51,160,151,123,71,118,126,176,110,144,170,153,149,127,49,53,165,172,102,158,159,118,115,98,140,88,94,124,143,109,231,146,52,104,157,172,153,100,89,

127,143,147,110,153,130,87,127,107,139,182,117,126,118,126,122,114,132,128,121,131,147,121,123,115,170,121,78,130,117,122,128,158,132,113,142,135,154,122,101,102,120,101,99,154,178,147,108,125,125,142,140,109,122,137,137,132,93,117,163,135,124,93,126,145,162,106,123,100,146,138,123,134,155,133,130,115,139,135,130,98,138,152,102,120,129,126,153,127,120,125,136,133,136,138,147,132,138,134,124,

100,123,135,137,125,137,146,149,138,122,115,116,125,136,136,147,121,126,136,143,144,131,110,132,120,130,142,170,127,112,114,120,136,143,136,140,136,110,121,152,141,149,115,115,129,137,144,156,124,113,132,134,146,127,124,131,127,136,135,133,137,123,123,146,144,142,129,117,127,119,138,150,129,124,131,126,129,150,129,128,121,116,127,146,145,132,129,134,149,136,130,123,130,132,121,126,142,137,130,128,

133,140,127,124,126,125,136,136,124,123,139,138,137,129,139,131,112,124,138,132,129,125,137,139,125,125,135,122,126,135,135,132,132,132,128,134,133,126,127,129,127,129,131,132,122,126,133,133,125,124,135,136,133,129,126,131,130,130,130,128,129,130,130,130,128,128,131,130,129,129,128,128,127,128,129,131,130,128,129,128,130,129,129,130,129,129,127,129,129,128,127,128,128,129,128,128,129,129,129,129,

129,128,128,128,128,129,128,128,128,128,128,128,128,128

};

 

const uint8_t drum6[] PROGMEM =

{

128,149,117,85,141,185,112,43,133,218,116,10,125,251,128,2,109,237,143,15,101,223,148,25,94,211,163,31,88,205,164,53,74,198,177,55,71,183,183,74,62,167,191,93,48,164,193,94,63,145,195,113,53,137,199,117,59,126,188,139,59,106,196,148,63,97,186,166,75,75,180,184,83,62,163,193,96,55,156,192,103,67,138,191,119,66,133,188,123,68,124,185,131,71,118,181,

142,72,111,180,142,80,110,170,145,88,107,163,149,95,103,155,154,98,102,153,150,106,106,144,145,113,112,135,145,118,111,137,143,120,114,134,139,122,115,132,140,124,116,129,138,127,118,129,136,127,121,125,135,131,121,126,133,130,124,126,132,129,127,128,130,129

};

 

const uint8_t drum7[] PROGMEM =

{

128,129,112,108,86,114,157,124,159,206,159,121,96,93,46,41,167,172,164,178,227,178,165,116,38,8,79,124,133,148,186,255,230,163,96,39,8,18,59,85,125,241,248,243,201,128,83,4,6,38,52,92,172,243,247,229,165,76,13,8,7,29,66,142,238,247,242,194,123,48,6,11,9,33,103,164,247,244,238,160,92,49,13,9,17,58,134,216,246,241,194,139,73,35,12,12,

29,91,163,242,237,227,162,122,79,16,13,17,67,126,175,230,236,183,157,104,72,21,19,41,95,148,178,219,212,169,150,108,52,34,40,80,110,146,172,182,185,166,127,97,60,52,71,93,127,140,166,174,176,153,117,87,76,75,90,99,125,142,159,175,154,139,114,97,88,92,96,107,118,145,156,160,148,127,118,110,104,94,97,108,126,143,153,144,143,131,126,116,104,102,98,114,129,136,143,141,

137,140,129,120,103,103,107,116,127,129,136,142,143,140,130,118,109,105,115,116,123,128,134,144,146,139,127,116,115,113,112,116,117,130,138,145,142,135,128,120,117,115,111,114,121,131,143,142,141,130,129,125,118,113,110,116,127,134,140,140,137,136,128,125,114,112,112,120,129,136,138,139,137,136,130,120,115,111,118,123,131,134,137,140,140,134,128,117,115,116,119,126,128,136,137,141,139,131,124,118,

116,120,121,126,129,135,141,139,137,128,123,121,121,121,123,125,132,135,138,136,131,128,125,124,122,123,123,127,132,135,134,134,129,129,127,125,124,123,126,129,131,132,132,131,130,128,128,125,125,125,127,129,130,130,130,130,130,128,127,126,126,127,128,129,129,129,130,130,129,128,127,127,127,128,128,128,129,129,129,129,129,128,128,128,128,128,128,128,128,129,128,128,128,128,128,128,128,128

};

 

const uint8_t drum8[] PROGMEM =

{

128,128,129,129,129,128,128,128,129,128,128,128,128,127,128,127,130,129,129,130,128,128,128,127,129,129,129,123,130,127,127,126,131,128,127,128,130,125,129,127,125,131,124,126,126,128,124,124,128,125,129,133,130,121,130,122,135,126,120,127,123,117,137,129,119,138,122,125,135,129,142,113,140,121,112,148,107,142,135,108,151,105,137,124,114,141,142,114,130,138,113,126,127,150,118,127,

110,143,115,137,124,130,122,126,121,120,124,123,120,129,117,127,133,138,130,130,104,133,135,119,148,129,119,142,126,126,128,143,117,132,119,128,138,128,122,134,126,138,142,124,156,106,112,150,132,118,189,101,118,127,106,150,117,118,131,113,140,128,131,115,103,171,103,146,116,148,104,111,124,163,75,127,144,148,124,118,101,170,124,143,133,133,129,128,125,143,152,116,98,153,140,100,115,111,160,93,

111,157,157,138,168,97,158,113,116,157,143,184,99,132,183,70,155,133,118,111,109,100,88,111,134,125,163,79,134,112,60,174,128,123,144,116,166,114,147,132,31,144,57,120,166,121,114,127,77,171,118,48,191,62,147,143,159,105,134,132,208,84,90,221,88,157,156,67,99,179,83,177,139,150,107,103,181,78,122,162,106,214,135,122,88,123,179,79,143,178,55,169,115,132,159,66,133,224,88,175,

95,162,124,57,177,120,125,151,140,70,224,95,246,98,60,130,110,88,150,102,118,69,134,118,108,152,106,70,91,144,106,213,138,88,89,150,170,179,85,144,96,90,106,124,177,84,168,110,145,148,69,183,75,126,137,127,113,90,78,174,73,92,193,87,131,161,97,146,158,124,139,157,86,158,120,93,80,105,104,152,81,177,41,164,178,143,91,128,143,111,56,126,137,106,114,123,132,143,107,152,

129,159,137,88,79,114,177,61,168,116,128,76,123,149,171,83,160,160,115,140,101,113,144,154,147,134,97,135,120,134,113,121,112,181,77,159,124,155,73,168,155,137,112,135,95,152,158,100,143,132,123,128,150,117,116,127,141,102,113,158,121,121,145,104,100,112,138,123,133,132,120,125,126,127,118,121,119,135,93,129,120,128,133,127,118,127,128,131,131,133,116,127,140,120,130,122,132,122,128,128,

128,127,123,130,125,124,122,136,121,130,130,127,120,123,133,126,122,125,132,123,130,125,129,123,133,125,126,127,130,125,127,129,127,127,124,126,126,129,125,127,121,135,128,123,130,123,128,126,125,125,128,121,130,123,123,126,125,128,123,126,124,127,122,129,123,125,129,125,126,124,129,126,128,126,130,123,128,127,127,128,127,129,127,127,128,127,126,130,125,128,127,129,125,128,126,127,128,129,127,127,

129,125,129,128,128,126,127,127,127,127,127,126,128,126,125,127,125,128,126,125,127,128,125,126,127,127,125,127,126,126,127,126,126,127,127,126,126,126,127,127,127,127,127,127,126,128,128,126,128,128,127,127,127,129,127,127,128,127,128,128,127,128,128,127,128,129,127,127,128,127,127,128,127,128,127,128,128,126,127,127,127,127,127,127,126,127,127,127,128,127,127,127,127,128,127,128,127,127,127,127,

127,128,128,127,127,127,127,128,127,128,128,128,128,127,128,128,127,128,128,127,127,128,128,127,128,127,128,128,128,128,127,128,128,128,127,127,128,127,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128

};

 

 

void setup() {

OSCCAL=255;

// Enable 64 MHz PLL and use as source for Timer1

PLLCSR = 1<<PCKE | 1<<PLLE;

 

// Set up Timer/Counter1 for PWM output

TIMSK = 0; // Timer interrupts OFF

TCCR1 = 1<<PWM1A | 2<<COM1A0 | 1<<CS10; // PWM A, clear on match, 1:1 prescale

//GTCCR = 1<<PWM1B | 2<<COM1B0; // PWM B, clear on match

OCR1A = 128; //OCR1B = 128; // 50% duty at start

 

pinMode(1, OUTPUT); // Enable PWM output pin

pinMode(2, INPUT_PULLUP);

 

 

//Set up Timer/Counter0 for 20kHz interrupt to output samples.

TCCR0A = 3<<WGM00; // Fast PWM

TCCR0B = 1<<WGM02 | 2<<CS00; // 1/8 prescale

TIMSK = 1<<OCIE0A; // Enable compare match, disable overflow

OCR0A = 49; // Divide by 400

 

uint16_t dummy=analogRead(0);

}

 

void loop() {

uint16_t samplecnt1,samplecnt2,samplecnt3,samplecnt4,samplecnt5,samplecnt6,samplecnt7,samplecnt8;

uint16_t samplepnt1,samplepnt2,samplepnt3,samplepnt4,samplepnt5,samplepnt6,samplepnt7,samplepnt8;

uint8_t dread2;

uint8_t odread2;

uint8_t Seldrum;

uint8_t MUX=2;

sbi(ADCSRA, ADSC); //start next conversation

while(1) {

if (RingCount<32) { //if space in ringbuffer

int16_t total=0;

if (samplecnt1) {

total+=(pgm_read_byte_near(drum1 + samplepnt1++)-128);

samplecnt1–;

}

if (samplecnt2) {

total+=(pgm_read_byte_near(drum2 + samplepnt2++)-128);

samplecnt2–;

}

if (samplecnt3) {

total+=(pgm_read_byte_near(drum3 + samplepnt3++)-128);

samplecnt3–;

}

if (samplecnt4) {

total+=(pgm_read_byte_near(drum4 + samplepnt4++)-128);

samplecnt4–;

}

if (samplecnt5) {

total+=(pgm_read_byte_near(drum5 + samplepnt5++)-128);

samplecnt5–;

}

if (samplecnt6) {

total+=(pgm_read_byte_near(drum6 + samplepnt6++)-128);

samplecnt6–;

}

if (samplecnt7) {

total+=(pgm_read_byte_near(drum7 + samplepnt7++)-128);

samplecnt7–;

}

if (samplecnt8) {

total+=(pgm_read_byte_near(drum8 + samplepnt8++)-128);

samplecnt8–;

}

total>>=1;

total+=128;

if (total>255) total=255;

cli();

Ringbuffer[RingWrite]=total;

RingWrite++;

RingCount++;

sei();

dread2=digitalRead(2);

if (dread2!=odread2) {

odread2=dread2;

if (odread2) {

if (Seldrum==0) {

samplepnt1=0;

samplecnt1=sizeof(drum1);

}

if (Seldrum==1) {

samplepnt2=0;

samplecnt2=sizeof(drum2);

}

if (Seldrum==2) {

samplepnt3=0;

samplecnt3=sizeof(drum3);

}

if (Seldrum==3) {

samplepnt4=0;

samplecnt4=sizeof(drum4);

}

if (Seldrum==4) {

samplepnt5=0;

samplecnt5=sizeof(drum5);

}

if (Seldrum==5) {

samplepnt6=0;

samplecnt6=sizeof(drum6);

}

if (Seldrum==6) {

samplepnt7=0;

samplecnt7=sizeof(drum7);

}

if (Seldrum==7) {

samplepnt8=0;

samplecnt8=sizeof(drum8);

}

}

}

if (!(ADCSRA & 64)) {

if (MUX==3) OCR0A = 49+((127-((ADCL+(ADCH<<8))>>3)));

if (MUX==2) Seldrum=((ADCL+(ADCH<<8))>>7);

MUX++;

if (MUX==4) MUX=2;

ADMUX = MUX; //Select MUX

sbi(ADCSRA, ADSC); //start next conversation

}

 

}

}

}

 

ISR(TIMER0_COMPA_vect) {

//——————- Ringbuffer handler ————————-

if (RingCount) { //If entry in FIFO..

OCR1A = Ringbuffer[(RingRead++)]; //Output 8-bit DAC

RingCount–;

}

//—————————————————————–

}

 

 

Advertisements

%d bloggers like this: