Skip to content

Commit

Permalink
fixed shell execute for .NET core in demo apps
Browse files Browse the repository at this point in the history
  • Loading branch information
markheath committed Feb 6, 2021
1 parent 278b551 commit 9bbd2bd
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Docs/RawSourceWaveStream.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Note that WAV files can contain compressed audio, so as long as you know the cor

## Converting G.729 audio into a PCM WAV

Suppose we have a .g729 file containing raw audio compressed with G.729. G.729 isn't actually a built-in `WaveFormat` in NAudio (some other common ones like mu and a-law are). But we can use `WaveFormat.CreateCustomFormat` or even derive from `WaveFormat` to define the correct format.
Suppose we have a `.g729` file containing raw audio compressed with G.729. G.729 isn't actually a built-in `WaveFormat` in NAudio (some other common ones like mu and a-law are). But we can use `WaveFormat.CreateCustomFormat` or even derive from `WaveFormat` to define the correct format.

Now in the previous example we saw how we could create a WAV file that contains the G.729 audio still encoded. But if we wanted it to be PCM, we'd need to use `WaveFormatConversionStream.CreatePcmStream` to look for an ACM codec that understands the incoming `WaveFormat` and can turn it into PCM.

Expand All @@ -89,7 +89,7 @@ using(var converter = WaveFormatConversionStream.CreatePcmStream(reader))
}
```

If it was a format that NAUdio has built-in support for like G.711 a-law, then we'd do it like this:
If it was a format that NAudio has built-in support for like G.711 a-law, then we'd do it like this:

```c#
var inFile = @"c:\users\mheath\desktop\alaw.bin";
Expand Down
5 changes: 3 additions & 2 deletions NAudioDemo/AcmDemo/AcmPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Windows.Forms;
using NAudio.Wave;
using NAudio.Wave.Compression;
using NAudioDemo.Utils;

namespace NAudioDemo.AcmDemo
{
Expand Down Expand Up @@ -95,7 +96,7 @@ private void EncodeFile()
}
if (checkBoxAutoLaunchConvertedFile.Checked)
{
System.Diagnostics.Process.Start(outputFileName);
ProcessHelper.ShellExecute(outputFileName);
}
}
}
Expand All @@ -122,7 +123,7 @@ private void DecodeFile()
}
if (checkBoxAutoLaunchConvertedFile.Checked)
{
System.Diagnostics.Process.Start(outputFileName);
ProcessHelper.ShellExecute(outputFileName);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion NAudioDemo/AsioRecordingDemo/AsioRecordingPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Windows.Forms;
using NAudio.Wave;
using NAudioDemo.Utils;

namespace NAudioDemo.AsioRecordingDemo
{
Expand Down Expand Up @@ -146,7 +147,7 @@ private void OnButtonPlayClick(object sender, EventArgs e)
{
if (listBoxRecordings.SelectedItem != null)
{
Process.Start((string)listBoxRecordings.SelectedItem);
ProcessHelper.ShellExecute((string)listBoxRecordings.SelectedItem);
}
}

Expand Down
5 changes: 3 additions & 2 deletions NAudioDemo/RecordingDemo/RecordingPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Windows.Forms;
using NAudio.CoreAudioApi;
using NAudio.Wave;
using NAudioDemo.Utils;

namespace NAudioDemo.RecordingDemo
{
Expand Down Expand Up @@ -213,7 +214,7 @@ private void OnButtonPlayClick(object sender, EventArgs e)
{
if (listBoxRecordings.SelectedItem != null)
{
Process.Start(Path.Combine(outputFolder, (string)listBoxRecordings.SelectedItem));
ProcessHelper.ShellExecute(Path.Combine(outputFolder, (string)listBoxRecordings.SelectedItem));
}
}

Expand Down Expand Up @@ -246,7 +247,7 @@ private void OnButtonDeleteClick(object sender, EventArgs e)

private void OnOpenFolderClick(object sender, EventArgs e)
{
Process.Start(outputFolder);
ProcessHelper.ShellExecute(outputFolder);
}
}

Expand Down
17 changes: 17 additions & 0 deletions NAudioDemo/Utils/ProcessHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Diagnostics;

namespace NAudioDemo.Utils
{
static class ProcessHelper
{
public static void ShellExecute(string file)
{
var process = new Process();
process.StartInfo = new ProcessStartInfo(file)
{
UseShellExecute = true
};
process.Start();
}
}
}
4 changes: 2 additions & 2 deletions NAudioDemo/VolumeMixerDemo/VolumePanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ private void cmbDevice_SelectedIndexChanged(object sender, EventArgs e)
private void btnSoundProperties_Click(object sender, EventArgs e)
{
if (!devicePanel)
System.Diagnostics.Process.Start("control", "mmsys.cpl,,2");
Process.Start("control", "mmsys.cpl,,2");
else
System.Diagnostics.Process.Start("control", "mmsys.cpl,,0");
Process.Start("control", "mmsys.cpl,,0");
}

private void tbVolume_MouseCaptureChanged(object sender, EventArgs e)
Expand Down
14 changes: 12 additions & 2 deletions NAudioWpfDemo/WasapiCaptureDemo/RecordingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@ public RecordingsViewModel()

private void OpenFolder()
{
Process.Start(OutputFolder);
ShellExecute(OutputFolder);
}

private static void ShellExecute(string file)
{
var process = new Process();
process.StartInfo = new ProcessStartInfo(file)
{
UseShellExecute = true
};
process.Start();
}

private void Delete()
Expand All @@ -59,7 +69,7 @@ private void Play()
{
if (SelectedRecording != null)
{
Process.Start(Path.Combine(OutputFolder, SelectedRecording));
ShellExecute(Path.Combine(OutputFolder, SelectedRecording));
}
}

Expand Down

0 comments on commit 9bbd2bd

Please sign in to comment.