Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: piano loads subset of audio notes in layers #53

Merged
merged 1 commit into from
Dec 15, 2023

Conversation

georgecartridge
Copy link
Contributor

@georgecartridge georgecartridge commented Dec 15, 2023

Summary:
I've introduced the ability for the Splended Grand Piano component to load a subset of its audio files in the configuration object.

Why:
This allows you to reduce the amount of audio files downloaded by the user by specifying the notes and a velocity range that the user will play when setting the piano component up.

Changes:

  • added optional notesToLoad object to Splended Grand Piano's configuration object
  • added filtering for velocity and sample layers based on notesToLoad data
  • added unit tests for these changes

[Additional Note + Example]:
notesToLoad.velocityRange will include the notes given in notesToLoad.notes for all velocity layers in that velocity range.

So if a user wants to load audio files for the note C4 for all velocity layers, they can pass a notesToLoad object with this data. The resulting component would look like this

import { SplendidGrandPiano } from "smplr";

const context = new AudioContext();
const piano = new SplendidGrandPiano(context, { 
     notesToLoad:  {
          notes: [60],
          velocityRange: [1, 127],
     }
});

piano.start({ note: "C4" });

@danigb danigb merged commit 410c86b into danigb:main Dec 15, 2023
@danigb
Copy link
Owner

danigb commented Dec 15, 2023

Thanks!

@danigb
Copy link
Owner

danigb commented Dec 15, 2023

BTW, published v0.12.0

@georgecartridge
Copy link
Contributor Author

BTW, published v0.12.0

I just tried updating my smplr version but the feature changes don't seem to have been published in the package. The updated README file is there, just not the code in the merged commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants