@libraz/libcantus-wasm 0.0.0-stage → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Counterpoint classification of a harmonic interval by consonance.
3
+ *
4
+ * Distinct from a spelled interval's quality label — see
5
+ * {@link IntervalQualityLabel}, which names the `'P'` / `'M'` / `'m'` / `'A'` /
6
+ * `'d'` spelling of an interval rather than how it sounds against another
7
+ * voice.
8
+ *
9
+ * @see {@link IntervalQualityLabel}
10
+ * @category Pitch & Intervals
11
+ */
12
+ declare enum ConsonanceClass {
13
+ PerfectConsonance = 0,
14
+ ImperfectConsonance = 1,
15
+ Dissonance = 2
16
+ }
17
+ /**
18
+ * Classify an interval for counterpoint evaluation.
19
+ *
20
+ * The interval is reduced modulo 12, so compound intervals classify as their
21
+ * simple equivalents. The perfect fourth (5) is context-dependent: with
22
+ * `twoVoice` (the default) it classifies as a dissonance, matching
23
+ * {@link isConsonantInterval}; otherwise it is an imperfect consonance.
24
+ *
25
+ * @param semitones Interval size in semitones (may be negative or compound).
26
+ * @param twoVoice When true, the perfect fourth is treated as dissonant.
27
+ * @returns The counterpoint quality of the interval.
28
+ * @example
29
+ * ```ts
30
+ * import { classifyInterval, ConsonanceClass } from '@libraz/libcantus';
31
+ * classifyInterval(7); // ConsonanceClass.PerfectConsonance
32
+ * classifyInterval(5); // ConsonanceClass.Dissonance (two-voice)
33
+ * classifyInterval(5, false); // ConsonanceClass.ImperfectConsonance
34
+ * ```
35
+ * @category Pitch & Intervals
36
+ */
37
+ declare function classifyInterval(semitones: number, twoVoice?: boolean): ConsonanceClass;
38
+ /**
39
+ * Test whether an interval is a perfect consonance: the unison/octave or the
40
+ * fifth.
41
+ *
42
+ * The perfect fourth is deliberately excluded. This is the predicate the
43
+ * parallel-motion rules are written against, where the fourth behaves as a
44
+ * dissonance between two voices; {@link classifyInterval} is the general
45
+ * classifier, and it treats the fourth as context-dependent.
46
+ *
47
+ * @param semitones Interval size in semitones (may be negative or compound).
48
+ * @returns True for the unison/octave (0) and the perfect fifth (7) mod 12.
49
+ * @category Pitch & Intervals
50
+ */
51
+ declare function isPerfectInterval(semitones: number): boolean;
52
+ /**
53
+ * Test whether an interval is consonant.
54
+ *
55
+ * The consonant set is {0, 3, 4, 5, 7, 8, 9} mod 12. In two-voice counterpoint
56
+ * the perfect fourth (5) is treated as a dissonance, so `twoVoice` set to true
57
+ * excludes it.
58
+ *
59
+ * @param semitones Interval size in semitones (may be negative or compound).
60
+ * @param twoVoice When true, the perfect fourth is treated as dissonant.
61
+ * @returns True if the interval is consonant in the given context.
62
+ * @category Pitch & Intervals
63
+ */
64
+ declare function isConsonantInterval(semitones: number, twoVoice?: boolean): boolean;
65
+
66
+ export { ConsonanceClass as C, isPerfectInterval as a, classifyInterval as c, isConsonantInterval as i };