Beispiel #1
0
            private FAudioContext(IntPtr ctx, uint devices)
            {
                Handle = ctx;

                uint i;

                for (i = 0; i < devices; i += 1)
                {
                    FAudio.FAudio_GetDeviceDetails(
                        Handle,
                        i,
                        out DeviceDetails
                        );
                    if ((DeviceDetails.Role & FAudio.FAudioDeviceRole.FAudioDefaultGameDevice) == FAudio.FAudioDeviceRole.FAudioDefaultGameDevice)
                    {
                        break;
                    }
                }
                if (i == devices)
                {
                    i = 0;                     /* Oh well. */
                    FAudio.FAudio_GetDeviceDetails(
                        Handle,
                        i,
                        out DeviceDetails
                        );
                }
                if (FAudio.FAudio_CreateMasteringVoice(
                        Handle,
                        out MasterVoice,
                        FAudio.FAUDIO_DEFAULT_CHANNELS,
                        FAudio.FAUDIO_DEFAULT_SAMPLERATE,
                        0,
                        i,
                        IntPtr.Zero
                        ) != 0)
                {
                    FAudio.FAudio_Release(ctx);
                    Handle = IntPtr.Zero;
                    FNALoggerEXT.LogError(
                        "Failed to create mastering voice!"
                        );
                    return;
                }

                CurveDistanceScaler = 1.0f;
                DopplerScale        = 1.0f;
                SpeedOfSound        = 343.5f;
                Handle3D            = new byte[FAudio.F3DAUDIO_HANDLE_BYTESIZE];
                FAudio.F3DAudioInitialize(
                    DeviceDetails.OutputFormat.dwChannelMask,
                    SpeedOfSound,
                    Handle3D
                    );

                Context = this;
            }