Recent

Author Topic: Midi Packet Size is different between 32carbon and 64 bit cocoa  (Read 8214 times)

Josh

  • Hero Member
  • *****
  • Posts: 1271
Re: Midi Packet Size is different between 32carbon and 64 bit cocoa
« Reply #15 on: June 22, 2019, 08:51:21 am »
Hi

Thanks everyone for their input.

I managed to rebuild the modification and everythiong is now working correctly.
I have created a bug tracker entry

https://bugs.freepascal.org/view.php?id=35750
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Thaddy

  • Hero Member
  • *****
  • Posts: 14214
  • Probably until I exterminate Putin.
Re: Midi Packet Size is different between 32carbon and 64 bit cocoa
« Reply #16 on: June 22, 2019, 10:42:02 am »
I have repeated my comments on the bug tracker. (And I checked the record sizes on my mini Mac)
The pack size is wrong: that is programmer error and not a bug.
Again: midi is a streaming protocol and does not allow slack space. Record packing should be byte aligned. Always.
< RTFM  >:D >:D>

What you seem to forget is that natural alignment between 32 and 64 bitness is not equal.
« Last Edit: June 22, 2019, 10:45:29 am by Thaddy »
Specialize a type, not a var.

BeRo

  • New Member
  • *
  • Posts: 45
    • My site
Re: Midi Packet Size is different between 32carbon and 64 bit cocoa
« Reply #17 on: January 02, 2021, 06:49:45 am »
I have repeated my comments on the bug tracker. (And I checked the record sizes on my mini Mac)
The pack size is wrong: that is programmer error and not a bug.
Again: midi is a streaming protocol and does not allow slack space. Record packing should be byte aligned. Always.
< RTFM  >:D >:D>

What you seem to forget is that natural alignment between 32 and 64 bitness is not equal.

Sorry, but {$packrecords 4} is right here (or a packed record together with a AlignmentDummy UInt16 after the length UInt16). I've tested with my own pascal-native cross-platform Mini-DAW (Digital Audio Workstation), which I'm developing in the moment. You are probably confusing API data structures (here CoreMIDI) with the MIDI specification of the MIDI bytestream. 

Thaddy

  • Hero Member
  • *****
  • Posts: 14214
  • Probably until I exterminate Putin.
Re: Midi Packet Size is different between 32carbon and 64 bit cocoa
« Reply #18 on: January 02, 2021, 07:29:10 am »
No it is not.  It is 1. not 4. Midi is a streaming protocol.
« Last Edit: January 02, 2021, 07:31:52 am by Thaddy »
Specialize a type, not a var.

BeRo

  • New Member
  • *
  • Posts: 45
    • My site
Re: Midi Packet Size is different between 32carbon and 64 bit cocoa
« Reply #19 on: January 02, 2021, 04:58:38 pm »
No it is not.  It is 1. not 4. Midi is a streaming protocol.

Sorry, but MidiPacket is a CoreMIDI data struct, only MidiPacket.data contains the raw MIDI

Even in the original CoreMIDI header sources from Apple itself one can see "// MIDIPacket must be 4-byte aligned" as code comment.

https://github.com/phracker/MacOSX-SDKs/blob/master/MacOSX10.9.sdk/System/Library/Frameworks/CoreMIDI.framework/Versions/A/Headers/MIDIServices.h#L1984

and see "#pragma pack(push, 4)" at

https://github.com/phracker/MacOSX-SDKs/blob/master/MacOSX10.9.sdk/System/Library/Frameworks/CoreMIDI.framework/Versions/A/Headers/MIDIServices.h#L338

Josh is saying, Apple is saying it, I'm saying it. You are pretty much alone with your opinion, which is probably due to the misunderstanding on your part that the MidiPacket Struct contains completely only raw MIDI data, which it defacto does not. It is a container structure including header data for raw MIDI data.
« Last Edit: January 02, 2021, 05:30:26 pm by BeRo »

BeRo

  • New Member
  • *
  • Posts: 45
    • My site
Re: Midi Packet Size is different between 32carbon and 64 bit cocoa
« Reply #20 on: January 02, 2021, 05:01:46 pm »
(In addition, I work with it productively as a professional developer in the audio field as well.)

BeRo

  • New Member
  • *
  • Posts: 45
    • My site
Re: Midi Packet Size is different between 32carbon and 64 bit cocoa
« Reply #21 on: January 02, 2021, 05:11:38 pm »

Code: C  [Select][+][-]
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. #include <CoreServices/CoreServices.h>
  6. #include <CoreMIDI/MIDIServices.h>
  7. #include <CoreAudio/HostTime.h>
  8. #include <unistd.h>
  9.  
  10. int main(){
  11.   int i = sizeof(MIDIPacket);
  12.   printf("%i\n", i);
  13.   return 0;
  14. }      
  15.  

Prints also 268 on my 2015 MacBook Pro 13 inch under a 64-bit MacOS Big Sur. 

freq

  • New Member
  • *
  • Posts: 22
Re: Midi Packet Size is different between 32carbon and 64 bit cocoa
« Reply #22 on: September 07, 2021, 04:45:10 pm »
Hi

Thanks everyone for their input.

I managed to rebuild the modification and everythiong is now working correctly.
I have created a bug tracker entry

https://bugs.freepascal.org/view.php?id=35750

Hi, can confirm that your solution with {$packrecords 4} is working also here with Intel Mac, 64bit under BigSur!
Thanks for providing the solution!

Key-Real

  • Full Member
  • ***
  • Posts: 185
Re: Midi Packet Size is different between 32carbon and 64 bit cocoa
« Reply #23 on: May 23, 2023, 08:51:15 am »
I have FPC Trunk 3.3.1 [2023/05/22]

This Issue is still not solved :(

I'm on an AArch64 Mac (M1)

this works (around line 573):


Code: Pascal  [Select][+][-]
  1. {$push}
  2. {$packrecords 4}
  3.   MIDIPacket = record
  4.                 timeStamp: MIDITimeStamp;
  5.                 length: UInt16;
  6.                 data: array [0..255] of Byte;
  7.                end;
  8. {$pop}


and (around line 612):


Code: Pascal  [Select][+][-]
  1. {$push}
  2. {$packrecords 4}
  3.   MIDIPacketList = record
  4.                     numPackets: UInt32;
  5.                     packet: array [0..0] of MIDIPacket;
  6.                    end;
  7. {$pop}
  8.  



pls fix

 

TinyPortal © 2005-2018