sharpdx / SharpDX

SharpDX GitHub Repository
http://sharpdx.org
MIT License
1.69k stars 641 forks source link

Missing XAudio2 Reverb Parameter Constants. How to add to mapping? #253

Closed dfkeenan closed 10 years ago

dfkeenan commented 10 years ago

Hi,

I am porting the reverb stuff from the DirectXtk for the SharpDX.Toolkit.Audio API I am working on. I cannot seem to find the reverb constants from "XAudio2fx.h". I manually ported the I3DL2 presets and started porting the function "ReverbConvertI3DL2ToNative" to a cast operator but some of the required constants are missing. I tried adding the mapping to the mapping.xml as bellow, but a fatal error occurs.

<const from-macro="XAUDIO2FX_REVERB_MIN_REFLECTIONS_DELAY" type="int" cpp-type="int" name="MinReflectionsDelay" class="SharpDX.XAudio2.Fx.ReverbParameters" visibility="public const" />

Any help would be appreciated.

Cheers, dfkeenan

xoofx commented 10 years ago

Indeed this part is not in XAudio2 currently. The code for ReverbConvertI3DL2ToNativecannot be generated from .h files as it is inlined in the header, so it needs to be converted manually. Also constants XAUDIO2FX_I3DL2_PRESET_DEFAULT...etc. are mapping to a C struct declaration that we can't reproduce without writing it manually in C#. If you could help on this, that would be great

dfkeenan commented 10 years ago

Hi @xoofx,

I have already manual ported all the presets (XAUDIO2FX_I3DL2PRESET*) and ReverbConvertI3DL2ToNative inline function. But the function ReverbConvertI3DL2ToNative requires constants like XAUDIO2FX_REVERB_DEFAULT_REAR_DELAY and they are just int/float.

I still haven't worked out how to use the SharpGen stuff....maybe I put it in the wrong mapping file or something. If you had time to workout which spot in which mapping file and an example for 1 of the constants (i.e. XAUDIO2FX_REVERB_MIN_WET_DRY_MIX) for me and I can take it from there. There's like 54 of them, might even be less work to manually port these as well, but I think it's best to use SharpGen where possible.

Cheers, Dan

xoofx commented 10 years ago

Ah sorry, misread your original question. You can add this two lines to the extension part in Mapping-xaudio2.xml file and you should get all constants accessible from Fx.Reverb class

    <create class="SharpDX.XAudio2.Fx.Reverb" visibility="public"/>
    <const from-macro="XAUDIO2FX_REVERB_(.*)" type="float" cpp-type="float" name="$1" class="SharpDX.XAudio2.Fx.Reverb" visibility="public const" />
dfkeenan commented 10 years ago

Thanks!

I ended up having to do an entry per constant because they were all different types. It worked, but it out put into "Fx\Functions.cs" not sure if that is right.