{
const audio = new Float32Array(filteredStates.map(s => s.velocity))
const audioCtx = new AudioContext();
const sourceBuffer = audioCtx.createBuffer(1, audio.length, audioCtx.sampleRate);
const channelData = sourceBuffer.getChannelData(0);
channelData.set(audio);
const newSampleRate = 44100;
const newLength = Math.round(channelData.length * (newSampleRate / audioCtx.sampleRate));
const newBuffer = audioCtx.createBuffer(1, newLength, newSampleRate);
const newChannelData = newBuffer.getChannelData(0);
for (let i = 0; i < newLength; i++) {
const originalIndex = (i / newLength) * channelData.length;
const floorIndex = Math.floor(originalIndex);
const ceilIndex = Math.ceil(originalIndex);
const fraction = originalIndex - floorIndex;
const floorValue = channelData[floorIndex];
const ceilValue = channelData[ceilIndex];
const interpolatedValue = (1 - fraction) * floorValue + fraction * ceilValue;
newChannelData[i] = interpolatedValue;
}
const source = audioCtx.createBufferSource();
source.buffer = newBuffer;
source.connect(audioCtx.destination);
source.start(0);
}