Skip to content

Commit

Permalink
Re-added support for .NET Framework 4.0 (Windows XP)
Browse files Browse the repository at this point in the history
  • Loading branch information
LAGonauta committed Aug 10, 2019
1 parent 46321d9 commit 0c929e7
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ASIORecAndPlay/ASIORecAndPlay.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>WinExe</OutputType>
<RootNamespace>ASIORecAndPlay</RootNamespace>
<AssemblyName>ASIORecAndPlay</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
Expand Down
2 changes: 1 addition & 1 deletion ASIORecAndPlay/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
10 changes: 8 additions & 2 deletions ASIORecAndPlay/ChannelMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

namespace ASIORecAndPlay
{
internal struct Mapping
{
public int inputChannel;
public int outputChannel;
}

internal class ChannelMapping
{
private IDictionary<int, int> channelMapping;
Expand Down Expand Up @@ -63,12 +69,12 @@ public bool Remove(int outputChannel)
/// Gets an ordered enumerable of a copy the mapping, ordered by input channel.
/// </summary>
/// <returns></returns>
public IEnumerable<(int inputChannel, int outputChannel)> GetMappingList()
public IEnumerable<Mapping> GetMappingList()
{
lock (_lock)
{
return channelMapping
.Select(e => (inputChannel: e.Value, outputChannel: e.Key))
.Select(e => new Mapping { inputChannel = e.Value, outputChannel = e.Key })
.OrderBy(e => e.inputChannel).ToList();
}
}
Expand Down
10 changes: 5 additions & 5 deletions ASIORecAndPlay/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public partial class MainWindow : Window

private void DispatchStatusText(object buffer)
{
Application.Current.Dispatcher.Invoke(() => UpdateText($"Buffered time: {((RecAndPlay)buffer).BufferedDuration().TotalMilliseconds.ToString()} ms."));
Application.Current.Dispatcher.Invoke(new Action(() => UpdateText($"Buffered time: {((RecAndPlay)buffer).BufferedDuration().TotalMilliseconds.ToString()} ms.")));
}

private void DispatchPlaybackMeters(object buffer)
{
Application.Current.Dispatcher.Invoke(() => UpdateMeter(((RecAndPlay)buffer).PlaybackAudioValue));
Application.Current.Dispatcher.Invoke(new Action(() => UpdateMeter(((RecAndPlay)buffer).PlaybackAudioValue)));
}

private void UpdateText(string message)
Expand Down Expand Up @@ -309,7 +309,7 @@ private void OnButtonBeginClick(object sender, RoutedEventArgs e)
{
statusTextTimer.Dispose();
audioMeterTimer.Dispose();
Application.Current.Dispatcher.Invoke(() => UpdateText("Stopped."));
Application.Current.Dispatcher.Invoke(new Action(() => UpdateText("Stopped.")));
Stop();
}
}
Expand All @@ -319,10 +319,10 @@ private void Stop()
if (running)
{
statusTextTimer.Dispose();
Application.Current.Dispatcher.Invoke(() => UpdateText("Stopped."));
Application.Current.Dispatcher.Invoke(new Action(() => UpdateText("Stopped.")));

audioMeterTimer.Dispose();
Application.Current.Dispatcher.Invoke(() => UpdateMeter(new VolumeMeterChannels()));
Application.Current.Dispatcher.Invoke(new Action(() => UpdateMeter(new VolumeMeterChannels())));

running = false;
UI_ButtonBegin.Content = "Start";
Expand Down
5 changes: 2 additions & 3 deletions ASIORecAndPlay/RecAndPlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal class RecAndPlay : IDisposable
public bool Valid { get; private set; }
public bool CalculateRMS { get; set; }

private IEnumerable<(int inputChannel, int outputChannel)> channelMapping;
private IEnumerable<Mapping> channelMapping;
private int firstInputChannel, lastInputChannel, numOutputChannels;

public RecAndPlay(AsioOut recordingDevice, IWavePlayer playingDevice, ChannelMapping channelMapping, ChannelLayout? forcedNumOutputChannels = null)
Expand Down Expand Up @@ -143,7 +143,7 @@ private void OnAudioAvailable(object sender, AsioAudioAvailableEventArgs e)
var mappings = channelMapping;
if (mappings.Count() > 0)
{
foreach (var map in mappings.Select(item => (inputChannel: item.inputChannel - firstInputChannel, outputChannel: item.outputChannel)))
foreach (var map in mappings.Select(item => new Mapping { inputChannel = item.inputChannel - firstInputChannel, outputChannel = item.outputChannel }))
{
for (int sampleNumber = 0; sampleNumber < e.SamplesPerBuffer; ++sampleNumber)
{
Expand Down Expand Up @@ -211,7 +211,6 @@ private float GetRMSVolume(int samplesPerChannel, int channelNumber)
return (float)Math.Sqrt(sum / samplesPerChannel);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private unsafe int GetInputSampleInt32LSB(IntPtr inputBuffer, int n)
{
return *((int*)inputBuffer + n);
Expand Down

0 comments on commit 0c929e7

Please sign in to comment.