Skip to content

scales

JustScale

This class implements arbitrary just intonation scales.

Source code in /opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/jintonic/scales.py
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
class JustScale:
    """This class implements arbitrary just intonation scales."""

    def __init__(self, tones: List[JustInterval]):
        """Initializes a JustScale.

        Parameters:
            tones: A list of intervals or an object containing a list of
                intervals (that implements the attribute intervals)

        Examples:
            >>> scale = JustScale([JustInterval(1, 1)])
            >>> scale.append(JustInterval(3, 2))
            >>> scale.append(JustInterval(2, 1))
            >>> scale
            JustScale([1/1, 3/2, 2/1])
        """
        self._tones = tones

    def append(self, tone: JustInterval):
        """Appends tones to the scale.

        Parameters:
            tone: A new tone

        Examples:
            >>> scale = JustScale([JustInterval(3, 2)])
            >>> scale.append(JustInterval(4, 3))
            >>> scale.tones
            [JustInterval(4, 3), JustInterval(3, 2)]
        """
        if not isinstance(tone, JustInterval):
            msg = "cannot append type {}. ".format(type(tone))
            msg += 'Expecting type "JustInterval"'
            raise ValueError(msg)
        self._tones.append(tone)

    def hertz(self, fundamental: float) -> List[float]:
        """Translates scale intervals to pitches in Hertz over a fundamental

        Note:
            Here, the fundamental is always 1/1 and is not to be mistaken with
            the first tone of the scale. If 1/1 is not part of the scale's
            tones, the fundamental will not be part of the scale.

        Parameters:
            fundamental: The scale's 0 degree (fundamental) pitch in Hertz.

        Returns:
            Scale pitches as Hertz
        """
        return [fundamental * tone for tone in self.tones]

    @property
    def tones(self) -> List[JustInterval]:
        """JustScale tones.

        Returns:
            Scale tones
        """
        return sorted(self._tones)

    @tones.setter
    def tones(self, values: List[JustInterval]):
        """Sets JustScale tones.

        Parameters:
            values: A list of tones
        """
        for tone in values:
            if not isinstance(tone, JustInterval):
                msg = "tones must be a list of JustIntervals. "
                msg += "Got '{}'".format(values)
                raise ValueError(msg)
        self._tones = values

    @property
    def intervals(self) -> List[JustInterval]:
        """JustScale intervals.

        Returns:
            Scale intervals

        Examples:
            >>> scale = JustScale([JustInterval(1, 1)])
            >>> scale.append(JustInterval(3, 2))
            >>> scale.append(JustInterval(2, 1))
            >>> scale.intervals
            [JustInterval(3, 2), JustInterval(4, 3)]
        """
        return [tone - self.tones[i - 1] for i, tone in enumerate(self.tones)][1:]

    @property
    def complement(self) -> JustScale:
        """JustScale complement

        Returns:
            The complement scale

        Examples:
            >>> scale = JustScale([JustInterval(1, 1)])
            >>> scale.append(JustInterval(3, 2))
            >>> scale.append(JustInterval(2, 1))
            >>> scale.complement
            JustScale([1/1, 4/3, 2/1])
        """
        tones = [tone.complement for tone in self.tones]
        return JustScale(tones)

    @property
    def prime_limit(self) -> int:
        """JustScale prime limit"""
        return max([tone.prime_limit for tone in self.tones])

    def __repr__(self):
        """repr(self)"""
        pitches = ", ".join(
            [
                "/".join([str(tone.numerator), str(tone.denominator)])
                for tone in self.tones
            ]
        )
        return "{}([{}])".format(self.__class__.__name__, pitches)

tones: List[JustInterval] writable property

JustScale tones.

Returns:

Type Description
List[JustInterval]

Scale tones

intervals: List[JustInterval] property

JustScale intervals.

Returns:

Type Description
List[JustInterval]

Scale intervals

Examples:

