/* Audio Pitch Shifter David Johnson-Davies - www.technoblogy.com - 11th February 2017 ATtiny85 @ 8MHz (internal oscillator; BOD disabled) CC BY 4.0 Licensed under a Creative Commons Attribution 4.0 International license: http://creativecommons.org/licenses/by/4.0/ */ volatile uint8_t Buffer[256]; // Circular buffer volatile uint8_t ReadPtr, WritePtr, LastPtr, New; // Everything done by interrupts ********************************** // ADC conversion complete - save sample in buffer ISR (ADC_vect) { Buffer[LastPtr] = New; New = ADCH + 128; Buffer[WritePtr] = (Buffer[WritePtr] + New)>>1; LastPtr = WritePtr; WritePtr = (WritePtr + 1) & 0xFF; } // Timer interrupt - read from buffer and output to DAC ISR (TIMER0_COMPA_vect) { OCR1A = Buffer[ReadPtr]; ReadPtr = (ReadPtr + 1) & 0xFF; } // Pin change interrupt adjusts shift ISR (PCINT0_vect) { int Buttons = PINB; if ((Buttons & 0x01) == 0) OCR0A++; else if ((Buttons & 0x04) == 0) OCR0A--; } // Setup ********************************************** void setup () { // Enable 64 MHz PLL and use as source for Timer1 PLLCSR = 1<