# Changelog

## Releases

### 3.1.2

- Add trigger start handling
- fixe some limits on acqusition process (usb and source queues timeout)

### 3.1.0-1 (In Progress) Major Refactoring - Breaking Changes

This is a major architectural overhaul of the Megamicros library implementing modern Python patterns and improved modularity.

#### Architecture Changes

**New Multi-Source Architecture:**

- Created `sources/` module with pluggable data source system
- `DataSource` protocol defining unified interface
- Four concrete implementations:
  - `UsbDataSource`: Physical USB hardware (Mu32, Mu256, Mu1024)
  - `H5DataSource`: HDF5 file playback (MuH5 format) - not yet available
  - `RandomDataSource`: Random signal generator (testing/development)
  - `WebSocketDataSource`: Remote devices over WebSocket (🚧 under development)

**Configuration System:**

- New `core/config.py` with type-safe dataclasses:
  - `AcquisitionConfig`: All acquisition parameters in one object
  - `UsbConfig`: USB device configuration
  - `MemsArrayInfo`: Array geometry and metadata
- Replaces scattered instance variables with structured configs

**Refactored Megamicros Class:**

- Now a facade/factory over data sources
- Automatic source selection:
  - `Megamicros(filepath='data.h5')` → H5DataSource
  - `Megamicros(url='ws://...')` → WebSocketDataSource
  - `Megamicros(usb=True)` → UsbDataSource
  - `Megamicros()` → Auto-detect or fallback to Random
- Fully backward compatible with v3.x API
- Supports explicit source injection for testing

#### Packaging Improvements

- Updated `pyproject.toml` with modern practices:
  - Minimum Python 3.9 (was 3.7)
  - Version constraints on dependencies
  - Optional dependencies: `dev`, `websocket`, `simulation`
  - Better classifiers and keywords
- Removed unnecessary `cmake_build_extension` dependency

#### Goals

- [x] Improve code modularity with pluggable data sources
- [x] Enhance type safety with dataclasses and protocols
- [x] Streamline API (backward compatible)
- [x] Enable easy testing without hardware (RandomDataSource)
- [x] Better separation of concerns between layers
- [ ] Add comprehensive test suite (pytest)
- [ ] Add type checking (mypy)
- [ ] Complete WebSocketDataSource implementation

#### Breaking Changes

None yet - v3.1.0 maintains full backward compatibility with v3.x API

#### New Features

- **Multi-source architecture**: Use same API for USB, H5, WebSocket, or Random
- **Random data generator**: Test without hardware
- **Configuration objects**: Type-safe, validated configs
- **Protocol-based design**: Easy to add new data sources
- **Better error messages**: Explicit exceptions for each source type

#### Migration Guide (when upgrading from 3.x)

The v3.x API still works:

```python  
# v3.x code works unchanged
antenna = Megamicros()
antenna.run(mems=[0,1,2,3], sampling_frequency=50000)
for frame in antenna:
    process(frame)
antenna.wait()
```

But v3.1 offers new patterns:

```python
# Explicit H5 playback
antenna = Megamicros(filepath='recording.h5')

# Testing without hardware
antenna = Megamicros()  # Auto-falls back to RandomDataSource

# Using configuration objects
from megamicros import AcquisitionConfig
config = AcquisitionConfig(mems=[0,1,2,3], sampling_frequency=50000, duration=10)
antenna.run(**config.__dict__)
```

### 3.0.2-5

- Add Data classes for signal and video
- Define the default sensibility of analogs to 0.33 (see megaicros.core.mu)

### 3.0.1