>>> scale = JustScale([JustInterval(1, 1)])
>>> scale.append(JustInterval(3, 2))
>>> scale.append(JustInterval(2, 1))
>>> scale.intervals
[JustInterval(3, 2), JustInterval(4, 3)]

complement: JustScale property

JustScale complement

Returns:

Type Description
JustScale

The complement scale

Examples:

>>> scale = JustScale([JustInterval(1, 1)])
>>> scale.append(JustInterval(3, 2))
>>> scale.append(JustInterval(2, 1))
>>> scale.complement
JustScale([1/1, 4/3, 2/1])

prime_limit: int property

JustScale prime limit

__init__(tones)

Initializes a JustScale.

Parameters:

Name Type Description Default
tones List[JustInterval]

A list of intervals or an object containing a list of intervals (that implements the attribute intervals)

required

Examples:

>>> scale = JustScale([JustInterval(1, 1)])
>>> scale.append(JustInterval(3, 2))
>>> scale.append(JustInterval(2, 1))
>>> scale
JustScale([1/1, 3/2, 2/1])
Source code in /opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/jintonic/scales.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def __init__(self, tones: List[JustInterval]):
    """Initializes a JustScale.

    Parameters:
        tones: A list of intervals or an object containing a list of
            intervals (that implements the attribute intervals)

    Examples:
        >>> scale = JustScale([JustInterval(1, 1)])
        >>> scale.append(JustInterval(3, 2))
        >>> scale.append(JustInterval(2, 1))
        >>> scale
        JustScale([1/1, 3/2, 2/1])
    """
    self._tones = tones

append(tone)

Appends tones to the scale.

Parameters:

Name Type Description Default
tone JustInterval

A new tone

required

Examples:

>>> scale = JustScale([JustInterval(3, 2)])
>>> scale.append(JustInterval(4, 3))
>>> scale.tones
[JustInterval(4, 3), JustInterval(3, 2)]
Source code in /opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/jintonic/scales.py
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
def append(self, tone: JustInterval):
    """Appends tones to the scale.

    Parameters:
        tone: A new tone

    Examples:
        >>> scale = JustScale([JustInterval(3, 2)])
        >>> scale.append(JustInterval(4, 3))
        >>> scale.tones
        [JustInterval(4, 3), JustInterval(3, 2)]
    """
    if not isinstance(tone, JustInterval):
        msg = "cannot append type {}. ".format(type(tone))
        msg += 'Expecting type "JustInterval"'
        raise ValueError(msg)
    self._tones.append(tone)

hertz(fundamental)

Translates scale intervals to pitches in Hertz over a fundamental

Note

Here, the fundamental is always 1/1 and is not to be mistaken with the first tone of the scale. If 1/1 is not part of the scale's tones, the fundamental will not be part of the scale.

Parameters:

Name Type Description Default
fundamental float

The scale's 0 degree (fundamental) pitch in Hertz.

required

Returns:

Type Description
List[float]

Scale pitches as Hertz

Source code in /opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/jintonic/scales.py
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
def hertz(self, fundamental: float) -> List[float]:
    """Translates scale intervals to pitches in Hertz over a fundamental

    Note:
        Here, the fundamental is always 1/1 and is not to be mistaken with
        the first tone of the scale. If 1/1 is not part of the scale's
        tones, the fundamental will not be part of the scale.

    Parameters:
        fundamental: The scale's 0 degree (fundamental) pitch in Hertz.

    Returns:
        Scale pitches as Hertz
    """
    return [fundamental * tone for tone in self.tones]

JustTetrachord

This class implements disjunct just intonation tetrachords.

Source code in /opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/jintonic/scales.py
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
class JustTetrachord:
    """This class implements disjunct just intonation tetrachords."""

    def __init__(
        self,
        intervals: Optional[List[JustInterval]] = None,
        genus: Optional[str] = None,
        prime_limit: int = 7,
    ):
        """Initializes a JustTetrachord.

        A JustTetrachord can be constructed in one of two ways :

            - from a genus name (with naive division)
            - from a list of intervals between each successive tone

        Parameters:
            intervals: A list of intervals
            genus: One of 'enharmonic', 'chromatic', or 'diatonic'
            prime_limit: The prime limit to respect

        Examples:
            >>> JustTetrachord(genus='chromatic')
            JustTetrachord('chromatic' [27:28, 14:15, 5:6])

            >>> JustTetrachord(genus='enharmonic')
            JustTetrachord('enharmonic' [45:46, 23:24, 4:5])
            >>> JustTetrachord(genus='enharmonic').prime_limit
            23

            >>> intervals = []
            >>> intervals.append(JustInterval(32, 31))
            >>> intervals.append(JustInterval(31, 30))
            >>> intervals.append(JustInterval(5, 4))
            >>> JustTetrachord(intervals)
            JustTetrachord('enharmonic' [31:32, 30:31, 4:5])
            >>> JustTetrachord(intervals).prime_limit
            31
        """
        if not is_prime(prime_limit):
            msg = "The prime limit must be a prime number. "
            msg += "Got: '{}'".format(prime_limit)
            raise ValueError(msg)
        self._prime_limit = prime_limit

        if intervals is not None:
            self.intervals = intervals
        elif genus is not None:
            self.genus = genus.strip().lower()
        else:
            self._intervals: List[JustInterval] = []

    @classmethod
    def validate_tetrachord(cls, tetrachord: Union[JustTetrachord, List[JustInterval]]):
        """Validates a tetrachord.

        Parameters:
            tetrachord: The tetrachord to validate

        Raises:
            ValueError: If the given tetrachord is invalid
        """
        if len(tetrachord) != 3:
            msg = "Tetrachords must be formed of exactly three intervals. "
            msg += 'Got: "{}"'.format(tetrachord)
            raise ValueError(msg)
        # TODO implement __add__ and __radd__ to avoid needing these sum loops
        total_interval = JustInterval(1, 1)
        if isinstance(tetrachord, JustTetrachord):
            for interval in tetrachord.intervals:
                total_interval += interval
        else:
            for interval in tetrachord:
                total_interval += interval
        if total_interval != JustInterval(4, 3):
            msg = "Tetrachord intervals must sum to JustInterval(4, 3). "
            msg += 'Got: "{}"'.format(total_interval)
            raise ValueError(msg)

    @property
    def intervals(self) -> List[JustInterval]:
        """JustTetrachord intervals.
        Returns:
            The tetrachord's intervals

        Examples:
            >>> JustTetrachord(genus='enharmonic').intervals
            [JustInterval(46, 45), JustInterval(24, 23), JustInterval(5, 4)]
        """
        return self._intervals

    @intervals.setter
    def intervals(self, values):
        """Set JustTetrachord intervals.

        Parameters:
            value: A list of exactly three intervals which sum to 4:3
        """
        self.validate_tetrachord(values)
        self._prime_limit = max(
            values[0].prime_limit, values[1].prime_limit, values[2].prime_limit
        )
        self._intervals = values

    @property
    def genus(self) -> str:
        """JustTetrachord genus."""
        if not self.intervals:
            raise ValueError("Undefined intervals")
        end_intervals = [JustInterval(5, 4), JustInterval(6, 5), JustInterval(10, 9)]
        genera = ["enharmonic", "chromatic", "diatonic"]
        try:
            return genera[end_intervals.index(self.intervals[-1])]
        except ValueError:
            return "non-classical"

    @genus.setter
    def genus(self, value: str):
        """Set JustTetrachord genus.

        Note:
            When setting the genus, the movable tone is set to its most basic
            position by dividing by two the interval remaining after taking the
            characteristic interval.

        Parameters:
            value: A valid classical genus from ['enharmonic', 'chromatic', 'diatonic']
        """
        characteristic_intervals = {
            "enharmonic": JustInterval(5, 4),
            "chromatic": JustInterval(6, 5),
            "diatonic": JustInterval(10, 9),
        }
        characteristic = characteristic_intervals[value]
        remainder = JustInterval(4, 3) - characteristic
        intervals = remainder.divisions(2, self.prime_limit)
        intervals.append(characteristic)
        self.intervals = intervals

    @property
    def prime_limit(self) -> int:
        """JustTetrachord prime limit."""
        return self._prime_limit

    @property
    def permutations(self) -> List[JustTetrachord]:
        """All (there are six) possible permutations of the JustTetrachord.

        Returns:
            The permutations of the JustTetrachord
        """
        return [
            JustTetrachord(intervals=list(permutation))
            for permutation in permutations(self.intervals)
        ]

    def __repr__(self):
        """repr(self)"""
        return "{}('{}' [{}:{}, {}:{}, {}:{}])".format(
            self.__class__.__name__,
            self.genus,
            self.intervals[0].denominator,
            self.intervals[0].numerator,
            self.intervals[1].denominator,
            self.intervals[1].numerator,
            self.intervals[2].denominator,
            self.intervals[2].numerator,
        )

    def __eq__(self, other):
        """self == other"""
        return self.intervals == other.intervals

    def __len__(self):
        """len(self)"""
        return len(self.intervals)

