-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
4,476 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
## Ignore Visual Studio temporary files, build results, and | ||
## files generated by popular Visual Studio add-ons. | ||
|
||
# User-specific files | ||
*.suo | ||
*.user | ||
*.userosscache | ||
*.sln.docstates | ||
|
||
# User-specific files (MonoDevelop/Xamarin Studio) | ||
*.userprefs | ||
|
||
# Build results | ||
[Dd]ebug/ | ||
[Dd]ebugPublic/ | ||
[Rr]elease/ | ||
[Rr]eleases/ | ||
x64/ | ||
x86/ | ||
build/ | ||
bld/ | ||
[Bb]in/ | ||
[Oo]bj/ | ||
|
||
# Visual Studio 2015 cache/options directory | ||
.vs/ | ||
|
||
# MSTest test Results | ||
[Tt]est[Rr]esult*/ | ||
[Bb]uild[Ll]og.* | ||
|
||
# NUNIT | ||
*.VisualState.xml | ||
TestResult.xml | ||
|
||
# Build Results of an ATL Project | ||
[Dd]ebugPS/ | ||
[Rr]eleasePS/ | ||
dlldata.c | ||
|
||
# DNX | ||
project.lock.json | ||
artifacts/ | ||
|
||
*_i.c | ||
*_p.c | ||
*_i.h | ||
*.ilk | ||
*.meta | ||
*.obj | ||
*.pch | ||
*.pdb | ||
*.pgc | ||
*.pgd | ||
*.rsp | ||
*.sbr | ||
*.tlb | ||
*.tli | ||
*.tlh | ||
*.tmp | ||
*.tmp_proj | ||
*_wpftmp.csproj | ||
*.log | ||
*.vspscc | ||
*.vssscc | ||
.builds | ||
*.pidb | ||
*.svclog | ||
*.scc | ||
|
||
# Chutzpah Test files | ||
_Chutzpah* | ||
|
||
# Visual C++ cache files | ||
ipch/ | ||
*.aps | ||
*.ncb | ||
*.opensdf | ||
*.sdf | ||
*.cachefile | ||
*.VC.db | ||
*.vc.opendb | ||
|
||
# Visual Studio profiler | ||
*.psess | ||
*.vsp | ||
*.vspx | ||
|
||
# TFS 2012 Local Workspace | ||
$tf/ | ||
|
||
# Guidance Automation Toolkit | ||
*.gpState | ||
|
||
# ReSharper is a .NET coding add-in | ||
_ReSharper*/ | ||
*.[Rr]e[Ss]harper | ||
*.DotSettings.user | ||
|
||
# JustCode is a .NET coding add-in | ||
.JustCode | ||
|
||
# TeamCity is a build add-in | ||
_TeamCity* | ||
|
||
# DotCover is a Code Coverage Tool | ||
*.dotCover | ||
|
||
# NCrunch | ||
_NCrunch_* | ||
.*crunch*.local.xml | ||
|
||
# MightyMoose | ||
*.mm.* | ||
AutoTest.Net/ | ||
|
||
# Web workbench (sass) | ||
.sass-cache/ | ||
|
||
# Installshield output folder | ||
[Ee]xpress/ | ||
|
||
# DocProject is a documentation generator add-in | ||
DocProject/buildhelp/ | ||
DocProject/Help/*.HxT | ||
DocProject/Help/*.HxC | ||
DocProject/Help/*.hhc | ||
DocProject/Help/*.hhk | ||
DocProject/Help/*.hhp | ||
DocProject/Help/Html2 | ||
DocProject/Help/html | ||
|
||
# Click-Once directory | ||
publish/ | ||
|
||
# Publish Web Output | ||
*.[Pp]ublish.xml | ||
*.azurePubxml | ||
## TODO: Comment the next line if you want to checkin your | ||
## web deploy settings but do note that will include unencrypted | ||
## passwords | ||
#*.pubxml | ||
|
||
*.publishproj | ||
|
||
# NuGet Packages | ||
*.nupkg | ||
# The packages folder can be ignored because of Package Restore | ||
**/packages/* | ||
# except build/, which is used as an MSBuild target. | ||
!**/packages/build/ | ||
# Uncomment if necessary however generally it will be regenerated when needed | ||
#!**/packages/repositories.config | ||
|
||
# Windows Azure Build Output | ||
csx/ | ||
*.build.csdef | ||
|
||
# Windows Store app package directory | ||
AppPackages/ | ||
|
||
# Visual Studio cache files | ||
# files ending in .cache can be ignored | ||
*.[Cc]ache | ||
# but keep track of directories ending in .cache | ||
!*.[Cc]ache/ | ||
|
||
# Others | ||
ClientBin/ | ||
[Ss]tyle[Cc]op.* | ||
~$* | ||
*~ | ||
*.dbmdl | ||
*.dbproj.schemaview | ||
*.pfx | ||
*.publishsettings | ||
node_modules/ | ||
orleans.codegen.cs | ||
|
||
# RIA/Silverlight projects | ||
Generated_Code/ | ||
|
||
# Backup & report files from converting an old project file | ||
# to a newer Visual Studio version. Backup files are not needed, | ||
# because we have git ;-) | ||
_UpgradeReport_Files/ | ||
Backup*/ | ||
UpgradeLog*.XML | ||
UpgradeLog*.htm | ||
|
||
# SQL Server files | ||
*.mdf | ||
*.ldf | ||
|
||
# Business Intelligence projects | ||
*.rdl.data | ||
*.bim.layout | ||
*.bim_*.settings | ||
|
||
# Microsoft Fakes | ||
FakesAssemblies/ | ||
|
||
# Node.js Tools for Visual Studio | ||
.ntvs_analysis.dat | ||
|
||
# Visual Studio 6 build log | ||
*.plg | ||
|
||
# Visual Studio 6 workspace options file | ||
*.opt | ||
|
||
# LightSwitch generated files | ||
GeneratedArtifacts/ | ||
_Pvt_Extensions/ | ||
ModelManifest.xml | ||
|
||
# Sublime | ||
*.sublime-project | ||
*.sublime-workspace | ||
|
||
# Inno scripts | ||
*.iss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.31829.152 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MergeSynced", "MergeSynced\MergeSynced.csproj", "{AF9CD880-7333-424F-ABF8-1CBD5C650126}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{AF9CD880-7333-424F-ABF8-1CBD5C650126}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{AF9CD880-7333-424F-ABF8-1CBD5C650126}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{AF9CD880-7333-424F-ABF8-1CBD5C650126}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{AF9CD880-7333-424F-ABF8-1CBD5C650126}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {CB1B5859-70CE-48EE-AEA5-82D578EC85B1} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=MergeSynced_002EAnnotations/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Numerics; | ||
|
||
namespace MergeSynced | ||
{ | ||
public class Analysis | ||
{ | ||
/// <summary> | ||
/// https://stackoverflow.com/questions/70993291/calculate-the-crosscorrelation-of-two-vectors-more-efficiently | ||
/// https://dsp.stackexchange.com/questions/736/how-do-i-implement-cross-correlation-to-prove-two-audio-files-are-similar | ||
/// </summary> | ||
/// <param name="a">Dataset A</param> | ||
/// <param name="b">Dataset B</param> | ||
/// <param name="c">Cross correlation</param> | ||
/// <returns></returns> | ||
public static void CrossCorrelation(float[] a, float[] b, out float[] c) | ||
{ | ||
// Both arrays must be same size, if not, take smaller count | ||
int size = a.Length < b.Length ? a.Length : b.Length; | ||
|
||
// Convert data to complex type and calculate norm sqrt(sum(X.^2)) ////////// | ||
Complex[] aComp = new Complex[size]; | ||
Complex[] bComp = new Complex[size]; | ||
Complex normA = Complex.Zero; | ||
Complex normB = Complex.Zero; | ||
|
||
for (int i = 0; i < size; i++) | ||
{ | ||
aComp[i] = a[i]; | ||
bComp[i] = b[i]; | ||
|
||
normA += Complex.Pow(aComp[i], 2); | ||
normB += Complex.Pow(bComp[i], 2); | ||
} | ||
|
||
normA = Complex.Sqrt(normA); | ||
normB = Complex.Sqrt(normB); | ||
Complex multipliedNorm = Complex.Multiply(normA, normB); | ||
|
||
// Fourier transformation of A and B //////////////////////////////////////// | ||
//A | ||
Stopwatch sw = Stopwatch.StartNew(); | ||
MathNet.Numerics.IntegralTransforms.Fourier.Forward(aComp); | ||
Debug.WriteLine($"{sw.ElapsedMilliseconds}ms for first FFT"); | ||
sw.Restart(); | ||
|
||
//B | ||
MathNet.Numerics.IntegralTransforms.Fourier.Forward(bComp); | ||
Debug.WriteLine($"{sw.ElapsedMilliseconds}ms for second FFT"); | ||
sw.Restart(); | ||
|
||
// Complex conjugation of B ///////////////////////////////////////////////// | ||
for (int i = 0; i < size; i++) | ||
{ | ||
bComp[i] = Complex.Conjugate(bComp[i]); | ||
} | ||
Debug.WriteLine($"{sw.ElapsedMilliseconds}ms complex conjugation"); | ||
sw.Restart(); | ||
|
||
// Multiply FFTs //////////////////////////////////////////////////////////// | ||
Complex[] multipliedFft = new Complex[size]; | ||
for (int i = 0; i < size; i++) | ||
{ | ||
multipliedFft[i] = Complex.Multiply(aComp[i], bComp[i]); | ||
} | ||
Debug.WriteLine($"{sw.ElapsedMilliseconds}ms for multiply FFTs"); | ||
sw.Restart(); | ||
|
||
// Inverse FFT ////////////////////////////////////////////////////////////// | ||
MathNet.Numerics.IntegralTransforms.Fourier.Inverse(multipliedFft); | ||
Debug.WriteLine($"{sw.ElapsedMilliseconds}ms for inverse FFT"); | ||
sw.Reset(); | ||
|
||
// Norm and convert complex type back to input type ///////////////////////// | ||
c = new float[size]; | ||
for (int i = 0; i < size; i++) | ||
{ | ||
// Normalize to unity and use absolute values used to avoid | ||
// checking for min values to get correct peak, also don't care if phase shifted?! | ||
c[i] = Math.Abs(Convert.ToSingle(Complex.Divide(multipliedFft[i], multipliedNorm).Real)); | ||
//c[i] = Math.Abs(Convert.ToSingle(multipliedFft[i].Real)); | ||
} | ||
} | ||
|
||
public static double CalculateDelay(float[] corrData, int sampleRate) | ||
{ | ||
float max = corrData.Max(); | ||
int maxIndex = Array.IndexOf(corrData, max); | ||
double resFromLeft = (double)maxIndex / sampleRate; | ||
double resFromRight = (double)(corrData.Length - maxIndex) / sampleRate; | ||
Debug.WriteLine($"{resFromLeft}s _delay (from left)"); | ||
Debug.WriteLine($"{resFromRight}s _delay (from right)"); | ||
|
||
if (resFromLeft < resFromRight) return -1 * resFromLeft; | ||
return resFromRight; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /> | ||
</startup> | ||
<runtime> | ||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
<dependentAssembly> | ||
<assemblyIdentity name="ScottPlot" publicKeyToken="86698dc10387c39e" culture="neutral" /> | ||
<bindingRedirect oldVersion="0.0.0.0-4.1.36.0" newVersion="4.1.36.0" /> | ||
</dependentAssembly> | ||
</assemblyBinding> | ||
</runtime> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Application x:Class="MergeSynced.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:MergeSynced" | ||
StartupUri="MainWindow.xaml"> | ||
<Application.Resources> | ||
<!--To suppress: | ||
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, | ||
AncestorType='System.Windows.Controls.ItemsControl', AncestorLevel='1''. BindingExpression:Path=VerticalContentAlignment; | ||
DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'VerticalContentAlignment' (type 'VerticalAlignment') --> | ||
<Style TargetType="{x:Type ComboBoxItem}"> | ||
<Setter Property="HorizontalContentAlignment" Value="Left" /> | ||
<Setter Property="VerticalContentAlignment" Value="Center" /> | ||
</Style> | ||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Windows; | ||
|
||
namespace MergeSynced | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
} | ||
} |
Oops, something went wrong.