@generative-music/samples.generative.fm

1.23.0 • Public • Published

samples.generative.fm

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.

Usage

There are three ways to import the client.

1. Environment Automatic Detection

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';

2. Browser-only

import fetchSpecFile from 'samples.generative.fm/browser-client';

3. Node-only

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'
});

API

fetchSpecFile([baseUrl], [filename])

Returns an object containing information about the samples.

Parameters

  • 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.

Local Development

The package is built with npm run build:pkg.

Readme

Keywords

none

Package Sidebar

Install

npm i @generative-music/samples.generative.fm

Weekly Downloads

3

Version

1.23.0

License

MIT

Unpacked Size

13.8 kB

Total Files

8

Last publish

Collaborators

  • metalex9