intervals: List[JustInterval] writable property

JustTetrachord intervals.

Returns:

Type Description
List[JustInterval]

The tetrachord's intervals

Examples:

>>> JustTetrachord(genus='enharmonic').intervals
[JustInterval(46, 45), JustInterval(24, 23), JustInterval(5, 4)]

genus: str writable property

JustTetrachord genus.

prime_limit: int property

JustTetrachord prime limit.

permutations: List[JustTetrachord] property

All (there are six) possible permutations of the JustTetrachord.

Returns:

Type Description
List[JustTetrachord]

The permutations of the JustTetrachord

__init__(intervals=None, genus=None, prime_limit=7)

Initializes a JustTetrachord.

A JustTetrachord can be constructed in one of two ways
  • from a genus name (with naive division)
  • from a list of intervals between each successive tone

Parameters:

Name Type Description Default
intervals Optional[List[JustInterval]]

A list of intervals

None
genus Optional[str]

One of 'enharmonic', 'chromatic', or 'diatonic'

None
prime_limit int

The prime limit to respect

7

Examples:

>>> JustTetrachord(genus='chromatic')
JustTetrachord('chromatic' [27:28, 14:15, 5:6])
>>> JustTetrachord(genus='enharmonic')
JustTetrachord('enharmonic' [45:46, 23:24, 4:5])
>>> JustTetrachord(genus='enharmonic').prime_limit
23
>>> intervals = []
>>> intervals.append(JustInterval(32, 31))
>>> intervals.append(JustInterval(31, 30))
>>> intervals.append(JustInterval(5, 4))
>>> JustTetrachord(intervals)
JustTetrachord('enharmonic' [31:32, 30:31, 4:5])
>>> JustTetrachord(intervals).prime_limit
31
Source code in /opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/jintonic/scales.py
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
def __init__(
    self,
    intervals: Optional[List[JustInterval]] = None,
    genus: Optional[str] = None,
    prime_limit: int = 7,
):
    """Initializes a JustTetrachord.

    A JustTetrachord can be constructed in one of two ways :

        - from a genus name (with naive division)
        - from a list of intervals between each successive tone

    Parameters:
        intervals: A list of intervals
        genus: One of 'enharmonic', 'chromatic', or 'diatonic'
        prime_limit: The prime limit to respect

    Examples:
        >>> JustTetrachord(genus='chromatic')
        JustTetrachord('chromatic' [27:28, 14:15, 5:6])

        >>> JustTetrachord(genus='enharmonic')
        JustTetrachord('enharmonic' [45:46, 23:24, 4:5])
        >>> JustTetrachord(genus='enharmonic').prime_limit
        23

        >>> intervals = []
        >>> intervals.append(JustInterval(32, 31))
        >>> intervals.append(JustInterval(31, 30))
        >>> intervals.append(JustInterval(5, 4))
        >>> JustTetrachord(intervals)
        JustTetrachord('enharmonic' [31:32, 30:31, 4:5])
        >>> JustTetrachord(intervals).prime_limit
        31
    """
    if not is_prime(prime_limit):
        msg = "The prime limit must be a prime number. "
        msg += "Got: '{}'".format(prime_limit)
        raise ValueError(msg)
    self._prime_limit = prime_limit

    if intervals is not None:
        self.intervals = intervals
    elif genus is not None:
        self.genus = genus.strip().lower()
    else:
        self._intervals: List[JustInterval] = []

