@aurio/soundbank
v0.1.1
Published
Simple HTTP soundbank server for serving a Strudel soundbank
Maintainers
Readme
@aurio/soundbank
A tiny HTTP server for serving local audio samples to Strudel.
Inspired by @strudel/sampler but with a few changes I needed to make.
- No dependencies (not even cows).
- No PostgreSQL default port conflicts.
- No Directory traversal
- No re-scan on each request by default. The whole point is to have as close to zero latency as possible. Index rebuild is opt-in and based on file-watching, so it's still better.
Installation
Run directly with npx:
npx @aurio/soundbankOr install globally:
npm install -g @aurio/soundbank
soundbankUsage
Serve samples from the current directory:
soundbankServe samples from a specific directory:
soundbank --dir ~/SamplesUse a custom port:
soundbank --port 9000Generate a strudel.json file and exit:
soundbank --jsonWatch the directory and automatically rebuild the sample index when files change:
soundbank --watchStrudel
After starting the server:
Serving soundbank:
/Users/alice/Samples
- http://localhost:8787
- http://192.168.1.143:8787Use the displayed URL directly in Strudel:
await samples("http://localhost:8787");If another device on your local network needs access, use the LAN URL printed by the server.
Supported Formats
- WAV (
.wav) - MP3 (
.mp3) - OGG (
.ogg)
Bank Naming
Given the following directory structure:
Samples/
├── drums/
│ ├── kick.wav
│ └── snare.wav
└── bass/
└── sub.wavThe generated banks are:
{
"drums": [
"/drums/kick.wav",
"/drums/snare.wav"
],
"bass": [
"/bass/sub.wav"
]
}With --flat, paths are flattened into unique names:
{
"drums_kick": [
"/drums/kick.wav"
],
"drums_snare": [
"/drums/snare.wav"
],
"bass_sub": [
"/bass/sub.wav"
]
}Security
@aurio/soundbank only serves files located under the configured root directory.
Path traversal attempts such as:
../../etc/passwdare rejected.
Why?
This package started as a clean-room replacement for another sample server whose implementation had accumulated several design issues:
- unnecessary runtime dependencies
- repeated filesystem scans on every request
- synchronous filesystem operations inside asynchronous handlers
- lack of path traversal protection
- poor defaults
The goal of @aurio/soundbank is simple:
Serve audio files to Strudel with as little code and as few surprises as possible.
License
MIT
