diff --git a/NAudio.Universal.sln b/NAudio.Universal.sln
deleted file mode 100644
index 4f03bf66..00000000
--- a/NAudio.Universal.sln
+++ /dev/null
@@ -1,64 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.23107.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F91DCE20-90A9-49A8-8773-CACECE651F37}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NAudio.Universal", "NAudio.Universal\NAudio.Universal.csproj", "{B7418F4D-290E-4CBA-9DAB-83923E54DC61}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NAudioUniversalDemo", "NAudioUniversalDemo\NAudioUniversalDemo.csproj", "{0BE833CC-8127-4079-BEEC-27397EDA3EDB}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Debug|ARM = Debug|ARM
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|Any CPU = Release|Any CPU
- Release|ARM = Release|ARM
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {B7418F4D-290E-4CBA-9DAB-83923E54DC61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {B7418F4D-290E-4CBA-9DAB-83923E54DC61}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {B7418F4D-290E-4CBA-9DAB-83923E54DC61}.Debug|ARM.ActiveCfg = Debug|ARM
- {B7418F4D-290E-4CBA-9DAB-83923E54DC61}.Debug|ARM.Build.0 = Debug|ARM
- {B7418F4D-290E-4CBA-9DAB-83923E54DC61}.Debug|x64.ActiveCfg = Debug|x64
- {B7418F4D-290E-4CBA-9DAB-83923E54DC61}.Debug|x64.Build.0 = Debug|x64
- {B7418F4D-290E-4CBA-9DAB-83923E54DC61}.Debug|x86.ActiveCfg = Debug|x86
- {B7418F4D-290E-4CBA-9DAB-83923E54DC61}.Debug|x86.Build.0 = Debug|x86
- {B7418F4D-290E-4CBA-9DAB-83923E54DC61}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {B7418F4D-290E-4CBA-9DAB-83923E54DC61}.Release|Any CPU.Build.0 = Release|Any CPU
- {B7418F4D-290E-4CBA-9DAB-83923E54DC61}.Release|ARM.ActiveCfg = Release|ARM
- {B7418F4D-290E-4CBA-9DAB-83923E54DC61}.Release|ARM.Build.0 = Release|ARM
- {B7418F4D-290E-4CBA-9DAB-83923E54DC61}.Release|x64.ActiveCfg = Release|x64
- {B7418F4D-290E-4CBA-9DAB-83923E54DC61}.Release|x64.Build.0 = Release|x64
- {B7418F4D-290E-4CBA-9DAB-83923E54DC61}.Release|x86.ActiveCfg = Release|x86
- {B7418F4D-290E-4CBA-9DAB-83923E54DC61}.Release|x86.Build.0 = Release|x86
- {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Debug|Any CPU.ActiveCfg = Debug|x86
- {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Debug|ARM.ActiveCfg = Debug|ARM
- {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Debug|ARM.Build.0 = Debug|ARM
- {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Debug|ARM.Deploy.0 = Debug|ARM
- {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Debug|x64.ActiveCfg = Debug|x64
- {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Debug|x64.Build.0 = Debug|x64
- {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Debug|x64.Deploy.0 = Debug|x64
- {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Debug|x86.ActiveCfg = Debug|x86
- {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Debug|x86.Build.0 = Debug|x86
- {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Debug|x86.Deploy.0 = Debug|x86
- {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Release|Any CPU.ActiveCfg = Release|x86
- {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Release|ARM.ActiveCfg = Release|ARM
- {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Release|ARM.Build.0 = Release|ARM
- {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Release|ARM.Deploy.0 = Release|ARM
- {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Release|x64.ActiveCfg = Release|x64
- {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Release|x64.Build.0 = Release|x64
- {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Release|x64.Deploy.0 = Release|x64
- {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Release|x86.ActiveCfg = Release|x86
- {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Release|x86.Build.0 = Release|x86
- {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Release|x86.Deploy.0 = Release|x86
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/NAudio.Universal.sln.DotSettings b/NAudio.Universal.sln.DotSettings
deleted file mode 100644
index e3bb2d5c..00000000
--- a/NAudio.Universal.sln.DotSettings
+++ /dev/null
@@ -1,6 +0,0 @@
-
- System
- System.Linq
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
\ No newline at end of file
diff --git a/NAudio.Universal/CoreAudioApi/PropVariantNative.cs b/NAudio.Universal/CoreAudioApi/PropVariantNative.cs
deleted file mode 100644
index d2202ef8..00000000
--- a/NAudio.Universal/CoreAudioApi/PropVariantNative.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System;
-using System.Runtime.InteropServices;
-
-namespace NAudio.CoreAudioApi.Interfaces
-{
- class PropVariantNative
- {
- // Windows 10 requires api-ms-win-core-com-l1-1-1.dll
- [DllImport("api-ms-win-core-com-l1-1-1.dll")]
- internal static extern int PropVariantClear(ref PropVariant pvar);
-
- [DllImport("api-ms-win-core-com-l1-1-1.dll")]
- internal static extern int PropVariantClear(IntPtr pvar);
-
- }
-}
diff --git a/NAudio.Universal/NAudio.Universal.csproj b/NAudio.Universal/NAudio.Universal.csproj
deleted file mode 100644
index e32400fb..00000000
--- a/NAudio.Universal/NAudio.Universal.csproj
+++ /dev/null
@@ -1,841 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {B7418F4D-290E-4CBA-9DAB-83923E54DC61}
- Library
- Properties
- NAudio.Universal
- NAudio.Universal
- en-US
- UAP
- 10.0.10240.0
- 10.0.10240.0
- 14
- 512
- {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UAP
- prompt
- 4
- bin\Debug\NAudio.Universal.XML
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE;NETFX_CORE;WINDOWS_UAP
- prompt
- 4
- bin\Release\NAudio.Universal.XML
-
-
- ARM
- true
- bin\ARM\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UAP
- ;2008
- full
- ARM
- false
- prompt
- true
-
-
- ARM
- bin\ARM\Release\
- TRACE;NETFX_CORE;WINDOWS_UAP
- true
- ;2008
- pdbonly
- ARM
- false
- prompt
- true
-
-
- x64
- true
- bin\x64\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UAP
- ;2008
- full
- x64
- false
- prompt
- true
-
-
- x64
- bin\x64\Release\
- TRACE;NETFX_CORE;WINDOWS_UAP
- true
- ;2008
- pdbonly
- x64
- false
- prompt
- true
-
-
- x86
- true
- bin\x86\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UAP
- ;2008
- full
- x86
- false
- prompt
- true
-
-
- x86
- bin\x86\Release\
- TRACE;NETFX_CORE;WINDOWS_UAP
- true
- ;2008
- pdbonly
- x86
- false
- prompt
- true
- false
-
-
-
-
-
-
-
- Codecs\ALawDecoder.cs
-
-
- Codecs\ALawEncoder.cs
-
-
- Codecs\G722Codec.cs
-
-
- Codecs\MuLawDecoder.cs
-
-
- Codecs\MuLawEncoder.cs
-
-
- CoreAudioApi\AudioCaptureClient.cs
-
-
- CoreAudioApi\AudioClient.cs
-
-
- CoreAudioApi\AudioClientBufferFlags.cs
-
-
- CoreAudioApi\AudioClientProperties.cs
-
-
- CoreAudioApi\AudioClientShareMode.cs
-
-
- CoreAudioApi\AudioClientStreamFlags.cs
-
-
- CoreAudioApi\AudioClientStreamOptions.cs
-
-
- CoreAudioApi\AudioClockClient.cs
-
-
- CoreAudioApi\AudioEndpointVolume.cs
-
-
- CoreAudioApi\AudioEndpointVolumeCallback.cs
-
-
- CoreAudioApi\AudioEndpointVolumeChannel.cs
-
-
- CoreAudioApi\AudioEndpointVolumeChannels.cs
-
-
- CoreAudioApi\AudioEndpointVolumeNotificationDelegate.cs
-
-
- CoreAudioApi\AudioEndpointVolumeStepInformation.cs
-
-
- CoreAudioApi\AudioEndpointVolumeVolumeRange.cs
-
-
- CoreAudioApi\AudioMeterInformation.cs
-
-
- CoreAudioApi\AudioMeterInformationChannels.cs
-
-
- CoreAudioApi\AudioRenderClient.cs
-
-
- CoreAudioApi\AudioSessionControl.cs
-
-
- CoreAudioApi\AudioSessionEventsCallback.cs
-
-
- CoreAudioApi\AudioSessionManager.cs
-
-
- CoreAudioApi\AudioSessionNotification.cs
-
-
- CoreAudioApi\AudioStreamCategory.cs
-
-
- CoreAudioApi\AudioStreamVolume.cs
-
-
- CoreAudioApi\AudioVolumeNotificationData.cs
-
-
- CoreAudioApi\DataFlow.cs
-
-
- CoreAudioApi\DeviceState.cs
-
-
- CoreAudioApi\EEndpointHardwareSupport.cs
-
-
- CoreAudioApi\Interfaces\AudioVolumeNotificationDataStruct.cs
-
-
- CoreAudioApi\Interfaces\Blob.cs
-
-
- CoreAudioApi\Interfaces\ClsCtx.cs
-
-
- CoreAudioApi\Interfaces\ErrorCodes.cs
-
-
- CoreAudioApi\Interfaces\IAudioCaptureClient.cs
-
-
- CoreAudioApi\Interfaces\IAudioClient.cs
-
-
- CoreAudioApi\Interfaces\IAudioClock2.cs
-
-
- CoreAudioApi\Interfaces\IAudioEndpointVolume.cs
-
-
- CoreAudioApi\Interfaces\IAudioEndpointVolumeCallback.cs
-
-
- CoreAudioApi\Interfaces\IAudioMeterInformation.cs
-
-
- CoreAudioApi\Interfaces\IAudioRenderClient.cs
-
-
- CoreAudioApi\Interfaces\IAudioSessionControl.cs
-
-
- CoreAudioApi\Interfaces\IAudioSessionEnumerator.cs
-
-
- CoreAudioApi\Interfaces\IAudioSessionEvents.cs
-
-
- CoreAudioApi\Interfaces\IAudioSessionEventsHandler.cs
-
-
- CoreAudioApi\Interfaces\IAudioSessionManager.cs
-
-
- CoreAudioApi\Interfaces\IAudioSessionNotification.cs
-
-
- CoreAudioApi\Interfaces\IAudioStreamVolume.cs
-
-
- CoreAudioApi\Interfaces\IMMDevice.cs
-
-
- CoreAudioApi\Interfaces\IMMDeviceCollection.cs
-
-
- CoreAudioApi\Interfaces\IMMDeviceEnumerator.cs
-
-
- CoreAudioApi\Interfaces\IMMEndpoint.cs
-
-
- CoreAudioApi\Interfaces\IMMNotificationClient.cs
-
-
- CoreAudioApi\Interfaces\IPropertyStore.cs
-
-
- CoreAudioApi\Interfaces\ISimpleAudioVolume.cs
-
-
- CoreAudioApi\Interfaces\MMDeviceEnumeratorComObject.cs
-
-
- CoreAudioApi\Interfaces\StorageAccessMode.cs
-
-
- CoreAudioApi\MMDevice.cs
-
-
- CoreAudioApi\MMDeviceCollection.cs
-
-
- CoreAudioApi\MMDeviceEnumerator.cs
-
-
- CoreAudioApi\PropertyKey.cs
-
-
- CoreAudioApi\PropertyKeys.cs
-
-
- CoreAudioApi\PropertyStore.cs
-
-
- CoreAudioApi\PropertyStoreProperty.cs
-
-
- CoreAudioApi\PropVariant.cs
-
-
- CoreAudioApi\Role.cs
-
-
- CoreAudioApi\SessionCollection.cs
-
-
- CoreAudioApi\SimpleAudioVolume.cs
-
-
- Dmo\AudioMediaSubtypes.cs
-
-
- Dmo\IWMResamplerProps.cs
-
-
- Dsp\BiQuadFilter.cs
-
-
- Dsp\Complex.cs
-
-
- Dsp\EnvelopeDetector.cs
-
-
- Dsp\EnvelopeGenerator.cs
-
-
- Dsp\FastFourierTransform.cs
-
-
- Dsp\ImpulseResponseConvolution.cs
-
-
- Dsp\SimpleCompressor.cs
-
-
- Dsp\SimpleGate.cs
-
-
- Dsp\WdlResampler.cs
-
-
- FileFormats\Mp3\ChannelMode.cs
-
-
- FileFormats\Mp3\Id3v2Tag.cs
-
-
- FileFormats\Mp3\IMp3FrameDecompressor.cs
-
-
- FileFormats\Mp3\Mp3Frame.cs
-
-
- FileFormats\Mp3\MpegLayer.cs
-
-
- FileFormats\Mp3\MpegVersion.cs
-
-
- FileFormats\Mp3\XingHeader.cs
-
-
- FileFormats\SoundFont\Generator.cs
-
-
- FileFormats\SoundFont\GeneratorBuilder.cs
-
-
- FileFormats\SoundFont\GeneratorEnum.cs
-
-
- FileFormats\SoundFont\InfoChunk.cs
-
-
- FileFormats\SoundFont\Instrument.cs
-
-
- FileFormats\SoundFont\InstrumentBuilder.cs
-
-
- FileFormats\SoundFont\Modulator.cs
-
-
- FileFormats\SoundFont\ModulatorBuilder.cs
-
-
- FileFormats\SoundFont\ModulatorType.cs
-
-
- FileFormats\SoundFont\Preset.cs
-
-
- FileFormats\SoundFont\PresetBuilder.cs
-
-
- FileFormats\SoundFont\PresetsChunk.cs
-
-
- FileFormats\SoundFont\RiffChunk.cs
-
-
- FileFormats\SoundFont\SampleDataChunk.cs
-
-
- FileFormats\SoundFont\SampleHeader.cs
-
-
- FileFormats\SoundFont\SampleHeaderBuilder.cs
-
-
- FileFormats\SoundFont\SampleMode.cs
-
-
- FileFormats\SoundFont\SFSampleLink.cs
-
-
- FileFormats\SoundFont\SFVersion.cs
-
-
- FileFormats\SoundFont\SFVersionBuilder.cs
-
-
- FileFormats\SoundFont\SoundFont.cs
-
-
- FileFormats\SoundFont\StructureBuilder.cs
-
-
- FileFormats\SoundFont\Zone.cs
-
-
- FileFormats\SoundFont\ZoneBuilder.cs
-
-
- MediaFoundation\AudioSubtypes.cs
-
-
- MediaFoundation\IMFActivate.cs
-
-
- MediaFoundation\IMFAttributes.cs
-
-
- MediaFoundation\IMFByteStream.cs
-
-
- MediaFoundation\IMFCollection.cs
-
-
- MediaFoundation\IMFMediaBuffer.cs
-
-
- MediaFoundation\IMFMediaEvent.cs
-
-
- MediaFoundation\IMFMediaType.cs
-
-
- MediaFoundation\IMFReadWriteClassFactory.cs
-
-
- MediaFoundation\IMFSample.cs
-
-
- MediaFoundation\IMFSinkWriter.cs
-
-
- MediaFoundation\IMFSourceReader.cs
-
-
- MediaFoundation\IMFTransform.cs
-
-
- MediaFoundation\MediaEventType.cs
-
-
- MediaFoundation\MediaFoundationAttributes.cs
-
-
- MediaFoundation\MediaFoundationErrors.cs
-
-
- MediaFoundation\MediaFoundationHelpers.cs
-
-
- MediaFoundation\MediaFoundationInterop.cs
-
-
- MediaFoundation\MediaFoundationTransform.cs
-
-
- MediaFoundation\MediaFoundationTransformCategories.cs
-
-
- MediaFoundation\MediaType.cs
-
-
- MediaFoundation\MediaTypes.cs
-
-
- MediaFoundation\MFT_INPUT_STREAM_INFO.cs
-
-
- MediaFoundation\MFT_MESSAGE_TYPE.cs
-
-
- MediaFoundation\MFT_OUTPUT_DATA_BUFFER.cs
-
-
- MediaFoundation\MFT_OUTPUT_STREAM_INFO.cs
-
-
- MediaFoundation\MFT_REGISTER_TYPE_INFO.cs
-
-
- MediaFoundation\MF_SINK_WRITER_STATISTICS.cs
-
-
- MediaFoundation\_MFT_ENUM_FLAG.cs
-
-
- MediaFoundation\_MFT_INPUT_STATUS_FLAGS.cs
-
-
- MediaFoundation\_MFT_INPUT_STREAM_INFO_FLAGS.cs
-
-
- MediaFoundation\_MFT_OUTPUT_DATA_BUFFER_FLAGS.cs
-
-
- MediaFoundation\_MFT_OUTPUT_STATUS_FLAGS.cs
-
-
- MediaFoundation\_MFT_OUTPUT_STREAM_INFO_FLAGS.cs
-
-
- MediaFoundation\_MFT_PROCESS_OUTPUT_FLAGS.cs
-
-
- MediaFoundation\_MFT_PROCESS_OUTPUT_STATUS.cs
-
-
- MediaFoundation\_MFT_SET_TYPE_FLAGS.cs
-
-
- Utils\BufferHelpers.cs
-
-
- Utils\ByteArrayExtensions.cs
-
-
- Utils\ByteEncoding.cs
-
-
- Utils\CircularBuffer.cs
-
-
- Utils\Decibels.cs
-
-
- Utils\FieldDescriptionAttribute.cs
-
-
- Utils\FieldDescriptionHelper.cs
-
-
- Utils\HResult.cs
-
-
- Utils\IEEE.cs
-
-
- Utils\IgnoreDisposeStream.cs
-
-
- Utils\MergeSort.cs
-
-
- Utils\NativeMethods.cs
-
-
- Wave\WaveInputs\WaveInEventArgs.cs
-
-
- Wave\SampleChunkConverters\ISampleChunkConverter.cs
-
-
- Wave\SampleChunkConverters\Mono16SampleChunkConverter.cs
-
-
- Wave\SampleChunkConverters\Mono24SampleChunkConverter.cs
-
-
- Wave\SampleChunkConverters\Mono8SampleChunkConverter.cs
-
-
- Wave\SampleChunkConverters\MonoFloatSampleChunkConverter.cs
-
-
- Wave\SampleChunkConverters\Stereo16SampleChunkConverter.cs
-
-
- Wave\SampleChunkConverters\Stereo24SampleChunkConverter.cs
-
-
- Wave\SampleChunkConverters\Stereo8SampleChunkConverter.cs
-
-
- Wave\SampleChunkConverters\StereoFloatSampleChunkConverter.cs
-
-
- Wave\SampleProviders\ConcatenatingSampleProvider.cs
-
-
- Wave\SampleProviders\FadeInOutSampleProvider.cs
-
-
- Wave\SampleProviders\MeteringSampleProvider.cs
-
-
- Wave\SampleProviders\MixingSampleProvider.cs
-
-
- Wave\SampleProviders\MonoToStereoSampleProvider.cs
-
-
- Wave\SampleProviders\MultiplexingSampleProvider.cs
-
-
- Wave\SampleProviders\NotifyingSampleProvider.cs
-
-
- Wave\SampleProviders\OffsetSampleProvider.cs
-
-
- Wave\SampleProviders\PanningSampleProvider.cs
-
-
- Wave\SampleProviders\Pcm16BitToSampleProvider.cs
-
-
- Wave\SampleProviders\Pcm24BitToSampleProvider.cs
-
-
- Wave\SampleProviders\Pcm32BitToSampleProvider.cs
-
-
- Wave\SampleProviders\Pcm8BitToSampleProvider.cs
-
-
- Wave\SampleProviders\SampleChannel.cs
-
-
- Wave\SampleProviders\SampleProviderConverterBase.cs
-
-
- Wave\SampleProviders\SampleProviderConverters.cs
-
-
- Wave\SampleProviders\SampleToWaveProvider.cs
-
-
- Wave\SampleProviders\SampleToWaveProvider16.cs
-
-
- Wave\SampleProviders\SampleToWaveProvider24.cs
-
-
- Wave\SampleProviders\SignalGenerator.cs
-
-
- Wave\SampleProviders\StereoToMonoSampleProvider.cs
-
-
- Wave\SampleProviders\VolumeSampleProvider.cs
-
-
- Wave\SampleProviders\WaveToSampleProvider.cs
-
-
- Wave\SampleProviders\WaveToSampleProvider64.cs
-
-
- Wave\SampleProviders\WdlResamplingSampleProvider.cs
-
-
- Wave\WaveExtensionMethods.cs
-
-
- Wave\WaveFormats\AdpcmWaveFormat.cs
-
-
- Wave\WaveFormats\Gsm610WaveFormat.cs
-
-
- Wave\WaveFormats\ImaAdpcmWaveFormat.cs
-
-
- Wave\WaveFormats\Mp3WaveFormat.cs
-
-
- Wave\WaveFormats\OggWaveFormat.cs
-
-
- Wave\WaveFormats\TrueSpeechWaveFormat.cs
-
-
- Wave\WaveFormats\WaveFormat.cs
-
-
- Wave\WaveFormats\WaveFormatEncoding.cs
-
-
- Wave\WaveFormats\WaveFormatExtensible.cs
-
-
- Wave\WaveFormats\WaveFormatExtraData.cs
-
-
- Wave\WaveFormats\WmaWaveFormat.cs
-
-
- Wave\WaveInputs\IWaveIn.cs
-
-
- Wave\WaveOutputs\IWaveBuffer.cs
-
-
- Wave\WaveOutputs\IWaveProvider.cs
-
-
- Wave\WaveOutputs\IWaveProviderFloat.cs
-
-
- Wave\WaveOutputs\PlaybackState.cs
-
-
- Wave\WaveOutputs\StoppedEventArgs.cs
-
-
- Wave\WaveOutputs\WaveBuffer.cs
-
-
- Wave\WaveProviders\BufferedWaveProvider.cs
-
-
- Wave\WaveProviders\MonoToStereoProvider16.cs
-
-
- Wave\WaveProviders\MultiplexingWaveProvider.cs
-
-
- Wave\WaveProviders\StereoToMonoProvider16.cs
-
-
- Wave\WaveProviders\VolumeWaveProvider16.cs
-
-
- Wave\WaveProviders\Wave16toFloatProvider.cs
-
-
- Wave\WaveProviders\WaveFloatTo16Provider.cs
-
-
- Wave\WaveProviders\WaveInProvider.cs
-
-
- Wave\WaveProviders\WaveProvider16.cs
-
-
- Wave\WaveProviders\WaveProvider32.cs
-
-
- Wave\WaveStreams\BlockAlignReductionStream.cs
-
-
- Wave\WaveStreams\ISampleNotifier.cs
-
-
- Wave\WaveStreams\MediaFoundationReader.cs
-
-
- Wave\WaveStreams\RawSourceWaveStream.cs
-
-
- Wave\WaveStreams\SimpleCompressorStream.cs
-
-
- Wave\WaveStreams\WaveChannel32.cs
-
-
- Wave\WaveStreams\WaveOffsetStream.cs
-
-
- Wave\WaveStreams\WaveStream.cs
-
-
-
-
-
-
-
-
-
-
-
- 14.0
-
-
-
-
\ No newline at end of file
diff --git a/NAudio.Universal/Properties/AssemblyInfo.cs b/NAudio.Universal/Properties/AssemblyInfo.cs
deleted file mode 100644
index b23c0f55..00000000
--- a/NAudio.Universal/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("NAudio.Universal")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("NAudio.Universal")]
-[assembly: AssemblyCopyright("Copyright © Mark Heath 2017")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
-[assembly: ComVisible(false)]
\ No newline at end of file
diff --git a/NAudio.Universal/Utils/MarshalHelpers.cs b/NAudio.Universal/Utils/MarshalHelpers.cs
deleted file mode 100644
index 46f01714..00000000
--- a/NAudio.Universal/Utils/MarshalHelpers.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System;
-using System.Linq;
-using System.Runtime.InteropServices;
-
-// ReSharper disable once CheckNamespace
-namespace NAudio.Utils
-{
- ///
- /// Support for Marshal Methods in both UWP and .NET 3.5
- ///
- public static class MarshalHelpers
- {
- ///
- /// SizeOf a structure
- ///
- public static int SizeOf()
- {
- return Marshal.SizeOf();
- }
-
- ///
- /// Offset of a field in a structure
- ///
- public static IntPtr OffsetOf(string fieldName)
- {
- return Marshal.OffsetOf(fieldName);
- }
-
- ///
- /// Pointer to Structure
- ///
- public static T PtrToStructure(IntPtr pointer)
- {
- return Marshal.PtrToStructure(pointer);
- }
- }
-}
diff --git a/NAudio.Universal/Wave/WaveOutputs/IWavePlayer.cs b/NAudio.Universal/Wave/WaveOutputs/IWavePlayer.cs
deleted file mode 100644
index 6605a3d9..00000000
--- a/NAudio.Universal/Wave/WaveOutputs/IWavePlayer.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-using System;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace NAudio.Wave
-{
- ///
- /// Represents the interface to a device that can play audio
- ///
- public interface IWavePlayer : IDisposable
- {
- ///
- /// Begin playback
- ///
- void Play();
-
- ///
- /// Stop playback
- ///
- void Stop();
-
- ///
- /// Pause Playback
- ///
- void Pause();
-
- ///
- /// Obsolete init method
- ///
- ///
- ///
- [Obsolete]
- Task Init(IWaveProvider waveProvider);
-
- ///
- /// Initialise playback
- ///
- /// Function to create the waveprovider to be played
- /// Called on the playback thread
- void Init(Func waveProviderFunc);
-
- ///
- /// Current playback state
- ///
- PlaybackState PlaybackState { get; }
-
- ///
- /// Indicates that playback has gone into a stopped state due to
- /// reaching the end of the input stream or an error has been encountered during playback
- ///
- event EventHandler PlaybackStopped;
- }
-}
diff --git a/NAudio.Universal/project.json b/NAudio.Universal/project.json
deleted file mode 100644
index c5949392..00000000
--- a/NAudio.Universal/project.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "dependencies": {
- "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0"
- },
- "frameworks": {
- "uap10.0": {}
- },
- "runtimes": {
- "win10-arm": {},
- "win10-arm-aot": {},
- "win10-x86": {},
- "win10-x86-aot": {},
- "win10-x64": {},
- "win10-x64-aot": {}
- }
-}
\ No newline at end of file
diff --git a/NAudio.nuspec b/NAudio.nuspec
deleted file mode 100644
index 798309be..00000000
--- a/NAudio.nuspec
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
- NAudio
- @build.number@
- Mark Heath
- Mark Heath
- https://github.com/naudio/NAudio/blob/master/license.txt
- https://github.com/naudio/NAudio
- false
- NAudio, an audio library for .NET
-
- C# .NET audio sound
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/NAudio.sln b/NAudio.sln
index 112b0412..c38f4693 100644
--- a/NAudio.sln
+++ b/NAudio.sln
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2009
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NAudio", "NAudio\NAudio.csproj", "{DA4F02E3-0B5E-42CD-B8D9-5583FA51D66E}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NAudio", "NAudio\NAudio.csproj", "{DA4F02E3-0B5E-42CD-B8D9-5583FA51D66E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MidiFileConverter", "MidiFileConverter\MidiFileConverter.csproj", "{5B5897BD-A423-4AF8-8A59-1C1372ED77DB}"
EndProject
@@ -22,7 +22,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
build.bat = build.bat
build.fsx = build.fsx
license.txt = license.txt
- NAudio.nuspec = NAudio.nuspec
README.md = README.md
readme.txt = readme.txt
RELEASE_NOTES.md = RELEASE_NOTES.md
@@ -63,72 +62,124 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{BA7F6DBB-9
Docs\WaveProviders.md = Docs\WaveProviders.md
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NAudioUniversalDemo", "NAudioUniversalDemo\NAudioUniversalDemo.csproj", "{0BE833CC-8127-4079-BEEC-27397EDA3EDB}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
+ Debug|ARM = Debug|ARM
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
+ Release|ARM = Release|ARM
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DA4F02E3-0B5E-42CD-B8D9-5583FA51D66E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA4F02E3-0B5E-42CD-B8D9-5583FA51D66E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DA4F02E3-0B5E-42CD-B8D9-5583FA51D66E}.Debug|ARM.ActiveCfg = Debug|Any CPU
+ {DA4F02E3-0B5E-42CD-B8D9-5583FA51D66E}.Debug|ARM.Build.0 = Debug|Any CPU
{DA4F02E3-0B5E-42CD-B8D9-5583FA51D66E}.Debug|x64.ActiveCfg = Debug|Any CPU
{DA4F02E3-0B5E-42CD-B8D9-5583FA51D66E}.Debug|x86.ActiveCfg = Debug|Any CPU
{DA4F02E3-0B5E-42CD-B8D9-5583FA51D66E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA4F02E3-0B5E-42CD-B8D9-5583FA51D66E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {DA4F02E3-0B5E-42CD-B8D9-5583FA51D66E}.Release|ARM.ActiveCfg = Release|Any CPU
+ {DA4F02E3-0B5E-42CD-B8D9-5583FA51D66E}.Release|ARM.Build.0 = Release|Any CPU
{DA4F02E3-0B5E-42CD-B8D9-5583FA51D66E}.Release|x64.ActiveCfg = Release|Any CPU
{DA4F02E3-0B5E-42CD-B8D9-5583FA51D66E}.Release|x86.ActiveCfg = Release|Any CPU
{5B5897BD-A423-4AF8-8A59-1C1372ED77DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B5897BD-A423-4AF8-8A59-1C1372ED77DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5B5897BD-A423-4AF8-8A59-1C1372ED77DB}.Debug|ARM.ActiveCfg = Debug|Any CPU
+ {5B5897BD-A423-4AF8-8A59-1C1372ED77DB}.Debug|ARM.Build.0 = Debug|Any CPU
{5B5897BD-A423-4AF8-8A59-1C1372ED77DB}.Debug|x64.ActiveCfg = Debug|Any CPU
{5B5897BD-A423-4AF8-8A59-1C1372ED77DB}.Debug|x86.ActiveCfg = Debug|Any CPU
{5B5897BD-A423-4AF8-8A59-1C1372ED77DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B5897BD-A423-4AF8-8A59-1C1372ED77DB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5B5897BD-A423-4AF8-8A59-1C1372ED77DB}.Release|ARM.ActiveCfg = Release|Any CPU
+ {5B5897BD-A423-4AF8-8A59-1C1372ED77DB}.Release|ARM.Build.0 = Release|Any CPU
{5B5897BD-A423-4AF8-8A59-1C1372ED77DB}.Release|x64.ActiveCfg = Release|Any CPU
{5B5897BD-A423-4AF8-8A59-1C1372ED77DB}.Release|x86.ActiveCfg = Release|Any CPU
{1293DD10-378A-4370-AEE2-AA1E9E87039B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1293DD10-378A-4370-AEE2-AA1E9E87039B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1293DD10-378A-4370-AEE2-AA1E9E87039B}.Debug|ARM.ActiveCfg = Debug|Any CPU
+ {1293DD10-378A-4370-AEE2-AA1E9E87039B}.Debug|ARM.Build.0 = Debug|Any CPU
{1293DD10-378A-4370-AEE2-AA1E9E87039B}.Debug|x64.ActiveCfg = Debug|Any CPU
{1293DD10-378A-4370-AEE2-AA1E9E87039B}.Debug|x86.ActiveCfg = Debug|Any CPU
{1293DD10-378A-4370-AEE2-AA1E9E87039B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1293DD10-378A-4370-AEE2-AA1E9E87039B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1293DD10-378A-4370-AEE2-AA1E9E87039B}.Release|ARM.ActiveCfg = Release|Any CPU
+ {1293DD10-378A-4370-AEE2-AA1E9E87039B}.Release|ARM.Build.0 = Release|Any CPU
{1293DD10-378A-4370-AEE2-AA1E9E87039B}.Release|x64.ActiveCfg = Release|Any CPU
{1293DD10-378A-4370-AEE2-AA1E9E87039B}.Release|x86.ActiveCfg = Release|Any CPU
{5080281A-F9A1-403F-85C7-0DFF6839B07B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5080281A-F9A1-403F-85C7-0DFF6839B07B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5080281A-F9A1-403F-85C7-0DFF6839B07B}.Debug|ARM.ActiveCfg = Debug|Any CPU
+ {5080281A-F9A1-403F-85C7-0DFF6839B07B}.Debug|ARM.Build.0 = Debug|Any CPU
{5080281A-F9A1-403F-85C7-0DFF6839B07B}.Debug|x64.ActiveCfg = Debug|Any CPU
{5080281A-F9A1-403F-85C7-0DFF6839B07B}.Debug|x86.ActiveCfg = Debug|Any CPU
{5080281A-F9A1-403F-85C7-0DFF6839B07B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5080281A-F9A1-403F-85C7-0DFF6839B07B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5080281A-F9A1-403F-85C7-0DFF6839B07B}.Release|ARM.ActiveCfg = Release|Any CPU
+ {5080281A-F9A1-403F-85C7-0DFF6839B07B}.Release|ARM.Build.0 = Release|Any CPU
{5080281A-F9A1-403F-85C7-0DFF6839B07B}.Release|x64.ActiveCfg = Release|Any CPU
{5080281A-F9A1-403F-85C7-0DFF6839B07B}.Release|x86.ActiveCfg = Release|Any CPU
{C37A547B-F31E-45FB-870A-CFA704D06152}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C37A547B-F31E-45FB-870A-CFA704D06152}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C37A547B-F31E-45FB-870A-CFA704D06152}.Debug|ARM.ActiveCfg = Debug|Any CPU
+ {C37A547B-F31E-45FB-870A-CFA704D06152}.Debug|ARM.Build.0 = Debug|Any CPU
{C37A547B-F31E-45FB-870A-CFA704D06152}.Debug|x64.ActiveCfg = Debug|Any CPU
{C37A547B-F31E-45FB-870A-CFA704D06152}.Debug|x86.ActiveCfg = Debug|Any CPU
{C37A547B-F31E-45FB-870A-CFA704D06152}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C37A547B-F31E-45FB-870A-CFA704D06152}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C37A547B-F31E-45FB-870A-CFA704D06152}.Release|ARM.ActiveCfg = Release|Any CPU
+ {C37A547B-F31E-45FB-870A-CFA704D06152}.Release|ARM.Build.0 = Release|Any CPU
{C37A547B-F31E-45FB-870A-CFA704D06152}.Release|x64.ActiveCfg = Release|Any CPU
{C37A547B-F31E-45FB-870A-CFA704D06152}.Release|x86.ActiveCfg = Release|Any CPU
{D29C1659-635C-497B-847E-FE9A5A69ED03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D29C1659-635C-497B-847E-FE9A5A69ED03}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D29C1659-635C-497B-847E-FE9A5A69ED03}.Debug|ARM.ActiveCfg = Debug|Any CPU
+ {D29C1659-635C-497B-847E-FE9A5A69ED03}.Debug|ARM.Build.0 = Debug|Any CPU
{D29C1659-635C-497B-847E-FE9A5A69ED03}.Debug|x64.ActiveCfg = Debug|Any CPU
{D29C1659-635C-497B-847E-FE9A5A69ED03}.Debug|x86.ActiveCfg = Debug|Any CPU
{D29C1659-635C-497B-847E-FE9A5A69ED03}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D29C1659-635C-497B-847E-FE9A5A69ED03}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D29C1659-635C-497B-847E-FE9A5A69ED03}.Release|ARM.ActiveCfg = Release|Any CPU
+ {D29C1659-635C-497B-847E-FE9A5A69ED03}.Release|ARM.Build.0 = Release|Any CPU
{D29C1659-635C-497B-847E-FE9A5A69ED03}.Release|x64.ActiveCfg = Release|Any CPU
{D29C1659-635C-497B-847E-FE9A5A69ED03}.Release|x86.ActiveCfg = Release|Any CPU
{A7B74F85-D353-4ED4-A321-E6E4AD4D7D32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A7B74F85-D353-4ED4-A321-E6E4AD4D7D32}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A7B74F85-D353-4ED4-A321-E6E4AD4D7D32}.Debug|ARM.ActiveCfg = Debug|Any CPU
+ {A7B74F85-D353-4ED4-A321-E6E4AD4D7D32}.Debug|ARM.Build.0 = Debug|Any CPU
{A7B74F85-D353-4ED4-A321-E6E4AD4D7D32}.Debug|x64.ActiveCfg = Debug|Any CPU
{A7B74F85-D353-4ED4-A321-E6E4AD4D7D32}.Debug|x86.ActiveCfg = Debug|Any CPU
{A7B74F85-D353-4ED4-A321-E6E4AD4D7D32}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A7B74F85-D353-4ED4-A321-E6E4AD4D7D32}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A7B74F85-D353-4ED4-A321-E6E4AD4D7D32}.Release|ARM.ActiveCfg = Release|Any CPU
+ {A7B74F85-D353-4ED4-A321-E6E4AD4D7D32}.Release|ARM.Build.0 = Release|Any CPU
{A7B74F85-D353-4ED4-A321-E6E4AD4D7D32}.Release|x64.ActiveCfg = Release|Any CPU
{A7B74F85-D353-4ED4-A321-E6E4AD4D7D32}.Release|x86.ActiveCfg = Release|Any CPU
+ {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Debug|Any CPU.ActiveCfg = Debug|x86
+ {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Debug|ARM.ActiveCfg = Debug|ARM
+ {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Debug|ARM.Build.0 = Debug|ARM
+ {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Debug|ARM.Deploy.0 = Debug|ARM
+ {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Debug|x64.ActiveCfg = Debug|x64
+ {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Debug|x64.Build.0 = Debug|x64
+ {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Debug|x64.Deploy.0 = Debug|x64
+ {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Debug|x86.ActiveCfg = Debug|x86
+ {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Debug|x86.Build.0 = Debug|x86
+ {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Debug|x86.Deploy.0 = Debug|x86
+ {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Release|Any CPU.ActiveCfg = Release|x86
+ {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Release|ARM.ActiveCfg = Release|ARM
+ {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Release|ARM.Build.0 = Release|ARM
+ {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Release|ARM.Deploy.0 = Release|ARM
+ {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Release|x64.ActiveCfg = Release|x64
+ {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Release|x64.Build.0 = Release|x64
+ {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Release|x64.Deploy.0 = Release|x64
+ {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Release|x86.ActiveCfg = Release|x86
+ {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Release|x86.Build.0 = Release|x86
+ {0BE833CC-8127-4079-BEEC-27397EDA3EDB}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -140,6 +191,7 @@ Global
{D29C1659-635C-497B-847E-FE9A5A69ED03} = {778D0FA5-FE72-4BF9-B83F-5ECDFBF32F62}
{A7B74F85-D353-4ED4-A321-E6E4AD4D7D32} = {778D0FA5-FE72-4BF9-B83F-5ECDFBF32F62}
{BA7F6DBB-9FC4-49E6-92E4-621EFE4BBBBC} = {F91DCE20-90A9-49A8-8773-CACECE651F37}
+ {0BE833CC-8127-4079-BEEC-27397EDA3EDB} = {778D0FA5-FE72-4BF9-B83F-5ECDFBF32F62}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F7CAB18A-FDAF-4BC8-AFD0-19CC898E85CE}
diff --git a/NAudio.sln.DotSettings b/NAudio.sln.DotSettings
index e3bb2d5c..1ca1f0eb 100644
--- a/NAudio.sln.DotSettings
+++ b/NAudio.sln.DotSettings
@@ -3,4 +3,5 @@
System.Linq
<Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
<Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
- <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
\ No newline at end of file
+ <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
+ <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />
\ No newline at end of file
diff --git a/NAudio/Codecs/ALawDecoder.cs b/NAudio/Codecs/ALawDecoder.cs
index 8cf4ff22..c86a63af 100644
--- a/NAudio/Codecs/ALawDecoder.cs
+++ b/NAudio/Codecs/ALawDecoder.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace NAudio.Codecs
+namespace NAudio.Codecs
{
///
/// a-law decoder
diff --git a/NAudio/Codecs/ALawEncoder.cs b/NAudio/Codecs/ALawEncoder.cs
index cd953ed7..f8c071cc 100644
--- a/NAudio/Codecs/ALawEncoder.cs
+++ b/NAudio/Codecs/ALawEncoder.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace NAudio.Codecs
+namespace NAudio.Codecs
{
///
/// A-law encoder
diff --git a/NAudio/Codecs/G722Codec.cs b/NAudio/Codecs/G722Codec.cs
index 3b48dec6..e3d25fce 100644
--- a/NAudio/Codecs/G722Codec.cs
+++ b/NAudio/Codecs/G722Codec.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
namespace NAudio.Codecs
{
diff --git a/NAudio/CoreAudioApi/AudioClient.cs b/NAudio/CoreAudioApi/AudioClient.cs
index 30c45ca7..4fbfb008 100644
--- a/NAudio/CoreAudioApi/AudioClient.cs
+++ b/NAudio/CoreAudioApi/AudioClient.cs
@@ -73,8 +73,7 @@ public int BufferSize
{
get
{
- uint bufferSize;
- Marshal.ThrowExceptionForHR(audioClientInterface.GetBufferSize(out bufferSize));
+ Marshal.ThrowExceptionForHR(audioClientInterface.GetBufferSize(out uint bufferSize));
return (int) bufferSize;
}
}
diff --git a/NAudio/CoreAudioApi/AudioSessionControl.cs b/NAudio/CoreAudioApi/AudioSessionControl.cs
index 8afd7e77..38dca24e 100644
--- a/NAudio/CoreAudioApi/AudioSessionControl.cs
+++ b/NAudio/CoreAudioApi/AudioSessionControl.cs
@@ -28,13 +28,9 @@ public AudioSessionControl(IAudioSessionControl audioSessionControl)
audioSessionControlInterface = audioSessionControl;
audioSessionControlInterface2 = audioSessionControl as IAudioSessionControl2;
- // ReSharper disable once SuspiciousTypeConversion.Global
- var meters = audioSessionControlInterface as IAudioMeterInformation;
- // ReSharper disable once SuspiciousTypeConversion.Global
- var volume = audioSessionControlInterface as ISimpleAudioVolume;
- if (meters != null)
+ if (audioSessionControlInterface is IAudioMeterInformation meters)
AudioMeterInformation = new AudioMeterInformation(meters);
- if (volume != null)
+ if (audioSessionControlInterface is ISimpleAudioVolume volume)
SimpleAudioVolume = new SimpleAudioVolume(volume);
}
diff --git a/NAudio/CoreAudioApi/AudioSessionNotification.cs b/NAudio/CoreAudioApi/AudioSessionNotification.cs
index 899b4555..a5428778 100644
--- a/NAudio/CoreAudioApi/AudioSessionNotification.cs
+++ b/NAudio/CoreAudioApi/AudioSessionNotification.cs
@@ -1,6 +1,4 @@
using NAudio.CoreAudioApi.Interfaces;
-using System;
-using System.Linq;
using System.Runtime.InteropServices;
namespace NAudio.CoreAudioApi
diff --git a/NAudio/CoreAudioApi/DataFlow.cs b/NAudio/CoreAudioApi/DataFlow.cs
index a634d5fe..731b6add 100644
--- a/NAudio/CoreAudioApi/DataFlow.cs
+++ b/NAudio/CoreAudioApi/DataFlow.cs
@@ -21,7 +21,5 @@ public enum DataFlow
/// endpoint device, or from the audio endpoint device to the application.
///
All
- };
-
-
+ }
}
diff --git a/NAudio/CoreAudioApi/PropVariantNative.cs b/NAudio/CoreAudioApi/PropVariantNative.cs
index 6e6b8103..a307108d 100644
--- a/NAudio/CoreAudioApi/PropVariantNative.cs
+++ b/NAudio/CoreAudioApi/PropVariantNative.cs
@@ -5,10 +5,19 @@ namespace NAudio.CoreAudioApi.Interfaces
{
class PropVariantNative
{
+#if WINDOWS_UWP
+ // Windows 10 requires api-ms-win-core-com-l1-1-1.dll
+ [DllImport("api-ms-win-core-com-l1-1-1.dll")]
+#else
[DllImport("ole32.dll")]
+#endif
internal static extern int PropVariantClear(ref PropVariant pvar);
+#if WINDOWS_UWP
+ [DllImport("api-ms-win-core-com-l1-1-1.dll")]
+#else
[DllImport("ole32.dll")]
+#endif
internal static extern int PropVariantClear(IntPtr pvar);
}
}
diff --git a/NAudio/Dmo/IMediaBuffer.cs b/NAudio/Dmo/IMediaBuffer.cs
index ba713f9b..46c44cf1 100644
--- a/NAudio/Dmo/IMediaBuffer.cs
+++ b/NAudio/Dmo/IMediaBuffer.cs
@@ -7,7 +7,7 @@ namespace NAudio.Dmo
/// IMediaBuffer Interface
///
[ComImport,
-#if !NETFX_CORE
+#if !WINDOWS_UWP
System.Security.SuppressUnmanagedCodeSecurity,
#endif
Guid("59eff8b9-938c-4a26-82f2-95cb84cdc837"),
diff --git a/NAudio/Dmo/IMediaObject.cs b/NAudio/Dmo/IMediaObject.cs
index a4886087..8e22c490 100644
--- a/NAudio/Dmo/IMediaObject.cs
+++ b/NAudio/Dmo/IMediaObject.cs
@@ -7,7 +7,7 @@ namespace NAudio.Dmo
/// defined in mediaobj.h
///
[ComImport,
-#if !NETFX_CORE
+#if !WINDOWS_UWP
System.Security.SuppressUnmanagedCodeSecurity,
#endif
Guid("d8ad0f58-5494-4102-97c5-ec798e59bcf4"),
diff --git a/NAudio/Dmo/IMediaObjectInPlace.cs b/NAudio/Dmo/IMediaObjectInPlace.cs
index 22fc0a41..6f238531 100644
--- a/NAudio/Dmo/IMediaObjectInPlace.cs
+++ b/NAudio/Dmo/IMediaObjectInPlace.cs
@@ -6,7 +6,10 @@ namespace NAudio.Dmo
///
/// defined in mediaobj.h
///
- [ComImport, System.Security.SuppressUnmanagedCodeSecurity,
+ [ComImport,
+#if !NETFX_CORE
+ System.Security.SuppressUnmanagedCodeSecurity,
+#endif
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid("651B9AD0-0FC7-4AA9-9538-D89931010741")]
internal interface IMediaObjectInPlace
diff --git a/NAudio/Dmo/IMediaParamInfo.cs b/NAudio/Dmo/IMediaParamInfo.cs
index 5f188f50..668cec78 100644
--- a/NAudio/Dmo/IMediaParamInfo.cs
+++ b/NAudio/Dmo/IMediaParamInfo.cs
@@ -7,7 +7,7 @@ namespace NAudio.Dmo
/// defined in Medparam.h
///
[ComImport,
-#if !NETFX_CORE
+#if !WINDOWS_UWP
System.Security.SuppressUnmanagedCodeSecurity,
#endif
Guid("6d6cbb60-a223-44aa-842f-a2f06750be6d"),
diff --git a/NAudio/Dsp/Complex.cs b/NAudio/Dsp/Complex.cs
index f454e207..b82c9ea8 100644
--- a/NAudio/Dsp/Complex.cs
+++ b/NAudio/Dsp/Complex.cs
@@ -1,7 +1,3 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
namespace NAudio.Dsp
{
///
diff --git a/NAudio/Dsp/EnvelopeDetector.cs b/NAudio/Dsp/EnvelopeDetector.cs
index 00a8e266..eec14811 100644
--- a/NAudio/Dsp/EnvelopeDetector.cs
+++ b/NAudio/Dsp/EnvelopeDetector.cs
@@ -24,10 +24,7 @@ public EnvelopeDetector( double ms, double sampleRate )
public double TimeConstant
{
- get
- {
- return ms;
- }
+ get => ms;
set
{
System.Diagnostics.Debug.Assert( value > 0.0 );
@@ -38,10 +35,7 @@ public double TimeConstant
public double SampleRate
{
- get
- {
- return sampleRate;
- }
+ get => sampleRate;
set
{
System.Diagnostics.Debug.Assert( value > 0.0 );
@@ -50,9 +44,9 @@ public double SampleRate
}
}
- public void Run( double inValue, ref double state )
+ public double Run( double inValue, double state )
{
- state = inValue + coeff * (state - inValue);
+ return inValue + coeff * (state - inValue);
}
private void SetCoef()
@@ -77,32 +71,29 @@ public AttRelEnvelope( double attackMilliseconds, double releaseMilliseconds, do
public double Attack
{
- get { return attack.TimeConstant; }
- set { attack.TimeConstant = value; }
+ get => attack.TimeConstant;
+ set => attack.TimeConstant = value;
}
public double Release
{
- get { return release.TimeConstant; }
- set { release.TimeConstant = value; }
+ get => release.TimeConstant;
+ set => release.TimeConstant = value;
}
public double SampleRate
{
- get { return attack.SampleRate; }
- set { attack.SampleRate = release.SampleRate = value; }
+ get => attack.SampleRate;
+ set => attack.SampleRate = release.SampleRate = value;
}
- public void Run(double inValue, ref double state)
+ public double Run(double inValue, double state)
{
// assumes that:
// positive delta = attack
// negative delta = release
// good for linear & log values
- if ( inValue > state )
- attack.Run( inValue, ref state ); // attack
- else
- release.Run( inValue, ref state ); // release
+ return inValue > state ? attack.Run( inValue, state ) : release.Run( inValue, state );
}
}
}
diff --git a/NAudio/Dsp/SimpleCompressor.cs b/NAudio/Dsp/SimpleCompressor.cs
index b5bd332e..a873c867 100644
--- a/NAudio/Dsp/SimpleCompressor.cs
+++ b/NAudio/Dsp/SimpleCompressor.cs
@@ -6,10 +6,8 @@ namespace NAudio.Dsp
{
class SimpleCompressor : AttRelEnvelope
{
- // transfer function
-
// runtime variables
- private double envdB; // over-threshold envelope (dB)
+ private double envdB; // over-threshold envelope (dB)
public SimpleCompressor(double attackTime, double releaseTime, double sampleRate)
: base(attackTime, releaseTime, sampleRate)
@@ -21,12 +19,8 @@ public SimpleCompressor(double attackTime, double releaseTime, double sampleRate
}
public SimpleCompressor()
- : base(10.0, 10.0, 44100.0)
+ : this(10.0, 10.0, 44100.0)
{
- this.Threshold = 0.0;
- this.Ratio = 1.0;
- this.MakeUpGain = 0.0;
- this.envdB = DC_OFFSET;
}
public double MakeUpGain { get; set; }
@@ -47,29 +41,29 @@ public void Process(ref double in1, ref double in2)
// sidechain
// rectify input
- double rect1 = Math.Abs( in1 ); // n.b. was fabs
- double rect2 = Math.Abs( in2 ); // n.b. was fabs
+ double rect1 = Math.Abs(in1); // n.b. was fabs
+ double rect2 = Math.Abs(in2); // n.b. was fabs
// if desired, one could use another EnvelopeDetector to smooth
// the rectified signal.
double link = Math.Max( rect1, rect2 ); // link channels with greater of 2
- link += DC_OFFSET; // add DC offset to avoid log( 0 )
- double keydB = Decibels.LinearToDecibels( link ); // convert linear -> dB
+ link += DC_OFFSET; // add DC offset to avoid log( 0 )
+ double keydB = Decibels.LinearToDecibels(link); // convert linear -> dB
// threshold
- double overdB = keydB - Threshold; // delta over threshold
- if ( overdB < 0.0 )
+ double overdB = keydB - Threshold; // delta over threshold
+ if (overdB < 0.0)
overdB = 0.0;
// attack/release
- overdB += DC_OFFSET; // add DC offset to avoid denormal
+ overdB += DC_OFFSET; // add DC offset to avoid denormal
- Run( overdB, ref envdB ); // run attack/release envelope
+ envdB = Run(overdB, envdB); // run attack/release envelope
- overdB = envdB - DC_OFFSET; // subtract DC offset
+ overdB = envdB - DC_OFFSET; // subtract DC offset
// Regarding the DC offset: In this case, since the offset is added before
// the attack/release processes, the envelope will never fall below the offset,
diff --git a/NAudio/Dsp/SimpleGate.cs b/NAudio/Dsp/SimpleGate.cs
index 9cf886e8..0198504b 100644
--- a/NAudio/Dsp/SimpleGate.cs
+++ b/NAudio/Dsp/SimpleGate.cs
@@ -42,7 +42,7 @@ public void Process( ref double in1, ref double in2 )
// attack/release
over += DC_OFFSET; // add DC offset to avoid denormal
- Run( over, ref env ); // run attack/release
+ env = Run(over, env); // run attack/release
over = env - DC_OFFSET; // subtract DC offset
@@ -59,10 +59,7 @@ public void Process( ref double in1, ref double in2 )
public double Threshold
{
- get
- {
- return threshdB;
- }
+ get => threshdB;
set
{
threshdB = value;
diff --git a/NAudio/Dsp/WdlResampler.cs b/NAudio/Dsp/WdlResampler.cs
index a25b2bfe..d7df9b34 100644
--- a/NAudio/Dsp/WdlResampler.cs
+++ b/NAudio/Dsp/WdlResampler.cs
@@ -24,8 +24,6 @@
using System;
-using System.Diagnostics;
-using System.Linq;
// default to floats for audio samples
using WDL_ResampleSample = System.Single; // n.b. default in WDL is double
diff --git a/NAudio/FileFormats/Mp3/ChannelMode.cs b/NAudio/FileFormats/Mp3/ChannelMode.cs
index 7fd80f9d..0f2291e6 100644
--- a/NAudio/FileFormats/Mp3/ChannelMode.cs
+++ b/NAudio/FileFormats/Mp3/ChannelMode.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace NAudio.Wave
+namespace NAudio.Wave
{
///
/// Channel Mode
diff --git a/NAudio/FileFormats/Mp3/IMp3FrameDecompressor.cs b/NAudio/FileFormats/Mp3/IMp3FrameDecompressor.cs
index cd2716cd..29fc94ce 100644
--- a/NAudio/FileFormats/Mp3/IMp3FrameDecompressor.cs
+++ b/NAudio/FileFormats/Mp3/IMp3FrameDecompressor.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
namespace NAudio.Wave
{
diff --git a/NAudio/FileFormats/Mp3/Mp3Frame.cs b/NAudio/FileFormats/Mp3/Mp3Frame.cs
index f2d47390..ea230350 100644
--- a/NAudio/FileFormats/Mp3/Mp3Frame.cs
+++ b/NAudio/FileFormats/Mp3/Mp3Frame.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using System.IO;
namespace NAudio.Wave
diff --git a/NAudio/FileFormats/Mp3/Mp3FrameDecompressor.cs b/NAudio/FileFormats/Mp3/Mp3FrameDecompressor.cs
index 5d94faf0..63cb2712 100644
--- a/NAudio/FileFormats/Mp3/Mp3FrameDecompressor.cs
+++ b/NAudio/FileFormats/Mp3/Mp3FrameDecompressor.cs
@@ -50,8 +50,7 @@ public int DecompressFrame(Mp3Frame frame, byte[] dest, int destOffset)
throw new ArgumentNullException("frame", "You must provide a non-null Mp3Frame to decompress");
}
Array.Copy(frame.RawData, conversionStream.SourceBuffer, frame.FrameLength);
- int sourceBytesConverted = 0;
- int converted = conversionStream.Convert(frame.FrameLength, out sourceBytesConverted);
+ int converted = conversionStream.Convert(frame.FrameLength, out int sourceBytesConverted);
if (sourceBytesConverted != frame.FrameLength)
{
throw new InvalidOperationException(String.Format("Couldn't convert the whole MP3 frame (converted {0}/{1})",
diff --git a/NAudio/FileFormats/Mp3/MpegLayer.cs b/NAudio/FileFormats/Mp3/MpegLayer.cs
index 1fe711dc..cb978040 100644
--- a/NAudio/FileFormats/Mp3/MpegLayer.cs
+++ b/NAudio/FileFormats/Mp3/MpegLayer.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace NAudio.Wave
+namespace NAudio.Wave
{
///
/// MPEG Layer flags
diff --git a/NAudio/FileFormats/Mp3/MpegVersion.cs b/NAudio/FileFormats/Mp3/MpegVersion.cs
index 36d58e33..075c13bc 100644
--- a/NAudio/FileFormats/Mp3/MpegVersion.cs
+++ b/NAudio/FileFormats/Mp3/MpegVersion.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace NAudio.Wave
+namespace NAudio.Wave
{
///
/// MPEG Version Flags
diff --git a/NAudio/FileFormats/Mp3/XingHeader.cs b/NAudio/FileFormats/Mp3/XingHeader.cs
index e6cc67d3..cec5300a 100644
--- a/NAudio/FileFormats/Mp3/XingHeader.cs
+++ b/NAudio/FileFormats/Mp3/XingHeader.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
namespace NAudio.Wave
{
diff --git a/NAudio/FileFormats/SoundFont/Generator.cs b/NAudio/FileFormats/SoundFont/Generator.cs
index ae1dd686..6281d7da 100644
--- a/NAudio/FileFormats/SoundFont/Generator.cs
+++ b/NAudio/FileFormats/SoundFont/Generator.cs
@@ -1,136 +1,82 @@
-using System;
-
-namespace NAudio.SoundFont
+namespace NAudio.SoundFont
{
- ///
- /// Soundfont generator
- ///
- public class Generator
- {
- private GeneratorEnum generatorType;
- private ushort rawAmount;
- private Instrument instrument;
- private SampleHeader sampleHeader;
-
- ///
- /// Gets the generator type
- ///
- public GeneratorEnum GeneratorType
- {
- get
- {
- return generatorType;
- }
- set
- {
- generatorType = value;
- }
- }
-
- ///
- /// Generator amount as an unsigned short
- ///
- public ushort UInt16Amount
- {
- get
- {
- return rawAmount;
- }
- set
- {
- rawAmount = value;
- }
- }
-
- ///
- /// Generator amount as a signed short
- ///
- public short Int16Amount
- {
- get
- {
- return (short) rawAmount;
- }
- set
- {
- rawAmount = (ushort) value;
- }
- }
-
- ///
- /// Low byte amount
- ///
- public byte LowByteAmount
- {
- get
- {
- return (byte) (rawAmount & 0x00FF);
- }
- set
- {
- rawAmount &= 0xFF00;
- rawAmount += value;
- }
- }
-
- ///
- /// High byte amount
- ///
- public byte HighByteAmount
- {
- get
- {
- return (byte) ((rawAmount & 0xFF00) >> 8);
- }
- set
- {
- rawAmount &= 0x00FF;
- rawAmount += (ushort) (value << 8);
- }
- }
+ ///
+ /// Soundfont generator
+ ///
+ public class Generator
+ {
+ ///
+ /// Gets the generator type
+ ///
+ public GeneratorEnum GeneratorType { get; set; }
+
+ ///
+ /// Generator amount as an unsigned short
+ ///
+ public ushort UInt16Amount { get; set; }
+
+ ///
+ /// Generator amount as a signed short
+ ///
+ public short Int16Amount
+ {
+ get => (short)UInt16Amount;
+ set => UInt16Amount = (ushort)value;
+ }
+
+ ///
+ /// Low byte amount
+ ///
+ public byte LowByteAmount
+ {
+ get
+ {
+ return (byte)(UInt16Amount & 0x00FF);
+ }
+ set
+ {
+ UInt16Amount &= 0xFF00;
+ UInt16Amount += value;
+ }
+ }
- ///
- /// Instrument
- ///
- public Instrument Instrument
- {
- get
- {
- return instrument;
- }
- set
- {
- instrument = value;
- }
- }
+ ///
+ /// High byte amount
+ ///
+ public byte HighByteAmount
+ {
+ get
+ {
+ return (byte)((UInt16Amount & 0xFF00) >> 8);
+ }
+ set
+ {
+ UInt16Amount &= 0x00FF;
+ UInt16Amount += (ushort)(value << 8);
+ }
+ }
- ///
- /// Sample Header
- ///
- public SampleHeader SampleHeader
- {
- get
- {
- return sampleHeader;
- }
- set
- {
- sampleHeader = value;
- }
- }
+ ///
+ /// Instrument
+ ///
+ public Instrument Instrument { get; set; }
- ///
- ///
- ///
- public override string ToString()
- {
- if(generatorType == GeneratorEnum.Instrument)
- return String.Format("Generator Instrument {0}",instrument.Name);
- else if(generatorType == GeneratorEnum.SampleID)
- return String.Format("Generator SampleID {0}",sampleHeader);
- else
- return String.Format("Generator {0} {1}",generatorType,rawAmount);
- }
+ ///
+ /// Sample Header
+ ///
+ public SampleHeader SampleHeader { get; set; }
- }
+ ///
+ ///
+ ///
+ public override string ToString()
+ {
+ if (GeneratorType == GeneratorEnum.Instrument)
+ return $"Generator Instrument {Instrument.Name}";
+ else if (GeneratorType == GeneratorEnum.SampleID)
+ return $"Generator SampleID {SampleHeader}";
+ else
+ return $"Generator {GeneratorType} {UInt16Amount}";
+ }
+ }
}
\ No newline at end of file
diff --git a/NAudio/FileFormats/SoundFont/GeneratorBuilder.cs b/NAudio/FileFormats/SoundFont/GeneratorBuilder.cs
index e3adfa84..ddcfe2bc 100644
--- a/NAudio/FileFormats/SoundFont/GeneratorBuilder.cs
+++ b/NAudio/FileFormats/SoundFont/GeneratorBuilder.cs
@@ -1,59 +1,48 @@
-using System;
using System.IO;
-namespace NAudio.SoundFont
+namespace NAudio.SoundFont
{
- internal class GeneratorBuilder : StructureBuilder
- {
- public override Generator Read(BinaryReader br)
- {
- Generator g = new Generator();
- g.GeneratorType = (GeneratorEnum) br.ReadUInt16();
- g.UInt16Amount = br.ReadUInt16();
- data.Add(g);
- return g;
- }
+ internal class GeneratorBuilder : StructureBuilder
+ {
+ public override Generator Read(BinaryReader br)
+ {
+ Generator g = new Generator();
+ g.GeneratorType = (GeneratorEnum)br.ReadUInt16();
+ g.UInt16Amount = br.ReadUInt16();
+ data.Add(g);
+ return g;
+ }
- public override void Write(BinaryWriter bw, Generator o)
- {
- //Zone z = (Zone) o;
- //bw.Write(p.---);
- }
+ public override void Write(BinaryWriter bw, Generator o)
+ {
+ //Zone z = (Zone) o;
+ //bw.Write(p.---);
+ }
- public override int Length {
- get {
- return 4;
- }
- }
+ public override int Length => 4;
- public Generator[] Generators
- {
- get
- {
- return data.ToArray();
- }
- }
+ public Generator[] Generators => data.ToArray();
- public void Load(Instrument[] instruments)
- {
- foreach(Generator g in Generators)
- {
- if(g.GeneratorType == GeneratorEnum.Instrument)
- {
- g.Instrument = instruments[g.UInt16Amount];
- }
- }
- }
+ public void Load(Instrument[] instruments)
+ {
+ foreach (Generator g in Generators)
+ {
+ if (g.GeneratorType == GeneratorEnum.Instrument)
+ {
+ g.Instrument = instruments[g.UInt16Amount];
+ }
+ }
+ }
- public void Load(SampleHeader[] sampleHeaders)
- {
- foreach(Generator g in Generators)
- {
- if(g.GeneratorType == GeneratorEnum.SampleID)
- {
- g.SampleHeader = sampleHeaders[g.UInt16Amount];
- }
- }
- }
- }
+ public void Load(SampleHeader[] sampleHeaders)
+ {
+ foreach (Generator g in Generators)
+ {
+ if (g.GeneratorType == GeneratorEnum.SampleID)
+ {
+ g.SampleHeader = sampleHeaders[g.UInt16Amount];
+ }
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/NAudio/FileFormats/SoundFont/Instrument.cs b/NAudio/FileFormats/SoundFont/Instrument.cs
index 0c4b4d88..31f4342a 100644
--- a/NAudio/FileFormats/SoundFont/Instrument.cs
+++ b/NAudio/FileFormats/SoundFont/Instrument.cs
@@ -1,54 +1,28 @@
using System;
-namespace NAudio.SoundFont
+namespace NAudio.SoundFont
{
- ///
- /// SoundFont instrument
- ///
- public class Instrument
- {
- private string name;
- internal ushort startInstrumentZoneIndex;
- internal ushort endInstrumentZoneIndex;
- private Zone[] zones;
-
- ///
- /// instrument name
- ///
- public string Name
- {
- get
- {
- return name;
- }
- set
- {
- // TODO: validate
- name = value;
- }
- }
+ ///
+ /// SoundFont instrument
+ ///
+ public class Instrument
+ {
+ internal ushort startInstrumentZoneIndex;
+ internal ushort endInstrumentZoneIndex;
- ///
- /// Zones
- ///
- public Zone[] Zones
- {
- get
- {
- return zones;
- }
- set
- {
- zones = value;
- }
- }
+ ///
+ /// instrument name
+ ///
+ public string Name { get; set; }
- ///
- ///
- ///
- public override string ToString()
- {
- return this.name;
- }
- }
+ ///
+ /// Zones
+ ///
+ public Zone[] Zones { get; set; }
+
+ ///
+ ///
+ ///
+ public override string ToString() => Name;
+ }
}
\ No newline at end of file
diff --git a/NAudio/FileFormats/SoundFont/InstrumentBuilder.cs b/NAudio/FileFormats/SoundFont/InstrumentBuilder.cs
index 1a86a09f..11521b8e 100644
--- a/NAudio/FileFormats/SoundFont/InstrumentBuilder.cs
+++ b/NAudio/FileFormats/SoundFont/InstrumentBuilder.cs
@@ -2,65 +2,53 @@
using System.IO;
using System.Text;
-namespace NAudio.SoundFont
+namespace NAudio.SoundFont
{
- ///
- /// Instrument Builder
- ///
- internal class InstrumentBuilder : StructureBuilder
- {
- private Instrument lastInstrument = null;
+ ///
+ /// Instrument Builder
+ ///
+ internal class InstrumentBuilder : StructureBuilder
+ {
+ private Instrument lastInstrument = null;
- public override Instrument Read(BinaryReader br)
- {
- Instrument i = new Instrument();
- string s = Encoding.UTF8.GetString(br.ReadBytes(20), 0, 20);
- if(s.IndexOf('\0') >= 0)
- {
- s = s.Substring(0,s.IndexOf('\0'));
- }
- i.Name = s;
- i.startInstrumentZoneIndex = br.ReadUInt16();
- if(lastInstrument != null)
- {
- lastInstrument.endInstrumentZoneIndex = (ushort) (i.startInstrumentZoneIndex - 1);
- }
- data.Add(i);
- lastInstrument = i;
- return i;
- }
+ public override Instrument Read(BinaryReader br)
+ {
+ Instrument i = new Instrument();
+ string s = Encoding.UTF8.GetString(br.ReadBytes(20), 0, 20);
+ if (s.IndexOf('\0') >= 0)
+ {
+ s = s.Substring(0, s.IndexOf('\0'));
+ }
+ i.Name = s;
+ i.startInstrumentZoneIndex = br.ReadUInt16();
+ if (lastInstrument != null)
+ {
+ lastInstrument.endInstrumentZoneIndex = (ushort)(i.startInstrumentZoneIndex - 1);
+ }
+ data.Add(i);
+ lastInstrument = i;
+ return i;
+ }
- public override void Write(BinaryWriter bw, Instrument instrument)
- {
- }
+ public override void Write(BinaryWriter bw, Instrument instrument)
+ {
+ }
- public override int Length
- {
- get
- {
- return 22;
- }
- }
+ public override int Length => 22;
- public void LoadZones(Zone[] zones)
- {
- // don't do the last preset, which is simply EOP
- for(int instrument = 0; instrument < data.Count - 1; instrument++)
- {
- Instrument i = (Instrument) data[instrument];
- i.Zones = new Zone[i.endInstrumentZoneIndex - i.startInstrumentZoneIndex + 1];
- Array.Copy(zones,i.startInstrumentZoneIndex,i.Zones,0,i.Zones.Length);
- }
- // we can get rid of the EOP record now
- data.RemoveAt(data.Count - 1);
- }
+ public void LoadZones(Zone[] zones)
+ {
+ // don't do the last preset, which is simply EOP
+ for (int instrument = 0; instrument < data.Count - 1; instrument++)
+ {
+ Instrument i = data[instrument];
+ i.Zones = new Zone[i.endInstrumentZoneIndex - i.startInstrumentZoneIndex + 1];
+ Array.Copy(zones, i.startInstrumentZoneIndex, i.Zones, 0, i.Zones.Length);
+ }
+ // we can get rid of the EOP record now
+ data.RemoveAt(data.Count - 1);
+ }
- public Instrument[] Instruments
- {
- get
- {
- return data.ToArray();
- }
- }
- }
+ public Instrument[] Instruments => data.ToArray();
+ }
}
\ No newline at end of file
diff --git a/NAudio/FileFormats/SoundFont/Modulator.cs b/NAudio/FileFormats/SoundFont/Modulator.cs
index 42d6f06b..ae02f649 100644
--- a/NAudio/FileFormats/SoundFont/Modulator.cs
+++ b/NAudio/FileFormats/SoundFont/Modulator.cs
@@ -1,114 +1,58 @@
using System;
-namespace NAudio.SoundFont
+namespace NAudio.SoundFont
{
- ///
- /// Transform Types
- ///
- public enum TransformEnum
- {
- ///
- /// Linear
- ///
- Linear = 0
- }
-
- ///
- /// Modulator
- ///
- public class Modulator
- {
- private ModulatorType sourceModulationData;
- private GeneratorEnum destinationGenerator;
- private short amount;
- private ModulatorType sourceModulationAmount;
- private TransformEnum sourceTransform;
-
- ///
- /// Source Modulation data type
- ///
- public ModulatorType SourceModulationData
- {
- get
- {
- return sourceModulationData;
- }
- set
- {
- sourceModulationData = value;
- }
- }
-
- ///
- /// Destination generator type
- ///
- public GeneratorEnum DestinationGenerator
- {
- get
- {
- return destinationGenerator;
- }
- set
- {
- destinationGenerator = value;
- }
- }
-
- ///
- /// Amount
- ///
- public short Amount
- {
- get
- {
- return amount;
- }
- set
- {
- amount = value;
- }
- }
-
- ///
- /// Source Modulation Amount Type
- ///
- public ModulatorType SourceModulationAmount
- {
- get
- {
- return sourceModulationAmount;
- }
- set
- {
- sourceModulationAmount = value;
- }
- }
-
- ///
- /// Source Transform Type
- ///
- public TransformEnum SourceTransform
- {
- get
- {
- return sourceTransform;
- }
- set
- {
- sourceTransform = value;
- }
- }
-
- ///
- ///
- ///
- public override string ToString()
- {
- return String.Format("Modulator {0} {1} {2} {3} {4}",
- sourceModulationData,destinationGenerator,
- amount,sourceModulationAmount,sourceTransform);
+ ///
+ /// Transform Types
+ ///
+ public enum TransformEnum
+ {
+ ///
+ /// Linear
+ ///
+ Linear = 0
+ }
- }
+ ///
+ /// Modulator
+ ///
+ public class Modulator
+ {
- }
+ ///
+ /// Source Modulation data type
+ ///
+ public ModulatorType SourceModulationData { get; set; }
+
+ ///
+ /// Destination generator type
+ ///
+ public GeneratorEnum DestinationGenerator { get; set; }
+
+ ///
+ /// Amount
+ ///
+ public short Amount { get; set; }
+
+ ///
+ /// Source Modulation Amount Type
+ ///
+ public ModulatorType SourceModulationAmount { get; set; }
+
+ ///
+ /// Source Transform Type
+ ///
+ public TransformEnum SourceTransform { get; set; }
+
+ ///
+ ///
+ ///
+ public override string ToString()
+ {
+ return String.Format("Modulator {0} {1} {2} {3} {4}",
+ SourceModulationData, DestinationGenerator,
+ Amount, SourceModulationAmount, SourceTransform);
+ }
+
+ }
}
\ No newline at end of file
diff --git a/NAudio/FileFormats/SoundFont/ModulatorBuilder.cs b/NAudio/FileFormats/SoundFont/ModulatorBuilder.cs
index 877cfb47..81c39cb9 100644
--- a/NAudio/FileFormats/SoundFont/ModulatorBuilder.cs
+++ b/NAudio/FileFormats/SoundFont/ModulatorBuilder.cs
@@ -1,38 +1,29 @@
-using System;
using System.IO;
-namespace NAudio.SoundFont {
- class ModulatorBuilder : StructureBuilder {
+namespace NAudio.SoundFont
+{
+ class ModulatorBuilder : StructureBuilder
+ {
public override Modulator Read(BinaryReader br)
{
- Modulator m = new Modulator();
- m.SourceModulationData = new ModulatorType(br.ReadUInt16());
- m.DestinationGenerator = (GeneratorEnum) br.ReadUInt16();
- m.Amount = br.ReadInt16();
- m.SourceModulationAmount = new ModulatorType(br.ReadUInt16());
- m.SourceTransform = (TransformEnum) br.ReadUInt16();
- data.Add(m);
- return m;
- }
+ Modulator m = new Modulator();
+ m.SourceModulationData = new ModulatorType(br.ReadUInt16());
+ m.DestinationGenerator = (GeneratorEnum)br.ReadUInt16();
+ m.Amount = br.ReadInt16();
+ m.SourceModulationAmount = new ModulatorType(br.ReadUInt16());
+ m.SourceTransform = (TransformEnum)br.ReadUInt16();
+ data.Add(m);
+ return m;
+ }
public override void Write(BinaryWriter bw, Modulator o)
- {
- //Zone z = (Zone) o;
- //bw.Write(p.---);
- }
+ {
+ //Zone z = (Zone) o;
+ //bw.Write(p.---);
+ }
- public override int Length {
- get {
- return 10;
- }
- }
+ public override int Length => 10;
- public Modulator[] Modulators
- {
- get
- {
- return data.ToArray();
- }
- }
- }
+ public Modulator[] Modulators => data.ToArray();
+ }
}
\ No newline at end of file
diff --git a/NAudio/FileFormats/SoundFont/Preset.cs b/NAudio/FileFormats/SoundFont/Preset.cs
index 8a8f826f..d15e106a 100644
--- a/NAudio/FileFormats/SoundFont/Preset.cs
+++ b/NAudio/FileFormats/SoundFont/Preset.cs
@@ -1,92 +1,45 @@
using System;
-namespace NAudio.SoundFont
+namespace NAudio.SoundFont
{
- ///
- /// A SoundFont Preset
- ///
- public class Preset
- {
- private string name;
- private ushort patchNumber;
- private ushort bank;
- internal ushort startPresetZoneIndex;
- internal ushort endPresetZoneIndex;
- internal uint library;
- internal uint genre;
- internal uint morphology;
- private Zone[] zones;
-
- ///
- /// Preset name
- ///
- public string Name
- {
- get
- {
- return name;
- }
- set
- {
- // TODO: validate
- name = value;
- }
- }
-
- ///
- /// Patch Number
- ///
- public ushort PatchNumber
- {
- get
- {
- return patchNumber;
- }
- set
- {
- // TODO: validate
- patchNumber = value;
- }
- }
-
- ///
- /// Bank number
- ///
- public ushort Bank
- {
- get
- {
- return bank;
- }
- set
- {
- // 0 - 127, GM percussion bank is 128
- // TODO: validate
- bank = value;
- }
- }
-
- ///
- /// Zones
- ///
- public Zone[] Zones
- {
- get
- {
- return zones;
- }
- set
- {
- zones = value;
- }
- }
+ ///
+ /// A SoundFont Preset
+ ///
+ public class Preset
+ {
+ internal ushort startPresetZoneIndex;
+ internal ushort endPresetZoneIndex;
+ internal uint library;
+ internal uint genre;
+ internal uint morphology;
- ///
- ///
- ///
- public override string ToString()
- {
- return String.Format("{0}-{1} {2}",bank,patchNumber,name);
- }
- }
+ ///
+ /// Preset name
+ ///
+ public string Name { get; set; }
+
+ ///
+ /// Patch Number
+ ///
+ public ushort PatchNumber { get; set; }
+
+ ///
+ /// Bank number
+ /// 0 - 127, GM percussion bank is 128
+ ///
+ public ushort Bank { get; set; }
+
+ ///
+ /// Zones
+ ///
+ public Zone[] Zones { get; set; }
+
+ ///
+ ///
+ ///
+ public override string ToString()
+ {
+ return $"{Bank}-{PatchNumber} {Name}";
+ }
+ }
}
\ No newline at end of file
diff --git a/NAudio/FileFormats/SoundFont/PresetBuilder.cs b/NAudio/FileFormats/SoundFont/PresetBuilder.cs
index d3c97be7..32989176 100644
--- a/NAudio/FileFormats/SoundFont/PresetBuilder.cs
+++ b/NAudio/FileFormats/SoundFont/PresetBuilder.cs
@@ -2,62 +2,53 @@
using System.IO;
using System.Text;
-namespace NAudio.SoundFont
+namespace NAudio.SoundFont
{
- class PresetBuilder : StructureBuilder
- {
- private Preset lastPreset = null;
+ class PresetBuilder : StructureBuilder
+ {
+ private Preset lastPreset = null;
- public override Preset Read(BinaryReader br)
- {
- Preset p = new Preset();
- string s = Encoding.UTF8.GetString(br.ReadBytes(20), 0, 20);
- if(s.IndexOf('\0') >= 0) {
- s = s.Substring(0,s.IndexOf('\0'));
- }
- p.Name = s;
- p.PatchNumber = br.ReadUInt16();
- p.Bank = br.ReadUInt16();
- p.startPresetZoneIndex = br.ReadUInt16();
- p.library = br.ReadUInt32();
- p.genre = br.ReadUInt32();
- p.morphology = br.ReadUInt32();
- if(lastPreset != null)
- lastPreset.endPresetZoneIndex = (ushort) (p.startPresetZoneIndex - 1);
- data.Add(p);
- lastPreset = p;
- return p;
- }
+ public override Preset Read(BinaryReader br)
+ {
+ Preset p = new Preset();
+ string s = Encoding.UTF8.GetString(br.ReadBytes(20), 0, 20);
+ if (s.IndexOf('\0') >= 0)
+ {
+ s = s.Substring(0, s.IndexOf('\0'));
+ }
+ p.Name = s;
+ p.PatchNumber = br.ReadUInt16();
+ p.Bank = br.ReadUInt16();
+ p.startPresetZoneIndex = br.ReadUInt16();
+ p.library = br.ReadUInt32();
+ p.genre = br.ReadUInt32();
+ p.morphology = br.ReadUInt32();
+ if (lastPreset != null)
+ lastPreset.endPresetZoneIndex = (ushort)(p.startPresetZoneIndex - 1);
+ data.Add(p);
+ lastPreset = p;
+ return p;
+ }
public override void Write(BinaryWriter bw, Preset preset)
- {
- }
+ {
+ }
- public override int Length {
- get {
- return 38;
- }
- }
+ public override int Length => 38;
- public void LoadZones(Zone[] presetZones)
- {
- // don't do the last preset, which is simply EOP
- for(int preset = 0; preset < data.Count - 1; preset++)
- {
- Preset p = (Preset) data[preset];
- p.Zones = new Zone[p.endPresetZoneIndex - p.startPresetZoneIndex + 1];
- Array.Copy(presetZones,p.startPresetZoneIndex,p.Zones,0,p.Zones.Length);
- }
- // we can get rid of the EOP record now
- data.RemoveAt(data.Count - 1);
- }
+ public void LoadZones(Zone[] presetZones)
+ {
+ // don't do the last preset, which is simply EOP
+ for (int preset = 0; preset < data.Count - 1; preset++)
+ {
+ Preset p = data[preset];
+ p.Zones = new Zone[p.endPresetZoneIndex - p.startPresetZoneIndex + 1];
+ Array.Copy(presetZones, p.startPresetZoneIndex, p.Zones, 0, p.Zones.Length);
+ }
+ // we can get rid of the EOP record now
+ data.RemoveAt(data.Count - 1);
+ }
- public Preset[] Presets
- {
- get
- {
- return data.ToArray();
- }
- }
- }
+ public Preset[] Presets => data.ToArray();
+ }
}
\ No newline at end of file
diff --git a/NAudio/FileFormats/SoundFont/PresetsChunk.cs b/NAudio/FileFormats/SoundFont/PresetsChunk.cs
index 72b5daa2..c483d641 100644
--- a/NAudio/FileFormats/SoundFont/PresetsChunk.cs
+++ b/NAudio/FileFormats/SoundFont/PresetsChunk.cs
@@ -81,44 +81,26 @@ internal PresetsChunk(RiffChunk chunk)
presetHeaders.LoadZones(presetZones.Zones);
sampleHeaders.RemoveEOS();
}
-
- ///
- /// The Presets contained in this chunk
- ///
- public Preset[] Presets
- {
- get
- {
- return presetHeaders.Presets;
- }
- }
- ///
- /// The instruments contained in this chunk
- ///
- public Instrument[] Instruments
- {
- get
- {
- return instruments.Instruments;
- }
- }
+ ///
+ /// The Presets contained in this chunk
+ ///
+ public Preset[] Presets => presetHeaders.Presets;
- ///
- /// The sample headers contained in this chunk
- ///
- public SampleHeader[] SampleHeaders
- {
- get
- {
- return sampleHeaders.SampleHeaders;
- }
- }
+ ///
+ /// The instruments contained in this chunk
+ ///
+ public Instrument[] Instruments => instruments.Instruments;
+
+ ///
+ /// The sample headers contained in this chunk
+ ///
+ public SampleHeader[] SampleHeaders => sampleHeaders.SampleHeaders;
- ///
- ///
- ///
- public override string ToString()
+ ///
+ ///
+ ///
+ public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append("Preset Headers:\r\n");
diff --git a/NAudio/FileFormats/SoundFont/RiffChunk.cs b/NAudio/FileFormats/SoundFont/RiffChunk.cs
index 282f5b87..e2999189 100644
--- a/NAudio/FileFormats/SoundFont/RiffChunk.cs
+++ b/NAudio/FileFormats/SoundFont/RiffChunk.cs
@@ -1,164 +1,148 @@
using System;
using System.IO;
-using System.Net;
-using System.Text;
using NAudio.Utils;
-namespace NAudio.SoundFont
+namespace NAudio.SoundFont
{
- internal class RiffChunk
- {
- private string chunkID;
- private uint chunkSize;
- private long dataOffset; // data offset in the file
- private BinaryReader riffFile;
-
- public static RiffChunk GetTopLevelChunk(BinaryReader file)
- {
- RiffChunk r = new RiffChunk(file);
- r.ReadChunk();
- return r;
- }
-
- private RiffChunk(BinaryReader file)
- {
- riffFile = file;
- chunkID = "????";
- chunkSize = 0;
- dataOffset = 0;
- }
-
- ///
- /// just reads a chunk ID at the current position
- ///
- /// chunk ID
- public string ReadChunkID()
- {
- byte []cid = riffFile.ReadBytes(4);
- if(cid.Length != 4)
- {
- throw new InvalidDataException("Couldn't read Chunk ID");
- }
- return ByteEncoding.Instance.GetString(cid, 0, cid.Length);
- }
-
- ///
- /// reads a chunk at the current position
- ///
- private void ReadChunk()
- {
- this.chunkID = ReadChunkID();
- this.chunkSize = riffFile.ReadUInt32(); //(uint) IPAddress.NetworkToHostOrder(riffFile.ReadUInt32());
- this.dataOffset = riffFile.BaseStream.Position;
- }
-
- ///
- /// creates a new riffchunk from current position checking that we're not
- /// at the end of this chunk first
- ///
- /// the new chunk
- public RiffChunk GetNextSubChunk()
- {
- if(riffFile.BaseStream.Position + 8 < dataOffset + chunkSize)
- {
- RiffChunk chunk = new RiffChunk(riffFile);
- chunk.ReadChunk();
- return chunk;
- }
- //Console.WriteLine("DEBUG Failed to GetNextSubChunk because Position is {0}, dataOffset{1}, chunkSize {2}",riffFile.BaseStream.Position,dataOffset,chunkSize);
- return null;
- }
-
- public byte[] GetData()
- {
- riffFile.BaseStream.Position = dataOffset;
- byte[] data = riffFile.ReadBytes((int) chunkSize);
- if(data.Length != chunkSize)
- {
- throw new InvalidDataException(String.Format("Couldn't read chunk's data Chunk: {0}, read {1} bytes",this,data.Length));
- }
- return data;
- }
-
- ///
- /// useful for chunks that just contain a string
- ///
- /// chunk as string
- public string GetDataAsString()
- {
- byte[] data = GetData();
- if(data == null)
- return null;
- return ByteEncoding.Instance.GetString(data, 0, data.Length);
- }
-
- public T GetDataAsStructure(StructureBuilder s)
- {
- riffFile.BaseStream.Position = dataOffset;
- if(s.Length != chunkSize)
- {
- throw new InvalidDataException(String.Format("Chunk size is: {0} so can't read structure of: {1}",chunkSize,s.Length));
- }
- return s.Read(riffFile);
- }
-
- public T[] GetDataAsStructureArray(StructureBuilder s)
- {
- riffFile.BaseStream.Position = dataOffset;
- if(chunkSize % s.Length != 0)
- {
- throw new InvalidDataException(String.Format("Chunk size is: {0} not a multiple of structure size: {1}", chunkSize, s.Length));
- }
- int structuresToRead = (int) (chunkSize / s.Length);
- T[] a = new T[structuresToRead];
- for(int n = 0; n < structuresToRead; n++)
- {
- a[n] = s.Read(riffFile);
- }
- return a;
- }
-
- public string ChunkID
- {
- get
- {
- return chunkID;
- }
- set
- {
- if(value == null)
- {
- throw new ArgumentNullException("ChunkID may not be null");
- }
- if(value.Length != 4)
- {
- throw new ArgumentException("ChunkID must be four characters");
- }
- chunkID = value;
- }
- }
-
- public uint ChunkSize
- {
- get
- {
- return chunkSize;
- }
- }
-
- public long DataOffset
- {
- get
- {
- return dataOffset;
- }
- }
-
- public override string ToString()
- {
- return String.Format("RiffChunk ID: {0} Size: {1} Data Offset: {2}",ChunkID,ChunkSize,DataOffset);
- }
-
- }
+ internal class RiffChunk
+ {
+ private string chunkID;
+ private BinaryReader riffFile;
+
+ public static RiffChunk GetTopLevelChunk(BinaryReader file)
+ {
+ RiffChunk r = new RiffChunk(file);
+ r.ReadChunk();
+ return r;
+ }
+
+ private RiffChunk(BinaryReader file)
+ {
+ riffFile = file;
+ chunkID = "????";
+ ChunkSize = 0;
+ DataOffset = 0;
+ }
+
+ ///
+ /// just reads a chunk ID at the current position
+ ///
+ /// chunk ID
+ public string ReadChunkID()
+ {
+ byte[] cid = riffFile.ReadBytes(4);
+ if (cid.Length != 4)
+ {
+ throw new InvalidDataException("Couldn't read Chunk ID");
+ }
+ return ByteEncoding.Instance.GetString(cid, 0, cid.Length);
+ }
+
+ ///
+ /// reads a chunk at the current position
+ ///
+ private void ReadChunk()
+ {
+ this.chunkID = ReadChunkID();
+ this.ChunkSize = riffFile.ReadUInt32(); //(uint) IPAddress.NetworkToHostOrder(riffFile.ReadUInt32());
+ this.DataOffset = riffFile.BaseStream.Position;
+ }
+
+ ///
+ /// creates a new riffchunk from current position checking that we're not
+ /// at the end of this chunk first
+ ///
+ /// the new chunk
+ public RiffChunk GetNextSubChunk()
+ {
+ if (riffFile.BaseStream.Position + 8 < DataOffset + ChunkSize)
+ {
+ RiffChunk chunk = new RiffChunk(riffFile);
+ chunk.ReadChunk();
+ return chunk;
+ }
+ //Console.WriteLine("DEBUG Failed to GetNextSubChunk because Position is {0}, dataOffset{1}, chunkSize {2}",riffFile.BaseStream.Position,dataOffset,chunkSize);
+ return null;
+ }
+
+ public byte[] GetData()
+ {
+ riffFile.BaseStream.Position = DataOffset;
+ byte[] data = riffFile.ReadBytes((int)ChunkSize);
+ if (data.Length != ChunkSize)
+ {
+ throw new InvalidDataException(String.Format("Couldn't read chunk's data Chunk: {0}, read {1} bytes", this, data.Length));
+ }
+ return data;
+ }
+
+ ///
+ /// useful for chunks that just contain a string
+ ///
+ /// chunk as string
+ public string GetDataAsString()
+ {
+ byte[] data = GetData();
+ if (data == null)
+ return null;
+ return ByteEncoding.Instance.GetString(data, 0, data.Length);
+ }
+
+ public T GetDataAsStructure(StructureBuilder s)
+ {
+ riffFile.BaseStream.Position = DataOffset;
+ if (s.Length != ChunkSize)
+ {
+ throw new InvalidDataException(String.Format("Chunk size is: {0} so can't read structure of: {1}", ChunkSize, s.Length));
+ }
+ return s.Read(riffFile);
+ }
+
+ public T[] GetDataAsStructureArray(StructureBuilder s)
+ {
+ riffFile.BaseStream.Position = DataOffset;
+ if (ChunkSize % s.Length != 0)
+ {
+ throw new InvalidDataException(String.Format("Chunk size is: {0} not a multiple of structure size: {1}", ChunkSize, s.Length));
+ }
+ int structuresToRead = (int)(ChunkSize / s.Length);
+ T[] a = new T[structuresToRead];
+ for (int n = 0; n < structuresToRead; n++)
+ {
+ a[n] = s.Read(riffFile);
+ }
+ return a;
+ }
+
+ public string ChunkID
+ {
+ get
+ {
+ return chunkID;
+ }
+ set
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException("ChunkID may not be null");
+ }
+ if (value.Length != 4)
+ {
+ throw new ArgumentException("ChunkID must be four characters");
+ }
+ chunkID = value;
+ }
+ }
+
+ public uint ChunkSize { get; private set; }
+
+ public long DataOffset { get; private set; }
+
+ public override string ToString()
+ {
+ return String.Format("RiffChunk ID: {0} Size: {1} Data Offset: {2}", ChunkID, ChunkSize, DataOffset);
+ }
+
+ }
}
diff --git a/NAudio/FileFormats/SoundFont/SFVersion.cs b/NAudio/FileFormats/SoundFont/SFVersion.cs
index 917cf0c5..5bb1f8af 100644
--- a/NAudio/FileFormats/SoundFont/SFVersion.cs
+++ b/NAudio/FileFormats/SoundFont/SFVersion.cs
@@ -1,44 +1,22 @@
using System;
using System.IO;
-namespace NAudio.SoundFont
+namespace NAudio.SoundFont
{
- ///
- /// SoundFont Version Structure
- ///
- public class SFVersion
- {
- private short major;
- private short minor;
+ ///
+ /// SoundFont Version Structure
+ ///
+ public class SFVersion
+ {
- ///
- /// Major Version
- ///
- public short Major
- {
- get
- {
- return major;
- }
- set
- {
- major = value;
- }
- }
+ ///
+ /// Major Version
+ ///
+ public short Major { get; set; }
- ///
- /// Minor Version
- ///
- public short Minor
- {
- get
- {
- return minor;
- }
- set
- {
- minor = value;
- }
- }
- }
+ ///
+ /// Minor Version
+ ///
+ public short Minor { get; set; }
+ }
}
\ No newline at end of file
diff --git a/NAudio/FileFormats/SoundFont/SFVersionBuilder.cs b/NAudio/FileFormats/SoundFont/SFVersionBuilder.cs
index 01b45480..8e9b45db 100644
--- a/NAudio/FileFormats/SoundFont/SFVersionBuilder.cs
+++ b/NAudio/FileFormats/SoundFont/SFVersionBuilder.cs
@@ -1,43 +1,36 @@
-using System;
using System.IO;
-namespace NAudio.SoundFont
+namespace NAudio.SoundFont
{
- ///
- /// Builds a SoundFont version
- ///
- class SFVersionBuilder : StructureBuilder
- {
- ///
- /// Reads a SoundFont Version structure
- ///
- public override SFVersion Read(BinaryReader br)
- {
- SFVersion v = new SFVersion();
- v.Major = br.ReadInt16();
- v.Minor = br.ReadInt16();
- data.Add(v);
- return v;
- }
+ ///
+ /// Builds a SoundFont version
+ ///
+ class SFVersionBuilder : StructureBuilder
+ {
+ ///
+ /// Reads a SoundFont Version structure
+ ///
+ public override SFVersion Read(BinaryReader br)
+ {
+ SFVersion v = new SFVersion();
+ v.Major = br.ReadInt16();
+ v.Minor = br.ReadInt16();
+ data.Add(v);
+ return v;
+ }
- ///
- /// Writes a SoundFont Version structure
- ///
- public override void Write(BinaryWriter bw, SFVersion v)
- {
- bw.Write(v.Major);
- bw.Write(v.Minor);
- }
+ ///
+ /// Writes a SoundFont Version structure
+ ///
+ public override void Write(BinaryWriter bw, SFVersion v)
+ {
+ bw.Write(v.Major);
+ bw.Write(v.Minor);
+ }
- ///
- /// Gets the length of this structure
- ///
- public override int Length
- {
- get
- {
- return 4;
- }
- }
- }
+ ///
+ /// Gets the length of this structure
+ ///
+ public override int Length => 4;
+ }
}
\ No newline at end of file
diff --git a/NAudio/FileFormats/SoundFont/SampleDataChunk.cs b/NAudio/FileFormats/SoundFont/SampleDataChunk.cs
index 6a896085..212019c3 100644
--- a/NAudio/FileFormats/SoundFont/SampleDataChunk.cs
+++ b/NAudio/FileFormats/SoundFont/SampleDataChunk.cs
@@ -1,28 +1,20 @@
-using System;
using System.IO;
-namespace NAudio.SoundFont
+namespace NAudio.SoundFont
{
- class SampleDataChunk
- {
- private byte[] sampleData;
- public SampleDataChunk(RiffChunk chunk)
- {
- string header = chunk.ReadChunkID();
- if(header != "sdta")
- {
- throw new InvalidDataException(String.Format("Not a sample data chunk ({0})",header));
- }
- sampleData = chunk.GetData();
- }
+ class SampleDataChunk
+ {
+ public SampleDataChunk(RiffChunk chunk)
+ {
+ string header = chunk.ReadChunkID();
+ if (header != "sdta")
+ {
+ throw new InvalidDataException($"Not a sample data chunk ({header})");
+ }
+ SampleData = chunk.GetData();
+ }
- public byte[] SampleData
- {
- get
- {
- return sampleData;
- }
- }
- }
+ public byte[] SampleData { get; private set; }
+ }
-} // end of namespace
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/NAudio/FileFormats/SoundFont/SampleHeader.cs b/NAudio/FileFormats/SoundFont/SampleHeader.cs
index 145c3e3a..327c2766 100644
--- a/NAudio/FileFormats/SoundFont/SampleHeader.cs
+++ b/NAudio/FileFormats/SoundFont/SampleHeader.cs
@@ -1,61 +1,56 @@
-using System;
-
-namespace NAudio.SoundFont
+namespace NAudio.SoundFont
{
- ///
- /// A SoundFont Sample Header
- ///
- public class SampleHeader
- {
- ///
- /// The sample name
- ///
- public string SampleName;
- ///
- /// Start offset
- ///
- public uint Start;
- ///
- /// End offset
- ///
- public uint End;
- ///
- /// Start loop point
- ///
- public uint StartLoop;
- ///
- /// End loop point
- ///
- public uint EndLoop;
- ///
- /// Sample Rate
- ///
- public uint SampleRate;
- ///
- /// Original pitch
- ///
- public byte OriginalPitch;
- ///
- /// Pitch correction
- ///
- public sbyte PitchCorrection;
- ///
- /// Sample Link
- ///
- public ushort SampleLink;
- ///
- /// SoundFont Sample Link Type
- ///
- public SFSampleLink SFSampleLink;
+ ///
+ /// A SoundFont Sample Header
+ ///
+ public class SampleHeader
+ {
+ ///
+ /// The sample name
+ ///
+ public string SampleName;
+ ///
+ /// Start offset
+ ///
+ public uint Start;
+ ///
+ /// End offset
+ ///
+ public uint End;
+ ///
+ /// Start loop point
+ ///
+ public uint StartLoop;
+ ///
+ /// End loop point
+ ///
+ public uint EndLoop;
+ ///
+ /// Sample Rate
+ ///
+ public uint SampleRate;
+ ///
+ /// Original pitch
+ ///
+ public byte OriginalPitch;
+ ///
+ /// Pitch correction
+ ///
+ public sbyte PitchCorrection;
+ ///
+ /// Sample Link
+ ///
+ public ushort SampleLink;
+ ///
+ /// SoundFont Sample Link Type
+ ///
+ public SFSampleLink SFSampleLink;
+
+ ///
+ ///
+ ///
+ public override string ToString() => SampleName;
- ///
- ///
- ///
- public override string ToString()
- {
- return SampleName;
- }
-
- }
+ }
}
diff --git a/NAudio/FileFormats/SoundFont/SampleHeaderBuilder.cs b/NAudio/FileFormats/SoundFont/SampleHeaderBuilder.cs
index 3f30ea6b..d9c9907f 100644
--- a/NAudio/FileFormats/SoundFont/SampleHeaderBuilder.cs
+++ b/NAudio/FileFormats/SoundFont/SampleHeaderBuilder.cs
@@ -1,54 +1,40 @@
-using System;
using System.IO;
-using System.Text;
using NAudio.Utils;
namespace NAudio.SoundFont
{
- class SampleHeaderBuilder : StructureBuilder
- {
- public override SampleHeader Read(BinaryReader br)
- {
- SampleHeader sh = new SampleHeader();
+ class SampleHeaderBuilder : StructureBuilder
+ {
+ public override SampleHeader Read(BinaryReader br)
+ {
+ SampleHeader sh = new SampleHeader();
var s = br.ReadBytes(20);
- sh.SampleName = ByteEncoding.Instance.GetString(s, 0, s.Length);
- sh.Start = br.ReadUInt32();
- sh.End = br.ReadUInt32();
- sh.StartLoop = br.ReadUInt32();
- sh.EndLoop = br.ReadUInt32();
- sh.SampleRate = br.ReadUInt32();
- sh.OriginalPitch = br.ReadByte();
- sh.PitchCorrection = br.ReadSByte();
- sh.SampleLink = br.ReadUInt16();
- sh.SFSampleLink = (SFSampleLink) br.ReadUInt16();
- data.Add(sh);
- return sh;
- }
+ sh.SampleName = ByteEncoding.Instance.GetString(s, 0, s.Length);
+ sh.Start = br.ReadUInt32();
+ sh.End = br.ReadUInt32();
+ sh.StartLoop = br.ReadUInt32();
+ sh.EndLoop = br.ReadUInt32();
+ sh.SampleRate = br.ReadUInt32();
+ sh.OriginalPitch = br.ReadByte();
+ sh.PitchCorrection = br.ReadSByte();
+ sh.SampleLink = br.ReadUInt16();
+ sh.SFSampleLink = (SFSampleLink)br.ReadUInt16();
+ data.Add(sh);
+ return sh;
+ }
- public override void Write(BinaryWriter bw, SampleHeader sampleHeader)
- {
- }
+ public override void Write(BinaryWriter bw, SampleHeader sampleHeader)
+ {
+ }
- public override int Length
- {
- get
- {
- return 46;
- }
- }
+ public override int Length => 46;
- internal void RemoveEOS()
- {
- data.RemoveAt(data.Count-1);
- }
+ internal void RemoveEOS()
+ {
+ data.RemoveAt(data.Count - 1);
+ }
- public SampleHeader[] SampleHeaders
- {
- get
- {
- return data.ToArray();
- }
- }
- }
+ public SampleHeader[] SampleHeaders => data.ToArray();
+ }
}
\ No newline at end of file
diff --git a/NAudio/FileFormats/SoundFont/SampleMode.cs b/NAudio/FileFormats/SoundFont/SampleMode.cs
index 4c27e142..44ef0849 100644
--- a/NAudio/FileFormats/SoundFont/SampleMode.cs
+++ b/NAudio/FileFormats/SoundFont/SampleMode.cs
@@ -1,27 +1,25 @@
-using System;
-
namespace NAudio.SoundFont
{
- ///
- /// SoundFont sample modes
- ///
- public enum SampleMode
- {
+ ///
+ /// SoundFont sample modes
+ ///
+ public enum SampleMode
+ {
///
/// No loop
///
- NoLoop,
+ NoLoop,
///
/// Loop Continuously
///
- LoopContinuously,
+ LoopContinuously,
///
/// Reserved no loop
///
- ReservedNoLoop,
+ ReservedNoLoop,
///
/// Loop and continue
///
- LoopAndContinue
- }
+ LoopAndContinue
+ }
}
diff --git a/NAudio/FileFormats/SoundFont/SoundFont.cs b/NAudio/FileFormats/SoundFont/SoundFont.cs
index a2c55386..f54b3e0d 100644
--- a/NAudio/FileFormats/SoundFont/SoundFont.cs
+++ b/NAudio/FileFormats/SoundFont/SoundFont.cs
@@ -1,26 +1,26 @@
using System;
using System.IO;
-namespace NAudio.SoundFont
+namespace NAudio.SoundFont
{
- ///
- /// Represents a SoundFont
- ///
- public class SoundFont
- {
- private InfoChunk info;
- private PresetsChunk presetsChunk;
- private SampleDataChunk sampleData;
+ ///
+ /// Represents a SoundFont
+ ///
+ public class SoundFont
+ {
+ private InfoChunk info;
+ private PresetsChunk presetsChunk;
+ private SampleDataChunk sampleData;
#if !NETFX_CORE
- ///
- /// Loads a SoundFont from a file
- ///
- /// Filename of the SoundFont
- public SoundFont(string fileName) :
- this(new FileStream(fileName,FileMode.Open,FileAccess.Read))
- {
- }
+ ///
+ /// Loads a SoundFont from a file
+ ///
+ /// Filename of the SoundFont
+ public SoundFont(string fileName) :
+ this(new FileStream(fileName, FileMode.Open, FileAccess.Read))
+ {
+ }
#endif
///
@@ -28,105 +28,75 @@ public SoundFont(string fileName) :
///
/// stream
public SoundFont(Stream sfFile)
- {
- using(sfFile) // a bit ugly, done to get Win store to compile
- {
- RiffChunk riff = RiffChunk.GetTopLevelChunk(new BinaryReader(sfFile));
- if(riff.ChunkID == "RIFF")
- {
- string formHeader = riff.ReadChunkID();
- if(formHeader != "sfbk")
- {
- throw new InvalidDataException(String.Format("Not a SoundFont ({0})",formHeader));
- }
- RiffChunk list = riff.GetNextSubChunk();
- if(list.ChunkID == "LIST")
- {
- //RiffChunk r = list.GetNextSubChunk();
- info = new InfoChunk(list);
+ {
+ using (sfFile) // a bit ugly, done to get Win store to compile
+ {
+ RiffChunk riff = RiffChunk.GetTopLevelChunk(new BinaryReader(sfFile));
+ if (riff.ChunkID == "RIFF")
+ {
+ string formHeader = riff.ReadChunkID();
+ if (formHeader != "sfbk")
+ {
+ throw new InvalidDataException(String.Format("Not a SoundFont ({0})", formHeader));
+ }
+ RiffChunk list = riff.GetNextSubChunk();
+ if (list.ChunkID == "LIST")
+ {
+ //RiffChunk r = list.GetNextSubChunk();
+ info = new InfoChunk(list);
- RiffChunk r = riff.GetNextSubChunk();
- sampleData = new SampleDataChunk(r);
+ RiffChunk r = riff.GetNextSubChunk();
+ sampleData = new SampleDataChunk(r);
- r = riff.GetNextSubChunk();
- presetsChunk = new PresetsChunk(r);
- }
- else
- {
+ r = riff.GetNextSubChunk();
+ presetsChunk = new PresetsChunk(r);
+ }
+ else
+ {
throw new InvalidDataException(String.Format("Not info list found ({0})", list.ChunkID));
- }
- }
- else
- {
+ }
+ }
+ else
+ {
throw new InvalidDataException("Not a RIFF file");
- }
- }
- }
+ }
+ }
+ }
- ///
- /// The File Info Chunk
- ///
- public InfoChunk FileInfo
- {
- get
- {
- return info;
- }
- }
+ ///
+ /// The File Info Chunk
+ ///
+ public InfoChunk FileInfo => info;
- ///
- /// The Presets
- ///
- public Preset[] Presets
- {
- get
- {
- return presetsChunk.Presets;
- }
- }
+ ///
+ /// The Presets
+ ///
+ public Preset[] Presets => presetsChunk.Presets;
- ///
- /// The Instruments
- ///
- public Instrument[] Instruments
- {
- get
- {
- return presetsChunk.Instruments;
- }
- }
+ ///
+ /// The Instruments
+ ///
+ public Instrument[] Instruments => presetsChunk.Instruments;
- ///
- /// The Sample Headers
- ///
- public SampleHeader[] SampleHeaders
- {
- get
- {
- return presetsChunk.SampleHeaders;
- }
- }
+ ///
+ /// The Sample Headers
+ ///
+ public SampleHeader[] SampleHeaders => presetsChunk.SampleHeaders;
- ///
- /// The Sample Data
- ///
- public byte[] SampleData
- {
- get
- {
- return sampleData.SampleData;
- }
- }
+ ///
+ /// The Sample Data
+ ///
+ public byte[] SampleData => sampleData.SampleData;
- ///
- ///
- ///
- public override string ToString()
- {
- return String.Format("Info Chunk:\r\n{0}\r\nPresets Chunk:\r\n{1}",
- info,presetsChunk);
- }
+ ///
+ ///
+ ///
+ public override string ToString()
+ {
+ return String.Format("Info Chunk:\r\n{0}\r\nPresets Chunk:\r\n{1}",
+ info, presetsChunk);
+ }
- // TODO: save / save as function
- }
+ // TODO: save / save as function
+ }
}
diff --git a/NAudio/FileFormats/SoundFont/StructureBuilder.cs b/NAudio/FileFormats/SoundFont/StructureBuilder.cs
index 4c9ca157..eb39b09f 100644
--- a/NAudio/FileFormats/SoundFont/StructureBuilder.cs
+++ b/NAudio/FileFormats/SoundFont/StructureBuilder.cs
@@ -1,39 +1,31 @@
using System;
using System.Collections.Generic;
using System.IO;
-using System.Collections;
-
-namespace NAudio.SoundFont
+namespace NAudio.SoundFont
{
- ///
- /// base class for structures that can read themselves
- ///
- internal abstract class StructureBuilder
- {
- protected List data;
+ ///
+ /// base class for structures that can read themselves
+ ///
+ internal abstract class StructureBuilder
+ {
+ protected List data;
+
+ public StructureBuilder()
+ {
+ Reset();
+ }
+
+ public abstract T Read(BinaryReader br);
+ public abstract void Write(BinaryWriter bw, T o);
+ public abstract int Length { get; }
- public StructureBuilder()
- {
- Reset();
- }
+ public void Reset()
+ {
+ data = new List();
+ }
- public abstract T Read(BinaryReader br);
- public abstract void Write(BinaryWriter bw,T o);
- public abstract int Length { get; }
-
- public void Reset()
- {
- data = new List();
- }
-
- public T[] Data
- {
- get
- {
- return data.ToArray();
- }
- }
- }
+ public T[] Data => data.ToArray();
+ }
}
\ No newline at end of file
diff --git a/NAudio/FileFormats/SoundFont/Zone.cs b/NAudio/FileFormats/SoundFont/Zone.cs
index 604de6ad..c792b27e 100644
--- a/NAudio/FileFormats/SoundFont/Zone.cs
+++ b/NAudio/FileFormats/SoundFont/Zone.cs
@@ -1,57 +1,35 @@
using System;
-namespace NAudio.SoundFont
+namespace NAudio.SoundFont
{
- ///
- /// A SoundFont zone
- ///
- public class Zone
- {
- internal ushort generatorIndex;
- internal ushort modulatorIndex;
- internal ushort generatorCount;
- internal ushort modulatorCount;
- private Modulator[] modulators;
- private Generator[] generators;
+ ///
+ /// A SoundFont zone
+ ///
+ public class Zone
+ {
+ internal ushort generatorIndex;
+ internal ushort modulatorIndex;
+ internal ushort generatorCount;
+ internal ushort modulatorCount;
- ///
- ///
- ///
- public override string ToString()
- {
- return String.Format("Zone {0} Gens:{1} {2} Mods:{3}",generatorCount,generatorIndex,
- modulatorCount,modulatorIndex);
- }
+ ///
+ ///
+ ///
+ public override string ToString()
+ {
+ return String.Format("Zone {0} Gens:{1} {2} Mods:{3}", generatorCount, generatorIndex,
+ modulatorCount, modulatorIndex);
+ }
- ///
- /// Modulators for this Zone
- ///
- public Modulator[] Modulators
- {
- get
- {
- return modulators;
- }
- set
- {
- modulators = value;
- }
- }
+ ///
+ /// Modulators for this Zone
+ ///
+ public Modulator[] Modulators { get; set; }
- ///
- /// Generators for this Zone
- ///
- public Generator[] Generators
- {
- get
- {
- return generators;
- }
- set
- {
- generators = value;
- }
- }
+ ///
+ /// Generators for this Zone
+ ///
+ public Generator[] Generators { get; set; }
- }
+ }
}
\ No newline at end of file
diff --git a/NAudio/FileFormats/SoundFont/ZoneBuilder.cs b/NAudio/FileFormats/SoundFont/ZoneBuilder.cs
index f09e674e..ce33c653 100644
--- a/NAudio/FileFormats/SoundFont/ZoneBuilder.cs
+++ b/NAudio/FileFormats/SoundFont/ZoneBuilder.cs
@@ -1,59 +1,49 @@
using System;
using System.IO;
-namespace NAudio.SoundFont
+namespace NAudio.SoundFont
{
- class ZoneBuilder : StructureBuilder
- {
- private Zone lastZone = null;
+ class ZoneBuilder : StructureBuilder
+ {
+ private Zone lastZone = null;
- public override Zone Read(BinaryReader br)
+ public override Zone Read(BinaryReader br)
{
- Zone z = new Zone();
- z.generatorIndex = br.ReadUInt16();
- z.modulatorIndex = br.ReadUInt16();
- if(lastZone != null)
- {
- lastZone.generatorCount = (ushort) (z.generatorIndex - lastZone.generatorIndex);
- lastZone.modulatorCount = (ushort) (z.modulatorIndex - lastZone.modulatorIndex);
- }
- data.Add(z);
- lastZone = z;
- return z;
- }
+ Zone z = new Zone();
+ z.generatorIndex = br.ReadUInt16();
+ z.modulatorIndex = br.ReadUInt16();
+ if (lastZone != null)
+ {
+ lastZone.generatorCount = (ushort)(z.generatorIndex - lastZone.generatorIndex);
+ lastZone.modulatorCount = (ushort)(z.modulatorIndex - lastZone.modulatorIndex);
+ }
+ data.Add(z);
+ lastZone = z;
+ return z;
+ }
- public override void Write(BinaryWriter bw, Zone zone)
- {
- //bw.Write(p.---);
- }
+ public override void Write(BinaryWriter bw, Zone zone)
+ {
+ //bw.Write(p.---);
+ }
- public void Load(Modulator[] modulators, Generator[] generators)
- {
- // don't do the last zone, which is simply EOZ
- for(int zone = 0; zone < data.Count - 1; zone++)
- {
- Zone z = (Zone) data[zone];
- z.Generators = new Generator[z.generatorCount];
- Array.Copy(generators,z.generatorIndex,z.Generators,0,z.generatorCount);
- z.Modulators = new Modulator[z.modulatorCount];
- Array.Copy(modulators,z.modulatorIndex,z.Modulators,0,z.modulatorCount);
- }
- // we can get rid of the EOP record now
- data.RemoveAt(data.Count - 1);
- }
+ public void Load(Modulator[] modulators, Generator[] generators)
+ {
+ // don't do the last zone, which is simply EOZ
+ for (int zone = 0; zone < data.Count - 1; zone++)
+ {
+ Zone z = (Zone)data[zone];
+ z.Generators = new Generator[z.generatorCount];
+ Array.Copy(generators, z.generatorIndex, z.Generators, 0, z.generatorCount);
+ z.Modulators = new Modulator[z.modulatorCount];
+ Array.Copy(modulators, z.modulatorIndex, z.Modulators, 0, z.modulatorCount);
+ }
+ // we can get rid of the EOP record now
+ data.RemoveAt(data.Count - 1);
+ }
- public Zone[] Zones
- {
- get
- {
- return data.ToArray();
- }
- }
+ public Zone[] Zones => data.ToArray();
- public override int Length {
- get {
- return 4;
- }
- }
- }
+ public override int Length => 4;
+ }
}
\ No newline at end of file
diff --git a/NAudio/MediaFoundation/AudioSubtypes.cs b/NAudio/MediaFoundation/AudioSubtypes.cs
index b6ba751d..030c4068 100644
--- a/NAudio/MediaFoundation/AudioSubtypes.cs
+++ b/NAudio/MediaFoundation/AudioSubtypes.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using NAudio.Utils;
namespace NAudio.MediaFoundation
diff --git a/NAudio/MediaFoundation/MediaFoundationHelpers.cs b/NAudio/MediaFoundation/MediaFoundationHelpers.cs
index 805390eb..fb42e178 100644
--- a/NAudio/MediaFoundation/MediaFoundationHelpers.cs
+++ b/NAudio/MediaFoundation/MediaFoundationHelpers.cs
@@ -40,10 +40,8 @@ public static void Startup()
///
public static IEnumerable EnumerateTransforms(Guid category)
{
- IntPtr interfacesPointer;
- int interfaceCount;
MediaFoundationInterop.MFTEnumEx(category, _MFT_ENUM_FLAG.MFT_ENUM_FLAG_ALL,
- null, null, out interfacesPointer, out interfaceCount);
+ null, null, out var interfacesPointer, out var interfaceCount);
var interfaces = new IMFActivate[interfaceCount];
for (int n = 0; n < interfaceCount; n++)
{
@@ -77,8 +75,7 @@ public static void Shutdown()
///
public static IMFMediaType CreateMediaType()
{
- IMFMediaType mediaType;
- MediaFoundationInterop.MFCreateMediaType(out mediaType);
+ MediaFoundationInterop.MFCreateMediaType(out IMFMediaType mediaType);
return mediaType;
}
@@ -107,8 +104,7 @@ public static IMFMediaType CreateMediaTypeFromWaveFormat(WaveFormat waveFormat)
/// The memory buffer
public static IMFMediaBuffer CreateMemoryBuffer(int bufferSize)
{
- IMFMediaBuffer buffer;
- MediaFoundationInterop.MFCreateMemoryBuffer(bufferSize, out buffer);
+ MediaFoundationInterop.MFCreateMemoryBuffer(bufferSize, out IMFMediaBuffer buffer);
return buffer;
}
@@ -118,8 +114,7 @@ public static IMFMediaBuffer CreateMemoryBuffer(int bufferSize)
/// The sample object
public static IMFSample CreateSample()
{
- IMFSample sample;
- MediaFoundationInterop.MFCreateSample(out sample);
+ MediaFoundationInterop.MFCreateSample(out IMFSample sample);
return sample;
}
@@ -130,8 +125,7 @@ public static IMFSample CreateSample()
/// The attributes store
public static IMFAttributes CreateAttributes(int initialSize)
{
- IMFAttributes attributes;
- MediaFoundationInterop.MFCreateAttributes(out attributes, initialSize);
+ MediaFoundationInterop.MFCreateAttributes(out IMFAttributes attributes, initialSize);
return attributes;
}
@@ -166,8 +160,7 @@ public static IMFByteStream CreateByteStream(object stream)
/// A media foundation source reader
public static IMFSourceReader CreateSourceReaderFromByteStream(IMFByteStream byteStream)
{
- IMFSourceReader reader;
- MediaFoundationInterop.MFCreateSourceReaderFromByteStream(byteStream, null, out reader);
+ MediaFoundationInterop.MFCreateSourceReaderFromByteStream(byteStream, null, out IMFSourceReader reader);
return reader;
}
}
diff --git a/NAudio/Midi/MidiEvent.cs b/NAudio/Midi/MidiEvent.cs
index 48f6e83d..01ff540e 100644
--- a/NAudio/Midi/MidiEvent.cs
+++ b/NAudio/Midi/MidiEvent.cs
@@ -1,13 +1,15 @@
using System;
using System.IO;
-using System.Text;
namespace NAudio.Midi
{
///
/// Represents an individual MIDI event
///
- public class MidiEvent : ICloneable
+ public class MidiEvent
+#if !WINDOWS_UWP
+ : ICloneable
+#endif
{
/// The MIDI command code
private MidiCommandCode commandCode;
@@ -75,8 +77,8 @@ public static MidiEvent FromRawMessage(int rawMessage)
case MidiCommandCode.AutoSensing:
me = new MidiEvent(absoluteTime,channel,commandCode);
break;
- case MidiCommandCode.MetaEvent:
- case MidiCommandCode.Sysex:
+ //case MidiCommandCode.MetaEvent:
+ //case MidiCommandCode.Sysex:
default:
throw new FormatException(String.Format("Unsupported MIDI Command Code for Raw Message {0}", commandCode));
}
@@ -92,7 +94,7 @@ public static MidiEvent FromRawMessage(int rawMessage)
/// A new MidiEvent
public static MidiEvent ReadNextEvent(BinaryReader br, MidiEvent previous)
{
- int deltaTime = MidiEvent.ReadVarInt(br);
+ int deltaTime = ReadVarInt(br);
MidiCommandCode commandCode;
int channel = 1;
byte b = br.ReadByte();
@@ -187,7 +189,7 @@ protected MidiEvent()
public MidiEvent(long absoluteTime, int channel, MidiCommandCode commandCode)
{
this.absoluteTime = absoluteTime;
- this.Channel = channel;
+ Channel = channel;
this.commandCode = commandCode;
}
@@ -196,17 +198,16 @@ public MidiEvent(long absoluteTime, int channel, MidiCommandCode commandCode)
///
public virtual MidiEvent Clone() => (MidiEvent)MemberwiseClone();
+#if !WINDOWS_UWP
object ICloneable.Clone() => Clone();
+#endif
///
/// The MIDI Channel Number for this event (1-16)
///
public virtual int Channel
{
- get
- {
- return channel;
- }
+ get => channel;
set
{
if ((value < 1) || (value > 16))
diff --git a/NAudio/Midi/MidiFile.cs b/NAudio/Midi/MidiFile.cs
index 3a8f8963..9e95b791 100644
--- a/NAudio/Midi/MidiFile.cs
+++ b/NAudio/Midi/MidiFile.cs
@@ -172,7 +172,13 @@ private MidiFile(Stream inputStream, bool strictChecking, bool ownInputStream)
finally
{
if (ownInputStream)
+ {
+#if NET35
br.Close();
+#else
+ br.Dispose();
+#endif
+ }
}
}
diff --git a/NAudio/Midi/MidiInCapabilities.cs b/NAudio/Midi/MidiInCapabilities.cs
index 1663e9e6..f982538e 100644
--- a/NAudio/Midi/MidiInCapabilities.cs
+++ b/NAudio/Midi/MidiInCapabilities.cs
@@ -8,7 +8,11 @@ namespace NAudio.Midi
///
/// MIDI In Device Capabilities
///
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ [StructLayout(LayoutKind.Sequential
+#if !WINDOWS_UWP
+ , CharSet = CharSet.Auto
+#endif
+ )]
public struct MidiInCapabilities
{
///
diff --git a/NAudio/Midi/MidiInterop.cs b/NAudio/Midi/MidiInterop.cs
index ffac8c09..408f9676 100644
--- a/NAudio/Midi/MidiInterop.cs
+++ b/NAudio/Midi/MidiInterop.cs
@@ -1,6 +1,5 @@
using System;
using System.Runtime.InteropServices;
-using NAudio.Wave;
namespace NAudio.Midi
{
@@ -73,14 +72,18 @@ public enum MidiOutMessage
// http://msdn.microsoft.com/en-us/library/dd798450%28VS.85%29.aspx
[DllImport("winmm.dll")]
- public static extern MmResult midiInAddBuffer(IntPtr hMidiIn, [MarshalAs(UnmanagedType.Struct)] ref MIDIHDR lpMidiInHdr, int uSize);
+ public static extern MmResult midiInAddBuffer(IntPtr hMidiIn, ref MIDIHDR lpMidiInHdr, int uSize);
// http://msdn.microsoft.com/en-us/library/dd798452%28VS.85%29.aspx
[DllImport("winmm.dll")]
public static extern MmResult midiInClose(IntPtr hMidiIn);
// http://msdn.microsoft.com/en-us/library/dd798453%28VS.85%29.aspx
- [DllImport("winmm.dll", CharSet = CharSet.Auto)]
+ [DllImport("winmm.dll"
+#if !WINDOWS_UWP
+ , CharSet = CharSet.Auto
+#endif
+ )]
public static extern MmResult midiInGetDevCaps(IntPtr deviceId, out MidiInCapabilities capabilities, int size);
// http://msdn.microsoft.com/en-us/library/dd798454%28VS.85%29.aspx
@@ -110,7 +113,7 @@ public enum MidiOutMessage
// http://msdn.microsoft.com/en-us/library/dd798459%28VS.85%29.aspx
[DllImport("winmm.dll")]
- public static extern MmResult midiInPrepareHeader(IntPtr hMidiIn, [MarshalAs(UnmanagedType.Struct)] ref MIDIHDR lpMidiInHdr, int uSize);
+ public static extern MmResult midiInPrepareHeader(IntPtr hMidiIn, ref MIDIHDR lpMidiInHdr, int uSize);
// http://msdn.microsoft.com/en-us/library/dd798461%28VS.85%29.aspx
[DllImport("winmm.dll")]
@@ -126,7 +129,7 @@ public enum MidiOutMessage
// http://msdn.microsoft.com/en-us/library/dd798464%28VS.85%29.aspx
[DllImport("winmm.dll")]
- public static extern MmResult midiInUnprepareHeader(IntPtr hMidiIn, [MarshalAs(UnmanagedType.Struct)] ref MIDIHDR lpMidiInHdr, int uSize);
+ public static extern MmResult midiInUnprepareHeader(IntPtr hMidiIn, ref MIDIHDR lpMidiInHdr, int uSize);
// http://msdn.microsoft.com/en-us/library/dd798465%28VS.85%29.aspx
[DllImport("winmm.dll")]
@@ -141,7 +144,11 @@ public enum MidiOutMessage
public static extern MmResult midiOutClose(IntPtr hMidiOut);
// http://msdn.microsoft.com/en-us/library/dd798469%28VS.85%29.aspx
- [DllImport("winmm.dll", CharSet = CharSet.Auto)]
+ [DllImport("winmm.dll"
+#if !WINDOWS_UWP
+ , CharSet = CharSet.Auto
+#endif
+ )]
public static extern MmResult midiOutGetDevCaps(IntPtr deviceNumber, out MidiOutCapabilities caps, int uSize);
// http://msdn.microsoft.com/en-us/library/dd798470%28VS.85%29.aspx
@@ -163,7 +170,7 @@ public enum MidiOutMessage
// http://msdn.microsoft.com/en-us/library/dd798474%28VS.85%29.aspx
[DllImport("winmm.dll")]
- public static extern MmResult midiOutLongMsg(IntPtr hMidiOut, [MarshalAs(UnmanagedType.Struct)] ref MIDIHDR lpMidiOutHdr, int uSize);
+ public static extern MmResult midiOutLongMsg(IntPtr hMidiOut, ref MIDIHDR lpMidiOutHdr, int uSize);
// http://msdn.microsoft.com/en-us/library/dd798475%28VS.85%29.aspx
[DllImport("winmm.dll")]
@@ -175,7 +182,7 @@ public enum MidiOutMessage
// http://msdn.microsoft.com/en-us/library/dd798477%28VS.85%29.aspx
[DllImport("winmm.dll")]
- public static extern MmResult midiOutPrepareHeader(IntPtr hMidiOut, [MarshalAs(UnmanagedType.Struct)] ref MIDIHDR lpMidiOutHdr, int uSize);
+ public static extern MmResult midiOutPrepareHeader(IntPtr hMidiOut, ref MIDIHDR lpMidiOutHdr, int uSize);
// http://msdn.microsoft.com/en-us/library/dd798479%28VS.85%29.aspx
[DllImport("winmm.dll")]
@@ -191,7 +198,7 @@ public enum MidiOutMessage
// http://msdn.microsoft.com/en-us/library/dd798482%28VS.85%29.aspx
[DllImport("winmm.dll")]
- public static extern MmResult midiOutUnprepareHeader(IntPtr hMidiOut, [MarshalAs(UnmanagedType.Struct)] ref MIDIHDR lpMidiOutHdr, int uSize);
+ public static extern MmResult midiOutUnprepareHeader(IntPtr hMidiOut, ref MIDIHDR lpMidiOutHdr, int uSize);
// http://msdn.microsoft.com/en-us/library/dd798485%28VS.85%29.aspx
[DllImport("winmm.dll")]
@@ -203,7 +210,7 @@ public enum MidiOutMessage
// http://msdn.microsoft.com/en-us/library/dd798487%28VS.85%29.aspx
[DllImport("winmm.dll")]
- public static extern MmResult midiStreamOut(IntPtr hMidiStream, [MarshalAs(UnmanagedType.Struct)] ref MIDIHDR pmh, int cbmh);
+ public static extern MmResult midiStreamOut(IntPtr hMidiStream, ref MIDIHDR pmh, int cbmh);
// http://msdn.microsoft.com/en-us/library/dd798488%28VS.85%29.aspx
[DllImport("winmm.dll")]
@@ -211,7 +218,7 @@ public enum MidiOutMessage
// http://msdn.microsoft.com/en-us/library/dd798489%28VS.85%29.aspx
[DllImport("winmm.dll")]
- public static extern MmResult midiStreamPosition(IntPtr hMidiStream, [MarshalAs(UnmanagedType.Struct)] ref MMTIME lpmmt, int cbmmt);
+ public static extern MmResult midiStreamPosition(IntPtr hMidiStream, ref MMTIME lpmmt, int cbmmt);
// http://msdn.microsoft.com/en-us/library/dd798490%28VS.85%29.aspx
[DllImport("winmm.dll")]
diff --git a/NAudio/Midi/MidiOutCapabilities.cs b/NAudio/Midi/MidiOutCapabilities.cs
index dda32cb4..c25db6ab 100644
--- a/NAudio/Midi/MidiOutCapabilities.cs
+++ b/NAudio/Midi/MidiOutCapabilities.cs
@@ -7,7 +7,12 @@ namespace NAudio.Midi
/// class representing the capabilities of a MIDI out device
/// MIDIOUTCAPS: http://msdn.microsoft.com/en-us/library/dd798467%28VS.85%29.aspx
///
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ [StructLayout(LayoutKind.Sequential
+#if !WINDOWS_UWP
+
+ , CharSet = CharSet.Auto
+#endif
+ )]
public struct MidiOutCapabilities
{
Int16 manufacturerId;
diff --git a/NAudio/Midi/SmpteOffsetEvent.cs b/NAudio/Midi/SmpteOffsetEvent.cs
index 22e9baba..7c4449be 100644
--- a/NAudio/Midi/SmpteOffsetEvent.cs
+++ b/NAudio/Midi/SmpteOffsetEvent.cs
@@ -1,17 +1,18 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using System.IO;
namespace NAudio.Midi
{
- class SmpteOffsetEvent : MetaEvent
+ ///
+ /// SMPTE Offset Event
+ ///
+ public class SmpteOffsetEvent : MetaEvent
{
- private byte hours;
- private byte minutes;
- private byte seconds;
- private byte frames;
- private byte subFrames; // 100ths of a frame
+ private readonly byte hours;
+ private readonly byte minutes;
+ private readonly byte seconds;
+ private readonly byte frames;
+ private readonly byte subFrames; // 100ths of a frame
///
/// Creates a new time signature event
@@ -51,44 +52,29 @@ public SmpteOffsetEvent(BinaryReader br,int length)
///
/// Hours
///
- public int Hours
- {
- get { return hours; }
- }
+ public int Hours => hours;
///
/// Minutes
///
- public int Minutes
- {
- get { return minutes; }
- }
+ public int Minutes => minutes;
///
/// Seconds
///
- public int Seconds
- {
- get { return seconds; }
- }
+ public int Seconds => seconds;
///
/// Frames
///
- public int Frames
- {
- get { return frames; }
- }
+ public int Frames => frames;
///
/// SubFrames
///
- public int SubFrames
- {
- get { return subFrames; }
- }
+ public int SubFrames => subFrames;
+
-
///
/// Describes this time signature event
///
diff --git a/NAudio/Mixer/BooleanMixerControl.cs b/NAudio/Mixer/BooleanMixerControl.cs
index 8336372d..83a6879c 100644
--- a/NAudio/Mixer/BooleanMixerControl.cs
+++ b/NAudio/Mixer/BooleanMixerControl.cs
@@ -1,6 +1,7 @@
// created on 10/12/2002 at 23:58
using System;
using System.Runtime.InteropServices;
+using NAudio.Utils;
namespace NAudio.Mixer
{
@@ -29,7 +30,7 @@ internal BooleanMixerControl(MixerInterop.MIXERCONTROL mixerControl, IntPtr mixe
/// memory pointer
protected override void GetDetails(IntPtr pDetails)
{
- boolDetails = (MixerInterop.MIXERCONTROLDETAILS_BOOLEAN) Marshal.PtrToStructure(pDetails,typeof(MixerInterop.MIXERCONTROLDETAILS_BOOLEAN));
+ boolDetails = MarshalHelpers.PtrToStructure(pDetails);
}
///
diff --git a/NAudio/Mixer/MixerControl.cs b/NAudio/Mixer/MixerControl.cs
index 1860a115..2936ae2d 100644
--- a/NAudio/Mixer/MixerControl.cs
+++ b/NAudio/Mixer/MixerControl.cs
@@ -2,6 +2,7 @@
using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
+using NAudio.Utils;
namespace NAudio.Mixer
{
@@ -41,14 +42,14 @@ public static IList GetMixerControls(IntPtr mixerHandle, MixerLine
var controls = new List();
if (mixerLine.ControlsCount > 0)
{
- int mixerControlSize = Marshal.SizeOf(typeof (MixerInterop.MIXERCONTROL));
+ int mixerControlSize = MarshalHelpers.SizeOf();
var mlc = new MixerInterop.MIXERLINECONTROLS();
IntPtr pmc = Marshal.AllocHGlobal(mixerControlSize * mixerLine.ControlsCount);
mlc.cbStruct = Marshal.SizeOf(mlc);
mlc.dwLineID = mixerLine.LineId;
mlc.cControls = mixerLine.ControlsCount;
mlc.pamxctrl = pmc;
- mlc.cbmxctrl = Marshal.SizeOf(typeof(MixerInterop.MIXERCONTROL));
+ mlc.cbmxctrl = MarshalHelpers.SizeOf();
try
{
MmResult err = MixerInterop.mixerGetLineControls(mixerHandle, ref mlc, MixerFlags.All | mixerHandleType);
@@ -60,8 +61,8 @@ public static IList GetMixerControls(IntPtr mixerHandle, MixerLine
{
Int64 address = pmc.ToInt64() + mixerControlSize * i;
- var mc = (MixerInterop.MIXERCONTROL)
- Marshal.PtrToStructure((IntPtr)address, typeof(MixerInterop.MIXERCONTROL));
+ var mc =
+ MarshalHelpers.PtrToStructure((IntPtr)address);
var mixerControl = GetMixerControl(mixerHandle, mixerLine.LineId, mc.dwControlID, mixerLine.Channels,
mixerHandleType);
@@ -81,16 +82,16 @@ public static IList GetMixerControls(IntPtr mixerHandle, MixerLine
/// Gets a specified Mixer Control
///
/// Mixer Handle
- /// Line ID
+ /// Line ID
/// Control ID
/// Number of Channels
/// Flags to use (indicates the meaning of mixerHandle)
///
- public static MixerControl GetMixerControl(IntPtr mixerHandle, int nLineID, int controlId, int nChannels,
+ public static MixerControl GetMixerControl(IntPtr mixerHandle, int nLineId, int controlId, int nChannels,
MixerFlags mixerFlags)
{
- MixerInterop.MIXERLINECONTROLS mlc = new MixerInterop.MIXERLINECONTROLS();
- MixerInterop.MIXERCONTROL mc = new MixerInterop.MIXERCONTROL();
+ var mlc = new MixerInterop.MIXERLINECONTROLS();
+ var mc = new MixerInterop.MIXERCONTROL();
// set up the pointer to a structure
IntPtr pMixerControl = Marshal.AllocCoTaskMem(Marshal.SizeOf(mc));
@@ -101,7 +102,7 @@ public static MixerControl GetMixerControl(IntPtr mixerHandle, int nLineID, int
mlc.dwControlID = controlId;
mlc.cbmxctrl = Marshal.SizeOf(mc);
mlc.pamxctrl = pMixerControl;
- mlc.dwLineID = nLineID;
+ mlc.dwLineID = nLineId;
MmResult err = MixerInterop.mixerGetLineControls(mixerHandle, ref mlc, MixerFlags.OneById | mixerFlags);
if (err != MmResult.NoError)
{
@@ -110,33 +111,35 @@ public static MixerControl GetMixerControl(IntPtr mixerHandle, int nLineID, int
}
// retrieve the structure from the pointer
- mc = (MixerInterop.MIXERCONTROL) Marshal.PtrToStructure(mlc.pamxctrl, typeof (MixerInterop.MIXERCONTROL));
+ mc = MarshalHelpers.PtrToStructure(mlc.pamxctrl);
Marshal.FreeCoTaskMem(pMixerControl);
- if (MixerControl.IsControlBoolean(mc.dwControlType))
+ if (IsControlBoolean(mc.dwControlType))
{
return new BooleanMixerControl(mc, mixerHandle, mixerFlags, nChannels);
}
- else if (MixerControl.IsControlSigned(mc.dwControlType))
+
+ if (IsControlSigned(mc.dwControlType))
{
return new SignedMixerControl(mc, mixerHandle, mixerFlags, nChannels);
}
- else if (MixerControl.IsControlUnsigned(mc.dwControlType))
+
+ if (IsControlUnsigned(mc.dwControlType))
{
return new UnsignedMixerControl(mc, mixerHandle, mixerFlags, nChannels);
}
- else if (MixerControl.IsControlListText(mc.dwControlType))
+
+ if (IsControlListText(mc.dwControlType))
{
return new ListTextMixerControl(mc, mixerHandle, mixerFlags, nChannels);
}
- else if (MixerControl.IsControlCustom(mc.dwControlType))
+
+ if (IsControlCustom(mc.dwControlType))
{
return new CustomMixerControl(mc, mixerHandle, mixerFlags, nChannels);
}
- else
- {
- throw new InvalidOperationException(String.Format("Unknown mixer control type {0}", mc.dwControlType));
- }
+
+ throw new InvalidOperationException($"Unknown mixer control type {mc.dwControlType}");
}
///
@@ -175,19 +178,19 @@ protected void GetControlDetails()
if (IsBoolean)
{
- mixerControlDetails.cbDetails = Marshal.SizeOf(new MixerInterop.MIXERCONTROLDETAILS_BOOLEAN());
+ mixerControlDetails.cbDetails = MarshalHelpers.SizeOf();
}
else if (IsListText)
{
- mixerControlDetails.cbDetails = Marshal.SizeOf(new MixerInterop.MIXERCONTROLDETAILS_LISTTEXT());
+ mixerControlDetails.cbDetails = MarshalHelpers.SizeOf();
}
else if (IsSigned)
{
- mixerControlDetails.cbDetails = Marshal.SizeOf(new MixerInterop.MIXERCONTROLDETAILS_SIGNED());
+ mixerControlDetails.cbDetails = MarshalHelpers.SizeOf();
}
else if (IsUnsigned)
{
- mixerControlDetails.cbDetails = Marshal.SizeOf(new MixerInterop.MIXERCONTROLDETAILS_UNSIGNED());
+ mixerControlDetails.cbDetails = MarshalHelpers.SizeOf();
}
else
{
@@ -227,18 +230,12 @@ protected void GetControlDetails()
///
/// Mixer control name
///
- public String Name
- {
- get { return mixerControl.szName; }
- }
+ public String Name => mixerControl.szName;
///
/// Mixer control type
///
- public MixerControlType ControlType
- {
- get { return mixerControl.dwControlType; }
- }
+ public MixerControlType ControlType => mixerControl.dwControlType;
///
/// Returns true if this is a boolean control
@@ -269,10 +266,7 @@ private static bool IsControlBoolean(MixerControlType controlType)
///
/// Is this a boolean control
///
- public bool IsBoolean
- {
- get { return MixerControl.IsControlBoolean(mixerControl.dwControlType); }
- }
+ public bool IsBoolean => IsControlBoolean(mixerControl.dwControlType);
///
/// Determines whether a specified mixer control type is a list text control
@@ -295,10 +289,7 @@ private static bool IsControlListText(MixerControlType controlType)
///
/// True if this is a list text control
///
- public bool IsListText
- {
- get { return MixerControl.IsControlListText(mixerControl.dwControlType); }
- }
+ public bool IsListText => IsControlListText(mixerControl.dwControlType);
private static bool IsControlSigned(MixerControlType controlType)
{
@@ -320,10 +311,7 @@ private static bool IsControlSigned(MixerControlType controlType)
///
/// True if this is a signed control
///
- public bool IsSigned
- {
- get { return MixerControl.IsControlSigned(mixerControl.dwControlType); }
- }
+ public bool IsSigned => IsControlSigned(mixerControl.dwControlType);
private static bool IsControlUnsigned(MixerControlType controlType)
{
@@ -348,30 +336,21 @@ private static bool IsControlUnsigned(MixerControlType controlType)
///
/// True if this is an unsigned control
///
- public bool IsUnsigned
- {
- get { return MixerControl.IsControlUnsigned(mixerControl.dwControlType); }
- }
+ public bool IsUnsigned => IsControlUnsigned(mixerControl.dwControlType);
private static bool IsControlCustom(MixerControlType controlType)
{
- return (controlType == MixerControlType.Custom);
+ return controlType == MixerControlType.Custom;
}
///
/// True if this is a custom control
///
- public bool IsCustom
- {
- get { return MixerControl.IsControlCustom(mixerControl.dwControlType); }
- }
+ public bool IsCustom => IsControlCustom(mixerControl.dwControlType);
///
/// String representation for debug purposes
///
- public override string ToString()
- {
- return String.Format("{0} {1}", Name, ControlType);
- }
+ public override string ToString() => $"{Name} {ControlType}";
}
}
diff --git a/NAudio/Mixer/MixerInterop.cs b/NAudio/Mixer/MixerInterop.cs
index dead1a00..23555465 100644
--- a/NAudio/Mixer/MixerInterop.cs
+++ b/NAudio/Mixer/MixerInterop.cs
@@ -58,7 +58,11 @@ class MixerInterop
public static extern MmResult mixerSetControlDetails(IntPtr hMixer, ref MIXERCONTROLDETAILS mixerControlDetails, MixerFlags dwDetailsFlags);
// http://msdn.microsoft.com/en-us/library/dd757294%28VS.85%29.aspx
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 1)]
+ [StructLayout(LayoutKind.Sequential,
+#if !WINDOWS_UWP
+ CharSet = CharSet.Auto,
+#endif
+ Pack = 1)]
public struct MIXERCONTROLDETAILS
{
public Int32 cbStruct; // size of the MIXERCONTROLDETAILS structure
diff --git a/NAudio/Mixer/SignedMixerControl.cs b/NAudio/Mixer/SignedMixerControl.cs
index e5f19eb0..20b40686 100644
--- a/NAudio/Mixer/SignedMixerControl.cs
+++ b/NAudio/Mixer/SignedMixerControl.cs
@@ -1,6 +1,7 @@
// created on 13/12/2002 at 22:01
using System;
using System.Runtime.InteropServices;
+using NAudio.Utils;
using NAudio.Wave;
namespace NAudio.Mixer
@@ -27,7 +28,7 @@ internal SignedMixerControl(MixerInterop.MIXERCONTROL mixerControl, IntPtr mixer
///
protected override void GetDetails(IntPtr pDetails)
{
- signedDetails = (MixerInterop.MIXERCONTROLDETAILS_SIGNED) Marshal.PtrToStructure(mixerControlDetails.paDetails,typeof(MixerInterop.MIXERCONTROLDETAILS_SIGNED));
+ signedDetails = MarshalHelpers.PtrToStructure(mixerControlDetails.paDetails);
}
///
diff --git a/NAudio/Mixer/UnsignedMixerControl.cs b/NAudio/Mixer/UnsignedMixerControl.cs
index e05506f7..5cb7ed48 100644
--- a/NAudio/Mixer/UnsignedMixerControl.cs
+++ b/NAudio/Mixer/UnsignedMixerControl.cs
@@ -1,6 +1,7 @@
// created on 13/12/2002 at 22:04
using System;
using System.Runtime.InteropServices;
+using NAudio.Utils;
using NAudio.Wave;
namespace NAudio.Mixer
@@ -30,7 +31,7 @@ protected override void GetDetails(IntPtr pDetails)
unsignedDetails = new MixerInterop.MIXERCONTROLDETAILS_UNSIGNED[nChannels];
for (int channel = 0; channel < nChannels; channel++)
{
- unsignedDetails[channel] = (MixerInterop.MIXERCONTROLDETAILS_UNSIGNED)Marshal.PtrToStructure(mixerControlDetails.paDetails, typeof(MixerInterop.MIXERCONTROLDETAILS_UNSIGNED));
+ unsignedDetails[channel] = MarshalHelpers.PtrToStructure(mixerControlDetails.paDetails);
}
}
diff --git a/NAudio/NAudio.csproj b/NAudio/NAudio.csproj
index 71581ae6..206d330d 100644
--- a/NAudio/NAudio.csproj
+++ b/NAudio/NAudio.csproj
@@ -1,592 +1,84 @@
-
-
+
+
- Debug
- AnyCPU
- 9.0.30729
- 2.0
- {DA4F02E3-0B5E-42CD-B8D9-5583FA51D66E}
- Library
- Properties
- NAudio
- NAudio
-
-
-
-
-
-
-
-
-
-
-
-
- 3.5
- v3.5
- publish\
- true
- Disk
- false
- Foreground
- 7
- Days
- false
- false
- true
- 0
- 1.0.0.%2a
- false
- false
- true
- Client
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
- true
- bin\Debug\NAudio.XML
- AnyCPU
- NAudio.ruleset
- true
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
+ netstandard2.0;net35;uap10.0.10240
+ 1.9.0
+ Mark Heath & Contributors
true
- AnyCPU
- AllRules.ruleset
- bin\Release\NAudio.XML
+ NAudio, an audio library for .NET
+ https://github.com/naudio/NAudio/blob/master/license.txt
+ https://github.com/naudio/NAudio
+ C# .NET audio sound
+ https://github.com/naudio/NAudio
+ © Mark Heath 2019
+ true
+ true
-
-
-
-
+
+
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Component
-
-
- UserControl
-
-
- UserControl
-
-
- Pot.cs
-
-
- Component
-
-
- VolumeMeter.cs
-
-
- UserControl
-
-
- Component
-
-
- WaveformPainter.cs
-
-
- UserControl
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- UserControl
-
-
- ProgressLog.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
- Fader.cs
- Designer
-
-
- PanSlider.cs
- Designer
-
-
- Pot.cs
- Designer
-
-
- VolumeSlider.cs
- Designer
-
-
- WaveViewer.cs
- Designer
-
-
- ProgressLog.cs
- Designer
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
- False
- .NET Framework 3.5 SP1 Client Profile
- false
-
-
- False
- .NET Framework 3.5 SP1
- true
-
-
- False
- Windows Installer 3.1
- true
-
+
+
+
+
+
-
-
-
+
\ No newline at end of file
diff --git a/NAudio/Properties/AssemblyInfo.cs b/NAudio/Properties/AssemblyInfo.cs
index 9408d5f4..0832b8da 100644
--- a/NAudio/Properties/AssemblyInfo.cs
+++ b/NAudio/Properties/AssemblyInfo.cs
@@ -2,35 +2,5 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("NAudio")]
-[assembly: AssemblyDescription("NAudio .NET Audio Library")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Mark Heath")]
-[assembly: AssemblyProduct("NAudio")]
-[assembly: AssemblyCopyright("© 2001-2018 Mark Heath")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
[assembly: InternalsVisibleTo("NAudioTests")]
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("e82fa7f0-f952-4d93-b7b0-392bbf53b2a4")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-[assembly: AssemblyVersion("1.8.5.0")]
-[assembly: AssemblyFileVersion("1.8.5.0")]
diff --git a/NAudio/Utils/FieldDescriptionHelper.cs b/NAudio/Utils/FieldDescriptionHelper.cs
index fc8dbd1b..14c5f00c 100644
--- a/NAudio/Utils/FieldDescriptionHelper.cs
+++ b/NAudio/Utils/FieldDescriptionHelper.cs
@@ -15,7 +15,7 @@ public static string Describe(Type t, Guid guid)
{
// when we go to .NET 3.5, use LINQ for this
foreach (var f in t
-#if NETFX_CORE
+#if NETSTANDARD1_6
.GetRuntimeFields())
#else
.GetFields(BindingFlags.Static | BindingFlags.Public))
diff --git a/NAudio/Utils/HResult.cs b/NAudio/Utils/HResult.cs
index 6fb99959..917e4d06 100644
--- a/NAudio/Utils/HResult.cs
+++ b/NAudio/Utils/HResult.cs
@@ -64,7 +64,7 @@ public static int MAKE_HRESULT(int sev, int fac, int code)
/// The HResult
public static int GetHResult(this COMException exception)
{
-#if NETFX_CORE
+#if NETSTANDARD1_6 || NETFX_CORE
return exception.HResult;
#else
return exception.ErrorCode;
diff --git a/NAudio/Utils/MarshalHelpers.cs b/NAudio/Utils/MarshalHelpers.cs
index f21e36d4..704daf94 100644
--- a/NAudio/Utils/MarshalHelpers.cs
+++ b/NAudio/Utils/MarshalHelpers.cs
@@ -13,7 +13,11 @@ public static class MarshalHelpers
///
public static int SizeOf()
{
+#if NET35
return Marshal.SizeOf(typeof (T));
+#else
+ return Marshal.SizeOf();
+#endif
}
///
@@ -21,15 +25,23 @@ public static int SizeOf()
///
public static IntPtr OffsetOf(string fieldName)
{
+#if NET35
return Marshal.OffsetOf(typeof(T), fieldName);
+#else
+ return Marshal.OffsetOf(fieldName);
+#endif
}
-
+
///
/// Pointer to Structure
///
public static T PtrToStructure(IntPtr pointer)
{
+#if NET35
return (T)Marshal.PtrToStructure(pointer, typeof(T));
+#else
+ return Marshal.PtrToStructure(pointer);
+#endif
}
}
}
diff --git a/NAudio/Wave/Asio/ASIODriver.cs b/NAudio/Wave/Asio/ASIODriver.cs
index f75373d3..abbe2cdc 100644
--- a/NAudio/Wave/Asio/ASIODriver.cs
+++ b/NAudio/Wave/Asio/ASIODriver.cs
@@ -23,6 +23,7 @@ private AsioDriver()
{
}
+#if NET35
///
/// Gets the ASIO driver names installed.
///
@@ -54,7 +55,7 @@ public static AsioDriver GetAsioDriverByName(String name)
var guid = regKey.GetValue("CLSID").ToString();
return GetAsioDriverByGuid(new Guid(guid));
}
-
+#endif
///
/// Instantiate the ASIO driver by GUID.
///
diff --git a/NAudio/Wave/Compression/AcmDriver.cs b/NAudio/Wave/Compression/AcmDriver.cs
index 5f6011b7..9a242108 100644
--- a/NAudio/Wave/Compression/AcmDriver.cs
+++ b/NAudio/Wave/Compression/AcmDriver.cs
@@ -54,8 +54,7 @@ public static AcmDriver AddLocalDriver(string driverFile)
NativeMethods.FreeLibrary(handle);
throw new ArgumentException("Failed to discover DriverProc");
}
- IntPtr driverHandle;
- var result = AcmInterop.acmDriverAdd(out driverHandle,
+ var result = AcmInterop.acmDriverAdd(out IntPtr driverHandle,
handle, driverProc, 0, AcmDriverAddFlags.Function);
if (result != MmResult.NoError)
{
@@ -155,8 +154,7 @@ public int MaxFormatSize
{
get
{
- int maxFormatSize;
- MmException.Try(AcmInterop.acmMetrics(driverHandle, AcmMetrics.MaxSizeFormat, out maxFormatSize), "acmMetrics");
+ MmException.Try(AcmInterop.acmMetrics(driverHandle, AcmMetrics.MaxSizeFormat, out int maxFormatSize), "acmMetrics");
return maxFormatSize;
}
}
diff --git a/NAudio/Wave/Compression/AcmDriverAddFlags.cs b/NAudio/Wave/Compression/AcmDriverAddFlags.cs
index 4be85229..ffcc23c1 100644
--- a/NAudio/Wave/Compression/AcmDriverAddFlags.cs
+++ b/NAudio/Wave/Compression/AcmDriverAddFlags.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace NAudio.Wave.Compression
+namespace NAudio.Wave.Compression
{
///
/// Flags for use with acmDriverAdd
diff --git a/NAudio/Wave/Compression/AcmDriverEnumFlags.cs b/NAudio/Wave/Compression/AcmDriverEnumFlags.cs
index 87761b01..3ffa12fb 100644
--- a/NAudio/Wave/Compression/AcmDriverEnumFlags.cs
+++ b/NAudio/Wave/Compression/AcmDriverEnumFlags.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
namespace NAudio.Wave.Compression
{
diff --git a/NAudio/Wave/Compression/AcmFormat.cs b/NAudio/Wave/Compression/AcmFormat.cs
index 5a9a6005..6aa61dff 100644
--- a/NAudio/Wave/Compression/AcmFormat.cs
+++ b/NAudio/Wave/Compression/AcmFormat.cs
@@ -1,9 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Runtime.InteropServices;
-
-namespace NAudio.Wave.Compression
+namespace NAudio.Wave.Compression
{
///
/// ACM Format
@@ -11,63 +6,41 @@ namespace NAudio.Wave.Compression
public class AcmFormat
{
private readonly AcmFormatDetails formatDetails;
- private readonly WaveFormat waveFormat;
internal AcmFormat(AcmFormatDetails formatDetails)
{
this.formatDetails = formatDetails;
- waveFormat = WaveFormat.MarshalFromPtr(formatDetails.waveFormatPointer);
+ WaveFormat = WaveFormat.MarshalFromPtr(formatDetails.waveFormatPointer);
}
///
/// Format Index
///
- public int FormatIndex
- {
- get { return formatDetails.formatIndex; }
- }
+ public int FormatIndex => formatDetails.formatIndex;
///
/// Format Tag
///
- public WaveFormatEncoding FormatTag
- {
- get { return (WaveFormatEncoding)formatDetails.formatTag; }
- }
+ public WaveFormatEncoding FormatTag => (WaveFormatEncoding)formatDetails.formatTag;
///
/// Support Flags
///
- public AcmDriverDetailsSupportFlags SupportFlags
- {
- get { return formatDetails.supportFlags; }
- }
+ public AcmDriverDetailsSupportFlags SupportFlags => formatDetails.supportFlags;
///
/// WaveFormat
///
- public WaveFormat WaveFormat
- {
- get
- {
- return waveFormat;
- }
- }
+ public WaveFormat WaveFormat { get; private set; }
///
/// WaveFormat Size
///
- public int WaveFormatByteSize
- {
- get { return formatDetails.waveFormatByteSize; }
- }
+ public int WaveFormatByteSize => formatDetails.waveFormatByteSize;
///
/// Format Description
///
- public string FormatDescription
- {
- get { return formatDetails.formatDescription; }
- }
+ public string FormatDescription => formatDetails.formatDescription;
}
}
diff --git a/NAudio/Wave/Compression/AcmFormatChoose.cs b/NAudio/Wave/Compression/AcmFormatChoose.cs
index 5f014a0b..de6b7580 100644
--- a/NAudio/Wave/Compression/AcmFormatChoose.cs
+++ b/NAudio/Wave/Compression/AcmFormatChoose.cs
@@ -9,7 +9,11 @@ namespace NAudio.Wave.Compression
/// ACMFORMATCHOOSE
/// http://msdn.microsoft.com/en-us/library/dd742911%28VS.85%29.aspx
///
- [StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Auto)]
+ [StructLayout(LayoutKind.Sequential, Pack = 4
+#if NET35
+ , CharSet = CharSet.Auto
+#endif
+ )]
struct AcmFormatChoose
{
///
diff --git a/NAudio/Wave/Compression/AcmFormatChooseStyleFlags.cs b/NAudio/Wave/Compression/AcmFormatChooseStyleFlags.cs
index 899309bd..389414dc 100644
--- a/NAudio/Wave/Compression/AcmFormatChooseStyleFlags.cs
+++ b/NAudio/Wave/Compression/AcmFormatChooseStyleFlags.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
namespace NAudio.Wave.Compression
{
diff --git a/NAudio/Wave/Compression/AcmFormatDetails.cs b/NAudio/Wave/Compression/AcmFormatDetails.cs
index 085419cc..d80f0ff3 100644
--- a/NAudio/Wave/Compression/AcmFormatDetails.cs
+++ b/NAudio/Wave/Compression/AcmFormatDetails.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.Wave.Compression
diff --git a/NAudio/Wave/Compression/AcmFormatEnumFlags.cs b/NAudio/Wave/Compression/AcmFormatEnumFlags.cs
index 71719c80..72788f67 100644
--- a/NAudio/Wave/Compression/AcmFormatEnumFlags.cs
+++ b/NAudio/Wave/Compression/AcmFormatEnumFlags.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
namespace NAudio.Wave.Compression
{
diff --git a/NAudio/Wave/Compression/AcmFormatSuggestFlags.cs b/NAudio/Wave/Compression/AcmFormatSuggestFlags.cs
index 680f8ee9..6eb47788 100644
--- a/NAudio/Wave/Compression/AcmFormatSuggestFlags.cs
+++ b/NAudio/Wave/Compression/AcmFormatSuggestFlags.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
namespace NAudio.Wave.Compression
{
diff --git a/NAudio/Wave/Compression/AcmFormatTag.cs b/NAudio/Wave/Compression/AcmFormatTag.cs
index df239d61..3a0c55e3 100644
--- a/NAudio/Wave/Compression/AcmFormatTag.cs
+++ b/NAudio/Wave/Compression/AcmFormatTag.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace NAudio.Wave.Compression
+namespace NAudio.Wave.Compression
{
///
/// ACM Format Tag
@@ -13,7 +9,7 @@ public class AcmFormatTag
internal AcmFormatTag(AcmFormatTagDetails formatTagDetails)
{
- this.formatTagDetails = formatTagDetails;
+ this.formatTagDetails = formatTagDetails;
}
///
diff --git a/NAudio/Wave/Compression/AcmFormatTagDetails.cs b/NAudio/Wave/Compression/AcmFormatTagDetails.cs
index d205a8ae..b3feb806 100644
--- a/NAudio/Wave/Compression/AcmFormatTagDetails.cs
+++ b/NAudio/Wave/Compression/AcmFormatTagDetails.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Runtime.InteropServices;
+using System.Runtime.InteropServices;
namespace NAudio.Wave.Compression
{
diff --git a/NAudio/Wave/Compression/AcmInterop.cs b/NAudio/Wave/Compression/AcmInterop.cs
index 18c9f45a..a2ddcba3 100644
--- a/NAudio/Wave/Compression/AcmInterop.cs
+++ b/NAudio/Wave/Compression/AcmInterop.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections;
using System.Runtime.InteropServices;
namespace NAudio.Wave.Compression
@@ -84,7 +83,8 @@ public static extern MmResult acmDriverRemove(IntPtr driverHandle,
// http://msdn.microsoft.com/en-us/library/dd742914%28VS.85%29.aspx
[DllImport("Msacm32.dll")]
public static extern MmResult acmFormatEnum(IntPtr hAcmDriver, ref AcmFormatDetails formatDetails, AcmFormatEnumCallback callback, IntPtr instance, AcmFormatEnumFlags flags);
-
+
+#if NET35
///
/// http://msdn.microsoft.com/en-us/library/dd742916%28VS.85%29.aspx
/// MMRESULT acmFormatSuggest(
@@ -103,6 +103,7 @@ public static extern MmResult acmFormatSuggest(
WaveFormat destFormat,
int sizeDestFormat,
AcmFormatSuggestFlags suggestFlags);
+#endif
[DllImport("Msacm32.dll",EntryPoint="acmFormatSuggest")]
public static extern MmResult acmFormatSuggest2(
@@ -120,7 +121,8 @@ public static extern MmResult acmFormatSuggest2(
// this version of the prototype is for metrics that output a single integer
[DllImport("Msacm32.dll")]
public static extern MmResult acmMetrics(IntPtr hAcmObject, AcmMetrics metric, out int output);
-
+
+#if NET35
///
/// http://msdn.microsoft.com/en-us/library/dd742928%28VS.85%29.aspx
/// MMRESULT acmStreamOpen(
@@ -145,6 +147,7 @@ public static extern MmResult acmStreamOpen(
IntPtr callback,
IntPtr instance,
AcmStreamOpenFlags openFlags);
+#endif
///
/// A version with pointers for troubleshooting
diff --git a/NAudio/Wave/Compression/AcmMetrics.cs b/NAudio/Wave/Compression/AcmMetrics.cs
index 08d8d5d1..c3567ec5 100644
--- a/NAudio/Wave/Compression/AcmMetrics.cs
+++ b/NAudio/Wave/Compression/AcmMetrics.cs
@@ -1,7 +1,3 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
namespace NAudio.Wave
{
enum AcmMetrics
diff --git a/NAudio/Wave/Compression/AcmStream.cs b/NAudio/Wave/Compression/AcmStream.cs
index a796b05f..2540176a 100644
--- a/NAudio/Wave/Compression/AcmStream.cs
+++ b/NAudio/Wave/Compression/AcmStream.cs
@@ -28,7 +28,19 @@ public AcmStream(WaveFormat sourceFormat, WaveFormat destFormat)
this.sourceFormat = sourceFormat;
int sourceBufferSize = Math.Max(65536, sourceFormat.AverageBytesPerSecond);
sourceBufferSize -= (sourceBufferSize % sourceFormat.BlockAlign);
- MmException.Try(AcmInterop.acmStreamOpen(out streamHandle, IntPtr.Zero, sourceFormat, destFormat, null, IntPtr.Zero, IntPtr.Zero, AcmStreamOpenFlags.NonRealTime), "acmStreamOpen");
+ IntPtr sourceFormatPointer = WaveFormat.MarshalToPtr(sourceFormat);
+ IntPtr destFormatPointer = WaveFormat.MarshalToPtr(destFormat);
+
+ try
+ {
+ MmException.Try(AcmInterop.acmStreamOpen2(out streamHandle, IntPtr.Zero, sourceFormatPointer, destFormatPointer, null, IntPtr.Zero, IntPtr.Zero, AcmStreamOpenFlags.NonRealTime), "acmStreamOpen");
+ }
+ finally
+ {
+ Marshal.FreeHGlobal(sourceFormatPointer);
+ Marshal.FreeHGlobal(destFormatPointer);
+
+ }
int destBufferSize = SourceToDest(sourceBufferSize);
streamHeader = new AcmStreamHeader(streamHandle, sourceBufferSize, destBufferSize);
@@ -44,7 +56,7 @@ public AcmStream(WaveFormat sourceFormat, WaveFormat destFormat)
///
/// Creates a new ACM stream to convert one format to another, using a
- /// specified driver identified and wave filter
+ /// specified driver identifier and wave filter
///
/// the driver identifier
/// the source format
@@ -55,8 +67,17 @@ public AcmStream(IntPtr driverId, WaveFormat sourceFormat, WaveFilter waveFilter
this.sourceFormat = sourceFormat;
sourceBufferSize -= (sourceBufferSize % sourceFormat.BlockAlign);
MmException.Try(AcmInterop.acmDriverOpen(out driverHandle, driverId, 0), "acmDriverOpen");
- MmException.Try(AcmInterop.acmStreamOpen(out streamHandle, driverHandle,
- sourceFormat, sourceFormat, waveFilter, IntPtr.Zero, IntPtr.Zero, AcmStreamOpenFlags.NonRealTime), "acmStreamOpen");
+
+ IntPtr sourceFormatPointer = WaveFormat.MarshalToPtr(sourceFormat);
+ try
+ {
+ MmException.Try(AcmInterop.acmStreamOpen2(out streamHandle, driverHandle,
+ sourceFormatPointer, sourceFormatPointer, waveFilter, IntPtr.Zero, IntPtr.Zero, AcmStreamOpenFlags.NonRealTime), "acmStreamOpen");
+ }
+ finally
+ {
+ Marshal.FreeHGlobal(sourceFormatPointer);
+ }
streamHeader = new AcmStreamHeader(streamHandle, sourceBufferSize, SourceToDest(sourceBufferSize));
}
@@ -100,17 +121,23 @@ public static WaveFormat SuggestPcmFormat(WaveFormat compressedFormat)
{
// create a PCM format
WaveFormat suggestedFormat = new WaveFormat(compressedFormat.SampleRate, 16, compressedFormat.Channels);
- MmException.Try(AcmInterop.acmFormatSuggest(IntPtr.Zero, compressedFormat, suggestedFormat, Marshal.SizeOf(suggestedFormat), AcmFormatSuggestFlags.FormatTag), "acmFormatSuggest");
+ //MmException.Try(AcmInterop.acmFormatSuggest(IntPtr.Zero, compressedFormat, suggestedFormat, Marshal.SizeOf(suggestedFormat), AcmFormatSuggestFlags.FormatTag), "acmFormatSuggest");
- /*IntPtr suggestedFormatPointer = WaveFormat.MarshalToPtr(suggestedFormat);
- IntPtr compressedFormatPointer = WaveFormat.MarshalToPtr(compressedFormat);
- MmResult result = AcmInterop.acmFormatSuggest2(IntPtr.Zero, compressedFormatPointer, suggestedFormatPointer, Marshal.SizeOf(suggestedFormat), AcmFormatSuggestFlags.FormatTag);
- suggestedFormat = WaveFormat.MarshalFromPtr(suggestedFormatPointer);
- Marshal.FreeHGlobal(suggestedFormatPointer);
- Marshal.FreeHGlobal(compressedFormatPointer);
- MmException.Try(result, "acmFormatSuggest");*/
-
+ IntPtr suggestedFormatPointer = WaveFormat.MarshalToPtr(suggestedFormat);
+ IntPtr compressedFormatPointer = WaveFormat.MarshalToPtr(compressedFormat);
+ try
+ {
+ MmResult result = AcmInterop.acmFormatSuggest2(IntPtr.Zero, compressedFormatPointer,
+ suggestedFormatPointer, Marshal.SizeOf(suggestedFormat), AcmFormatSuggestFlags.FormatTag);
+ suggestedFormat = WaveFormat.MarshalFromPtr(suggestedFormatPointer);
+ MmException.Try(result, "acmFormatSuggest");
+ }
+ finally
+ {
+ Marshal.FreeHGlobal(suggestedFormatPointer);
+ Marshal.FreeHGlobal(compressedFormatPointer);
+ }
return suggestedFormat;
}
diff --git a/NAudio/Wave/Compression/AcmStreamConvertFlags.cs b/NAudio/Wave/Compression/AcmStreamConvertFlags.cs
index f11208ac..bced297a 100644
--- a/NAudio/Wave/Compression/AcmStreamConvertFlags.cs
+++ b/NAudio/Wave/Compression/AcmStreamConvertFlags.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
namespace NAudio.Wave
{
diff --git a/NAudio/Wave/Compression/AcmStreamHeader.cs b/NAudio/Wave/Compression/AcmStreamHeader.cs
index 497bfb8f..15977c4e 100644
--- a/NAudio/Wave/Compression/AcmStreamHeader.cs
+++ b/NAudio/Wave/Compression/AcmStreamHeader.cs
@@ -6,9 +6,7 @@ namespace NAudio.Wave.Compression
class AcmStreamHeader : IDisposable
{
private AcmStreamHeaderStruct streamHeader;
- private byte[] sourceBuffer;
private GCHandle hSourceBuffer;
- private byte[] destBuffer;
private GCHandle hDestBuffer;
private IntPtr streamHandle;
private bool firstTime;
@@ -16,11 +14,11 @@ class AcmStreamHeader : IDisposable
public AcmStreamHeader(IntPtr streamHandle, int sourceBufferLength, int destBufferLength)
{
streamHeader = new AcmStreamHeaderStruct();
- sourceBuffer = new byte[sourceBufferLength];
- hSourceBuffer = GCHandle.Alloc(sourceBuffer, GCHandleType.Pinned);
+ SourceBuffer = new byte[sourceBufferLength];
+ hSourceBuffer = GCHandle.Alloc(SourceBuffer, GCHandleType.Pinned);
- destBuffer = new byte[destBufferLength];
- hDestBuffer = GCHandle.Alloc(destBuffer, GCHandleType.Pinned);
+ DestBuffer = new byte[destBufferLength];
+ hDestBuffer = GCHandle.Alloc(DestBuffer, GCHandleType.Pinned);
this.streamHandle = streamHandle;
firstTime = true;
@@ -30,18 +28,18 @@ public AcmStreamHeader(IntPtr streamHandle, int sourceBufferLength, int destBuff
private void Prepare()
{
streamHeader.cbStruct = Marshal.SizeOf(streamHeader);
- streamHeader.sourceBufferLength = sourceBuffer.Length;
+ streamHeader.sourceBufferLength = SourceBuffer.Length;
streamHeader.sourceBufferPointer = hSourceBuffer.AddrOfPinnedObject();
- streamHeader.destBufferLength = destBuffer.Length;
+ streamHeader.destBufferLength = DestBuffer.Length;
streamHeader.destBufferPointer = hDestBuffer.AddrOfPinnedObject();
MmException.Try(AcmInterop.acmStreamPrepareHeader(streamHandle, streamHeader, 0), "acmStreamPrepareHeader");
}
private void Unprepare()
{
- streamHeader.sourceBufferLength = sourceBuffer.Length;
+ streamHeader.sourceBufferLength = SourceBuffer.Length;
streamHeader.sourceBufferPointer = hSourceBuffer.AddrOfPinnedObject();
- streamHeader.destBufferLength = destBuffer.Length;
+ streamHeader.destBufferLength = DestBuffer.Length;
streamHeader.destBufferPointer = hDestBuffer.AddrOfPinnedObject();
MmResult result = AcmInterop.acmStreamUnprepareHeader(streamHandle, streamHeader, 0);
@@ -67,7 +65,7 @@ public int Convert(int bytesToConvert, out int sourceBytesConverted)
AcmStreamConvertFlags flags = firstTime ? (AcmStreamConvertFlags.Start | AcmStreamConvertFlags.BlockAlign) : AcmStreamConvertFlags.BlockAlign;
MmException.Try(AcmInterop.acmStreamConvert(streamHandle, streamHeader, flags), "acmStreamConvert");
firstTime = false;
- System.Diagnostics.Debug.Assert(streamHeader.destBufferLength == destBuffer.Length, "Codecs should not change dest buffer length");
+ System.Diagnostics.Debug.Assert(streamHeader.destBufferLength == DestBuffer.Length, "Codecs should not change dest buffer length");
sourceBytesConverted = streamHeader.sourceBufferLengthUsed;
}
finally
@@ -78,21 +76,9 @@ public int Convert(int bytesToConvert, out int sourceBytesConverted)
return streamHeader.destBufferLengthUsed;
}
- public byte[] SourceBuffer
- {
- get
- {
- return sourceBuffer;
- }
- }
+ public byte[] SourceBuffer { get; private set; }
- public byte[] DestBuffer
- {
- get
- {
- return destBuffer;
- }
- }
+ public byte[] DestBuffer { get; private set; }
#region IDisposable Members
@@ -109,8 +95,8 @@ protected virtual void Dispose(bool disposing)
if (!disposed)
{
//Unprepare();
- sourceBuffer = null;
- destBuffer = null;
+ SourceBuffer = null;
+ DestBuffer = null;
hSourceBuffer.Free();
hDestBuffer.Free();
}
diff --git a/NAudio/Wave/Compression/AcmStreamHeaderStatusFlags.cs b/NAudio/Wave/Compression/AcmStreamHeaderStatusFlags.cs
index e2fd8f51..b04acbd5 100644
--- a/NAudio/Wave/Compression/AcmStreamHeaderStatusFlags.cs
+++ b/NAudio/Wave/Compression/AcmStreamHeaderStatusFlags.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
namespace NAudio.Wave.Compression
{
diff --git a/NAudio/Wave/Compression/AcmStreamHeaderStruct.cs b/NAudio/Wave/Compression/AcmStreamHeaderStruct.cs
index 99645097..80b2373f 100644
--- a/NAudio/Wave/Compression/AcmStreamHeaderStruct.cs
+++ b/NAudio/Wave/Compression/AcmStreamHeaderStruct.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace NAudio.Wave.Compression
diff --git a/NAudio/Wave/Compression/AcmStreamOpenFlags.cs b/NAudio/Wave/Compression/AcmStreamOpenFlags.cs
index a48343bb..1fb3ab1e 100644
--- a/NAudio/Wave/Compression/AcmStreamOpenFlags.cs
+++ b/NAudio/Wave/Compression/AcmStreamOpenFlags.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
namespace NAudio.Wave.Compression
{
diff --git a/NAudio/Wave/Compression/AcmStreamSizeFlags.cs b/NAudio/Wave/Compression/AcmStreamSizeFlags.cs
index b18dbbfe..c9149629 100644
--- a/NAudio/Wave/Compression/AcmStreamSizeFlags.cs
+++ b/NAudio/Wave/Compression/AcmStreamSizeFlags.cs
@@ -1,7 +1,3 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
namespace NAudio.Wave.Compression
{
enum AcmStreamSizeFlags
diff --git a/NAudio/Wave/Compression/WaveFilter.cs b/NAudio/Wave/Compression/WaveFilter.cs
index ec99389d..c0baff2e 100644
--- a/NAudio/Wave/Compression/WaveFilter.cs
+++ b/NAudio/Wave/Compression/WaveFilter.cs
@@ -1,12 +1,11 @@
-using System;
using System.Runtime.InteropServices;
namespace NAudio.Wave.Compression
{
- ///
- /// Summary description for WaveFilter.
- ///
- [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
+ ///
+ /// Summary description for WaveFilter.
+ ///
+ [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
public class WaveFilter
{
///
diff --git a/NAudio/Wave/MmeInterop/WaveCallbackInfo.cs b/NAudio/Wave/MmeInterop/WaveCallbackInfo.cs
index fb713e7b..1fcb4316 100644
--- a/NAudio/Wave/MmeInterop/WaveCallbackInfo.cs
+++ b/NAudio/Wave/MmeInterop/WaveCallbackInfo.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
namespace NAudio.Wave
{
diff --git a/NAudio/Wave/MmeInterop/WaveCallbackStrategy.cs b/NAudio/Wave/MmeInterop/WaveCallbackStrategy.cs
index 0a2b3a83..fdd35ae6 100644
--- a/NAudio/Wave/MmeInterop/WaveCallbackStrategy.cs
+++ b/NAudio/Wave/MmeInterop/WaveCallbackStrategy.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace NAudio.Wave
+namespace NAudio.Wave
{
///
/// Wave Callback Strategy
diff --git a/NAudio/Wave/MmeInterop/WaveInCapabilities.cs b/NAudio/Wave/MmeInterop/WaveInCapabilities.cs
index 7312c32a..6ee5706e 100644
--- a/NAudio/Wave/MmeInterop/WaveInCapabilities.cs
+++ b/NAudio/Wave/MmeInterop/WaveInCapabilities.cs
@@ -8,7 +8,11 @@ namespace NAudio.Wave
/// WaveInCapabilities structure (based on WAVEINCAPS2 from mmsystem.h)
/// http://msdn.microsoft.com/en-us/library/ms713726(VS.85).aspx
///
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ [StructLayout(LayoutKind.Sequential
+#if !WINDOWS_UWP
+ , CharSet = CharSet.Auto
+#endif
+ )]
public struct WaveInCapabilities
{
///
@@ -101,7 +105,7 @@ internal static class WaveCapabilitiesHelpers
public static readonly Guid MicrosoftDefaultManufacturerId = new Guid("d5a47fa8-6d98-11d1-a21a-00a0c9223196");
public static readonly Guid DefaultWaveOutGuid = new Guid("E36DC310-6D9A-11D1-A21A-00A0C9223196");
public static readonly Guid DefaultWaveInGuid = new Guid("E36DC311-6D9A-11D1-A21A-00A0C9223196");
-
+#if NET35
///
/// The device name from the registry if supported
///
@@ -117,5 +121,6 @@ public static string GetNameFromGuid(Guid guid)
}
return name;
}
+#endif
}
}
diff --git a/NAudio/Wave/MmeInterop/WaveInterop.cs b/NAudio/Wave/MmeInterop/WaveInterop.cs
index f8584839..c758c1a9 100644
--- a/NAudio/Wave/MmeInterop/WaveInterop.cs
+++ b/NAudio/Wave/MmeInterop/WaveInterop.cs
@@ -109,7 +109,7 @@ public enum WaveMessage
// http://msdn.microsoft.com/en-us/library/dd743863%28VS.85%29.aspx
[DllImport("winmm.dll")]
- public static extern MmResult waveOutGetPosition(IntPtr hWaveOut, out MmTime mmTime, int uSize);
+ public static extern MmResult waveOutGetPosition(IntPtr hWaveOut, ref MmTime mmTime, int uSize);
// http://msdn.microsoft.com/en-us/library/dd743874%28VS.85%29.aspx
[DllImport("winmm.dll")]
@@ -119,14 +119,22 @@ public enum WaveMessage
public static extern MmResult waveOutGetVolume(IntPtr hWaveOut, out int dwVolume);
// http://msdn.microsoft.com/en-us/library/dd743857%28VS.85%29.aspx
- [DllImport("winmm.dll", CharSet = CharSet.Auto)]
+ [DllImport("winmm.dll"
+#if !WINDOWS_UWP
+ , CharSet = CharSet.Auto
+#endif
+ )]
public static extern MmResult waveOutGetDevCaps(IntPtr deviceID, out WaveOutCapabilities waveOutCaps, int waveOutCapsSize);
[DllImport("winmm.dll")]
public static extern Int32 waveInGetNumDevs();
// http://msdn.microsoft.com/en-us/library/dd743841%28VS.85%29.aspx
- [DllImport("winmm.dll", CharSet = CharSet.Auto)]
+ [DllImport("winmm.dll"
+#if !WINDOWS_UWP
+ , CharSet = CharSet.Auto
+#endif
+ )]
public static extern MmResult waveInGetDevCaps(IntPtr deviceID, out WaveInCapabilities waveInCaps, int waveInCapsSize);
// http://msdn.microsoft.com/en-us/library/dd743838%28VS.85%29.aspx
diff --git a/NAudio/Wave/MmeInterop/WaveOutCapabilities.cs b/NAudio/Wave/MmeInterop/WaveOutCapabilities.cs
index 70b2f30c..046b1ad5 100644
--- a/NAudio/Wave/MmeInterop/WaveOutCapabilities.cs
+++ b/NAudio/Wave/MmeInterop/WaveOutCapabilities.cs
@@ -7,7 +7,11 @@ namespace NAudio.Wave
/// WaveOutCapabilities structure (based on WAVEOUTCAPS2 from mmsystem.h)
/// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_waveoutcaps_str.asp
///
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ [StructLayout(LayoutKind.Sequential
+#if !WINDOWS_UWP
+ , CharSet = CharSet.Auto
+#endif
+ )]
public struct WaveOutCapabilities
{
///
diff --git a/NAudio/Wave/MmeInterop/WaveWindow.cs b/NAudio/Wave/MmeInterop/WaveWindow.cs
index 76669492..1ee852c1 100644
--- a/NAudio/Wave/MmeInterop/WaveWindow.cs
+++ b/NAudio/Wave/MmeInterop/WaveWindow.cs
@@ -1,12 +1,10 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace NAudio.Wave
{
- class WaveWindowNative : System.Windows.Forms.NativeWindow
+ class WaveWindowNative : NativeWindow
{
private WaveInterop.WaveCallback waveCallback;
@@ -15,7 +13,7 @@ public WaveWindowNative(WaveInterop.WaveCallback waveCallback)
this.waveCallback = waveCallback;
}
- protected override void WndProc(ref System.Windows.Forms.Message m)
+ protected override void WndProc(ref Message m)
{
WaveInterop.WaveMessage message = (WaveInterop.WaveMessage)m.Msg;
@@ -50,7 +48,7 @@ public WaveWindow(WaveInterop.WaveCallback waveCallback)
this.waveCallback = waveCallback;
}
- protected override void WndProc(ref System.Windows.Forms.Message m)
+ protected override void WndProc(ref Message m)
{
WaveInterop.WaveMessage message = (WaveInterop.WaveMessage)m.Msg;
diff --git a/NAudio/Wave/SampleChunkConverters/ISampleChunkConverter.cs b/NAudio/Wave/SampleChunkConverters/ISampleChunkConverter.cs
index a8d03140..486f1b53 100644
--- a/NAudio/Wave/SampleChunkConverters/ISampleChunkConverter.cs
+++ b/NAudio/Wave/SampleChunkConverters/ISampleChunkConverter.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace NAudio.Wave.SampleProviders
+namespace NAudio.Wave.SampleProviders
{
///
/// Sample provider interface to make WaveChannel32 extensible
diff --git a/NAudio/Wave/SampleChunkConverters/Mono16SampleChunkConverter.cs b/NAudio/Wave/SampleChunkConverters/Mono16SampleChunkConverter.cs
index 6a21bb40..8a35aac2 100644
--- a/NAudio/Wave/SampleChunkConverters/Mono16SampleChunkConverter.cs
+++ b/NAudio/Wave/SampleChunkConverters/Mono16SampleChunkConverter.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using NAudio.Utils;
+using NAudio.Utils;
namespace NAudio.Wave.SampleProviders
{
diff --git a/NAudio/Wave/SampleChunkConverters/Mono24SampleChunkConverter.cs b/NAudio/Wave/SampleChunkConverters/Mono24SampleChunkConverter.cs
index 43ad8ba4..65461488 100644
--- a/NAudio/Wave/SampleChunkConverters/Mono24SampleChunkConverter.cs
+++ b/NAudio/Wave/SampleChunkConverters/Mono24SampleChunkConverter.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using NAudio.Utils;
+using NAudio.Utils;
namespace NAudio.Wave.SampleProviders
{
diff --git a/NAudio/Wave/SampleChunkConverters/Mono8SampleChunkConverter.cs b/NAudio/Wave/SampleChunkConverters/Mono8SampleChunkConverter.cs
index 06cb391c..9af65b02 100644
--- a/NAudio/Wave/SampleChunkConverters/Mono8SampleChunkConverter.cs
+++ b/NAudio/Wave/SampleChunkConverters/Mono8SampleChunkConverter.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using NAudio.Utils;
+using NAudio.Utils;
namespace NAudio.Wave.SampleProviders
{
diff --git a/NAudio/Wave/SampleChunkConverters/MonoFloatSampleChunkConverter.cs b/NAudio/Wave/SampleChunkConverters/MonoFloatSampleChunkConverter.cs
index 896d3239..e6c11941 100644
--- a/NAudio/Wave/SampleChunkConverters/MonoFloatSampleChunkConverter.cs
+++ b/NAudio/Wave/SampleChunkConverters/MonoFloatSampleChunkConverter.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using NAudio.Utils;
+using NAudio.Utils;
namespace NAudio.Wave.SampleProviders
{
diff --git a/NAudio/Wave/SampleChunkConverters/Stereo16SampleChunkConverter.cs b/NAudio/Wave/SampleChunkConverters/Stereo16SampleChunkConverter.cs
index fba53816..4111692b 100644
--- a/NAudio/Wave/SampleChunkConverters/Stereo16SampleChunkConverter.cs
+++ b/NAudio/Wave/SampleChunkConverters/Stereo16SampleChunkConverter.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using NAudio.Utils;
+using NAudio.Utils;
namespace NAudio.Wave.SampleProviders
{
diff --git a/NAudio/Wave/SampleChunkConverters/Stereo24SampleChunkConverter.cs b/NAudio/Wave/SampleChunkConverters/Stereo24SampleChunkConverter.cs
index b1573f2f..a832fe1e 100644
--- a/NAudio/Wave/SampleChunkConverters/Stereo24SampleChunkConverter.cs
+++ b/NAudio/Wave/SampleChunkConverters/Stereo24SampleChunkConverter.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using NAudio.Utils;
+using NAudio.Utils;
namespace NAudio.Wave.SampleProviders
{
diff --git a/NAudio/Wave/SampleChunkConverters/Stereo8SampleChunkConverter.cs b/NAudio/Wave/SampleChunkConverters/Stereo8SampleChunkConverter.cs
index 4d702c9c..398eccd0 100644
--- a/NAudio/Wave/SampleChunkConverters/Stereo8SampleChunkConverter.cs
+++ b/NAudio/Wave/SampleChunkConverters/Stereo8SampleChunkConverter.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using NAudio.Utils;
+using NAudio.Utils;
namespace NAudio.Wave.SampleProviders
{
diff --git a/NAudio/Wave/SampleChunkConverters/StereoFloatSampleChunkConverter.cs b/NAudio/Wave/SampleChunkConverters/StereoFloatSampleChunkConverter.cs
index 47e9410b..db42a126 100644
--- a/NAudio/Wave/SampleChunkConverters/StereoFloatSampleChunkConverter.cs
+++ b/NAudio/Wave/SampleChunkConverters/StereoFloatSampleChunkConverter.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using NAudio.Utils;
+using NAudio.Utils;
namespace NAudio.Wave.SampleProviders
{
diff --git a/NAudio/Wave/SampleProviders/AdsrSampleProvider.cs b/NAudio/Wave/SampleProviders/AdsrSampleProvider.cs
index 805f6d49..4a2a635f 100644
--- a/NAudio/Wave/SampleProviders/AdsrSampleProvider.cs
+++ b/NAudio/Wave/SampleProviders/AdsrSampleProvider.cs
@@ -1,5 +1,4 @@
using System;
-using System.Linq;
using NAudio.Dsp;
namespace NAudio.Wave.SampleProviders
diff --git a/NAudio/Wave/SampleProviders/Pcm24BitToSampleProvider.cs b/NAudio/Wave/SampleProviders/Pcm24BitToSampleProvider.cs
index 7a04671a..f348cd13 100644
--- a/NAudio/Wave/SampleProviders/Pcm24BitToSampleProvider.cs
+++ b/NAudio/Wave/SampleProviders/Pcm24BitToSampleProvider.cs
@@ -1,6 +1,4 @@
-using System;
-
-namespace NAudio.Wave.SampleProviders
+namespace NAudio.Wave.SampleProviders
{
///
/// Converts an IWaveProvider containing 24 bit PCM to an
diff --git a/NAudio/Wave/SampleProviders/Pcm8BitToSampleProvider.cs b/NAudio/Wave/SampleProviders/Pcm8BitToSampleProvider.cs
index 6870d2d7..75719ec3 100644
--- a/NAudio/Wave/SampleProviders/Pcm8BitToSampleProvider.cs
+++ b/NAudio/Wave/SampleProviders/Pcm8BitToSampleProvider.cs
@@ -1,6 +1,4 @@
-using System;
-
-namespace NAudio.Wave.SampleProviders
+namespace NAudio.Wave.SampleProviders
{
///
/// Converts an IWaveProvider containing 8 bit PCM to an
diff --git a/NAudio/Wave/SampleProviders/SampleProviderConverterBase.cs b/NAudio/Wave/SampleProviders/SampleProviderConverterBase.cs
index df2265db..05f7ecde 100644
--- a/NAudio/Wave/SampleProviders/SampleProviderConverterBase.cs
+++ b/NAudio/Wave/SampleProviders/SampleProviderConverterBase.cs
@@ -1,5 +1,4 @@
-using System;
-using NAudio.Utils;
+using NAudio.Utils;
namespace NAudio.Wave.SampleProviders
{
diff --git a/NAudio/Wave/WaveExtensionMethods.cs b/NAudio/Wave/WaveExtensionMethods.cs
index fd086d67..4d3be419 100644
--- a/NAudio/Wave/WaveExtensionMethods.cs
+++ b/NAudio/Wave/WaveExtensionMethods.cs
@@ -18,6 +18,7 @@ public static ISampleProvider ToSampleProvider(this IWaveProvider waveProvider)
return SampleProviderConverters.ConvertWaveProviderIntoSampleProvider(waveProvider);
}
+#if !WINDOWS_UWP
///
/// Allows sending a SampleProvider directly to an IWavePlayer without needing to convert
/// back to an IWaveProvider
@@ -30,6 +31,7 @@ public static void Init(this IWavePlayer wavePlayer, ISampleProvider sampleProvi
IWaveProvider provider = convertTo16Bit ? (IWaveProvider)new SampleToWaveProvider16(sampleProvider) : new SampleToWaveProvider(sampleProvider);
wavePlayer.Init(provider);
}
+#endif
///
/// Turns WaveFormatExtensible into a standard waveformat if possible
diff --git a/NAudio/Wave/WaveFormats/TrueSpeechWaveFormat.cs b/NAudio/Wave/WaveFormats/TrueSpeechWaveFormat.cs
index d0c72ebc..e6371ae6 100644
--- a/NAudio/Wave/WaveFormats/TrueSpeechWaveFormat.cs
+++ b/NAudio/Wave/WaveFormats/TrueSpeechWaveFormat.cs
@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Runtime.InteropServices;
+using System.Runtime.InteropServices;
using System.IO;
namespace NAudio.Wave
diff --git a/NAudio/Wave/WaveFormats/WaveFormatExtensible.cs b/NAudio/Wave/WaveFormats/WaveFormatExtensible.cs
index f84ab215..7239f6d6 100644
--- a/NAudio/Wave/WaveFormats/WaveFormatExtensible.cs
+++ b/NAudio/Wave/WaveFormats/WaveFormatExtensible.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Runtime.InteropServices;
using NAudio.Dmo;
diff --git a/NAudio/Wave/WaveInputs/CaptureState.cs b/NAudio/Wave/WaveInputs/CaptureState.cs
new file mode 100644
index 00000000..6849b1b6
--- /dev/null
+++ b/NAudio/Wave/WaveInputs/CaptureState.cs
@@ -0,0 +1,27 @@
+// for consistency this should be in NAudio.Wave namespace, but left as it is for backwards compatibility
+// ReSharper disable once CheckNamespace
+namespace NAudio.CoreAudioApi
+{
+ ///
+ /// Represents state of a capture device
+ ///
+ public enum CaptureState
+ {
+ ///
+ /// Not recording
+ ///
+ Stopped,
+ ///
+ /// Beginning to record
+ ///
+ Starting,
+ ///
+ /// Recording in progress
+ ///
+ Capturing,
+ ///
+ /// Requesting stop
+ ///
+ Stopping
+ }
+}
\ No newline at end of file
diff --git a/NAudio/Wave/WaveInputs/WasapiCapture.cs b/NAudio/Wave/WaveInputs/WasapiCapture.cs
index 888bc8fb..91eae9a3 100644
--- a/NAudio/Wave/WaveInputs/WasapiCapture.cs
+++ b/NAudio/Wave/WaveInputs/WasapiCapture.cs
@@ -1,35 +1,12 @@
using System;
-using NAudio.Wave;
using System.Threading;
using System.Runtime.InteropServices;
+using NAudio.Wave;
// for consistency this should be in NAudio.Wave namespace, but left as it is for backwards compatibility
// ReSharper disable once CheckNamespace
namespace NAudio.CoreAudioApi
{
- ///
- /// Represents state of a capture device
- ///
- public enum CaptureState
- {
- ///
- /// Not recording
- ///
- Stopped,
- ///
- /// Beginning to record
- ///
- Starting,
- ///
- /// Recording in progress
- ///
- Capturing,
- ///
- /// Requesting stop
- ///
- Stopping
- }
-
///
/// Audio Capture using Wasapi
/// See http://msdn.microsoft.com/en-us/library/dd370800%28VS.85%29.aspx
@@ -214,8 +191,7 @@ public void StartRecording()
}
captureState = CaptureState.Starting;
InitializeCaptureDevice();
- ThreadStart start = () => CaptureThread(audioClient);
- captureThread = new Thread(start);
+ captureThread = new Thread(() => CaptureThread(audioClient));
captureThread.Start();
}
@@ -262,7 +238,11 @@ private void DoRecording(AudioClient client)
var capture = client.AudioCaptureClient;
client.Start();
- captureState = CaptureState.Capturing;
+ // avoid race condition where we stop immediately after starting
+ if (captureState == CaptureState.Starting)
+ {
+ captureState = CaptureState.Capturing;
+ }
while (captureState == CaptureState.Capturing)
{
bool readBuffer = true;
@@ -307,9 +287,7 @@ private void ReadNextPacket(AudioCaptureClient capture)
while (packetSize != 0)
{
- int framesAvailable;
- AudioClientBufferFlags flags;
- IntPtr buffer = capture.GetBuffer(out framesAvailable, out flags);
+ IntPtr buffer = capture.GetBuffer(out int framesAvailable, out AudioClientBufferFlags flags);
int bytesAvailable = framesAvailable * bytesPerFrame;
@@ -318,7 +296,7 @@ private void ReadNextPacket(AudioCaptureClient capture)
int spaceRemaining = Math.Max(0, recordBuffer.Length - recordBufferOffset);
if (spaceRemaining < bytesAvailable && recordBufferOffset > 0)
{
- if (DataAvailable != null) DataAvailable(this, new WaveInEventArgs(recordBuffer, recordBufferOffset));
+ DataAvailable?.Invoke(this, new WaveInEventArgs(recordBuffer, recordBufferOffset));
recordBufferOffset = 0;
}
@@ -335,10 +313,7 @@ private void ReadNextPacket(AudioCaptureClient capture)
capture.ReleaseBuffer(framesAvailable);
packetSize = capture.GetNextPacketSize();
}
- if (DataAvailable != null)
- {
- DataAvailable(this, new WaveInEventArgs(recordBuffer, recordBufferOffset));
- }
+ DataAvailable?.Invoke(this, new WaveInEventArgs(recordBuffer, recordBufferOffset));
}
///
diff --git a/NAudio.Universal/Wave/WaveInputs/WasapiCaptureRT.cs b/NAudio/Wave/WaveInputs/WasapiCaptureRT.cs
similarity index 96%
rename from NAudio.Universal/Wave/WaveInputs/WasapiCaptureRT.cs
rename to NAudio/Wave/WaveInputs/WasapiCaptureRT.cs
index 6aa1aa37..a6496249 100644
--- a/NAudio.Universal/Wave/WaveInputs/WasapiCaptureRT.cs
+++ b/NAudio/Wave/WaveInputs/WasapiCaptureRT.cs
@@ -6,7 +6,6 @@
using System.Threading;
using System.Diagnostics;
using System.Runtime.InteropServices;
-using NAudio.Win8.Wave.WaveOutputs;
using Windows.Devices.Enumeration;
using Windows.Media.Devices;
@@ -304,15 +303,13 @@ private void RaiseRecordingStopped(Exception exception)
private void ReadNextPacket(AudioCaptureClient capture)
{
IntPtr buffer;
- int framesAvailable;
- AudioClientBufferFlags flags;
int packetSize = capture.GetNextPacketSize();
int recordBufferOffset = 0;
//Debug.WriteLine(string.Format("packet size: {0} samples", packetSize / 4));
while (packetSize != 0)
{
- buffer = capture.GetBuffer(out framesAvailable, out flags);
+ buffer = capture.GetBuffer(out int framesAvailable, out AudioClientBufferFlags flags);
int bytesAvailable = framesAvailable * bytesPerFrame;
@@ -321,7 +318,7 @@ private void ReadNextPacket(AudioCaptureClient capture)
int spaceRemaining = Math.Max(0, recordBuffer.Length - recordBufferOffset);
if (spaceRemaining < bytesAvailable && recordBufferOffset > 0)
{
- if (DataAvailable != null) DataAvailable(this, new WaveInEventArgs(recordBuffer, recordBufferOffset));
+ DataAvailable?.Invoke(this, new WaveInEventArgs(recordBuffer, recordBufferOffset));
recordBufferOffset = 0;
}
@@ -338,10 +335,7 @@ private void ReadNextPacket(AudioCaptureClient capture)
capture.ReleaseBuffer(framesAvailable);
packetSize = capture.GetNextPacketSize();
}
- if (DataAvailable != null)
- {
- DataAvailable(this, new WaveInEventArgs(recordBuffer, recordBufferOffset));
- }
+ DataAvailable?.Invoke(this, new WaveInEventArgs(recordBuffer, recordBufferOffset));
}
///
diff --git a/NAudio/Wave/WaveInputs/WaveInEvent.cs b/NAudio/Wave/WaveInputs/WaveInEvent.cs
index 494fbd4f..bc75b763 100644
--- a/NAudio/Wave/WaveInputs/WaveInEvent.cs
+++ b/NAudio/Wave/WaveInputs/WaveInEvent.cs
@@ -97,7 +97,8 @@ private void OpenWaveInDevice()
{
CloseWaveInDevice();
MmResult result = WaveInterop.waveInOpenWindow(out waveInHandle, (IntPtr)DeviceNumber, WaveFormat,
- callbackEvent.SafeWaitHandle.DangerousGetHandle(), IntPtr.Zero, WaveInterop.WaveInOutOpenFlags.CallbackEvent);
+ callbackEvent.SafeWaitHandle.DangerousGetHandle(),
+ IntPtr.Zero, WaveInterop.WaveInOutOpenFlags.CallbackEvent);
MmException.Try(result, "waveInOpen");
CreateBuffers();
}
@@ -279,3 +280,4 @@ public void Dispose()
}
}
}
+
diff --git a/NAudio/Wave/WaveOutputs/AiffFileWriter.cs b/NAudio/Wave/WaveOutputs/AiffFileWriter.cs
index a281a0f0..6a80a921 100644
--- a/NAudio/Wave/WaveOutputs/AiffFileWriter.cs
+++ b/NAudio/Wave/WaveOutputs/AiffFileWriter.cs
@@ -331,7 +331,7 @@ protected override void Dispose(bool disposing)
{
// in a finally block as we don't want the FileStream to run its disposer in
// the GC thread if the code above caused an IOException (e.g. due to disk full)
- outStream.Close(); // will close the underlying base stream
+ outStream.Dispose(); // will close the underlying base stream
outStream = null;
}
}
diff --git a/NAudio/Wave/WaveOutputs/BwfWriter.cs b/NAudio/Wave/WaveOutputs/BwfWriter.cs
index e42fa05b..64cb309a 100644
--- a/NAudio/Wave/WaveOutputs/BwfWriter.cs
+++ b/NAudio/Wave/WaveOutputs/BwfWriter.cs
@@ -134,7 +134,11 @@ public void Dispose()
if (!isDisposed)
{
FixUpChunkSizes(false);
+#if NET35
writer.Close();
+#else
+ writer.Dispose();
+#endif
isDisposed = true;
}
}
diff --git a/NAudio/Wave/WaveOutputs/DirectSoundOut.cs b/NAudio/Wave/WaveOutputs/DirectSoundOut.cs
index 5d4fdc80..0c265833 100644
--- a/NAudio/Wave/WaveOutputs/DirectSoundOut.cs
+++ b/NAudio/Wave/WaveOutputs/DirectSoundOut.cs
@@ -670,7 +670,7 @@ private int Feed(int bytesToCopy)
//----------------------------------------------------------------------------------------------
// Minimal Native DirectSound COM interop interfaces
//----------------------------------------------------------------------------------------------
- #region Native DirectSound COM Interface
+#region Native DirectSound COM Interface
[StructLayout(LayoutKind.Sequential, Pack = 2)]
internal class BufferDescription
@@ -763,8 +763,11 @@ internal struct DirectSoundBufferPositionNotify
///
[ComImport,
Guid("279AFA83-4981-11CE-A521-0020AF0BE560"),
- InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
- SuppressUnmanagedCodeSecurity]
+#if !WINDOWS_UWP
+ System.Security.SuppressUnmanagedCodeSecurity,
+#endif
+ InterfaceType(ComInterfaceType.InterfaceIsIUnknown)
+ ]
internal interface IDirectSound
{
//STDMETHOD(CreateSoundBuffer) (THIS_ LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOuter) PURE;
@@ -790,8 +793,11 @@ internal interface IDirectSound
///
[ComImport,
Guid("279AFA85-4981-11CE-A521-0020AF0BE560"),
- InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
- SuppressUnmanagedCodeSecurity]
+#if !WINDOWS_UWP
+ System.Security.SuppressUnmanagedCodeSecurity,
+#endif
+ InterfaceType(ComInterfaceType.InterfaceIsIUnknown)
+ ]
internal interface IDirectSoundBuffer
{
// STDMETHOD(GetCaps) (THIS_ LPDSBCAPS pDSBufferCaps) PURE;
@@ -841,8 +847,10 @@ internal interface IDirectSoundBuffer
///
[ComImport,
Guid("b0210783-89cd-11d0-af08-00a0c925cd16"),
- InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
- SuppressUnmanagedCodeSecurity]
+#if !WINDOWS_UWP
+ System.Security.SuppressUnmanagedCodeSecurity,
+#endif
+ InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IDirectSoundNotify
{
void SetNotificationPositions(UInt32 dwPositionNotifies, [In, MarshalAs(UnmanagedType.LPArray)] DirectSoundBufferPositionNotify[] pcPositionNotifies);
@@ -903,7 +911,7 @@ internal interface IDirectSoundNotify
/// HANDLE of the Desktop window
[DllImport("user32.dll")]
private static extern IntPtr GetDesktopWindow();
- #endregion
+#endregion
}
///
diff --git a/NAudio/Wave/WaveOutputs/IWavePlayer.cs b/NAudio/Wave/WaveOutputs/IWavePlayer.cs
index 4d5e5c01..53c7cb5a 100644
--- a/NAudio/Wave/WaveOutputs/IWavePlayer.cs
+++ b/NAudio/Wave/WaveOutputs/IWavePlayer.cs
@@ -23,16 +23,27 @@ public interface IWavePlayer : IDisposable
///
void Pause();
+#if WINDOWS_UWP
///
- /// Initialise playback
+ /// Obsolete init method
///
- /// The waveprovider to be played
- void Init(IWaveProvider waveProvider);
+ ///
+ ///
+ [Obsolete]
+ System.Threading.Tasks.Task Init(IWaveProvider waveProvider);
///
- /// Current playback state
+ /// Initialise playback
///
- PlaybackState PlaybackState { get; }
+ /// Function to create the waveprovider to be played
+ /// Called on the playback thread
+ void Init(Func waveProviderFunc);
+#else
+ ///
+ /// Initialise playback
+ ///
+ /// The waveprovider to be played
+ void Init(IWaveProvider waveProvider);
///
/// The volume
@@ -40,6 +51,12 @@ public interface IWavePlayer : IDisposable
/// Note that not all implementations necessarily support volume changes
///
float Volume { get; set; }
+#endif
+ ///
+ /// Current playback state
+ ///
+ PlaybackState PlaybackState { get; }
+
///
/// Indicates that playback has gone into a stopped state due to
diff --git a/NAudio/Wave/WaveOutputs/WasapiOut.cs b/NAudio/Wave/WaveOutputs/WasapiOut.cs
index 1fe732cf..35a40cba 100644
--- a/NAudio/Wave/WaveOutputs/WasapiOut.cs
+++ b/NAudio/Wave/WaveOutputs/WasapiOut.cs
@@ -285,7 +285,7 @@ public WaveFormat OutputWaveFormat
get { return outputFormat; }
}
- #region IWavePlayer Members
+#region IWavePlayer Members
///
/// Begin Playback
@@ -489,9 +489,9 @@ public AudioStreamVolume AudioStreamVolume
}
}
- #endregion
+#endregion
- #region IDisposable Members
+#region IDisposable Members
///
/// Dispose
@@ -508,6 +508,6 @@ public void Dispose()
}
}
- #endregion
+#endregion
}
}
diff --git a/NAudio.Universal/Wave/WaveOutputs/WasapiOutRT.cs b/NAudio/Wave/WaveOutputs/WasapiOutRT.cs
similarity index 99%
rename from NAudio.Universal/Wave/WaveOutputs/WasapiOutRT.cs
rename to NAudio/Wave/WaveOutputs/WasapiOutRT.cs
index 9f993450..fe58abd1 100644
--- a/NAudio.Universal/Wave/WaveOutputs/WasapiOutRT.cs
+++ b/NAudio/Wave/WaveOutputs/WasapiOutRT.cs
@@ -1,19 +1,15 @@
using System;
-using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
-using Windows.System.Threading;
using NAudio.CoreAudioApi;
using NAudio.CoreAudioApi.Interfaces;
-using NAudio.Dsp;
-using NAudio.Wave;
using Windows.Media.Devices;
using NAudio.Utils;
using NAudio.Wave.SampleProviders;
-namespace NAudio.Win8.Wave.WaveOutputs
+namespace NAudio.Wave
{
enum WasapiOutState
{
@@ -127,7 +123,7 @@ private async Task Activate()
IActivateAudioInterfaceAsyncOperation activationOperation;
NativeMethods.ActivateAudioInterfaceAsync(device, IID_IAudioClient2, IntPtr.Zero, icbh, out activationOperation);
var audioClient2 = await icbh;
- this.audioClient = new AudioClient((IAudioClient)audioClient2);
+ audioClient = new AudioClient((IAudioClient)audioClient2);
}
private static string GetDefaultAudioEndpoint()
@@ -307,9 +303,10 @@ public void Pause()
///
///
[Obsolete]
- public async Task Init(IWaveProvider provider)
+ public Task Init(IWaveProvider provider)
{
Init(() => provider);
+ return Task.CompletedTask;
}
///
@@ -327,6 +324,7 @@ public void Init(Func waveProviderFunc)
});
}
+
///
/// Initialize for playing the specified wave stream
///
diff --git a/NAudio/Wave/WaveOutputs/WaveFileWriter.cs b/NAudio/Wave/WaveOutputs/WaveFileWriter.cs
index 7fb79dfd..8700defb 100644
--- a/NAudio/Wave/WaveOutputs/WaveFileWriter.cs
+++ b/NAudio/Wave/WaveOutputs/WaveFileWriter.cs
@@ -385,7 +385,7 @@ protected override void Dispose(bool disposing)
{
// in a finally block as we don't want the FileStream to run its disposer in
// the GC thread if the code above caused an IOException (e.g. due to disk full)
- outStream.Close(); // will close the underlying base stream
+ outStream.Dispose(); // will close the underlying base stream
outStream = null;
}
}
diff --git a/NAudio.Universal/Wave/WaveOutputs/WaveFileWriterRT.cs b/NAudio/Wave/WaveOutputs/WaveFileWriterRT.cs
similarity index 100%
rename from NAudio.Universal/Wave/WaveOutputs/WaveFileWriterRT.cs
rename to NAudio/Wave/WaveOutputs/WaveFileWriterRT.cs
diff --git a/NAudio/Wave/WaveOutputs/WaveOut.cs b/NAudio/Wave/WaveOutputs/WaveOut.cs
index fb2cfcf9..d05317df 100644
--- a/NAudio/Wave/WaveOutputs/WaveOut.cs
+++ b/NAudio/Wave/WaveOutputs/WaveOut.cs
@@ -245,20 +245,7 @@ public void Stop()
/// stream - it calls directly into waveOutGetPosition)
///
/// Position in bytes
- public long GetPosition()
- {
- lock (waveOutLock)
- {
- MmTime mmTime = new MmTime();
- mmTime.wType = MmTime.TIME_BYTES; // request results in bytes, TODO: perhaps make this a little more flexible and support the other types?
- MmException.Try(WaveInterop.waveOutGetPosition(hWaveOut, out mmTime, Marshal.SizeOf(mmTime)), "waveOutGetPosition");
-
- if (mmTime.wType != MmTime.TIME_BYTES)
- throw new Exception(string.Format("waveOutGetPosition: wType -> Expected {0}, Received {1}", MmTime.TIME_BYTES, mmTime.wType));
-
- return mmTime.cb;
- }
- }
+ public long GetPosition() => WaveOutUtils.GetPositionBytes(hWaveOut, waveOutLock);
///
/// Gets a instance indicating the format the hardware is using.
@@ -277,40 +264,12 @@ public float Volume
{
get
{
- return GetWaveOutVolume(hWaveOut, waveOutLock);
+ return WaveOutUtils.GetWaveOutVolume(hWaveOut, waveOutLock);
}
set
{
- SetWaveOutVolume(value, hWaveOut, waveOutLock);
- }
- }
-
- internal static float GetWaveOutVolume(IntPtr hWaveOut, object lockObject)
- {
- int stereoVolume;
- MmResult result;
- lock (lockObject)
- {
- result = WaveInterop.waveOutGetVolume(hWaveOut, out stereoVolume);
- }
- MmException.Try(result, "waveOutGetVolume");
- return (stereoVolume & 0xFFFF) / (float)0xFFFF;
- }
-
- internal static void SetWaveOutVolume(float value, IntPtr hWaveOut, object lockObject)
- {
- if (value < 0) throw new ArgumentOutOfRangeException(nameof(value), "Volume must be between 0.0 and 1.0");
- if (value > 1) throw new ArgumentOutOfRangeException(nameof(value), "Volume must be between 0.0 and 1.0");
- float left = value;
- float right = value;
-
- int stereoVolume = (int) (left*0xFFFF) + ((int) (right*0xFFFF) << 16);
- MmResult result;
- lock (lockObject)
- {
- result = WaveInterop.waveOutSetVolume(hWaveOut, stereoVolume);
+ WaveOutUtils.SetWaveOutVolume(value, hWaveOut, waveOutLock);
}
- MmException.Try(result, "waveOutSetVolume");
}
#region Dispose Pattern
diff --git a/NAudio/Wave/WaveOutputs/WaveOutEvent.cs b/NAudio/Wave/WaveOutputs/WaveOutEvent.cs
index 11dc2cc3..052d902a 100644
--- a/NAudio/Wave/WaveOutputs/WaveOutEvent.cs
+++ b/NAudio/Wave/WaveOutputs/WaveOutEvent.cs
@@ -86,7 +86,7 @@ public void Init(IWaveProvider waveProvider)
callbackEvent = new AutoResetEvent(false);
waveStream = waveProvider;
- int bufferSize = waveProvider.WaveFormat.ConvertLatencyToByteSize((DesiredLatency + NumberOfBuffers - 1) / NumberOfBuffers);
+ int bufferSize = waveProvider.WaveFormat.ConvertLatencyToByteSize((DesiredLatency + NumberOfBuffers - 1) / NumberOfBuffers);
MmResult result;
lock (waveOutLock)
@@ -248,50 +248,25 @@ public void Stop()
/// stream - it calls directly into waveOutGetPosition)
///
/// Position in bytes
- public long GetPosition()
- {
- lock (waveOutLock)
- {
- var mmTime = new MmTime();
- mmTime.wType = MmTime.TIME_BYTES; // request results in bytes, TODO: perhaps make this a little more flexible and support the other types?
- MmException.Try(WaveInterop.waveOutGetPosition(hWaveOut, out mmTime, Marshal.SizeOf(mmTime)), "waveOutGetPosition");
-
- if (mmTime.wType != MmTime.TIME_BYTES)
- throw new Exception(string.Format("waveOutGetPosition: wType -> Expected {0}, Received {1}", MmTime.TIME_BYTES, mmTime.wType));
-
- return mmTime.cb;
- }
- }
+ public long GetPosition() => WaveOutUtils.GetPositionBytes(hWaveOut, waveOutLock);
///
/// Gets a instance indicating the format the hardware is using.
///
- public WaveFormat OutputWaveFormat
- {
- get { return waveStream.WaveFormat; }
- }
+ public WaveFormat OutputWaveFormat => waveStream.WaveFormat;
///
/// Playback State
///
- public PlaybackState PlaybackState
- {
- get { return playbackState; }
- }
+ public PlaybackState PlaybackState => playbackState;
///
/// Volume for this device 1.0 is full scale
///
public float Volume
{
- get
- {
- return WaveOut.GetWaveOutVolume(hWaveOut, waveOutLock);
- }
- set
- {
- WaveOut.SetWaveOutVolume(value, hWaveOut, waveOutLock);
- }
+ get => WaveOutUtils.GetWaveOutVolume(hWaveOut, waveOutLock);
+ set => WaveOutUtils.SetWaveOutVolume(value, hWaveOut, waveOutLock);
}
#region Dispose Pattern
@@ -359,7 +334,7 @@ private void DisposeBuffers()
Debug.Assert(false, "WaveOutEvent device was not closed");
}
- #endregion
+#endregion
private void RaisePlaybackStoppedEvent(Exception e)
{
diff --git a/NAudio/Wave/WaveOutputs/WaveOutUtils.cs b/NAudio/Wave/WaveOutputs/WaveOutUtils.cs
new file mode 100644
index 00000000..f84d0ace
--- /dev/null
+++ b/NAudio/Wave/WaveOutputs/WaveOutUtils.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Runtime.InteropServices;
+
+// ReSharper disable once CheckNamespace
+namespace NAudio.Wave
+{
+ static class WaveOutUtils
+ {
+ public static float GetWaveOutVolume(IntPtr hWaveOut, object lockObject)
+ {
+ int stereoVolume;
+ MmResult result;
+ lock (lockObject)
+ {
+ result = WaveInterop.waveOutGetVolume(hWaveOut, out stereoVolume);
+ }
+ MmException.Try(result, "waveOutGetVolume");
+ return (stereoVolume & 0xFFFF) / (float)0xFFFF;
+ }
+
+ public static void SetWaveOutVolume(float value, IntPtr hWaveOut, object lockObject)
+ {
+ if (value < 0) throw new ArgumentOutOfRangeException(nameof(value), "Volume must be between 0.0 and 1.0");
+ if (value > 1) throw new ArgumentOutOfRangeException(nameof(value), "Volume must be between 0.0 and 1.0");
+ float left = value;
+ float right = value;
+
+ int stereoVolume = (int)(left * 0xFFFF) + ((int)(right * 0xFFFF) << 16);
+ MmResult result;
+ lock (lockObject)
+ {
+ result = WaveInterop.waveOutSetVolume(hWaveOut, stereoVolume);
+ }
+ MmException.Try(result, "waveOutSetVolume");
+ }
+
+ public static long GetPositionBytes(IntPtr hWaveOut, object lockObject)
+ {
+ lock (lockObject)
+ {
+ var mmTime = new MmTime();
+ mmTime.wType = MmTime.TIME_BYTES; // request results in bytes, TODO: perhaps make this a little more flexible and support the other types?
+ MmException.Try(WaveInterop.waveOutGetPosition(hWaveOut, ref mmTime, Marshal.SizeOf(mmTime)), "waveOutGetPosition");
+
+ if (mmTime.wType != MmTime.TIME_BYTES)
+ throw new Exception(string.Format("waveOutGetPosition: wType -> Expected {0}, Received {1}", MmTime.TIME_BYTES, mmTime.wType));
+
+ return mmTime.cb;
+ }
+ }
+ }
+}
diff --git a/NAudio/Wave/WaveStreams/AiffFileReader.cs b/NAudio/Wave/WaveStreams/AiffFileReader.cs
index 2abd6cef..25d41a98 100644
--- a/NAudio/Wave/WaveStreams/AiffFileReader.cs
+++ b/NAudio/Wave/WaveStreams/AiffFileReader.cs
@@ -139,7 +139,11 @@ protected override void Dispose(bool disposing)
// only dispose our source if we created it
if (ownInput)
{
+#if NET35
waveStream.Close();
+#else
+ waveStream.Dispose();
+#endif
}
waveStream = null;
}
@@ -262,7 +266,7 @@ public override int Read(byte[] array, int offset, int count)
}
}
- #region Endian Helpers
+#region Endian Helpers
private static uint ConvertInt(byte[] buffer)
{
if (buffer.Length != 4) throw new Exception("Incorrect length for long.");
@@ -274,10 +278,10 @@ private static short ConvertShort(byte[] buffer)
if (buffer.Length != 2) throw new Exception("Incorrect length for int.");
return (short)((buffer[0] << 8) | buffer[1]);
}
- #endregion
+#endregion
- #region AiffChunk
+#region AiffChunk
///
/// AIFF Chunk
///
@@ -319,6 +323,6 @@ private static string ReadChunkName(BinaryReader br)
{
return new string(br.ReadChars(4));
}
- #endregion
+#endregion
}
}
diff --git a/NAudio/Wave/WaveStreams/ComStream.cs b/NAudio/Wave/WaveStreams/ComStream.cs
index 34c10d42..f949867a 100644
--- a/NAudio/Wave/WaveStreams/ComStream.cs
+++ b/NAudio/Wave/WaveStreams/ComStream.cs
@@ -35,8 +35,10 @@ internal ComStream(Stream stream, bool synchronizeStream)
{
if (stream == null)
throw new ArgumentNullException(nameof(stream));
+#if !WINDOWS_UWP
if (synchronizeStream)
stream = Synchronized(stream);
+#endif
this.stream = stream;
}
@@ -151,6 +153,7 @@ protected override void Dispose(bool disposing)
stream = null;
}
+#if !WINDOWS_UWP
public override void Close()
{
base.Close();
@@ -159,5 +162,6 @@ public override void Close()
stream.Close();
stream = null;
}
+#endif
}
}
diff --git a/NAudio/Wave/WaveStreams/CueList.cs b/NAudio/Wave/WaveStreams/CueList.cs
index 8c266d2a..48191c8d 100644
--- a/NAudio/Wave/WaveStreams/CueList.cs
+++ b/NAudio/Wave/WaveStreams/CueList.cs
@@ -165,7 +165,7 @@ internal CueList(byte[] cueChunkData, byte[] listChunkData)
labelLength = BitConverter.ToInt32(listChunkData, p + 4) - 4;
var cueId = BitConverter.ToInt32(listChunkData, p + 8);
cue = cueIndex[cueId];
- labels[cue] = Encoding.Default.GetString(listChunkData, p + 12, labelLength - 1);
+ labels[cue] = Encoding.UTF8.GetString(listChunkData, p + 12, labelLength - 1);
}
}
@@ -225,7 +225,7 @@ internal byte[] GetRiffChunks()
writer.Write(labelChunkId);
writer.Write(this[cue].Label.Length + 1 + 4);
writer.Write(cue);
- writer.Write(Encoding.Default.GetBytes(this[cue].Label.ToCharArray()));
+ writer.Write(Encoding.UTF8.GetBytes(this[cue].Label.ToCharArray()));
if (this[cue].Label.Length % 2 == 0)
{
writer.Seek(2, SeekOrigin.Current);
diff --git a/NAudio/Wave/WaveStreams/SimpleCompressorStream.cs b/NAudio/Wave/WaveStreams/SimpleCompressorStream.cs
index a9a13ed0..1b27b27d 100644
--- a/NAudio/Wave/WaveStreams/SimpleCompressorStream.cs
+++ b/NAudio/Wave/WaveStreams/SimpleCompressorStream.cs
@@ -1,4 +1,3 @@
-using System;
using NAudio.Dsp;
namespace NAudio.Wave
@@ -6,24 +5,21 @@ namespace NAudio.Wave
///
/// A simple compressor
///
- public class SimpleCompressorStream : WaveStream
+ public class SimpleCompressorEffect : ISampleProvider
{
- private WaveStream sourceStream;
+ private readonly ISampleProvider sourceStream;
private readonly SimpleCompressor simpleCompressor;
- private byte[] sourceBuffer; // buffer used by Read function
private readonly int channels;
- private readonly int bytesPerSample;
private readonly object lockObject = new object();
///
/// Create a new simple compressor stream
///
/// Source stream
- public SimpleCompressorStream(WaveStream sourceStream)
+ public SimpleCompressorEffect(ISampleProvider sourceStream)
{
this.sourceStream = sourceStream;
channels = sourceStream.WaveFormat.Channels;
- bytesPerSample = sourceStream.WaveFormat.BitsPerSample / 8;
simpleCompressor = new SimpleCompressor(5.0, 10.0, sourceStream.WaveFormat.SampleRate);
simpleCompressor.Threshold = 16;
simpleCompressor.Ratio = 6;
@@ -36,10 +32,7 @@ public SimpleCompressorStream(WaveStream sourceStream)
///
public double MakeUpGain
{
- get
- {
- return simpleCompressor.MakeUpGain;
- }
+ get => simpleCompressor.MakeUpGain;
set
{
lock (lockObject)
@@ -54,10 +47,7 @@ public double MakeUpGain
///
public double Threshold
{
- get
- {
- return simpleCompressor.Threshold;
- }
+ get => simpleCompressor.Threshold;
set
{
lock (lockObject)
@@ -72,10 +62,7 @@ public double Threshold
///
public double Ratio
{
- get
- {
- return simpleCompressor.Ratio;
- }
+ get => simpleCompressor.Ratio;
set
{
lock (lockObject)
@@ -90,10 +77,7 @@ public double Ratio
///
public double Attack
{
- get
- {
- return simpleCompressor.Attack;
- }
+ get => simpleCompressor.Attack;
set
{
lock (lockObject)
@@ -108,10 +92,7 @@ public double Attack
///
public double Release
{
- get
- {
- return simpleCompressor.Release;
- }
+ get => simpleCompressor.Release;
set
{
lock (lockObject)
@@ -121,103 +102,16 @@ public double Release
}
}
-
- ///
- /// Determine whether the stream has the required amount of data.
- ///
- /// Number of bytes of data required from the stream.
- /// Flag indicating whether the required amount of data is avialable.
- public override bool HasData(int count)
- {
- return sourceStream.HasData(count);
- }
-
-
///
/// Turns gain on or off
///
public bool Enabled { get; set; }
-
- ///
- /// Returns the stream length
- ///
- public override long Length => sourceStream.Length;
-
- ///
- /// Gets or sets the current position in the stream
- ///
- public override long Position
- {
- get
- {
- return sourceStream.Position;
- }
- set
- {
- lock (lockObject)
- {
- sourceStream.Position = value;
- }
- }
- }
-
///
/// Gets the WaveFormat of this stream
///
- public override WaveFormat WaveFormat => sourceStream.WaveFormat;
+ public WaveFormat WaveFormat => sourceStream.WaveFormat;
- private void ReadSamples(byte[] buffer, int start, out double left, out double right)
- {
- if (bytesPerSample == 4)
- {
- left = BitConverter.ToSingle(buffer, start);
- if (channels > 1)
- {
- right = BitConverter.ToSingle(buffer, start + bytesPerSample);
- }
- else
- {
- right = left;
- }
- }
- else if (bytesPerSample == 2)
- {
- left = BitConverter.ToInt16(buffer, start) / 32768.0;
- if (channels > 1)
- {
- right = BitConverter.ToInt16(buffer, start + bytesPerSample) / 32768.0;
- }
- else
- {
- right = left;
- }
- }
- else
- {
- throw new InvalidOperationException(String.Format("Unsupported bytes per sample: {0}", bytesPerSample));
- }
- }
-
- private void WriteSamples(byte[] buffer, int start, double left, double right)
- {
- if (bytesPerSample == 4)
- {
- Array.Copy(BitConverter.GetBytes((float)left), 0, buffer, start, bytesPerSample);
- if (channels > 1)
- {
- Array.Copy(BitConverter.GetBytes((float)right), 0, buffer, start + bytesPerSample, bytesPerSample);
- }
- }
- else if (bytesPerSample == 2)
- {
- Array.Copy(BitConverter.GetBytes((short)(left * 32768.0)), 0, buffer, start, bytesPerSample);
- if (channels > 1)
- {
- Array.Copy(BitConverter.GetBytes((short)(right * 32768.0)), 0, buffer, start + bytesPerSample, bytesPerSample);
- }
- }
- }
///
/// Reads bytes from this stream
@@ -226,65 +120,24 @@ private void WriteSamples(byte[] buffer, int start, double left, double right)
/// Offset in array to read into
/// Number of bytes to read
/// Number of bytes read
- public override int Read(byte[] array, int offset, int count)
+ public int Read(float[] array, int offset, int count)
{
lock (lockObject)
{
+ int samplesRead = sourceStream.Read(array, offset, count);
if (Enabled)
{
- if (sourceBuffer == null || sourceBuffer.Length < count)
- sourceBuffer = new byte[count];
- int sourceBytesRead = sourceStream.Read(sourceBuffer, 0, count);
- int sampleCount = sourceBytesRead / (bytesPerSample * channels);
- for (int sample = 0; sample < sampleCount; sample++)
+ for (int sample = 0; sample < samplesRead; sample+=channels)
{
- int start = sample * bytesPerSample * channels;
- double in1;
- double in2;
- ReadSamples(sourceBuffer, start, out in1, out in2);
+ double in1 = array[offset+sample];
+ double in2 = (channels == 1) ? 0 : array[offset+sample+1];
simpleCompressor.Process(ref in1, ref in2);
- WriteSamples(array, offset + start, in1, in2);
+ array[offset + sample] = (float)in1;
+ if (channels > 1)
+ array[offset + sample + 1] = (float)in2;
}
- return count;
}
- else
- {
- return sourceStream.Read(array, offset, count);
- }
- }
-
- }
-
- ///
- /// Disposes this stream
- ///
- /// true if the user called this
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- // Release managed resources.
- if (sourceStream != null)
- {
- sourceStream.Dispose();
- sourceStream = null;
- }
- }
- // Release unmanaged resources.
- // Set large fields to null.
- // Call Dispose on your base class.
- base.Dispose(disposing);
- }
-
- ///
- /// Gets the block alignment for this stream
- ///
- public override int BlockAlign
- {
- get
- {
- // TODO: investigate forcing 20ms
- return sourceStream.BlockAlign;
+ return samplesRead;
}
}
}
diff --git a/NAudioDemo/AudioPlaybackDemo/AudioPlaybackPanel.Designer.cs b/NAudioDemo/AudioPlaybackDemo/AudioPlaybackPanel.Designer.cs
index 4c3c7b0d..0f31f493 100644
--- a/NAudioDemo/AudioPlaybackDemo/AudioPlaybackPanel.Designer.cs
+++ b/NAudioDemo/AudioPlaybackDemo/AudioPlaybackPanel.Designer.cs
@@ -302,7 +302,7 @@ private void InitializeComponent()
this.Controls.Add(this.volumeSlider1);
this.Name = "AudioPlaybackPanel";
this.Size = new System.Drawing.Size(591, 381);
- this.Load += new System.EventHandler(this.Form1_Load);
+ this.Load += new System.EventHandler(this.OnFormLoad);
this.groupBoxDriverModel.ResumeLayout(false);
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
diff --git a/NAudioDemo/AudioPlaybackDemo/AudioPlaybackPanel.cs b/NAudioDemo/AudioPlaybackDemo/AudioPlaybackPanel.cs
index 382c4194..c8ccac8a 100644
--- a/NAudioDemo/AudioPlaybackDemo/AudioPlaybackPanel.cs
+++ b/NAudioDemo/AudioPlaybackDemo/AudioPlaybackPanel.cs
@@ -195,7 +195,7 @@ private void CloseWaveOut()
}
}
- private void Form1_Load(object sender, EventArgs e)
+ private void OnFormLoad(object sender, EventArgs e)
{
comboBoxLatency.Items.Add(25);
comboBoxLatency.Items.Add(50);
@@ -221,19 +221,10 @@ private void OnButtonPauseClick(object sender, EventArgs e)
private void OnVolumeSliderChanged(object sender, EventArgs e)
{
- if (setVolumeDelegate != null)
- {
- setVolumeDelegate(volumeSlider1.Volume);
- }
+ setVolumeDelegate?.Invoke(volumeSlider1.Volume);
}
- private void OnButtonStopClick(object sender, EventArgs e)
- {
- if (waveOut != null)
- {
- waveOut.Stop();
- }
- }
+ private void OnButtonStopClick(object sender, EventArgs e) => waveOut?.Stop();
private void OnTimerTick(object sender, EventArgs e)
{
diff --git a/NAudioDemo/AudioPlaybackDemo/WaveOutSettingsPanel.cs b/NAudioDemo/AudioPlaybackDemo/WaveOutSettingsPanel.cs
index f257b7dd..744f0ef1 100644
--- a/NAudioDemo/AudioPlaybackDemo/WaveOutSettingsPanel.cs
+++ b/NAudioDemo/AudioPlaybackDemo/WaveOutSettingsPanel.cs
@@ -44,7 +44,7 @@ private void InitialiseStrategyCombo()
comboBoxCallback.SelectedIndex = 0;
}
- public int SelectedDeviceNumber => comboBoxWaveOutDevice.SelectedIndex;
+ public int SelectedDeviceNumber => comboBoxWaveOutDevice.SelectedIndex - 1;
public WaveCallbackStrategy CallbackStrategy => ((CallbackComboItem)comboBoxCallback.SelectedItem).Strategy;
}
diff --git a/NAudioDemo/Mp3StreamingDemo/MP3StreamingPanel.Designer.cs b/NAudioDemo/Mp3StreamingDemo/MP3StreamingPanel.Designer.cs
index ee8daecc..2c032ec8 100644
--- a/NAudioDemo/Mp3StreamingDemo/MP3StreamingPanel.Designer.cs
+++ b/NAudioDemo/Mp3StreamingDemo/MP3StreamingPanel.Designer.cs
@@ -60,7 +60,7 @@ private void InitializeComponent()
this.textBoxStreamingUrl.Name = "textBoxStreamingUrl";
this.textBoxStreamingUrl.Size = new System.Drawing.Size(228, 20);
this.textBoxStreamingUrl.TabIndex = 1;
- this.textBoxStreamingUrl.Text = "http://radio.reaper.fm/stream/";
+ this.textBoxStreamingUrl.Text = "http://bbcmedia.ic.llnwd.net/stream/bbcmedia_lrsolent_mf_p?s=1547899570&e=1547913970&h=8fae702f7db0469c3a6b36036c6273c3";
//
// timer1
//
diff --git a/NAudioTests/Acm/GsmEncodeTest.cs b/NAudioTests/Acm/GsmEncodeTest.cs
index a335ff8f..67f4949a 100644
--- a/NAudioTests/Acm/GsmEncodeTest.cs
+++ b/NAudioTests/Acm/GsmEncodeTest.cs
@@ -11,7 +11,7 @@ namespace NAudioTests.Acm
public class GsmEncodeTest
{
private string tempFolder;
- [TestFixtureSetUp]
+ [OneTimeSetUp]
public void Setup()
{
tempFolder = Path.Combine(Path.GetTempPath(), "NAudio");
diff --git a/NAudioTests/NAudioTests.csproj b/NAudioTests/NAudioTests.csproj
index 9528848b..1c828407 100644
--- a/NAudioTests/NAudioTests.csproj
+++ b/NAudioTests/NAudioTests.csproj
@@ -1,5 +1,6 @@
+
Debug
AnyCPU
@@ -41,6 +42,8 @@
true
+
+
true
@@ -62,17 +65,11 @@
AllRules.ruleset
-
+
..\packages\Moq.4.0.10827\lib\NET35\Moq.dll
-
- ..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll
-
-
- ..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll
-
-
- ..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll
+
+ ..\packages\NUnit.3.10.1\lib\net35\nunit.framework.dll
@@ -168,6 +165,12 @@
"$(SolutionDir)Tools\nuget" install "$(ProjectDir)packages.config" -o "$(SolutionDir)Packages"
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+