Recent

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

josh

  • Hero Member
  • *****
  • Posts: 808
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
Development Installation Lazarus 1.3, FPC 2.7.1,Windows 7/8 32/64, OSX, *nix

Test Environment Lazarus & FPC Trunk on Windows and OSX (Cocoa Mainly on OSX). Testing also Crosscompile windows to OSX.. 
Any posts made from 2015 will be based on Lazarus Trunk.

Thaddy

  • Hero Member
  • *****
  • Posts: 10704
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 »

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: 10704
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 »

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. 

 

TinyPortal © 2005-2018