Replies: 7 comments 20 replies
-
Hi, First of all, thanks for such kind words! As for iOS support – there is a chance that the library will work on the platform due to macOS support. As far as I know, both iOS and macOS use the same system APIs. If you can test a simple app on iOS, it would be great. By the way, high precision timer is needed for |
Beta Was this translation helpful? Give feedback.
-
Hi, I tested it with a simple .Net MAUI project (default tempate for .NET Maui in Visual Studio) on the Mac (Apple Silicon based) and got the same error in Visual Studio for Mac (Version 17.4.2) as mentioned in my answer above : for an iOS build and also for Mac Catalyst. I also did a quick cross check with a .Net Core Console project on the Mac, which produces no errors, although I did not call any APIs of DryWetMidi (just Nuget Install & build). Interesstingly the same DryWetMid DLL's can be found in the build output directory of the .Net Core Console projects and the .Net MAUI build for iOS and Mac Catalyst. Any ideas ? cheers |
Beta Was this translation helpful? Give feedback.
-
Hi Ayaphi, universal.dylib has been built using command line tools
from this simple files (this is a PowerShell script that creates the files): Set-Content -Path .\arm64.c -Value "int Foo() { return 234; }"
Set-Content -Path .\x86_64.c -Value "int Foo() { return 345; }" So the So you can pass all this info into an issue in .NET MAUI. We've determined that your problem is related not with DryWetMIDI but with how Thanks, |
Beta Was this translation helpful? Give feedback.
-
Hi Melanchal, before I reach out to the .NET MAUI team, I did a quick google search on the topic and found 3 hints, but I could not dig into them deep enough by now. The main thing seems to be : external libraries needs to be statically linked for iOS in .NET MAUI apps and we have to find a proper way to do this in .NET MAUI ".csproj" - not a place I know like the back of my hand by now ;-) 1.) Xamarin iOS related (most of the Xamarin stuff is still valid for .NET MAUI) : https://learn.microsoft.com/en-us/xamarin/ios/platform/native-interop#linking-your-library says "Any third-party library that you consume needs to be statically linked with your application." So there has to be extra stuff for the project build. The webiste above states extra flags (-gcc_flags and a string parameter), which I do not know how to integrate in the ".csproj" makefile (alike) of the .NET MAUI project yet. Respectively how to let the ".csproj" generate that for the Xcode build ... these are the downsides (dark sides ?) of abstracted cross plattform magic ;-) 2.) Also there has to be some additional bootstrap code in c# : https://learn.microsoft.com/en-us/xamarin/ios/platform/native-interop#accessing-c-dylibs . 3.) A closed issue on github gives another hint to "@rpath/" prefix : dotnet/maui#4569 (comment) These could be the missing pieces - does the above make any sense to you (taking a quick glance)? cheers & happy new year |
Beta Was this translation helpful? Give feedback.
-
Hi Ayaphi, Well, I've created a fat .a file for arm64 and x86_64 archs (I've skipped 32-bit old archs): Melanchall_DryWetMidi_Native64.zip. Build succeded without errors but I can't check if the result file is valid or not:
Can you please take the file from the provided archive, add it to your project (I suppose it would be useful to set “Copy to Output Directory” to “Copy always” for the file) and repeat all previous actions regarding build and sending to iOS device? Also please note that I will be AFK until Jan 11, so I won't be able to do any coding before that day. So if the build will fail with the provided .a file, I'll get back to you on Jan 11. Thanks for your assistance and happy new year! |
Beta Was this translation helpful? Give feedback.
-
Hi Max, long story short : I found a working solution that works with Swift and I will change gears and develop the app in Swift & SwiftUI. +++ In a nutshell: the solution on “planet iOS” is AVAudioSequencer, which is essentially a MIDI sequencer & playback engine integrated into AVAudioEngine – it can load & playback MIDI files and also supports adding and removing MIDI events (note, tempo and more). Inside AVAudioEngine one can use AVAudioUnitSampler to load SF2 Soundfont files (sample libraries) for playing the sound for the notes of the midi tracks. Its also possible to let AVAudioSequencer route a track (chunk) of the loaded midi file to a certain AVAudioUnitSampler instance and hence a multi timbral song playback and editing is possible to achieve. To a first degree this also works in .NET MAUI with the provided native bindings – loading a MIDI file into AVAudioSequencer, a SF2 into AVAudioUnitSampler, and playing back the MIDI file with that sounds works fine (I tested it with 2 tracks and 2 audio sampler). But when it comes to “track editing”, the bindings in .NET MAUI are not complete, so e.g. AVMusicTrack in .NET MAUI misses all methods, like addEvent. I don’t know why these API are missing as the promotion of .NET MAUI has always been “you can access all native APIs on the supported platform”, but I will not ask (over on their Github project site) and not dig into it. I think .NET MAUI could become a great technology, but if it’s the right choice, depends on what one wants to achieve and beside that, from my exploration of .NET MAUI coding so far, it feels like its still in the “get it going” phase – it has not settled yet. .NET MAUI might become a good choice for line of business apps, social media apps and alike – but if one wants to deeply integrate with a essential framework of one of the supported platforms, like Audio & MIDI (both !) and the ecosystem of AUv3 plugins on iOS, I think its a better idea to use the native programming language and techniques & tools of the platform. And by the way: using AUv3 plugins and integrating one’s own app (e.g. a fancy MIDI Sequencer ;-) in the AUv3 ecosystem, the Swift framework AVFAudio (that houses AVAudioSequencer and AVAudioEngine) most probably is not the best choice either and one has to drop into the objective-c layer or use a promising Swift library from the AudioKit project (https://github.com/AudioKit/AudioKit). +++ So that’s for now – but as I said : if you got new DryWetMidi .NET MAUI ideas & builds for me to test on an iOS device, please let me know. As using DryWetMidi for pure MIDI creation & playback on .NET MAUI might make sense, especially when we can get an easy access to midi ports that are published in the core midi runtime (I am not sure if this is the right term, still digging ;-) and hence connect and playback to AUv3 hosts and DAWs on iOS. Cheers |
Beta Was this translation helpful? Give feedback.
-
Hi Ayaphi, Thanks for the info you've provided! At this moment I have no ideas what to do further. So I've created questions:
Our next step is to wait for a response :) If some info will be requested, I let you know. Thanks again! Good luck with your main project and have a nice coding, |
Beta Was this translation helpful? Give feedback.
-
Hi there,
and first of all : a huge thanks Maxim for your amazing work respectively library ... its a joy to discover & use it and your documentation is great (and really needed in that detail, because the feature richness has a complexity that can hardly be discovered by try and error ... thanks !!!).
I played around with the library in a Windows App SDK project and it works great and now I am thinking, if its somehow possible to use it in a .NET MAUI project running on iOS.
Its clear that on iOS the Device API is not implemented, which leads to the frist question : Maxim has put so much effort in building and evolving this library, so there might be a good reason that there is no Device API implementation for iOS, e.g. because of technical restrictions or issues - as Xamarain.iOS is a long time around and .NET MAUI moving in its footsteps.
What's obvious : a high resolution time is needed that could "drive" the iOS implementation of IOutputDevice, which could be done quite nicely in .NET Maui project with partial classes and methods (see : https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/invoke-platform-code?view=net-maui-7.0#partial-classes-and-methods).
But as I have no experience in using iOS Plattform APIs or classes in .NET (neither via Xamarin.iOS nor via .NET Maui), I am not aware of the limitations that exist - I guess that some API & classes, even if they are present in .NET MAUI through bindings the team has implemented, they might cause somehow trouble using them via C#, because of the technical nature of how .NET MAUI is running on iOS - it's a different game than on Windows and maybe even on MacOS.
As Timer can have high demand on a device resources (e.g. draining battery if they keep runing on the CPU like on a rat race for getting that high resolution ;-), I could imagine, that even if there is a high resolution timer (with 1ms support) on iOS available, it cannot be used "that easy" in a .NET MAUI app.
If that's the case, what about a "sidechain" workaround : is there a chance to link a piece of swift code to the .NET MAUI project that implements an output device (with a maybe slightly different api)?
Has anyone experiences in this "deep fields of iOS" ;-) and maybe some useful tipps ?
Thanks in advance ... cheers and happy new year.
ayaphi
Beta Was this translation helpful? Give feedback.
All reactions