Skip to content

Commit

Permalink
Merge pull request #20 from micahmo/release/v1.10.1
Browse files Browse the repository at this point in the history
Release/v1.10.1
  • Loading branch information
micahmo authored Apr 14, 2023
2 parents 9f2e96c + a277f56 commit 838ba40
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 44 deletions.
17 changes: 16 additions & 1 deletion SoundBoard/Buttons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -922,9 +922,24 @@ private void SoundPathMenuItem_Click(object sender, RoutedEventArgs e)
Process.Start("explorer.exe", $"/select, \"{SoundPath}\"");
}

private static readonly IEnumerable<Color> _defaultPalette = (IEnumerable<Color>)typeof(ColorPickerDialog)
.GetField("DefaultPalette", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static)?
.GetValue(null) ?? Enumerable.Empty<Color>();

private void SetColorMenuItem_Click(object sender, RoutedEventArgs e)
{
ColorPickerDialog colorPickerDialog = new ColorPickerDialog(Color ?? Colors.White) { ShowTransparencyPicker = false };
var palette = MainWindow.Instance.GetSoundButtons().Where(sb => sb.Color != null).Select(sb => sb.Color.Value) // Existing colors
.Concat(_defaultPalette) // The default palette
.Distinct(); // Remove dupes

ColorPickerDialog colorPickerDialog = new ColorPickerDialog(Color ?? Colors.White, palette)
{
Width = 584,
Height = 491,
ResizeMode = ResizeMode.NoResize,
WindowStyle = WindowStyle.ToolWindow,
ShowTransparencyPicker = false
};

if (colorPickerDialog.ShowDialog() == true)
{
Expand Down
96 changes: 75 additions & 21 deletions SoundBoard/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1576,35 +1576,89 @@ private void HandleInputOutputChange()

if (GlobalSettings.GetInputDeviceGuids().Any())
{
Guid inputDeviceId = GlobalSettings.GetInputDeviceGuids().First();

foreach (var outputDeviceId in GlobalSettings.GetOutputDeviceGuids())
{
// Create the input
Guid inputDeviceId = GlobalSettings.GetInputDeviceGuids().First();
MMDevice inputDevice = Utilities.GetDevice(inputDeviceId, DataFlow.Capture);
WasapiCapture inputCapture = new WasapiCapture(inputDevice);
inputCapture.RecordingStopped += HandleRecordingStopped;
_inputCaptures.Add(inputCapture);

// Create the buffer
BufferedWaveProvider bufferedWaveProvider = new BufferedWaveProvider(inputDevice.AudioClient.MixFormat)
try
{
DiscardOnBufferOverflow = true
};
_bufferedWaveProviders.Add(bufferedWaveProvider);
// Create the input
MMDevice inputDevice = Utilities.GetDevice(inputDeviceId, DataFlow.Capture);
WasapiCapture inputCapture = new WasapiCapture(inputDevice);
inputCapture.RecordingStopped += HandleRecordingStopped;
_inputCaptures.Add(inputCapture);

// Create the buffer
BufferedWaveProvider bufferedWaveProvider = new BufferedWaveProvider(inputDevice.AudioClient.MixFormat)
{
DiscardOnBufferOverflow = true
};
_bufferedWaveProviders.Add(bufferedWaveProvider);

inputCapture.DataAvailable += (_, args) =>
{
bufferedWaveProvider.AddSamples(args.Buffer, 0, args.BytesRecorded);
};

inputCapture.DataAvailable += (_, args) =>
// Create the outputs
WasapiOut output = new WasapiOut(Utilities.GetDevice(outputDeviceId, DataFlow.Render), AudioClientShareMode.Shared, true, GlobalSettings.AudioPassthroughLatency);
_outputCaptures.Add(output);

output.Init(bufferedWaveProvider);
output.Play();

inputCapture.StartRecording();
}
catch (Exception ex)
{
bufferedWaveProvider.AddSamples(args.Buffer, 0, args.BytesRecorded);
};
HandleRecordingStopped(this, new StoppedEventArgs());

// Create the outputs
WasapiOut output = new WasapiOut(Utilities.GetDevice(outputDeviceId, DataFlow.Render), AudioClientShareMode.Shared, true, GlobalSettings.AudioPassthroughLatency);
_outputCaptures.Add(output);
Dispatcher.Invoke(async () =>
{
// Try to get the friendly input/output device names.
string inputDeviceName = Properties.Resources.UNKNOWN;
string outputDeviceName = Properties.Resources.UNKNOWN;
try
{
inputDeviceName = Utilities.GetDevice(inputDeviceId, DataFlow.Capture).FriendlyName;
}
catch {}
try
{
outputDeviceName = Utilities.GetDevice(outputDeviceId, DataFlow.Render).FriendlyName;
}
catch {}

string error = string.Format(Properties.Resources.AudioPassthroughError, inputDeviceName, outputDeviceName);

if (ex is COMException comException)
{
if (comException.ErrorCode == -2004287478)
{
// This is a specific error we know about which means the output device is being held exclusively.
error += $"{Environment.NewLine}{Environment.NewLine}{Properties.Resources.AudioPassthroughOutputExclusiveError}";
}

error += $"{Environment.NewLine}{Environment.NewLine}{string.Format(Properties.Resources.ComErrorCode, comException.ErrorCode)}";
}

output.Init(bufferedWaveProvider);
output.Play();
string fullError = $"{error}{Environment.NewLine}{Environment.NewLine}{ex}";

inputCapture.StartRecording();
var res = await this.ShowMessageAsync(Properties.Resources.Error, error,
MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings
{
AffirmativeButtonText = Properties.Resources.CopyDetails,
NegativeButtonText = Properties.Resources.OK
});

if (res == MessageDialogResult.Affirmative)
{
Clipboard.SetText(fullError);
}
});

return;
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions SoundBoard/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// 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.10.0.2")]
[assembly: AssemblyFileVersion("1.10.0.2")]
[assembly: AssemblyVersion("1.10.1.0")]
[assembly: AssemblyFileVersion("1.10.1.0")]
36 changes: 36 additions & 0 deletions SoundBoard/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions SoundBoard/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -380,4 +380,16 @@ Global Hotkey: {1}</value>
<data name="ChangeDefaultButtonGrid" xml:space="preserve">
<value>Change Default Button Grid</value>
</data>
<data name="UNKNOWN" xml:space="preserve">
<value>UNKNOWN</value>
</data>
<data name="AudioPassthroughError" xml:space="preserve">
<value>There was an error opening the input ({0}) or output ({1}) audio device for audio passthrough.</value>
</data>
<data name="ComErrorCode" xml:space="preserve">
<value>Error code: 0x{0:X}</value>
</data>
<data name="AudioPassthroughOutputExclusiveError" xml:space="preserve">
<value>The output audio device is being used exclusively by another application.</value>
</data>
</root>
8 changes: 4 additions & 4 deletions SoundBoard/SoundBoard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
<ApplicationIcon>.\icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="AppHelpers.WPF, Version=0.1.0.12, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\AppHelpers.WPF.0.1.0-rc3\lib\net45\AppHelpers.WPF.dll</HintPath>
<Reference Include="AppHelpers.WPF, Version=0.1.0.14, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\AppHelpers.WPF.0.1.0\lib\net45\AppHelpers.WPF.dll</HintPath>
</Reference>
<Reference Include="ControlzEx, Version=3.0.2.4, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ControlzEx.3.0.2.4\lib\net462\ControlzEx.dll</HintPath>
Expand Down Expand Up @@ -81,8 +81,8 @@
<Reference Include="NAudio, Version=1.9.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NAudio.1.9.0\lib\net35\NAudio.dll</HintPath>
</Reference>
<Reference Include="PortableSettingsProvider, Version=0.2.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\PortableSettingsProvider.0.2.3\lib\net45\PortableSettingsProvider.dll</HintPath>
<Reference Include="PortableSettingsProvider, Version=0.2.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\PortableSettingsProvider.0.2.4\lib\net45\PortableSettingsProvider.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
Expand Down
20 changes: 6 additions & 14 deletions SoundBoard/VersionInfo.xml
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<AppUpdate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/micahmo/SoundBoard/master/SoundBoard/AppUpdate.xsd">
<Version>1.10.0.2</Version>
<ReleaseDate>2023-03-10</ReleaseDate>
<Version>1.10.1.0</Version>
<ReleaseDate>2023-04-14</ReleaseDate>
<!-- Default download -->
<DownloadLink>https://github.com/micahmo/SoundBoard/releases/download/v1.10.0/SoundBoard.exe</DownloadLink>
<DownloadLink>https://github.com/micahmo/SoundBoard/releases/download/v1.10.1/SoundBoard.exe</DownloadLink>
<DownloadFileName>SoundBoard.exe</DownloadFileName>
<!-- All download options -->
<Downloads>
<Download key="portable">
<Link>https://github.com/micahmo/SoundBoard/releases/download/v1.10.0/SoundBoard.exe</Link>
<Link>https://github.com/micahmo/SoundBoard/releases/download/v1.10.1/SoundBoard.exe</Link>
<FileName>SoundBoard.exe</FileName>
<FileHash></FileHash>
</Download>
</Downloads>
<!-- Release notes -->
<VersionNotes> - Audio recording device can be passed through to an audio playback device (#18)
- Hotkeys can be assigned to sounds
- Multiple sounds or a whole folder can be added at once
- Select sounds with Control- or Shift-Click to update or play multiple at once
- Sounds can be configured to stop all other sounds when played
- Sound names are more readable at different sizes (#17)
- Tabs with currently playing sounds will now be clearly indicated
- Sounds can trigger other sounds, allowing chaining
- The default grid layout for new pages can be configured
- General bug fixes and improvements</VersionNotes>
<VersionNotes> - Improve color picker
- Handle audio passthrough errors</VersionNotes>
<ReleaseNotes></ReleaseNotes>
</AppUpdate>
4 changes: 2 additions & 2 deletions SoundBoard/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AppHelpers.WPF" version="0.1.0-rc3" targetFramework="net48" />
<package id="AppHelpers.WPF" version="0.1.0" targetFramework="net48" />
<package id="ControlzEx" version="3.0.2.4" targetFramework="net472" />
<package id="Costura.Fody" version="4.0.0" targetFramework="net472" developmentDependency="true" />
<package id="Extended.Wpf.Toolkit" version="3.5.0" targetFramework="net472" />
Expand All @@ -13,7 +13,7 @@
<package id="NAudio" version="1.9.0" targetFramework="net472" />
<package id="NHotkey" version="2.1.0" targetFramework="net48" />
<package id="NHotkey.Wpf" version="2.1.0" targetFramework="net48" />
<package id="PortableSettingsProvider" version="0.2.3" targetFramework="net48" />
<package id="PortableSettingsProvider" version="0.2.4" targetFramework="net48" />
<package id="System.Reactive" version="5.0.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
Expand Down

0 comments on commit 838ba40

Please sign in to comment.