This commit is contained in:
Jade (Rose) Rowland 2025-09-27 15:29:55 -04:00
parent 626a99ba5b
commit 774372a339
6 changed files with 19 additions and 23 deletions

View file

@ -23,8 +23,8 @@ function humanFileSize(bytes, si) {
}
export function getSampleInfo(hapValue, bank) {
const { speed = 1.0 } = hapValue;
const {transpose, url, index, midi, label} = getCommonSampleInfo(hapValue, bank)
const { speed = 1.0 } = hapValue;
const { transpose, url, index, midi, label } = getCommonSampleInfo(hapValue, bank);
let playbackRate = Math.abs(speed) * Math.pow(2, transpose / 12);
return { transpose, url, index, midi, label, playbackRate };
}
@ -245,11 +245,10 @@ export const samples = async (sampleMap, baseUrl = sampleMap._base || '', option
}
const { prebake, tag } = options;
processSampleMap(
sampleMap,
(key, bank) => {
registerSampleSource(key, bank, { baseUrl, prebake, tag })
registerSampleSource(key, bank, { baseUrl, prebake, tag });
},
baseUrl,
);
@ -341,21 +340,19 @@ export async function onTriggerSample(t, value, onended, bank, resolveUrl) {
return handle;
}
function registerSample(key, bank, params) {
registerSound(key, (t, hapValue, onended) => onTriggerSample(t, hapValue, onended, bank), {
type: 'sample',
samples: bank,
...params
})
...params,
});
}
export function registerSampleSource(key, bank, params) {
const isWavetable = key.startsWith('wt_');
if (isWavetable) {
registerWaveTable(key,bank, params)
registerWaveTable(key, bank, params);
} else {
registerSample(key, bank, params)
registerSample(key, bank, params);
}
}
}

View file

@ -100,7 +100,7 @@ export function getCommonSampleInfo(hapValue, bank) {
transpose = -midiDiff(closest); // semitones to repitch
index = getSoundIndex(n, bank[closest].length);
url = bank[closest][index];
}
}
const label = `${s}:${index}`;
return { transpose, url, index, midi, label };
}
}

View file

@ -43,7 +43,7 @@ async function loadWavetableFrames(url, label, frameLen = 2048) {
const buf = await loadBuffer(url, ac, label);
const ch0 = buf.getChannelData(0);
const total = ch0.length;
const numFrames = Math.max(1,Math.floor(total / frameLen));
const numFrames = Math.max(1, Math.floor(total / frameLen));
const frames = new Array(numFrames);
for (let i = 0; i < numFrames; i++) {
const start = i * frameLen;
@ -87,7 +87,7 @@ function humanFileSize(bytes, si) {
}
export function getTableInfo(hapValue, urls) {
return getCommonSampleInfo(hapValue,urls)
return getCommonSampleInfo(hapValue, urls);
}
const loadBuffer = (url, ac, label) => {
@ -134,15 +134,15 @@ const _processTables = (json, baseUrl, frameLen) => {
baseUrl = githubPath(baseUrl, '');
}
value = value.map((v) => baseUrl + v);
registerWaveTable(key,value, {baseUrl, frameLen})
registerWaveTable(key, value, { baseUrl, frameLen });
});
};
export function registerWaveTable(key, bank, params) {
export function registerWaveTable(key, bank, params) {
registerSound(key, (t, hapValue, onended) => onTriggerSynth(t, hapValue, onended, bank, params?.frameLen ?? 2048), {
type: 'wavetable',
tables: bank,
...params
...params,
});
}

View file

@ -1049,7 +1049,7 @@ class WavetableOscillatorProcessor extends AudioWorkletProcessor {
{ name: 'begin', defaultValue: 0, min: 0, max: Number.POSITIVE_INFINITY },
{ name: 'end', defaultValue: 0, min: 0, max: Number.POSITIVE_INFINITY },
{ name: 'frequency', defaultValue: 220, minValue: 0.01, maxValue: 20000 },
{ name: 'detune', defaultValue: .18 },
{ name: 'detune', defaultValue: 0.18 },
{ name: 'position', defaultValue: 0, minValue: 0, maxValue: 1 },
{ name: 'warp', defaultValue: 0, minValue: 0, maxValue: 1 },
{ name: 'warpMode', defaultValue: 0 },
@ -1239,7 +1239,7 @@ class WavetableOscillatorProcessor extends AudioWorkletProcessor {
}
const outL = outputs[0][0];
const outR = outputs[0][1] || outputs[0][0];
const gainAdjustment = .15;
const gainAdjustment = 0.3;
if (!this.tables) {
outL.fill(0);

View file

@ -76,8 +76,7 @@ export function registerSamplesFromDB(config = userSamplesDBConfig, onComplete =
})
.map((title) => titlePathMap.get(title));
registerSampleSource(key,value, {prebake: false})
registerSampleSource(key, value, { prebake: false });
});
logger('imported sounds registered!', 'success');

View file

@ -33,7 +33,7 @@ export async function prebake() {
tag: 'drum-machines',
}),
samples(`${baseNoTrailing}/uzu-wavetables.json`, undefined, {
prebake: true,
prebake: true,
}),
samples(`${baseNoTrailing}/mridangam.json`, undefined, { prebake: true, tag: 'drum-machines' }),
samples(