Пример #1
0
        public void RenderPNGvisual(PictureBox pictureBox, FileSystem fileSystem) //visualization af lyd, Kopieret fra nettet
        {
            var maxPeakProvider      = new MaxPeakProvider();
            var rmsPeakProvider      = new RmsPeakProvider(200);      // e.g. 200
            var samplingPeakProvider = new SamplingPeakProvider(200); // e.g. 200
            var averagePeakProvider  = new AveragePeakProvider(4);    // e.g. 4

            var topSpacerColor = Color.FromArgb(64, 224, 224, 224);

            var myRendererSettings = new SoundCloudBlockWaveFormSettings(Color.FromArgb(196, 197, 53, 0), topSpacerColor, Color.FromArgb(196, 79, 26, 0),
                                                                         Color.FromArgb(64, 79, 79, 79))
            {
                Name          = "SoundCloud Orange Transparent Blocks",
                PixelsPerPeak = 2,
                SpacerPixels  = 1,
                TopSpacerGradientStartColor = topSpacerColor,
                BackgroundColor             = Color.Transparent
            };;

            myRendererSettings.Width        = pictureBox.Width;
            myRendererSettings.TopHeight    = 20;
            myRendererSettings.BottomHeight = 15;


            var renderer      = new WaveFormRenderer();
            var audioFilePath = fileSystem.wavFiles[tal];
            var image         = renderer.Render(audioFilePath, rmsPeakProvider, myRendererSettings);

            pictureBox.Image = image;
        }
Пример #2
0
        private void RenderChart(PictureBox picbox, string audioFilePath)
        {
            MaxPeakProvider      maxPeakProvider      = new MaxPeakProvider();
            RmsPeakProvider      rmsPeakProvider      = new RmsPeakProvider(200);      // e.g. 200
            SamplingPeakProvider samplingPeakProvider = new SamplingPeakProvider(200); // e.g. 200
            AveragePeakProvider  averagePeakProvider  = new AveragePeakProvider(4);    // e.g. 4

            StandardWaveFormRendererSettings myRendererSettings = new StandardWaveFormRendererSettings();

            myRendererSettings.Width        = 4320;
            myRendererSettings.TopHeight    = 256;
            myRendererSettings.BottomHeight = 256;
            //myRendererSettings.BottomSpacerPen = new Pen(Color.Transparent);
            //myRendererSettings.TopSpacerPen = new Pen(Color.Transparent);
            //myRendererSettings.PixelsPerPeak = 10;
            //myRendererSettings.SpacerPixels = 2;
            myRendererSettings.TopPeakPen      = new Pen(Color.FromArgb(0, 192, 192));
            myRendererSettings.BottomPeakPen   = new Pen(Color.FromArgb(100, 0, 192, 192));
            myRendererSettings.BackgroundColor = Color.Transparent;
            //myRendererSettings.DecibelScale = true;
            WaveFormRenderer renderer = new WaveFormRenderer();

            Image image = renderer.Render(audioFilePath, averagePeakProvider, myRendererSettings);

            picbox.Image = image;
        }
Пример #3
0
        private void SelectSong_button_Click(object sender, EventArgs e)
        {
            //openFileDialog1.ShowDialog();
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                //listBox3.Items.Add(openFileDialog1.SafeFileName); //Addes the song to the list TODO: a function to call
            }

            var maxPeakProvider      = new MaxPeakProvider();
            var rmsPeakProvider      = new RmsPeakProvider(200);      // e.g. 200
            var samplingPeakProvider = new SamplingPeakProvider(200); // e.g. 200
            var averagePeakProvider  = new AveragePeakProvider(4);    // e.g. 4

            var myRendererSettings = new StandardWaveFormRendererSettings();

            myRendererSettings.Width           = 640;
            myRendererSettings.TopHeight       = 32;
            myRendererSettings.BottomHeight    = 32;
            myRendererSettings.BackgroundColor = Color.White;

            var renderer      = new WaveFormRenderer();
            var audioFilePath = "./user_data/sound/" + openFileDialog1.SafeFileName;
            var image         = renderer.Render(audioFilePath, myRendererSettings);

            pictureBox1.Image = image;
        }
Пример #4
0
        public void RenderWaveform()
        {
            if (selectedFile == null)
            {
                return;
            }
            var settings     = GetRendererSettings();
            var peakProvider = new SamplingPeakProvider(200);

            Task.Factory.StartNew(() => RenderThreadFunc(peakProvider, settings));
        }
