Commit cc6823ca authored by Jenda's avatar Jenda

fix missing bits.h, updated makefile, docstrings, fft measurements

parent 2c34f38a
......@@ -500,7 +500,7 @@ class client():
print("Remote says: samplerate %i, center frequency: %ik, ppm: %i, gain: %s, fft size: %i"%(samplerate, frequency/1000, ppm, gain, fftw))
print(" samples per frame: %i, buffer length: %i frames, max FIR len: %i"%(packetlen, bufsize, maxtaps))
if self.info_callback:
self.info_callback(samplerate, frequency, ppm, gain, packetlen, fftw, bufsize, maxtaps)
self.info_callback(samplerate, frequency, ppm, gain, packetlen, fftw, bufsize, maxtaps) #FIXME
if self.xlater_callback:
self.xlaters_lock.acquire()
......@@ -577,14 +577,14 @@ class client():
def Xlater(self):
""" Structure to hold information about one running xlater
float rotate -- rotator in radians per sample
int decimation -- the ratio of sdr_samplerate/channel_samplerate
bool sql -- apply squelch to this channel
bool afc -- apply afc to this channel
rid -- local reference ID
thread -- feeder thread
data -- queue of channel data that are written to program stdin
sqlsave -- last frame in case of closed squelch, we use this to replay on frame on opening squelch
float rotate -- rotator in radians per sample
int decimation -- the ratio of sdr_samplerate/channel_samplerate
bool sql -- apply squelch to this channel
bool afc -- apply afc to this channel
int rid -- local reference ID
threading.Thread thread -- feeder thread
Queue.Queue data -- queue of channel data that are written to program stdin
string sqlsave -- last frame in case of closed squelch, we use this to replay on frame on opening squelch
"""
XlaterT = libutil.Struct("xlater", "rotate decimation sql afc rid thread data sqlsave")
return XlaterT(None, None, False, False, None, None, None, None)
......
......@@ -3,17 +3,17 @@ CFLAGS = -pedantic -pthread -std=gnu99 -Wall -lprotobuf-c -lm -lvolk -lfftw3f -O
.PHONY: clean
all: c2s.pb-c.h server
all: server
OTHINGS = xlate_worker.o server.o socket.o util.o client_parser.o metadata.o c2s.pb-c.o bits.o
c2s.pb-c.h:
c2s.pb-c.c:
protoc-c --c_out=. c2s.proto
%.o: %.c
$(CPP) $(CFLAGS) -c $< -o $@ $(INC)
server: $(OTHINGS)
server: c2s.pb-c.c $(OTHINGS)
$(CPP) $(CFLAGS) $(OTHINGS) -o server
clean:
......
#ifndef BITS_H
#define BITS_H
#include "bits.h"
#include <string.h>
#include <inttypes.h>
#if OUR_ENDIAN != TARGET_ENDIAN
void LE32(void *x) {
uint32_t i;
memcpy(&i, x, sizeof(i));
i = htobe32(i);
memcpy(x, &i, sizeof(i));
}
void LE16(void *x) {
uint16_t i;
memcpy(&i, x, sizeof(i));
i = htobe16(i);
memcpy(x, &i, sizeof(i));
}
#else
void LE32(void *x) {}
void LE16(void *x) {}
#endif
#endif
#ifndef BITS_H
#define BITS_H
#include <endian.h>
#define OUR_ENDIAN __BYTE_ORDER
#define TARGET_ENDIAN __LITTLE_ENDIAN
void LE32(void *x);
void LE16(void *x);
#endif
......@@ -80,6 +80,9 @@ void calc_spectrum(sdr_packet * pkt, int spp, int fftskip) {
/* Transform */
fftwf_execute(p);
/* FFTW computes DFT without scaling by 1/sqrt(N) */
float dftscale = 1/sqrtf(fftsize);
/* Read output */
float * fout = (float *) fftw_out;
for(int k = 0; k<fftsize; k++) {
......@@ -88,14 +91,15 @@ void calc_spectrum(sdr_packet * pkt, int spp, int fftskip) {
/* We are computing sum(log(hypot(i,q))).
* We can compute log(prod(hypot(i,q))) and save computationally intesive logarithms */
/* gah, numeriacally unstable!
/* gah, numerically unstable! probably can be implemented by splitting the float with
* frexp(3) and computing exponent separately...
if(j == 0) {
fftw_avg[k] = hypotf(v1, v2);
} else {
fftw_avg[k] *= hypotf(v1, v2);
}*/
fftw_avg[k] += logf(hypotf(v1, v2));
fftw_avg[k] += logf(hypotf(v1, v2) * dftscale);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment