pctheory.util

factor(n)

Factors a positive integer

Parameters:

n – An integer

Returns:

A list of factors, in sorted order, including duplicates

lcm(integers)

Computes the LCM of a list of positive integers

Parameters:

integers – A list of positive integers

Returns:

The LCM

map_to_chromatic(scale_map, sequence)

Maps one sequence of items to another sequence of items. This is useful for doing things like mapping scale degrees 0-6 to actual chromatic pitches. You only need to provide a map for one octave, and all transpositions will be accounted for.

Parameters:
  • scale_map – The scale map

  • sequence – The sequence to map

Returns:

The mapped sequence

norgard(n: int)

Generates the first n numbers of OEIS A004718 (Per Nørgård’s infinity series)

Parameters:

n – The number of terms to compute

Returns:

The series