Thanks for the reply and the sample code.
The problem is that timer0 is used by the millis() and delay() and all internal timekeeping in the Arduino libraries. Changing it’s time constant impacts these operations.
The notes are created by using the delay function. Example:
void Beets:: triplet(Volume &vol ) {
digitalWrite(_pin,HIGH);
vol.tone(_pitch, 255);
vol.fadeOut(10 / delayTime);
vol.delay(delayTime / 3);
vol.tone(_pitch, 127);
vol.fadeOut(10 / delayTime);
vol.delay(delayTime / 3);
vol.tone(_pitch, 127);
vol.fadeOut(10 / delayTime);
vol.delay(delayTime / 3);
digitalWrite(_pin,LOW);
}
I also can’t use timer2 because that is related to the tone function.
I’ve also tried the timer1 library but that seems to cause a meltdown,
#include <TimerOne.h>
#include "Beets_machine.h"
#include "Volume.h"
Volume vol;
Beets Beets;
void setup() {
Serial.begin(9600);
Timer1.initialize(500000); // initialize timer1, and set a 1/2 second period
//Timer1.pwm(9, 512); // setup pwm on pin 9, 50% duty cycle
Timer1.attachInterrupt(callback); // attaches callback() as a timer overflow interrupt
}
void loop() {
uint8_t sound = Beets.SoundPot(A5);
Beets.beets(vol, sound,2);
sound = Beets.SoundPot(A4);
Beets.beets(vol, sound,8);
sound = Beets.SoundPot(A3);
Beets.beets(vol, sound,9);
sound = Beets.SoundPot(A2);
Beets.beets(vol, sound,10);
}
void callback()
{
uint8_t
pitch,
playSpeed;
int
inputSpeed,
inputPitch;
playSpeed = Beets.SpeedPot(A1);
inputSpeed = map(playSpeed,0,255,200,1000);
Serial.println(inputSpeed);
Beets.Speed(inputSpeed);
pitch = Beets.PitchPot(A0);
inputPitch = map(pitch,0,255,100,1000);
Beets.Pitch(inputPitch);
}