Ejemplo n.º 1
0
        public void LoadFromData()
        {
            FileNameBox.Text = Data.FilePath;
            if (Data.FilePath != "")
            {
                if (Sound == null)
                {
                    Sound = new AudioSound(Data.FilePath, Data.StartTime, Data.EndTime, Data.Volume);
                }
                else
                {
                    if (Sound.FileName != Data.FilePath)
                    {
                        Sound = new AudioSound(Data.FilePath, Data.StartTime, Data.EndTime, Data.Volume);
                    }
                }
                WaveGraph.WaveStream = Sound.FileReader;
                var temp = EndTime.Maximum;
                EndTime.Maximum = (decimal)Sound.FileReader.TotalTime.TotalSeconds;
                if (temp == 0)
                {
                    EndTime.Value = EndTime.Maximum;
                }
                TotalTimeLabel.Text  = $"{EndTime.Maximum} s";
                VolumeControl.Volume = 1;
            }



            NameTextBox.Text     = Data.Name;
            StartTime.Value      = (decimal)Data.StartTime;
            EndTime.Value        = (decimal)Data.EndTime;
            VolumeControl.Volume = Data.Volume;
        }
Ejemplo n.º 2
0
        private void _updateGraph(bool eraseIfEmpty = false)
        {
            if (FileNameBox.Text == "")
            {
                if (eraseIfEmpty)
                {
                    TotalTimeLabel.Text  = "";
                    EndTime.Maximum      = 0;
                    WaveGraph.WaveStream = null;
                }
                return;
            }

            Sound = new AudioSound(FileNameBox.Text, (double)StartTime.Value, (double)EndTime.Value, VolumeControl.Volume);

            WaveGraph.WaveStream = Sound.FileReader;
            var temp = EndTime.Maximum;

            EndTime.Maximum = (decimal)Sound.FileReader.TotalTime.TotalSeconds;
            if (temp == 0)
            {
                EndTime.Value = EndTime.Maximum;
            }
            TotalTimeLabel.Text  = $"{EndTime.Maximum} s";
            VolumeControl.Volume = 1;
        }
Ejemplo n.º 3
0
 public void PlaySoundAsync()
 {
     //var sound = AudioSound.AddSound(FileNameBox.Text, WaveGraph.Slider1Value, WaveGraph.Slider2Value, (float)VolumeTrack.Value / 100);
     //return sound != null;// true if successfull
     if (Sound == null)
     {
         return;
     }
     AudioSound.PlaySound(Sound);
 }
Ejemplo n.º 4
0
 public static void PlaySound(AudioSound sound)
 {
     if (Sounds.Contains(sound))
     {
         new AudioSound(sound).Play();
     }
     else
     {
         sound.Play();
     }
 }
Ejemplo n.º 5
0
 private void PlayButton_Click(object sender, EventArgs e)
 {
     if (FileNameBox.Text == "")
     {
         MessageBox.Show("Enter a valid File to play!");
         return;
     }
     AudioSound.PlaySound(Sound);
     //if (!PlaySoundAsync())
     //{
     //    MessageBox.Show("Enter a valid File to play!");
     //    return;
     //}
 }
Ejemplo n.º 6
0
        private void InputCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            var prov = Recorder.GetWaveProvider();

            VolumeControl.Volume = 1;
            Sound                = new AudioSound(prov, 0, 0, VolumeControl.Volume);
            Sound.EndPos         = Recorder.RecordedTime;
            StartTime.Minimum    = 0;
            StartTime.Maximum    = (decimal)Sound.EndPos;
            EndTime.Minimum      = 0;
            EndTime.Maximum      = StartTime.Maximum;
            EndTime.Value        = StartTime.Maximum;
            TotalTimeLabel.Text  = $"{EndTime.Maximum} s";
            WaveGraph.WaveStream = Sound.FileReader;
        }
Ejemplo n.º 7
0
 private void Form_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (char.TryParse(Name, out char c))
     {
         if (e.KeyChar == c)
         {
             SoundForm.PlaySoundAsync();
         }
     }
     if (e.KeyChar == ' ')
     {
         AudioSound.StopAll();
         //Stop sounds
     }
 }
Ejemplo n.º 8
0
        public SaveSound()
        {
            InitializeComponent();

            AddActionsForControlsOfTypes((Control c) => c.KeyDown += PlayStopOnKeys, typeof(Button), typeof(ComboBox), typeof(NumericUpDown));
            AddActionsForControlsOfTypes((Control c) => c.KeyDown += SelectNextOnEnterKey, typeof(ComboBox), typeof(NumericUpDown), typeof(TextBox));
            AddActionsForControlsOfTypes((Control c) => c.KeyDown += SpaceForNumUpDown, typeof(NumericUpDown));
            AddArrowSelectForControls(StartTime, EndTime);
            AddActionsForControlsOfTypes((Control c) => { c.KeyDown += CloseOnEsc; c.KeyDown += SupressKeys; }, typeof(Button), typeof(ComboBox), typeof(NumericUpDown), typeof(TextBox));

            Recorder = Form1.Recorders[0];
            foreach (var recorder in Form1.Recorders)
            {
                recorder.StopRecording();
                InputCombo.Items.Add(WaveIn.GetCapabilities(recorder.Device).ProductName);
            }
            InputCombo.SelectedIndex = 0;
            var prov = Recorder.GetWaveProvider();

            Sound               = new AudioSound(prov, 0, 0, VolumeControl.Volume);
            Sound.EndPos        = Recorder.RecordedTime;
            StartTime.Minimum   = 0;
            StartTime.Maximum   = (decimal)Sound.EndPos;
            EndTime.Minimum     = 0;
            EndTime.Maximum     = StartTime.Maximum;
            EndTime.Value       = StartTime.Maximum;
            TotalTimeLabel.Text = $"{EndTime.Maximum} s";
            KeyCombo.Items.Add("Select a key");
            foreach (var item in Form1.MyKeyboard)
            {
                foreach (var key in item)
                {
                    KeyCombo.Items.Add(key);
                }
            }
            KeyCombo.SelectedIndex = 0;
            //SaveButton.Enabled = false;
            WaveGraph.WaveStream = Sound.FileReader;
        }
Ejemplo n.º 9
0
 private void SelectSound_FormClosed(object sender, FormClosedEventArgs e)
 {
     //Stop sounds
     //if (Sound != null) Sound.Stop();
     AudioSound.StopAll();
 }
Ejemplo n.º 10
0
 private void StopButton_Click(object sender, EventArgs e)
 {
     //Stop sounds
     //if (Sound != null) Engine.Init(Sound);
     AudioSound.StopAll();
 }
Ejemplo n.º 11
0
 private AudioSound(AudioSound sound) : this(sound.FileName, sound._startPos, sound._endPos, sound.Volume)
 {
 }