Skip to content

Instantly share code, notes, and snippets.

@miccolis
Forked from anonymous/freq.c
Created January 5, 2013 23:32
Show Gist options
  • Save miccolis/4464309 to your computer and use it in GitHub Desktop.
Save miccolis/4464309 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdint.h>
int main() {
// B7, G7 & G#7 intentionally differ from the hex values in the data sheet
static int octave[12] = {0x892B, 0x9153, 0x99F7, 0xA31F, 0xACD2, 0xB719, 0xC1FC,
0xCD85, 0xD9BD, 0xE6B0, 0xF467, 0x102F0};
for (int i = 0; i < 95; i++) {
int note = octave[i % 12];
//printf("Note: %x\n", note);
//printf("Octave: %d\n", i / 12);
note = note >> (7 - (i / 12));
uint8_t freqLo = note & 0xFF;
uint8_t freqHi = note >> 8;
printf("Output: %d > %x %x\n", i, freqHi, freqLo);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment