Example #1
0
        /// <summary>
        ///   Create fingerprints according to the Google's researchers algorithm
        /// </summary>
        /// <param name = "proxy">Proxy used in reading from file</param>
        /// <param name = "filename">Filename to be analyzed</param>
        /// <param name = "stride">Stride between 2 consecutive fingerprints</param>
        /// <param name = "milliseconds">Milliseconds to analyze</param>
        /// <param name = "startmilliseconds">Starting point of analysis</param>
        /// <returns>Fingerprint signatures</returns>
        public List <bool[]> CreateFingerprints(IWaveformPlayer proxy, string filename, IStride stride, int milliseconds, int startmilliseconds)
        {
            float[][]     spectrum          = CreateLogSpectrogram(proxy, filename, milliseconds, startmilliseconds);
            int           fingerprintLength = FingerprintLength;
            int           overlap           = Overlap;
            int           logbins           = LogBins;
            int           start             = stride.GetFirstStride() / overlap;
            List <bool[]> fingerprints      = new List <bool[]>();

            int width = spectrum.GetLength(0);

            while (start + fingerprintLength < width)
            {
                float[][] frames = new float[fingerprintLength][];
                for (int i = 0; i < fingerprintLength; i++)
                {
                    frames[i] = new float[logbins];
                    Array.Copy(spectrum[start + i], frames[i], logbins);
                }
                start += fingerprintLength + stride.GetStride() / overlap;
                WaveletDecomposition.DecomposeImageInPlace(frames);                 /*Compute wavelets*/
                bool[] image = ExtractTopWavelets(frames);
                fingerprints.Add(image);
            }
            return(fingerprints);
        }
Example #2
0
        /// <summary>
        ///   Create log-spectrogram (spaced according to manager's parameters)
        /// </summary>
        /// <param name = "proxy">Proxy used in generating the spectrogram</param>
        /// <param name = "filename">Filename to be processed</param>
        /// <param name = "milliseconds">Milliseconds to be analyzed</param>
        /// <param name = "startmilliseconds">Starting point</param>
        /// <returns>Logarithmically spaced bins within the power spectrum</returns>
        public float[][] CreateLogSpectrogram(IWaveformPlayer proxy, string filename, int milliseconds, int startmilliseconds)
        {
            //read 5512 Hz, Mono, PCM, with a specific proxy
            float[] samples = BassProxy.ReadMonoFromFile(filename, SampleRate, milliseconds, startmilliseconds);
            //NormalizeInPlace(samples);
            int overlap        = Overlap;
            int fftWindowsSize = WdftSize;

            double[] windowArray = FFTWindow.GetWindowFunction(FFTWindowType.HANNING, fftWindowsSize);

            int width = (samples.Length - fftWindowsSize) / overlap;           /*width of the image*/

            float[][] frames        = new float[width][];
            float[]   complexSignal = new float[2 * fftWindowsSize];         /*even - Re, odd - Img*/
            for (int i = 0; i < width; i++)
            {
                //take 371 ms each 11.6 ms (2048 samples each 64 samples)
                for (int j = 0; j < fftWindowsSize /*2048*/; j++)
                {
                    // Weight by Hann Window
                    complexSignal[2 * j] = (float)(windowArray[j] * samples[i * overlap + j]);
                    //complexSignal[2*j] = (float) (_windowArray[j]*samples[i*overlap + j]); /*Weight by Hann Window*/
                    complexSignal[2 * j + 1] = 0;
                }
                //FFT transform for gathering the spectrum
                Fourier.FFT(complexSignal, fftWindowsSize, FourierDirection.Forward);
                frames[i] = ExtractLogBins(complexSignal);
            }
            return(frames);
        }
        /// <summary>
        /// Register a sound player from which the waveform timeline
        /// can get the necessary playback data.
        /// </summary>
        /// <param name="soundPlayer">A sound player that provides waveform data through the IWaveformPlayer interface methods.</param>
        public void RegisterSoundPlayer(IWaveformPlayer soundPlayer)
        {
            this._soundPlayer            = soundPlayer;
            soundPlayer.PropertyChanged += soundPlayer_PropertyChanged;

            customWaveViewer1.RegisterSoundPlayer(soundPlayer);
            customWaveViewer1.PropertyChanged += CustomWaveViewer_PropertyChanged;

            //customSpectrumAnalyzer1.RegisterSoundPlayer(soundPlayer);
        }
Example #4
0
        public MushraTestTransportControlsView()
        {
            _waveDisplay    = WaveFormPlayer.Instance;
            _settingsObject = AudioSettingsModel.GetInstance;
            _scoreLogger    = LogFactory.GetLoggerObject((byte)LoggerType.ScoreLogger);
            _scorerDetails  = ScorerDetails.GetInstance;

            MUSHRASessionWindow.SessionCreated      += MUSHRASessionWindow_SessionCreated;
            MUSHRASessionWindow.SessionClosed       += MUSHRASessionWindow_SessionClosed;
            MushraTestScoreView.MushraClickedButton += OnMushraClickedButton;
            MushraTestScoreView.ScoringSliderEvent  += ScoringSliderEvent;
            LoadSelectedTrialEvent          += OnLoadSelectedTrialEvent;
            this.Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;

            InitializeComponent();
        }
