@avoid.quest/audio 0.1.0 → 0.1.1-beta.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.
Files changed (41) hide show
  1. package/README.md +30 -2
  2. package/dist/effects/index.d.ts +21 -72
  3. package/dist/effects/index.js +212 -505
  4. package/dist/effects/index.js.map +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/midi/index.d.ts +0 -24
  8. package/dist/midi/index.js +222 -258
  9. package/dist/midi/index.js.map +1 -1
  10. package/dist/native-Bern4_PB.js +172 -0
  11. package/dist/native-Bern4_PB.js.map +1 -0
  12. package/dist/pcm-buffer-DSzGHbon.js +436 -0
  13. package/dist/pcm-buffer-DSzGHbon.js.map +1 -0
  14. package/dist/playback/index.d.ts +60 -114
  15. package/dist/playback/index.js +899 -1062
  16. package/dist/playback/index.js.map +1 -1
  17. package/dist/queue/index.d.ts +8 -19
  18. package/dist/queue/index.js +461 -960
  19. package/dist/queue/index.js.map +1 -1
  20. package/dist/recognize/index.d.ts +37 -74
  21. package/dist/recognize/index.js +172 -2715
  22. package/dist/recognize/index.js.map +1 -1
  23. package/dist/routing/index.d.ts +3 -34
  24. package/dist/routing/index.js +413 -536
  25. package/dist/routing/index.js.map +1 -1
  26. package/dist/shazam-gBrX1NEY.d.ts +27 -0
  27. package/dist/sync/index.d.ts +9 -77
  28. package/dist/sync/index.js +320 -542
  29. package/dist/sync/index.js.map +1 -1
  30. package/dist/{worklet-loader-BvEW0oVO.d.ts → worklet-loader-BabwPALw.d.ts} +4 -7
  31. package/dist/{worklet-loader-S7R8ZAmP.js → worklet-loader-f741D1tk.js} +37 -52
  32. package/dist/worklet-loader-f741D1tk.js.map +1 -0
  33. package/dist/worklets/couch-live.js +110 -192
  34. package/dist/worklets/couch-live.js.map +1 -1
  35. package/dist/worklets/meter.js +14 -20
  36. package/dist/worklets/meter.js.map +1 -1
  37. package/dist/worklets/pcm-capture.d.ts +6 -0
  38. package/dist/worklets/pcm-capture.js +52 -0
  39. package/dist/worklets/pcm-capture.js.map +1 -0
  40. package/package.json +8 -3
  41. package/dist/worklet-loader-S7R8ZAmP.js.map +0 -1
@@ -1,46 +1,19 @@
1
- import { Effect } from "effect";
2
- import FFT from "fft.js";
3
- import { n as AudioDecodeError } from "../errors-BT9HxDLn.js";
4
- // src/recognize/crc32.ts
5
- const CRC32_POLYNOMIAL = 0xedb88320;
6
- const CRC32_TABLE = (() => {
7
- const table = /* @__PURE__ */ new Uint32Array(256);
8
- for (let i = 0; i < 256; i += 1) {
9
- let crc = i;
10
- for (let bit = 0; bit < 8; bit += 1) crc = (crc & 1) === 0 ? crc >>> 1 : crc >>> 1 ^ CRC32_POLYNOMIAL;
11
- table[i] = crc >>> 0;
12
- }
13
- return table;
14
- })();
15
- /**
16
- * Pure TypeScript IEEE 802.3 CRC32 over `Uint8Array` (zero `node:zlib` imports).
17
- * Matches IEEE test vector: `crc32(utf8("123456789")) === 0xcbf43926`.
18
- */
19
- function crc32(bytes, seed = 0) {
20
- let crc = (seed ^ 0xffffffff) >>> 0;
21
- for (const byte of bytes) crc = ((CRC32_TABLE[(crc ^ byte) & 255] ?? 0) ^ crc >>> 8) >>> 0;
22
- return (crc ^ 0xffffffff) >>> 0;
23
- }
24
- /**
25
- * Convenience helper computing IEEE 802.3 CRC32 over a UTF-8 string.
26
- */
27
- function crc32String(input, seed = 0) {
28
- return crc32(new TextEncoder().encode(input), seed);
29
- }
30
- // src/recognize/playlist.ts
31
- const BOM_REGEX = /^\uFEFF/u;
32
- const NEWLINE_REGEX = /\r?\n/u;
33
- const WHITESPACE_CHAR_REGEX = /\s/u;
34
- const FILE_EXT_REGEX = /\.[^.]+$/u;
35
- const SEPARATOR_REGEX = /[_-]+/gu;
36
- const ATTR_PAIR_REGEX = /(?<key>[A-Za-z0-9_-]+)=(?:"(?<quoted>[^"]*)"|(?<bare>[^,\s]*))/gu;
37
- const PLS_LINE_REGEX = /^(?<field>file|title|length)(?<index>\d+)\s*=\s*(?<value>.*)$/iu;
38
- const PLS_COUNT_REGEX = /^numberofentries\s*=\s*(?<count>\d+)$/iu;
39
- const PLS_VERSION_REGEX = /^version\s*=\s*(?<ver>\d+)$/iu;
40
- const RESOLUTION_REGEX = /^(?<width>\d+)x(?<height>\d+)$/iu;
41
- function splitLines(content) {
42
- return content.replace(BOM_REGEX, "").split(NEWLINE_REGEX).map((line) => line.trim()).filter((line) => line.length > 0);
43
- }
1
+ import { _ as crc32, a as computePeakCorrection, c as SHAZAM_HANNING_WINDOW, d as SHAZAM_MAX_SAMPLES, f as SHAZAM_SAMPLE_RATE, g as resampleMonoTo16kHz, h as float32ToPcm16Le, i as prepareShazamPcm, l as SHAZAM_MAX_DURATION_SECONDS, m as bytesToBase64, n as createPcmRingBuffer, o as generateShazamSignature, p as base64ToBytes, r as generateShazamSignatureFromFloat32, s as generateShazamSignatureSync, t as PCM_RING_MAX_SECONDS, u as SHAZAM_MAX_PCM_BYTES, v as crc32String } from "../pcm-buffer-DSzGHbon.js";
2
+ // src/recognize/playlist-m3u.ts
3
+ const BOM_RE = /^\uFEFF/u;
4
+ const NEWLINE_RE = /\r?\n/u;
5
+ const SPACE_RE = /\s/u;
6
+ const FILE_EXT_RE = /\.[^.]+$/u;
7
+ const SEP_RE = /[_-]+/gu;
8
+ const ATTR_RE = /(?<key>[A-Za-z0-9_-]+)=(?:"(?<quoted>[^"]*)"|(?<bare>[^,\s]*))/gu;
9
+ const PLS_LINE_RE = /^(?<field>file|title|length)(?<index>\d+)\s*=\s*(?<value>.*)$/iu;
10
+ const PLS_COUNT_RE = /^numberofentries\s*=\s*(?<count>\d+)$/iu;
11
+ const PLS_VER_RE = /^version\s*=\s*(?<ver>\d+)$/iu;
12
+ const splitLines = (content) => content.replace(BOM_RE, "").split(NEWLINE_RE).map((l) => l.trim()).filter(Boolean);
13
+ const splitTag = (line) => {
14
+ const i = line.indexOf(":");
15
+ return i === -1 ? [line, ""] : [line.slice(0, i), line.slice(i + 1)];
16
+ };
44
17
  function resolveUri(uri, baseUrl) {
45
18
  const trimmed = uri.trim();
46
19
  if (!baseUrl) return trimmed;
@@ -50,92 +23,70 @@ function resolveUri(uri, baseUrl) {
50
23
  return trimmed;
51
24
  }
52
25
  }
