Replaced by @generative-music/samples-alex-bainter.
Browser and Node client for accessing files from samples.generative.fm.
Access to samples.generative.fm is currently restricted with CORS. Unrecognized origins will not be able to fetch audio files.
There are three ways to import the client.
This method will detect if the package has been imported in a browser or Node environment.
import fetchSpecFile from 'samples.generative.fm';
// or
const fetchSpecFile from 'samples.generative.fm';
import fetchSpecFile from 'samples.generative.fm/browser-client';
const fetchSpecFile from 'samples.generative.fm/node-client';
The imported function can be used like so:
fetchSpecFile('my-sample-host.com', 'sample-spec.json').then(sampleInfo => {
console.log(sampleInfo.samples['sampled-instrument'].ogg['A4']);
// outputs something like 'https://samples.generative.fm/sampled-instrument/ogg/<filename>.ogg'
});
Returns an object containing information about the samples.
baseUrl
(string) [optional, default'https://samples.generative.fm'
]: Prepended to all requests.filename
(string) [optional, default'index.<CURRENT_PKG_VERSION>'.json
]: The filename to use when fetching the spec file.
The package is built with npm run build:pkg
.