Skip to content

Commit a1b8f56

Browse files
author
Sascha Lange
committed
- Fix wrong sound volume control
- Upgraded to .NET Framework 4.8 - Test Application with x64 support
1 parent 0166955 commit a1b8f56

File tree

13 files changed

+71
-30
lines changed

13 files changed

+71
-30
lines changed

Source/DirectShow/MediaPlayers/BaseClasses.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,16 @@ public virtual double Volume
391391
m_basicAudio.get_Volume(out dShowVolume);
392392

393393
/* Do calulations to convert to a base of 0 for silence */
394-
dShowVolume -= DSHOW_VOLUME_SILENCE;
395-
return (double)dShowVolume / -DSHOW_VOLUME_SILENCE;
394+
if (dShowVolume <= DSHOW_VOLUME_SILENCE)
395+
return 0.0;
396+
else if (dShowVolume >= DSHOW_VOLUME_MAX)
397+
return 1.0;
398+
else
399+
{
400+
return Math.Pow(10, ((double)dShowVolume / 20 / 100));
401+
}
402+
403+
396404
}
397405
set
398406
{
@@ -413,7 +421,10 @@ public virtual double Volume
413421
* for silence and DSHOW_VOLUME_MAX for full volume
414422
* so we calculate that here based off an input of 0 of silence and 1.0
415423
* for full audio */
416-
int dShowVolume = (int)((1 - value) * DSHOW_VOLUME_SILENCE);
424+
425+
//int dShowVolume = (int)((1 - value) * DSHOW_VOLUME_SILENCE);
426+
427+
int dShowVolume = (int)(20 * Math.Log10(value) * 100);
417428
m_basicAudio.put_Volume(dShowVolume);
418429
}
419430
}
@@ -857,7 +868,7 @@ private IBaseFilter CreateEnhancedVideoRenderer(IGraphBuilder graph, int streamC
857868
{
858869
var evr = new EnhancedVideoRenderer();
859870
filter = evr as IBaseFilter;
860-
871+
861872
int hr = graph.AddFilter(filter, string.Format("Renderer: {0}", VideoRendererType.EnhancedVideoRenderer));
862873
DsError.ThrowExceptionForHR(hr);
863874

Source/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[assembly: AssemblyConfiguration("")]
99
[assembly: AssemblyCompany("WPF MediaKit Team")]
1010
[assembly: AssemblyProduct("WPF MediaKit")]
11-
[assembly: AssemblyCopyright("Copyright © 2015-2017 by WPF MediaKit Team")]
11+
[assembly: AssemblyCopyright("Copyright © 2015-2024 by WPF MediaKit Team")]
1212
[assembly: AssemblyTrademark("")]
1313
[assembly: AssemblyCulture("")]
1414

@@ -25,4 +25,4 @@
2525

2626

2727

28-
[assembly: AssemblyVersion("2.2.0")]
28+
[assembly: AssemblyVersion("2.3.0")]

Source/Properties/Resources.Designer.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/Properties/Settings.Designer.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/WPF MediaKit.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>WPFMediaKit</RootNamespace>
1111
<AssemblyName>WPFMediaKit</AssemblyName>
12-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
12+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
1515
<WarningLevel>4</WarningLevel>

Test Application/EVRPresenter32.dll

3 KB
Binary file not shown.

Test Application/EVRPresenter64.dll

53 KB
Binary file not shown.

Test Application/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
[assembly: AssemblyConfiguration("")]
1313
[assembly: AssemblyCompany("")]
1414
[assembly: AssemblyProduct("Test Application")]
15-
[assembly: AssemblyCopyright("Copyright © 2015")]
15+
[assembly: AssemblyCopyright("Copyright © 2024")]
1616
[assembly: AssemblyTrademark("")]
1717
[assembly: AssemblyCulture("")]
1818

Test Application/Properties/Resources.Designer.cs

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Test Application/Properties/Settings.Designer.cs

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)