Module util

Utility module

Functions

dbamp (db) db to amp.
time () get system time in s+us.
scandir (directory) scan directory, return file list.
file_exists (name) check if file exists.
make_dir (path) make directory (with parents as needed).
os_capture (cmd, raw) execute os command, capture output.
string_starts (s, start) string begins with.
trim_string_to_width (s, width) trim string to a display width
clamp (n, min, max) clamp values to min max.
linexp (slo, shi, dlo, dhi, f) convert a linear range to an exponential range
linlin (slo, shi, dlo, dhi, f) map a linear range to another linear range.
explin (slo, shi, dlo, dhi, f) convert an exponential range to a linear range.
expexp (slo, shi, dlo, dhi, f) map an exponential range to another exponential range.
round (number, quant) round to a multiple of a number
round_up (number, quant) round up to a multiple of a number.
s_to_hms (s) format string, seconds to h:m:s.


Functions

dbamp (db)
db to amp.

Parameters:

  • db number

Returns:

    number amp
time ()
get system time in s+us.

Returns:

    time
scandir (directory)
scan directory, return file list.

Parameters:

  • directory string path to directory

Returns:

    table
file_exists (name)
check if file exists.

Parameters:

Returns:

    boolean true/false
make_dir (path)
make directory (with parents as needed).

Parameters:

os_capture (cmd, raw)
execute os command, capture output.

Parameters:

  • cmd string command
  • raw raw output (omit for scrubbed)

Returns:

    output
string_starts (s, start)
string begins with.

Parameters:

  • s string string to examine
  • start string string to search for

Returns:

    boolean true or false
trim_string_to_width (s, width)
trim string to a display width

Parameters:

  • s string string to trim
  • width number maximum width

Returns:

    string trimmed string
clamp (n, min, max)
clamp values to min max.

Parameters:

  • n number value
  • min number minimum
  • max number maximum

Returns:

    number clamped value
linexp (slo, shi, dlo, dhi, f)
convert a linear range to an exponential range

Parameters:

  • slo number lower limit of input range
  • shi number upper limit of input range
  • dlo number lower limit of output range (must be non-zero and of the same sign as dhi)
  • dhi number upper limit of output range (must be non-zero and of the same sign as dlo)
  • f number input to convert

Returns:

    number
linlin (slo, shi, dlo, dhi, f)
map a linear range to another linear range.

Parameters:

  • slo number lower limit of input range
  • shi number upper limit of input range
  • dlo number lower limit of output range
  • dhi number upper limit of output range
  • f number input to convert

Returns:

    number
explin (slo, shi, dlo, dhi, f)
convert an exponential range to a linear range.

Parameters:

  • slo number lower limit of input range (must be non-zero and of the same sign as shi)
  • shi number upper limit of input range (must be non-zero and of the same sign as slo)
  • dlo number lower limit of output range
  • dhi number upper limit of output range
  • f number input to convert

Returns:

    number
expexp (slo, shi, dlo, dhi, f)
map an exponential range to another exponential range.

Parameters:

  • slo number lower limit of input range (must be non-zero and of the same sign as shi)
  • shi number upper limit of input range (must be non-zero and of the same sign as slo)
  • dlo number lower limit of output range (must be non-zero and of the same sign as dhi)
  • dhi number upper limit of output range (must be non-zero and of the same sign as dlo)
  • f number input to convert

Returns:

    number
round (number, quant)
round to a multiple of a number

Parameters:

  • number number to round
  • quant number precision to round to
round_up (number, quant)
round up to a multiple of a number.

Parameters:

  • number number to round
  • quant number precision to round to
s_to_hms (s)
format string, seconds to h:m:s.

Parameters:

  • s number seconds

Returns:

    string seconds : seconds in h:m:s
generated by LDoc 1.4.6 Last updated 2020-03-28 23:45:19