/// <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"); } }
public Visualizer(IAudioFormat audio, VisualisationModes vm, int downSampleCoef = 1) { soundBuffer = new SoundBuffer(audio.Data, audio.Channels, audio.SampleRate); visualisation = CreateMode(soundBuffer, vm, downSampleCoef); }
public Visualizer(short[] data, uint channelCount, uint sampleRate, VisualisationModes vm, int downSampleCoef = 1) { soundBuffer = new SoundBuffer(data, channelCount, sampleRate); visualisation = CreateMode(soundBuffer, vm, downSampleCoef); }