{"_id":"@elron/svelte-audio-store","_rev":"3-1095a5a518d02df829acb733875e1478","name":"@elron/svelte-audio-store","dist-tags":{"latest":"1.0.0"},"versions":{"0.0.1":{"name":"@elron/svelte-audio-store","version":"0.0.1","author":{"name":"Elron Bucai"},"license":"MIT","keywords":["svelte","audio","sound","store","playback","sound-effects","svelte-store","web-audio","audio-management","svelte-component","audio-player","sound-library","svelte-library","audio-preload","interactive-sound","game-audio","webapp-audio","svelte-audio","audio-api"],"repository":{"type":"git","url":"git+https://github.com/elron/svelte-audio-store.git"},"homepage":"https://svelte-audio-store.netlify.app/","bugs":{"url":"https://github.com/elron/svelte-audio-store/issues"},"exports":{".":{"types":"./dist/index.d.ts","svelte":"./dist/index.js"}},"peerDependencies":{"svelte":"^4.0.0"},"devDependencies":{"@sveltejs/adapter-auto":"^2.0.0","@sveltejs/kit":"^1.20.4","@sveltejs/package":"^2.0.0","@typescript-eslint/eslint-plugin":"^5.45.0","@typescript-eslint/parser":"^5.45.0","eslint":"^8.28.0","eslint-config-prettier":"^8.5.0","eslint-plugin-svelte":"^2.30.0","prettier":"^2.8.0","prettier-plugin-svelte":"^2.10.1","publint":"^0.1.9","svelte":"^4.0.5","svelte-check":"^3.4.3","tslib":"^2.4.1","typescript":"^5.0.0","vite":"^4.4.2","vitest":"^0.34.0"},"svelte":"./dist/index.js","types":"./dist/index.d.ts","type":"module","scripts":{"dev":"vite dev","build":"vite build && npm run package","preview":"vite preview","package":"svelte-kit sync && svelte-package && publint","check":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json","check:watch":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch","test":"vitest","lint":"prettier --plugin-search-dir . --check . && eslint .","format":"prettier --plugin-search-dir . --write ."},"description":"A Svelte store for managing and playing audio, available as @elron/svelte-audio-store on npm.","_id":"@elron/svelte-audio-store@0.0.1","_integrity":"sha512-JXUxmZ0a++Fef7KpTkSxpQrijPIhYNdzBOWcFDOAVBowBwfgd1nTjsMhzwmP66235nri4s4f3/IEc/FL6efOdA==","_resolved":"/private/var/folders/0f/2xtv0jzn15751v32f01znrb80000gn/T/b175a375cc82ce1e14e46f711426e8a3/elron-svelte-audio-store-0.0.1.tgz","_from":"file:elron-svelte-audio-store-0.0.1.tgz","_nodeVersion":"20.3.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-JXUxmZ0a++Fef7KpTkSxpQrijPIhYNdzBOWcFDOAVBowBwfgd1nTjsMhzwmP66235nri4s4f3/IEc/FL6efOdA==","shasum":"8a7d4e64dc9c51c39e15ecc16d5faf65188ba388","tarball":"https://registry.npmjs.org/@elron/svelte-audio-store/-/svelte-audio-store-0.0.1.tgz","fileCount":6,"unpackedSize":14296,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCYe9KTkEC1VmykYhXt+6kbWS39Ff6hRN8T0YvscS6z2AIhALsH12eFSxr/yurkC+Z2DB70brhKI30OEHlg/qSm+gO5"}]},"_npmUser":{"name":"elron","email":"elron100duck@gmail.com"},"directories":{},"maintainers":[{"name":"elron","email":"elron100duck@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svelte-audio-store_0.0.1_1693147829918_0.019665542626861487"},"_hasShrinkwrap":false},"0.0.2":{"name":"@elron/svelte-audio-store","version":"0.0.2","author":{"name":"Elron Bucai"},"license":"MIT","keywords":["svelte","audio","sound","store","playback","sound-effects","svelte-store","web-audio","audio-management","svelte-component","audio-player","sound-library","svelte-library","audio-preload","interactive-sound","game-audio","webapp-audio","svelte-audio","audio-api"],"repository":{"type":"git","url":"git+https://github.com/elron/svelte-audio-store.git"},"homepage":"https://svelte-audio-store.netlify.app/","bugs":{"url":"https://github.com/elron/svelte-audio-store/issues"},"exports":{".":{"types":"./dist/index.d.ts","svelte":"./dist/index.js"}},"peerDependencies":{"svelte":"^4.0.0"},"devDependencies":{"@sveltejs/adapter-auto":"^2.0.0","@sveltejs/kit":"^1.20.4","@sveltejs/package":"^2.0.0","@typescript-eslint/eslint-plugin":"^5.45.0","@typescript-eslint/parser":"^5.45.0","eslint":"^8.28.0","eslint-config-prettier":"^8.5.0","eslint-plugin-svelte":"^2.30.0","prettier":"^2.8.0","prettier-plugin-svelte":"^2.10.1","publint":"^0.1.9","svelte":"^4.0.5","svelte-check":"^3.4.3","tslib":"^2.4.1","typescript":"^5.0.0","vite":"^4.4.2","vitest":"^0.34.0"},"svelte":"./dist/index.js","types":"./dist/index.d.ts","type":"module","scripts":{"dev":"vite dev","build":"vite build && npm run package","preview":"vite preview","package":"svelte-kit sync && svelte-package && publint","check":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json","check:watch":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch","test":"vitest","lint":"prettier --plugin-search-dir . --check . && eslint .","format":"prettier --plugin-search-dir . --write ."},"description":"A Svelte store for managing and playing audio, available as @elron/svelte-audio-store on npm.","_id":"@elron/svelte-audio-store@0.0.2","_integrity":"sha512-FCysjLD2FY6nSLftUXac9hNjg96y9pAlqOo26Jo9ZOg5ypf46MS7SwmIDljR6bRH0JgVR7k4arEJWbC322iqeQ==","_resolved":"/private/var/folders/0f/2xtv0jzn15751v32f01znrb80000gn/T/3b7bbfafc095eaffabe133617607e08d/elron-svelte-audio-store-0.0.2.tgz","_from":"file:elron-svelte-audio-store-0.0.2.tgz","_nodeVersion":"20.3.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-FCysjLD2FY6nSLftUXac9hNjg96y9pAlqOo26Jo9ZOg5ypf46MS7SwmIDljR6bRH0JgVR7k4arEJWbC322iqeQ==","shasum":"4c2402c860c4e678943109f33cf4b0665541d0d0","tarball":"https://registry.npmjs.org/@elron/svelte-audio-store/-/svelte-audio-store-0.0.2.tgz","fileCount":6,"unpackedSize":14309,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDVSKm/gJMQvo3tdP0Un8Zi2JJAy53ZZJnfKNRAF+i50AIhAIiCFnQLNmchU5HzS3gbkPxLCWaZzkcqkfALnHGvo9R0"}]},"_npmUser":{"name":"elron","email":"elron100duck@gmail.com"},"directories":{},"maintainers":[{"name":"elron","email":"elron100duck@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svelte-audio-store_0.0.2_1693148034789_0.9337032196060322"},"_hasShrinkwrap":false},"0.0.3":{"name":"@elron/svelte-audio-store","version":"0.0.3","author":{"name":"Elron Bucai"},"license":"MIT","keywords":["svelte","audio","sound","store","playback","sound-effects","svelte-store","web-audio","audio-management","svelte-component","audio-player","sound-library","svelte-library","audio-preload","interactive-sound","game-audio","webapp-audio","svelte-audio","audio-api"],"repository":{"type":"git","url":"git+https://github.com/elron/svelte-audio-store.git"},"homepage":"https://svelte-audio-store.netlify.app/","bugs":{"url":"https://github.com/elron/svelte-audio-store/issues"},"exports":{".":{"types":"./dist/index.d.ts","svelte":"./dist/index.js"}},"peerDependencies":{"svelte":"^4.0.0"},"devDependencies":{"@sveltejs/adapter-auto":"^2.0.0","@sveltejs/kit":"^1.20.4","@sveltejs/package":"^2.0.0","@typescript-eslint/eslint-plugin":"^5.45.0","@typescript-eslint/parser":"^5.45.0","eslint":"^8.28.0","eslint-config-prettier":"^8.5.0","eslint-plugin-svelte":"^2.30.0","prettier":"^2.8.0","prettier-plugin-svelte":"^2.10.1","publint":"^0.1.9","svelte":"^4.0.5","svelte-check":"^3.4.3","tslib":"^2.4.1","typescript":"^5.0.0","vite":"^4.4.2","vitest":"^0.34.0"},"svelte":"./dist/index.js","types":"./dist/index.d.ts","type":"module","scripts":{"dev":"vite dev","build":"vite build && npm run package","preview":"vite preview","package":"svelte-kit sync && svelte-package && publint","check":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json","check:watch":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch","test":"vitest","lint":"prettier --plugin-search-dir . --check . && eslint .","format":"prettier --plugin-search-dir . --write ."},"description":"A Svelte store for managing and playing audio, available as @elron/svelte-audio-store on npm.","_id":"@elron/svelte-audio-store@0.0.3","_integrity":"sha512-dlhSQqcyO2ZJsmVLo+KQtOfHIuQy2CoBUORdoTCJ1TCpB0oEkKuewmYmT4xLHxOTG+bejcVqreMJ7WuQqYYMeQ==","_resolved":"/private/var/folders/0f/2xtv0jzn15751v32f01znrb80000gn/T/d69aa790d5326ec6a091dc00d325d3e7/elron-svelte-audio-store-0.0.3.tgz","_from":"file:elron-svelte-audio-store-0.0.3.tgz","_nodeVersion":"20.3.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-dlhSQqcyO2ZJsmVLo+KQtOfHIuQy2CoBUORdoTCJ1TCpB0oEkKuewmYmT4xLHxOTG+bejcVqreMJ7WuQqYYMeQ==","shasum":"02f78f384ad9cf9d2d838eface6c4167a7cc06bb","tarball":"https://registry.npmjs.org/@elron/svelte-audio-store/-/svelte-audio-store-0.0.3.tgz","fileCount":6,"unpackedSize":14404,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDxPIcwIkHgUGmWBp+/eJRaeWIBIrRlRTy3vWjwQl7fvAIhAIKchL27/MvQFTnIzhAsHCSGer0GS6VgclyrhQSnOHXu"}]},"_npmUser":{"name":"elron","email":"elron100duck@gmail.com"},"directories":{},"maintainers":[{"name":"elron","email":"elron100duck@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svelte-audio-store_0.0.3_1693148744172_0.0037665771906130185"},"_hasShrinkwrap":false},"1.0.0":{"name":"@elron/svelte-audio-store","version":"1.0.0","author":{"name":"Elron Bucai"},"license":"MIT","keywords":["svelte","audio","sound","store","playback","sound-effects","svelte-store","web-audio","audio-management","svelte-component","audio-player","sound-library","svelte-library","audio-preload","interactive-sound","game-audio","webapp-audio","svelte-audio","audio-api"],"repository":{"type":"git","url":"git+https://github.com/elron/svelte-audio-store.git"},"homepage":"https://svelte-audio-store.netlify.app/","bugs":{"url":"https://github.com/elron/svelte-audio-store/issues"},"exports":{".":{"types":"./dist/index.d.ts","svelte":"./dist/index.js"}},"peerDependencies":{"svelte":"^4.0.0"},"devDependencies":{"@sveltejs/adapter-auto":"^2.0.0","@sveltejs/kit":"^1.20.4","@sveltejs/package":"^2.0.0","@typescript-eslint/eslint-plugin":"^5.45.0","@typescript-eslint/parser":"^5.45.0","eslint":"^8.28.0","eslint-config-prettier":"^8.5.0","eslint-plugin-svelte":"^2.30.0","prettier":"^2.8.0","prettier-plugin-svelte":"^2.10.1","publint":"^0.1.9","svelte":"^4.0.5","svelte-check":"^3.4.3","tslib":"^2.4.1","typescript":"^5.0.0","vite":"^4.4.2","vitest":"^0.34.0"},"svelte":"./dist/index.js","types":"./dist/index.d.ts","type":"module","scripts":{"dev":"vite dev","build":"vite build && npm run package","preview":"vite preview","package":"svelte-kit sync && svelte-package && publint","check":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json","check:watch":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch","test":"vitest","lint":"prettier --plugin-search-dir . --check . && eslint .","format":"prettier --plugin-search-dir . --write ."},"description":"A Svelte store for managing and playing audio, available as @elron/svelte-audio-store on npm.","_id":"@elron/svelte-audio-store@1.0.0","_integrity":"sha512-ksBF88rG4cbIt+ZLrxMKDdr1CxWxxEiyyZfHfNHCF/G9O2eDflSnCytSpid0Y43R4DwK+AukUlFfc0j5evqqEw==","_resolved":"/private/var/folders/0f/2xtv0jzn15751v32f01znrb80000gn/T/30f4bb4b4467617f73035ec7baba5af5/elron-svelte-audio-store-1.0.0.tgz","_from":"file:elron-svelte-audio-store-1.0.0.tgz","_nodeVersion":"20.3.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-ksBF88rG4cbIt+ZLrxMKDdr1CxWxxEiyyZfHfNHCF/G9O2eDflSnCytSpid0Y43R4DwK+AukUlFfc0j5evqqEw==","shasum":"7c7079bf5341c8f3178ebfc3bbc9a107c0b812af","tarball":"https://registry.npmjs.org/@elron/svelte-audio-store/-/svelte-audio-store-1.0.0.tgz","fileCount":6,"unpackedSize":14507,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIE52t7dQ6jLl1d0x7d3xOOBpAOZGwB9GxRY3ic7t3w+3AiEAyKM4AocHfACo3nsO8uXNONbXyWj4CyYAQ0C0UAJPX+8="}]},"_npmUser":{"name":"elron","email":"elron100duck@gmail.com"},"directories":{},"maintainers":[{"name":"elron","email":"elron100duck@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/svelte-audio-store_1.0.0_1693410692661_0.052049514254668416"},"_hasShrinkwrap":false}},"time":{"created":"2023-08-27T14:50:29.843Z","0.0.1":"2023-08-27T14:50:30.088Z","modified":"2023-08-30T15:51:33.010Z","0.0.2":"2023-08-27T14:53:54.992Z","0.0.3":"2023-08-27T15:05:44.321Z","1.0.0":"2023-08-30T15:51:32.838Z"},"maintainers":[{"name":"elron","email":"elron100duck@gmail.com"}],"description":"A Svelte store for managing and playing audio, available as @elron/svelte-audio-store on npm.","homepage":"https://svelte-audio-store.netlify.app/","keywords":["svelte","audio","sound","store","playback","sound-effects","svelte-store","web-audio","audio-management","svelte-component","audio-player","sound-library","svelte-library","audio-preload","interactive-sound","game-audio","webapp-audio","svelte-audio","audio-api"],"repository":{"type":"git","url":"git+https://github.com/elron/svelte-audio-store.git"},"author":{"name":"Elron Bucai"},"bugs":{"url":"https://github.com/elron/svelte-audio-store/issues"},"license":"MIT","readme":"# svelte-audio-store\n\nA Svelte store for managing and playing audio, available as @elron/svelte-audio-store on npm.\n\n`svelte-audio-store` provides a seamless way to manage audio in your Svelte projects. Whether it's for a game, a web application, or any project needing sound, `svelte-audio-store` offers an intuitive API to preload, play, stop, and manipulate audio.\n\n**Example:** [Demo](https://svelte-audio-store.netlify.app/)\n\n**Package Showcase:** [The Confetti Game](https://svelte-audio-store.netlify.app/) \n\n![TypeScript Auto Types using svelte-audio-store](./repo/svelte-audio-store-typescript-autoimport.gif)\n\n\n## Installation\n\n```bash\n# pnpm\npnpm install @elron/svelte-audio-store@latest\n\n# npm\nnpm install @elron/svelte-audio-store@latest\n\n# Yarn\nyarn add @elron/svelte-audio-store@latest\n```\n\n## Getting Started\n\n### 1. Create an Audio Store\n\nDefine a set of sounds for your application by associating keys to sound paths. You can give any unique key name to each sound to make it easy to remember and use.\n\nFor example, if you're creating:\n\n```svelte\nimport { createAudioStore } from '@elron/svelte-audio-store';\n\nconst sounds = {\n  click: '/sounds/click.mp3',\n  notification: '/sounds/notification.wav',\n  alert: '/sounds/alert.mp3',\n  // ... other sounds ...\n};\n\nexport const gameSounds = createAudioStore(sounds);\n```\n\nBy using descriptive key names, it becomes intuitive to play specific sounds in your application.\n\nYou're also free to name your store based on its function or theme. Some naming ideas:\n\n- `uiSounds` for user-interface specific audio.\n- `gameSounds` if you're creating a game and have many sounds.\n- `bgMusicStore` for background music tracks.\n- `effectSounds` for short-lived sound effects.\n\n### 2. Preloading Sounds\nIt's a good practice to preload your sounds, especially if they are crucial to the user experience. This ensures sounds are loaded into memory for faster playback. Use the `preload` method when your component mounts.\n\n```svelte\n<script>\n  import { onMount } from 'svelte';\n  import { gameSounds } from './gameStore';\n\n  onMount(() => {\n    gameSounds.preload();\n  });\n</script>\nThis code usually goes into `+layout.svelte`, but feel free to use it however makes sense in your project.\n```\n\n## Usage & Examples\n\n### Play a Sound\n\n```svelte\n<script>\n  import { gameSounds } from './gameStore';\n\n  function playGoSound() {\n    gameSounds.play('go');\n  }\n</script>\n\n<button on:click={playGoSound}>Play Go Sound</button>\n```\n\n### Stop a sound\n```svelte\n<script>\n  function stopGoSound() {\n    gameSounds.stop('go');\n  }\n</script>\n<button on:click={stopGoSound}>Stop Go Sound</button>\n```\n\n### Adjust Volume (for all sounds)\n```svelte\n<script>\n  function setVolumeToHalf() {\n    gameSounds.setVolume(0.5);\n  }\n</script>\n\n<button on:click={setVolumeToHalf}>Set Volume to 50%</button>\n```\n\n### Looping a sound\n```ts\ngameSounds.play('bgmusic', { loop: true });\n```\n\n### Fading a sound\n\nFade in and out when a component is mounted and unmounted:\n```ts\n// plays background-music faded in\nonMount(() => gameSounds.play('bgmusic', { fade: 2000 }));\n\n// stops background-music faded out\nonDestory(() => gameSounds.stop('bgmusic', { fade: 2000 }));\n```\n\n### Random pitch\nFor making sound variations, you can pitch it randomly (good for games):\n```ts\ngameSounds.play('ouch', { pitch: randomBetween(0.8, 1.4) });\n```\n\n### Trim a sound\nIf you need to play only a portion of a sound-track:\n```ts\n// Starts on second 1.5 and continues until finish\ngameSounds.play('ouch', { trim: {start: 1.5} });\n\n// Starts on second 1.5 and continues until second 3\ngameSounds.play('ouch', { trim: {start: 1.5, end: 3} });\n\n// Starts on 300ms and continues until 600ms\ngameSounds.play('ouch', { trim: {start: 0.3, end: 0.6} });\n```\n\n## Advanced Options\n`AudioStore` offers advanced playback settings like adjusting pitch, volume, loops, fades, and trimming. For a complete list of options, check the `PlayOptions` interface in the `AudioStore.ts` module.\n\nThe `play` and `stop` methods support various advanced options:\n\n\n| Option\t| Type | Description\t| Default Value | \n|---|---|---|---|\n| volume\t|`number` (0.0 - 1.0)\t| Adjusts the playback volume of the sound. Values should be between 0.0 (muted) and 1.0 (full volume).\t| `None` | \n| loop\t| `boolean` |Determines if the sound should loop indefinitely.\t| `false` | \n| fade\t| `number` (milliseconds) \t| Duration (in milliseconds) for a fade-in (when playing) or fade-out (when stopping).\t| `None` | \n| pitch\t|  `number` | Adjusts the playback speed and pitch of the sound. A value of 1.0 is the normal rate.\t| `1.0` | \n| preservesPitch |`boolean`\t| If set to true, changing the pitch with playbackRate won't affect the sound's pitch. Browser support varies.\t| `false` | \n| trim\t| `object { start?: number, end?: number }` | An object specifying when to start (start) and stop (stop) the playback, in seconds.\t| `None` | \n\n\n\n## Contributing\nWant to contribute?\n\n1. Fork the repo.\n2. Make your changes.\n3. Submit a pull request.\n\n## License\nMIT License: Open and free to use, modify, and distribute. See LICENSE file for full details.","readmeFilename":"README.md"}