Пример #5
0
        //SINGLE-IMPORT AUDIO
        private void button1_Click(object sender, EventArgs e)
        {
            //GET AUDIO FILE
            OpenFileDialog openFileDialog1 = new OpenFileDialog
            {
                InitialDirectory = @"C:\",
                Title            = "Browse Audio Files",

                CheckFileExists = true,
                CheckPathExists = true,

                DefaultExt       = "wav",
                Filter           = "wav files (*.wav)|*.wav",
                FilterIndex      = 2,
                RestoreDirectory = true,

                ReadOnlyChecked = true,
                ShowReadOnly    = true
            };

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                single_audio   = openFileDialog1.FileName;
                textBox1.Text += "Opened Audio File Successfully" + "\r\n";
                textBox2.Text  = "Imported Audio: " + single_audio;
            }

            if (single_audio != null)
            {
                //DISPLAY WAVEFORM
                var maxPeakProvider      = new MaxPeakProvider();
                var rmsPeakProvider      = new RmsPeakProvider(200);      // e.g. 200
                var samplingPeakProvider = new SamplingPeakProvider(200); // e.g. 200
                var averagePeakProvider  = new AveragePeakProvider(4);    // e.g. 4

                var myRendererSettings = new StandardWaveFormRendererSettings();
                myRendererSettings.Width        = 651;
                myRendererSettings.TopHeight    = 24;
                myRendererSettings.BottomHeight = 24;

                var renderer      = new WaveFormRenderer();
                var audioFilePath = single_audio;
                var image         = renderer.Render(audioFilePath, averagePeakProvider, myRendererSettings);

                pictureBox1.Image = image;
            }
        }
Пример #6
0
        private void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    fileName = openFileDialog1.FileName;
                }
            }
            catch (ArgumentNullException)
            {
                return;
            }

            // 1. Configure Providers
            MaxPeakProvider      maxPeakProvider      = new MaxPeakProvider();
            RmsPeakProvider      rmsPeakProvider      = new RmsPeakProvider(200);      // e.g. 200
            SamplingPeakProvider samplingPeakProvider = new SamplingPeakProvider(200); // e.g. 200
            AveragePeakProvider  averagePeakProvider  = new AveragePeakProvider(4);    // e.g. 4

            // 2. Configure the style of the audio wave image
            StandardWaveFormRendererSettings myRendererSettings = new StandardWaveFormRendererSettings();

            myRendererSettings.Width        = 1080;
            myRendererSettings.TopHeight    = 64;
            myRendererSettings.BottomHeight = 64;

            myRendererSettings.BackgroundImage = new Bitmap(@"C:\Users\Kao\Pictures\Background\73109534_p6_master1200.jpg");

            // 3. Define the audio file from which the audio wave will be created and define the providers and settings
            WaveFormRenderer renderer = new WaveFormRenderer();
            Image            image    = renderer.Render(fileName, averagePeakProvider, myRendererSettings);

            // 4. Store the image
            image.Save(@"../render.png", ImageFormat.Png);
            pictureBox1.Image = image;
            // Or jpeg, however PNG is recommended if your audio wave needs transparency
            // image.Save(@"C:\Users\sdkca\Desktop\myfile.jpg", ImageFormat.Jpeg);

            waveOut = new WaveOut();
            waveOut.PlaybackStopped += WaveOut_OnPlaybackStopped;
            var reader = new Mp3FileReader(fileName);

            waveOut.Init(reader);
        }
Пример #7
0
        public Image audioWave(int Width, ILogger log)
        {
            //MaxPeakProvider maxPeakProvider = new MaxPeakProvider();
            //RmsPeakProvider rmsPeakProvider = new RmsPeakProvider(1000); // e.g. 200
            SamplingPeakProvider samplingPeakProvider = new SamplingPeakProvider(200); // e.g. 200
            //AveragePeakProvider averagePeakProvider = new AveragePeakProvider(3); // e.g. 4

            StandardWaveFormRendererSettings myRendererSettings = new StandardWaveFormRendererSettings();

            myRendererSettings.Width           = Width;
            myRendererSettings.TopHeight       = 128;
            myRendererSettings.BottomHeight    = 128;
            myRendererSettings.PixelsPerPeak   = 1;
            myRendererSettings.BackgroundColor = Color.LightGray;

            renderer = new WaveFormRenderer();
            return(renderer.Render(this.apath, samplingPeakProvider, myRendererSettings, log));
        }
Пример #8
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var openFileDialog1 = new OpenFileDialog();

            try
            {
                fileName = openFileDialog1.FileName;
            }
            catch (ArgumentNullException)
            {
                return;
            }

            // 1. Configure Providers
            MaxPeakProvider      maxPeakProvider      = new MaxPeakProvider();
            RmsPeakProvider      rmsPeakProvider      = new RmsPeakProvider(200);      // e.g. 200
            SamplingPeakProvider samplingPeakProvider = new SamplingPeakProvider(200); // e.g. 200
            AveragePeakProvider  averagePeakProvider  = new AveragePeakProvider(4);    // e.g. 4

            // 2. Configure the style of the audio wave image
            StandardWaveFormRendererSettings myRendererSettings = new StandardWaveFormRendererSettings();

            myRendererSettings.Width        = 1080;
            myRendererSettings.TopHeight    = 64;
            myRendererSettings.BottomHeight = 64;

            myRendererSettings.BackgroundImage = new Bitmap(@"C:\Users\ciit\Pictures\Konachan.com - 218504 arima_kousei a-shacho blonde_hair dark glasses instrument male miyazono_kaori piano shigatsu_wa_kimi_no_uso tree violin.jpg");

            // 3. Define the audio file from which the audio wave will be created and define the providers and settings
            WaveFormRenderer renderer = new WaveFormRenderer();
            Image            image    = renderer.Render(fileName, averagePeakProvider, myRendererSettings);

            // 4. Store the image
            image.Save(@"../render.png", ImageFormat.Png);
            MusicImage.Image = image;
            // Or jpeg, however PNG is recommended if your audio wave needs transparency
            // image.Save(@"C:\Users\sdkca\Desktop\myfile.jpg", ImageFormat.Jpeg);

            waveOut = new WaveOut();
            waveOut.PlaybackStopped += WaveOut_OnPlaybackStopped;
            var reader = new Mp3FileReader(fileName);

            waveOut.Init(reader);
        }
