data_to_pitch

astronify.utils.data_to_pitch(data_array, pitch_range=[100, 10000], center_pitch=440, zero_point='median', stretch='linear', minmax_percent=None, minmax_value=None, invert=False)[source]

Map data array to audible pitches in the given range, and apply stretch and scaling as required.

Parameters
data_arrayarray-like

Data to map to pitch values. Individual data values should be floats.

pitch_rangearray

Optional, default [100,10000]. Range of acceptable pitches in Hz.

center_pitchfloat

Optional, default 440. The pitch in Hz where that the the zero point of the data will be mapped to.

zero_pointstr or float

Optional, default “median”. The data value that will be mapped to the center pitch. Options are mean, median, or a specified data value (float).

stretchstr

Optional, default ‘linear’. The stretch to apply to the data array. Valid values are: asinh, sinh, sqrt, log, linear

minmax_percentarray

Optional. Interval based on a keeping a specified fraction of data values (can be asymmetric) when scaling the data. The format is [lower percentile, upper percentile], where data values below the lower percentile and above the upper percentile are clipped. Only one of minmax_percent and minmax_value should be specified.

minmax_valuearray

Optional. Interval based on user-specified data values when scaling the data array. The format is [min value, max value], where data values below the min value and above the max value are clipped. Only one of minmax_percent and minmax_value should be specified.

invertbool

Optional, default False. If True the pitch array is inverted (low pitches become high and vice versa).

Returns
responsearray

The normalized data array, with values in given pitch range.