Kire Pudsje
2012-05-21 21:24:10 UTC
I wrote for myself an octave wrapper for all functions in the header
file of the rtl-sdr library. Even the async routine generates a
callback to octave functions. The whole is a 1-to-1 mapping of the
functions, I tried to stay as close as possible to the C-library.
I do not know if it just me using octave, but if there is any interest
in this code, I could place it somewhere.
sample code:
pkg load rtlsdr
if rtlsdr_get_device_count()>0
dev = rtlsdr_open(0);
samprate=2048e3;
nsamples=2048;
rtlsdr_set_sample_rate(dev, samprate);
rtlsdr_set_center_freq(dev, 100e6);
rtlsdr_set_tuner_gain_mode(dev, 0);
rtlsdr_reset_buffer(dev);
buf = rtlsdr_read_sync(dev, nsamples * 2);
d = (double(buf) - 128) / 128.0;
d = d(1:2:end) + 1i * d(2:2:end);
f = (-.5:1/nsamples:.5-1/nsamples) * samprate;
plot(f, 20*log10(abs(fftshift(fft(d .* blackman(nsamples)') / nsamples))));
rtlsdr_close(dev);
end
file of the rtl-sdr library. Even the async routine generates a
callback to octave functions. The whole is a 1-to-1 mapping of the
functions, I tried to stay as close as possible to the C-library.
I do not know if it just me using octave, but if there is any interest
in this code, I could place it somewhere.
sample code:
pkg load rtlsdr
if rtlsdr_get_device_count()>0
dev = rtlsdr_open(0);
samprate=2048e3;
nsamples=2048;
rtlsdr_set_sample_rate(dev, samprate);
rtlsdr_set_center_freq(dev, 100e6);
rtlsdr_set_tuner_gain_mode(dev, 0);
rtlsdr_reset_buffer(dev);
buf = rtlsdr_read_sync(dev, nsamples * 2);
d = (double(buf) - 128) / 128.0;
d = d(1:2:end) + 1i * d(2:2:end);
f = (-.5:1/nsamples:.5-1/nsamples) * samprate;
plot(f, 20*log10(abs(fftshift(fft(d .* blackman(nsamples)') / nsamples))));
rtlsdr_close(dev);
end