sound-bakery 1.0.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.
- package/LICENSE +21 -0
- package/README.md +71 -0
- package/dist/sound-bakery.js +1 -0
- package/dist/sound-bakery.modern.mjs +1 -0
- package/dist/sound-bakery.module.js +1 -0
- package/dist/sound-bakery.umd.js +1 -0
- package/package.json +27 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nitinkumar Gove
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# 🍞 Sound Bakery
|
|
2
|
+
|
|
3
|
+
> Tiny (< 1KB) browser-based sound synthesis library. No audio files, just code.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 📦 **Tiny**: < 1KB (gzipped).
|
|
8
|
+
- ⚡ **Fast**: Generates sounds on the fly using Web Audio API.
|
|
9
|
+
- 🚫 **Zero Dependencies**: Pure JavaScript.
|
|
10
|
+
- 🎛️ **19 Presets**: UI, Notifications, Success/Error feedback.
|
|
11
|
+
- 🛡️ **Type Safe**: Exported constants for all sound names.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install sound-bakery
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
Import the `play` function and the sound constants.
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
import { play, CLICK, SUCCESS, ERROR } from 'sound-bakery';
|
|
25
|
+
|
|
26
|
+
// Play a simple click
|
|
27
|
+
play(CLICK);
|
|
28
|
+
|
|
29
|
+
// Handle a successful action
|
|
30
|
+
play(SUCCESS);
|
|
31
|
+
|
|
32
|
+
// Handle an error
|
|
33
|
+
play(ERROR);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
> **Note**: Modern browsers require user interaction (e.g., a click) before the `AudioContext` can start. The library handles unlocking, but the first sound must strictly be triggered by a user action.
|
|
37
|
+
|
|
38
|
+
## Supported Sounds
|
|
39
|
+
|
|
40
|
+
All sounds are exported as constants.
|
|
41
|
+
|
|
42
|
+
### UI Interactions
|
|
43
|
+
- `CLICK` - Short crisp click
|
|
44
|
+
- `TAP` - Soft tap
|
|
45
|
+
- `TOGGLE` - Toggle switch
|
|
46
|
+
- `HOVER` - Gentle hover feedback
|
|
47
|
+
|
|
48
|
+
### Navigation
|
|
49
|
+
- `SWIPE` - Swipe gesture
|
|
50
|
+
- `BACK` - Navigate back (descending)
|
|
51
|
+
- `FORWARD` - Navigate forward (ascending)
|
|
52
|
+
|
|
53
|
+
### Positive Feedback
|
|
54
|
+
- `SUCCESS` - Task completion
|
|
55
|
+
- `COMPLETE` - Major achievement
|
|
56
|
+
- `CONFIRM` - Confirmation
|
|
57
|
+
|
|
58
|
+
### Neutral Feedback
|
|
59
|
+
- `POP` - Bubble/pop effect
|
|
60
|
+
- `BLIP` - Quick blip
|
|
61
|
+
- `TICK` - Subtle tick
|
|
62
|
+
|
|
63
|
+
### Negative Feedback
|
|
64
|
+
- `ERROR` - Error (descending)
|
|
65
|
+
- `WARNING` - Warning tone
|
|
66
|
+
- `CANCEL` - Cancel action
|
|
67
|
+
|
|
68
|
+
### Notifications
|
|
69
|
+
- `NOTIFICATION` - Incoming notification
|
|
70
|
+
- `MESSAGE` - New message
|
|
71
|
+
- `ALERT` - Important alert
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e,t={click:[1,800,.05,.1],tap:[0,600,.08,.08],toggle:[3,700,.06,.09],hover:[0,400,.04,.05],swipe:[0,500,.12,.08,!0],back:[1,600,.08,.09,!0],forward:[0,400,.08,.09],success:[3,800,.25,.12],complete:[0,1e3,.3,.11],confirm:[0,650,.15,.1],pop:[0,600,.1,.1,!0],blip:[1,900,.06,.08],tick:[1,1200,.03,.07],error:[2,200,.3,.12,!0],warning:[2,350,.25,.11],cancel:[1,300,.15,.09,!0],notification:[0,800,.2,.11],message:[0,900,.15,.1],alert:[2,600,.35,.13]},o=function(){return e||(e=new(window.AudioContext||window.webkitAudioContext)),e},r=function(e,t,r,n,s){void 0===n&&(n=.1),void 0===s&&(s=!1);var i=o(),p=i.createOscillator(),a=i.createGain();p.type=["sine","square","sawtooth","triangle"][e]||"sine",p.frequency.setValueAtTime(t,i.currentTime),s&&p.frequency.exponentialRampToValueAtTime(.01,i.currentTime+r),a.gain.setValueAtTime(n,i.currentTime),a.gain.exponentialRampToValueAtTime(1e-5,i.currentTime+r),p.connect(a),a.connect(i.destination),p.start(),p.stop(i.currentTime+r)};exports.ALERT="alert",exports.BACK="back",exports.BLIP="blip",exports.CANCEL="cancel",exports.CLICK="click",exports.COMPLETE="complete",exports.CONFIRM="confirm",exports.ERROR="error",exports.FORWARD="forward",exports.HOVER="hover",exports.MESSAGE="message",exports.NOTIFICATION="notification",exports.POP="pop",exports.SUCCESS="success",exports.SWIPE="swipe",exports.TAP="tap",exports.TICK="tick",exports.TOGGLE="toggle",exports.WARNING="warning",exports.play=function(e){var n=t[e];n?("suspended"===o().state&&o().resume(),r.apply(void 0,n)):console.warn("Sound not found:",e)},exports.presets=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={click:[1,800,.05,.1],tap:[0,600,.08,.08],toggle:[3,700,.06,.09],hover:[0,400,.04,.05],swipe:[0,500,.12,.08,!0],back:[1,600,.08,.09,!0],forward:[0,400,.08,.09],success:[3,800,.25,.12],complete:[0,1e3,.3,.11],confirm:[0,650,.15,.1],pop:[0,600,.1,.1,!0],blip:[1,900,.06,.08],tick:[1,1200,.03,.07],error:[2,200,.3,.12,!0],warning:[2,350,.25,.11],cancel:[1,300,.15,.09,!0],notification:[0,800,.2,.11],message:[0,900,.15,.1],alert:[2,600,.35,.13]},t="click",n="tap",o="toggle",i="hover",c="swipe",r="back",a="forward",s="success",l="complete",p="confirm",u="pop",m="blip",w="tick",d="error",g="warning",T="cancel",f="notification",k="message",A="alert";let b;const x=()=>(b||(b=new(window.AudioContext||window.webkitAudioContext)),b),V=t=>{const n=e[t];n?("suspended"===x().state&&x().resume(),((e,t,n,o=.1,i=!1)=>{const c=x(),r=c.createOscillator(),a=c.createGain();r.type=["sine","square","sawtooth","triangle"][e]||"sine",r.frequency.setValueAtTime(t,c.currentTime),i&&r.frequency.exponentialRampToValueAtTime(.01,c.currentTime+n),a.gain.setValueAtTime(o,c.currentTime),a.gain.exponentialRampToValueAtTime(1e-5,c.currentTime+n),r.connect(a),a.connect(c.destination),r.start(),r.stop(c.currentTime+n)})(...n)):console.warn("Sound not found:",t)};export{A as ALERT,r as BACK,m as BLIP,T as CANCEL,t as CLICK,l as COMPLETE,p as CONFIRM,d as ERROR,a as FORWARD,i as HOVER,k as MESSAGE,f as NOTIFICATION,u as POP,s as SUCCESS,c as SWIPE,n as TAP,w as TICK,o as TOGGLE,g as WARNING,V as play,e as presets};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e,t={click:[1,800,.05,.1],tap:[0,600,.08,.08],toggle:[3,700,.06,.09],hover:[0,400,.04,.05],swipe:[0,500,.12,.08,!0],back:[1,600,.08,.09,!0],forward:[0,400,.08,.09],success:[3,800,.25,.12],complete:[0,1e3,.3,.11],confirm:[0,650,.15,.1],pop:[0,600,.1,.1,!0],blip:[1,900,.06,.08],tick:[1,1200,.03,.07],error:[2,200,.3,.12,!0],warning:[2,350,.25,.11],cancel:[1,300,.15,.09,!0],notification:[0,800,.2,.11],message:[0,900,.15,.1],alert:[2,600,.35,.13]},n="click",i="tap",o="toggle",r="hover",a="swipe",c="back",s="forward",u="success",l="complete",p="confirm",m="pop",d="blip",w="tick",f="error",g="warning",T="cancel",v="notification",k="message",A="alert",b=function(){return e||(e=new(window.AudioContext||window.webkitAudioContext)),e},x=function(e,t,n,i,o){void 0===i&&(i=.1),void 0===o&&(o=!1);var r=b(),a=r.createOscillator(),c=r.createGain();a.type=["sine","square","sawtooth","triangle"][e]||"sine",a.frequency.setValueAtTime(t,r.currentTime),o&&a.frequency.exponentialRampToValueAtTime(.01,r.currentTime+n),c.gain.setValueAtTime(i,r.currentTime),c.gain.exponentialRampToValueAtTime(1e-5,r.currentTime+n),a.connect(c),c.connect(r.destination),a.start(),a.stop(r.currentTime+n)},y=function(e){var n=t[e];n?("suspended"===b().state&&b().resume(),x.apply(void 0,n)):console.warn("Sound not found:",e)};export{A as ALERT,c as BACK,d as BLIP,T as CANCEL,n as CLICK,l as COMPLETE,p as CONFIRM,f as ERROR,s as FORWARD,r as HOVER,k as MESSAGE,v as NOTIFICATION,m as POP,u as SUCCESS,a as SWIPE,i as TAP,w as TICK,o as TOGGLE,g as WARNING,y as play,t as presets};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e||self).soundBakery={})}(this,function(e){var n,t={click:[1,800,.05,.1],tap:[0,600,.08,.08],toggle:[3,700,.06,.09],hover:[0,400,.04,.05],swipe:[0,500,.12,.08,!0],back:[1,600,.08,.09,!0],forward:[0,400,.08,.09],success:[3,800,.25,.12],complete:[0,1e3,.3,.11],confirm:[0,650,.15,.1],pop:[0,600,.1,.1,!0],blip:[1,900,.06,.08],tick:[1,1200,.03,.07],error:[2,200,.3,.12,!0],warning:[2,350,.25,.11],cancel:[1,300,.15,.09,!0],notification:[0,800,.2,.11],message:[0,900,.15,.1],alert:[2,600,.35,.13]},o=function(){return n||(n=new(window.AudioContext||window.webkitAudioContext)),n},i=function(e,n,t,i,r){void 0===i&&(i=.1),void 0===r&&(r=!1);var a=o(),c=a.createOscillator(),s=a.createGain();c.type=["sine","square","sawtooth","triangle"][e]||"sine",c.frequency.setValueAtTime(n,a.currentTime),r&&c.frequency.exponentialRampToValueAtTime(.01,a.currentTime+t),s.gain.setValueAtTime(i,a.currentTime),s.gain.exponentialRampToValueAtTime(1e-5,a.currentTime+t),c.connect(s),s.connect(a.destination),c.start(),c.stop(a.currentTime+t)};e.ALERT="alert",e.BACK="back",e.BLIP="blip",e.CANCEL="cancel",e.CLICK="click",e.COMPLETE="complete",e.CONFIRM="confirm",e.ERROR="error",e.FORWARD="forward",e.HOVER="hover",e.MESSAGE="message",e.NOTIFICATION="notification",e.POP="pop",e.SUCCESS="success",e.SWIPE="swipe",e.TAP="tap",e.TICK="tick",e.TOGGLE="toggle",e.WARNING="warning",e.play=function(e){var n=t[e];n?("suspended"===o().state&&o().resume(),i.apply(void 0,n)):console.warn("Sound not found:",e)},e.presets=t});
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sound-bakery",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Tiny browser-based sound effects library for modern web apps",
|
|
5
|
+
"source": "src/index.js",
|
|
6
|
+
"main": "dist/sound-bakery.js",
|
|
7
|
+
"module": "dist/sound-bakery.module.js",
|
|
8
|
+
"unpkg": "dist/sound-bakery.umd.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "rm -rf dist && microbundle --no-sourcemap && cp dist/sound-bakery.module.js docs/sound-bakery.js",
|
|
11
|
+
"dev": "microbundle watch"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"web audio",
|
|
15
|
+
"sound",
|
|
16
|
+
"synthesis",
|
|
17
|
+
"tiny"
|
|
18
|
+
],
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"author": "Nitinkumar Gove",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"microbundle": "^0.15.1"
|
|
26
|
+
}
|
|
27
|
+
}
|