Only in freq51/linux: read.me Only in freq51/source: .depend diff -ur freq51-orig/source/extern.h freq51/source/extern.h --- freq51-orig/source/extern.h Sun Mar 10 22:42:26 1996 +++ freq51/source/extern.h Thu Feb 20 05:03:40 1997 @@ -60,6 +60,8 @@ extern int display_peak; /* Flag for displaying the peak information */ extern int freeze; /* Flag for freeze-frame mode */ extern int barmode; /* Flag indicating bar display or line display */ +extern int display_notes; /* Flag indicating display of notes on/off */ +extern char *NoteName[]; /* Data for the FFT routines */ extern short *fftdata; /* Output data from the FFT routine */ Only in freq51/source: freq diff -ur freq51-orig/source/freq.c freq51/source/freq.c --- freq51-orig/source/freq.c Sun Mar 10 22:42:24 1996 +++ freq51/source/freq.c Thu Feb 20 17:00:10 1997 @@ -810,9 +810,30 @@ if(display_peak) { - char ach[20]; - sprintf(ach,"%7.1f",(double)SampleRate*peak_index/fftlen); - draw_bar(PKX,PKY-1,PKX+63,PKY+_font_height,0); + char ach[100]; + + if (display_notes) { + double frq, a; + int octave, step, dec; + + frq = (double)SampleRate*peak_index/fftlen; + if (frq == 0.0) { + octave=0; + step=3; /* C */ + dec=0; + } else { + a = log(frq/aFreq)/log(2); + octave = (int) floor(rint(12*a) / 12) + aOct; + step = (int) rint(12*a) % 12; + dec = (int) rint(10.0*(12.0*a-rint(12.0*a))); + if (step < 0) step += 12; + if (step > 2) octave++; /* start new octave at C */ + } + sprintf(ach,"%7.1f (%2d%2s%+2d)", + frq, octave, NoteName[step], dec); + } else /* !dispnotes */ + sprintf(ach,"%7.1f",(double)SampleRate*peak_index/fftlen); + draw_bar(PKX,PKY-1,PKX+163,PKY+_font_height,0); draw_text_left(PKX,PKY,ach); } if(freeze) /* Highlight the bin in freeze mode */ diff -ur freq51-orig/source/freq.h freq51/source/freq.h --- freq51-orig/source/freq.h Sun Mar 10 22:42:26 1996 +++ freq51/source/freq.h Fri Mar 14 21:27:22 1997 @@ -31,7 +31,7 @@ #endif /* Define the maximum buffer length. */ -#define MAX_LEN 2048 +#define MAX_LEN 16384 /* 2048 */ /* Maximum amount of temporal averaging allowed */ #define MAX_DECAY_COUNT 64 @@ -67,7 +67,7 @@ #define LVY 74 #define MGX 320 #define MGY 86 -#define PKX 550 +#define PKX 450 #define PKY 470 /* DOS values used here for VGA compatibility (1-6 not all supported) */ @@ -224,4 +224,5 @@ void init_mulaw_sc(void); #endif - +#define aFreq 440 /* Frequency for note A */ +#define aOct 1 /* Number of its Octave */ Only in freq51/source: freq.o Only in freq51/source: freq.static Only in freq51/source: gr_linux.o Only in freq51/source: makefile diff -ur freq51-orig/source/makefile.linux freq51/source/makefile.linux --- freq51-orig/source/makefile.linux Sun Mar 10 22:42:26 1996 +++ freq51/source/makefile.linux Thu Feb 20 04:21:02 1997 @@ -30,7 +30,7 @@ #DEBUG=-ggdb #PROF=-pg -static PROC=-m486 -OPT=-O2 -fpcc-struct-return $(PROC) +OPT=-O2 -fpcc-struct-return -fomit-frame-pointer -fno-strength-reduce $(PROC) FLAGS=-Wall INSTALL=install Only in freq51/source: passdata.o diff -ur freq51-orig/source/procinp.c freq51/source/procinp.c --- freq51-orig/source/procinp.c Sun Mar 10 22:42:26 1996 +++ freq51/source/procinp.c Sun Mar 9 23:28:05 1997 @@ -34,12 +34,16 @@ int help_mode=0; /* Flag indicating help mode 0 (off), 1, or 2 */ int bw_mode=0; /* Flag indicating a Black/White palette */ int freeze=0; /* Flag indicating a paused display */ +int display_notes=!0; /* Flag indicating display of notes on/off */ float freq_scalefactor=1.0; /* Scalefactor for increasing the horizonal scale */ float freq_base=0.0; /* Base frequency for the display */ int bin=0; /* Bin number for cursor display */ int mic_level=0; /* Storage for mic input mixer level (0-100) */ int ext_level=0; /* Storage for ext input mixer level (0-100) */ int int_level=0; /* Storage for int input mixer level (0-100) */ +char *NoteName[12] = { + "A ", "A#", "H ", "C ", "C#", "D ", "D#", "E ", "F ", "F#", "G ", "G#" +}; #ifdef DOS void cleanup_vga(void) @@ -168,7 +172,28 @@ db=-100; } - draw_bar(0,21,160,71,0); + draw_bar(0,9,160,71,0); + if (display_notes) { + double frq, a; + int octave, step, dec; + + frq = (double)bin*SampleRate/fftlen; + if (bin == 0) { + octave=0; + step=3; /* C */ + dec=0; + } else { + a = log(frq/aFreq)/log(2); + octave = (int) floor(rint(12*a) / 12) + aOct; + step = (int) rint(12*a) % 12; + dec = (int) rint(10.0*(12.0*a-rint(12.0*a))); + if (step < 0) step += 12; + if (step > 2) octave++; /* start new octave at C */ + } + sprintf(ach," (%2d%2s%+2d)", + octave, NoteName[step], dec); + draw_text_left(0,10,ach); + } sprintf(ach," Freq: %7.5g Hz ",(double)bin*SampleRate/fftlen); draw_text_left(0,22,ach); sprintf(ach," Amp: %7.5g ",amp); @@ -254,7 +279,7 @@ } else { - draw_bar(0,21,160,71,0); + draw_bar(0,9,160,71,0); draw_bar(WINDOW_LEFT-5,MGY-1,WINDOW_RIGHT+5,MGY+_font_height,0); reset_decay_buffers(); } @@ -326,7 +351,7 @@ draw_bar(WINDOW_LEFT-5,MGY-1,WINDOW_RIGHT+5,MGY+_font_height,0); draw_text_centered(MGX,MGY,"Use H,J,K,L to move, Enter to save to disk, Space to continue."); } - if(c=='J' || c=='j') /* Move the cursor one bin left */ + if(c=='J' || c=='j' || c==LEFT_ARROW) /* Move the cursor one bin left */ { double current; bin-=repetitions; @@ -346,7 +371,7 @@ } update_display(); } - else if(c=='K' || c=='k') /* Move the cursor one bin right */ + else if(c=='K' || c=='k' || c==RIGHT_ARROW) /* Move the cursor one bin right */ { double current; bin+=repetitions; @@ -1192,6 +1217,11 @@ sprintf(ach,"Gain of %d dB per octave (ref: %ld Hz)",gain,ref_freq); draw_text_centered(DGX,DGY,ach); } + } + else if(c=='N' || c=='n') /* Toggle display of notes */ + { + display_notes=!display_notes; + setup_xscale(); } else if(mixers) { Only in freq51/source: procinp.o Only in freq51/source: realfft.o Only in freq51/source: sc_linux.o Only in freq51/source: sc_mulaw.o diff -ur freq51-orig/source/setupsub.c freq51/source/setupsub.c --- freq51-orig/source/setupsub.c Sun Mar 10 22:42:26 1996 +++ freq51/source/setupsub.c Sun Mar 9 23:04:01 1997 @@ -999,7 +999,56 @@ draw_fontcolor(LABEL_COLOR); - if(logfreq==2) + if (display_notes) { + double freq; + int x, i; + + for (i=0; i<132; i++) { /* 132 halftones from a(-4) */ + freq = 13.75 * pow(2.0, i / 12.0); + if (logfreq==0) + x=floor((freq-freq_base) * 2*freq_scalefactor/SampleRate + *(double)(WINDOW_RIGHT-WINDOW_LEFT)+0.5)+WINDOW_LEFT; + else + x=floor(log(freq/SampleRate*fftlen)/log(fftlen/2) + *(double)(WINDOW_RIGHT-WINDOW_LEFT)+0.5)+WINDOW_LEFT; + if((x>=WINDOW_LEFT) && (x<=WINDOW_RIGHT)) { + int y=WINDOW_BOTTOM+3, l=5; + char c = 0; + + switch (i%12) { + case 3: + c='C'; + break; + case 5: + c='D'; + break; + case 7: + c='E'; + break; + case 10: + c='G'; + break; + case 0: + c='A'; + break; + case 8: + case 2: + break; /* just the longer line */ + default: + l=3; + break; + } + draw_line(x,y,x,y+l,BORDER_COLOR); + if (c) { + sprintf(text,"%c", c); + draw_text_vertical(x-_font_width/2,y+8,text); + } + } + else if (x>WINDOW_RIGHT) + break; + } + } + else if(logfreq==2) { /* Put up the equalizer band values */ @@ -1016,8 +1065,10 @@ sprintf(text,"%.0f",freq); draw_text_vertical(x-_font_width/2,y+6,text); } + else if (x>WINDOW_RIGHT) + break; } - } + } else { if(logfreq) Only in freq51/source: setupsub.o