star-audio 0.1.0 → 0.1.1

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 (2) hide show
  1. package/PROMPT.md +119 -0
  2. package/package.json +2 -1
package/PROMPT.md ADDED
@@ -0,0 +1,119 @@
1
+ **Installation**
2
+
3
+ First, add the package to your project:
4
+ ` ` `bash
5
+ yarn add star-audio
6
+ ` ` `
7
+
8
+ ### Star Audio SDK
9
+
10
+ **Mobile-first, bulletproof audio for web games.** Works on iOS/Android out of the box. Missing files won't crash your game.
11
+
12
+ **Import:**
13
+ ` ` `javascript
14
+ import createAudio from 'star-audio';
15
+ const audio = createAudio();
16
+ ` ` `
17
+
18
+ **CRITICAL:** Import in JavaScript - don't add `<script src="/star-sdk/audio.js">` tags.
19
+
20
+ **Why Star Audio?**
21
+ - ✅ **Mobile-first** - Works on iOS/Android, handles audio unlock automatically, plays even in silent mode
22
+ - ✅ **Never throws** - Missing audio files? Game keeps running with clear warnings
23
+ - ✅ **Zero-config** - Works on first play, no setup needed
24
+ - ✅ **No try/catch needed** - Fire-and-forget API, perfect for AI-generated games
25
+
26
+ ---
27
+
28
+ **Quick Start:**
29
+
30
+ ` ` `javascript
31
+ const audio = createAudio();
32
+
33
+ // CRITICAL: Preload presets before playing them
34
+ // You can set per-sound volumes in preload
35
+ audio.preload({
36
+ jump: { synth: 'jump', volume: 0.5 }, // Quieter jump
37
+ shoot: { synth: 'shoot', volume: 0.8 }, // Loud shoot
38
+ coin: { synth: 'coin', volume: 0.6 },
39
+ explosion: { synth: 'explosion', volume: 1.0 }
40
+ });
41
+
42
+ // Now play them - volumes are already set
43
+ audio.play('jump');
44
+ audio.play('shoot');
45
+ ` ` `
46
+
47
+ **ONLY THESE 17 PRESETS EXIST - DO NOT INVENT NAMES:**
48
+ - UI: `beep`, `click`, `select`, `error`, `success`
49
+ - Actions: `jump`, `swoosh`, `shoot`, `laser`, `explosion`
50
+ - Combat: `hit`, `hurt`
51
+ - Collection: `coin`, `pickup`, `bonus`, `unlock`, `powerup`
52
+
53
+ **If you need a sound that's not in this list, use custom synth or generate audio.**
54
+
55
+ **CRITICAL:** Preload all presets before use. Set volumes in preload:
56
+ ` ` `javascript
57
+ audio.preload({
58
+ jump: { synth: 'jump', volume: 0.5 }, // With custom volume
59
+ coin: 'coin', // Default volume
60
+ explosion: 'explosion' // For crashes/impacts
61
+ });
62
+ ` ` `
63
+
64
+ ---
65
+
66
+ **Custom synth (advanced):**
67
+
68
+ ` ` `javascript
69
+ audio.preload({
70
+ 'sfx.charge': {
71
+ waveform: 'triangle',
72
+ frequency: [200, 300, 450, 650, 900], // Rising charge-up
73
+ duration: 0.40,
74
+ volume: 0.38
75
+ }
76
+ });
77
+ ` ` `
78
+
79
+ **Make sounds feel good:**
80
+ - **Use frequency arrays** - Sweeps/arpeggios are more satisfying than single tones
81
+ - **Rising = positive** - Ascending pitches for rewards (coin, jump, powerup)
82
+ - **Descending = impact** - Falling pitches for actions (shoot, hurt, explosion)
83
+ - **More notes = richer** - 3-6 frequencies sound fuller than 1-2
84
+ - **Musical intervals** - Use harmonious ratios (octaves, fifths, major chords)
85
+
86
+ **Waveform choice:**
87
+ - `sine` - Pure, pleasant (UI, bells, rewards)
88
+ - `triangle` - Warm, full (jumps, explosions, success)
89
+ - `square` - Retro, characterful (powerups, beeps, chiptune)
90
+ - `sawtooth` - Harsh, aggressive (lasers, damage, errors)
91
+
92
+ **Frequency guide:**
93
+ - High (800-2000 Hz): Bright, attention-grabbing (UI, coins)
94
+ - Mid (200-800 Hz): Game actions (jumps, shoots)
95
+ - Low (30-200 Hz): Impacts, bass (explosions, rumbles)
96
+ - Arrays: 3-4 notes for melodies, 6+ for noise-like effects
97
+
98
+ ---
99
+
100
+ **Audio files:**
101
+
102
+ ` ` `javascript
103
+ audio.preload({
104
+ 'sfx.boom': 'assets/boom.mp3',
105
+ 'bgm.theme': 'assets/music.mp3'
106
+ });
107
+ audio.play('sfx.boom');
108
+ audio.music.crossfadeTo('bgm.theme', { duration: 1.5 });
109
+ ` ` `
110
+
111
+ ---
112
+
113
+ **Controls:**
114
+
115
+ ` ` `javascript
116
+ audio.setMusicVolume(0.5);
117
+ audio.setSfxVolume(0.8);
118
+ audio.toggleMute();
119
+ ` ` `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "star-audio",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "private": false,
5
5
  "description": "Mobile-first Web Audio for games.",
6
6
  "type": "module",
@@ -31,6 +31,7 @@
31
31
  "types": "./dist/index.d.ts",
32
32
  "files": [
33
33
  "dist",
34
+ "PROMPT.md",
34
35
  "LICENSE-3RD-PARTY.md"
35
36
  ],
36
37
  "scripts": {