Skip to content

Instantly share code, notes, and snippets.

@jboone
Created March 3, 2014 16:59
Show Gist options
  • Save jboone/9329407 to your computer and use it in GitHub Desktop.
Save jboone/9329407 to your computer and use it in GitHub Desktop.
Quick and dirty Hellschreiber code for ToorCon San Diego 15's software defined radio workshop
#!/usr/bin/env python
import math
import numpy
import scipy.fftpack
import scipy.signal
letters = {
' ': [
" ",
" ",
" ",
" ",
" ",
],
'/': [
"* ",
" * ",
" * ",
" * ",
" *",
],
'C': [
"*****",
"* ",
"* ",
"* ",
"*****",
],
'E': [
"*****",
"* ",
"*** ",
"* ",
"*****",
],
'L': [
"* ",
"* ",
"* ",
"* ",
"*****",
],
'M': [
"*****",
"* * *",
"* * *",
"* * *",
"* * *",
],
'N': [
"*****",
"* *",
"* *",
"* *",
"* *",
],
'O': [
"*****",
"* *",
"* *",
"* *",
"*****",
],
'R': [
"*****",
"* *",
"*****",
"* * ",
"* *",
],
'T': [
"*****",
" * ",
" * ",
" * ",
" * ",
],
'W': [
"* *",
"* *",
"* * *",
"* * *",
"*****"
],
}
message = "/// WELCOME TO TOORCON "
image = []
for c in message:
image.extend(letters[c])
image.append(" ")
sampling_rate = 1e6
line_rate = 5
samples_per_line = sampling_rate / line_rate
samples_per_line = 1 << int(math.ceil(math.log(samples_per_line, 2)))
fft_width = samples_per_line
print('samples per line: %d' % samples_per_line)
char_width = 5
print(fft_width)
waveform_window = scipy.signal.blackman(fft_width)
bin_per_hz = float(fft_width) / sampling_rate
pixel_stride = int(5e3 * bin_per_hz)
pixel_width = 1
#bin_offset = int(100e3 * bin_per_hz)
bin_offset = 0
print('offset: %d' % bin_offset)
print('stride: %d' % pixel_stride)
waveforms = []
for line in image:
spectrum = numpy.zeros((fft_width,), dtype=numpy.complex64)
for n in range(len(line)):
pixel = 0 if line[n] == ' ' else 1
bin_start = bin_offset + n * pixel_stride
bin_end = bin_start + pixel_width
spectrum[bin_start:bin_end] = pixel
#spectrum = scipy.fftpack.ifftshift(spectrum)
waveform = scipy.fftpack.ifft(spectrum)
#waveform = scipy.fftpack.fftshift(waveform)
waveform *= (fft_width / char_width)
#waveform *= waveform_window
waveforms.append(waveform)
waveforms = numpy.concatenate(waveforms)
waveforms.tofile('banner_bb.c64')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment