Skip to content

Commit

Permalink
Apply updates to Sanford.Multimedia.Midi, Version 1.1.0.2
Browse files Browse the repository at this point in the history
* Fixes Ppqn division issue.
* Ppqn no longer asserts in DEBUG.
* Migrate to new NuGet system.
* Rename License to License.md
  • Loading branch information
trigger-segfault committed Mar 26, 2019
1 parent d280491 commit 85a3ad3
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 48 deletions.
File renamed without changes.
1 change: 0 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ A midi player for Terrarian instruments such as the Harp and Bell. Terraria Midi
## About

* **Created By:** Robert Jordan
* **Version:** 1.1.0.1
* **Language:** C#, WPF

## Requirements for Running
Expand Down
5 changes: 4 additions & 1 deletion Sanford/Sanford.Multimedia.Midi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand All @@ -43,6 +43,7 @@
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<RunCodeAnalysis>False</RunCodeAnalysis>
<SourceAnalysisOverrideSettingsFile>C:\Users\TF\AppData\Roaming\ICSharpCode\SharpDevelop5\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
Expand All @@ -63,6 +64,7 @@
<WarningLevel>0</WarningLevel>
<DebugType>Full</DebugType>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
Expand All @@ -85,6 +87,7 @@
<WarningLevel>0</WarningLevel>
<DebugType>pdbonly</DebugType>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
9 changes: 2 additions & 7 deletions Sanford/Sanford.Multimedia.Midi/Clocks/PpqnClock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,8 @@ public int Ppqn
if(value < PpqnMinValue)
{
throw new ArgumentOutOfRangeException("Ppqn", value,
"Pulses per quarter note out of range.");
}
else if(value % PpqnMinValue != 0)
{
throw new ArgumentException(
"Pulses per quarter note is not a multiple of 24.");
}
"Pulses per quarter note is smaller than 24.");
}

#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,11 @@ public int Division
{
throw new ObjectDisposedException("OutputStream");
}
else if((value % PpqnClock.PpqnMinValue) != 0)
else if(value < PpqnClock.PpqnMinValue)
{
throw new ArgumentException();
}
throw new ArgumentOutOfRangeException("Ppqn", value,
"Pulses per quarter note is smaller than 24.");
}

#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,11 @@ public int Ppqn
{
#region Require

if(value % PpqnClock.PpqnMinValue != 0)
if(value < PpqnClock.PpqnMinValue)
{
throw new ArgumentException(
"Invalid pulses per quarter note value.");
}
throw new ArgumentOutOfRangeException("Ppqn", value,
"Pulses per quarter note is smaller than 24.");
}

#endregion

Expand Down
32 changes: 21 additions & 11 deletions Sanford/Sanford.Multimedia.Midi/Sequencing/MidiFileProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,22 @@ public void Read(Stream strm)

#endregion

format = trackCount = division = 0;
this.format = this.trackCount = this.division = 0;

FindHeader(strm);
Format = (int)ReadProperty(strm);
TrackCount = (int)ReadProperty(strm);
Division = (int)ReadProperty(strm);

FindHeader(strm);
int format = (int) ReadProperty(strm);
int trackCount = (int) ReadProperty(strm);
int division = (int) ReadProperty(strm);

// Division must be set first if Ppqn
Division = division;
Format = format;
TrackCount = trackCount;

//Format = (int)ReadProperty(strm);
//TrackCount = (int)ReadProperty(strm);
//Division = (int)ReadProperty(strm);

#region Invariant

Expand Down Expand Up @@ -245,7 +255,7 @@ private void AssertValid()
else
{
Debug.Assert(SequenceType == SequenceType.Ppqn);
Debug.Assert(Division % PpqnClock.PpqnMinValue == 0);
Debug.Assert(Division >= PpqnClock.PpqnMinValue);
}
}

Expand All @@ -259,7 +269,7 @@ public int Format
{
#region Require

if(value < 0 || value > 3)
if(value < 0 || value > 2)
{
throw new ArgumentOutOfRangeException("Format", value,
"MIDI file format out of range.");
Expand Down Expand Up @@ -347,11 +357,11 @@ public int Division
}
else
{
if(value % PpqnClock.PpqnMinValue != 0)
if(value < PpqnClock.PpqnMinValue)
{
throw new ArgumentException(
"Invalid pulses per quarter note value.");
}
throw new ArgumentOutOfRangeException("Ppqn", value,
"Pulses per quarter note is smaller than 24.");
}
else
{
sequenceType = SequenceType.Ppqn;
Expand Down
7 changes: 5 additions & 2 deletions TerrariaMidiPlayer.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.28307.421
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TerrariaMidiPlayer", "TerrariaMidiPlayer\TerrariaMidiPlayer.csproj", "{9562FE49-6292-413D-83DF-005E86AD82AE}"
EndProject
Expand All @@ -25,4 +25,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {148A791B-DB48-4AAD-B338-818DC3EECFF7}
EndGlobalSection
EndGlobal
2 changes: 0 additions & 2 deletions TerrariaMidiPlayer/Controls/TrackGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,7 @@ private struct TrackNote {
// Set guidelines for pixel perfection
GuidelineSet guidelines = new GuidelineSet();
guidelines.GuidelinesX.Add(0.5);
guidelines.GuidelinesX.Add(ActualHeight + 0.5);
guidelines.GuidelinesY.Add(0.5);
guidelines.GuidelinesY.Add(ActualWidth + 0.5);
d.PushGuidelineSet(guidelines);

// Highlight the midi's octave range
Expand Down
6 changes: 3 additions & 3 deletions TerrariaMidiPlayer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Trigger's Tools & Games")]
[assembly: AssemblyProduct("TerrariaMidiPlayer")]
[assembly: AssemblyCopyright("Copyright © Robert Jordan 2017")]
[assembly: AssemblyCopyright("Copyright © Robert Jordan {YEAR}")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down Expand Up @@ -51,8 +51,8 @@
// 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.1.0.1")]
[assembly: AssemblyFileVersion("1.1.0.1")]
[assembly: AssemblyVersion("1.1.0.2")]
[assembly: AssemblyFileVersion("1.1.0.2")]
[assembly: Guid("868163E6-E0A0-4035-AA63-3042476FD242")]
[assembly: NeutralResourcesLanguage("en-US")]

20 changes: 11 additions & 9 deletions TerrariaMidiPlayer/TerrariaMidiPlayer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@
<ApplicationIcon>App.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Gma.System.MouseKeyHook, Version=5.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MouseKeyHook.5.4.0\lib\net40\Gma.System.MouseKeyHook.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
Expand All @@ -59,10 +55,6 @@
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="Xceed.Wpf.Toolkit, Version=3.1.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.3.1\lib\net40\Xceed.Wpf.Toolkit.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
Expand Down Expand Up @@ -225,7 +217,6 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand Down Expand Up @@ -346,6 +337,17 @@
<ItemGroup>
<Resource Include="Resources\Icons\PianoSkip.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Extended.Wpf.Toolkit">
<Version>3.1.0</Version>
</PackageReference>
<PackageReference Include="MouseKeyHook">
<Version>5.4.0</Version>
</PackageReference>
<PackageReference Include="TriggersTools.Build.CopyrightYear">
<Version>1.0.2</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
5 changes: 0 additions & 5 deletions TerrariaMidiPlayer/packages.config

This file was deleted.

0 comments on commit 85a3ad3

Please sign in to comment.