commit f606aac0d7dd8093528658c057084676b9fb82d7 Author: LongHairedHacker Date: Sat Feb 16 21:30:51 2019 +0100 Initial commit with all clutter diff --git a/demod.dat b/demod.dat new file mode 100644 index 0000000..eb79d3b Binary files /dev/null and b/demod.dat differ diff --git a/demod.py b/demod.py new file mode 100644 index 0000000..7d9901a --- /dev/null +++ b/demod.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python3 + +import scipy.io.wavfile +from matplotlib import pyplot as plt +import numpy as np +from scipy.signal import decimate, hilbert + +MIX_FREQ = 1200.0 + +def render_waterfall(rate, chuck_period, samples): + period = 1/rate + print("Period is %s" % (period, )) + + chunk_size = int(chuck_period / period) + chunk_count = int(len(samples) / chunk_size) + + print("Chunk size: %d samples" % chunk_size) + print("Chunk count: %d" % chunk_count) + + ffts = [] + for i in range(0, chunk_count): + fft = np.fft.rfft(samples[i * chunk_size: (i+1) * chunk_size]) + fft = np.abs(fft) + fft /= len(fft) + fft = 20 * np.log10(fft) + ffts +=[fft] + + freqs = np.fft.rfftfreq(chunk_size, period) + + plt.viridis() + fig = plt.figure() + ax = fig.add_subplot(111) + cax = ax.matshow(ffts, aspect='auto', extent=(freqs[0], freqs[-1], chunk_count, 0)) + fig.colorbar(cax) + + plt.show() + + + +def main(): + rate, data = scipy.io.wavfile.read("satnogs_29407_2019-01-31T17-11-29_short.wav") + + render_waterfall(rate, 10 * 10**-3, data) + + phase_acc = np.arange(0, len(data)) + mix_sig = np.cos(phase_acc * 2 * np.pi * MIX_FREQ/rate) + data = data * mix_sig + + data = decimate(data, 20) + data = data - np.average(data) + data = data / np.max(np.abs(data)) + + render_waterfall(rate/20, 100 * 10**-3, data) + + cmplx = hilbert(data) + + phase = np.angle(cmplx) / np.pi + + dphase = phase[:-1] - phase[1:] + + plt.plot(dphase) + plt.show() + + +if __name__ == '__main__': + main() diff --git a/demod.wav b/demod.wav new file mode 100644 index 0000000..82ba0e2 Binary files /dev/null and b/demod.wav differ diff --git a/deriv.py b/deriv.py new file mode 100644 index 0000000..85161f3 --- /dev/null +++ b/deriv.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +import scipy.io.wavfile +from matplotlib import pyplot as plt +import numpy as np + +def main(): + rate, data = scipy.io.wavfile.read("demod.wav") + + data = data - np.average(data) + data = data / np.max(np.abs(data)) + + deriv = np.abs(data[1:] - data[0:-1]) + + plt.plot(deriv) + plt.show() + + + + + +if __name__ == '__main__': + main() diff --git a/output.png b/output.png new file mode 100644 index 0000000..362fa1f Binary files /dev/null and b/output.png differ diff --git a/render.py b/render.py new file mode 100644 index 0000000..7497f20 --- /dev/null +++ b/render.py @@ -0,0 +1,130 @@ +#!/usr/bin/env python3 + +import matplotlib.pyplot as plt +import struct + +from PIL import Image + +IMG_WIDTH = 640 + +SYNC_LENGTH = 105 +SYNC_THRESH = 100 +PORCH_LENGTH = 10 + +LINE_LENGTH = SYNC_LENGTH + PORCH_LENGTH + 4 * IMG_WIDTH + +MAX_DEV = 600 +CENTER = 1750 +MIN_FREQ = 1200 +MAX_FREQ = 2300 + +COLOR_LOW = 1500 +COLOR_HIGH = MAX_FREQ + +def to_freq(sample): + freq = CENTER + sample * MAX_DEV + freq = max(MIN_FREQ, freq) + freq = min(MAX_FREQ, freq) + return freq + +def to_color(sample): + sample = (sample - 1500) / (COLOR_HIGH - COLOR_LOW) + sample = int(sample * 255) + sample = max(sample, 0) + sample = min(sample, 255) + return sample + +def ycbcr_to_rgb(y, cb, cr): + r = int(y + 1.402 * (cr - 128)) + g = int(y - 3.44136 * (cb - 128) - 0.714136 * (cr - 128)) + b = int(y + 1.772 * (cb - 128)) + return (r,g,b) + +last_sync = False +def is_sync(backlog): + global last_sync + count = 0 + for sample in backlog: + if sample < COLOR_LOW: + count += 1 + + res = False + if count > SYNC_THRESH and not last_sync: + res = True + + last_sync = count > SYNC_THRESH + return res + + +def render_lines(line): + pixels = [[(0,0,0)] * IMG_WIDTH, [(0,0,0)] * IMG_WIDTH] + + # Strip porch + porch = len(line) - SYNC_LENGTH - 4 * IMG_WIDTH + if porch < 0: + return pixels + line = line[PORCH_LENGTH:] + + for i in range(0, IMG_WIDTH): + y0 = to_color(line[i]) + cr = to_color(line[IMG_WIDTH + i]) + cb = to_color(line[2 * IMG_WIDTH + i]) + y1 = to_color(line[3 * IMG_WIDTH + i]) + + pixels[0][i] = y0, cb, cr + pixels[1][i] = y1, cb, cr + + return pixels + +def main(): + data_file = open("demod.dat", 'rb') + + samples = [] + syncs = [] + + pixels = [] + + backlog = [0.0] * SYNC_LENGTH + line = [] + + bytes = data_file.read(4) + while len(bytes) == 4: + sample = struct.unpack('f', bytes)[0] + sample = to_freq(sample) + samples += [sample] + + backlog = backlog[1:] + [sample] + + line += [sample] + + if is_sync(backlog) or len(line) > LINE_LENGTH: + if len(line) > SYNC_LENGTH + 4 * IMG_WIDTH: + syncs += [1000] + print("%d \t %d" % (len(line), len(line) - LINE_LENGTH)) + pixels += render_lines(line) + else: + print("Short line dropped") + line = [] + else: + syncs += [0] + + bytes = data_file.read(4) + + + plt.plot(samples) + plt.plot(syncs) + plt.show() + + img = Image.new('YCbCr', (IMG_WIDTH, len(pixels))) + img_pix = img.load() + for x in range(0, IMG_WIDTH): + for y in range(0, len(pixels)): + img_pix[x,y] = pixels[y][x] + + img = img.convert('RGB') + + img.save('output.png') + + +if __name__ == '__main__': + main() diff --git a/satnogs_29407_2019-01-31T17-11-29.ogg b/satnogs_29407_2019-01-31T17-11-29.ogg new file mode 100644 index 0000000..cf471c6 Binary files /dev/null and b/satnogs_29407_2019-01-31T17-11-29.ogg differ diff --git a/satnogs_29407_2019-01-31T17-11-29.wav b/satnogs_29407_2019-01-31T17-11-29.wav new file mode 100644 index 0000000..653776b Binary files /dev/null and b/satnogs_29407_2019-01-31T17-11-29.wav differ diff --git a/satnogs_29407_2019-01-31T17-11-29_short.wav b/satnogs_29407_2019-01-31T17-11-29_short.wav new file mode 100644 index 0000000..ce4b0df Binary files /dev/null and b/satnogs_29407_2019-01-31T17-11-29_short.wav differ diff --git a/satnogs_29412_2019-02-01T16-20-03_short.wav b/satnogs_29412_2019-02-01T16-20-03_short.wav new file mode 100644 index 0000000..4a4996f Binary files /dev/null and b/satnogs_29412_2019-02-01T16-20-03_short.wav differ diff --git a/setup_env.sh b/setup_env.sh new file mode 100644 index 0000000..6e3b49c --- /dev/null +++ b/setup_env.sh @@ -0,0 +1,2 @@ +export PYTHONPATH=/usr/local/lib/python2.7/site-packages/ +export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib/python2.7/site-packages/satnogs:/usr/local/lib/" diff --git a/sstv_decode.grc b/sstv_decode.grc new file mode 100644 index 0000000..8911f38 --- /dev/null +++ b/sstv_decode.grc @@ -0,0 +1,1463 @@ + + + + Fri Feb 8 18:51:01 2019 + + options + + author + + + + window_size + + + + category + [GRC Hier Blocks] + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + qt_gui + + + hier_block_src_path + .: + + + id + top_block + + + max_nouts + 0 + + + qt_qss_theme + + + + realtime_scheduling + + + + run_command + {python} -u {filename} + + + run_options + prompt + + + run + True + + + sizing_mode + fixed + + + thread_safe_setters + + + + title + + + + placement + (0,0) + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (7, 115) + + + _rotation + 0 + + + id + samp_rate + + + value + 48000 + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (7, 179) + + + _rotation + 0 + + + id + samp_rate_low + + + value + 4000 + + + + analog_sig_source_x + + amp + 1 + + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + freq + 1200 + + + _coordinate + (279, 91) + + + _rotation + 0 + + + id + analog_sig_source_x_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + offset + 0 + + + type + float + + + samp_rate + samp_rate + + + waveform + analog.GR_COS_WAVE + + + + blocks_multiply_xx + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (502, 239) + + + _rotation + 0 + + + id + blocks_multiply_xx_0 + + + type + float + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + num_inputs + 2 + + + vlen + 1 + + + + blocks_throttle + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (271, 267) + + + _rotation + 0 + + + id + blocks_throttle_0 + + + ignoretag + True + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samples_per_second + samp_rate + + + type + float + + + vlen + 1 + + + + blocks_wavfile_sink + + bits_per_sample + 8 + + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + file + /home/sebastian/projects/satnogs/sstv/demod.wav + + + _coordinate + (1092, 649) + + + _rotation + 0 + + + id + blocks_wavfile_sink_0 + + + nchan + 1 + + + samp_rate + samp_rate_low + + + + blocks_wavfile_source + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + file + /home/sebastian/projects/satnogs/sstv/satnogs_29407_2019-01-31T17-11-29_short.wav + + + _coordinate + (55, 259) + + + _rotation + 0 + + + id + blocks_wavfile_source_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + nchan + 1 + + + repeat + False + + + + fir_filter_xxx + + alias + + + + comment + + + + affinity + + + + decim + 1 + + + _enabled + True + + + _coordinate + (845, 562) + + + _rotation + 0 + + + id + fir_filter_xxx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samp_delay + 0 + + + taps + [1, -1] + + + type + fff + + + + low_pass_filter + + beta + 6.76 + + + alias + + + + comment + + + + affinity + + + + cutoff_freq + 1100 + + + decim + 12 + + + _enabled + True + + + type + fir_filter_fff + + + _coordinate + (342, 522) + + + _rotation + 0 + + + gain + 1 + + + id + low_pass_filter_0 + + + interp + 1 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samp_rate + samp_rate + + + width + 100 + + + win + firdes.WIN_HAMMING + + + + qtgui_time_sink_x + + autoscale + False + + + axislabels + True + + + alias + + + + comment + + + + ctrlpanel + False + + + affinity + + + + entags + True + + + _enabled + True + + + _coordinate + (1092, 554) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_time_sink_x_0 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + marker1 + -1 + + + style1 + 1 + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "blue" + + + label10 + + + + marker10 + -1 + + + style10 + 1 + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + marker2 + -1 + + + style2 + 1 + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "green" + + + label3 + + + + marker3 + -1 + + + style3 + 1 + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "black" + + + label4 + + + + marker4 + -1 + + + style4 + 1 + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "cyan" + + + label5 + + + + marker5 + -1 + + + style5 + 1 + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "magenta" + + + label6 + + + + marker6 + -1 + + + style6 + 1 + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "yellow" + + + label7 + + + + marker7 + -1 + + + style7 + 1 + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "dark red" + + + label8 + + + + marker8 + -1 + + + style8 + 1 + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "dark green" + + + label9 + + + + marker9 + -1 + + + style9 + 1 + + + width9 + 1 + + + name + "" + + + nconnections + 1 + + + size + 4096 + + + srate + samp_rate_low + + + stemplot + False + + + tr_chan + 0 + + + tr_delay + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_FREE + + + tr_slope + qtgui.TRIG_SLOPE_POS + + + tr_tag + "" + + + type + float + + + update_time + 0.01 + + + ylabel + Amplitude + + + yunit + "" + + + ymax + 1 + + + ymin + -1 + + + + qtgui_waterfall_sink_x + + axislabels + True + + + bw + samp_rate_low + + + alias + + + + fc + 0 + + + comment + + + + affinity + + + + _enabled + True + + + fftsize + 1024 + + + _coordinate + (598, 466) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_waterfall_sink_x_0 + + + int_max + 10 + + + int_min + -140 + + + legend + True + + + alpha1 + 1.0 + + + color1 + 3 + + + label1 + + + + alpha10 + 1.0 + + + color10 + 0 + + + label10 + + + + alpha2 + 1.0 + + + color2 + 0 + + + label2 + + + + alpha3 + 1.0 + + + color3 + 0 + + + label3 + + + + alpha4 + 1.0 + + + color4 + 0 + + + label4 + + + + alpha5 + 1.0 + + + color5 + 0 + + + label5 + + + + alpha6 + 1.0 + + + color6 + 0 + + + label6 + + + + alpha7 + 1.0 + + + color7 + 0 + + + label7 + + + + alpha8 + 1.0 + + + color8 + 0 + + + label8 + + + + alpha9 + 1.0 + + + color9 + 0 + + + label9 + + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + name + "" + + + nconnections + 1 + + + showports + True + + + freqhalf + False + + + type + float + + + update_time + 0.10 + + + wintype + firdes.WIN_BLACKMAN_hARRIS + + + + qtgui_waterfall_sink_x + + axislabels + True + + + bw + samp_rate_low + + + alias + + + + fc + 0 + + + comment + + + + affinity + + + + _enabled + True + + + fftsize + 1024 + + + _coordinate + (1092, 458) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_waterfall_sink_x_0_0 + + + int_max + 10 + + + int_min + -140 + + + legend + True + + + alpha1 + 1.0 + + + color1 + 3 + + + label1 + + + + alpha10 + 1.0 + + + color10 + 0 + + + label10 + + + + alpha2 + 1.0 + + + color2 + 0 + + + label2 + + + + alpha3 + 1.0 + + + color3 + 0 + + + label3 + + + + alpha4 + 1.0 + + + color4 + 0 + + + label4 + + + + alpha5 + 1.0 + + + color5 + 0 + + + label5 + + + + alpha6 + 1.0 + + + color6 + 0 + + + label6 + + + + alpha7 + 1.0 + + + color7 + 0 + + + label7 + + + + alpha8 + 1.0 + + + color8 + 0 + + + label8 + + + + alpha9 + 1.0 + + + color9 + 0 + + + label9 + + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + name + "" + + + nconnections + 1 + + + showports + True + + + freqhalf + False + + + type + float + + + update_time + 0.10 + + + wintype + firdes.WIN_BLACKMAN_hARRIS + + + + satnogs_quad_demod_filter_ff + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (598, 562) + + + _rotation + 0 + + + gain + 1.0 + + + id + satnogs_quad_demod_filter_ff_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + win + 40 + + + + analog_sig_source_x_0 + blocks_multiply_xx_0 + 0 + 0 + + + blocks_multiply_xx_0 + low_pass_filter_0 + 0 + 0 + + + blocks_throttle_0 + blocks_multiply_xx_0 + 0 + 1 + + + blocks_wavfile_source_0 + blocks_throttle_0 + 0 + 0 + + + fir_filter_xxx_0 + blocks_wavfile_sink_0 + 0 + 0 + + + fir_filter_xxx_0 + qtgui_time_sink_x_0 + 0 + 0 + + + fir_filter_xxx_0 + qtgui_waterfall_sink_x_0_0 + 0 + 0 + + + low_pass_filter_0 + qtgui_waterfall_sink_x_0 + 0 + 0 + + + low_pass_filter_0 + satnogs_quad_demod_filter_ff_0 + 0 + 0 + + + satnogs_quad_demod_filter_ff_0 + fir_filter_xxx_0 + 0 + 0 + + diff --git a/sstv_decode2.grc b/sstv_decode2.grc new file mode 100644 index 0000000..9119b0b --- /dev/null +++ b/sstv_decode2.grc @@ -0,0 +1,1448 @@ + + + + Fri Feb 8 18:51:01 2019 + + options + + author + + + + window_size + + + + category + [GRC Hier Blocks] + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (8, 8) + + + _rotation + 0 + + + generate_options + qt_gui + + + hier_block_src_path + .: + + + id + top_block + + + max_nouts + 0 + + + qt_qss_theme + + + + realtime_scheduling + + + + run_command + {python} -u {filename} + + + run_options + prompt + + + run + True + + + sizing_mode + fixed + + + thread_safe_setters + + + + title + + + + placement + (0,0) + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (7, 115) + + + _rotation + 0 + + + id + samp_rate + + + value + 48000 + + + + analog_nbfm_rx + + audio_rate + samp_rate/4 + + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (979, 187) + + + _rotation + 0 + + + id + analog_nbfm_rx_0 + + + max_dev + 600 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + quad_rate + samp_rate/4 + + + tau + 75e-6 + + + + blocks_file_sink + + append + False + + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + file + demod.dat + + + _coordinate + (1011, 505) + + + _rotation + 0 + + + id + blocks_file_sink_0 + + + type + float + + + unbuffered + False + + + vlen + 1 + + + + blocks_throttle + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (270, 227) + + + _rotation + 0 + + + id + blocks_throttle_0 + + + ignoretag + True + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samples_per_second + samp_rate + + + type + float + + + vlen + 1 + + + + blocks_wavfile_source + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + file + /home/sebastian/projects/satnogs/sstv/satnogs_29412_2019-02-01T16-20-03_short.wav + + + _coordinate + (23, 219) + + + _rotation + 0 + + + id + blocks_wavfile_source_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + nchan + 1 + + + repeat + False + + + + freq_xlating_fir_filter_xxx + + alias + + + + center_freq + 1750 + + + comment + + + + affinity + + + + decim + 4 + + + _enabled + True + + + _coordinate + (661, 219) + + + _rotation + 0 + + + id + freq_xlating_fir_filter_xxx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samp_rate + samp_rate + + + taps + 127 + + + type + ccc + + + + hilbert_fc + + beta + 6.76 + + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (470, 227) + + + _rotation + 0 + + + id + hilbert_fc_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + num_taps + 65 + + + win + firdes.WIN_HAMMING + + + + low_pass_filter + + beta + 6.76 + + + alias + + + + comment + + + + affinity + + + + cutoff_freq + 1000 + + + decim + 1 + + + _enabled + True + + + type + fir_filter_fff + + + _coordinate + (549, 442) + + + _rotation + 0 + + + gain + 1 + + + id + low_pass_filter_0 + + + interp + 1 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + samp_rate + 12000 + + + width + 1000 + + + win + firdes.WIN_HAMMING + + + + qtgui_time_sink_x + + autoscale + False + + + axislabels + True + + + alias + + + + comment + + + + ctrlpanel + False + + + affinity + + + + entags + True + + + _enabled + True + + + _coordinate + (1011, 402) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_time_sink_x_0 + + + legend + True + + + alpha1 + 1.0 + + + color1 + "blue" + + + label1 + + + + marker1 + -1 + + + style1 + 1 + + + width1 + 1 + + + alpha10 + 1.0 + + + color10 + "blue" + + + label10 + + + + marker10 + -1 + + + style10 + 1 + + + width10 + 1 + + + alpha2 + 1.0 + + + color2 + "red" + + + label2 + + + + marker2 + -1 + + + style2 + 1 + + + width2 + 1 + + + alpha3 + 1.0 + + + color3 + "green" + + + label3 + + + + marker3 + -1 + + + style3 + 1 + + + width3 + 1 + + + alpha4 + 1.0 + + + color4 + "black" + + + label4 + + + + marker4 + -1 + + + style4 + 1 + + + width4 + 1 + + + alpha5 + 1.0 + + + color5 + "cyan" + + + label5 + + + + marker5 + -1 + + + style5 + 1 + + + width5 + 1 + + + alpha6 + 1.0 + + + color6 + "magenta" + + + label6 + + + + marker6 + -1 + + + style6 + 1 + + + width6 + 1 + + + alpha7 + 1.0 + + + color7 + "yellow" + + + label7 + + + + marker7 + -1 + + + style7 + 1 + + + width7 + 1 + + + alpha8 + 1.0 + + + color8 + "dark red" + + + label8 + + + + marker8 + -1 + + + style8 + 1 + + + width8 + 1 + + + alpha9 + 1.0 + + + color9 + "dark green" + + + label9 + + + + marker9 + -1 + + + style9 + 1 + + + width9 + 1 + + + name + "" + + + nconnections + 1 + + + size + 1024 + + + srate + 5263 + + + stemplot + False + + + tr_chan + 0 + + + tr_delay + 0 + + + tr_level + 0.0 + + + tr_mode + qtgui.TRIG_MODE_FREE + + + tr_slope + qtgui.TRIG_SLOPE_POS + + + tr_tag + "" + + + type + float + + + update_time + 0.10 + + + ylabel + Amplitude + + + yunit + "" + + + ymax + 3.2 + + + ymin + -3.2 + + + + qtgui_waterfall_sink_x + + axislabels + True + + + bw + samp_rate + + + alias + + + + fc + 0 + + + comment + + + + affinity + + + + _enabled + True + + + fftsize + 4096 + + + _coordinate + (597, 115) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_waterfall_sink_x_0 + + + int_max + 10 + + + int_min + -140 + + + legend + True + + + alpha1 + 1.0 + + + color1 + 0 + + + label1 + + + + alpha10 + 1.0 + + + color10 + 0 + + + label10 + + + + alpha2 + 1.0 + + + color2 + 0 + + + label2 + + + + alpha3 + 1.0 + + + color3 + 0 + + + label3 + + + + alpha4 + 1.0 + + + color4 + 0 + + + label4 + + + + alpha5 + 1.0 + + + color5 + 0 + + + label5 + + + + alpha6 + 1.0 + + + color6 + 0 + + + label6 + + + + alpha7 + 1.0 + + + color7 + 0 + + + label7 + + + + alpha8 + 1.0 + + + color8 + 0 + + + label8 + + + + alpha9 + 1.0 + + + color9 + 0 + + + label9 + + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + name + "" + + + nconnections + 1 + + + showports + True + + + freqhalf + True + + + type + complex + + + update_time + 0.10 + + + wintype + firdes.WIN_BLACKMAN_hARRIS + + + + qtgui_waterfall_sink_x + + axislabels + True + + + bw + 5263 + + + alias + + + + fc + 0 + + + comment + + + + affinity + + + + _enabled + True + + + fftsize + 4096 + + + _coordinate + (1011, 609) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_waterfall_sink_x_0_0 + + + int_max + 10 + + + int_min + -140 + + + legend + True + + + alpha1 + 1.0 + + + color1 + 0 + + + label1 + + + + alpha10 + 1.0 + + + color10 + 0 + + + label10 + + + + alpha2 + 1.0 + + + color2 + 0 + + + label2 + + + + alpha3 + 1.0 + + + color3 + 0 + + + label3 + + + + alpha4 + 1.0 + + + color4 + 0 + + + label4 + + + + alpha5 + 1.0 + + + color5 + 0 + + + label5 + + + + alpha6 + 1.0 + + + color6 + 0 + + + label6 + + + + alpha7 + 1.0 + + + color7 + 0 + + + label7 + + + + alpha8 + 1.0 + + + color8 + 0 + + + label8 + + + + alpha9 + 1.0 + + + color9 + 0 + + + label9 + + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + name + "" + + + nconnections + 1 + + + showports + True + + + freqhalf + True + + + type + float + + + update_time + 0.10 + + + wintype + firdes.WIN_BLACKMAN_hARRIS + + + + rational_resampler_xxx + + alias + + + + comment + + + + affinity + + + + decim + 12000 + + + _enabled + True + + + fbw + 0 + + + _coordinate + (732, 466) + + + _rotation + 0 + + + id + rational_resampler_xxx_0 + + + interp + 5263 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + taps + + + + type + fff + + + + analog_nbfm_rx_0 + low_pass_filter_0 + 0 + 0 + + + blocks_throttle_0 + hilbert_fc_0 + 0 + 0 + + + blocks_wavfile_source_0 + blocks_throttle_0 + 0 + 0 + + + freq_xlating_fir_filter_xxx_0 + analog_nbfm_rx_0 + 0 + 0 + + + hilbert_fc_0 + freq_xlating_fir_filter_xxx_0 + 0 + 0 + + + hilbert_fc_0 + qtgui_waterfall_sink_x_0 + 0 + 0 + + + low_pass_filter_0 + rational_resampler_xxx_0 + 0 + 0 + + + rational_resampler_xxx_0 + blocks_file_sink_0 + 0 + 0 + + + rational_resampler_xxx_0 + qtgui_time_sink_x_0 + 0 + 0 + + + rational_resampler_xxx_0 + qtgui_waterfall_sink_x_0_0 + 0 + 0 + + diff --git a/top_block.py b/top_block.py new file mode 100755 index 0000000..e81309c --- /dev/null +++ b/top_block.py @@ -0,0 +1,260 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +################################################## +# GNU Radio Python Flow Graph +# Title: Top Block +# Generated: Sat Feb 16 20:51:50 2019 +################################################## + +if __name__ == '__main__': + import ctypes + import sys + if sys.platform.startswith('linux'): + try: + x11 = ctypes.cdll.LoadLibrary('libX11.so') + x11.XInitThreads() + except: + print "Warning: failed to XInitThreads()" + +from PyQt4 import Qt +from gnuradio import analog +from gnuradio import blocks +from gnuradio import eng_notation +from gnuradio import filter +from gnuradio import gr +from gnuradio import qtgui +from gnuradio.eng_option import eng_option +from gnuradio.filter import firdes +from optparse import OptionParser +import sip +import sys +from gnuradio import qtgui + + +class top_block(gr.top_block, Qt.QWidget): + + def __init__(self): + gr.top_block.__init__(self, "Top Block") + Qt.QWidget.__init__(self) + self.setWindowTitle("Top Block") + qtgui.util.check_set_qss() + try: + self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) + except: + pass + self.top_scroll_layout = Qt.QVBoxLayout() + self.setLayout(self.top_scroll_layout) + self.top_scroll = Qt.QScrollArea() + self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) + self.top_scroll_layout.addWidget(self.top_scroll) + self.top_scroll.setWidgetResizable(True) + self.top_widget = Qt.QWidget() + self.top_scroll.setWidget(self.top_widget) + self.top_layout = Qt.QVBoxLayout(self.top_widget) + self.top_grid_layout = Qt.QGridLayout() + self.top_layout.addLayout(self.top_grid_layout) + + self.settings = Qt.QSettings("GNU Radio", "top_block") + self.restoreGeometry(self.settings.value("geometry").toByteArray()) + + + ################################################## + # Variables + ################################################## + self.samp_rate = samp_rate = 48000 + + ################################################## + # Blocks + ################################################## + self.rational_resampler_xxx_0 = filter.rational_resampler_fff( + interpolation=5263, + decimation=12000, + taps=None, + fractional_bw=None, + ) + self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_f( + 4096, #size + firdes.WIN_BLACKMAN_hARRIS, #wintype + 0, #fc + 5263, #bw + "", #name + 1 #number of inputs + ) + self.qtgui_waterfall_sink_x_0_0.set_update_time(0.10) + self.qtgui_waterfall_sink_x_0_0.enable_grid(False) + self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True) + + if not True: + self.qtgui_waterfall_sink_x_0_0.disable_legend() + + if "float" == "float" or "float" == "msg_float": + self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True) + + labels = ['', '', '', '', '', + '', '', '', '', ''] + colors = [0, 0, 0, 0, 0, + 0, 0, 0, 0, 0] + alphas = [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0] + for i in xrange(1): + if len(labels[i]) == 0: + self.qtgui_waterfall_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) + else: + self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i]) + self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i]) + self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i]) + + self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-140, 10) + + self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget) + self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_win) + self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( + 4096, #size + firdes.WIN_BLACKMAN_hARRIS, #wintype + 0, #fc + samp_rate, #bw + "", #name + 1 #number of inputs + ) + self.qtgui_waterfall_sink_x_0.set_update_time(0.10) + self.qtgui_waterfall_sink_x_0.enable_grid(False) + self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) + + if not True: + self.qtgui_waterfall_sink_x_0.disable_legend() + + if "complex" == "float" or "complex" == "msg_float": + self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) + + labels = ['', '', '', '', '', + '', '', '', '', ''] + colors = [0, 0, 0, 0, 0, + 0, 0, 0, 0, 0] + alphas = [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0] + for i in xrange(1): + if len(labels[i]) == 0: + self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) + else: + self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) + self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) + self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) + + self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) + + self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) + self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) + self.qtgui_time_sink_x_0 = qtgui.time_sink_f( + 1024, #size + 5263, #samp_rate + "", #name + 1 #number of inputs + ) + self.qtgui_time_sink_x_0.set_update_time(0.10) + self.qtgui_time_sink_x_0.set_y_axis(-3.2, 3.2) + + self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") + + self.qtgui_time_sink_x_0.enable_tags(-1, True) + self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") + self.qtgui_time_sink_x_0.enable_autoscale(False) + self.qtgui_time_sink_x_0.enable_grid(False) + self.qtgui_time_sink_x_0.enable_axis_labels(True) + self.qtgui_time_sink_x_0.enable_control_panel(False) + self.qtgui_time_sink_x_0.enable_stem_plot(False) + + if not True: + self.qtgui_time_sink_x_0.disable_legend() + + labels = ['', '', '', '', '', + '', '', '', '', ''] + widths = [1, 1, 1, 1, 1, + 1, 1, 1, 1, 1] + colors = ["blue", "red", "green", "black", "cyan", + "magenta", "yellow", "dark red", "dark green", "blue"] + styles = [1, 1, 1, 1, 1, + 1, 1, 1, 1, 1] + markers = [-1, -1, -1, -1, -1, + -1, -1, -1, -1, -1] + alphas = [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0] + + for i in xrange(1): + if len(labels[i]) == 0: + self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) + else: + self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) + self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) + self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) + self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) + self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) + self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) + + self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) + self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) + self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass( + 1, 12000, 1000, 1000, firdes.WIN_HAMMING, 6.76)) + self.hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76) + self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(4, (127, ), 1750, samp_rate) + self.blocks_wavfile_source_0 = blocks.wavfile_source('/home/sebastian/projects/satnogs/sstv/satnogs_29412_2019-02-01T16-20-03_short.wav', False) + self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) + self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, 'demod.dat', False) + self.blocks_file_sink_0.set_unbuffered(False) + self.analog_nbfm_rx_0 = analog.nbfm_rx( + audio_rate=samp_rate/4, + quad_rate=samp_rate/4, + tau=75e-6, + max_dev=600, + ) + + + + ################################################## + # Connections + ################################################## + self.connect((self.analog_nbfm_rx_0, 0), (self.low_pass_filter_0, 0)) + self.connect((self.blocks_throttle_0, 0), (self.hilbert_fc_0, 0)) + self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_throttle_0, 0)) + self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_nbfm_rx_0, 0)) + self.connect((self.hilbert_fc_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) + self.connect((self.hilbert_fc_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) + self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0)) + self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_file_sink_0, 0)) + self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_time_sink_x_0, 0)) + self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0)) + + def closeEvent(self, event): + self.settings = Qt.QSettings("GNU Radio", "top_block") + self.settings.setValue("geometry", self.saveGeometry()) + event.accept() + + def get_samp_rate(self): + return self.samp_rate + + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + self.qtgui_waterfall_sink_x_0.set_frequency_range(0, self.samp_rate) + self.blocks_throttle_0.set_sample_rate(self.samp_rate) + + +def main(top_block_cls=top_block, options=None): + + from distutils.version import StrictVersion + if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"): + style = gr.prefs().get_string('qtgui', 'style', 'raster') + Qt.QApplication.setGraphicsSystem(style) + qapp = Qt.QApplication(sys.argv) + + tb = top_block_cls() + tb.start() + tb.show() + + def quitting(): + tb.stop() + tb.wait() + qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) + qapp.exec_() + + +if __name__ == '__main__': + main()