diff --git a/AcoustID/ChromaContext.cs b/AcoustID/ChromaContext.cs index 76fb99a..2eecb53 100644 --- a/AcoustID/ChromaContext.cs +++ b/AcoustID/ChromaContext.cs @@ -6,12 +6,9 @@ namespace AcoustID { - using System; - using System.Collections.Generic; - using System.Linq; - using System.Text; using AcoustID.Chromaprint; using AcoustID.Util; + using System; /// /// The main Chromaprint API. @@ -21,7 +18,7 @@ public class ChromaContext /// /// Return the version number of Chromaprint. /// - public static readonly string Version = "1.1.0"; + public static readonly string Version = "1.2.0"; Fingerprinter fingerprinter; int algorithm; diff --git a/AcoustID/Chromaprint/Image.cs b/AcoustID/Chromaprint/Image.cs index 082b9e8..0f7afb4 100644 --- a/AcoustID/Chromaprint/Image.cs +++ b/AcoustID/Chromaprint/Image.cs @@ -13,6 +13,9 @@ namespace AcoustID.Chromaprint /// public class Image { + private const int BUFFER_BLOCK_SIZE = 2048; + + private int m_rows; private int m_columns; private double[] m_data; @@ -23,7 +26,7 @@ public int Columns public int Rows { - get { return m_data.Length / m_columns; } + get { return m_rows; } } public double this[int i, int j] @@ -44,12 +47,14 @@ public Image(int columns) public Image(int columns, int rows) { + m_rows = rows; m_columns = columns; - m_data = new double[columns * rows]; + m_data = new double[Math.Max(columns * rows, BUFFER_BLOCK_SIZE)]; } - + public Image(int columns, double[] data) { + m_rows = data.Length / columns; m_columns = columns; m_data = data; } @@ -66,13 +71,21 @@ internal void Set(int i, int j, double value) internal void AddRow(double[] row) { - int n = m_data.Length; - Array.Resize(ref m_data, n + m_columns); + int n = m_rows * m_columns; + + int size = m_data.Length; + + if (n + m_columns > size) + { + Array.Resize(ref m_data, size + BUFFER_BLOCK_SIZE); + } for (int i = 0; i < m_columns; i++) { m_data[n + i] = row[i]; } + + m_rows++; } internal double[] Row(int i) diff --git a/AcoustID/Configuration.cs b/AcoustID/Configuration.cs index aaddbfd..efaa014 100644 --- a/AcoustID/Configuration.cs +++ b/AcoustID/Configuration.cs @@ -1,17 +1,15 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - + namespace AcoustID { + using System; + public class Configuration { /// /// The API key for using the AcoustID webservice. /// /// - /// Visit http://acoustid.org/ to get an API key for your application. + /// Visit https://acoustid.org/ to get an API key for your application. /// public static string ApiKey = String.Empty; }