53
- function fallbackTitleFromUrl(url) {
54
- try {
55
- const lastSegment = new URL(url, "https://placeholder.invalid").pathname.split("/").filter(Boolean).at(-1);
56
- if (lastSegment) {
57
- const cleaned = decodeURIComponent(lastSegment).replace(FILE_EXT_REGEX, "").replaceAll(SEPARATOR_REGEX, " ").trim();
58
- if (cleaned.length > 0) return cleaned;
59
- }
60
- } catch {}
61
- return "Unknown Track";
62
- }
26
+ const parseNum = (raw) => {
27
+ const n = raw === void 0 ? NaN : Number(raw.trim());
28
+ return Number.isFinite(n) ? n : void 0;
29
+ };
30
+ const parseNonNeg = (raw) => {
31
+ const n = parseNum(raw);
32
+ return n !== void 0 && n >= 0 ? n : void 0;
33
+ };
63
34
  function parseAttributes(input) {
64
35
  const attrs = {};
65
- ATTR_PAIR_REGEX.lastIndex = 0;
66
- let match = ATTR_PAIR_REGEX.exec(input);
67
- while (match !== null) {
68
- const key = match.groups?.key;
69
- const value = match.groups?.quoted ?? match.groups?.bare ?? "";
70
- if (key !== void 0) attrs[key] = value;
71
- match = ATTR_PAIR_REGEX.exec(input);
36
+ for (const m of input.matchAll(ATTR_RE)) {
37
+ const key = m.groups?.key;
38
+ if (key !== void 0) attrs[key] = m.groups?.quoted ?? m.groups?.bare ?? "";
72
39
  }
73
40
  return attrs;
74
41
  }
42
+ function fallbackTitle(url) {
43
+ try {
44
+ const seg = new URL(url, "https://placeholder.invalid").pathname.split("/").findLast(Boolean);
45
+ const cleaned = seg ? decodeURIComponent(seg).replace(FILE_EXT_RE, "").replaceAll(SEP_RE, " ").trim() : "";
46
+ if (cleaned) return cleaned;
47
+ } catch {}
48
+ return "Unknown Track";
49
+ }
75
50
  function findUnquotedComma(body) {
76
- let inQuotes = false;
51
+ let quoted = false;
77
52
  for (let i = 0; i < body.length; i += 1) {
78
53
  const ch = body[i];
79
- if (ch === "\"") inQuotes = !inQuotes;
80
- else if (ch === "," && !inQuotes) return i;
54
+ if (ch === "\"") quoted = !quoted;
55
+ else if (ch === "," && !quoted) return i;
81
56
  }
82
57
  return -1;
83
58
  }
84
- function parseExtinfLine(line) {
85
- const body = line.slice(8);
86
- const commaIndex = findUnquotedComma(body);
87
- const metaPart = commaIndex >= 0 ? body.slice(0, commaIndex) : body;
88
- const titlePart = commaIndex >= 0 ? body.slice(commaIndex + 1).trim() : "";
89
- const firstSpace = metaPart.search(WHITESPACE_CHAR_REGEX);
90
- const durationStr = firstSpace >= 0 ? metaPart.slice(0, firstSpace) : metaPart;
91
- const parsedDuration = Number(durationStr.trim());
92
- const duration = Number.isFinite(parsedDuration) && parsedDuration >= 0 ? parsedDuration : void 0;
93
- const attrStr = firstSpace >= 0 ? metaPart.slice(firstSpace + 1) : "";
94
- const parsedAttrs = attrStr.trim().length > 0 ? parseAttributes(attrStr) : void 0;
59
+ function parseExtinf(body) {
60
+ const comma = findUnquotedComma(body);
61
+ const meta = comma >= 0 ? body.slice(0, comma) : body;
62
+ const space = meta.search(SPACE_RE);
63
+ const attrStr = space >= 0 ? meta.slice(space + 1).trim() : "";
64
+ const attrs = attrStr ? parseAttributes(attrStr) : void 0;
95
65
  return {
96
- attributes: parsedAttrs && Object.keys(parsedAttrs).length > 0 ? parsedAttrs : void 0,
97
- duration,
98
- title: titlePart.length > 0 ? titlePart : void 0
66
+ attributes: attrs && Object.keys(attrs).length > 0 ? attrs : void 0,
67
+ duration: parseNonNeg(space >= 0 ? meta.slice(0, space) : meta),
68
+ title: (comma >= 0 ? body.slice(comma + 1).trim() : "") || void 0
99
69
  };
100
70
  }
101
- /**
102
- * Pure-TS M3U / M3U8 playlist parser supporting `#EXTM3U`, `#EXTINF`,
103
- * IPTV/Kodi attributes (`tvg-id`, `tvg-name`, `tvg-logo`, `group-title`),
104
- * and relative URL resolution.
105
- */
106
71
  function parseM3u(content, baseUrl) {
107
- const lines = splitLines(content);
108
72
  let isExtended = false;
109
73
  let tvgUrl;
110
74
  const entries = [];
111
- let pendingTitle;
112
- let pendingDuration;
113
- let pendingAttrs;
114
- for (const line of lines) {
115
- if (line.startsWith("#EXTM3U")) {
116
- isExtended = true;
117
- const headerAttrs = parseAttributes(line.slice(7));
118
- tvgUrl = headerAttrs["x-tvg-url"] ?? headerAttrs["url-tvg"] ?? tvgUrl;
119
- continue;
120
- }
121
- if (line.startsWith("#EXTINF:")) {
122
- const parsed = parseExtinfLine(line);
123
- pendingDuration = parsed.duration;
124
- pendingTitle = parsed.title;
125
- pendingAttrs = parsed.attributes;
126
- continue;
127
- }
128
- if (line.startsWith("#")) continue;
75
+ let pending;
76
+ for (const line of splitLines(content)) if (line.startsWith("#EXTM3U")) {
77
+ isExtended = true;
78
+ const attrs = parseAttributes(line.slice(7));
79
+ tvgUrl = attrs["x-tvg-url"] ?? attrs["url-tvg"] ?? tvgUrl;
80
+ } else if (line.startsWith("#EXTINF:")) pending = parseExtinf(line.slice(8));
81
+ else if (!line.startsWith("#")) {
129
82
  const url = resolveUri(line, baseUrl);
130
83
  entries.push({
131
- attributes: pendingAttrs,
132
- durationSeconds: pendingDuration,
133
- title: pendingTitle ?? fallbackTitleFromUrl(url),
84
+ attributes: pending?.attributes,
85
+ durationSeconds: pending?.duration,
86
+ title: pending?.title ?? fallbackTitle(url),
134
87
  url
135
88
  });
136
- pendingTitle = void 0;
137
- pendingDuration = void 0;
138
- pendingAttrs = void 0;
89
+ pending = void 0;
139
90
  }
140
91
  return {
141
92
  entries,
@@ -144,53 +95,38 @@ function parseM3u(content, baseUrl) {
144
95
  tvgUrl
145
96
  };
146
97
  }
147
- function applyPlsEntryLine(line, byIndex) {
148
- const entryMatch = PLS_LINE_REGEX.exec(line);
149
- if (!entryMatch?.groups) return;
150
- const field = entryMatch.groups.field?.toLowerCase();
151
- const index = Number(entryMatch.groups.index);
152
- const value = (entryMatch.groups.value ?? "").trim();
153
- if (!Number.isFinite(index)) return;
98
+ function applyPlsLine(line, byIndex) {
99
+ const m = PLS_LINE_RE.exec(line)?.groups;
100
+ const index = Number(m?.index);
101
+ if (!m || !Number.isFinite(index)) return;
154
102
  const bucket = byIndex.get(index) ?? {};
155
- if (field === "file") bucket.file = value;
156
- else if (field === "title") bucket.title = value;
157
- else if (field === "length") {
158
- const parsedLen = Number(value);
159
- bucket.length = Number.isFinite(parsedLen) && parsedLen >= 0 ? parsedLen : void 0;
160
- }
103
+ const field = m.field?.toLowerCase();
104
+ const val = (m.value ?? "").trim();
105
+ if (field === "file") bucket.file = val;
106
+ else if (field === "title") bucket.title = val;
107
+ else if (field === "length") bucket.length = parseNonNeg(val);
161
108
  byIndex.set(index, bucket);
162
109
  }
163
- /**
164
- * Pure-TS PLS (`[playlist]`) parser sorting entries numerically by index.
165
- */
166
110
  function parsePls(content, baseUrl) {
167
- const lines = splitLines(content);
168
111
  const byIndex = /* @__PURE__ */ new Map();
169
112
  let numberOfEntries;
170
113
  let version;
171
- for (const line of lines) {
114
+ for (const line of splitLines(content)) {
172
115
  if (line.startsWith("[") || line.startsWith(";") || line.startsWith("#")) continue;
173
- const countMatch = PLS_COUNT_REGEX.exec(line);
174
- if (countMatch?.groups?.count !== void 0) {
175
- numberOfEntries = Number(countMatch.groups.count);
176
- continue;
177
- }
178
- const versionMatch = PLS_VERSION_REGEX.exec(line);
179
- if (versionMatch?.groups?.ver !== void 0) {
180
- version = Number(versionMatch.groups.ver);
181
- continue;
182
- }
183
- applyPlsEntryLine(line, byIndex);
116
+ const count = PLS_COUNT_RE.exec(line)?.groups?.count;
117
+ const ver = PLS_VER_RE.exec(line)?.groups?.ver;
118
+ if (count !== void 0) numberOfEntries = Number(count);
119
+ else if (ver === void 0) applyPlsLine(line, byIndex);
120
+ else version = Number(ver);
184
121
  }
185
- const sortedIndices = [...byIndex.keys()].toSorted((a, b) => a - b);
186
122
  const entries = [];
187
- for (const index of sortedIndices) {
188
- const item = byIndex.get(index);
123
+ for (const idx of [...byIndex.keys()].toSorted((a, b) => a - b)) {
124
+ const item = byIndex.get(idx);
189
125
  if (!item?.file) continue;
190
126
  const url = resolveUri(item.file, baseUrl);
191
127
  entries.push({
192
128
  durationSeconds: item.length,
193
- title: item.title && item.title.length > 0 ? item.title : fallbackTitleFromUrl(url),
129
+ title: item.title || fallbackTitle(url),
194
130
  url
195
131
  });
196
132
  }
@@ -201,75 +137,52 @@ function parsePls(content, baseUrl) {
201
137
  version
202
138
  };
203
139
  }
204
- /**
205
- * Auto-detects PLS (`[playlist]`) vs M3U/M3U8 and parses accordingly.
206
- */
207
- function parsePlaylist(content, baseUrl) {
208
- if (content.replace(BOM_REGEX, "").trimStart().toLowerCase().startsWith("[playlist]")) return parsePls(content, baseUrl);
209
- return parseM3u(content, baseUrl);
210
- }
211
- function parseFiniteNumber(raw) {
212
- if (raw === void 0) return;
213
- const num = Number(raw);
214
- return Number.isFinite(num) ? num : void 0;
215
- }
216
- function parseResolution(raw) {
217
- if (!raw) return;
218
- const match = RESOLUTION_REGEX.exec(raw);
219
- if (!match?.groups?.width || !match.groups.height) return;
220
- return {
221
- height: Number(match.groups.height),
222
- width: Number(match.groups.width)
223
- };
224
- }
140
+ // src/recognize/playlist-hls.ts
141
+ const RES_RE = /^(?<width>\d+)x(?<height>\d+)$/iu;
142
+ const parseRes = (raw) => {
143
+ const g = raw ? RES_RE.exec(raw)?.groups : void 0;
144
+ return g?.width && g.height ? {
145
+ height: Number(g.height),
146
+ width: Number(g.width)
147
+ } : void 0;
148
+ };
225
149
  function parseHlsMaster(lines, baseUrl) {
226
150
  let version;
227
151
  let independentSegments = false;
228
152
  const variants = [];
229
153
  const renditions = [];
230
- let pendingVariantAttrs;
231
- for (const line of lines) {
232
- if (line.startsWith("#EXT-X-VERSION:")) {
233
- version = parseFiniteNumber(line.slice(15).trim());
234
- continue;
235
- }
236
- if (line === "#EXT-X-INDEPENDENT-SEGMENTS") {
237
- independentSegments = true;
238
- continue;
239
- }
240
- if (line.startsWith("#EXT-X-MEDIA:")) {
241
- const attrs = parseAttributes(line.slice(13));
154
+ let pendingAttrs;
155
+ for (const line of lines) if (line.startsWith("#")) {
156
+ const [tag, val] = splitTag(line);
157
+ if (tag === "#EXT-X-VERSION") version = parseNum(val);
158
+ else if (tag === "#EXT-X-INDEPENDENT-SEGMENTS") independentSegments = true;
159
+ else if (tag === "#EXT-X-MEDIA") {
160
+ const a = parseAttributes(val);
242
161
  renditions.push({
243
- attributes: attrs,
244
- autoSelect: attrs.AUTOSELECT === "YES",
245
- groupId: attrs["GROUP-ID"] ?? "",
246
- isDefault: attrs.DEFAULT === "YES",
247
- language: attrs.LANGUAGE,
248
- name: attrs.NAME ?? "",
249
- type: attrs.TYPE ?? "",
250
- url: attrs.URI ? resolveUri(attrs.URI, baseUrl) : void 0
162
+ attributes: a,
163
+ autoSelect: a.AUTOSELECT === "YES",
164
+ groupId: a["GROUP-ID"] ?? "",
165
+ isDefault: a.DEFAULT === "YES",
166
+ language: a.LANGUAGE,
167
+ name: a.NAME ?? "",
168
+ type: a.TYPE ?? "",
169
+ url: a.URI ? resolveUri(a.URI, baseUrl) : void 0
251
170
  });
252
- continue;
253
- }
254
- if (line.startsWith("#EXT-X-STREAM-INF:")) {
255
- pendingVariantAttrs = parseAttributes(line.slice(18));
256
- continue;
257
- }
258
- if (line.startsWith("#") || !pendingVariantAttrs) continue;
259
- const attrs = pendingVariantAttrs;
171
+ } else if (tag === "#EXT-X-STREAM-INF") pendingAttrs = parseAttributes(val);
172
+ } else if (pendingAttrs) {
260
173
  variants.push({
261
- attributes: attrs,
262
- audioGroup: attrs.AUDIO,
263
- averageBandwidth: parseFiniteNumber(attrs["AVERAGE-BANDWIDTH"]),
264
- bandwidth: parseFiniteNumber(attrs.BANDWIDTH) ?? 0,
265
- codecs: attrs.CODECS,
266
- frameRate: parseFiniteNumber(attrs["FRAME-RATE"]),
267
- name: attrs.NAME,
268
- resolution: parseResolution(attrs.RESOLUTION),
269
- subtitlesGroup: attrs.SUBTITLES,
174
+ attributes: pendingAttrs,
175
+ audioGroup: pendingAttrs.AUDIO,
176
+ averageBandwidth: parseNum(pendingAttrs["AVERAGE-BANDWIDTH"]),
177
+ bandwidth: parseNum(pendingAttrs.BANDWIDTH) ?? 0,
178
+ codecs: pendingAttrs.CODECS,
179
+ frameRate: parseNum(pendingAttrs["FRAME-RATE"]),
180
+ name: pendingAttrs.NAME,
181
+ resolution: parseRes(pendingAttrs.RESOLUTION),
182
+ subtitlesGroup: pendingAttrs.SUBTITLES,
270
183
  url: resolveUri(line, baseUrl)
271
184
  });
272
- pendingVariantAttrs = void 0;
185
+ pendingAttrs = void 0;
273
186
  }
274
187
  return {
275
188
  cacheTtlMs: Number.POSITIVE_INFINITY,
@@ -280,2537 +193,81 @@ function parseHlsMaster(lines, baseUrl) {
280
193
  version
281
194
  };
282
195
  }
283
- function parseMediaExtinf(line, state) {
284
- const body = line.slice(8);
285
- const comma = body.indexOf(",");
286
- const durationStr = comma === -1 ? body : body.slice(0, comma);
287
- const titleStr = comma === -1 ? "" : body.slice(comma + 1).trim();
288
- const dur = parseFiniteNumber(durationStr.trim());
289
- state.pendingDuration = dur !== void 0 && dur >= 0 ? dur : 0;
290
- state.pendingTitle = titleStr.length > 0 ? titleStr : void 0;
291
- }
292
- function handleHlsMediaTag(line, state, baseUrl) {
293
- if (line.startsWith("#EXT-X-VERSION:")) state.version = parseFiniteNumber(line.slice(15).trim());
294
- else if (line.startsWith("#EXT-X-TARGETDURATION:")) {
295
- const td = parseFiniteNumber(line.slice(22).trim());
296
- if (td !== void 0 && td >= 0) state.targetDurationSeconds = td;
297
- } else if (line.startsWith("#EXT-X-MEDIA-SEQUENCE:")) {
298
- const seq = parseFiniteNumber(line.slice(22).trim());
299
- if (seq !== void 0 && seq >= 0) state.mediaSequence = seq;
300
- } else if (line.startsWith("#EXT-X-PLAYLIST-TYPE:")) {
301
- const rawType = line.slice(21).trim().toUpperCase();
302
- if (rawType === "VOD" || rawType === "EVENT") state.playlistType = rawType;
303
- } else if (line === "#EXT-X-ENDLIST") state.hasEndList = true;
304
- else if (line === "#EXT-X-DISCONTINUITY") state.nextDiscontinuity = true;
305
- else if (line.startsWith("#EXT-X-MAP:")) {
306
- const attrs = parseAttributes(line.slice(11));
307
- if (attrs.URI) state.currentMapUri = resolveUri(attrs.URI, baseUrl);
308
- } else if (line.startsWith("#EXTINF:")) parseMediaExtinf(line, state);
309
- }
196
+ const HLS_MEDIA_TAGS = {
197
+ "#EXT-X-DISCONTINUITY": (_v, s) => {
198
+ s.nextDiscontinuity = true;
199
+ },
200
+ "#EXT-X-ENDLIST": (_v, s) => {
201
+ s.hasEndList = true;
202
+ },
203
+ "#EXT-X-MAP": (v, s, baseUrl) => {
204
+ const uri = parseAttributes(v).URI;
205
+ if (uri) s.currentMapUri = resolveUri(uri, baseUrl);
206
+ },
207
+ "#EXT-X-MEDIA-SEQUENCE": (v, s) => {
208
+ s.mediaSequence = parseNonNeg(v) ?? s.mediaSequence;
209
+ },
210
+ "#EXT-X-PLAYLIST-TYPE": (v, s) => {
211
+ const t = v.trim().toUpperCase();
212
+ if (t === "VOD" || t === "EVENT") s.playlistType = t;
213
+ },
214
+ "#EXT-X-TARGETDURATION": (v, s) => {
215
+ s.targetDurationSeconds = parseNonNeg(v) ?? s.targetDurationSeconds;
216
+ },
217
+ "#EXT-X-VERSION": (v, s) => {
218
+ s.version = parseNum(v);
219
+ },
220
+ "#EXTINF": (v, s) => {
221
+ const comma = v.indexOf(",");
222
+ s.pendingDuration = parseNonNeg(comma === -1 ? v : v.slice(0, comma)) ?? 0;
223
+ s.pendingTitle = (comma === -1 ? "" : v.slice(comma + 1).trim()) || void 0;
224
+ }
225
+ };
310
226
  function parseHlsMedia(lines, baseUrl) {
311
- const state = {
227
+ const s = {
312
228
  hasEndList: false,
313
229
  mediaSequence: 0,
314
230
  nextDiscontinuity: false,
315
- segments: [],
316
231
  targetDurationSeconds: 0
317
232
  };
318
- for (const line of lines) {
319
- if (line.startsWith("#")) {
320
- handleHlsMediaTag(line, state, baseUrl);
321
- continue;
322
- }
323
- if (state.pendingDuration !== void 0) {
324
- state.segments.push({
325
- discontinuity: state.nextDiscontinuity,
326
- durationSeconds: state.pendingDuration,
327
- mapUri: state.currentMapUri,
328
- sequence: state.mediaSequence + state.segments.length,
329
- title: state.pendingTitle,
330
- url: resolveUri(line, baseUrl)
331
- });
332
- state.pendingDuration = void 0;
333
- state.pendingTitle = void 0;
334
- state.nextDiscontinuity = false;
335
- }
233
+ const segments = [];
234
+ for (const line of lines) if (line.startsWith("#")) {
235
+ const [tag, val] = splitTag(line);
236
+ HLS_MEDIA_TAGS[tag]?.(val, s, baseUrl);
237
+ } else if (s.pendingDuration !== void 0) {
238
+ segments.push({
239
+ discontinuity: s.nextDiscontinuity,
240
+ durationSeconds: s.pendingDuration,
241
+ mapUri: s.currentMapUri,
242
+ sequence: s.mediaSequence + segments.length,
243
+ title: s.pendingTitle,
244
+ url: resolveUri(line, baseUrl)
245
+ });
246
+ s.pendingDuration = void 0;
247
+ s.pendingTitle = void 0;
248
+ s.nextDiscontinuity = false;
336
249
  }
337
- const isLive = !state.hasEndList && state.playlistType !== "VOD";
250
+ const isLive = !s.hasEndList && s.playlistType !== "VOD";
338
251
  return {
339
- cacheTtlMs: isLive ? state.targetDurationSeconds * 500 : Number.POSITIVE_INFINITY,
340
- hasEndList: state.hasEndList,
252
+ cacheTtlMs: isLive ? s.targetDurationSeconds * 500 : Number.POSITIVE_INFINITY,
253
+ hasEndList: s.hasEndList,
341
254
  isLive,
342
255
  kind: "media",
343
- mediaSequence: state.mediaSequence,
344
- playlistType: state.playlistType,
345
- segments: state.segments,
346
- targetDurationSeconds: state.targetDurationSeconds,
347
- version: state.version
256
+ mediaSequence: s.mediaSequence,
257
+ playlistType: s.playlistType,
258
+ segments,
259
+ targetDurationSeconds: s.targetDurationSeconds,
260
+ version: s.version
348
261
  };
349
262
  }
350
- /**
351
- * Pure-TS RFC 8216 HLS manifest parser supporting Master playlists
352
- * (`#EXT-X-STREAM-INF`, `#EXT-X-MEDIA`) and Media playlists (VOD/EVENT/Live).
353
- */
354
263
  function parseHlsManifest(content, baseUrl) {
355
264
  const lines = splitLines(content);
356
- return lines.some((line) => line.startsWith("#EXT-X-STREAM-INF:") || line.startsWith("#EXT-X-MEDIA:")) ? parseHlsMaster(lines, baseUrl) : parseHlsMedia(lines, baseUrl);
265
+ return lines.some((l) => l.startsWith("#EXT-X-STREAM-INF:") || l.startsWith("#EXT-X-MEDIA:")) ? parseHlsMaster(lines, baseUrl) : parseHlsMedia(lines, baseUrl);
357
266
  }
358
- // src/recognize/shazam-hanning.ts
359
- /*! @license
360
- MIT License
361
- Copyright (c) 2024 dotX12 (shazamio-core)
362
- Exact pre-rounded f32 2048-point Hanning window coefficients from shazamio-core
363
- commit d7608768ab274c1b149f0d9086b75db2e661b9bb.
364
- */
365
- const SHAZAM_HANNING_WINDOW = new Float32Array([
366
- 23508e-10,
367
- 94032e-10,
368
- 21157e-9,
369
- 37612e-9,
370
- 58769e-9,
371
- 84626e-9,
372
- 11518e-8,
373
- 15044e-8,
374
- 1904e-7,
375
- 23506e-8,
376
- 28442e-8,
377
- 33848e-8,
378
- 39723e-8,
379
- 46069e-8,
380
- 52884e-8,
381
- 60168e-8,
382
- 67923e-8,
383
- 76147e-8,
384
- 8484e-7,
385
- 94003e-8,
386
- .0010363,
387
- .0011374,
388
- .0012431,
389
- .0013535,
390
- .0014685,
391
- .0015883,
392
- .0017128,
393
- .0018419,
394
- .0019757,
395
- .0021142,
396
- .0022574,
397
- .0024053,
398
- .0025578,
399
- .0027151,
400
- .002877,
401
- .0030435,
402
- .0032148,
403
- .0033907,
404
- .0035713,
405
- .0037566,
406
- .0039465,
407
- .0041411,
408
- .0043403,
409
- .0045443,
410
- .0047528,
411
- .0049661,
412
- .0051839,
413
- .0054065,
414
- .0056337,
415
- .0058655,
416
- .006102,
417
- .0063431,
418
- .0065889,
419
- .0068393,
420
- .0070943,
421
- .007354,
422
- .0076183,
423
- .0078873,
424
- .0081608,
425
- .008439,
426
- .0087219,
427
- .0090093,
428
- .0093013,
429
- .009598,
430
- .0098993,
431
- .010205,
432
- .010516,
433
- .010831,
434
- .01115,
435
- .011475,
436
- .011804,
437
- .012137,
438
- .012475,
439
- .012818,
440
- .013165,
441
- .013517,
442
- .013873,
443
- .014234,
444
- .0146,
445
- .01497,
446
- .015344,
447
- .015724,
448
- .016107,
449
- .016496,
450
- .016889,
451
- .017286,
452
- .017688,
453
- .018094,
454
- .018505,
455
- .018921,
456
- .019341,
457
- .019766,
458
- .020195,
459
- .020628,
460
- .021066,
461
- .021509,
462
- .021956,
463
- .022408,
464
- .022864,
465
- .023324,
466
- .023789,
467
- .024259,
468
- .024733,
469
- .025211,
470
- .025694,
471
- .026182,
472
- .026674,
473
- .02717,
474
- .027671,
475
- .028176,
476
- .028686,
477
- .0292,
478
- .029718,
479
- .030241,
480
- .030768,
481
- .0313,
482
- .031836,
483
- .032377,
484
- .032922,
485
- .033471,
486
- .034025,
487
- .034583,
488
- .035146,
489
- .035712,
490
- .036284,
491
- .036859,
492
- .037439,
493
- .038024,
494
- .038612,
495
- .039205,
496
- .039803,
497
- .040404,
498
- .04101,
499
- .04162,
500
- .042235,
501
- .042854,
502
- .043477,
503
- .044105,
504
- .044736,
505
- .045372,
506
- .046013,
507
- .046657,
508
- .047306,
509
- .047959,
510
- .048617,
511
- .049278,
512
- .049944,
513
- .050614,
514
- .051288,
515
- .051967,
516
- .05265,
517
- .053337,
518
- .054028,
519
- .054723,
520
- .055423,
521
- .056126,
522
- .056834,
523
- .057546,
524
- .058263,
525
- .058983,
526
- .059707,
527
- .060436,
528
- .061169,
529
- .061906,
530
- .062647,
531
- .063392,
532
- .064141,
533
- .064895,
534
- .065652,
535
- .066413,
536
- .067179,
537
- .067949,
538
- .068722,
539
- .0695,
540
- .070282,
541
- .071068,
542
- .071858,
543
- .072652,
544
- .07345,
545
- .074252,
546
- .075058,
547
- .075868,
548
- .076682,
549
- .0775,
550
- .078321,
551
- .079147,
552
- .079977,
553
- .080811,
554
- .081649,
555
- .08249,
556
- .083336,
557
- .084185,
558
- .085039,
559
- .085896,
560
- .086757,
561
- .087622,
562
- .088491,
563
- .089364,
564
- .090241,
565
- .091121,
566
- .092006,
567
- .092894,
568
- .093786,
569
- .094682,
570
- .095582,
571
- .096485,
572
- .097392,
573
- .098303,
574
- .099218,
575
- .10014,
576
- .10106,
577
- .10199,
578
- .10292,
579
- .10385,
580
- .10479,
581
- .10573,
582
- .10667,
583
- .10762,
584
- .10857,
585
- .10953,
586
- .11049,
587
- .11145,
588
- .11242,
589
- .11339,
590
- .11436,
591
- .11534,
592
- .11632,
593
- .11731,
594
- .1183,
595
- .11929,
596
- .12028,
597
- .12128,
598
- .12228,
599
- .12329,
600
- .1243,
601
- .12531,
602
- .12633,
603
- .12735,
604
- .12838,
605
- .1294,
606
- .13043,
607
- .13147,
608
- .13251,
609
- .13355,
610
- .13459,
611
- .13564,
612
- .13669,
613
- .13775,
614
- .13881,
615
- .13987,
616
- .14093,
617
- .142,
618
- .14307,
619
- .14415,
620
- .14523,
621
- .14631,
622
- .1474,
623
- .14849,
624
- .14958,
625
- .15067,
626
- .15177,
627
- .15287,
628
- .15398,
629
- .15509,
630
- .1562,
631
- .15731,
632
- .15843,
633
- .15955,
634
- .16068,
635
- .1618,
636
- .16294,
637
- .16407,
638
- .16521,
639
- .16635,
640
- .16749,
641
- .16864,
642
- .16979,
643
- .17094,
644
- .1721,
645
- .17325,
646
- .17442,
647
- .17558,
648
- .17675,
649
- .17792,
650
- .1791,
651
- .18027,
652
- .18145,
653
- .18264,
654
- .18382,
655
- .18501,
656
- .1862,
657
- .1874,
658
- .1886,
659
- .1898,
660
- .191,
661
- .19221,
662
- .19342,
663
- .19463,
664
- .19585,
665
- .19707,
666
- .19829,
667
- .19951,
668
- .20074,
669
- .20197,
670
- .2032,
671
- .20444,
672
- .20567,
673
- .20691,
674
- .20816,
675
- .2094,
676
- .21065,
677
- .2119,
678
- .21316,
679
- .21442,
680
- .21568,
681
- .21694,
682
- .2182,
683
- .21947,
684
- .22074,
685
- .22202,
686
- .22329,
687
- .22457,
688
- .22585,
689
- .22713,
690
- .22842,
691
- .22971,
692
- .231,
693
- .23229,
694
- .23359,
695
- .23489,
696
- .23619,
697
- .23749,
698
- .2388,
699
- .24011,
700
- .24142,
701
- .24273,
702
- .24405,
703
- .24537,
704
- .24669,
705
- .24801,
706
- .24934,
707
- .25066,
708
- .25199,
709
- .25333,
710
- .25466,
711
- .256,
712
- .25734,
713
- .25868,
714
- .26002,
715
- .26137,
716
- .26272,
717
- .26407,
718
- .26542,
719
- .26678,
720
- .26813,
721
- .26949,
722
- .27086,
723
- .27222,
724
- .27359,
725
- .27495,
726
- .27632,
727
- .2777,
728
- .27907,
729
- .28045,
730
- .28183,
731
- .28321,
732
- .28459,
733
- .28597,
734
- .28736,
735
- .28875,
736
- .29014,
737
- .29153,
738
- .29293,
739
- .29432,
740
- .29572,
741
- .29712,
742
- .29852,
743
- .29993,
744
- .30133,
745
- .30274,
746
- .30415,
747
- .30556,
748
- .30698,
749
- .30839,
750
- .30981,
751
- .31123,
752
- .31265,
753
- .31407,
754
- .3155,
755
- .31692,
756
- .31835,
757
- .31978,
758
- .32121,
759
- .32264,
760
- .32408,
761
- .32551,
762
- .32695,
763
- .32839,
764
- .32983,
765
- .33127,
766
- .33272,
767
- .33416,
768
- .33561,
769
- .33706,
770
- .33851,
771
- .33996,
772
- .34141,
773
- .34287,
774
- .34433,
775
- .34578,
776
- .34724,
777
- .3487,
778
- .35017,
779
- .35163,
780
- .35309,
781
- .35456,
782
- .35603,
783
- .3575,
784
- .35897,
785
- .36044,
786
- .36191,
787
- .36339,
788
- .36486,
789
- .36634,
790
- .36782,
791
- .3693,
792
- .37078,
793
- .37226,
794
- .37374,
795
- .37522,
796
- .37671,
797
- .3782,
798
- .37968,
799
- .38117,
800
- .38266,
801
- .38415,
802
- .38565,
803
- .38714,
804
- .38863,
805
- .39013,
806
- .39162,
807
- .39312,
808
- .39462,
809
- .39612,
810
- .39762,
811
- .39912,
812
- .40062,
813
- .40213,
814
- .40363,
815
- .40513,
816
- .40664,
817
- .40815,
818
- .40965,
819
- .41116,
820
- .41267,
821
- .41418,
822
- .41569,
823
- .41721,
824
- .41872,
825
- .42023,
826
- .42174,
827
- .42326,
828
- .42478,
829
- .42629,
830
- .42781,
831
- .42933,
832
- .43084,
833
- .43236,
834
- .43388,
835
- .4354,
836
- .43692,
837
- .43844,
838
- .43997,
839
- .44149,
840
- .44301,
841
- .44453,
842
- .44606,
843
- .44758,
844
- .44911,
845
- .45063,
846
- .45216,
847
- .45369,
848
- .45521,
849
- .45674,
850
- .45827,
851
- .4598,
852
- .46132,
853
- .46285,
854
- .46438,
855
- .46591,
856
- .46744,
857
- .46897,
858
- .4705,
859
- .47203,
860
- .47356,
861
- .4751,
862
- .47663,
863
- .47816,
864
- .47969,
865
- .48122,
866
- .48275,
867
- .48429,
868
- .48582,
869
- .48735,
870
- .48888,
871
- .49042,
872
- .49195,
873
- .49348,
874
- .49502,
875
- .49655,
876
- .49808,
877
- .49962,
878
- .50115,
879
- .50268,
880
- .50422,
881
- .50575,
882
- .50728,
883
- .50882,
884
- .51035,
885
- .51188,
886
- .51341,
887
- .51495,
888
- .51648,
889
- .51801,
890
- .51954,
891
- .52108,
892
- .52261,
893
- .52414,
894
- .52567,
895
- .5272,
896
- .52873,
897
- .53026,
898
- .53179,
899
- .53332,
900
- .53485,
901
- .53638,
902
- .53791,
903
- .53944,
904
- .54097,
905
- .5425,
906
- .54402,
907
- .54555,
908
- .54708,
909
- .5486,
910
- .55013,
911
- .55165,
912
- .55318,
913
- .5547,
914
- .55623,
915
- .55775,
916
- .55927,
917
- .5608,
918
- .56232,
919
- .56384,
920
- .56536,
921
- .56688,
922
- .5684,
923
- .56992,
924
- .57143,
925
- .57295,
926
- .57447,
927
- .57598,
928
- .5775,
929
- .57901,
930
- .58053,
931
- .58204,
932
- .58355,
933
- .58506,
934
- .58657,
935
- .58808,
936
- .58959,
937
- .5911,
938
- .59261,
939
- .59411,
940
- .59562,
941
- .59712,
942
- .59863,
943
- .60013,
944
- .60163,
945
- .60313,
946
- .60463,
947
- .60613,
948
- .60763,
949
- .60912,
950
- .61062,
951
- .61211,
952
- .61361,
953
- .6151,
954
- .61659,
955
- .61808,
956
- .61957,
957
- .62106,
958
- .62255,
959
- .62403,
960
- .62552,
961
- .627,
962
- .62848,
963
- .62996,
964
- .63144,
965
- .63292,
966
- .6344,
967
- .63588,
968
- .63735,
969
- .63883,
970
- .6403,
971
- .64177,
972
- .64324,
973
- .64471,
974
- .64617,
975
- .64764,
976
- .6491,
977
- .65057,
978
- .65203,
979
- .65349,
980
- .65495,
981
- .6564,
982
- .65786,
983
- .65931,
984
- .66077,
985
- .66222,
986
- .66367,
987
- .66511,
988
- .66656,
989
- .668,
990
- .66945,
991
- .67089,
992
- .67233,
993
- .67377,
994
- .67521,
995
- .67664,
996
- .67807,
997
- .67951,
998
- .68094,
999
- .68236,
1000
- .68379,
1001
- .68522,
1002
- .68664,
1003
- .68806,
1004
- .68948,
1005
- .6909,
1006
- .69232,
1007
- .69373,
1008
- .69514,
1009
- .69655,
1010
- .69796,
1011
- .69937,
1012
- .70077,
1013
- .70218,
1014
- .70358,
1015
- .70498,
1016
- .70638,
1017
- .70777,
1018
- .70916,
1019
- .71056,
1020
- .71195,
1021
- .71333,
1022
- .71472,
1023
- .7161,
1024
- .71748,
1025
- .71886,
1026
- .72024,
1027
- .72162,
1028
- .72299,
1029
- .72436,
1030
- .72573,
1031
- .7271,
1032
- .72846,
1033
- .72983,
1034
- .73119,
1035
- .73254,
1036
- .7339,
1037
- .73525,
1038
- .73661,
1039
- .73796,
1040
- .7393,
1041
- .74065,
1042
- .74199,
1043
- .74333,
1044
- .74467,
1045
- .74601,
1046
- .74734,
1047
- .74867,
1048
- .75,
1049
- .75133,
1050
- .75265,
1051
- .75397,
1052
- .75529,
1053
- .75661,
1054
- .75792,
1055
- .75924,
1056
- .76055,
1057
- .76185,
1058
- .76316,
1059
- .76446,
1060
- .76576,
1061
- .76706,
1062
- .76835,
1063
- .76965,
1064
- .77094,
1065
- .77222,
1066
- .77351,
1067
- .77479,
1068
- .77607,
1069
- .77735,
1070
- .77862,
1071
- .77989,
1072
- .78116,
1073
- .78243,
1074
- .78369,
1075
- .78495,
1076
- .78621,
1077
- .78747,
1078
- .78872,
1079
- .78997,
1080
- .79122,
1081
- .79246,
1082
- .79371,
1083
- .79495,
1084
- .79618,
1085
- .79742,
1086
- .79865,
1087
- .79988,
1088
- .8011,
1089
- .80232,
1090
- .80354,
1091
- .80476,
1092
- .80597,
1093
- .80719,
1094
- .80839,
1095
- .8096,
1096
- .8108,
1097
- .812,
1098
- .8132,
1099
- .81439,
1100
- .81558,
1101
- .81677,
1102
- .81796,
1103
- .81914,
1104
- .82032,
1105
- .82149,
1106
- .82266,
1107
- .82383,
1108
- .825,
1109
- .82616,
1110
- .82732,
1111
- .82848,
1112
- .82964,
1113
- .83079,
1114
- .83194,
1115
- .83308,
1116
- .83422,
1117
- .83536,
1118
- .8365,
1119
- .83763,
1120
- .83876,
1121
- .83989,
1122
- .84101,
1123
- .84213,
1124
- .84324,
1125
- .84436,
1126
- .84547,
1127
- .84657,
1128
- .84768,
1129
- .84878,
1130
- .84988,
1131
- .85097,
1132
- .85206,
1133
- .85315,
1134
- .85423,
1135
- .85531,
1136
- .85639,
1137
- .85746,
1138
- .85853,
1139
- .8596,
1140
- .86066,
1141
- .86172,
1142
- .86278,
1143
- .86383,
1144
- .86488,
1145
- .86593,
1146
- .86697,
1147
- .86801,
1148
- .86905,
1149
- .87008,
1150
- .87111,
1151
- .87214,
1152
- .87316,
1153
- .87418,
1154
- .87519,
1155
- .8762,
1156
- .87721,
1157
- .87822,
1158
- .87922,
1159
- .88022,
1160
- .88121,
1161
- .8822,
1162
- .88319,
1163
- .88417,
1164
- .88515,
1165
- .88613,
1166
- .8871,
1167
- .88807,
1168
- .88903,
1169
- .88999,
1170
- .89095,
1171
- .8919,
1172
- .89285,
1173
- .8938,
1174
- .89474,
1175
- .89568,
1176
- .89662,
1177
- .89755,
1178
- .89848,
1179
- .8994,
1180
- .90032,
1181
- .90124,
1182
- .90215,
1183
- .90306,
1184
- .90397,
1185
- .90487,
1186
- .90577,
1187
- .90666,
1188
- .90755,
1189
- .90844,
1190
- .90932,
1191
- .9102,
1192
- .91107,
1193
- .91194,
1194
- .91281,
1195
- .91367,
1196
- .91453,
1197
- .91539,
1198
- .91624,
1199
- .91709,
1200
- .91793,
1201
- .91877,
1202
- .91961,
1203
- .92044,
1204
- .92127,
1205
- .92209,
1206
- .92291,
1207
- .92373,
1208
- .92454,
1209
- .92535,
1210
- .92615,
1211
- .92695,
1212
- .92775,
1213
- .92854,
1214
- .92933,
1215
- .93011,
1216
- .93089,
1217
- .93166,
1218
- .93244,
1219
- .9332,
1220
- .93397,
1221
- .93473,
1222
- .93548,
1223
- .93623,
1224
- .93698,
1225
- .93772,
1226
- .93846,
1227
- .9392,
1228
- .93993,
1229
- .94066,
1230
- .94138,
1231
- .9421,
1232
- .94281,
1233
- .94352,
1234
- .94423,
1235
- .94493,
1236
- .94563,
1237
- .94632,
1238
- .94701,
1239
- .94769,
1240
- .94837,
1241
- .94905,
1242
- .94972,
1243
- .95039,
1244
- .95105,
1245
- .95171,
1246
- .95237,
1247
- .95302,
1248
- .95367,
1249
- .95431,
1250
- .95495,
1251
- .95558,
1252
- .95621,
1253
- .95684,
1254
- .95746,
1255
- .95807,
1256
- .95869,
1257
- .95929,
1258
- .9599,
1259
- .9605,
1260
- .96109,
1261
- .96168,
1262
- .96227,
1263
- .96285,
1264
- .96343,
1265
- .964,
1266
- .96457,
1267
- .96514,
1268
- .9657,
1269
- .96625,
1270
- .9668,
1271
- .96735,
1272
- .96789,
1273
- .96843,
1274
- .96897,
1275
- .9695,
1276
- .97002,
1277
- .97054,
1278
- .97106,
1279
- .97157,
1280
- .97208,
1281
- .97258,
1282
- .97308,
1283
- .97357,
1284
- .97406,
1285
- .97455,
1286
- .97503,
1287
- .9755,
1288
- .97598,
1289
- .97644,
1290
- .97691,
1291
- .97736,
1292
- .97782,
1293
- .97827,
1294
- .97871,
1295
- .97915,
1296
- .97959,
1297
- .98002,
1298
- .98045,
1299
- .98087,
1300
- .98129,
1301
- .9817,
1302
- .98211,
1303
- .98251,
1304
- .98291,
1305
- .98331,
1306
- .9837,
1307
- .98409,
1308
- .98447,
1309
- .98484,
1310
- .98522,
1311
- .98558,
1312
- .98595,
1313
- .98631,
1314
- .98666,
1315
- .98701,
1316
- .98735,
1317
- .98769,
1318
- .98803,
1319
- .98836,
1320
- .98869,
1321
- .98901,
1322
- .98933,
1323
- .98964,
1324
- .98995,
1325
- .99025,
1326
- .99055,
1327
- .99085,
1328
- .99114,
1329
- .99142,
1330
- .9917,
1331
- .99198,
1332
- .99225,
1333
- .99251,
1334
- .99278,
1335
- .99303,
1336
- .99329,
1337
- .99353,
1338
- .99378,
1339
- .99402,
1340
- .99425,
1341
- .99448,
1342
- .99471,
1343
- .99493,
1344
- .99514,
1345
- .99535,
1346
- .99556,
1347
- .99576,
1348
- .99596,
1349
- .99615,
1350
- .99634,
1351
- .99652,
1352
- .9967,
1353
- .99687,
1354
- .99704,
1355
- .9972,
1356
- .99736,
1357
- .99752,
1358
- .99767,
1359
- .99781,
1360
- .99796,
1361
- .99809,
1362
- .99822,
1363
- .99835,
1364
- .99847,
1365
- .99859,
1366
- .9987,
1367
- .99881,
1368
- .99891,
1369
- .99901,
1370
- .99911,
1371
- .9992,
1372
- .99928,
1373
- .99936,
1374
- .99944,
1375
- .99951,
1376
- .99957,
1377
- .99963,
1378
- .99969,
1379
- .99974,
1380
- .99979,
1381
- .99983,
1382
- .99987,
1383
- .9999,
1384
- .99993,
1385
- .99995,
1386
- .99997,
1387
- .99999,
1388
- .99999,
1389
- 1,
1390
- 1,
1391
- .99999,
1392
- .99999,
1393
- .99997,
1394
- .99995,
1395
- .99993,
1396
- .9999,
1397
- .99987,
1398
- .99983,
1399
- .99979,
1400
- .99974,
1401
- .99969,
1402
- .99963,
1403
- .99957,
1404
- .99951,
1405
- .99944,
1406
- .99936,
1407
- .99928,
1408
- .9992,
1409
- .99911,
1410
- .99901,
1411
- .99891,
1412
- .99881,
1413
- .9987,
1414
- .99859,
1415
- .99847,
1416
- .99835,
1417
- .99822,
1418
- .99809,
1419
- .99796,
1420
- .99781,
1421
- .99767,
1422
- .99752,
1423
- .99736,
1424
- .9972,
1425
- .99704,
1426
- .99687,
1427
- .9967,
1428
- .99652,
1429
- .99634,
1430
- .99615,
1431
- .99596,
1432
- .99576,
1433
- .99556,
1434
- .99535,
1435
- .99514,
1436
- .99493,
1437
- .99471,
1438
- .99448,
1439
- .99425,
1440
- .99402,
1441
- .99378,
1442
- .99353,
1443
- .99329,
1444
- .99303,
1445
- .99278,
1446
- .99251,
1447
- .99225,
1448
- .99198,
1449
- .9917,
1450
- .99142,
1451
- .99114,
1452
- .99085,
1453
- .99055,
1454
- .99025,
1455
- .98995,
1456
- .98964,
1457
- .98933,
1458
- .98901,
1459
- .98869,
1460
- .98836,
1461
- .98803,
1462
- .98769,
1463
- .98735,
1464
- .98701,
1465
- .98666,
1466
- .98631,
1467
- .98595,
1468
- .98558,
1469
- .98522,
1470
- .98484,
1471
- .98447,
1472
- .98409,
1473
- .9837,
1474
- .98331,
1475
- .98291,
1476
- .98251,
1477
- .98211,
1478
- .9817,
1479
- .98129,
1480
- .98087,
1481
- .98045,
1482
- .98002,
1483
- .97959,
1484
- .97915,
1485
- .97871,
1486
- .97827,
1487
- .97782,
1488
- .97736,
1489
- .97691,
1490
- .97644,
1491
- .97598,
1492
- .9755,
1493
- .97503,
1494
- .97455,
1495
- .97406,
1496
- .97357,
1497
- .97308,
1498
- .97258,
1499
- .97208,
1500
- .97157,
1501
- .97106,
1502
- .97054,
1503
- .97002,
1504
- .9695,
1505
- .96897,
1506
- .96843,
1507
- .96789,
1508
- .96735,
1509
- .9668,
1510
- .96625,
1511
- .9657,
1512
- .96514,
1513
- .96457,
1514
- .964,
1515
- .96343,
1516
- .96285,
1517
- .96227,
1518
- .96168,
1519
- .96109,
1520
- .9605,
1521
- .9599,
1522
- .95929,
1523
- .95869,
1524
- .95807,
1525
- .95746,
1526
- .95684,
1527
- .95621,
1528
- .95558,
1529
- .95495,
1530
- .95431,
1531
- .95367,
1532
- .95302,
1533
- .95237,
1534
- .95171,
1535
- .95105,
1536
- .95039,
1537
- .94972,
1538
- .94905,
1539
- .94837,
1540
- .94769,
1541
- .94701,
1542
- .94632,
1543
- .94563,
1544
- .94493,
1545
- .94423,
1546
- .94352,
1547
- .94281,
1548
- .9421,
1549
- .94138,
1550
- .94066,
1551
- .93993,
1552
- .9392,
1553
- .93846,
1554
- .93772,
1555
- .93698,
1556
- .93623,
1557
- .93548,
1558
- .93473,
1559
- .93397,
1560
- .9332,
1561
- .93244,
1562
- .93166,
1563
- .93089,
1564
- .93011,
1565
- .92933,
1566
- .92854,
1567
- .92775,
1568
- .92695,
1569
- .92615,
1570
- .92535,
1571
- .92454,
1572
- .92373,
1573
- .92291,
1574
- .92209,
1575
- .92127,
1576
- .92044,
1577
- .91961,
1578
- .91877,
1579
- .91793,
1580
- .91709,
1581
- .91624,
1582
- .91539,
1583
- .91453,
1584
- .91367,
1585
- .91281,
1586
- .91194,
1587
- .91107,
1588
- .9102,
1589
- .90932,
1590
- .90844,
1591
- .90755,
1592
- .90666,
1593
- .90577,
1594
- .90487,
1595
- .90397,
1596
- .90306,
1597
- .90215,
1598
- .90124,
1599
- .90032,
1600
- .8994,
1601
- .89848,
1602
- .89755,
1603
- .89662,
1604
- .89568,
1605
- .89474,
1606
- .8938,
1607
- .89285,
1608
- .8919,
1609
- .89095,
1610
- .88999,
1611
- .88903,
1612
- .88807,
1613
- .8871,
1614
- .88613,
1615
- .88515,
1616
- .88417,
1617
- .88319,
1618
- .8822,
1619
- .88121,
1620
- .88022,
1621
- .87922,
1622
- .87822,
1623
- .87721,
1624
- .8762,
1625
- .87519,
1626
- .87418,
1627
- .87316,
1628
- .87214,
1629
- .87111,
1630
- .87008,
1631
- .86905,
1632
- .86801,
1633
- .86697,
1634
- .86593,
1635
- .86488,
1636
- .86383,
1637
- .86278,
1638
- .86172,
1639
- .86066,
1640
- .8596,
1641
- .85853,
1642
- .85746,
1643
- .85639,
1644
- .85531,
1645
- .85423,
1646
- .85315,
1647
- .85206,
1648
- .85097,
1649
- .84988,
1650
- .84878,
1651
- .84768,
1652
- .84657,
1653
- .84547,
1654
- .84436,
1655
- .84324,
1656
- .84213,
1657
- .84101,
1658
- .83989,
1659
- .83876,
1660
- .83763,
1661
- .8365,
1662
- .83536,
1663
- .83422,
1664
- .83308,
1665
- .83194,
1666
- .83079,
1667
- .82964,
1668
- .82848,
1669
- .82732,
1670
- .82616,
1671
- .825,
1672
- .82383,
1673
- .82266,
1674
- .82149,
1675
- .82032,
1676
- .81914,
1677
- .81796,
1678
- .81677,
1679
- .81558,
1680
- .81439,
1681
- .8132,
1682
- .812,
1683
- .8108,
1684
- .8096,
1685
- .80839,
1686
- .80719,
1687
- .80597,
1688
- .80476,
1689
- .80354,
1690
- .80232,
1691
- .8011,
1692
- .79988,
1693
- .79865,
1694
- .79742,
1695
- .79618,
1696
- .79495,
1697
- .79371,
1698
- .79246,
1699
- .79122,
1700
- .78997,
1701
- .78872,
1702
- .78747,
1703
- .78621,
1704
- .78495,
1705
- .78369,
1706
- .78243,
1707
- .78116,
1708
- .77989,
1709
- .77862,
1710
- .77735,
1711
- .77607,
1712
- .77479,
1713
- .77351,
1714
- .77222,
1715
- .77094,
1716
- .76965,
1717
- .76835,
1718
- .76706,
1719
- .76576,
1720
- .76446,
1721
- .76316,
1722
- .76185,
1723
- .76055,
1724
- .75924,
1725
- .75792,
1726
- .75661,
1727
- .75529,
1728
- .75397,
1729
- .75265,
1730
- .75133,
1731
- .75,
1732
- .74867,
1733
- .74734,
1734
- .74601,
1735
- .74467,
1736
- .74333,
1737
- .74199,
1738
- .74065,
1739
- .7393,
1740
- .73796,
1741
- .73661,
1742
- .73525,
1743
- .7339,
1744
- .73254,
1745
- .73119,
1746
- .72983,
1747
- .72846,
1748
- .7271,
1749
- .72573,
1750
- .72436,
1751
- .72299,
1752
- .72162,
1753
- .72024,
1754
- .71886,
1755
- .71748,
1756
- .7161,
1757
- .71472,
1758
- .71333,
1759
- .71195,
1760
- .71056,
1761
- .70916,
1762
- .70777,
1763
- .70638,
1764
- .70498,
1765
- .70358,
1766
- .70218,
1767
- .70077,
1768
- .69937,
1769
- .69796,
1770
- .69655,
1771
- .69514,
1772
- .69373,
1773
- .69232,
1774
- .6909,
1775
- .68948,
1776
- .68806,
1777
- .68664,
1778
- .68522,
1779
- .68379,
1780
- .68236,
1781
- .68094,
1782
- .67951,
1783
- .67807,
1784
- .67664,
1785
- .67521,
1786
- .67377,
1787
- .67233,
1788
- .67089,
1789
- .66945,
1790
- .668,
1791
- .66656,
1792
- .66511,
1793
- .66367,
1794
- .66222,
1795
- .66077,
1796
- .65931,
1797
- .65786,
1798
- .6564,
1799
- .65495,
1800
- .65349,
1801
- .65203,
1802
- .65057,
1803
- .6491,
1804
- .64764,
1805
- .64617,
1806
- .64471,
1807
- .64324,
1808
- .64177,
1809
- .6403,
1810
- .63883,
1811
- .63735,
1812
- .63588,
1813
- .6344,
1814
- .63292,
1815
- .63144,
1816
- .62996,
1817
- .62848,
1818
- .627,
1819
- .62552,
1820
- .62403,
1821
- .62255,
1822
- .62106,
1823
- .61957,
1824
- .61808,
1825
- .61659,
1826
- .6151,
1827
- .61361,
1828
- .61211,
1829
- .61062,
1830
- .60912,
1831
- .60763,
1832
- .60613,
1833
- .60463,
1834
- .60313,
1835
- .60163,
1836
- .60013,
1837
- .59863,
1838
- .59712,
1839
- .59562,
1840
- .59411,
1841
- .59261,
1842
- .5911,
1843
- .58959,
1844
- .58808,
1845
- .58657,
1846
- .58506,
1847
- .58355,
1848
- .58204,
1849
- .58053,
1850
- .57901,
1851
- .5775,
1852
- .57598,
1853
- .57447,
1854
- .57295,
1855
- .57143,
1856
- .56992,
1857
- .5684,
1858
- .56688,
1859
- .56536,
1860
- .56384,
1861
- .56232,
1862
- .5608,
1863
- .55927,
1864
- .55775,
1865
- .55623,
1866
- .5547,
1867
- .55318,
1868
- .55165,
1869
- .55013,
1870
- .5486,
1871
- .54708,
1872
- .54555,
1873
- .54402,
1874
- .5425,
1875
- .54097,
1876
- .53944,
1877
- .53791,
1878
- .53638,
1879
- .53485,
1880
- .53332,
1881
- .53179,
1882
- .53026,
1883
- .52873,
1884
- .5272,
1885
- .52567,
1886
- .52414,
1887
- .52261,
1888
- .52108,
1889
- .51954,
1890
- .51801,
1891
- .51648,
1892
- .51495,
1893
- .51341,
1894
- .51188,
1895
- .51035,
1896
- .50882,
1897
- .50728,
1898
- .50575,
1899
- .50422,
1900
- .50268,
1901
- .50115,
1902
- .49962,
1903
- .49808,
1904
- .49655,
1905
- .49502,
1906
- .49348,
1907
- .49195,
1908
- .49042,
1909
- .48888,
1910
- .48735,
1911
- .48582,
1912
- .48429,
1913
- .48275,
1914
- .48122,
1915
- .47969,
1916
- .47816,
1917
- .47663,
1918
- .4751,
1919
- .47356,
1920
- .47203,
1921
- .4705,
1922
- .46897,
1923
- .46744,
1924
- .46591,
1925
- .46438,
1926
- .46285,
1927
- .46132,
1928
- .4598,
1929
- .45827,
1930
- .45674,
1931
- .45521,
1932
- .45369,
1933
- .45216,
1934
- .45063,
1935
- .44911,
1936
- .44758,
1937
- .44606,
1938
- .44453,
1939
- .44301,
1940
- .44149,
1941
- .43997,
1942
- .43844,
1943
- .43692,
1944
- .4354,
1945
- .43388,
1946
- .43236,
1947
- .43084,
1948
- .42933,
1949
- .42781,
1950
- .42629,
1951
- .42478,
1952
- .42326,
1953
- .42174,
1954
- .42023,
1955
- .41872,
1956
- .41721,
1957
- .41569,
1958
- .41418,
1959
- .41267,
1960
- .41116,
1961
- .40965,
1962
- .40815,
1963
- .40664,
1964
- .40513,
1965
- .40363,
1966
- .40213,
1967
- .40062,
1968
- .39912,
1969
- .39762,
1970
- .39612,
1971
- .39462,
1972
- .39312,
1973
- .39162,
1974
- .39013,
1975
- .38863,
1976
- .38714,
1977
- .38565,
1978
- .38415,
1979
- .38266,
1980
- .38117,
1981
- .37968,
1982
- .3782,
1983
- .37671,
1984
- .37522,
1985
- .37374,
1986
- .37226,
1987
- .37078,
1988
- .3693,
1989
- .36782,
1990
- .36634,
1991
- .36486,
1992
- .36339,
1993
- .36191,
1994
- .36044,
1995
- .35897,
1996
- .3575,
1997
- .35603,
1998
- .35456,
1999
- .35309,
2000
- .35163,
2001
- .35017,
2002
- .3487,
2003
- .34724,
2004
- .34578,
2005
- .34433,
2006
- .34287,
2007
- .34141,
2008
- .33996,
2009
- .33851,
2010
- .33706,
2011
- .33561,
2012
- .33416,
2013
- .33272,
2014
- .33127,
2015
- .32983,
2016
- .32839,
2017
- .32695,
2018
- .32551,
2019
- .32408,
2020
- .32264,
2021
- .32121,
2022
- .31978,
2023
- .31835,
2024
- .31692,
2025
- .3155,
2026
- .31407,
2027
- .31265,
2028
- .31123,
2029
- .30981,
2030
- .30839,
2031
- .30698,
2032
- .30556,
2033
- .30415,
2034
- .30274,
2035
- .30133,
2036
- .29993,
2037
- .29852,
2038
- .29712,
2039
- .29572,
2040
- .29432,
2041
- .29293,
2042
- .29153,
2043
- .29014,
2044
- .28875,
2045
- .28736,
2046
- .28597,
2047
- .28459,
2048
- .28321,
2049
- .28183,
2050
- .28045,
2051
- .27907,
2052
- .2777,
2053
- .27632,
2054
- .27495,
2055
- .27359,
2056
- .27222,
2057
- .27086,
2058
- .26949,
2059
- .26813,
2060
- .26678,
2061
- .26542,
2062
- .26407,
2063
- .26272,
2064
- .26137,
2065
- .26002,
2066
- .25868,
2067
- .25734,
2068
- .256,
2069
- .25466,
2070
- .25333,
2071
- .25199,
2072
- .25066,
2073
- .24934,
2074
- .24801,
2075
- .24669,
2076
- .24537,
2077
- .24405,
2078
- .24273,
2079
- .24142,
2080
- .24011,
2081
- .2388,
2082
- .23749,
2083
- .23619,
2084
- .23489,
2085
- .23359,
2086
- .23229,
2087
- .231,
2088
- .22971,
2089
- .22842,
2090
- .22713,
2091
- .22585,
2092
- .22457,
2093
- .22329,
2094
- .22202,
2095
- .22074,
2096
- .21947,
2097
- .2182,
2098
- .21694,
2099
- .21568,
2100
- .21442,
2101
- .21316,
2102
- .2119,
2103
- .21065,
2104
- .2094,
2105
- .20816,
2106
- .20691,
2107
- .20567,
2108
- .20444,
2109
- .2032,
2110
- .20197,
2111
- .20074,
2112
- .19951,
2113
- .19829,
2114
- .19707,
2115
- .19585,
2116
- .19463,
2117
- .19342,
2118
- .19221,
2119
- .191,
2120
- .1898,
2121
- .1886,
2122
- .1874,
2123
- .1862,
2124
- .18501,
2125
- .18382,
2126
- .18264,
2127
- .18145,
2128
- .18027,
2129
- .1791,
2130
- .17792,
2131
- .17675,
2132
- .17558,
2133
- .17442,
2134
- .17325,
2135
- .1721,
2136
- .17094,
2137
- .16979,
2138
- .16864,
2139
- .16749,
2140
- .16635,
2141
- .16521,
2142
- .16407,
2143
- .16294,
2144
- .1618,
2145
- .16068,
2146
- .15955,
2147
- .15843,
2148
- .15731,
2149
- .1562,
2150
- .15509,
2151
- .15398,
2152
- .15287,
2153
- .15177,
2154
- .15067,
2155
- .14958,
2156
- .14849,
2157
- .1474,
2158
- .14631,
2159
- .14523,
2160
- .14415,
2161
- .14307,
2162
- .142,
2163
- .14093,
2164
- .13987,
2165
- .13881,
2166
- .13775,
2167
- .13669,
2168
- .13564,
2169
- .13459,
2170
- .13355,
2171
- .13251,
2172
- .13147,
2173
- .13043,
2174
- .1294,
2175
- .12838,
2176
- .12735,
2177
- .12633,
2178
- .12531,
2179
- .1243,
2180
- .12329,
2181
- .12228,
2182
- .12128,
2183
- .12028,
2184
- .11929,
2185
- .1183,
2186
- .11731,
2187
- .11632,
2188
- .11534,
2189
- .11436,
2190
- .11339,
2191
- .11242,
2192
- .11145,
2193
- .11049,
2194
- .10953,
2195
- .10857,
2196
- .10762,
2197
- .10667,
2198
- .10573,
2199
- .10479,
2200
- .10385,
2201
- .10292,
2202
- .10199,
2203
- .10106,
2204
- .10014,
2205
- .099218,
2206
- .098303,
2207
- .097392,
2208
- .096485,
2209
- .095582,
2210
- .094682,
2211
- .093786,
2212
- .092894,
2213
- .092006,
2214
- .091121,
2215
- .090241,
2216
- .089364,
2217
- .088491,
2218
- .087622,
2219
- .086757,
2220
- .085896,
2221
- .085039,
2222
- .084185,
2223
- .083336,
2224
- .08249,
2225
- .081649,
2226
- .080811,
2227
- .079977,
2228
- .079147,
2229
- .078321,
2230
- .0775,
2231
- .076682,
2232
- .075868,
2233
- .075058,
2234
- .074252,
2235
- .07345,
2236
- .072652,
2237
- .071858,
2238
- .071068,
2239
- .070282,
2240
- .0695,
2241
- .068722,
2242
- .067949,
2243
- .067179,
2244
- .066413,
2245
- .065652,
2246
- .064895,
2247
- .064141,
2248
- .063392,
2249
- .062647,
2250
- .061906,
2251
- .061169,
2252
- .060436,
2253
- .059707,
2254
- .058983,
2255
- .058263,
2256
- .057546,
2257
- .056834,
2258
- .056126,
2259
- .055423,
2260
- .054723,
2261
- .054028,
2262
- .053337,
2263
- .05265,
2264
- .051967,
2265
- .051288,
2266
- .050614,
2267
- .049944,
2268
- .049278,
2269
- .048617,
2270
- .047959,
2271
- .047306,
2272
- .046657,
2273
- .046013,
2274
- .045372,
2275
- .044736,
2276
- .044105,
2277
- .043477,
2278
- .042854,
2279
- .042235,
2280
- .04162,
2281
- .04101,
2282
- .040404,
2283
- .039803,
2284
- .039205,
2285
- .038612,
2286
- .038024,
2287
- .037439,
2288
- .036859,
2289
- .036284,
2290
- .035712,
2291
- .035146,
2292
- .034583,
2293
- .034025,
2294
- .033471,
2295
- .032922,
2296
- .032377,
2297
- .031836,
2298
- .0313,
2299
- .030768,
2300
- .030241,
2301
- .029718,
2302
- .0292,
2303
- .028686,
2304
- .028176,
2305
- .027671,
2306
- .02717,
2307
- .026674,
2308
- .026182,
2309
- .025694,
2310
- .025211,
2311
- .024733,
2312
- .024259,
2313
- .023789,
2314
- .023324,
2315
- .022864,
2316
- .022408,
2317
- .021956,
2318
- .021509,
2319
- .021066,
2320
- .020628,
2321
- .020195,
2322
- .019766,
2323
- .019341,
2324
- .018921,
2325
- .018505,
2326
- .018094,
2327
- .017688,
2328
- .017286,
2329
- .016889,
2330
- .016496,
2331
- .016107,
2332
- .015724,
2333
- .015344,
2334
- .01497,
2335
- .0146,
2336
- .014234,
2337
- .013873,
2338
- .013517,
2339
- .013165,
2340
- .012818,
2341
- .012475,
2342
- .012137,
2343
- .011804,
2344
- .011475,
2345
- .01115,
2346
- .010831,
2347
- .010516,
2348
- .010205,
2349
- .0098993,
2350
- .009598,
2351
- .0093013,
2352
- .0090093,
2353
- .0087219,
2354
- .008439,
2355
- .0081608,
2356
- .0078873,
2357
- .0076183,
2358
- .007354,
2359
- .0070943,
2360
- .0068393,
2361
- .0065889,
2362
- .0063431,
2363
- .006102,
2364
- .0058655,
2365
- .0056337,
2366
- .0054065,
2367
- .0051839,
2368
- .0049661,
2369
- .0047528,
2370
- .0045443,
2371
- .0043403,
2372
- .0041411,
2373
- .0039465,
2374
- .0037566,
2375
- .0035713,
2376
- .0033907,
2377
- .0032148,
2378
- .0030435,
2379
- .002877,
2380
- .0027151,
2381
- .0025578,
2382
- .0024053,
2383
- .0022574,
2384
- .0021142,
2385
- .0019757,
2386
- .0018419,
2387
- .0017128,
2388
- .0015883,
2389
- .0014685,
2390
- .0013535,
2391
- .0012431,
2392
- .0011374,
2393
- .0010363,
2394
- 94003e-8,
2395
- 8484e-7,
2396
- 76147e-8,
2397
- 67923e-8,
2398
- 60168e-8,
2399
- 52884e-8,
2400
- 46069e-8,
2401
- 39723e-8,
2402
- 33848e-8,
2403
- 28442e-8,
2404
- 23506e-8,
2405
- 1904e-7,
2406
- 15044e-8,
2407
- 11518e-8,
2408
- 84626e-9,
2409
- 58769e-9,
2410
- 37612e-9,
2411
- 21157e-9,
2412
- 94032e-10,
2413
- 23508e-10
2414
- ]);
2415
- // src/recognize/shazam.ts
2416
- /*! @license
2417
- MIT License
2418
-
2419
- Copyright (c) 2024 dotX12 (shazamio-core)
2420
- Copyright (c) 2021 dotX12 (ShazamIO)
2421
- Copyright (c) 2017 Fedor Indutny (fft.js)
2422
-
2423
- Permission is hereby granted, free of charge, to any person obtaining a copy
2424
- of this software and associated documentation files (the "Software"), to deal
2425
- in the Software without restriction, including without limitation the rights
2426
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2427
- copies of the Software, and to permit persons to whom the Software is
2428
- furnished to do so, subject to the following conditions:
2429
-
2430
- The above copyright notice and this permission notice shall be included in all
2431
- copies or substantial portions of the Software.
2432
-
2433
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2434
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2435
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2436
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2437
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2438
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2439
- SOFTWARE.
2440
- */
2441
- const SHAZAM_SAMPLE_RATE = 16e3;
2442
- const SHAZAM_MAX_DURATION_SECONDS = 12;
2443
- const SHAZAM_MAX_SAMPLES = SHAZAM_SAMPLE_RATE * 12;
2444
- const SHAZAM_MAX_PCM_BYTES = SHAZAM_MAX_SAMPLES * 2;
2445
- const f32 = Math.fround;
2446
- const FREQUENCY_NEIGHBORS = [
2447
- -10,
2448
- -7,
2449
- -4,
2450
- -3,
2451
- 1,
2452
- 2,
2453
- 5,
2454
- 8
2455
- ];
2456
- const TIME_NEIGHBORS = [
2457
- -53,
2458
- -45,
2459
- 165,
2460
- 172,
2461
- 179,
2462
- 186,
2463
- 193,
2464
- 200,
2465
- 214,
2466
- 221,
2467
- 228,
2468
- 235,
2469
- 242,
2470
- 249
2471
- ];
2472
- const BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2473
- const WHITESPACE_REGEX = /[\r\n\s]/gu;
2474
- /**
2475
- * Pure-TS Uint8Array-to-base64 encoder (isomorphic, zero Node Buffer or DOM btoa dependency).
2476
- */
2477
- function bytesToBase64(bytes) {
2478
- const chunks = [];
2479
- const len = bytes.length;
2480
- for (let i = 0; i < len; i += 3) {
2481
- const b0 = bytes[i] ?? 0;
2482
- const b1 = i + 1 < len ? bytes[i + 1] ?? 0 : 0;
2483
- const b2 = i + 2 < len ? bytes[i + 2] ?? 0 : 0;
2484
- const triple = b0 << 16 | b1 << 8 | b2;
2485
- chunks.push(BASE64_ALPHABET[triple >>> 18 & 63] ?? "", BASE64_ALPHABET[triple >>> 12 & 63] ?? "", i + 1 < len ? BASE64_ALPHABET[triple >>> 6 & 63] ?? "" : "=", i + 2 < len ? BASE64_ALPHABET[triple & 63] ?? "" : "=");
2486
- }
2487
- return chunks.join("");
2488
- }
2489
- /**
2490
- * Pure-TS base64-to-Uint8Array decoder (isomorphic).
2491
- */
2492
- function base64ToBytes(base64) {
2493
- const clean = base64.replaceAll(WHITESPACE_REGEX, "");
2494
- let pad = 0;
2495
- if (clean.endsWith("==")) pad = 2;
2496
- else if (clean.endsWith("=")) pad = 1;
2497
- const outLen = Math.floor(clean.length * 3 / 4) - pad;
2498
- const out = new Uint8Array(Math.max(0, outLen));
2499
- let outIdx = 0;
2500
- for (let i = 0; i < clean.length; i += 4) {
2501
- const c0 = BASE64_ALPHABET.indexOf(clean[i] ?? "A");
2502
- const c1 = BASE64_ALPHABET.indexOf(clean[i + 1] ?? "A");
2503
- const c2 = clean[i + 2] === "=" ? 0 : BASE64_ALPHABET.indexOf(clean[i + 2] ?? "A");
2504
- const c3 = clean[i + 3] === "=" ? 0 : BASE64_ALPHABET.indexOf(clean[i + 3] ?? "A");
2505
- const triple = c0 << 18 | c1 << 12 | c2 << 6 | c3;
2506
- if (outIdx < outLen) {
2507
- out[outIdx] = triple >>> 16 & 255;
2508
- outIdx += 1;
2509
- }
2510
- if (outIdx < outLen) {
2511
- out[outIdx] = triple >>> 8 & 255;
2512
- outIdx += 1;
2513
- }
2514
- if (outIdx < outLen) {
2515
- out[outIdx] = triple & 255;
2516
- outIdx += 1;
2517
- }
2518
- }
2519
- return out;
2520
- }
2521
- /**
2522
- * Converts normalized mono Float32 samples `[-1, 1]` to signed 16-bit LE PCM bytes.
2523
- */
2524
- function float32ToPcm16Le(samples) {
2525
- const bytes = new Uint8Array(samples.length * 2);
2526
- const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
2527
- for (let i = 0; i < samples.length; i += 1) {
2528
- const clamped = Math.max(-1, Math.min(1, samples[i] ?? 0));
2529
- const int16 = clamped < 0 ? Math.round(clamped * 32768) : Math.round(clamped * 32767);
2530
- view.setInt16(i * 2, int16, true);
2531
- }
2532
- return bytes;
2533
- }
2534
- const BUTTERWORTH_4TH_Q = [.541196100146197, 1.3065629648763766];
2535
- const ANTI_ALIAS_CUTOFF_HZ = 6500;
2536
- /**
2537
- * Lightweight 4th-order Butterworth low-pass filter (two cascaded RBJ biquad
2538
- * stages) used before downsampling to suppress aliasing above 8 kHz Nyquist
2539
- * while keeping Shazam's 250–5500 Hz fingerprinting band flat.
2540
- */
2541
- function applyAntiAliasingLowPass(samples, sourceSampleRate, cutoffHz) {
2542
- const filtered = new Float32Array(samples);
2543
- const clampedCutoff = Math.max(100, Math.min(cutoffHz, sourceSampleRate * .45));
2544
- const w0 = 2 * Math.PI * clampedCutoff / sourceSampleRate;
2545
- const cosW0 = Math.cos(w0);
2546
- const sinW0 = Math.sin(w0);
2547
- for (const q of BUTTERWORTH_4TH_Q) {
2548
- const alpha = sinW0 / (2 * q);
2549
- const a0 = 1 + alpha;
2550
- const b0 = (1 - cosW0) / 2 / a0;
2551
- const b1 = (1 - cosW0) / a0;
2552
- const b2 = b0;
2553
- const a1 = -2 * cosW0 / a0;
2554
- const a2 = (1 - alpha) / a0;
2555
- let x1 = 0;
2556
- let x2 = 0;
2557
- let y1 = 0;
2558
- let y2 = 0;
2559
- for (let i = 0; i < filtered.length; i += 1) {
2560
- const x0 = filtered[i] ?? 0;
2561
- const y0 = b0 * x0 + b1 * x1 + b2 * x2 - a1 * y1 - a2 * y2;
2562
- x2 = x1;
2563
- x1 = x0;
2564
- y2 = y1;
2565
- y1 = y0;
2566
- filtered[i] = y0;
2567
- }
2568
- }
2569
- return filtered;
2570
- }
2571
- /**
2572
- * Anti-aliased mono resampler to 16 kHz for browser/worker callers starting
2573
- * from 44.1/48 kHz Float32 PCM. Applies a 4th-order Butterworth low-pass filter
2574
- * before downsampling to prevent high-frequency fold-back into Shazam bands.
2575
- */
2576
- function resampleMonoTo16kHz(samples, sourceSampleRate) {
2577
- if (!Number.isFinite(sourceSampleRate) || sourceSampleRate <= 0 || samples.length === 0) return /* @__PURE__ */ new Float32Array(0);
2578
- if (sourceSampleRate === 16e3) return new Float32Array(samples);
2579
- const source = sourceSampleRate > 16e3 ? applyAntiAliasingLowPass(samples, sourceSampleRate, ANTI_ALIAS_CUTOFF_HZ) : samples;
2580
- const ratio = sourceSampleRate / SHAZAM_SAMPLE_RATE;
2581
- const targetLength = Math.floor(source.length / ratio);
2582
- const output = new Float32Array(targetLength);
2583
- for (let i = 0; i < targetLength; i += 1) {
2584
- const srcPos = i * ratio;
2585
- const idx = Math.floor(srcPos);
2586
- const frac = srcPos - idx;
2587
- const s0 = source[idx] ?? 0;
2588
- const s1 = source[idx + 1] ?? s0;
2589
- output[i] = s0 + (s1 - s0) * frac;
2590
- }
2591
- return output;
2592
- }
2593
- /**
2594
- * Computes the Shazam parabolic sub-bin peak correction, returning `undefined`
2595
- * when `variation === 0` or non-finite to guard against division-by-zero
2596
- * (`NaN` / `±Infinity`).
2597
- */
2598
- function computePeakCorrection(before, peak, after) {
2599
- const variation = f32(f32(f32(peak * 2) - before) - after);
2600
- if (!Number.isFinite(variation) || variation === 0) return;
2601
- const correction = f32(f32(f32(after - before) * 32) / variation);
2602
- if (!Number.isFinite(correction)) return;
2603
- return Math.max(-0x80000000, Math.min(0x7fffffff, Math.trunc(correction)));
2604
- }
2605
- function logMagnitude(power) {
2606
- return f32(f32(Math.max(f32(Math.log(power)), 1 / 64) * f32(1477.3)) + 6144);
2607
- }
2608
- function bandForHz(hz) {
2609
- if (hz >= 250 && hz < 520) return 0;
2610
- if (hz >= 520 && hz < 1450) return 1;
2611
- if (hz >= 1450 && hz < 3500) return 2;
2612
- if (hz >= 3500 && hz <= 5500) return 3;
2613
- return -1;
2614
- }
2615
- function encodeSignatureBytes(peaks, samples) {
2616
- const parts = [];
2617
- let payloadByteLength = 0;
2618
- for (let band = 0; band < 4; band += 1) {
2619
- const entries = peaks[band];
2620
- if (!entries || entries.length === 0) continue;
2621
- const data = new Uint8Array(entries.length * 10);
2622
- const dataView = new DataView(data.buffer);
2623
- let offset = 0;
2624
- let previousPass = 0;
2625
- for (const peak of entries) {
2626
- if (peak.pass - previousPass >= 255) {
2627
- data[offset] = 255;
2628
- offset += 1;
2629
- dataView.setUint32(offset, peak.pass, true);
2630
- offset += 4;
2631
- previousPass = peak.pass;
2632
- }
2633
- data[offset] = peak.pass - previousPass;
2634
- offset += 1;
2635
- dataView.setUint16(offset, peak.magnitude, true);
2636
- dataView.setUint16(offset + 2, peak.bin, true);
2637
- offset += 4;
2638
- previousPass = peak.pass;
2639
- }
2640
- const bandHeader = /* @__PURE__ */ new Uint8Array(8);
2641
- const headerView = new DataView(bandHeader.buffer);
2642
- headerView.setUint32(0, 0x60030040 + band, true);
2643
- headerView.setUint32(4, offset, true);
2644
- const padLen = (4 - offset % 4) % 4;
2645
- parts.push(bandHeader, data.subarray(0, offset));
2646
- if (padLen > 0) parts.push(new Uint8Array(padLen));
2647
- payloadByteLength += 8 + offset + padLen;
2648
- }
2649
- const totalLength = 56 + payloadByteLength;
2650
- const binary = new Uint8Array(totalLength);
2651
- const view = new DataView(binary.buffer);
2652
- view.setUint32(0, 0xcafe2580, true);
2653
- view.setUint32(8, totalLength - 48, true);
2654
- view.setUint32(12, 0x94119c00, true);
2655
- view.setUint32(28, 3 << 27, true);
2656
- view.setUint32(40, samples + 3840, true);
2657
- view.setUint32(44, 8126464, true);
2658
- view.setUint32(48, 0x40000000, true);
2659
- view.setUint32(52, totalLength - 48, true);
2660
- let cursor = 56;
2661
- for (const part of parts) {
2662
- binary.set(part, cursor);
2663
- cursor += part.length;
2664
- }
2665
- view.setUint32(4, crc32(binary.subarray(8)), true);
2666
- return binary;
2667
- }
2668
- function normalizeInputToInt16(pcm) {
2669
- if (pcm instanceof Int16Array) {
2670
- if (pcm.length === 0 || pcm.length > 192e3) return { error: `Expected between 1 and ${SHAZAM_MAX_SAMPLES} mono 16 kHz samples (at most 12 s).` };
2671
- return { samples: pcm };
2672
- }
2673
- if (pcm.byteLength === 0 || pcm.byteLength % 2 !== 0 || pcm.byteLength > 384e3) return { error: `Expected at most 12 seconds of mono 16 kHz PCM16LE audio (${SHAZAM_MAX_PCM_BYTES} bytes).` };
2674
- const sampleCount = pcm.byteLength / 2;
2675
- const view = new DataView(pcm.buffer, pcm.byteOffset, pcm.byteLength);
2676
- const samples = new Int16Array(sampleCount);
2677
- for (let i = 0; i < sampleCount; i += 1) samples[i] = view.getInt16(i * 2, true);
2678
- return { samples };
2679
- }
2680
- function createWorkState(samples) {
2681
- return {
2682
- fft: new FFT(2048),
2683
- fftIndex: 0,
2684
- outputs: Array.from({ length: 256 }, () => /* @__PURE__ */ new Float32Array(1025)),
2685
- passes: 0,
2686
- peaks: [
2687
- [],
2688
- [],
2689
- [],
2690
- []
2691
- ],
2692
- ring: /* @__PURE__ */ new Int16Array(2048),
2693
- ringIndex: 0,
2694
- samples,
2695
- spectrum: /* @__PURE__ */ new Float64Array(4096),
2696
- spreadIndex: 0,
2697
- spreadOutputs: Array.from({ length: 256 }, () => /* @__PURE__ */ new Float32Array(1025)),
2698
- windowed: /* @__PURE__ */ new Float32Array(2048)
2699
- };
2700
- }
2701
- function spreadPower(state, power) {
2702
- const spread = state.spreadOutputs[state.spreadIndex];
2703
- if (!spread) return;
2704
- spread.set(power);
2705
- for (let index = 0; index <= 1022; index += 1) spread[index] = Math.max(spread[index] ?? 0, spread[index + 1] ?? 0, spread[index + 2] ?? 0);
2706
- for (const previous of [
2707
- 1,
2708
- 3,
2709
- 6
2710
- ]) {
2711
- const earlier = state.spreadOutputs[state.spreadIndex - previous & 255];
2712
- if (!earlier) continue;
2713
- for (let index = 0; index <= 1024; index += 1) earlier[index] = Math.max(earlier[index] ?? 0, spread[index] ?? 0);
2714
- }
2715
- state.spreadIndex = state.spreadIndex + 1 & 255;
2716
- }
2717
- function isLocalMaximum(state, earlierSpread, bin, value) {
2718
- if (value < 1 / 64 || value < (earlierSpread[bin - 1] ?? 0)) return false;
2719
- for (const offset of FREQUENCY_NEIGHBORS) if (value <= (earlierSpread[bin + offset] ?? 0)) return false;
2720
- for (const offset of TIME_NEIGHBORS) if (value <= (state.spreadOutputs[state.spreadIndex + offset & 255]?.[bin - 1] ?? 0)) return false;
2721
- return true;
2722
- }
2723
- function detectPeaks(state) {
2724
- const earlierPower = state.outputs[state.fftIndex - 46 & 255];
2725
- const earlierSpread = state.spreadOutputs[state.spreadIndex - 49 & 255];
2726
- if (!earlierPower || !earlierSpread) return;
2727
- for (let bin = 10; bin <= 1014; bin += 1) {
2728
- const value = earlierPower[bin] ?? 0;
2729
- if (!isLocalMaximum(state, earlierSpread, bin, value)) continue;
2730
- const peak = logMagnitude(value);
2731
- const correctionInt = computePeakCorrection(logMagnitude(earlierPower[bin - 1] ?? 1e-10), peak, logMagnitude(earlierPower[bin + 1] ?? 1e-10));
2732
- if (correctionInt === void 0) continue;
2733
- const correctedBin = bin * 64 + correctionInt & 65535;
2734
- const band = bandForHz(Math.trunc(correctedBin * (7.8125 / 64)));
2735
- if (band !== -1) state.peaks[band]?.push({
2736
- bin: correctedBin,
2737
- magnitude: Math.min(65535, Math.max(0, Math.trunc(peak))),
2738
- pass: state.passes - 46
2739
- });
2740
- }
2741
- }
2742
- function processHop(state, sampleOffset) {
2743
- const { samples, ring, windowed, fft, spectrum, outputs } = state;
2744
- for (let index = 0; index < 128; index += 1) ring[state.ringIndex + index] = samples[sampleOffset + index] ?? 0;
2745
- state.ringIndex = state.ringIndex + 128 & 2047;
2746
- for (let index = 0; index < 2048; index += 1) {
2747
- const sampleVal = ring[index + state.ringIndex & 2047] ?? 0;
2748
- const winVal = SHAZAM_HANNING_WINDOW[index] ?? 0;
2749
- windowed[index] = sampleVal * winVal;
2750
- }
2751
- fft.realTransform(spectrum, windowed);
2752
- const power = outputs[state.fftIndex];
2753
- if (!power) return;
2754
- for (let index = 0; index <= 1024; index += 1) {
2755
- const real = f32(spectrum[index * 2] ?? 0);
2756
- const imaginary = f32(spectrum[index * 2 + 1] ?? 0);
2757
- power[index] = Math.max(f32(f32(f32(real * real) + f32(imaginary * imaginary)) / 131072), 1e-10);
2758
- }
2759
- state.fftIndex = state.fftIndex + 1 & 255;
2760
- spreadPower(state, power);
2761
- state.passes += 1;
2762
- if (state.passes >= 46) detectPeaks(state);
2763
- }
2764
- function finalizeResult(state) {
2765
- const bytes = encodeSignatureBytes(state.peaks, state.samples.length);
2766
- const base64 = bytesToBase64(bytes);
2767
- const peaksByBand = [
2768
- state.peaks[0].length,
2769
- state.peaks[1].length,
2770
- state.peaks[2].length,
2771
- state.peaks[3].length
2772
- ];
2773
- return {
2774
- base64,
2775
- bytes,
2776
- peakCount: peaksByBand[0] + peaksByBand[1] + peaksByBand[2] + peaksByBand[3],
2777
- peaksByBand,
2778
- sampleMs: Math.trunc(f32(f32(state.samples.length / 16e3) * 1e3)),
2779
- uri: `data:audio/vnd.shazam.sig;base64,${base64}`
2780
- };
2781
- }
2782
- /**
2783
- * Synchronous pure-TS Shazam spectral-peak fingerprinter.
2784
- * Accepts mono 16 kHz PCM16LE bytes (`Uint8Array`) or `Int16Array` (up to 12 s).
2785
- */
2786
- function generateShazamSignatureSync(pcm) {
2787
- const normalized = normalizeInputToInt16(pcm);
2788
- if ("error" in normalized) throw new RangeError(normalized.error);
2789
- const state = createWorkState(normalized.samples);
2790
- const totalSamples = normalized.samples.length;
2791
- for (let sample = 0; sample + 128 <= totalSamples; sample += 128) processHop(state, sample);
2792
- return finalizeResult(state);
2793
- }
2794
- /**
2795
- * Cooperative Effect-based Shazam spectral-peak fingerprinter (yields every
2796
- * 16,384 samples so concurrent audio/network fibers stay responsive).
2797
- */
2798
- function generateShazamSignature(pcm) {
2799
- return Effect.gen(function* () {
2800
- const normalized = normalizeInputToInt16(pcm);
2801
- if ("error" in normalized) return yield* Effect.fail(new AudioDecodeError({
2802
- message: normalized.error,
2803
- source: "shazam"
2804
- }));
2805
- const state = createWorkState(normalized.samples);
2806
- const totalSamples = normalized.samples.length;
2807
- for (let sample = 0; sample + 128 <= totalSamples; sample += 128) {
2808
- if (sample > 0 && sample % 16384 === 0) yield* Effect.yieldNow;
2809
- processHop(state, sample);
2810
- }
2811
- return finalizeResult(state);
2812
- });
267
+ // src/recognize/playlist.ts
268
+ function parsePlaylist(content, baseUrl) {
269
+ return content.replace(BOM_RE, "").trimStart().toLowerCase().startsWith("[playlist]") ? parsePls(content, baseUrl) : parseM3u(content, baseUrl);
2813
270
  }
2814
- export { SHAZAM_HANNING_WINDOW, SHAZAM_MAX_DURATION_SECONDS, SHAZAM_MAX_PCM_BYTES, SHAZAM_MAX_SAMPLES, SHAZAM_SAMPLE_RATE, base64ToBytes, bytesToBase64, computePeakCorrection, crc32, crc32String, float32ToPcm16Le, generateShazamSignature, generateShazamSignatureSync, parseHlsManifest, parseM3u, parsePlaylist, parsePls, resampleMonoTo16kHz };
271
+ export { PCM_RING_MAX_SECONDS, SHAZAM_HANNING_WINDOW, SHAZAM_MAX_DURATION_SECONDS, SHAZAM_MAX_PCM_BYTES, SHAZAM_MAX_SAMPLES, SHAZAM_SAMPLE_RATE, base64ToBytes, bytesToBase64, computePeakCorrection, crc32, crc32String, createPcmRingBuffer, float32ToPcm16Le, generateShazamSignature, generateShazamSignatureFromFloat32, generateShazamSignatureSync, parseHlsManifest, parseM3u, parsePlaylist, parsePls, prepareShazamPcm, resampleMonoTo16kHz };
2815
272
 
2816
273
  //# sourceMappingURL=index.js.map