Skip to content

Commit

Permalink
Filtro corretto
Browse files Browse the repository at this point in the history
  • Loading branch information
gpicchiarelli committed Dec 9, 2023
1 parent 423932a commit 38fad1f
Show file tree
Hide file tree
Showing 37 changed files with 168 additions and 19 deletions.
21 changes: 5 additions & 16 deletions AccordaGUItar/Audio/Audio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ private double CalculateFrequencyFromFFT(double[] buffer)
.OrderByDescending(x => x.Value)
.First().Index;

double frequency = indexOfMaxValue * sampleRate / buffer.Length;
return frequency;
double fundamentalFrequency = indexOfMaxValue * sampleRate / buffer.Length;

// Trova la prima armonica
return fundamentalFrequency;
}

private void WaveIn_DataAvailable(object sender, WaveInEventArgs e)
Expand All @@ -66,7 +68,7 @@ private void WaveIn_DataAvailable(object sender, WaveInEventArgs e)
if (maxVolume > volumeThreshold)
{
double frequency = CalculateFrequencyFromFFT(buffer);
float cutoffFrequency = (float)(frequency * 0.3); // filtraggio
float cutoffFrequency = (float)(frequency * 0.1); // filtraggio

BiQuadFilter filter = BiQuadFilter.LowPassFilter(sampleRate, cutoffFrequency, 1.0f);
for (int i = 0; i < buffer.Length; i++)
Expand All @@ -90,19 +92,6 @@ public List<string> ElencaDispositiviIngresso()
return dispositivi;
}

private double[] CalculateAutocorrelation(double[] buffer)
{
double[] autocorrelation = new double[buffer.Length];
for (int lag = 0; lag < buffer.Length; lag++)
{
for (int i = 0; i < buffer.Length - lag; i++)
{
autocorrelation[lag] += buffer[i] * buffer[i + lag];
}
}
return autocorrelation;
}

