Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.4.4 - Sound and Timing #147

Merged
merged 57 commits into from Feb 3, 2022
Merged

v0.4.4 - Sound and Timing #147

merged 57 commits into from Feb 3, 2022

Conversation

sneakers-the-rat
Copy link
Contributor

@sneakers-the-rat sneakers-the-rat commented Feb 2, 2022

Several parts to this update!

  • See Jackd triggers #146 for details about improvements to jackd sound timing! In short:
  • Changed the way that continuous sounds work. Rather than cycling through an array, which was easy to drop, now pass a sound object that can generate its own samples on the fly using the hydration module.
  • More accurate timing of sound ending callbacks. Before, the event would be called immediately on buffering the sounds into the jack ports, but that was systematically too early. Instead, use jack timing methods to account for delay from blocksize and n_periods to wait_until a certain delay to set() the event. See _wait_for_end

Other stuff:

New

  • hydration module for creating and storing autopilot objects between processes and computers!
  • @Introspect made and added to sound classes. Will be moved to root class. Allows storing the parameters given on instantiation.
  • requires module for more explicit declarations of by-object dependencies to resolve lots of the little fragile checks throughout the package, as well as make it easier for plugins :)
  • minor - added exceptions module, just stubs for now
  • Made dummy sound class to just use sounds without needing a running sound server
  • New transformations! The Prasad line fitting algorithm as Linefit_Prasad and ordering points in a line from, eg. edge detection in Order_Points

Improvements

  • Only warn once for returning a default pref value, and make its own warning class so that it can be filtered.
  • Cleaning up the base sound classes and moved them to their own module because sounds was very cumbersome and hard to reason about. Now use get_sound_class instead of declaring within the module.
  • Made optional install packages as extras_require so now can install with pip install auto-pi-lot -E pilot rather than autodetecting based on architecture. Further improvements (moving to poetry) will be in v0.5.0

Bugfixes

  • Correctly identify filenames in logging, before the last module name was treated as a suffix on the path and removed, and so only the most recent logger created would actually log to disk. Logging now works across threads and processes.
  • Fall back to a non-multiprocessing-based prefs if for some reason we can't use a mp.Manager in the given context (eg. ipython) - Still need to figure out a way to not print the exception because it is thrown asynchronously.
  • as much as i love it, the splash screen being absent for whatever reason shouldn't crash the program.
  • Raise an exception when instantiating a picamera without having picamera installed, re: PiCamera instance variables #142
  • Raise ImportError when ffmpeg is not present and trying to use a videowriter class
  • Use a deque rather than an infinitely growing list to store GPIO events.

Docs

  • Documenting the scripts module a bit better.
  • Lots more docs on jack_server

# Conflicts:
#	autopilot/transform/geometry.py
[bugfix] make sure welcome_msg in manifest
[bugfix] initialize _fps to None in camera metaclass
[bugfix] raise ImportErrors when picamera, ffmpeg can't be found instead of logging exceptions
[docs] add name and fps to PiCamera example in quickstart
# Conflicts:
#	autopilot/stim/sound/jackclient.py
# Conflicts:
#	autopilot/stim/sound/jackclient.py
#	autopilot/stim/sound/sounds.py
#	autopilot/tasks/task.py
…of autodetecting architectures which has bad downstream consequences
…of autodetecting architectures which has bad downstream consequences
…of autodetecting architectures which has bad downstream consequences
… to use filter before it is created in __init__, but it cant be created until the superclass __init__ methods finish.
[docs] documenting functionality of jack client a bit more within the class documentation
…enerate tables of sounds without needing a backend, and more...

[bugfix] logging names were adding in the sense of string contatenation rather than addition
[refactor] base sound classes were split into their own module, and a bit of tidying was done to better handle their dependency checks and etc. Instead of BASE_CLASS being defined within the sounds module itself, you now use get_sound_class() which should read from prefs and do the thing properly
[refactor] a dummy Sound class was made that will eventually be the parent class for all sounds (and then backend specific stuff will be added as a mixin. Currently the Sound class is not in the inheritance tree of the jack backend, but it will
[lateral enhancement] added some methods in sound generation to accomodate the dummy class
[logging] a few logging flags in the jack server
[enhancement] Requires module! Module for specifying object requirements. just a stub for now, but will be where we go with v0.5.0
[enhancement] types module for declaring common and basic types. will eventually be used for handling units. remains to be seen how we will make data carrying structures.
[partial bugfix] Added workarounds for prefs when multiprocessing fails, to use a dict instead of failing. Still needs some polish because of async exceptions, but better than before which would prevent import
# Conflicts:
#	autopilot/stim/sound/jackclient.py
#	autopilot/stim/sound/sounds.py
- check continuous queue every time, use it if updated
- abstractmethod for init_sound
- correct type hints on get_sound_class
- use write_to_outports if got no continuous sound in process method
remove __del__ calls
- adding exceptions module with default pref warning to make it easier to filter
- clean prefs fixture
it was the first ping that needed confirmation!
Jackd triggers

Improvements to sound timing and stability!!! The major change here is in the sound modules
- Changed the way that continuous sounds work. Rather than cycling through an array, which was easy to drop, now pass a sound object that can generate its own samples on the fly using the `hydration` module. 
- More accurate timing of sound ending callbacks. Before, the event would be called immediately on buffering the sounds into the jack ports, but that was systematically too early. Instead, use jack timing methods to account for delay from blocksize and n_periods to wait_until a certain delay to `set()` the event. See `_wait_for_end`

# New
- `hydration` module for creating and storing autopilot objects between processes and computers!
- `@Introspect` made and added to sound classes. Will be moved to root class. Allows storing the parameters given on instantiation.
- minor - added exceptions module

# Improvements
- Made `ALSA_NPERIODS` its own pref
- More debugging flags!
- Changed `repeat` to false by default in Nodes because it is largely unnecessary in normal use and causes a lot of overhead!
- Made a method to debug timing within the sound server, pass `debug_timing=True` to `jackclient`
- `Noise` now can generate noise continuously as a model for refactoring sound classes to do that as the main  way of doing so in the future.
- Incremental improvements to `requires` classes.

# Bugfixes
- Fixed several lists that would grow indefinitely and cause hard to diagnose memory issues, particularly with continuously operating things like the sound server or streaming data. Using a deque 
- `__del__` methods cause more problems than they solve, need to start moving towards registering signal handles explicitly rather than trying to clean up as a last resort when removing from memory. Removed from hardware and networking classes or at least wrapped in try blocks for now.
- use `str(Path)` rather than passing a `Path` instance to `pkgutil.iter_modules`
- use `importlib-metadata` for python3.7

# Deprecations
- Removed `jack_apt` because it only causes problems. `jackd_source` works every time and doesn't take that long.
-
@sneakers-the-rat sneakers-the-rat merged commit eb2b5c7 into main Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant