Git Product home page Git Product logo

Comments (6)

adamnemecek avatar adamnemecek commented on May 25, 2024

Thanks for the info. I used to handle this case.

https://github.com/adamnemecek/WebMIDIKit/blob/a042248820c930fb83a2866e1e9475a9ae01484a/Sources/AXMIDI/AXMIDI.c

I think that at one point, my code was similar to yours but eventually decided to drop the C dependency for easiness when I realized that I think that your case mostly likely wont actually happen.

The reason for that is that I dont think that people are sending anything but notes or other short messages with their keyboardds. No one actually uses the dynamically sized messages. They might do it in MIDI files but definitely not for midi recording.

Lemme know what you think.

from webmidikit.

jrmaxdev avatar jrmaxdev commented on May 25, 2024

Thanks for the reply.
I agree, most people would use it that way.

I stumbled into this pointer issue when I tried to read data out of MusicEventUserData delivered by a sequence callback. I could not find a decent way to get a pointer to the data field of UnsafePointer< MusicEventUserData >. The only thing that worked in swift was calculating the offset of the data field in the struct but that indeed looked very ugly.

Using a simple c-function to return the pointer from the struct seemed much safer to me.
So I am dependent on c anyway (like anybody using CoreMIDI). The only effort to use this function is to include a bridging header.

The same problem would apply when reading meta events or sysex data from a sequence.

The only thing that would matter to me in reading packet lists would be performance.
I don't think that a c-function call will cause much overhead. When using CoreMIDI in swift you call c-functions all the time.

from webmidikit.

adamnemecek avatar adamnemecek commented on May 25, 2024

It was not a performance decision. You can always get a UnsafePointer to the data, or use the Data (aka NSData) class.

The overhead was due to the package structure not performance. Including C in an SPM package is annoying. I used to have it but removed it.

from webmidikit.

jrmaxdev avatar jrmaxdev commented on May 25, 2024

Thank for your reply.
Your remark 'you can always get a UnsafePointer to the data' made me think about it again.
With a little effort and some awkward lookin swift expressions I managed to remove all c-functions.

from webmidikit.

adamnemecek avatar adamnemecek commented on May 25, 2024

Are you aware of the audiokit project? https://github.com/AudioKit/AudioKit/ I'll invite you to the slack group, you'll fit right in.

from webmidikit.

adamnemecek avatar adamnemecek commented on May 25, 2024

What's your email?

from webmidikit.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.