| | |
| | | ;Authors: A. Nguyen, 2025. |
| | | ;Authors: |
| | | ; A. Nguyen, 2025 |
| | | ; M. Schumacher, 2025 |
| | | |
| | | ; Design limitations: |
| | | ; 1) Sounds must have identical sample rate; otherwise, SoX fails silently, literally. |
| | |
| | | |
| | | ; ### Ambisonics ### |
| | | |
| | | (defun sox-hoaencode-sn3d-factor (order degree) ; andere Nomenklatur, "degree" wäre besser "order" um Verwechslung mit Winkeln zu vermeiden |
| | | (defun sox-hoaencode-sn3d-factor (order degree) |
| | | "This is a placeholder for documentation" |
| | | (ecase order |
| | | (0 1) |
| | | (1 1) |
| | |
| | | ) |
| | | |
| | | (defun sox-hoaencode-azimuth-factor (degree theta_deg) |
| | | "This is a placeholder for documentation" |
| | | (let* |
| | | ( |
| | | (theta (sox-hoaencode-deg-to-rad theta_deg)) |
| | |
| | | ) |
| | | |
| | | (defun sox-hoaencode-elevation-factor (order degree phi_deg) |
| | | "This is a placeholder for documentation" |
| | | (let* |
| | | ( |
| | | (phi (sox-hoaencode-deg-to-rad phi_deg)) |
| | |
| | | |
| | | ; #### Utility functions #### |
| | | |
| | | #| |
| | | (defun sox-hoaencode-auto-convert-positions (positions) |
| | | "Ensures that positions are given as '((azimuth elevation) ...) (in degrees), i.e. |
| | | 1) if list of list of three values, input is assumed to be '(x y z) coordinates and will be transformed to '(azimuth elevation) coordinates (in the navigational spherical coordinate system). |
| | |
| | | (t (error "Positions must consist of lists of length 2 (ae) or 3 (xyz).")) |
| | | )) |
| | | (t (error "Positions must be of type 3dc or list.")))) |
| | | |
| | | |# |
| | | |
| | | |
| | | ; ####### High-level API ########## |
| | |
| | | |
| | | (defclass! sox-hoaencode (sox-input) |
| | | ( |
| | | (positions :accessor positions :initarg :positions :initform nil :documentation *sox-hoaencode-positions-doc*) |
| | | (order :accessor order :initarg :order :initform nil :documentation *sox-hoaencode-order-doc*) |
| | | (gain :accessor gain :initarg :gain :initform 0 :documentation "gain value in dB (decibel)") |
| | | (azimuth :accessor azimuth :initarg :azimuth :initform 0 :documentation "azimuth angle in degrees") |
| | | (elevation :accessor elevation :initarg :elevation :initform 0 :documentation "elevation angle in degrees") |
| | | (order :accessor order :initarg :order :initform 3 :documentation *sox-hoaencode-order-doc*) |
| | | ) |
| | | (:icon 100) |
| | | (:documentation "Sox-hoaencode transforms <sound> into a <order>-th ambisonic (HOA) signal at <positions>. |
| | | (:documentation "Sox-hoaencode encodes <sound> into a <order>-th ambisonic (HOA) signal at <positions>. |
| | | |
| | | The signal follows the ambiX convention, i.e. it uses SN3D normalization and ACN channel ordering. The resulting file has (<order>+1)^2 channels (order 0: 1 channel, order 1: 4 channels, order 2: 9 channels, order 3: 16 channels, ...).") |
| | | ) |
| | |
| | | (defmethod initialize-instance :after ((self sox-hoaencode) &rest l) |
| | | (declare (ignore l)) |
| | | (when (sound self) |
| | | (sox-init-sound self 'list) |
| | | (sox-init-sound self 'atom) |
| | | ) |
| | | ) |
| | | |