validate_tetrachord(tetrachord) classmethod

Validates a tetrachord.

Parameters:

Name Type Description Default
tetrachord Union[JustTetrachord, List[JustInterval]]

The tetrachord to validate

required

Raises:

Type Description
ValueError

If the given tetrachord is invalid

Source code in /opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/jintonic/scales.py
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
@classmethod
def validate_tetrachord(cls, tetrachord: Union[JustTetrachord, List[JustInterval]]):
    """Validates a tetrachord.

    Parameters:
        tetrachord: The tetrachord to validate

    Raises:
        ValueError: If the given tetrachord is invalid
    """
    if len(tetrachord) != 3:
        msg = "Tetrachords must be formed of exactly three intervals. "
        msg += 'Got: "{}"'.format(tetrachord)
        raise ValueError(msg)
    # TODO implement __add__ and __radd__ to avoid needing these sum loops
    total_interval = JustInterval(1, 1)
    if isinstance(tetrachord, JustTetrachord):
        for interval in tetrachord.intervals:
            total_interval += interval
    else:
        for interval in tetrachord:
            total_interval += interval
    if total_interval != JustInterval(4, 3):
        msg = "Tetrachord intervals must sum to JustInterval(4, 3). "
        msg += 'Got: "{}"'.format(total_interval)
        raise ValueError(msg)

JustTetrachordalScale

This class implements disjunct just intonation tetrachordal scales.

