mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-24 12:08:28 +00:00
regroup sounds
- extra tab for drum-machines - combine synths and soundfonts
This commit is contained in:
parent
15681262de
commit
e63a5d10c8
@ -140,7 +140,7 @@ export function registerSoundfonts() {
|
|||||||
};
|
};
|
||||||
return { node: envelope, stop };
|
return { node: envelope, stop };
|
||||||
},
|
},
|
||||||
{ type: 'soundfont', prebake: true },
|
{ type: 'soundfont', prebake: true, fonts },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -129,7 +129,7 @@ export const samples = async (sampleMap, baseUrl = sampleMap._base || '', option
|
|||||||
throw new Error(`error loading "${sampleMap}"`);
|
throw new Error(`error loading "${sampleMap}"`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const { prebake } = options;
|
const { prebake, tag } = options;
|
||||||
Object.entries(sampleMap).forEach(([key, value]) => {
|
Object.entries(sampleMap).forEach(([key, value]) => {
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
value = [value];
|
value = [value];
|
||||||
@ -155,6 +155,7 @@ export const samples = async (sampleMap, baseUrl = sampleMap._base || '', option
|
|||||||
samples: value,
|
samples: value,
|
||||||
baseUrl,
|
baseUrl,
|
||||||
prebake,
|
prebake,
|
||||||
|
tag,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -191,34 +191,6 @@ function ConsoleTab({ log }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
function groupBy(obj = {}, getter) {
|
|
||||||
const grouped = Object.entries(obj).reduce((acc, [key, value]) => {
|
|
||||||
const propValue = getter(value, key);
|
|
||||||
if (!acc.has(propValue)) {
|
|
||||||
acc.set(propValue, new Map());
|
|
||||||
}
|
|
||||||
acc.get(propValue).set(key, value);
|
|
||||||
return acc;
|
|
||||||
}, new Map());
|
|
||||||
return grouped;
|
|
||||||
}
|
|
||||||
const grouped = useMemo(() => {
|
|
||||||
if (!sounds) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
return groupBy(sounds, (s) =>
|
|
||||||
s.data.type === 'sample' ? 'Samples from ' + s.data?.baseUrl : 'Type ' + s.data.type,
|
|
||||||
);
|
|
||||||
}, [sounds]);
|
|
||||||
|
|
||||||
{Array.from(grouped).map(([category, sounds]) => (
|
|
||||||
<Fragment key={category}>
|
|
||||||
<h3 className="pb-2 pt-4 text-lg">{category}:</h3>
|
|
||||||
</Fragment>
|
|
||||||
))}
|
|
||||||
*/
|
|
||||||
|
|
||||||
const getSamples = (samples) =>
|
const getSamples = (samples) =>
|
||||||
Array.isArray(samples) ? samples.length : typeof samples === 'object' ? Object.values(samples).length : 1;
|
Array.isArray(samples) ? samples.length : typeof samples === 'object' ? Object.values(samples).length : 1;
|
||||||
|
|
||||||
@ -233,14 +205,14 @@ function SoundsTab() {
|
|||||||
if (soundsFilter === 'user') {
|
if (soundsFilter === 'user') {
|
||||||
return filtered.filter(([key, { data }]) => !data.prebake);
|
return filtered.filter(([key, { data }]) => !data.prebake);
|
||||||
}
|
}
|
||||||
|
if (soundsFilter === 'drums') {
|
||||||
|
return filtered.filter(([_, { data }]) => data.type === 'sample' && data.tag === 'drum-machines');
|
||||||
|
}
|
||||||
if (soundsFilter === 'samples') {
|
if (soundsFilter === 'samples') {
|
||||||
return filtered.filter(([_, { data }]) => data.type === 'sample');
|
return filtered.filter(([_, { data }]) => data.type === 'sample' && data.tag !== 'drum-machines');
|
||||||
}
|
}
|
||||||
if (soundsFilter === 'synths') {
|
if (soundsFilter === 'synths') {
|
||||||
return filtered.filter(([_, { data }]) => data.type === 'synth');
|
return filtered.filter(([_, { data }]) => ['synth', 'soundfont'].includes(data.type));
|
||||||
}
|
|
||||||
if (soundsFilter === 'soundfonts') {
|
|
||||||
return filtered.filter(([_, { data }]) => data.type === 'soundfont');
|
|
||||||
}
|
}
|
||||||
return filtered;
|
return filtered;
|
||||||
}, [sounds, soundsFilter]);
|
}, [sounds, soundsFilter]);
|
||||||
@ -260,14 +232,19 @@ function SoundsTab() {
|
|||||||
<ButtonGroup
|
<ButtonGroup
|
||||||
value={soundsFilter}
|
value={soundsFilter}
|
||||||
onChange={(value) => settingsMap.setKey('soundsFilter', value)}
|
onChange={(value) => settingsMap.setKey('soundsFilter', value)}
|
||||||
items={{ samples: 'Samples', synths: 'Synths', soundfonts: 'Soundfonts', user: 'Custom' }}
|
items={{
|
||||||
|
samples: 'samples',
|
||||||
|
drums: 'drum-machines',
|
||||||
|
synths: 'Synths',
|
||||||
|
user: 'User',
|
||||||
|
}}
|
||||||
></ButtonGroup>
|
></ButtonGroup>
|
||||||
</div>
|
</div>
|
||||||
<div className="p-2 min-h-0 max-h-full grow overflow-auto font-mono text-sm break-normal">
|
<div className="p-2 min-h-0 max-h-full grow overflow-auto font-mono text-sm break-normal">
|
||||||
{soundEntries.map(([name, { data, onTrigger }]) => (
|
{soundEntries.map(([name, { data, onTrigger }]) => (
|
||||||
<span
|
<span
|
||||||
key={name}
|
key={name}
|
||||||
className="cursor-pointer hover:opacity-50 block"
|
className="cursor-pointer hover:opacity-50"
|
||||||
onMouseDown={async () => {
|
onMouseDown={async () => {
|
||||||
const ctx = getAudioContext();
|
const ctx = getAudioContext();
|
||||||
const params = {
|
const params = {
|
||||||
@ -287,6 +264,7 @@ function SoundsTab() {
|
|||||||
{' '}
|
{' '}
|
||||||
{name}
|
{name}
|
||||||
{data?.type === 'sample' ? `(${getSamples(data.samples)})` : ''}
|
{data?.type === 'sample' ? `(${getSamples(data.samples)})` : ''}
|
||||||
|
{data?.type === 'soundfont' ? `(${data.fonts.length})` : ''}
|
||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
{!soundEntries.length ? 'No custom sounds loaded in this pattern (yet).' : ''}
|
{!soundEntries.length ? 'No custom sounds loaded in this pattern (yet).' : ''}
|
||||||
|
|||||||
@ -13,8 +13,11 @@ export async function prebake() {
|
|||||||
// https://api.github.com/repositories/126427031/contents/
|
// https://api.github.com/repositories/126427031/contents/
|
||||||
// LICENSE: CC0 general-purpose
|
// LICENSE: CC0 general-purpose
|
||||||
samples(`./vcsl.json`, 'github:sgossner/VCSL/master/', { prebake: true }),
|
samples(`./vcsl.json`, 'github:sgossner/VCSL/master/', { prebake: true }),
|
||||||
samples(`./tidal-drum-machines.json`, 'github:ritchse/tidal-drum-machines/main/machines/', { prebake: true }),
|
samples(`./tidal-drum-machines.json`, 'github:ritchse/tidal-drum-machines/main/machines/', {
|
||||||
samples(`./EmuSP12.json`, `./EmuSP12/`, { prebake: true }),
|
prebake: true,
|
||||||
|
tag: 'drum-machines',
|
||||||
|
}),
|
||||||
|
samples(`./EmuSP12.json`, `./EmuSP12/`, { prebake: true, tag: 'drum-machines' }),
|
||||||
// samples('github:tidalcycles/Dirt-Samples/master'),
|
// samples('github:tidalcycles/Dirt-Samples/master'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user