Minor fixes.

This commit is contained in:
Jonathan Chan 2018-03-22 18:04:52 -07:00
parent 3b39f9a455
commit ec7bd45097
1 changed files with 9 additions and 4 deletions

View File

@ -29,7 +29,7 @@
#define DUTY 250
#define DELAY 1000 // input sample delay in microseconds
#define MAXNOTES 64 // record at most 64 notes (arbitrary)
#define MAXNOTES 0x40 // record at most 64 notes (arbitrary)
// max length of note is 0xFFFF centiseconds = approx. 10 minutes
unsigned int rec[MAXNOTES]; // notes recorded
@ -41,7 +41,7 @@ volatile unsigned int us = 0;
volatile unsigned int cs = 0;
unsigned int scale[16] = {
c, dflat, d, eflat, e, f, gflat, g, aflat, a, bflat, b, cc, c, dflat, eflat
n, c, dflat, d, eflat, e, f, gflat, g, aflat, a, bflat, b, cc, n, n
};
unsigned int whole[8] = {
@ -49,8 +49,13 @@ unsigned int whole[8] = {
};
void play(unsigned int note) {
if (note != n) {
CCR0 = note;
CCR1 = note == n ? 0 : DUTY;
CCR1 = DUTY;
} else {
CCR0 = 0xFFFF; // cannot count to 0; set to max
CCR1 = 0;
}
}
void playback() {