Skip to content

Commit

Permalink
- Fix wrong sound volume control
Browse files Browse the repository at this point in the history
- Upgraded to .NET Framework 4.8
- Test Application with x64 support
  • Loading branch information
Sascha Lange committed Mar 5, 2024
1 parent 0166955 commit a1b8f56
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 30 deletions.
19 changes: 15 additions & 4 deletions Source/DirectShow/MediaPlayers/BaseClasses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,16 @@ public virtual double Volume
m_basicAudio.get_Volume(out dShowVolume);

/* Do calulations to convert to a base of 0 for silence */
dShowVolume -= DSHOW_VOLUME_SILENCE;
return (double)dShowVolume / -DSHOW_VOLUME_SILENCE;
if (dShowVolume <= DSHOW_VOLUME_SILENCE)
return 0.0;
else if (dShowVolume >= DSHOW_VOLUME_MAX)
return 1.0;
else
{
return Math.Pow(10, ((double)dShowVolume / 20 / 100));
}


}
set
{
Expand All @@ -413,7 +421,10 @@ public virtual double Volume
* for silence and DSHOW_VOLUME_MAX for full volume
* so we calculate that here based off an input of 0 of silence and 1.0
* for full audio */
int dShowVolume = (int)((1 - value) * DSHOW_VOLUME_SILENCE);

//int dShowVolume = (int)((1 - value) * DSHOW_VOLUME_SILENCE);

int dShowVolume = (int)(20 * Math.Log10(value) * 100);
m_basicAudio.put_Volume(dShowVolume);
}
}
Expand Down Expand Up @@ -857,7 +868,7 @@ private IBaseFilter CreateEnhancedVideoRenderer(IGraphBuilder graph, int streamC
{
var evr = new EnhancedVideoRenderer();
filter = evr as IBaseFilter;

int hr = graph.AddFilter(filter, string.Format("Renderer: {0}", VideoRendererType.EnhancedVideoRenderer));
DsError.ThrowExceptionForHR(hr);

Expand Down
4 changes: 2 additions & 2 deletions Source/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("WPF MediaKit Team")]
[assembly: AssemblyProduct("WPF MediaKit")]
[assembly: AssemblyCopyright("Copyright © 2015-2017 by WPF MediaKit Team")]
[assembly: AssemblyCopyright("Copyright © 2015-2024 by WPF MediaKit Team")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -25,4 +25,4 @@



[assembly: AssemblyVersion("2.2.0")]
[assembly: AssemblyVersion("2.3.0")]
4 changes: 2 additions & 2 deletions Source/Properties/Resources.Designer.cs

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

4 changes: 2 additions & 2 deletions Source/Properties/Settings.Designer.cs

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

2 changes: 1 addition & 1 deletion Source/WPF MediaKit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WPFMediaKit</RootNamespace>
<AssemblyName>WPFMediaKit</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
Expand Down
Binary file modified Test Application/EVRPresenter32.dll
Binary file not shown.
Binary file added Test Application/EVRPresenter64.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion Test Application/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Test Application")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
16 changes: 8 additions & 8 deletions Test Application/Properties/Resources.Designer.cs

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

10 changes: 5 additions & 5 deletions Test Application/Properties/Settings.Designer.cs

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

34 changes: 32 additions & 2 deletions Test Application/Test Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,29 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Test_Application</RootNamespace>
<AssemblyName>Test Application</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x86</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
Expand Down Expand Up @@ -106,6 +121,21 @@
<Content Include="EVRPresenter32.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="EVRPresenter64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.8 %28x86 und x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
2 changes: 1 addition & 1 deletion Test Application/app.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
4 changes: 2 additions & 2 deletions nuget/Package.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<package >
<metadata>
<id>WPFMediaKit</id>
<version>2.2.0</version>
<version>2.3.0</version>
<authors>WPF MediaKit Team</authors>
<owners>WPF MediaKit Team</owners>
<licenseUrl>https://github.com/Sascha-L/WPF-MediaKit/blob/master/License.txt</licenseUrl>
<projectUrl>https://github.com/Sascha-L/WPF-MediaKit</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A library to quickly build DirectShow and MediaFoundation media player controls in WPF. The kit comes with a MediaElement replacement, a VideoCaptureElement for web cams and a DVDPlayerElement that plays DVDs and supports interactive menus.</description>
<releaseNotes>Some bugfixes and performance improvements.</releaseNotes>
<copyright>Copyright © 2015-2017 by WPF MediaKit Team</copyright>
<copyright>Copyright © 2015-2024 by WPF MediaKit Team</copyright>
<tags>wpf video directshow evr dvd player media MediaFoundation</tags>
</metadata>
<files>
Expand Down

0 comments on commit a1b8f56

Please sign in to comment.