private void StartRecording()
{
waveIn.StartRecording();
Expand Down
Binary file modified AccordaGUItar/bin/Debug/net8.0-windows7.0/AccordaGUItar.dll
Binary file not shown.
Binary file modified AccordaGUItar/bin/Debug/net8.0-windows7.0/AccordaGUItar.exe
Binary file not shown.
Binary file modified AccordaGUItar/bin/Debug/net8.0-windows7.0/AccordaGUItar.pdb
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[assembly: System.Reflection.AssemblyCompanyAttribute("AccordaGUItar")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1c2d8ba0406a79032ef1ca5f04a4d8bc352998e3")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+423932ab85a031c1c9e1217ac4ce828c855ceeed")]
[assembly: System.Reflection.AssemblyProductAttribute("AccordaGUItar")]
[assembly: System.Reflection.AssemblyTitleAttribute("AccordaGUItar")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
01e2783b3992a43aef24da379b388bc0ec2427e2447eac33aabf0ff575ce792f
5957dd53353ba02abe1c70c51b2093ce0093b42fac294f0073ad70f8bde38acf
Binary file modified AccordaGUItar/obj/Debug/net8.0-windows7.0/AccordaGUItar.dll
Binary file not shown.
Binary file modified AccordaGUItar/obj/Debug/net8.0-windows7.0/AccordaGUItar.pdb
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"documents":{"C:\\Users\\Giacomo\\source\\repos\\accorda\\*":"https://raw.githubusercontent.com/gpicchiarelli/accorda/1c2d8ba0406a79032ef1ca5f04a4d8bc352998e3/*"}}
{"documents":{"C:\\Users\\Giacomo\\source\\repos\\accorda\\*":"https://raw.githubusercontent.com/gpicchiarelli/accorda/423932ab85a031c1c9e1217ac4ce828c855ceeed/*"}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Il codice è stato generato da uno strumento.
// Versione runtime:4.0.30319.42000
//
// Le modifiche apportate a questo file possono provocare un comportamento non corretto e andranno perse se
// il codice viene rigenerato.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("AccordaGUItar")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+423932ab85a031c1c9e1217ac4ce828c855ceeed")]
[assembly: System.Reflection.AssemblyProductAttribute("AccordaGUItar")]
[assembly: System.Reflection.AssemblyTitleAttribute("AccordaGUItar")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
[assembly: System.Runtime.Versioning.TargetPlatformAttribute("Windows7.0")]
[assembly: System.Runtime.Versioning.SupportedOSPlatformAttribute("Windows7.0")]

// Generato dalla classe WriteCodeFragment di MSBuild.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5957dd53353ba02abe1c70c51b2093ce0093b42fac294f0073ad70f8bde38acf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
is_global = true
build_property.TargetFramework = net8.0-windows7.0
build_property.TargetPlatformMinVersion = 7.0
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = AccordaGUItar_2r35qcdd_wpftmp
build_property.ProjectDir = C:\Users\Giacomo\source\repos\accorda\AccordaGUItar\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"documents":{"C:\\Users\\Giacomo\\source\\repos\\accorda\\*":"https://raw.githubusercontent.com/gpicchiarelli/accorda/423932ab85a031c1c9e1217ac4ce828c855ceeed/*"}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Il codice è stato generato da uno strumento.
// Versione runtime:4.0.30319.42000
//
// Le modifiche apportate a questo file possono provocare un comportamento non corretto e andranno perse se
// il codice viene rigenerato.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("AccordaGUItar")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+423932ab85a031c1c9e1217ac4ce828c855ceeed")]
[assembly: System.Reflection.AssemblyProductAttribute("AccordaGUItar")]
[assembly: System.Reflection.AssemblyTitleAttribute("AccordaGUItar")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
[assembly: System.Runtime.Versioning.TargetPlatformAttribute("Windows7.0")]
[assembly: System.Runtime.Versioning.SupportedOSPlatformAttribute("Windows7.0")]

// Generato dalla classe WriteCodeFragment di MSBuild.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5957dd53353ba02abe1c70c51b2093ce0093b42fac294f0073ad70f8bde38acf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
is_global = true
build_property.TargetFramework = net8.0-windows7.0
build_property.TargetPlatformMinVersion = 7.0
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = AccordaGUItar_cdg3mu2m_wpftmp
build_property.ProjectDir = C:\Users\Giacomo\source\repos\accorda\AccordaGUItar\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"documents":{"C:\\Users\\Giacomo\\source\\repos\\accorda\\*":"https://raw.githubusercontent.com/gpicchiarelli/accorda/423932ab85a031c1c9e1217ac4ce828c855ceeed/*"}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Il codice è stato generato da uno strumento.
// Versione runtime:4.0.30319.42000
//
// Le modifiche apportate a questo file possono provocare un comportamento non corretto e andranno perse se
// il codice viene rigenerato.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("AccordaGUItar")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+423932ab85a031c1c9e1217ac4ce828c855ceeed")]
[assembly: System.Reflection.AssemblyProductAttribute("AccordaGUItar")]
[assembly: System.Reflection.AssemblyTitleAttribute("AccordaGUItar")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
[assembly: System.Runtime.Versioning.TargetPlatformAttribute("Windows7.0")]
[assembly: System.Runtime.Versioning.SupportedOSPlatformAttribute("Windows7.0")]

// Generato dalla classe WriteCodeFragment di MSBuild.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5957dd53353ba02abe1c70c51b2093ce0093b42fac294f0073ad70f8bde38acf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
is_global = true
build_property.TargetFramework = net8.0-windows7.0
build_property.TargetPlatformMinVersion = 7.0
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = AccordaGUItar_mohhar3v_wpftmp
build_property.ProjectDir = C:\Users\Giacomo\source\repos\accorda\AccordaGUItar\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"documents":{"C:\\Users\\Giacomo\\source\\repos\\accorda\\*":"https://raw.githubusercontent.com/gpicchiarelli/accorda/423932ab85a031c1c9e1217ac4ce828c855ceeed/*"}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Il codice è stato generato da uno strumento.
// Versione runtime:4.0.30319.42000
//
// Le modifiche apportate a questo file possono provocare un comportamento non corretto e andranno perse se
// il codice viene rigenerato.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("AccordaGUItar")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+423932ab85a031c1c9e1217ac4ce828c855ceeed")]
[assembly: System.Reflection.AssemblyProductAttribute("AccordaGUItar")]
[assembly: System.Reflection.AssemblyTitleAttribute("AccordaGUItar")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
[assembly: System.Runtime.Versioning.TargetPlatformAttribute("Windows7.0")]
[assembly: System.Runtime.Versioning.SupportedOSPlatformAttribute("Windows7.0")]

// Generato dalla classe WriteCodeFragment di MSBuild.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5957dd53353ba02abe1c70c51b2093ce0093b42fac294f0073ad70f8bde38acf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
is_global = true
build_property.TargetFramework = net8.0-windows7.0
build_property.TargetPlatformMinVersion = 7.0
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = AccordaGUItar_xt1zdsq0_wpftmp
build_property.ProjectDir = C:\Users\Giacomo\source\repos\accorda\AccordaGUItar\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"documents":{"C:\\Users\\Giacomo\\source\\repos\\accorda\\*":"https://raw.githubusercontent.com/gpicchiarelli/accorda/423932ab85a031c1c9e1217ac4ce828c855ceeed/*"}}
Binary file modified AccordaGUItar/obj/Debug/net8.0-windows7.0/apphost.exe
Binary file not shown.
Binary file modified AccordaGUItar/obj/Debug/net8.0-windows7.0/ref/AccordaGUItar.dll
Binary file not shown.
Binary file not shown.
Binary file modified accorda.net/.vs/Accorda/v17/.suo
Binary file not shown.

0 comments on commit 38fad1f

Please sign in to comment.