Skip to content

SGMUSIC

sgmusic.Section dataclass

Tempo Section

Source code in sgmusic/__init__.py
84
85
86
87
88
89
@dataclass
class Section:
    """Tempo Section"""

    tempo: Expr = Symbol("t")
    name: str = ""

sgmusic.ramp(start_tempo, end_tempo, total_beats, bound_beat, bottom_bound_beat=0)

This integral is equal to the timecode at the bound_beat.

Source code in sgmusic/__init__.py
48
49
50
51
52
53
54
55
56
def ramp(start_tempo, end_tempo, total_beats, bound_beat, bottom_bound_beat=0):
    """This integral is equal to the timecode at the bound_beat."""
    x = symbols("x")
    a = S(start_tempo)
    b = S(end_tempo)
    return Integral(
        1 / (a / 60 + (x / total_beats) * (b / 60 - a / 60)),
        (x, bottom_bound_beat, bound_beat),
    )

sgmusic.separatetempolist(combined_list)

See _demotempolist() for an example. This function can separate out a list which occassionally contains tuples.

Source code in sgmusic/__init__.py
69
70
71
72
73
74
75
76
77
78
79
80
81
def separatetempolist(combined_list: list) -> Iterable[tuple]:
    """
    See _demotempolist() for an example.
    This function can separate out a list which occassionally contains tuples.
    """

    def separate(item):
        if isinstance(item, Iterable) and not isinstance(item, (str, bytes)):
            return item
        else:
            return item, ""

    return zip(*(separate(i) for i in combined_list))