@arraypress/waveform-sounds 0.1.3 → 0.3.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.
@@ -6,6 +6,8 @@
6
6
  * @module strings
7
7
  */
8
8
 
9
+ import {bpmRangeFromFilter, hasBpmFilter} from '../data/bpm.js';
10
+
9
11
  /** The English defaults. */
10
12
  export const DEFAULT_STRINGS = {
11
13
  search: 'Search sounds',
@@ -21,6 +23,8 @@ export const DEFAULT_STRINGS = {
21
23
  bpm: 'BPM',
22
24
  bpmMin: 'Min BPM',
23
25
  bpmMax: 'Max BPM',
26
+ anyBpm: 'Any BPM',
27
+ bpmRange: '{min}–{max} BPM',
24
28
  sort: 'Sort',
25
29
  sortBy: 'Sort by',
26
30
  sortDefault: 'Default',
@@ -29,6 +33,10 @@ export const DEFAULT_STRINGS = {
29
33
  sortKey: 'Key',
30
34
  sortDuration: 'Length',
31
35
  loop: 'Loop',
36
+ loopFilter: 'Loops or one-shots',
37
+ loops: 'Loops',
38
+ oneShots: 'One-shots',
39
+ isLoop: 'Loop',
32
40
  play: 'Play {title}',
33
41
  pause: 'Pause {title}',
34
42
  seek: 'Seek {title}',
@@ -62,6 +70,21 @@ export function fill(template, vars = {}) {
62
70
  return String(template).replace(/\{(\w+)\}/g, (match, name) => (name in vars ? String(vars[name]) : match));
63
71
  }
64
72
 
73
+ /**
74
+ * The BPM menu's label: "Any BPM", or the range the handles hold
75
+ * ("120–128 BPM"; an open end shows the pack's own end).
76
+ *
77
+ * @param {{bpmMin?: string|number, bpmMax?: string|number}} filter
78
+ * @param {{min: number, max: number}} extent - The pack's BPM range.
79
+ * @param {typeof DEFAULT_STRINGS} [strings]
80
+ * @returns {string}
81
+ */
82
+ export function bpmLabel(filter, extent, strings = DEFAULT_STRINGS) {
83
+ if (!hasBpmFilter(filter)) return strings.anyBpm;
84
+ const {lo, hi} = bpmRangeFromFilter(filter, extent);
85
+ return fill(strings.bpmRange, {min: lo, max: hi});
86
+ }
87
+
65
88
  /**
66
89
  * The count line: "300 sounds", "1 sound", "12 of 300 sounds".
67
90
  *