tuning-core 1.0.2 → 1.1.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.
- package/dist/lib/utils.d.ts +2 -2
- package/dist/lib/utils.js +3 -3
- package/package.json +2 -2
package/dist/lib/utils.d.ts
CHANGED
|
@@ -4,14 +4,14 @@ import type { HarmonicData } from './types';
|
|
|
4
4
|
* Convert a frequency ratio to cents.
|
|
5
5
|
* @param ratio - The ratio as FractionInput (number, string, array, object, or Fraction)
|
|
6
6
|
* @param places - Number of decimal places to round to (default: 0, no decimals)
|
|
7
|
-
* @returns The ratio in cents (1200 * log2(ratio)), rounded to the specified number of decimals
|
|
7
|
+
* @returns The ratio in cents (1200 * log2(ratio)), rounded to the specified number of decimals (default 0, no decimals 3/2 = 702 cents)
|
|
8
8
|
*/
|
|
9
9
|
export declare function ratioToCents(ratio: FractionInput, places?: number): Fraction;
|
|
10
10
|
/**
|
|
11
11
|
* Convert cents to a frequency ratio.
|
|
12
12
|
* @param cents - The interval in cents as FractionInput (number, string, array, object, or Fraction)
|
|
13
13
|
* @param places - Number of decimal places to round to (default: 0, no decimals)
|
|
14
|
-
* @returns The ratio as a Fraction object (2^(cents/1200)), rounded to the specified number of decimals
|
|
14
|
+
* @returns The ratio as a Fraction object (2^(cents/1200)), rounded to the specified number of decimals before contertion to fraction (default 3 decimals, 702 cents = 3/2)
|
|
15
15
|
*/
|
|
16
16
|
export declare function centsToRatio(cents: FractionInput, places?: number): Fraction;
|
|
17
17
|
/**
|
package/dist/lib/utils.js
CHANGED
|
@@ -6,7 +6,7 @@ function round(num, places = 0) {
|
|
|
6
6
|
* Convert a frequency ratio to cents.
|
|
7
7
|
* @param ratio - The ratio as FractionInput (number, string, array, object, or Fraction)
|
|
8
8
|
* @param places - Number of decimal places to round to (default: 0, no decimals)
|
|
9
|
-
* @returns The ratio in cents (1200 * log2(ratio)), rounded to the specified number of decimals
|
|
9
|
+
* @returns The ratio in cents (1200 * log2(ratio)), rounded to the specified number of decimals (default 0, no decimals 3/2 = 702 cents)
|
|
10
10
|
*/
|
|
11
11
|
export function ratioToCents(ratio, places = 0) {
|
|
12
12
|
const val = new Fraction(ratio).valueOf();
|
|
@@ -18,9 +18,9 @@ export function ratioToCents(ratio, places = 0) {
|
|
|
18
18
|
* Convert cents to a frequency ratio.
|
|
19
19
|
* @param cents - The interval in cents as FractionInput (number, string, array, object, or Fraction)
|
|
20
20
|
* @param places - Number of decimal places to round to (default: 0, no decimals)
|
|
21
|
-
* @returns The ratio as a Fraction object (2^(cents/1200)), rounded to the specified number of decimals
|
|
21
|
+
* @returns The ratio as a Fraction object (2^(cents/1200)), rounded to the specified number of decimals before contertion to fraction (default 3 decimals, 702 cents = 3/2)
|
|
22
22
|
*/
|
|
23
|
-
export function centsToRatio(cents, places =
|
|
23
|
+
export function centsToRatio(cents, places = 3) {
|
|
24
24
|
const val = new Fraction(cents).valueOf();
|
|
25
25
|
const num = Math.pow(2, val / 1200);
|
|
26
26
|
const rounded = round(num, places);
|