From 4847c1088bc37f391661dcaf3df036be17c3fda4 Mon Sep 17 00:00:00 2001 From: towsey Date: Fri, 6 Sep 2019 18:06:24 +1000 Subject: [PATCH] Continue setting up Content description framework. Issue #252 Set up WindContent class to determine content of different kinds of wind sound. Set up a loop to cycle through the minutes of acoustic spectral indices. --- .../AudioAnalysisTools.csproj | 1 + .../ContentDescription.cs | 27 +++++++++++++++++++ .../ContentDescriptionTools/WindContent.cs | 21 +++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 src/AudioAnalysisTools/ContentDescriptionTools/WindContent.cs diff --git a/src/AudioAnalysisTools/AudioAnalysisTools.csproj b/src/AudioAnalysisTools/AudioAnalysisTools.csproj index d8880bd02..4bf873492 100644 --- a/src/AudioAnalysisTools/AudioAnalysisTools.csproj +++ b/src/AudioAnalysisTools/AudioAnalysisTools.csproj @@ -242,6 +242,7 @@ + diff --git a/src/AudioAnalysisTools/ContentDescriptionTools/ContentDescription.cs b/src/AudioAnalysisTools/ContentDescriptionTools/ContentDescription.cs index d0edff7eb..1a4ccbc20 100644 --- a/src/AudioAnalysisTools/ContentDescriptionTools/ContentDescription.cs +++ b/src/AudioAnalysisTools/ContentDescriptionTools/ContentDescription.cs @@ -136,10 +136,37 @@ public static double[] AnalyseMinutes(Dictionary dictionary) { int rowCount = dictionary[ContentDescription.IndexNames[0]].GetLength(0); int freqBinCount = dictionary[ContentDescription.IndexNames[0]].GetLength(1); + + // over all rows assuming one minute per row. + for (int i = 0; i < rowCount; i++) + { + var oneMinuteOfIndices = GetIndicesForOneMinute(dictionary, i); + + // now send indices to various content searches + var windScores = WindContent.GetStrongWindContent(oneMinuteOfIndices); + } + var scores = new double[rowCount]; return scores; } + public static Dictionary GetIndicesForOneMinute(Dictionary allIndices, int rowId) + { + var opIndices = new Dictionary(); + + var keys = allIndices.Keys; + foreach (string key in keys) + { + var success = allIndices.TryGetValue(key, out double[,] matrix); + if (success) + { + opIndices.Add(key, MatrixTools.GetRow(matrix, rowId)); + } + } + + return opIndices; + } + public static void DrawNormalisedIndexMatrices(DirectoryInfo dir, string baseName, Dictionary dictionary) { var list = new List(); diff --git a/src/AudioAnalysisTools/ContentDescriptionTools/WindContent.cs b/src/AudioAnalysisTools/ContentDescriptionTools/WindContent.cs new file mode 100644 index 000000000..e3f51dc7c --- /dev/null +++ b/src/AudioAnalysisTools/ContentDescriptionTools/WindContent.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AudioAnalysisTools.ContentDescriptionTools +{ + using TowseyLibrary; + + public static class WindContent + { + + public static double GetStrongWindContent(Dictionary oneMinuteOfIndices) + { + var rn = new RandomNumber(); + var score = rn.GetDouble(); + return score; + } + } +}