hugbug / conpianist

App to control Yamaha CSP digital pianos from Windows, macOS or Linux.
GNU General Public License v3.0
32 stars 4 forks source link

Message delivery with confirmation #71

Closed hugbug closed 4 years ago

hugbug commented 4 years ago

ConPianist communicates with the piano via MIDI-messages. Sometimes we need to send many MIDI-messages to piano at once. For example after connecting to the piano we want to know current piano state. For each piano property we send a request-message and piano sends a response-message back.

Currently more than 170 messages are sent when syncing piano state. That number will only increase in the future as we enhance the program.

The piano can process messages at a limited speed. If we send too many messages in a short interval the piano may skip some of them and we don't get the responses. To avoid this currently we do small pauses between groups of messages. The lengths of pauses were determined empirically. That's unfortunately not 100% reliable. We could increase the pauses but then it would take unnecessary too long to exchange all the needed messages.

Smart Pianist makes that differently. It sends one message, then it waits for the response. Then it sends the next message.

We need a similar system in our program.

Advantages:

Potential disadvantages:

A possible enhancement for the potential slowness would be to send multiple messages in a batch and then wait for confirmations for all of them. That's however would be a separate tracker-issue. We need to implement the first stage first.

djangobaer commented 4 years ago

I remember by sending midi messages to CSP, that there are often a lot of answer-lines received back from CSP. Make sence to check how much time they really take. I think our problem with the split is around here. Great work.