public WithMirageSpriteBody(ActorInitializer init, WithMirageSpriteBodyInfo info)
            : base(init, info)
        {
            this.info = info;
            var self = init.Self;

            renderSprites = self.Trait <RenderSprites>();
            mirage        = self.Trait <Mirage>();
        }
예제 #2
0
파일: DataParser.cs 프로젝트: h0rm/No.Noise
        /// <summary>
        /// Converts a Mirage.Vector to a string representation with semicolons
        /// instead of commas.
        /// </summary>
        /// <param name="v">
        /// The <see cref="Mirage.Vector"/> to be converted
        /// </param>
        /// <returns>
        /// A <see cref="System.String"/> representation of the vector
        /// </returns>
        public static string MirageVectorToString (Mirage.Vector v)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append ("[");

            for (int i = 0; i < v.rows; i++) {
                if (i != 0)
                    sb.Append (";");
                sb.Append (v.d [i, 0].ToString (System.Globalization.CultureInfo.InvariantCulture));
            }
            sb.Append ("]");
            return sb.ToString ();
        }
예제 #3
0
        public bool InsertVector(Mirage.Vector v, int bid)
        {
            IDbCommand dbcmd = null;
            try {
                dbcon.Open();
                dbcmd = dbcon.CreateCommand();

                dbcmd.CommandText = string.Format("INSERT INTO MIRData (banshee_id, data) VALUES ('{0}', '{1}')",
                                                  bid, DataParser.MirageVectorToString(v));
                dbcmd.ExecuteNonQuery ();
            } catch (Exception e) {
                Log.Exception("NoNoise/DB - Mirage.Vector insert failed", e);
                return false;
            } finally {
                if (dbcmd != null)
                    dbcmd.Dispose();
                dbcmd = null;
                if (dbcon != null)
                    dbcon.Close();
            }

            return true;
        }
예제 #4
0
        /// <summary>
        /// Computes the median for each row of the MFCC matrix.
        /// </summary>
        /// <param name="mfcc">
        /// The MFCC <see cref="Mirage.Matrix"/>
        /// </param>
        /// <returns>
        /// A <see cref="Mirage.Vector"/> containing the median
        /// vector of the MFCC matrix
        /// </returns>
        private Mirage.Vector ConvertMfccToMedian (Mirage.Matrix mfcc)
        {
            Mirage.Vector data = new Mirage.Vector (mfcc.rows);

            for (int i = 0; i < mfcc.rows; i++) {
                float [] r = new float [mfcc.columns];

                for (int j = 0; j < mfcc.columns; j++) {
                    r [j] = mfcc.d [i, j];
                }

                Array.Sort<float> (r);
                data.d [i, 0] = r [r.Length / 2];
            }

            return data;
        }
예제 #5
0
        /// <summary>
        /// Computes the minimum for each row of the MFCC matrix.
        /// </summary>
        /// <param name="mfcc">
        /// The MFCC <see cref="Mirage.Matrix"/>
        /// </param>
        /// <returns>
        /// A <see cref="Mirage.Vector"/> containing the minimum
        /// vector of the MFCC matrix
        /// </returns>
        private Mirage.Vector ConvertMfccToMin (Mirage.Matrix mfcc)
        {
            Mirage.Vector data = new Mirage.Vector (mfcc.rows);

            for (int i = 0; i < mfcc.rows; i++) {
                float min = float.PositiveInfinity;
                for (int j = 0; j < mfcc.columns; j++) {
                    min = Math.Min (min, mfcc.d [i, j]);
                }
                data.d [i, 0] = min;
            }

            return data;
        }
예제 #6
0
        /// <summary>
        /// Computes the maximum for each row of the MFCC matrix.
        /// </summary>
        /// <param name="mfcc">
        /// The MFCC <see cref="Mirage.Matrix"/>
        /// </param>
        /// <returns>
        /// A <see cref="Mirage.Vector"/> containing the maximum
        /// vector of the MFCC matrix
        /// </returns>
        private Mirage.Vector ConvertMfccToMax (Mirage.Matrix mfcc)
        {
            Mirage.Vector data = new Mirage.Vector (mfcc.rows);

            for (int i = 0; i < mfcc.rows; i++) {
                float max = float.NegativeInfinity;
                for (int j = 0; j < mfcc.columns; j++) {
                    max = Math.Max (max, mfcc.d [i, j]);
                }
                data.d [i, 0] = max;
            }

            return data;
        }
예제 #7
0
        /// <summary>
        /// Computes the squared mean for each row of the MFCC matrix.
        /// </summary>
        /// <param name="mfcc">
        /// The MFCC <see cref="Mirage.Matrix"/>
        /// </param>
        /// <returns>
        /// A <see cref="Mirage.Vector"/> containing the squared mean
        /// vector of the MFCC matrix
        /// </returns>
        private Mirage.Vector ConvertMfccToSqrMean (Mirage.Matrix mfcc)
        {
            Mirage.Vector data = new Mirage.Vector (mfcc.rows);

            for (int i = 0; i < mfcc.rows; i++) {
                data.d [i, 0] = 0;
                for (int j = 0; j < mfcc.columns; j++) {
                    data.d [i, 0] += (float) Math.Pow (mfcc.d [i, j], 2);
                }
                data.d [i, 0] = (float) Math.Sqrt (data.d [i, 0]);
            }

            return data;
        }
