Fix MP3 export against smplr 0.24 (pass scheduler directly to SplendidGrandPiano)
This commit is contained in:
@@ -591,8 +591,7 @@ export const useAppStore = create<AppState>((set, get) => {
|
|||||||
try {
|
try {
|
||||||
// Lazy-load smplr so this code path doesn't bloat the initial bundle
|
// Lazy-load smplr so this code path doesn't bloat the initial bundle
|
||||||
// for users who never export.
|
// for users who never export.
|
||||||
const { renderOffline, Smplr, Scheduler, HttpStorage, pianoToSmplrJson } =
|
const { renderOffline, Scheduler, SplendidGrandPiano } = await import("smplr");
|
||||||
await import("smplr");
|
|
||||||
|
|
||||||
// Tail buffer so the final note's release isn't cut off + small lead-in
|
// Tail buffer so the final note's release isn't cut off + small lead-in
|
||||||
// so the first note isn't clipped at sample 0.
|
// so the first note isn't clipped at sample 0.
|
||||||
@@ -612,25 +611,16 @@ export const useAppStore = create<AppState>((set, get) => {
|
|||||||
//
|
//
|
||||||
// Workaround: construct our own Scheduler with a huge lookahead
|
// Workaround: construct our own Scheduler with a huge lookahead
|
||||||
// (effectively infinite) so EVERY note falls within the synchronous
|
// (effectively infinite) so EVERY note falls within the synchronous
|
||||||
// dispatch branch in Scheduler.schedule(). Then we bypass the
|
// dispatch branch in Scheduler.schedule(). smplr 0.24's
|
||||||
// SplendidGrandPiano wrapper (which doesn't forward `scheduler` to
|
// SplendidGrandPiano options now accept SmplrOptions (including
|
||||||
// its internal Smplr) and instantiate Smplr directly with the
|
// `scheduler`), so we pass it directly to the wrapper rather than
|
||||||
// piano's JSON config + our scheduler.
|
// bypassing to the low-level Smplr class.
|
||||||
//
|
//
|
||||||
// v1: always render with SplendidGrandPiano regardless of the
|
// v1: always render with SplendidGrandPiano regardless of the
|
||||||
// currently-selected live instrument. 99% of users are on the
|
// currently-selected live instrument. 99% of users are on the
|
||||||
// default "grand" anyway; we can extend per-instrument later.
|
// default "grand" anyway; we can extend per-instrument later.
|
||||||
const scheduler = new Scheduler(ctx, { lookaheadMs: 86_400_000 });
|
const scheduler = new Scheduler(ctx, { lookaheadMs: 86_400_000 });
|
||||||
// pianoToSmplrJson only takes piano-shape options. The storage
|
const player = new SplendidGrandPiano(ctx, { scheduler });
|
||||||
// backend belongs in the Smplr constructor's options (where the
|
|
||||||
// SplendidGrandPiano wrapper also passes it). HttpStorage is a
|
|
||||||
// const singleton, not a class - no `new`.
|
|
||||||
const json = pianoToSmplrJson({
|
|
||||||
baseUrl: "https://smpldsnds.github.io/sfzinstruments-splendid-grand-piano/samples",
|
|
||||||
detune: 0,
|
|
||||||
decayTime: 0.5,
|
|
||||||
});
|
|
||||||
const player = new Smplr(ctx, json, { scheduler, storage: HttpStorage });
|
|
||||||
await player.load;
|
await player.load;
|
||||||
|
|
||||||
// Schedule every note. velocity/duration straight from the doc;
|
// Schedule every note. velocity/duration straight from the doc;
|
||||||
|
|||||||
Reference in New Issue
Block a user