cscore icon indicating copy to clipboard operation
cscore copied to clipboard

Cross target NETSTANDARD2.0/NETCOREAPP2.0

Open iamcarbon opened this issue 7 years ago • 11 comments

This commit adds cross-targeting for NETCOREAPP2.0 & NETSTANDARD2.0.

In the process, I've bumped up the minimum framework target to NET451 (the default toolset installed with VS2017) and the framework version on all sample libraries.

Likely some things left to sort out, but hoping this is a good start to begin talking about NETSTANDARD support.

iamcarbon avatar Sep 29 '17 20:09 iamcarbon

Well, there are many windows dependencies like all the com objects, the calls to windows functions etc. How would we deal with those dependencies? Also I would like to keep it compatible with .net 3.5. I have little to no experience to what it means to target netstandard. Maybe you can give me hint?

filoe avatar Oct 01 '17 10:10 filoe

NETSTANDARD is just an abstraction that delegates down a native runtime (e.g. NET461, NETCOREAPP, or Mono). We can target NETSTANDARD and utilize either the full or core runtimes (2.0 has reached near parity) without regressing on Windows.

There's a bigger discussion on how to effectively target Linux & OSX -- and whether additional abstractions are needed to utilize different Media frameworks (CoreAudio, FFmpeg, and MediaFoundation) to support each.

Still fussing with NET35 but the tooling is still giving me trouble. Do we have any users depending on NET35? If we can bring up the target, we have a viable path to begin utilizing the wave of features coming in C# 7.2 (Instruction Primitives, span/memory, etc) that will allow us to Vectorize hot paths and reduce allocations across the entire codebase.

iamcarbon avatar Oct 01 '17 15:10 iamcarbon

Ok, so if we target netstandard, we would support different runtimes but still just the windows platform. I've planed to support linux quite a while ago (see #94). Whats still left is the support for resampler. Of course we could use ffmpeg as resampler, but I don't like the idea of being dependend on ffmpeg for having a resampler. I've planed to translate r8brain resampler to c# and use it within cscore (the author allows it). Unfortunatly, I had no time to translate it :-(.

To summerize it: We can add netstandard but if we want to target linux officially, there are some key components that have to be available. A resampler is one of them.

What are your thoughts on that?

filoe avatar Oct 01 '17 20:10 filoe

Exactly.

What do you think of utilizing the Cockos re-sampler that was already ported to C# by NAudio (Ms-PL licensed).

https://github.com/naudio/NAudio/blob/master/NAudio/Dsp/WdlResampler.cs

iamcarbon avatar Oct 01 '17 20:10 iamcarbon

Let me know when we've created a new branch for this!

iamcarbon avatar Oct 13 '17 19:10 iamcarbon

Branch is available. Now we'll have to fill it ...

filoe avatar Oct 13 '17 20:10 filoe

Great! I think the next step would be start the work on breaking out the Windows / COM logic into CSCore.Windows (CSCore.MediaFoundation would be a good name too) targeting NETFX and validating the postbuild IL rewrite step.

Let me know if you're able to start this work. That should uncover everything we need to make CSCore platform neutral.

iamcarbon avatar Oct 13 '17 21:10 iamcarbon

I've just checked out a new branch: https://github.com/filoe/cscore/tree/netstandard I've done some initial splitting of CSCore to CSCore.Windows.

filoe avatar Oct 22 '17 10:10 filoe

Does this branch work? I am trying to get CSAudio to compile for Windows IoT on Raspberry Pi

vbisbest avatar Sep 19 '18 16:09 vbisbest

@filoe @MineCake147E @iamcarbon Any progress on this PR?

Because I also have some ideas on how to continue / start on this task.

  • CSCore.Abstractions --> this is the base project (.NET 4.5.1 + .NETStandard 2.0) which contains all abstractions like: (base)models, interfaces and constants. It should not contain real business logic like codecs.

  • CSCore.Codecs --> this is a (.NET 4.5.1 + .NETStandard 2.0) library which contains all native supported Codecs like AIIF / FLAC / RAW / WAV

  • CSCore.Windows.Abstractions --> this is a .NET 4.5.1library which contains abstractions like: (base)models, interfaces and constants based on Windows / MediaFoundation code. It should not contain real business logic like codecs.

  • CSCore.Windows.Codecs --> this is a (.NET 4.5.1) library which contains all windows supported Codecs.

  • For the Codecs projects --> we could even split these up into separate projects + libraries like CSCore.Codecs.MP3 & CSCore.Windows.Codecs.MP3 because in the future it could be that MP3 can be decoded using native code or windows / MediaFoundation code

  • I did not include FFMEG yet in my list because I don't know exactly yet how this fits...

StefH avatar Mar 03 '19 09:03 StefH

Does this work? Could I use this on UWP?

jtorjo avatar Dec 30 '19 00:12 jtorjo