stuff
This commit is contained in:
24
src/API.ts
24
src/API.ts
@ -42,13 +42,23 @@ Array.prototype.in = function <T>(this: T[], value: T): boolean {
|
|||||||
return this.includes(value);
|
return this.includes(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Loading the Strudel sampler
|
|
||||||
Promise.all([
|
async function loadSamples() {
|
||||||
initAudioOnFirstClick(),
|
const ds = "https://raw.githubusercontent.com/felixroos/dough-samples/main/";
|
||||||
samples("github:tidalcycles/Dirt-Samples/master"),
|
return Promise.all([
|
||||||
samples("github:Bubobubobubobubo/Topos-Samples/main"),
|
initAudioOnFirstClick(),
|
||||||
registerSynthSounds(),
|
samples("github:Bubobubobubobubo/Topos-Samples/main"),
|
||||||
]);
|
samples(`${ds}/tidal-drum-machines.json`),
|
||||||
|
samples(`${ds}/piano.json`),
|
||||||
|
samples(`${ds}/Dirt-Samples.json`),
|
||||||
|
samples(`${ds}/EmuSP12.json`),
|
||||||
|
samples(`${ds}/vcsl.json`),
|
||||||
|
registerSynthSounds(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
loadSamples()
|
||||||
|
|
||||||
|
|
||||||
export class UserAPI {
|
export class UserAPI {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -45,9 +45,7 @@ export const tryEvaluate = async (
|
|||||||
if (cache.has(candidateCode)) {
|
if (cache.has(candidateCode)) {
|
||||||
// If the code is already in cache, use it
|
// If the code is already in cache, use it
|
||||||
cache.get(candidateCode)!.call(application.api);
|
cache.get(candidateCode)!.call(application.api);
|
||||||
console.log('Using cached code')
|
|
||||||
} else {
|
} else {
|
||||||
console.log('Evaluating code')
|
|
||||||
const wrappedCode = `let i = ${code.evaluations};` + candidateCode;
|
const wrappedCode = `let i = ${code.evaluations};` + candidateCode;
|
||||||
// Otherwise, evaluate the code and if valid, add it to the cache
|
// Otherwise, evaluate the code and if valid, add it to the cache
|
||||||
const isCodeValid = await Promise.race([
|
const isCodeValid = await Promise.race([
|
||||||
|
|||||||
Reference in New Issue
Block a user