- Add the sgcal diffuse antenna calibration of Charles Vanwynsberghe(see: [Charles Vanwynsberghe](https://github.com/cvanwynsberghe/sgcal-jasa).
- Add the `ParisParcGeoCalibDiffuse` Notebook as example of geocalibrating using `calibrate.py` and `covariancegpu.py` on the Sorbonne University Innovation City construction site (to be revized).

### 3.0.0

New major release

- Usb interface Refactoring

### 2.1.30-2.1.34

The next minor release (2.2) is comming soon.
The core of megamicros will not change but most of the tools will be reorganized

- Update the release making process
- Import mqtt and muh5 from the ol library megamicros_tools

### 2.1.29

- Minor updates on megamicros.mu

### 2.1.13-2.1.28

- Prepare the next major release
- Transform megamicros_tools package in megamicros.tools sub package
- Major updates in tools/acoustics/location.py
- Add BFE on limited frequency bandwith
- Add getBFE function in core/h5 to get BFE data from MµH5 files
- fix bug in tools/signal.py: `megamicros.exception` instead of `import exception`.

### 2.1.12

- Fix `get()` method error when getting signals from H5 file

### 2.1.11

- Fix the issue of H5 file bad recording

### 2.1.10

- Add system_type property to Mµ antenna systems

### 2.1.5 - 2.1.9

- Fix compatibility problems with libusb (Zadig) under windows

### 2.1.3 - 2.1.4

- Add the `megamicros` program

### 2.1.1 - 2.1.2

- Minor modifications

### 2.1.0

- Remove the aidb application from the package in favor of the megamicros-aidb new package
- Remove the aiboard application from the package in favor of the megamicros-aiboard new package
- megamicros-tools becomes a dependency of megamicros
- Remove log, mqtt, muh5, exception, previously moved in megamicros-tools
  - Please use in your code `from megamicros_tools.log import log` instead of `from megamicros.log import log`
  - Same with `exception`, `mqtt` and `muh5`.

### 2.0.75

- Remove docs form this repository. Documentation is now available on its on repository (megamicros-doc)

### 2.0.74

- Add 'real_time' option in MesmArrayH5 for playing H5 files
- There is still a bug to fix wen 'real_time=True': the delay which is imposed for real time respect leads to problem in the queue management

### 2.0.72 to 2.0.73

- Add download of H5 files as wav files du dbAi

### 2.0.71

- Add the megamicros base library for Megamicros device monitoring

### 2.0.70

- Fix bug in dataset concerning bad reshape when samples are shorter than split size

### 2.0.56 to 2.0.69

- Update aidb dataset by adding instance storing
- Update aiboard to work fine with the nexw dataset

### 2.0.55

- fix the download error in dataset samples duration

### 2.0.54

- update http address for aiboard

### 2.0.53

- ailab/sataset updated for data split and temporal zero padding

### 2.0.48, 2.0.49, 2.0.50, 2.0.51, 2.0.51, 2.0.52

- New Dataset view and serializer for AiDB

### 2.0.47

### 2.0.46

- Fix dataset error for entry removing in AiDB

### 2.0.45

- Fix error made by the default limit=20 for label downloading

### 2.0.44

- Create torch dataset for AiDB signals

### 2.0.43

- Add dbchantier database to megamicros-aiboard program configuration

### 2.0.42

- Compute power in decibels  on database signals

### 2.0.41

- Add the `fft` datatype for getting fft signals from the Megamicros broadcast server using the `run` method

### 2.0.40

- Add database endpoint for extracting samples (sourcefile/samples) and the library tools that comes with

### 2.0.39

- Add direct signal samples extraction from AI database

### 2.0.38

- Fix bug `TypeError: MemsArray.setAvailableAnalogs() got an unexpected keyword argument 'available_analogs_number'` in db.py

### 2.0.37

- Fix bug `TypeError: MemsArray.setAvailableMems() got an unexpected keyword argument 'available_mems_number'` in db.py

### 2.0.36

- Some updates

### 2.0.35

- Fix bug in H5 files reading

### 2.0.34

- Corrections in MemsArrayWS for using methods `settings()` and `selftest()` as *async* methods

### 2.0.33

### 2.0.32

- Before correcting DB_PROCESSING_DELAY_RATE issue, skip the realtime process

### 2.0.31

- Change the DB_PROCESSING_DELAY_RATE value needed for realtime simulation from 3/10 to 2/10
