Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

[doc] How to schedule notes with duration and velocity? #4

Open
mk-pmb opened this issue Aug 25, 2017 · 3 comments
Open

[doc] How to schedule notes with duration and velocity? #4

mk-pmb opened this issue Aug 25, 2017 · 3 comments

Comments

@mk-pmb
Copy link

mk-pmb commented Aug 25, 2017

Hi! I'm looking for a very stripped-down version of soundfont-player because I have my own wavetable format anyway so I'd like to avoid polluting the global namespace with that MIDI variable, and save the bytes for all that import magic. This package looks like a hot candidate, especially the "Schedule to play buffers at given times" example.

I guess I can calculate the gain by (velocity / 127), but how do I set the note duration?

I found some envelope stuff but I don't fully understand it. From the bits that I do understand, I should probably leave it to the sound font to decide how the sound changes at the end of the note. In an extreme case, someone could build a piano where the hammer hits a secondary string when you release the key. I can't think of how the MIDI.js sound font format could deal with that, but that's another problem for another day. :-)
For now I'm looking for an API that takes note durations and does the right thing with it, in order to shift the question of "What IS the right thing?" away from my code to sample-player. ;-)

@danigb
Copy link
Owner

danigb commented Aug 29, 2017

Sorry for the delay in the answer. Just a duration in the note object do the trick (like the example in the README.md):

marimba.schedule(ac.currentTime, [
  { note: 'c2', time: 0, gain: 0.9, duration: 1 },
  ...  
])

Hope it helps and it's not too late ;-)

@mk-pmb
Copy link
Author

mk-pmb commented Aug 29, 2017

Wow, that was easy. Thanks! I'll leave this open in hopes someone will add it to the readme.

@mk-pmb
Copy link
Author

mk-pmb commented Oct 14, 2017

I found more points that I'd like to have clarified in the readme:
Is note duration limited by the duration of the sample?
For longer notes, can a sample be made to be repeated?
Can these repeats be made to skip an initial part of the sample?
Can the jump in the repeat be smoothed by some means like cross-fading?

I'm planning on doing my own research on these points, I just list them here early in case someone already knows the answer and likes to share it.

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

No branches or pull requests

2 participants