little FFT display

pull/5/head
Oona 2013-01-21 08:09:41 +02:00
rodzic 5372b4b97a
commit 6369f9cd5e
6 zmienionych plików z 30 dodań i 30 usunięć

Wyświetl plik

@ -132,7 +132,7 @@ void *Listen ();
void populateDeviceList ();
void readPcm (gint numsamples);
void saveCurrentPic();
void setVU (short int PcmValue, int WinIdx);
void setVU (double *Power, int FFTLen, int WinIdx);
void evt_AbortRx ();
void evt_changeDevices ();

42
gui.c
Wyświetl plik

@ -77,18 +77,19 @@ void createGUI() {
gtk_entry_set_text(GTK_ENTRY(gui.entry_picdir),g_key_file_get_string(config,"slowrx","rxdir",NULL));
}
setVU(0, 6);
//setVU(0, 6);
gtk_widget_show_all (gui.window_main);
}
// Draw signal level meters according to given values
void setVU (short int PcmValue, int WinIdx) {
void setVU (double *Power, int FFTLen, int WinIdx) {
int x,y;
int PWRdB;
guchar *pixelsPWR, *pixelsSNR, *pPWR, *pSNR;
unsigned int rowstridePWR,rowstrideSNR;
double logpow;
rowstridePWR = gdk_pixbuf_get_rowstride (pixbuf_PWR);
pixelsPWR = gdk_pixbuf_get_pixels (pixbuf_PWR);
@ -96,40 +97,37 @@ void setVU (short int PcmValue, int WinIdx) {
rowstrideSNR = gdk_pixbuf_get_rowstride (pixbuf_SNR);
pixelsSNR = gdk_pixbuf_get_pixels (pixbuf_SNR);
if (PcmValue == 0)
PWRdB = 0;
else
PWRdB = (int)round(10 * log10(pow(PcmValue/32767.0,2)));
for (y=0; y<20; y++) {
for (x=0; x<100; x++) {
pPWR = pixelsPWR + y * rowstridePWR + (99-x) * 3;
pSNR = pixelsSNR + y * rowstrideSNR + (99-x) * 3;
if (y > 1 && y < 18 && x % 2 == 0) {
if (y > 3 && y < 16 && (99-x) % 16 >3 && x % 2 == 0) {
if (PWRdB >= -0.0075*pow(x,2)-3) {
pPWR[0] = 0x89;
pPWR[1] = 0xfe;
pPWR[2] = 0xf4;
if ((5-WinIdx) >= (99-x)/16) {
pSNR[0] = 0x34;
pSNR[1] = 0xe4;
pSNR[2] = 0x84;
} else {
pPWR[0] = pPWR[1] = pPWR[2] = 0x80;
}
if ((6-WinIdx)/0.06 > 100-x) {
pSNR[0] = 0xef;
pSNR[1] = 0xe4;
pSNR[2] = 0x34;
} else {
pSNR[0] = pSNR[1] = pSNR[2] = 0x80;
pSNR[0] = pSNR[2] = 0x60;
pSNR[1] = 0x60;
}
} else {
pPWR[0] = pPWR[1] = pPWR[2] = 0x40;
pSNR[0] = pSNR[1] = pSNR[2] = 0x40;
}
logpow = log(2*Power[(int)((99-x)*60/44100.0 * FFTLen)]);
if (logpow > (19-y)/2.0) {
pPWR[1] = 0xaa;
pPWR[2] = 0xff;
pPWR[0] = 0x33;
} else {
pPWR[0] = pPWR[1] = pPWR[2] = 0;
}
}
}

Wyświetl plik

@ -136,7 +136,7 @@ void *Listen() {
if (Finished && gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gui.tog_slant))) {
// Fix slant
setVU(0,6);
//setVU(0,6);
gdk_threads_enter ();
gtk_statusbar_push (GTK_STATUSBAR(gui.statusbar), 0, "Calculating slant..." );
gtk_widget_set_sensitive (gui.grid_vu, FALSE);
@ -163,7 +163,7 @@ void *Listen() {
// Save PNG
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(gui.tog_save))) {
setVU(0,6);
//setVU(0,6);
/*ensure_dir_exists("rx-lum");
LumFile = fopen(lumfilename,"w");

Wyświetl plik

@ -752,7 +752,7 @@
<object class="GtkLabel" id="label10">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Power</property>
<property name="label" translatable="yes">FFT</property>
</object>
<packing>
<property name="left_attach">0</property>

Wyświetl plik

@ -403,7 +403,7 @@ gboolean GetVideo(guchar Mode, double Rate, int Skip, gboolean Redraw) {
} /* endif (SampleNum == PixelGrid[PixelIdx].Time) */
if (!Redraw && SampleNum % 8820 == 0) {
setVU(pcm.PeakVal, WinIdx);
setVU(Power, FFTLen, WinIdx);
pcm.PeakVal = 0;
}

8
vis.c
Wyświetl plik

@ -52,9 +52,11 @@ guchar GetVIS () {
// Find the bin with most power
MaxBin = 0;
for (i = GetBin(500, FFTLen); i <= GetBin(3300, FFTLen); i++) {
for (i = 0; i <= GetBin(6000, FFTLen); i++) {
Power[i] = pow(out[i], 2) + pow(out[FFTLen - i], 2);
if (MaxBin == 0 || Power[i] > Power[MaxBin]) MaxBin = i;
if ( (i >= GetBin(500,FFTLen) && i < GetBin(3300,FFTLen)) &&
(MaxBin == 0 || Power[i] > Power[MaxBin]))
MaxBin = i;
}
// Find the peak frequency by Gaussian interpolation
@ -156,7 +158,7 @@ guchar GetVIS () {
}
if (++ptr == 25) {
setVU(pcm.PeakVal, 6);
setVU(Power, 2048, 6);
pcm.PeakVal = 0;
ptr = 0;
}