Source code in /opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/jintonic/scales.py
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
class JustTetrachordalScale:
    """This class implements disjunct just intonation tetrachordal scales."""

    def __init__(
        self,
        lower: JustTetrachord,
        upper: Optional[JustTetrachord] = None,
    ):
        """Initializes a JustTetrachordalScale.

        Parameters:
            lower: The lower tetrachord
            upper: The upper tetrachord. If None is passed, the lower tetrachord
                is also used for the upper, creating an 'equal' tetrachordal scale.

        Examples:
            >>> JustTetrachordalScale(JustTetrachord(genus='enharmonic'))
            JustTetrachordalScale([46/45, 24/23, 5/4, 9/8, 46/45, 24/23, 5/4])
        """

        self._lower = lower
        if upper is None:
            self._upper = lower
        else:
            self._upper = upper

    @property
    def lower(self) -> JustTetrachord:
        """Lower JustTetrachord."""
        return self._lower

    @lower.setter
    def lower(self, value: JustTetrachord):
        """Set lower JustTetrachord."""
        JustTetrachord.validate_tetrachord(value)
        self._lower = value

    @property
    def upper(self) -> JustTetrachord:
        """Upper JustTetrachord."""
        return self._upper

    @upper.setter
    def upper(self, value: JustTetrachord):
        """Set upper JustTetrachord."""
        JustTetrachord.validate_tetrachord(value)
        self._upper = value

    @property
    def intervals(self) -> List[JustInterval]:
        """JustTetrachordalScale intervals.

        Examples:
            >>> JustTetrachordalScale(JustTetrachord(genus='diatonic')).intervals
            [JustInterval(16, 15), JustInterval(9, 8), JustInterval(10, 9),
            JustInterval(9, 8), JustInterval(16, 15), JustInterval(9, 8),
            JustInterval(10, 9)]
        """
        return self.lower.intervals + [JustInterval(9, 8)] + self.upper.intervals

    @property
    def complement(self) -> JustScale:
        """JustTetrachordalScale complement

        Note:
            Returns a JustScale! The result will not be Tetrachordal.

        Returns:
            The JustScale that is the complement

        Examples:
            >>> JustTetrachordalScale(JustTetrachord(genus='chromatic')).complement
            JustScale([1/1, 6/5, 9/7, 4/3, 3/2, 9/5, 27/14, 2/1])
        """
        tones = [tone.complement for tone in self.tones]
        return JustScale(tones)

    @property
    def tones(self) -> List[JustInterval]:
        """JustTetrachordalScale tones.

        Examples:
            >>> JustTetrachordalScale(JustTetrachord(genus='diatonic')).tones
            [JustInterval(1, 1), JustInterval(16, 15), JustInterval(6, 5),
            JustInterval(4, 3), JustInterval(3, 2), JustInterval(8, 5),
            JustInterval(9, 5), JustInterval(2, 1)]
        """
        tones = [JustInterval(1, 1)]
        tones += [
            sum(self.intervals[:i], start=JustInterval(1, 1))
            for i in range(1, len(self.intervals))
        ]
        tones += [JustInterval(2, 1)]
        return tones

    def hertz(self, fundamental: float) -> List[float]:
        """Translates scale intervals to pitches in Hertz over a fundamental

        Parameters:
            fundamental: The scale's 0 degree (fundamental) pitch in Hertz.

        Returns:
            The scale's pitches as Hertz

        Examples:
            >>> JustTetrachordalScale(JustTetrachord(genus='diatonic')).hertz(60.)
            [60.0, 64.0, 72.0, 80.0, 90.0, 96.0, 108.0, 120.0]
        """
        return [fundamental * tone for tone in self.tones]

    @property
    def genera(self) -> Tuple[str, ...]:
        """JustTetrachordalScale genera for each constituent tetrachord.

        Examples:
            >>> intervals = []
            >>> intervals.append(JustInterval(32, 31))
            >>> intervals.append(JustInterval(31, 30))
            >>> intervals.append(JustInterval(5, 4))
            >>> scale = JustTetrachordalScale(JustTetrachord(intervals))
            >>> scale.upper = JustTetrachord(genus='diatonic')
            >>> scale.genera
            ('enharmonic', 'diatonic')
        """
        return (self.lower.genus, self.upper.genus)

    @property
    def is_equal(self) -> bool:
        """Evaluates whether the JustTetrachordalScale is equal or mixed."""
        return self.lower == self.upper

    @property
    def prime_limit(self) -> int:
        """JustTetrachordalScale prime limit."""
        return max(self.lower.prime_limit, self.upper.prime_limit)

    @property
    def permutations(self) -> List[JustTetrachordalScale]:
        """All (thirty-six) possible permutations of the JustTetrachordalScale."""
        return [
            JustTetrachordalScale(pair[0], pair[1])
            for pair in product(self.lower.permutations, self.upper.permutations)
        ]

    def __repr__(self):
        """repr(self)"""
        pitches = ", ".join(
            [
                "/".join([str(interval.numerator), str(interval.denominator)])
                for interval in self.intervals
            ]
        )
        return "{}([{}])".format(self.__class__.__name__, pitches)

lower: JustTetrachord writable property

Lower JustTetrachord.

upper: JustTetrachord writable property

Upper JustTetrachord.

intervals: List[JustInterval] property

JustTetrachordalScale intervals.

Examples:

>>> JustTetrachordalScale(JustTetrachord(genus='diatonic')).intervals
[JustInterval(16, 15), JustInterval(9, 8), JustInterval(10, 9),
JustInterval(9, 8), JustInterval(16, 15), JustInterval(9, 8),
JustInterval(10, 9)]

complement: JustScale property

JustTetrachordalScale complement

Note

Returns a JustScale! The result will not be Tetrachordal.

Returns:

Type Description
JustScale

The JustScale that is the complement

Examples:

>>> JustTetrachordalScale(JustTetrachord(genus='chromatic')).complement
JustScale([1/1, 6/5, 9/7, 4/3, 3/2, 9/5, 27/14, 2/1])

tones: List[JustInterval] property

JustTetrachordalScale tones.

Examples:

>>> JustTetrachordalScale(JustTetrachord(genus='diatonic')).tones
[JustInterval(1, 1), JustInterval(16, 15), JustInterval(6, 5),
JustInterval(4, 3), JustInterval(3, 2), JustInterval(8, 5),
JustInterval(9, 5), JustInterval(2, 1)]

genera: Tuple[str, ...] property

JustTetrachordalScale genera for each constituent tetrachord.

Examples:

>>> intervals = []
>>> intervals.append(JustInterval(32, 31))
>>> intervals.append(JustInterval(31, 30))
>>> intervals.append(JustInterval(5, 4))
>>> scale = JustTetrachordalScale(JustTetrachord(intervals))
>>> scale.upper = JustTetrachord(genus='diatonic')
>>> scale.genera
('enharmonic', 'diatonic')

is_equal: bool property

Evaluates whether the JustTetrachordalScale is equal or mixed.

prime_limit: int property

JustTetrachordalScale prime limit.

permutations: List[JustTetrachordalScale] property

All (thirty-six) possible permutations of the JustTetrachordalScale.

__init__(lower, upper=None)

Initializes a JustTetrachordalScale.

Parameters:

Name Type Description Default
lower JustTetrachord

The lower tetrachord

required
upper Optional[JustTetrachord]

The upper tetrachord. If None is passed, the lower tetrachord is also used for the upper, creating an 'equal' tetrachordal scale.

None

Examples:

>>> JustTetrachordalScale(JustTetrachord(genus='enharmonic'))
JustTetrachordalScale([46/45, 24/23, 5/4, 9/8, 46/45, 24/23, 5/4])
Source code in /opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/jintonic/scales.py
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
def __init__(
    self,
    lower: JustTetrachord,
    upper: Optional[JustTetrachord] = None,
):
    """Initializes a JustTetrachordalScale.

    Parameters:
        lower: The lower tetrachord
        upper: The upper tetrachord. If None is passed, the lower tetrachord
            is also used for the upper, creating an 'equal' tetrachordal scale.

    Examples:
        >>> JustTetrachordalScale(JustTetrachord(genus='enharmonic'))
        JustTetrachordalScale([46/45, 24/23, 5/4, 9/8, 46/45, 24/23, 5/4])
    """

    self._lower = lower
    if upper is None:
        self._upper = lower
    else:
        self._upper = upper

hertz(fundamental)

Translates scale intervals to pitches in Hertz over a fundamental

Parameters:

Name Type Description Default
fundamental float

The scale's 0 degree (fundamental) pitch in Hertz.

required

Returns:

Type Description
List[float]

The scale's pitches as Hertz

Examples:

>>> JustTetrachordalScale(JustTetrachord(genus='diatonic')).hertz(60.)
[60.0, 64.0, 72.0, 80.0, 90.0, 96.0, 108.0, 120.0]
Source code in /opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/jintonic/scales.py
409
410
411
412
413
414
415
416
417
418
419
420
421
422
def hertz(self, fundamental: float) -> List[float]:
    """Translates scale intervals to pitches in Hertz over a fundamental

    Parameters:
        fundamental: The scale's 0 degree (fundamental) pitch in Hertz.

    Returns:
        The scale's pitches as Hertz

    Examples:
        >>> JustTetrachordalScale(JustTetrachord(genus='diatonic')).hertz(60.)
        [60.0, 64.0, 72.0, 80.0, 90.0, 96.0, 108.0, 120.0]
    """
    return [fundamental * tone for tone in self.tones]