@hyperframes/core 0.8.59 → 0.8.60

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,12 @@
1
+ export interface StereoLevel {
2
+ l: number;
3
+ r: number;
4
+ }
5
+ export interface LevelTap {
6
+ /** Peak of the last analyser window per channel, linear 0..1+. */
7
+ read(): StereoLevel;
8
+ dispose(): void;
9
+ }
10
+ /** A side branch off `source`; the explicit-stereo gain up-mixes mono to both channels. */
11
+ export declare function createLevelTap(ctx: BaseAudioContext, source: AudioNode): LevelTap;
12
+ //# sourceMappingURL=levelTap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"levelTap.d.ts","sourceRoot":"","sources":["../../src/runtime/levelTap.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,QAAQ;IACvB,kEAAkE;IAClE,IAAI,IAAI,WAAW,CAAC;IACpB,OAAO,IAAI,IAAI,CAAC;CACjB;AAWD,2FAA2F;AAC3F,wBAAgB,cAAc,CAAC,GAAG,EAAE,gBAAgB,EAAE,MAAM,EAAE,SAAS,GAAG,QAAQ,CA0BjF"}
@@ -0,0 +1,38 @@
1
+ const WINDOW = 2048;
2
+ function peak(analyser, buf) {
3
+ analyser.getFloatTimeDomainData(buf);
4
+ let max = 0;
5
+ for (let i = 0; i < buf.length; i++)
6
+ max = Math.max(max, Math.abs(buf[i] ?? 0));
7
+ return max;
8
+ }
9
+ /** A side branch off `source`; the explicit-stereo gain up-mixes mono to both channels. */
10
+ export function createLevelTap(ctx, source) {
11
+ const mix = ctx.createGain();
12
+ mix.channelCount = 2;
13
+ mix.channelCountMode = "explicit";
14
+ const splitter = ctx.createChannelSplitter(2);
15
+ const left = ctx.createAnalyser();
16
+ const right = ctx.createAnalyser();
17
+ left.fftSize = right.fftSize = WINDOW;
18
+ source.connect(mix);
19
+ mix.connect(splitter);
20
+ splitter.connect(left, 0);
21
+ splitter.connect(right, 1);
22
+ const bufL = new Float32Array(new ArrayBuffer(WINDOW * 4));
23
+ const bufR = new Float32Array(new ArrayBuffer(WINDOW * 4));
24
+ return {
25
+ read: () => ({ l: peak(left, bufL), r: peak(right, bufR) }),
26
+ dispose: () => {
27
+ try {
28
+ source.disconnect(mix);
29
+ mix.disconnect();
30
+ splitter.disconnect();
31
+ }
32
+ catch {
33
+ // Source already torn down.
34
+ }
35
+ },
36
+ };
37
+ }
38
+ //# sourceMappingURL=levelTap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"levelTap.js","sourceRoot":"","sources":["../../src/runtime/levelTap.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,GAAG,IAAI,CAAC;AAEpB,SAAS,IAAI,CAAC,QAAsB,EAAE,GAA8B;IAClE,QAAQ,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChF,OAAO,GAAG,CAAC;AACb,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,cAAc,CAAC,GAAqB,EAAE,MAAiB;IACrE,MAAM,GAAG,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;IAC7B,GAAG,CAAC,YAAY,GAAG,CAAC,CAAC;IACrB,GAAG,CAAC,gBAAgB,GAAG,UAAU,CAAC;IAClC,MAAM,QAAQ,GAAG,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAC9C,MAAM,IAAI,GAAG,GAAG,CAAC,cAAc,EAAE,CAAC;IAClC,MAAM,KAAK,GAAG,GAAG,CAAC,cAAc,EAAE,CAAC;IACnC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;IACtC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACpB,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAC3B,MAAM,IAAI,GAAG,IAAI,YAAY,CAAC,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3D,MAAM,IAAI,GAAG,IAAI,YAAY,CAAC,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3D,OAAO;QACL,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC;QAC3D,OAAO,EAAE,GAAG,EAAE;YACZ,IAAI,CAAC;gBACH,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;gBACvB,GAAG,CAAC,UAAU,EAAE,CAAC;gBACjB,QAAQ,CAAC,UAAU,EAAE,CAAC;YACxB,CAAC;YAAC,MAAM,CAAC;gBACP,4BAA4B;YAC9B,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/core",
3
- "version": "0.8.59",
3
+ "version": "0.8.60",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -199,6 +199,10 @@
199
199
  "import": "./dist/runtime/webAudioRoute.js",
200
200
  "types": "./dist/runtime/webAudioRoute.d.ts"
201
201
  },
202
+ "./runtime/levelTap": {
203
+ "import": "./dist/runtime/levelTap.js",
204
+ "types": "./dist/runtime/levelTap.d.ts"
205
+ },
202
206
  "./compiler/html-document": {
203
207
  "import": "./dist/compiler/htmlDocument.js",
204
208
  "types": "./dist/compiler/htmlDocument.d.ts"
@@ -302,9 +306,9 @@
302
306
  "bpm-detective": "^2.0.5",
303
307
  "linkedom": "^0.18.12",
304
308
  "postcss": "^8.5.8",
305
- "@hyperframes/studio-server": "0.8.59",
306
- "@hyperframes/parsers": "0.8.59",
307
- "@hyperframes/lint": "0.8.59"
309
+ "@hyperframes/lint": "0.8.60",
310
+ "@hyperframes/studio-server": "0.8.60",
311
+ "@hyperframes/parsers": "0.8.60"
308
312
  },
309
313
  "devDependencies": {
310
314
  "@types/jsdom": "^28.0.0",