Пример #9
0
        private void ButBrowse_Click_1(object sender, EventArgs e)      //browse button
        {
            string oSelectedFile = "";

            System.Windows.Forms.OpenFileDialog oDlg = new System.Windows.Forms.OpenFileDialog();
            if (System.Windows.Forms.DialogResult.OK == oDlg.ShowDialog())
            {
                oSelectedFile = oDlg.FileName;      //selected file = oSelectedFile
                textBox1.Text = oSelectedFile;

                //configure Providers
                MaxPeakProvider      maxPeakProvider      = new MaxPeakProvider();
                RmsPeakProvider      rmsPeakProvider      = new RmsPeakProvider(200);
                SamplingPeakProvider samplingPeakProvider = new SamplingPeakProvider(200);      //could control these values with sliders?
                AveragePeakProvider  averagePeakProvider  = new AveragePeakProvider(4);

                //configure the style of the audio wave image
                StandardWaveFormRendererSettings myRendererSettings = new StandardWaveFormRendererSettings();
                myRendererSettings.Width        = 1080;
                myRendererSettings.TopHeight    = 64;
                myRendererSettings.BottomHeight = 64;

                WaveFormRenderer renderer      = new WaveFormRenderer();
                String           audioFilePath = textBox1.Text;
                Image            image         = renderer.Render(audioFilePath, averagePeakProvider, myRendererSettings);
                string           folder        = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
                System.IO.Directory.CreateDirectory(folder + "\\AudioManipulation");
                image.Save(folder + "\\AudioManipulation\\output.png", ImageFormat.Png);

                AddToLog("- Sound Played");

                //loads waveform after generation on file browse
                Image loadImage = Image.FromFile("\\output.png");
                pictureBox2.Image  = image;
                pictureBox2.Height = image.Height;
                pictureBox2.Width  = image.Width;
            }
        }
Пример #10
0
        public AudioFileViewModel(string filepath)
        {
            FilePath = filepath;

            var blockSize      = 200;
            var sampleInterval = 200;
            var scaleFactor    = 4;

            var maxPeakProvider      = new MaxPeakProvider();
            var rmsPeakProvider      = new RmsPeakProvider(blockSize);           // e.g. 200
            var samplingPeakProvider = new SamplingPeakProvider(sampleInterval); // e.g. 200
            var averagePeakProvider  = new AveragePeakProvider(scaleFactor);     // e.g. 4

            var myRendererSettings = new StandardWaveFormRendererSettings();

            myRendererSettings.Width        = 640;
            myRendererSettings.TopHeight    = 32;
            myRendererSettings.BottomHeight = 32;

            var renderer = new WaveFormRenderer();

            Image = ConvertImage(renderer.Render(FilePath, averagePeakProvider, myRendererSettings));
        }
Пример #11
0
        private static void MakeWav(string source, string target)
        {
            // 1. Configure Providers
            MaxPeakProvider      maxPeakProvider      = new MaxPeakProvider();
            RmsPeakProvider      rmsPeakProvider      = new RmsPeakProvider(200);      // e.g. 200
            SamplingPeakProvider samplingPeakProvider = new SamplingPeakProvider(200); // e.g. 200
            AveragePeakProvider  averagePeakProvider  = new AveragePeakProvider(4);    // e.g. 4

            // 2. Configure the style of the audio wave image
            //StandardWaveFormRendererSettings myRendererSettings = new StandardWaveFormRendererSettings();
            //myRendererSettings.Width = 1080;
            //myRendererSettings.TopHeight = 64;
            //myRendererSettings.BottomHeight = 64;

            // 3. Define the audio file from which the audio wave will be created and define the providers and settings
            WaveFormRenderer renderer = new WaveFormRenderer();
            //String audioFilePath = @"C:\Users\sdkca\Desktop\when_the_sun_goes_down_arctic_monkeys.mp3";
            Image image = renderer.Render(source, averagePeakProvider, _settings);

            // 4. Store the image
            image.Save(target, ImageFormat.Png);
            // Or jpeg, however PNG is recommended if your audio wave needs transparency
            // image.Save(@"C:\Users\sdkca\Desktop\myfile.jpg", ImageFormat.Jpeg);
        }