Exemplo n.º 1
0
        /// <summary>
        /// Create concrete Visualisation mode.
        /// </summary>
        /// <param name="soundBuffer">Sound buffer reference.</param>
        /// <param name="visualisationMode">Visualisation mode to be created.</param>
        /// <param name="downSampleCoef">Coefficient to downsample audio when visualisating.</param>
        /// <returns></returns>
        private static IVisualiserMode CreateMode(SoundBuffer soundBuffer, VisualisationModes visualisationMode, int downSampleCoef)
        {
            switch (visualisationMode)
            {
            case VisualisationModes.Amplitude:
                return(new AmplitudeMode(soundBuffer));

            case VisualisationModes.Frequencies:
                return(new FrequenciesMode(soundBuffer, downSampleCoef));

            case VisualisationModes.Spectrogram:
                return(new Spectrogram(soundBuffer, downSampleCoef));

            default:
                throw new ArgumentException($"Mode {visualisationMode.ToString()} is not supported");
            }
        }
Exemplo n.º 2
0
 public Visualizer(IAudioFormat audio, VisualisationModes vm, int downSampleCoef = 1)
 {
     soundBuffer   = new SoundBuffer(audio.Data, audio.Channels, audio.SampleRate);
     visualisation = CreateMode(soundBuffer, vm, downSampleCoef);
 }
Exemplo n.º 3
0
 public Visualizer(short[] data, uint channelCount, uint sampleRate, VisualisationModes vm, int downSampleCoef = 1)
 {
     soundBuffer   = new SoundBuffer(data, channelCount, sampleRate);
     visualisation = CreateMode(soundBuffer, vm, downSampleCoef);
 }