+#else
+struct note {
+ char notename[16];
+ double freq;
+};
+static note notes[] = {
+ { "E-3", 110.0 * (3.0/4.0) },
+ { "A-3", 110.0 },
+ { "D-4", 110.0 * (4.0/3.0) },
+ { "G-4", 110.0 * (4.0/3.0)*(4.0/3.0) },
+ { "B-4", 440.0 * (3.0/4.0)*(3.0/4.0) },
+ { "E-5", 440.0 * (3.0/4.0) }
+};
+
+void print_spectrogram(double freq, double amp)
+{
+ double best_away = 999999999.9;
+ unsigned best_away_ind = 0;
+
+ for (unsigned i = 0; i < sizeof(notes)/sizeof(note); ++i) {
+ double half_notes_away = 12.0 * log2(freq / notes[i].freq);
+ if (fabs(half_notes_away) < fabs(best_away)) {
+ best_away = half_notes_away;
+ best_away_ind = i;
+ }
+ }
+
+ for (unsigned i = 0; i < sizeof(notes)/sizeof(note); ++i)
+ if (i == best_away_ind)
+ printf("#");
+ else
+ printf(".");
+
+ printf(" (%s %+.2f, %5.2fHz) [%5.2fdB] [", notes[best_away_ind].notename, best_away, freq, amp);
+
+ for (int i = -10; i <= 10; ++i) {
+ if (best_away >= (i-0.5) * 0.05 && best_away < (i+0.5) * 0.05) {
+ printf("#");
+ } else {
+ if (i == 0) {
+ printf("|");
+ } else {
+ printf("-");
+ }
+ }
+ }
+ printf("]\n");
+}
+#endif