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

How do I play the note if I know its duration #7

Open
dyj11 opened this issue Aug 21, 2019 · 2 comments
Open

How do I play the note if I know its duration #7

dyj11 opened this issue Aug 21, 2019 · 2 comments

Comments

@dyj11
Copy link

dyj11 commented Aug 21, 2019

How do I play the note if I know its duration? Not NOTE_ON, NOTE_OFF

@chriscoomber
Copy link

One way is obviously to try to delay the NOTE_OFF by an amount of time. If you look at a MIDI file, you'll see that each note is made up of two events, at different times.

Another way is to send in the NOTE_OFF immediately after the NOTE_ON, but with a timestamp for the time that you want it to end. However, I couldn't get this working myself.

@pissartel
Copy link

Hi,
i'm trying your second solution but notes don't seem to stop.

msg.setMessage(ShortMessage.NOTE_OFF, 0, midiValue, 127)
receiver.send(msg, (System.currentTimeMillis() + durationInMillis).toLong())

We need to send the timestamp, not the duration right ? Is it in milli seconds ?
I don't know what i'm missing.

Thanks for you reply

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

No branches or pull requests

3 participants