tuning-core 1.1.0 → 1.2.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.
|
@@ -95,6 +95,15 @@ export declare class IntervalSet {
|
|
|
95
95
|
*/
|
|
96
96
|
toSweepIntervals(): Fraction[];
|
|
97
97
|
minMax(min: FractionInput, max: FractionInput): this;
|
|
98
|
+
/**
|
|
99
|
+
* Fill gaps between consecutive intervals by adding new intervals per gap,
|
|
100
|
+
* equally spaced in logarithmic (ratio) space. Adds at least 3 new intervals per gap.
|
|
101
|
+
* When maxGapCents is provided, subdivides further so each part is ≤ maxGapCents.
|
|
102
|
+
*
|
|
103
|
+
* @param maxGapCents - Optional maximum gap in cents. When set, each subdivision is ≤ this value.
|
|
104
|
+
* @returns this (for chaining)
|
|
105
|
+
*/
|
|
106
|
+
interpolateLog(maxGapCents?: number): this;
|
|
98
107
|
/**
|
|
99
108
|
* Generate all unique ratios between min and max with denominators up to maxDenominator.
|
|
100
109
|
*
|
|
@@ -182,6 +182,33 @@ export class IntervalSet {
|
|
|
182
182
|
}
|
|
183
183
|
return this;
|
|
184
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Fill gaps between consecutive intervals by adding new intervals per gap,
|
|
187
|
+
* equally spaced in logarithmic (ratio) space. Adds at least 3 new intervals per gap.
|
|
188
|
+
* When maxGapCents is provided, subdivides further so each part is ≤ maxGapCents.
|
|
189
|
+
*
|
|
190
|
+
* @param maxGapCents - Optional maximum gap in cents. When set, each subdivision is ≤ this value.
|
|
191
|
+
* @returns this (for chaining)
|
|
192
|
+
*/
|
|
193
|
+
interpolateLog(maxGapCents) {
|
|
194
|
+
if (maxGapCents !== undefined && maxGapCents <= 0) {
|
|
195
|
+
throw new Error("maxGapCents must be a positive number");
|
|
196
|
+
}
|
|
197
|
+
const ratios = this.getRatios();
|
|
198
|
+
for (let i = 0; i < ratios.length - 1; i++) {
|
|
199
|
+
const left = ratios[i].valueOf();
|
|
200
|
+
const right = ratios[i + 1].valueOf();
|
|
201
|
+
const gapRatio = right / left;
|
|
202
|
+
const gapCents = 1200 * Math.log2(gapRatio);
|
|
203
|
+
const n = Math.max(4, Math.ceil(gapCents / (maxGapCents ?? gapCents)));
|
|
204
|
+
for (let k = 1; k < n; k++) {
|
|
205
|
+
const num = left * Math.pow(gapRatio, k / n);
|
|
206
|
+
const rounded = Math.round(num * 10000) / 10000;
|
|
207
|
+
this.add(rounded);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return this;
|
|
211
|
+
}
|
|
185
212
|
/**
|
|
186
213
|
* Generate all unique ratios between min and max with denominators up to maxDenominator.
|
|
187
214
|
*
|