mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-22 02:58:32 +00:00
Merge pull request #239 from tidalcycles/load-samples-from-url
Load samples from url
This commit is contained in:
commit
5eae156134
@ -102,7 +102,13 @@ export const loadGithubSamples = async (path, nameFn) => {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const samples = (sampleMap, baseUrl = sampleMap._base || '') => {
|
export const samples = async (sampleMap, baseUrl = sampleMap._base || '') => {
|
||||||
|
if (typeof sampleMap === 'string') {
|
||||||
|
const base = sampleMap.split('/').slice(0, -1).join('/');
|
||||||
|
return fetch(sampleMap)
|
||||||
|
.then((res) => res.json())
|
||||||
|
.then((json) => samples(json, baseUrl || json._base || base));
|
||||||
|
}
|
||||||
sampleCache.current = {
|
sampleCache.current = {
|
||||||
...sampleCache.current,
|
...sampleCache.current,
|
||||||
...Object.fromEntries(
|
...Object.fromEntries(
|
||||||
|
|||||||
@ -1,23 +1,17 @@
|
|||||||
import { Pattern, toMidi } from '@strudel.cycles/core';
|
import { Pattern, toMidi } from '@strudel.cycles/core';
|
||||||
import { samples } from '@strudel.cycles/webaudio';
|
import { samples } from '@strudel.cycles/webaudio';
|
||||||
|
|
||||||
const loadSamples = async (url, baseDir = '') => {
|
|
||||||
await fetch(url)
|
|
||||||
.then((res) => res.json())
|
|
||||||
.then((json) => samples(json, baseDir));
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function prebake({ isMock = false, baseDir = '.' } = {}) {
|
export async function prebake({ isMock = false, baseDir = '.' } = {}) {
|
||||||
if (!isMock) {
|
if (!isMock) {
|
||||||
// https://archive.org/details/SalamanderGrandPianoV3
|
// https://archive.org/details/SalamanderGrandPianoV3
|
||||||
// License: CC-by http://creativecommons.org/licenses/by/3.0/ Author: Alexander Holm
|
// License: CC-by http://creativecommons.org/licenses/by/3.0/ Author: Alexander Holm
|
||||||
loadSamples('piano.json', `${baseDir}/piano/`);
|
samples('piano.json', `${baseDir}/piano/`);
|
||||||
// https://github.com/sgossner/VCSL/
|
// https://github.com/sgossner/VCSL/
|
||||||
// https://api.github.com/repositories/126427031/contents/
|
// https://api.github.com/repositories/126427031/contents/
|
||||||
// LICENSE: CC0 general-purpose
|
// LICENSE: CC0 general-purpose
|
||||||
loadSamples('vcsl.json', 'github:sgossner/VCSL/master/');
|
samples('vcsl.json', 'github:sgossner/VCSL/master/');
|
||||||
loadSamples('tidal-drum-machines.json', 'github:ritchse/tidal-drum-machines/main/machines/');
|
samples('tidal-drum-machines.json', 'github:ritchse/tidal-drum-machines/main/machines/');
|
||||||
loadSamples('EmuSP12.json', `${baseDir}/EmuSP12/`);
|
samples('EmuSP12.json', `${baseDir}/EmuSP12/`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user