Skip to content

Commit

Permalink
variable number of samples to fill
Browse files Browse the repository at this point in the history
  • Loading branch information
petersalomonsen committed Feb 9, 2024
1 parent 2eef23e commit 57e7985
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion wasmaudioworklet/synth1/assembly/midi/midisynth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const sampleBufferBytesPerChannel = sampleBufferFrames * 4;
export const sampleBufferChannels = 2;
export const samplebuffer = new StaticArray<f32>(sampleBufferFrames * sampleBufferChannels);
const bufferposstart = changetype<usize>(samplebuffer);
const bufferposend = changetype<usize>(samplebuffer) + sampleBufferBytesPerChannel;

const CONTROL_SUSTAIN: u8 = 64;
const CONTROL_VOLUME: u8 = 7;
Expand Down Expand Up @@ -285,6 +284,12 @@ export function playActiveVoices(): void {
}

export function fillSampleBuffer(): void {
fillSampleBufferWithNumSamples(sampleBufferFrames);
}

export function fillSampleBufferWithNumSamples(numSamples: i32): void {
const bufferposend = changetype<usize>(samplebuffer) + 4 * numSamples;

cleanupInactiveVoices();

let voiceTransitionBufferNdx = 0;
Expand Down
1 change: 1 addition & 0 deletions wasmaudioworklet/synth1/assembly/mixes/globalimports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export { allNotesOff } from '../midi/midisynth';
export { cleanupInactiveVoices } from '../midi/midisynth';
export { playActiveVoices } from '../midi/midisynth';
export { fillSampleBuffer } from '../midi/midisynth';
export { fillSampleBufferWithNumSamples } from '../midi/midisynth';
export { Q_BUTTERWORTH } from '../synth/biquad';
export { FilterType } from '../synth/biquad';
export { Coefficients } from '../synth/biquad';
Expand Down

Large diffs are not rendered by default.

0 comments on commit 57e7985

Please sign in to comment.