Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
markheath committed Jun 21, 2018
1 parent 65f3cab commit f5e7c10
Show file tree
Hide file tree
Showing 74 changed files with 864 additions and 1,424 deletions.
6 changes: 1 addition & 5 deletions NAudio/Codecs/ALawDecoder.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace NAudio.Codecs
namespace NAudio.Codecs
{
/// <summary>
/// a-law decoder
Expand Down
6 changes: 1 addition & 5 deletions NAudio/Codecs/ALawEncoder.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace NAudio.Codecs
namespace NAudio.Codecs
{
/// <summary>
/// A-law encoder
Expand Down
2 changes: 0 additions & 2 deletions NAudio/Codecs/G722Codec.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace NAudio.Codecs
{
Expand Down
3 changes: 1 addition & 2 deletions NAudio/CoreAudioApi/AudioClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
8 changes: 2 additions & 6 deletions NAudio/CoreAudioApi/AudioSessionControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 0 additions & 2 deletions NAudio/CoreAudioApi/AudioSessionNotification.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using NAudio.CoreAudioApi.Interfaces;
using System;
using System.Linq;
using System.Runtime.InteropServices;

namespace NAudio.CoreAudioApi
Expand Down
4 changes: 1 addition & 3 deletions NAudio/CoreAudioApi/DataFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,5 @@ public enum DataFlow
/// endpoint device, or from the audio endpoint device to the application.
/// </summary>
All
};


}
}
4 changes: 0 additions & 4 deletions NAudio/Dsp/Complex.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace NAudio.Dsp
{
/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions NAudio/Dsp/WdlResampler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions NAudio/FileFormats/Mp3/ChannelMode.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace NAudio.Wave
namespace NAudio.Wave
{
/// <summary>
/// Channel Mode
Expand Down
2 changes: 0 additions & 2 deletions NAudio/FileFormats/Mp3/IMp3FrameDecompressor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace NAudio.Wave
{
Expand Down
2 changes: 0 additions & 2 deletions NAudio/FileFormats/Mp3/Mp3Frame.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace NAudio.Wave
Expand Down
3 changes: 1 addition & 2 deletions NAudio/FileFormats/Mp3/Mp3FrameDecompressor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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})",
Expand Down
6 changes: 1 addition & 5 deletions NAudio/FileFormats/Mp3/MpegLayer.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace NAudio.Wave
namespace NAudio.Wave
{
/// <summary>
/// MPEG Layer flags
Expand Down
6 changes: 1 addition & 5 deletions NAudio/FileFormats/Mp3/MpegVersion.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace NAudio.Wave
namespace NAudio.Wave
{
/// <summary>
/// MPEG Version Flags
Expand Down
2 changes: 0 additions & 2 deletions NAudio/FileFormats/Mp3/XingHeader.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace NAudio.Wave
{
Expand Down
206 changes: 76 additions & 130 deletions NAudio/FileFormats/SoundFont/Generator.cs
Original file line number Diff line number Diff line change
@@ -1,136 +1,82 @@
using System;

namespace NAudio.SoundFont
namespace NAudio.SoundFont
{
/// <summary>
/// Soundfont generator
/// </summary>
public class Generator
{
private GeneratorEnum generatorType;
private ushort rawAmount;
private Instrument instrument;
private SampleHeader sampleHeader;

/// <summary>
/// Gets the generator type
/// </summary>
public GeneratorEnum GeneratorType
{
get
{
return generatorType;
}
set
{
generatorType = value;
}
}

/// <summary>
/// Generator amount as an unsigned short
/// </summary>
public ushort UInt16Amount
{
get
{
return rawAmount;
}
set
{
rawAmount = value;
}
}

/// <summary>
/// Generator amount as a signed short
/// </summary>
public short Int16Amount
{
get
{
return (short) rawAmount;
}
set
{
rawAmount = (ushort) value;
}
}

/// <summary>
/// Low byte amount
/// </summary>
public byte LowByteAmount
{
get
{
return (byte) (rawAmount & 0x00FF);
}
set
{
rawAmount &= 0xFF00;
rawAmount += value;
}
}

/// <summary>
/// High byte amount
/// </summary>
public byte HighByteAmount
{
get
{
return (byte) ((rawAmount & 0xFF00) >> 8);
}
set
{
rawAmount &= 0x00FF;
rawAmount += (ushort) (value << 8);
}
}
/// <summary>
/// Soundfont generator
/// </summary>
public class Generator
{
/// <summary>
/// Gets the generator type
/// </summary>
public GeneratorEnum GeneratorType { get; set; }

/// <summary>
/// Generator amount as an unsigned short
/// </summary>
public ushort UInt16Amount { get; set; }

/// <summary>
/// Generator amount as a signed short
/// </summary>
public short Int16Amount
{
get => (short)UInt16Amount;
set => UInt16Amount = (ushort)value;
}

/// <summary>
/// Low byte amount
/// </summary>
public byte LowByteAmount
{
get
{
return (byte)(UInt16Amount & 0x00FF);
}
set
{
UInt16Amount &= 0xFF00;
UInt16Amount += value;
}
}

/// <summary>
/// Instrument
/// </summary>
public Instrument Instrument
{
get
{
return instrument;
}
set
{
instrument = value;
}
}
/// <summary>
/// High byte amount
/// </summary>
public byte HighByteAmount
{
get
{
return (byte)((UInt16Amount & 0xFF00) >> 8);
}
set
{
UInt16Amount &= 0x00FF;
UInt16Amount += (ushort)(value << 8);
}
}

/// <summary>
/// Sample Header
/// </summary>
public SampleHeader SampleHeader
{
get
{
return sampleHeader;
}
set
{
sampleHeader = value;
}
}
/// <summary>
/// Instrument
/// </summary>
public Instrument Instrument { get; set; }

/// <summary>
/// <see cref="object.ToString"/>
/// </summary>
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);
}
/// <summary>
/// Sample Header
/// </summary>
public SampleHeader SampleHeader { get; set; }

}
/// <summary>
/// <see cref="object.ToString"/>
/// </summary>
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}";
}
}
}
Loading

0 comments on commit f5e7c10

Please sign in to comment.