@driftengine/audio 4.7.2 → 4.7.4

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/graph.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { AmbientLoop } from './ambientLoop.js';
2
2
  import { KickDetector } from './rhythm/kickDetector.js';
3
3
  import { SoundRegistry } from './registry.js';
4
- import { LIFT_FLOOR_HZ, SLAM_ATTACK_SEC, SLAM_CLIP_KNEE, SLAM_CLOSED_HZ, SLAM_DECAY_SEC, SLAM_DRIVE, SLAM_DUCK, SLAM_OPEN_HZ, SLAM_SHELF_DB, SLAM_SHELF_HZ, clamp01, cutoffForSpeed, liftFrequencyHz, liftGainFor, } from './filters.js';
4
+ import { clamp01 } from './filters.js';
5
5
  import { audioContextConstructor, claimPlaybackSession, errorName } from './session.js';
6
6
  import { MixConsole } from './mix/console.js';
7
7
  import { defaultLayout } from './mix/defaultLayout.js';
@@ -21,10 +21,6 @@ const RAMP = 0.08;
21
21
  * hears a transient.
22
22
  */
23
23
  const FADE_OUT = 0.008;
24
- const LONG_REVERB_SECONDS = 6;
25
- const LONG_REVERB_DECAY = 1.5;
26
- /** Baseline delay feedback: one clear repeat, not a rhythm of its own. */
27
- const DELAY_FEEDBACK = 0.34;
28
24
  export class AudioGraph {
29
25
  context;
30
26
  registry;
@@ -616,41 +612,3 @@ export class AudioGraph {
616
612
  param.setTargetAtTime(value, at, RAMP);
617
613
  }
618
614
  }