예제 #8
0
        /// <summary>
        /// Converts a Mirage.Vector to an array of doubles.
        /// </summary>
        /// <param name="vec">
        /// The <see cref="Mirage.Vector"/> to be converted
        /// </param>
        /// <returns>
        /// The <see cref="System.Double[]"/> representation of the vector
        /// </returns>
        private double[] ConvertMirageVector (Mirage.Vector vec)
        {
            double [] data = new double [vec.d.Length];

            for (int i = 0; i < vec.d.Length; i++) {
                data [i] = vec.d [i, 0];
            }

            return data;
        }
예제 #9
0
파일: DataParser.cs 프로젝트: tjom/MIRPCADB
        /// <summary>
        /// Converts a Mirage.Vector to a string representation with semicolons
        /// instead of commas.
        /// </summary>
        /// <param name="v">
        /// The <see cref="Mirage.Vector"/> to be converted
        /// </param>
        /// <returns>
        /// A <see cref="System.String"/> representation of the vector
        /// </returns>
        public static string MirageVectorToString(Mirage.Vector v)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append ("[");

            for (int i = 0; i < v.rows; i++) {
                if (i != 0)
                    sb.Append (";");
                sb.Append (v.d [i, 0]);
            }
            sb.Append ("]");
            return sb.ToString ();
        }
예제 #10
0
파일: DataParser.cs 프로젝트: h0rm/No.Noise
        /// <summary>
        /// Converts a Mirage.Matrix to a string representation with semicolons
        /// instead of commas.
        /// </summary>
        /// <param name="m">
        /// The <see cref="Mirage.Matrix"/> to be converted
        /// </param>
        /// <returns>
        /// A <see cref="System.String"/> representation of the matrix
        /// </returns>
        public static string MirageMatrixToString (Mirage.Matrix m)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < m.rows; i++) {
                if (i == 0)
                    sb.Append ("[[");
                else
                    sb.Append (" [");

                for (int j = 0; j < m.columns; j++) {
                    if (j != 0)
                        sb.Append (";");
                    sb.Append (m.d [i, j]);
                }

                if (i == (m.rows - 1)) {
                    sb.Append("]]");
                    continue;
                }
                sb.AppendLine("]");
            }

            return sb.ToString();
        }
예제 #11
0
 /// <summary>
 /// Instantiate a new Stft Class
 /// </summary>
 /// <param name="winsize">FFT window size</param>
 /// <param name="hopsize">Value to hop on to the next window</param>
 /// <param name="window">Window function to apply to every window processed</param>
 public StftMirage(int winsize, int hopsize, Mirage.IWindowFunction window)
 {
     this.winsize = winsize;
     this.hopsize = hopsize;
     fft = new Mirage.Fft(winsize, window);
 }
예제 #12
0
파일: PCAnalyzer.cs 프로젝트: tjom/MIRPCADB
        /// <summary>
        /// Converts a mirage matrix to a math matrix
        /// </summary>
        /// <param name="mat">
        /// A <see cref="Mirage.Matrix"/>
        /// </param>
        /// <returns>
        /// A <see cref="Matrix"/>
        /// </returns>
        private Matrix ConvertMatrix(Mirage.Matrix mat)
        {
            Log.Debug("NoNoise/PCA - converting mirage matrix");
            double[][] d = Matrix.CreateMatrixData(mat.rows, mat.columns);

            for (int i = 0; i < mat.rows; i++)
                for (int j = 0; j < mat.columns; j++)
                    d[i][j] = mat.d[i,j];
            num_columns = mat.columns;

            Log.Debug("NoNoise/PCA - conversion complete");

            return new Matrix (d);
        }
예제 #13
0
파일: PCAnalyzer.cs 프로젝트: tjom/MIRPCADB
 /// <summary>
 /// Deprecated constructor used for covariance matrix testing
 /// </summary>
 /// <param name="data">
 /// The mirage matrix which will be converted to a math matrix that should be user for the PCA
 /// (has to be a square covariance matrix)
 /// </param>
 public PCAnalyzer(Mirage.Matrix data)
 {
     m = ConvertMatrix (data);
     //            Console.WriteLine(m.ToString());
 }
예제 #14
0
 /// <summary>
 /// Prints debug information for an MFCC matrix.
 /// </summary>
 /// <param name="mfcc">
 /// A MFCC <see cref="Matrix"/>
 /// </param>
 private void DebugPrintMFCC(Mirage.Matrix mfcc)
 {
     Hyena.Log.Debug("Cols: " + mfcc.columns);
     Hyena.Log.Debug("Rows: " + mfcc.rows);
     Hyena.Log.Debug("Mean length: " + mfcc.Mean().rows);
     mfcc.Mean().Print();
 }
예제 #15
0
            /// <summary>
            /// Converts a Mirage.Vector to an array of doubles.
            /// </summary>
            /// <param name="mean">
            /// The <see cref="Mirage.Vector"/> to be converted
            /// </param>
            /// <returns>
            /// The <see cref="System.Double[]"/> representation of the vector
            /// </returns>
            private double[] ConvertMfccMean(Mirage.Vector mean)
            {
                double[] data = new double[mean.d.Length];

                for (int i = 0; i < mean.d.Length; i++) {
                    data[i] = mean.d[i, 0];
                }

                return data;
            }