Skip to content

Commit

Permalink
Attempt to resolve #12 the most of incompatibility issues fixed.
Browse files Browse the repository at this point in the history
The new issue created, the waterfall slides twice as fast as overlay.
  • Loading branch information
kaklik committed Apr 19, 2024
1 parent 14588a3 commit d35096b
Show file tree
Hide file tree
Showing 13 changed files with 208 additions and 47 deletions.
160 changes: 160 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
12 changes: 6 additions & 6 deletions detectors/noise_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def reduce(a, div=4, start=1, stop=3):

def coroutine():
def sleep(time):
for i in xrange(int(math.ceil(float(time) / row_duration))):
for i in range(int(math.ceil(float(time) / row_duration))):
yield

if len(args) != 5:
Expand All @@ -29,35 +29,35 @@ def sleep(time):
for i in sleep(2.0):
yield

freqs = xrange(int(args[2]), int(args[3]), int(args[4]))
freqs = range(int(args[2]), int(args[3]), int(args[4]))

nmeas_rows = int(math.ceil(float(1.0) / row_duration))
arr = np.zeros(nmeas_rows, dtype=np.float32)

with file(args[1], 'w') as outfile:
for freq in freqs:
fgen.recall_nvm()
print "resetting"
print("resetting")
for i in sleep(0.2):
yield

freq_mhz = float(freq) / 1000000
fgen.set_freq(10., freq_mhz * 2)
print "setting freq %f" % freq_mhz
print("setting freq %f" % freq_mhz)
for i in sleep(1.0):
yield

row, _s, _n = yield

emit_event("mlab.aabb_event.measurement_area", (row, row + nmeas_rows, 0, 4096, "%f MHz" % (freq_mhz,)))

for i in xrange(nmeas_rows):
for i in range(nmeas_rows):
_r, _s, noise_lvl = yield
arr[i] = noise_lvl

noise_lvl_sum = reduce(arr)

print "for freq %f, noise level is %f" % (freq_mhz, noise_lvl_sum)
print("for freq %f, noise level is %f" % (freq_mhz, noise_lvl_sum))
outfile.write("\t%f\t%f\n" % (freq_mhz, noise_lvl_sum))
outfile.flush()

Expand Down
8 changes: 4 additions & 4 deletions pysdr/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def screenshot(viewer):
Image.fromarray(image[::-1,:,:].copy()).save(time.strftime("screenshot_%Y%m%d%H%M%S.png",
time.gmtime()))
except Exception as e:
print e
print(e)

def textureshot(viewer):
prev_view = viewer.view
Expand Down Expand Up @@ -65,8 +65,8 @@ def textureshot(viewer):
view.scale_x, viewer.view.scale_y = float(resolution[0]) / 2, float(resolution[1])
view.origin_x = resolution[0] / 2

for x in xrange(viewer.multitexture.units_x):
for y in xrange(viewer.multitexture.units_y):
for x in range(viewer.multitexture.units_x):
for y in range(viewer.multitexture.units_y):
glClear(GL_COLOR_BUFFER_BIT)
glClearColor(0, 0, 0, 1)
glLoadIdentity()
Expand Down Expand Up @@ -98,7 +98,7 @@ def textureshot(viewer):
time.gmtime()))

except Exception as e:
print e
print(e)

viewer.view = prev_view
viewer.cb_reshape(prev_screen_size[0], prev_screen_size[1])
Expand Down
4 changes: 2 additions & 2 deletions pysdr/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def write(self, msg):
split[0] = self.lines.pop() + split[0]

self.lines += [s[x:x + self.columns_cutoff] for s in split for x \
in (range(0, len(s), self.columns_cutoff) if len(s) else [0])]
in (list(range(0, len(s), self.columns_cutoff)) if len(s) else [0])]

while len(self.lines) > self.lines_cutoff:
self.lines.pop(0)
Expand All @@ -95,7 +95,7 @@ def on_key_press(self, key):
return False

if key == '\r':
print self.prompt + self.last_line
print((self.prompt + self.last_line))
if self.push(self.last_line):
self.prompt = "... "
else:
Expand Down
18 changes: 9 additions & 9 deletions pysdr/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def on_event(self, event_id, payload):
if event_id.startswith('mlab.aabb_event.'):
event_mark = (event_id, (payload[0], payload[1]), (payload[2], payload[3]), payload[4])

for i in xrange(len(self.marks)):
for i in range(len(self.marks)):
mark = self.marks[i]
if (mark[0] == event_mark[0] and mark[1][0] == event_mark[1][0]
and event_mark[2] == event_mark[2]):
Expand Down Expand Up @@ -106,7 +106,7 @@ def draw_content(self):

class DetectorScript:
def script_api(func):
SCRIPT_API_METHODS[func.func_name] = func
SCRIPT_API_METHODS[func.__name__] = func

@script_api
def peak(self, a, b, s):
Expand Down Expand Up @@ -156,18 +156,18 @@ def __init__(self, viewer, listeners, args):
'row_duration': self.viewer.row_duration
}

for name, func in SCRIPT_API_METHODS.items():
for name, func in list(SCRIPT_API_METHODS.items()):
self.namespace[name] = func.__get__(self, DetectorScript)

execfile(self.filename, self.namespace)
exec(compile(open(self.filename, "rb").read(), self.filename, 'exec'), self.namespace)

def draw_screen(self):
for plot in self.plots.values():
for plot in list(self.plots.values()):
if hasattr(plot.__class__, 'draw_screen'):
plot.draw_screen()

def draw_content(self):
for plot in self.plots.values():
for plot in list(self.plots.values()):
if hasattr(plot.__class__, 'draw_content'):
plot.draw_content()

Expand All @@ -184,7 +184,7 @@ def call_script_pass(self, name, spectrum):
try:
self.namespace[name](self.viewer.process_row, spectrum)
except Exception:
print "exception in %s, disabling:" % self.filename
print("exception in %s, disabling:" % self.filename)
traceback.print_exc(file=sys.stdout)
self.disabled = True

Expand All @@ -211,6 +211,6 @@ def on_log_spectrum(self, spectrum):

[l.on_event(event_id, payload) for l in self.listeners]
except (ValueError, TypeError) as e:
print "failed to parse MIDI message '%s': %s" % (message[2:-1], e)
print("failed to parse MIDI message '%s': %s" % (message[2:-1], e))
else:
print "unknown MIDI message at frame %d: %s" % (frame, message.encode("hex"))
print("unknown MIDI message at frame %d: %s" % (frame, message.encode("hex")))
4 changes: 2 additions & 2 deletions pysdr/ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,12 @@ static PyObject *pysdr_jack_gather_midi_event(PyObject *self, PyObject *args)

PyObject *string;

if ((string = PyString_FromStringAndSize(NULL, size)) == 0) {
if ((string = PyBytes_FromStringAndSize(NULL, size)) == 0) {
jack_ringbuffer_read_advance(handle->midi_ringbuffer, size);
return NULL;
}

jack_ringbuffer_read(handle->midi_ringbuffer, PyString_AsString(string), size);
jack_ringbuffer_read(handle->midi_ringbuffer, PyUnicode_AsUTF8(string), size);

return Py_BuildValue("(KN)", time, string);
}
Expand Down
Loading

0 comments on commit d35096b

Please sign in to comment.