619
- /**
620
- * A synthesised impulse response: exponentially decaying noise.
621
- *
622
- * Not a real hall — a real one is a file, and files are what the registry is
623
- * for. This exists so reverb works before any asset has been recorded, on the
624
- * same principle as every other sound here.
625
- */
626
- /**
627
- * A soft clipper, transparent until it is driven and saturating hard after.
628
- *
629
- * `tanh` rather than a hard corner: a hard clip of a bass note is a square wave, and
630
- * a square wave's odd harmonics march all the way up the spectrum as buzz. `tanh`
631
- * rounds the corner, so what comes out is the second and third harmonic — which is
632
- * what "driven" sounds like as opposed to "broken".
633
- *
634
- * Odd-length so there is a sample exactly at zero, which keeps silence silent.
635
- */
636
- function softClipCurve() {
637
- const samples = 2049;
638
- const curve = new Float32Array(new ArrayBuffer(2049 * 4));
639
- for (let i = 0; i < samples; i++) {
640
- const x = (i / (samples - 1)) * 2 - 1;
641
- curve[i] = Math.tanh(x * SLAM_CLIP_KNEE) / Math.tanh(SLAM_CLIP_KNEE);
642
- }
643
- return curve;
644
- }
645
- function impulseResponse(context, seconds, decay) {
646
- const rate = context.sampleRate;
647
- const length = Math.max(1, Math.floor(rate * seconds));
648
- const buffer = context.createBuffer(2, length, rate);
649
- for (let channel = 0; channel < 2; channel++) {
650
- const data = buffer.getChannelData(channel);
651
- for (let i = 0; i < length; i++) {
652
- data[i] = (Math.random() * 2 - 1) * (1 - i / length) ** decay;
653
- }
654
- }
655
- return buffer;
656
- }
@@ -117,7 +117,7 @@ function buildCurves(samples, sampleRate) {
117
117
  const hop = settling ? pass : pass - warmupHops;
118
118
  const start = hop * hopSamples;
119
119
  measureBands(samples, start, hopSamples, filters, energies);
120
- const { sub, punch, sweet, bassline, mud, lowMid, high } = energies;
120
+ const { sub, punch, bassline, mud, lowMid, high } = energies;
121
121
  if (!settling) {
122
122
  energyAccum += sub + punch + bassline + mud + lowMid + high;
123
123
  energyCount++;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@driftengine/audio",
3
- "version": "4.7.2",
3
+ "version": "4.7.4",
4
4
  "description": "Layered stems, synthesis, rhythm analysis and positional placement",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
package/src/graph.ts CHANGED
@@ -2,22 +2,7 @@ import { AmbientLoop } from './ambientLoop.ts';
2
2
  import { KickDetector } from './rhythm/kickDetector.ts';
3
3
  import type { FetchLike } from './registry.ts';
4
4
  import { SoundRegistry } from './registry.ts';
5
- import {
6
- LIFT_FLOOR_HZ,
7
- SLAM_ATTACK_SEC,
8
- SLAM_CLIP_KNEE,
9
- SLAM_CLOSED_HZ,
10
- SLAM_DECAY_SEC,
11
- SLAM_DRIVE,
12
- SLAM_DUCK,
13
- SLAM_OPEN_HZ,
14
- SLAM_SHELF_DB,
15
- SLAM_SHELF_HZ,
16
- clamp01,
17
- cutoffForSpeed,
18
- liftFrequencyHz,
19
- liftGainFor,
20
- } from './filters.ts';
5
+ import { clamp01 } from './filters.ts';
21
6
  import { audioContextConstructor, claimPlaybackSession, errorName } from './session.ts';
22
7
  import { MixConsole } from './mix/console.ts';
23
8
  import { defaultLayout, type DefaultLayout } from './mix/defaultLayout.ts';
@@ -142,11 +127,6 @@ const RAMP = 0.08;
142
127
  */
143
128
  const FADE_OUT = 0.008;
144
129
 
145
- const LONG_REVERB_SECONDS = 6;
146
- const LONG_REVERB_DECAY = 1.5;
147
- /** Baseline delay feedback: one clear repeat, not a rhythm of its own. */
148
- const DELAY_FEEDBACK = 0.34;
149
-
150
130
  export class AudioGraph {
151
131
  readonly context: BaseAudioContext;
152
132
  readonly registry: SoundRegistry;
@@ -763,43 +743,3 @@ export class AudioGraph {
763
743
  param.setTargetAtTime(value, at, RAMP);
764
744
  }
765
745
  }
766
-
767
- /**
768
- * A synthesised impulse response: exponentially decaying noise.
769
- *
770
- * Not a real hall — a real one is a file, and files are what the registry is
771
- * for. This exists so reverb works before any asset has been recorded, on the
772
- * same principle as every other sound here.
773
- */
774
- /**
775
- * A soft clipper, transparent until it is driven and saturating hard after.
776
- *
777
- * `tanh` rather than a hard corner: a hard clip of a bass note is a square wave, and
778
- * a square wave's odd harmonics march all the way up the spectrum as buzz. `tanh`
779
- * rounds the corner, so what comes out is the second and third harmonic — which is
780
- * what "driven" sounds like as opposed to "broken".
781
- *
782
- * Odd-length so there is a sample exactly at zero, which keeps silence silent.
783
- */
784
- function softClipCurve(): Float32Array<ArrayBuffer> {
785
- const samples = 2049;
786
- const curve = new Float32Array(new ArrayBuffer(2049 * 4));
787
- for (let i = 0; i < samples; i++) {
788
- const x = (i / (samples - 1)) * 2 - 1;
789
- curve[i] = Math.tanh(x * SLAM_CLIP_KNEE) / Math.tanh(SLAM_CLIP_KNEE);
790
- }
791
- return curve;
792
- }
793
-
794
- function impulseResponse(context: BaseAudioContext, seconds: number, decay: number): AudioBuffer {
795
- const rate = context.sampleRate;
796
- const length = Math.max(1, Math.floor(rate * seconds));
797
- const buffer = context.createBuffer(2, length, rate);
798
- for (let channel = 0; channel < 2; channel++) {
799
- const data = buffer.getChannelData(channel);
800
- for (let i = 0; i < length; i++) {
801
- data[i] = (Math.random() * 2 - 1) * (1 - i / length) ** decay;
802
- }
803
- }
804
- return buffer;
805
- }
@@ -182,7 +182,7 @@ function buildCurves(samples: Float32Array, sampleRate: number): Curves {
182
182
  const start = hop * hopSamples;
183
183
  measureBands(samples, start, hopSamples, filters, energies);
184
184
 
185
- const { sub, punch, sweet, bassline, mud, lowMid, high } = energies;
185
+ const { sub, punch, bassline, mud, lowMid, high } = energies;
186
186
 
187
187
  if (!settling) {
188
188
  energyAccum += sub + punch + bassline + mud + lowMid + high;