convert_unit
Builtin index · Signal processing
convert_unit(s, unit)
Input: s, unit · Output: no output
What it is
Added in v0.2.4. Rescales the samples into another unit of the same physical quantity and moves the unit tag with them, so the two cannot disagree; a calibration's dB reference is re-expressed at the same time, which is why spl is unchanged by a conversion. Affine for temperatures. Refuses across physical quantities (V → Pa) naming both, and refuses a signal with no unit to convert *from*.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
convert_unit(s, unit) | s —a calibration's dB reference is re-expressed at the same time, which is why spl is unchanged by a conversion.unit —Rescales the samples into another unit of the same physical quantity and moves the unit tag with them, so the two cannot disagree. | not documented yet | Added in v0.2.4. Affine for temperatures. |
Examples
No documentation example calls this form yet. The Signal processing chapter is where one belongs.
How it works
convert_unit(s, "mV") / to_unit(s, "mV") -- rescale the SAMPLES into another unit of the same physical quantity and move the unit tag with them, so the two can never disagree. Refuses across families (V -> Pa) by naming both. That is the §1 "mismatched rates error, they never silently reinterpret" rule applied to the vertical axis: volts to pascals is a CALIBRATION, it needs a transducer sensitivity, and answering it with a scale factor would be inventing one.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.