Theory Background and Architecture / 理論背景とアーキテクチャ¶
This section explains the design philosophy, internal architecture, and theoretical background used in the Wandas library. このセクションでは、Wandasライブラリの設計思想、内部アーキテクチャ、およびライブラリで使用されている理論的背景について説明します。
Design Philosophy / 設計思想¶
Wandas is developed based on the following design principles: Wandasは以下の設計原則に基づいて開発されています:
- Intuitive API Design - Consistent interface that users can easily use. 直感的なAPI設計 - ユーザーが簡単に使える一貫性のあるインターフェース。
- Efficient Memory Usage - Memory-efficient implementation suitable for processing large-scale data. 効率的なメモリ使用 - 大規模データの処理に適したメモリ効率の良い実装。
- Extensibility - Expandable architecture that makes it easy to add new features and algorithms. 拡張性 - 新しい機能やアルゴリズムを追加しやすい拡張可能なアーキテクチャ。
Core Architecture / コアアーキテクチャ¶
Data Model / データモデル¶
The central data model of the Wandas library is structured around immutable frames: Wandasライブラリの中心となるデータモデルは、不変(Immutable)なフレームを中心に構成されています:
frames/
├── ChannelFrame (Time-domain signals / 時間領域信号)
├── SpectralFrame (Frequency-domain data / 周波数領域データ)
├── CepstralFrame (Quefrency-domain data / ケフレンシー領域データ)
├── SpectrogramFrame (Time-Frequency domain data / 時間-周波数領域データ)
└── CepstrogramFrame (Time-Quefrency domain data / 時間-ケフレンシー領域データ)
Responsibilities of each class: 各クラスの責任:
- ChannelFrame: Handles multi-channel time-domain waveform data. Manages axes, metadata, and lineage-derived operation history views. ChannelFrame: マルチチャンネルの時間領域波形データを扱います。軸、メタデータ、操作履歴を管理します。
- SpectralFrame: Handles frequency-domain data (e.g., FFT results). SpectralFrame: 周波数領域データ(FFT結果など)を扱います。
- SpectrogramFrame: Handles time-frequency domain data (e.g., STFT results). SpectrogramFrame: 時間-周波数領域データ(STFT結果など)を扱います。
- CepstralFrame: Handles one real cepstrum on a quefrency axis. CepstralFrame: ケフレンシー軸上の1つの実ケプストラムを扱います。
- CepstrogramFrame: Handles a real cepstrum evolving over STFT time frames. CepstrogramFrame: STFT時間フレームごとに変化する実ケプストラムを扱います。
Separation of Concerns / 関心の分離¶
- frames/: User-facing data structures. Responsible for orchestration and metadata management. frames/: ユーザー向けのデータ構造。オーケストレーションとメタデータ管理を担当します。
- processing/: Pure numerical logic (filters, spectral analysis, etc.). Frame methods delegate to these functions. processing/: 純粋な数値ロジック(フィルタ、スペクトル分析など)。フレームのメソッドはこれらの関数に処理を委譲します。
- io/: I/O helpers for WAV, WDF, CSV, etc. io/: WAV, WDF, CSVなどのI/Oヘルパー。
xarray-backed architecture / xarrayベースのアーキテクチャ¶
Wandas uses xarray internally as the labelled storage and frame-state layer while keeping Wandas as the waveform analysis API. In the current migration stage, xarray owns data, named dimensions, selected coordinates, and frame-level attrs. Wandas still owns validation, channel metadata objects, lineage-derived operation history view semantics, and operation execution.
Wandasは内部でxarrayをラベル付きストレージとフレーム状態の層として使い、波形解析APIとしての責務はWandasに残します。現在の移行段階では、xarrayがデータ、名前付き次元、選択された座標、フレーム単位の属性を担当し、Wandasが検証、チャンネルメタデータオブジェクト、操作履歴の意味づけ、操作の実行を担当します。
The storage record is in docs/design/2026-06-11-xarray-migration-consolidation.md;
the current state-update contract is in
docs/design/2026-07-21-immutable-frame-state-updates.md.
storage の設計記録は docs/design/2026-06-11-xarray-migration-consolidation.md、
現在の state 更新契約は docs/design/2026-07-21-immutable-frame-state-updates.md にあります。
Compatibility notes for this migration:
- Use
with_label(),with_metadata(), orwith_channel_extra()to return an annotation-updated Frame. Direct and nested mutation is unsupported; getters return detached snapshots. frame.channelsis a sequence-like xarray-backed metadata view, not alist. Userename_channels()for labels andwith_calibration()withChannelCalibration.with_factor(),with_unit(), orwith_ref()for physical-domain state.frame.channels.to_list()returns a list snapshot ofChannelMetadatavalue objects when list semantics are needed.
この移行に関する互換性メモ:
- annotation 更新には
with_label()、with_metadata()、またはwith_channel_extra()を使います。直接・nested mutation は非対応で、getter は分離された snapshot を返します。 frame.channelsはlistではなく xarray backed の sequence-like metadata view です。label はrename_channels()、physical-domain state はwith_calibration()とChannelCalibration.with_factor()、with_unit()、with_ref()で更新します。- list semantics が必要な場合は、
frame.channels.to_list()でChannelMetadatavalue object の list snapshot を取得できます。
Data Processing Flow / データ処理フロー¶
- Input Stage: Generate
ChannelFrameobjects from files usingiohelpers. 入力段階:ioヘルパーを使用してファイルからChannelFrameオブジェクトを生成します。 - Processing Stage: Apply processing such as filtering and resampling. Operations return new frame objects (immutability). 処理段階: フィルタリング、リサンプリングなどの処理を適用します。操作は新しいフレームオブジェクトを返します(不変性)。
- Analysis Stage: Analyze signal characteristics (spectrum, level, etc.). 分析段階: 信号の特性(スペクトル、レベル等)を分析します。
- Output Stage: Save processing results to files or visualize as graphs. 出力段階: 処理結果をファイルに保存またはグラフとして可視化します。
Implementation Details / 実装詳細¶
Pipeline Recipe Documentation / Pipeline Recipe ドキュメント¶
- Pipeline Recipe Design: representation and replay design.
- Pipeline Recipe Developer Guide: contributor-oriented overview, terms, extension checklist, and testing guidance.
- Scalability Contract: exact lazy/channel-wise scaling promises and limits.
- AudioOperation Execution: channel/time dependency classification and the channel-wise prototype boundary.
- Public API and Schema Stability: stable, experimental, optional, and serialization surfaces.
Memory Efficiency / メモリ効率¶
Wandas ensures memory efficiency for handling large audio data through the following methods: Wandasは大規模なオーディオデータを扱うために、以下の方法でメモリ効率を確保しています:
- Lazy Evaluation: A mechanism that delays calculations until needed (using Dask). 遅延評価: 必要になるまで計算を遅延させる仕組み(Daskを使用)。
- Dataset-first selection: Discover and filter many recordings before loading waveform samples. Dataset-first selection: 多数の収録を探索し、波形 sample の読み込み前に絞り込み。
WDF 0.4 writes internal chunks without precomputing the complete tensor. Users keep the
normal Frame workflow and obtain NumPy values through frame.data; xarray, Dask, and
storage chunk topology remain implementation details. See the
scalability contract for exact limits and the contributor
benchmark command.
Signal Processing Algorithms / 信号処理アルゴリズム¶
Wandas implements signal processing algorithms such as: Wandasは以下のような信号処理アルゴリズムを実装しています:
- Digital Filters: IIR/FIR filters such as Butterworth filters. デジタルフィルタ: バターワースフィルタなどのIIR/FIRフィルタ。
- Spectral Analysis: Frequency analysis based on Fast Fourier Transform (FFT). スペクトル分析: 高速フーリエ変換(FFT)に基づく周波数分析。
- Time-Frequency Analysis: Short-Time Fourier Transform (STFT), spectrograms. 時間-周波数分析: 短時間フーリエ変換(STFT)、スペクトログラム。
- Statistical Analysis: Calculation of signal characteristics such as RMS, peak values, crest factor. 統計的分析: RMS、ピーク値、クレストファクターなどの信号特性の計算。
Psychoacoustic Metrics / 心理音響メトリクス¶
Wandas provides psychoacoustic metrics for analyzing audio signals based on human perception. These metrics are calculated using standardized methods and the MoSQITo library.: Wandasは、人間の知覚に基づく音響信号を分析するための心理音響メトリクスを提供します。これらのメトリクスは、標準化された手法とMoSQIToライブラリを使用して計算されます。:
- Loudness Calculation / ラウドネス計算: Time-varying loudness calculation using Zwicker method according to ISO 532-1:2017. ISO 532-1:2017に準拠したZwicker法による時間変化するラウドネス計算。
- Sharpness Calculation / シャープネス計算: Sharpness calculation based on Aures method according to DIN 45692. DIN 45692に準拠したAures法によるシャープネス計算。
- Roughness Calculation / ラフネス計算: Roughness calculation using Daniel and Weber method. Daniel and Weber法によるラフネス計算。