format
This commit is contained in:
parent
626a99ba5b
commit
774372a339
6 changed files with 19 additions and 23 deletions
|
|
@ -23,8 +23,8 @@ function humanFileSize(bytes, si) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getSampleInfo(hapValue, bank) {
|
export function getSampleInfo(hapValue, bank) {
|
||||||
const { speed = 1.0 } = hapValue;
|
const { speed = 1.0 } = hapValue;
|
||||||
const {transpose, url, index, midi, label} = getCommonSampleInfo(hapValue, bank)
|
const { transpose, url, index, midi, label } = getCommonSampleInfo(hapValue, bank);
|
||||||
let playbackRate = Math.abs(speed) * Math.pow(2, transpose / 12);
|
let playbackRate = Math.abs(speed) * Math.pow(2, transpose / 12);
|
||||||
return { transpose, url, index, midi, label, playbackRate };
|
return { transpose, url, index, midi, label, playbackRate };
|
||||||
}
|
}
|
||||||
|
|
@ -245,11 +245,10 @@ export const samples = async (sampleMap, baseUrl = sampleMap._base || '', option
|
||||||
}
|
}
|
||||||
const { prebake, tag } = options;
|
const { prebake, tag } = options;
|
||||||
|
|
||||||
|
|
||||||
processSampleMap(
|
processSampleMap(
|
||||||
sampleMap,
|
sampleMap,
|
||||||
(key, bank) => {
|
(key, bank) => {
|
||||||
registerSampleSource(key, bank, { baseUrl, prebake, tag })
|
registerSampleSource(key, bank, { baseUrl, prebake, tag });
|
||||||
},
|
},
|
||||||
baseUrl,
|
baseUrl,
|
||||||
);
|
);
|
||||||
|
|
@ -341,21 +340,19 @@ export async function onTriggerSample(t, value, onended, bank, resolveUrl) {
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function registerSample(key, bank, params) {
|
function registerSample(key, bank, params) {
|
||||||
registerSound(key, (t, hapValue, onended) => onTriggerSample(t, hapValue, onended, bank), {
|
registerSound(key, (t, hapValue, onended) => onTriggerSample(t, hapValue, onended, bank), {
|
||||||
type: 'sample',
|
type: 'sample',
|
||||||
samples: bank,
|
samples: bank,
|
||||||
...params
|
...params,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function registerSampleSource(key, bank, params) {
|
export function registerSampleSource(key, bank, params) {
|
||||||
const isWavetable = key.startsWith('wt_');
|
const isWavetable = key.startsWith('wt_');
|
||||||
if (isWavetable) {
|
if (isWavetable) {
|
||||||
registerWaveTable(key,bank, params)
|
registerWaveTable(key, bank, params);
|
||||||
} else {
|
} else {
|
||||||
registerSample(key, bank, params)
|
registerSample(key, bank, params);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ export function getCommonSampleInfo(hapValue, bank) {
|
||||||
transpose = -midiDiff(closest); // semitones to repitch
|
transpose = -midiDiff(closest); // semitones to repitch
|
||||||
index = getSoundIndex(n, bank[closest].length);
|
index = getSoundIndex(n, bank[closest].length);
|
||||||
url = bank[closest][index];
|
url = bank[closest][index];
|
||||||
}
|
}
|
||||||
const label = `${s}:${index}`;
|
const label = `${s}:${index}`;
|
||||||
return { transpose, url, index, midi, label };
|
return { transpose, url, index, midi, label };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ async function loadWavetableFrames(url, label, frameLen = 2048) {
|
||||||
const buf = await loadBuffer(url, ac, label);
|
const buf = await loadBuffer(url, ac, label);
|
||||||
const ch0 = buf.getChannelData(0);
|
const ch0 = buf.getChannelData(0);
|
||||||
const total = ch0.length;
|
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);
|
const frames = new Array(numFrames);
|
||||||
for (let i = 0; i < numFrames; i++) {
|
for (let i = 0; i < numFrames; i++) {
|
||||||
const start = i * frameLen;
|
const start = i * frameLen;
|
||||||
|
|
@ -87,7 +87,7 @@ function humanFileSize(bytes, si) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTableInfo(hapValue, urls) {
|
export function getTableInfo(hapValue, urls) {
|
||||||
return getCommonSampleInfo(hapValue,urls)
|
return getCommonSampleInfo(hapValue, urls);
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadBuffer = (url, ac, label) => {
|
const loadBuffer = (url, ac, label) => {
|
||||||
|
|
@ -134,15 +134,15 @@ const _processTables = (json, baseUrl, frameLen) => {
|
||||||
baseUrl = githubPath(baseUrl, '');
|
baseUrl = githubPath(baseUrl, '');
|
||||||
}
|
}
|
||||||
value = value.map((v) => baseUrl + v);
|
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), {
|
registerSound(key, (t, hapValue, onended) => onTriggerSynth(t, hapValue, onended, bank, params?.frameLen ?? 2048), {
|
||||||
type: 'wavetable',
|
type: 'wavetable',
|
||||||
tables: bank,
|
tables: bank,
|
||||||
...params
|
...params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1049,7 +1049,7 @@ class WavetableOscillatorProcessor extends AudioWorkletProcessor {
|
||||||
{ name: 'begin', defaultValue: 0, min: 0, max: Number.POSITIVE_INFINITY },
|
{ name: 'begin', defaultValue: 0, min: 0, max: Number.POSITIVE_INFINITY },
|
||||||
{ name: 'end', 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: '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: 'position', defaultValue: 0, minValue: 0, maxValue: 1 },
|
||||||
{ name: 'warp', defaultValue: 0, minValue: 0, maxValue: 1 },
|
{ name: 'warp', defaultValue: 0, minValue: 0, maxValue: 1 },
|
||||||
{ name: 'warpMode', defaultValue: 0 },
|
{ name: 'warpMode', defaultValue: 0 },
|
||||||
|
|
@ -1239,7 +1239,7 @@ class WavetableOscillatorProcessor extends AudioWorkletProcessor {
|
||||||
}
|
}
|
||||||
const outL = outputs[0][0];
|
const outL = outputs[0][0];
|
||||||
const outR = outputs[0][1] || outputs[0][0];
|
const outR = outputs[0][1] || outputs[0][0];
|
||||||
const gainAdjustment = .15;
|
const gainAdjustment = 0.3;
|
||||||
|
|
||||||
if (!this.tables) {
|
if (!this.tables) {
|
||||||
outL.fill(0);
|
outL.fill(0);
|
||||||
|
|
|
||||||
|
|
@ -76,8 +76,7 @@ export function registerSamplesFromDB(config = userSamplesDBConfig, onComplete =
|
||||||
})
|
})
|
||||||
.map((title) => titlePathMap.get(title));
|
.map((title) => titlePathMap.get(title));
|
||||||
|
|
||||||
registerSampleSource(key,value, {prebake: false})
|
registerSampleSource(key, value, { prebake: false });
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
logger('imported sounds registered!', 'success');
|
logger('imported sounds registered!', 'success');
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ export async function prebake() {
|
||||||
tag: 'drum-machines',
|
tag: 'drum-machines',
|
||||||
}),
|
}),
|
||||||
samples(`${baseNoTrailing}/uzu-wavetables.json`, undefined, {
|
samples(`${baseNoTrailing}/uzu-wavetables.json`, undefined, {
|
||||||
prebake: true,
|
prebake: true,
|
||||||
}),
|
}),
|
||||||
samples(`${baseNoTrailing}/mridangam.json`, undefined, { prebake: true, tag: 'drum-machines' }),
|
samples(`${baseNoTrailing}/mridangam.json`, undefined, { prebake: true, tag: 'drum-machines' }),
|
||||||
samples(
|
samples(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue