NAudio Эквалайзер в реальном времени - PullRequest
0 голосов
/ 13 июня 2018

Мне нужно создать звуковой проигрыватель с эквалайзером в реальном времени, используя NAudio в c #, я уже создал плеер, но я не знаю, как реализовать эквалайзер

using System;
using System.IO;
using System.Collections.Generic;
using System.Media;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using Microsoft.Win32;
using NAudio.Wave;
using NAudio.Wave.SampleProviders;

namespace Player
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
        float volume1,volume2;
        private WaveOutEvent player1 = null;
        private WaveOutEvent player2 = null;
        private AudioFileReader audioFileReader1 = null;
        private AudioFileReader audioFileReader2 = null;
        private bands = new

        public Window1()
        {
            InitializeComponent();
            dispatcherTimer.Tick += dispatcherTimer_Tick;
            dispatcherTimer.Interval = new TimeSpan(0,0,1);
            dispatcherTimer.Start();
            player1 = new WaveOutEvent();
            player2 = new WaveOutEvent();
        }
        void progressBar1_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {

        }

        void browse1_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "MP3 File (.mp3) | *.mp3;";
            if(openFileDialog.ShowDialog() == true){
                audioFileReader1 = new AudioFileReader(openFileDialog.FileName);
                player1.Init(audioFileReader1);
                title1.Text = audioFileReader1.FileName;
            }
        }

        void browse2_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "MP3 File (.mp3) | *.mp3;";
            if(openFileDialog.ShowDialog() == true){
                audioFileReader2 = new AudioFileReader(openFileDialog.FileName);
                player2.Init(audioFileReader2);
                title2.Text = audioFileReader2.FileName;
            }
        }

        void play1_Click(object sender, RoutedEventArgs e)
        {
            volume_set1();
            player1.Play();
        }

        void pause1_click(object sender, RoutedEventArgs e)
        {
            player1.Stop();
        }

        void pause2_Click(object sender, RoutedEventArgs e)
        {
            player2.Stop();
        }

        void play2_click(object sender, RoutedEventArgs e)
        {
            volume_set2();
            player2.Play();
        }

        void progress2_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            progress2.Maximum = (int)(audioFileReader2.TotalTime.TotalSeconds);
            progress2.Value   = (int)(audioFileReader2.CurrentTime.TotalSeconds);
        }

        void progress1_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            progress1.Maximum = (int)(audioFileReader1.TotalTime.TotalSeconds);
            progress1.Value   = (int)(audioFileReader1.CurrentTime.TotalSeconds);
        }

        void crossfader_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            volume_set2();
            volume_set1();
        }

        void overall_volume_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            volume_set2();
            volume_set1();
        }

        void volume1_Control_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            volume_set1();
        }

        void volume2_Control_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            volume_set2();
        }

        void stop1_Click(object sender, RoutedEventArgs e)
        {
            player1.Stop();
            player1.
        }

        void stop2_Click(object sender, RoutedEventArgs e)
        {
            player2.Stop();
        }

        void dispatcherTimer_Tick(object sender, EventArgs e)
        {
            if(audioFileReader1 != null){
                progress1.Value   = (int)(audioFileReader1.CurrentTime.TotalSeconds);
            }
            if(audioFileReader2 != null){
                progress2.Value   = (int)(audioFileReader2.CurrentTime.TotalSeconds);
            }
        }

        void volume_set1()
        {
            if(audioFileReader1 != null){
                volume1 = (float)(volume1_Control.Value * overall_volume.Value * (0.5 - (crossfader.Value * 0.5)));
                audioFileReader1.Volume = volume1;
            }
        }
        void volume_set2()
        {
            if(audioFileReader2 != null){
                volume2 = (float)(volume2_Control.Value * overall_volume.Value * (0.5 + (crossfader.Value * 0.5)));
                audioFileReader2.Volume = volume2;
            }
        }
        }
} 

Некоторые функции пусты, потому что этовсе еще в стадии разработки.Я не могу использовать CSCore, потому что я использую Windows XP, и она сразу падает.Я также пытался использовать WMPLib, но не смог найти объяснение WMPEqualizerSettingsCtl.Любая помощь будет оценена.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...