InvisibleWrench / FlutterMidiCommand

A Flutter plugin to send and receive MIDI
BSD 3-Clause "New" or "Revised" License
95 stars 50 forks source link

Wrong `timestamp` in iOS #30

Closed noboru-i closed 3 years ago

noboru-i commented 3 years ago

I checked the received MidiPacket.timestamp. Its range seems 0 to 255.

But MIDI specification has 13 bit, so the range is 0 to 8192.


I thought, https://github.com/InvisibleWrench/FlutterMidiCommand/blob/644dd94431eda60724f5ffda4103ac5e096dd263/ios/Classes/SwiftFlutterMidiCommandPlugin.swift#L1043 tsHigh type is UInt8. So we may cast it before shift operation. timestamp = UInt64(tsHigh) << 7 | UInt64(tsLow)

Using: flutter_midi_command: 0.3.0 flutter: 2.0.4 Xcode: 12.4

mortenboye commented 3 years ago

I don't see any difference between the two variations. Can you share some more information about your setup and the BLE data your are receiving?

noboru-i commented 3 years ago

@mortenboye Thank you for replying.

image MyPlayground.playground.zip

I tried to create a small snippet in the Playground. Is it help you..?

mortenboye commented 3 years ago

That’s curious. I did the same experiment on http://online.swiftplayground.run and saw no difference.

I also tried in the plugin to hardcode high values for tsHigh and tsLow, but saw no difference here either.

I’m not sure if our environments are different or something, but I’m happy to implement the change, if you think it will make a difference on your side.

On Wed, 21 Apr 2021 at 16.25 noboru ISHIKURA(JP) @.***> wrote:

@mortenboye https://github.com/mortenboye Thank you for replying.

[image: image] https://user-images.githubusercontent.com/1567757/115569645-641ad000-a2f8-11eb-9b23-27c0c0e0dff7.png MyPlayground.playground.zip https://github.com/InvisibleWrench/FlutterMidiCommand/files/6351547/MyPlayground.playground.zip

I tried to create a small snippet in the Playground. Is it help you..?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/InvisibleWrench/FlutterMidiCommand/issues/30#issuecomment-824104032, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAETRGSSY7MP3XO6BYFCIETTJ3N6TANCNFSM43JMAX3A .

noboru-i commented 3 years ago

@mortenboye Thank you for checking 👍

I tried on http://online.swiftplayground.run/ with MyPlayground.playground.zip's code. It seems results have differences. image

I cannot find a difference in our environment... 😢

mortenboye commented 3 years ago

Thanks you for double checking. I have just pushed/released v0.3.2 with the proposed change. Thanks again for your contribution.

noboru-i commented 3 years ago

Thank you so much 🎉

MikeFP commented 3 years ago

@mortenboye @noboru-i Does anybody know in what unit the MidiPacket.timestamp is for iOS?

Reading the native docs I can see there's some value that needs to be factored in, but how can I get that value? Is it always the same or system-specific?