Example #5
0
        /// <summary>
        ///   Create spectrogram of the input file
        /// </summary>
        /// <param name = "proxy">Proxy used to read from file</param>
        /// <param name = "filename">Filename</param>
        /// <param name = "milliseconds">Milliseconds to process</param>
        /// <param name = "startmilliseconds">Starting point of the processing</param>
        /// <returns>Spectrogram</returns>
        public float[][] CreateSpectrogram(IWaveformPlayer proxy, string filename, int milliseconds, int startmilliseconds, bool doNormalise)
        {
            //read 5512 Hz, Mono, PCM, with a specific proxy
            float[] samples = BassProxy.ReadMonoFromFile(filename, SampleRate, milliseconds, startmilliseconds);
            if (doNormalise)
            {
                NormalizeInPlace(samples);
            }
            int overlap        = Overlap;
            int fftWindowsSize = WdftSize;             // aka N = FFT Length

            double[] windowArray = FFTWindow.GetWindowFunction(FFTWindowType.HANNING, fftWindowsSize);

            int width = (samples.Length - fftWindowsSize) / overlap;           /*width of the image*/

            float[][] frames        = new float[width][];
            float[]   complexSignal = new float[2 * fftWindowsSize];         /*even - Re, odd - Img*/
            for (int i = 0; i < width; i++)
            {
                //take 371 ms each 11.6 ms (2048 samples each 64 samples)
                // apply Hanning Window
                for (int j = 0; j < fftWindowsSize /*2048*/; j++)
                {
                    // Weight by Hann Window
                    complexSignal[2 * j] = (float)(windowArray[j] * samples[i * overlap + j]);
                    //complexSignal[2*j] = (float) ((4.0/(fftWindowsSize - 1)) * windowArray[j]*samples[i*overlap + j]); /*Weight by Hann Window*/
                    complexSignal[2 * j + 1] = 0;                    // need to clear out as fft modifies buffer
                }
                //FFT transform for gathering the spectrum
                Fourier.FFT(complexSignal, fftWindowsSize, FourierDirection.Forward);
                float[] band = new float[fftWindowsSize / 2 + 1];
                for (int j = 0; j < fftWindowsSize / 2 + 1; j++)
                {
                    double re  = complexSignal[2 * j];
                    double img = complexSignal[2 * j + 1];
                    //double img = 0.0; // TODO: Zero out the imaginary component (phase) ? / need to clear out as fft modifies buffer
                    band[j] = (float)Math.Sqrt(re * re + img * img);
                }
                frames[i] = band;
            }

            return(frames);
        }
Example #6
0
        public ABCTestView()
        {
            InitializeComponent();

            _scoreLogger = LogFactory.GetLoggerObject((byte)LoggerType.ScoreLogger);
            ABCSessionWindow.SessionCreated  += ABCSessionWindow_SessionCreated;
            ABCSessionWindow.SessionClosed   += ABCSessionWindow_SessionClosed;
            ScoringScales.ScoringSliderEvent += ScoringSliderEvent;

            LoadSelectedTrialEvent          += OnLoadSelectedTrialEvent;
            _waveDisplay                     = WaveFormPlayer.Instance;
            _settingsObject                  = AudioSettingsModel.GetInstance;
            _scorerDetails                   = ScorerDetails.GetInstance;
            this.Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;
            var image = (Image)FindResource("NoLoop");

            image.Height    = 50;
            LoopBtn.Content = image;
        }
 /// <summary>
 /// Register a sound player from which the waveform timeline
 /// can get the necessary playback data.
 /// </summary>
 /// <param name="soundPlayer">A sound player that provides waveform data through the IWaveformPlayer interface methods.</param>
 public void RegisterSoundPlayer(IWaveformPlayer soundPlayer)
 {
     this.soundPlayer = soundPlayer;
     soundPlayer.PropertyChanged += soundPlayer_PropertyChanged;
 }
 /// <summary>
 /// Register a sound player from which the waveform timeline
 /// can get the necessary playback data.
 /// </summary>
 /// <param name="soundPlayer">A sound player that provides waveform data through the IWaveformPlayer interface methods.</param>
 public void RegisterSoundPlayer(IWaveformPlayer soundPlayer)
 {
     this.soundPlayer             = soundPlayer;
     soundPlayer.PropertyChanged += soundPlayer_PropertyChanged;
 }
Example #9
0
 /// <summary>
 ///   Create fingerprints gathered from one specific song
 /// </summary>
 /// <param name = "proxy">Proxy used in reading the audio file</param>
 /// <param name = "filename">Filename</param>
 /// <param name = "stride">Stride used in fingerprint creation</param>
 /// <returns>List of fingerprint signatures</returns>
 public List <bool[]> CreateFingerprints(IWaveformPlayer proxy, string filename, IStride stride)
 {
     return(CreateFingerprints(proxy, filename, stride, 0, 0));
 }