{"_id":"@affectively/entrainment-audio","_rev":"2-604fbb668c098b824022992c2dd32241","name":"@affectively/entrainment-audio","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@affectively/entrainment-audio","version":"1.0.0","keywords":["binaural-beats","isochronic-tones","monaural-beats","brainwave","entrainment","meditation","audio","web-audio-api","relaxation","focus","sleep","pink-noise","brown-noise","wellness"],"author":{"name":"AFFECTIVELY","email":"opensource@affectively.ai"},"license":"MIT","_id":"@affectively/entrainment-audio@1.0.0","maintainers":[{"name":"buley","email":"buley@outlook.com"}],"homepage":"https://github.com/affectively-ai/entrainment-audio#readme","bugs":{"url":"https://github.com/affectively-ai/entrainment-audio/issues"},"dist":{"shasum":"2459968fc315091ff792176ebd95734a8990ed72","tarball":"https://registry.npmjs.org/@affectively/entrainment-audio/-/entrainment-audio-1.0.0.tgz","fileCount":8,"integrity":"sha512-xnR6dMbQHISm6O3IrAOAjEameWWcRS1rEx4BZUr7SWjbllcDXIEhn5lExkE0xGVaeWwM9saMpHTCRShiasI0hA==","signatures":[{"sig":"MEUCIQDtJ3Ucp8/UD1eNSZe4tFAfDTX5mJdfJ3YhHMMcXKelgQIgQHLJo5H44eM5RrxjoAE+XY2ss5YxLZpwigZ28XeosxU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":110361},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"0dccb8f7c22666bea29b669b87eeec48da30ccef","scripts":{"test":"bun test","build":"tsup src/index.ts --format cjs,esm --dts","prepublishOnly":"npm run build"},"_npmUser":{"name":"buley","email":"buley@outlook.com"},"repository":{"url":"git+https://github.com/affectively-ai/entrainment-audio.git","type":"git"},"_npmVersion":"11.7.0","description":"Brainwave entrainment audio generators: binaural beats, isochronic tones, monaural beats, pink noise, and brown noise using Web Audio API.","directories":{},"_nodeVersion":"25.4.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.9.0","@types/node":"^22.0.0"},"_npmOperationalInternal":{"tmp":"tmp/entrainment-audio_1.0.0_1769380324670_0.585492375231478","host":"s3://npm-registry-packages-npm-production"},"deprecated":"This package is deprecated and no longer supported. Do not use."}},"time":{"created":"2026-01-25T22:32:04.590Z","modified":"2026-03-27T20:03:35.278Z","1.0.0":"2026-01-25T22:32:04.816Z"},"bugs":{"url":"https://github.com/affectively-ai/entrainment-audio/issues"},"author":{"name":"AFFECTIVELY","email":"opensource@affectively.ai"},"license":"MIT","homepage":"https://github.com/affectively-ai/entrainment-audio#readme","keywords":["binaural-beats","isochronic-tones","monaural-beats","brainwave","entrainment","meditation","audio","web-audio-api","relaxation","focus","sleep","pink-noise","brown-noise","wellness"],"repository":{"url":"git+https://github.com/affectively-ai/entrainment-audio.git","type":"git"},"description":"Brainwave entrainment audio generators: binaural beats, isochronic tones, monaural beats, pink noise, and brown noise using Web Audio API.","maintainers":[{"name":"buley","email":"buley@outlook.com"}],"readme":"# @affectively/entrainment-audio\n\nBrainwave entrainment audio generators using the Web Audio API. Generate binaural beats, isochronic tones, monaural beats, and colored noise for meditation, focus, and relaxation applications.\n\n## Features\n\n- **Binaural Beats** - Stereo-separated tones that create perceived frequencies in the brain (requires headphones)\n- **Isochronic Tones** - Pulsed tones with 100% modulation depth for speaker playback\n- **Monaural Beats** - Physical interference patterns created by mixing two frequencies\n- **Brown Noise** - Deep, rumbling colored noise (1/f²) for masking and relaxation\n- **Pink Noise** - Balanced colored noise (1/f) like steady rain\n- **Preset Library** - Science-based presets for Delta, Theta, Alpha, Beta, and Gamma states\n- **Progressive Ramping** - Gradual frequency transitions for smoother entrainment\n- **Safety Warnings** - Built-in safety protocols and user warnings\n\n## Installation\n\n```bash\nnpm install @affectively/entrainment-audio\n# or\nbun add @affectively/entrainment-audio\n# or\nyarn add @affectively/entrainment-audio\n```\n\n## Quick Start\n\n```typescript\nimport { EntrainmentEngine, BRAINWAVE_PRESETS } from '@affectively/entrainment-audio';\n\n// Create engine instance\nconst engine = new EntrainmentEngine();\n\n// Initialize (must be called from user gesture due to browser autoplay policy)\nawait engine.initialize();\n\n// Start alpha wave entrainment (10 Hz) with brown noise\nawait engine.start({\n  preset: 'alpha',\n  manualMode: false,\n  generators: {\n    binaural: {\n      enabled: true,\n      volume: 0.5,\n      type: 'binaural',\n      carrierFrequency: 450, // Oster Curve: 400-500 Hz\n      beatFrequency: 10,\n    },\n    isochronic: {\n      enabled: false,\n      volume: 0.5,\n      type: 'isochronic',\n      carrierFrequency: 200,\n      beatFrequency: 10,\n      dutyCycle: 0.5,\n      attackTime: 5,\n      releaseTime: 5,\n    },\n    brownNoise: {\n      enabled: true,\n      volume: 0.15,\n      type: 'brown-noise',\n      filterStrength: 0.02,\n    },\n  },\n  masterVolume: 0.8,\n  progressiveRamping: true,\n  rampingDuration: 30,\n  mode: 'headphones',\n});\n\n// Stop entrainment\nengine.stop();\n\n// Cleanup when done\nengine.cleanup();\n```\n\n## Brainwave Presets\n\n| Preset | Frequency | Use Case |\n|--------|-----------|----------|\n| `delta` | 0.5-4 Hz | Deep sleep, restoration |\n| `theta` | 4-8 Hz | Meditation, creativity |\n| `alpha` | 8-12 Hz | Relaxed alertness, flow state |\n| `low-beta` | 12-15 Hz | Calm focus (SMR) |\n| `mid-beta` | 15-20 Hz | Active focus, problem-solving |\n| `high-beta` | 20-30 Hz | High energy, alertness |\n| `gamma` | 30-100 Hz | Peak performance, insight |\n\n## Using Individual Generators\n\n```typescript\nimport { BinauralGenerator, IsochronicGenerator, BrownNoiseGenerator } from '@affectively/entrainment-audio';\n\n// Create AudioContext\nconst ctx = new AudioContext();\nconst masterGain = ctx.createGain();\nmasterGain.connect(ctx.destination);\n\n// Binaural beats (requires headphones)\nconst binaural = new BinauralGenerator(ctx);\nbinaural.start({\n  enabled: true,\n  volume: 0.5,\n  type: 'binaural',\n  carrierFrequency: 450,\n  beatFrequency: 10, // Alpha wave\n}, masterGain);\n\n// Stop after use\nbinaural.stop();\n```\n\n## Safety Warnings\n\n```typescript\nimport { getSafetyWarnings, getAllSafetyWarnings } from '@affectively/entrainment-audio';\n\n// Get warnings for current configuration\nconst warnings = getSafetyWarnings({\n  hasVisualizer: true,\n  currentPreset: 'alpha',\n});\n\n// All warnings include:\n// - Epilepsy warning (for visual effects)\n// - Driving warning (for low-frequency presets)\n// - Pacemaker warning\n// - Mental health considerations\n// - Visual strobing warning\n```\n\n## The Oster Curve\n\nBinaural beats work best with carrier frequencies between 400-500 Hz (the \"Oster Curve\"). The library validates this automatically:\n\n```typescript\nimport { validateOsterCurve, getRecommendedCarrierFrequency } from '@affectively/entrainment-audio';\n\nvalidateOsterCurve(450); // true\nvalidateOsterCurve(200); // false\n\nconst recommended = getRecommendedCarrierFrequency(); // 450 Hz\n```\n\n## API Reference\n\n### EntrainmentEngine\n\nMain coordinator class that manages all generators.\n\n- `initialize()` - Initialize AudioContext (call from user gesture)\n- `start(config)` - Start entrainment with configuration\n- `stop()` - Stop all generators\n- `pause()` - Pause playback\n- `resumePlayback()` - Resume from pause\n- `updateConfig(config)` - Update parameters in real-time\n- `getSessionInfo()` - Get current session state\n- `cleanup()` - Disconnect and close AudioContext\n\n### Individual Generators\n\n- `BinauralGenerator` - Binaural beat generation\n- `IsochronicGenerator` - Isochronic tone generation\n- `MonauralGenerator` - Monaural beat generation\n- `BrownNoiseGenerator` - Brown noise generation\n- `PinkNoiseGenerator` - Pink noise generation\n\n## Browser Support\n\nRequires Web Audio API support (all modern browsers).\n\n## License\n\nMIT © AFFECTIVELY\n","readmeFilename":"README.md"}