示例#1
0
        private void LoadSpectrum(WavImagesPack pack, WaveForm waveForm, ViewOptions viewOptions)
        {
            var bitmap = spectrogram.MakeSpectrogram(waveForm, viewOptions);

            if (bitmap == null)
            {
                return;
            }
            pack.Spectrogram = bitmap;
        }
示例#2
0
        private void LoadWaveForm(WavImagesPack pack, WaveForm waveForm, int height, double yScale)
        {
            var bitmap = waveForm.DrawWaveform(height, waveformColor, yScale, waveForm.Path);

            if (bitmap == null)
            {
                return;
            }
            pack.WavImage = bitmap;
        }
示例#3
0
        private void LoadFrq(WavImagesPack pack, WaveForm waveForm, int height)
        {
            var frq = new Frq();

            frq.Load(waveForm.Path);
            if (frq.Points != null)
            {
                var visualPoints = frq.CalculateVisualPoints(waveForm, height);
                var bitmap       = frq.DrawPoints(visualPoints, height, waveForm.Path);
                if (bitmap == null)
                {
                    return;
                }
                pack.Frq = bitmap;
            }
        }
示例#4
0
        public void Load(WaveForm waveForm, int height, WavImagesHash hash)
        {
            var hasImage = images.TryGetValue(waveForm, out var pack);

            if (!hasImage)
            {
                pack = new WavImagesPack();
            }
            images.TryAdd(waveForm, pack);

            if (!waveForm.IsEnabled)
            {
                ClearWavformImages(waveForm);
                pack.IsLoading = false;
                pack.IsLoaded  = false;
                Console.WriteLine($"ImagesLibrary: failed to load image {hash.Recline}");
                OnImageLoaded(waveForm);
                return;
            }

            if (hash.Equals(waveForm.ImageHash) && pack.IsLoaded)
            {
                Console.WriteLine($"ImagesLibrary: image is already loaded {hash.Recline}");
                OnImageLoaded(waveForm);
                return;
            }
            if (!hash.Equals(waveForm.ImageHash))
            {
                ClearWavformImages(waveForm);
                images.TryAdd(waveForm, pack);
            }

            pack.IsLoading = true;
            pack.IsLoaded  = false;

            Console.WriteLine($"ImagesLibrary: started load image {hash.Recline}");
            LoadWaveForm(pack, waveForm, height, Settings.UserScaleY);
            LoadFrq(pack, waveForm, height);
            LoadSpectrum(pack, waveForm, ViewOptions);
            Console.WriteLine($"ImagesLibrary: finished load imag {hash.Recline}");

            pack.IsLoading = false;
            pack.IsLoaded  = true;

            OnImageLoaded(waveForm);
        }
示例#5
0
        public void RegisterWaveForm(WaveForm waveForm)
        {
            var pack = new WavImagesPack();

            images.TryAdd(waveForm, pack);
        }