private void button1_Click(object sender, EventArgs e) { // WavFileWrapper wav = new WavFileWrapper(@"C:\Users\hungc\Desktop\Project\Binary\Voice Comparasion\Debug\Data\Test\sin100.wav"/*"C:\\Users\\hungc\\Desktop\\Project\\Binary\\TestExtractionLib\\Debug\\what_movies_have_you_seen_recently.wav"*/); WavFileWrapper wav = new WavFileWrapper(@"C:\Users\hungc\Desktop\Project\Binary\TestExtraction\Debug\what_movies_have_you_seen_recently.wav"); bool result = wav.Load(); wav.SelectedWave(11999, 12512); MFCCWrapper mfcc = new MFCCWrapper(wav, 512u, 0u, 20u, 0.0f, 8000.0f, 12u, 2); mfcc.Process(); WaveViewerForm wavView = new WaveViewerForm(); wavView.Data = wav.SelectedData; wavView.Show(); LineChartForm chart = new LineChartForm(Object.Enum.FormTag.NONE); chart.MaxValue = (int)mfcc.Mfcc[0].Max() + 1; chart.MinValue = (int)mfcc.Mfcc[0].Min() - 1; chart.Data = mfcc.Mfcc[0]; chart.Show(); }
private void SetDataChart(FormTag tag) { if (this.InvokeRequired) { Action <FormTag> act = new Action <FormTag>(SetDataChart); Invoke(act, new object[] { tag }); } else { switch (tag) { case FormTag.REF_WAVE: if (refvoice_wave == null || refvoice_wave.IsDisposed) { refvoice_wave = new WaveViewerForm(tag); refvoice_wave.Text = "Ref Wave Chart"; } if (refmfcc != null && refmfcc.ProcessDone) { refvoice_wave.FilePath = refmfcc.Path + " FSize: " + refmfcc.FrameSize.ToString() + " SRate:" + _refWav.SampleRate.ToString(); refvoice_wave.Data = _refWav.SelectedData; } break; case FormTag.REF_FREQ: if (refvoice_freq == null || refvoice_freq.IsDisposed) { refvoice_freq = new MfccChartForm(tag); refvoice_freq.Text = "Ref Freq Chart"; } if (refmfcc != null && refmfcc.ProcessDone) { refvoice_freq.Title = refmfcc.Path; refvoice_freq.Data = refmfcc.Freq; } break; case FormTag.REF_MFCC: if (refvoice_mfcc == null || refvoice_mfcc.IsDisposed) { refvoice_mfcc = new MfccChartForm(tag); refvoice_mfcc.Text = "Ref MFCC Chart"; } if (refmfcc != null && refmfcc.ProcessDone) { refvoice_mfcc.Title = refmfcc.Path; refvoice_mfcc.Data = refmfcc.Mfcc; } break; case FormTag.REF_DOUBLE: if (refvoice_double == null || refvoice_double.IsDisposed) { refvoice_double = new MfccChartForm(tag); refvoice_double.Text = "Ref Double Chart"; } if (refmfcc != null && refmfcc.ProcessDone) { refvoice_double.Title = refmfcc.Path; refvoice_double.Data = refmfcc.DoubleDetalMfcc; } break; case FormTag.REF_DETAL: if (refvoice_detal == null || refvoice_detal.IsDisposed) { refvoice_detal = new MfccChartForm(tag); refvoice_detal.Text = "Ref Delta Chart"; } if (refmfcc != null && refmfcc.ProcessDone) { refvoice_detal.Title = refmfcc.Path; refvoice_detal.Data = refmfcc.DetalMfcc; } break; case FormTag.REF_PITCH: if (refvoice_pitch == null || refvoice_pitch.IsDisposed) { refvoice_pitch = new LineChartForm(tag); refvoice_pitch.Text = "Ref Pitch Chart"; } if (refpitch != null /*&& refpitch.IsProcessed == (int)State.SUCCESSED*/) { refvoice_pitch.Data = refpitch.SmoothPitchs; } break; case FormTag.YOUR_WAVE: if (yourvoice_wave == null || yourvoice_wave.IsDisposed) { yourvoice_wave = new WaveViewerForm(tag); yourvoice_wave.Text = "Your Wave Chart"; } if (yourmfcc != null && yourmfcc.ProcessDone) { yourvoice_wave.FilePath = yourmfcc.Path + " FSize: " + yourmfcc.FrameSize.ToString() + " SRate:" + _yourWav.SampleRate.ToString();; yourvoice_wave.Data = _yourWav.SelectedData; } break; case FormTag.YOUR_FREQ: if (yourvoice_freq == null || yourvoice_freq.IsDisposed) { yourvoice_freq = new MfccChartForm(tag); yourvoice_freq.Text = "Your Freq Chart"; } if (yourmfcc != null && yourmfcc.ProcessDone) { yourvoice_freq.Title = yourmfcc.Path; yourvoice_freq.Data = yourmfcc.Freq; //yourvoice_freq.Pitch = yourpitch.Pitchs; } break; case FormTag.YOUR_MFCC: if (yourvoice_mfcc == null || yourvoice_mfcc.IsDisposed) { yourvoice_mfcc = new MfccChartForm(tag); yourvoice_mfcc.Text = "Your MFCC Chart"; } if (yourmfcc != null && yourmfcc.ProcessDone) { yourvoice_mfcc.Title = yourmfcc.Path; yourvoice_mfcc.Data = yourmfcc.Mfcc; } break; case FormTag.YOUR_DOUBLE: if (yourvoice_double == null || yourvoice_double.IsDisposed) { yourvoice_double = new MfccChartForm(tag); yourvoice_double.Text = "Your Double Chart"; } if (yourmfcc != null && yourmfcc.ProcessDone) { yourvoice_double.Title = yourmfcc.Path; yourvoice_double.Data = yourmfcc.DoubleDetalMfcc; } break; case FormTag.YOUR_DETAL: if (yourvoice_detal == null || yourvoice_detal.IsDisposed) { yourvoice_detal = new MfccChartForm(tag); yourvoice_detal.Text = "Your Delta Chart"; } if (yourmfcc != null && yourmfcc.ProcessDone) { yourvoice_detal.Title = yourmfcc.Path; yourvoice_detal.Data = yourmfcc.DetalMfcc; } break; case FormTag.YOUR_PITCH: if (yourvoice_pitch == null || yourvoice_pitch.IsDisposed) { yourvoice_pitch = new LineChartForm(tag); yourvoice_pitch.Text = "Your Pitch Chart"; } if (yourpitch != null) { yourvoice_pitch.Data = yourpitch.SmoothPitchs; } break; } } }
private void ShowChart(FormTag tag, bool value) { if (InvokeRequired) { Action <FormTag, bool> act = new Action <FormTag, bool>(ShowChart); Invoke(act, new object[] { tag, value }); } else { switch (tag) { case FormTag.REF_WAVE: if (refvoice_wave == null || refvoice_wave.IsDisposed) { refvoice_wave = new WaveViewerForm(tag); SetDataChart(FormTag.REF_WAVE); } if (value) { if (!refvoice_wave.Visible) { refvoice_wave.Show(); } } else { if (refvoice_wave.Visible) { refvoice_wave.Hide(); } } break; case FormTag.REF_FREQ: if (refvoice_freq == null || refvoice_freq.IsDisposed) { refvoice_freq = new MfccChartForm(tag); SetDataChart(tag); } if (value) { if (!refvoice_freq.Visible) { refvoice_freq.Show(); } } else { if (refvoice_freq.Visible) { refvoice_freq.Hide(); } } break; case FormTag.REF_MFCC: if (refvoice_mfcc == null || refvoice_mfcc.IsDisposed) { refvoice_mfcc = new MfccChartForm(tag); SetDataChart(tag); } if (value) { if (!refvoice_mfcc.Visible) { refvoice_mfcc.Show(); } } else { if (refvoice_mfcc.Visible) { refvoice_mfcc.Hide(); } } break; case FormTag.REF_DOUBLE: if (refvoice_double == null || refvoice_double.IsDisposed) { refvoice_double = new MfccChartForm(tag); SetDataChart(tag); } if (value) { if (!refvoice_double.Visible) { refvoice_double.Show(); } } else { if (refvoice_double.Visible) { refvoice_double.Hide(); } } break; case FormTag.REF_DETAL: if (refvoice_detal == null || refvoice_detal.IsDisposed) { refvoice_detal = new MfccChartForm(tag); SetDataChart(tag); } if (value) { if (!refvoice_detal.Visible) { refvoice_detal.Show(); } } else { if (refvoice_detal.Visible) { refvoice_detal.Hide(); } } break; case FormTag.REF_PITCH: if (refvoice_pitch == null || refvoice_pitch.IsDisposed) { refvoice_pitch = new LineChartForm(tag); SetDataChart(tag); } if (value) { if (!refvoice_pitch.Visible) { refvoice_pitch.Show(); } } else { if (refvoice_pitch.Visible) { refvoice_pitch.Hide(); } } break; case FormTag.YOUR_WAVE: if (yourvoice_wave == null || yourvoice_wave.IsDisposed) { yourvoice_wave = new WaveViewerForm(tag); SetDataChart(tag); } if (value) { if (!yourvoice_wave.Visible) { yourvoice_wave.Show(); } } else { if (yourvoice_wave.Visible) { yourvoice_wave.Hide(); } } break; case FormTag.YOUR_FREQ: if (yourvoice_freq == null || yourvoice_freq.IsDisposed) { yourvoice_freq = new MfccChartForm(tag); SetDataChart(tag); } if (value) { if (!yourvoice_freq.Visible) { yourvoice_freq.Show(); } } else { if (yourvoice_freq.Visible) { yourvoice_freq.Hide(); } } break; case FormTag.YOUR_MFCC: if (yourvoice_mfcc == null || yourvoice_mfcc.IsDisposed) { yourvoice_mfcc = new MfccChartForm(tag); SetDataChart(tag); } if (value) { if (!yourvoice_mfcc.Visible) { yourvoice_mfcc.Show(); } } else { if (yourvoice_mfcc.Visible) { yourvoice_mfcc.Hide(); } } break; case FormTag.YOUR_DOUBLE: if (yourvoice_double == null || yourvoice_double.IsDisposed) { yourvoice_double = new MfccChartForm(tag); SetDataChart(tag); } if (value) { if (!yourvoice_double.Visible) { yourvoice_double.Show(); } } else { if (yourvoice_double.Visible) { yourvoice_double.Hide(); } } break; case FormTag.YOUR_DETAL: if (yourvoice_detal == null || yourvoice_detal.IsDisposed) { yourvoice_detal = new MfccChartForm(tag); SetDataChart(tag); yourvoice_detal.Text = ""; } if (value) { if (!yourvoice_detal.Visible) { yourvoice_detal.Show(); } } else { if (yourvoice_detal.Visible) { yourvoice_detal.Hide(); } } break; case FormTag.YOUR_PITCH: if (yourvoice_pitch == null || yourvoice_pitch.IsDisposed) { yourvoice_pitch = new LineChartForm(tag); SetDataChart(tag); } if (value) { if (!yourvoice_pitch.Visible) { yourvoice_pitch.Show(); } } else { if (yourvoice_pitch.Visible) { yourvoice_pitch.Hide(); } } break; } } }
private void SetDataChart(FormTag tag) { if (InvokeRequired) { Action <FormTag> act = new Action <FormTag>(SetDataChart); Invoke(act, new object[] { tag }); } else { switch (tag) { case FormTag.REF_WAVE: if (_refVoiceWave == null || _refVoiceWave.IsDisposed) { _refVoiceWave = new WaveViewerForm(tag); _refVoiceWave.Text = "Ref Wave Chart"; } if (_refMfcc != null && _refMfcc.ProcessDone && _refWav != null && _refWav.IsValid) { _refVoiceWave.FilePath = _refWav.Path + " FSize: " + _refMfcc.FrameSize.ToString() + " SRate:" + _refWav.SampleRate.ToString(); _refVoiceWave.Data = _refWav.SelectedData; } break; case FormTag.REF_FREQ: if (_refVoiceFreq == null || _refVoiceFreq.IsDisposed) { _refVoiceFreq = new MfccChartForm(tag); _refVoiceFreq.Text = "Ref Freq Chart"; } if (_refMfcc != null && _refMfcc.ProcessDone) { _refVoiceFreq.Title = _refMfcc.Path; _refVoiceFreq.Data = _refMfcc.Freq; } break; case FormTag.REF_MFCC: if (_refVoiceMfcc == null || _refVoiceMfcc.IsDisposed) { _refVoiceMfcc = new MfccChartForm(tag); _refVoiceMfcc.Text = "Ref MFCC Chart"; } if (_refMfcc != null && _refMfcc.ProcessDone) { _refVoiceMfcc.Title = _refMfcc.Path; _refVoiceMfcc.Data = _refMfcc.Mfcc; } break; case FormTag.REF_DOUBLE: if (_refVoiceDouble == null || _refVoiceDouble.IsDisposed) { _refVoiceDouble = new MfccChartForm(tag); _refVoiceDouble.Text = "Ref Double Chart"; } if (_refMfcc != null && _refMfcc.ProcessDone) { _refVoiceDouble.Title = _refMfcc.Path; _refVoiceDouble.Data = _refMfcc.DoubleDetalMfcc; } break; case FormTag.REF_DETAL: if (_refVoiceDetal == null || _refVoiceDetal.IsDisposed) { _refVoiceDetal = new MfccChartForm(tag); _refVoiceDetal.Text = "Ref Delta Chart"; } if (_refMfcc != null && _refMfcc.ProcessDone) { _refVoiceDetal.Title = _refMfcc.Path; _refVoiceDetal.Data = _refMfcc.DetalMfcc; } break; case FormTag.REF_PITCH: if (_refVoicePitch == null || _refVoicePitch.IsDisposed) { _refVoicePitch = new LineChartForm(tag); _refVoicePitch.Text = "Ref Pitch Chart"; } if (_refPitch != null) { _refVoicePitch.Data = _refPitch.SmoothPitchs; } break; case FormTag.YOUR_WAVE: if (_yourVoiceWave == null || _yourVoiceWave.IsDisposed) { _yourVoiceWave = new WaveViewerForm(tag); _yourVoiceWave.Text = "Your Wave Chart"; } if (_yourWav != null && _yourWav.IsValid && _yourMfcc != null && _yourMfcc.ProcessDone) { _yourVoiceWave.FilePath = _yourMfcc.Path + " FSize: " + _yourMfcc.FrameSize.ToString() + " SRate:" + _yourWav.SampleRate.ToString(); _yourVoiceWave.Data = _yourWav.SelectedData; } break; case FormTag.YOUR_FREQ: if (_yourVoiceFreq == null || _yourVoiceFreq.IsDisposed) { _yourVoiceFreq = new MfccChartForm(tag); _yourVoiceFreq.Text = "Your Freq Chart"; } if (_yourMfcc != null && _yourMfcc.ProcessDone) { _yourVoiceFreq.Title = _yourMfcc.Path; _yourVoiceFreq.Data = _yourMfcc.Freq; } break; case FormTag.YOUR_MFCC: if (_yourVoiceMfcc == null || _yourVoiceMfcc.IsDisposed) { _yourVoiceMfcc = new MfccChartForm(tag); _yourVoiceMfcc.Text = "Your MFCC Chart"; } if (_yourMfcc != null && _yourMfcc.ProcessDone) { _yourVoiceMfcc.Title = _yourMfcc.Path; _yourVoiceMfcc.Data = _yourMfcc.Mfcc; } break; case FormTag.YOUR_DOUBLE: if (_yourVoiceDouble == null || _yourVoiceDouble.IsDisposed) { _yourVoiceDouble = new MfccChartForm(tag); _yourVoiceDouble.Text = "Your Double Chart"; } if (_yourMfcc != null && _yourMfcc.ProcessDone) { _yourVoiceDouble.Title = _yourMfcc.Path; _yourVoiceDouble.Data = _yourMfcc.DoubleDetalMfcc; } break; case FormTag.YOUR_DETAL: if (_yourVoiceDetal == null || _yourVoiceDetal.IsDisposed) { _yourVoiceDetal = new MfccChartForm(tag); _yourVoiceDetal.Text = "Your Delta Chart"; } if (_yourMfcc != null && _yourMfcc.ProcessDone) { _yourVoiceDetal.Title = _yourMfcc.Path; _yourVoiceDetal.Data = _yourMfcc.DetalMfcc; } break; case FormTag.YOUR_PITCH: if (_yourVoicePitch == null || _yourVoicePitch.IsDisposed) { _yourVoicePitch = new LineChartForm(tag); _yourVoicePitch.Text = "Your Pitch Chart"; } if (_yourPitch != null) { _yourVoicePitch.Data = _yourPitch.SmoothPitchs; } break; } } }
private void ShowChart(FormTag tag, bool value) { if (InvokeRequired) { Action <FormTag, bool> act = new Action <FormTag, bool>(ShowChart); Invoke(act, new object[] { tag, value }); } else { switch (tag) { case FormTag.REF_WAVE: if (_refVoiceWave == null || _refVoiceWave.IsDisposed) { _refVoiceWave = new WaveViewerForm(tag); SetDataChart(FormTag.REF_WAVE); } if (value) { if (!_refVoiceWave.Visible) { _refVoiceWave.Show(); } } else { if (_refVoiceWave.Visible) { _refVoiceWave.Hide(); } } break; case FormTag.REF_FREQ: if (_refVoiceFreq == null || _refVoiceFreq.IsDisposed) { _refVoiceFreq = new MfccChartForm(tag); SetDataChart(tag); } if (value) { if (!_refVoiceFreq.Visible) { _refVoiceFreq.Show(); } } else { if (_refVoiceFreq.Visible) { _refVoiceFreq.Hide(); } } break; case FormTag.REF_MFCC: if (_refVoiceMfcc == null || _refVoiceMfcc.IsDisposed) { _refVoiceMfcc = new MfccChartForm(tag); SetDataChart(tag); } if (value) { if (!_refVoiceMfcc.Visible) { _refVoiceMfcc.Show(); } } else { if (_refVoiceMfcc.Visible) { _refVoiceMfcc.Hide(); } } break; case FormTag.REF_DOUBLE: if (_refVoiceDouble == null || _refVoiceDouble.IsDisposed) { _refVoiceDouble = new MfccChartForm(tag); SetDataChart(tag); } if (value) { if (!_refVoiceDouble.Visible) { _refVoiceDouble.Show(); } } else { if (_refVoiceDouble.Visible) { _refVoiceDouble.Hide(); } } break; case FormTag.REF_DETAL: if (_refVoiceDetal == null || _refVoiceDetal.IsDisposed) { _refVoiceDetal = new MfccChartForm(tag); SetDataChart(tag); } if (value) { if (!_refVoiceDetal.Visible) { _refVoiceDetal.Show(); } } else { if (_refVoiceDetal.Visible) { _refVoiceDetal.Hide(); } } break; case FormTag.REF_PITCH: if (_refVoicePitch == null || _refVoicePitch.IsDisposed) { _refVoicePitch = new LineChartForm(tag); SetDataChart(tag); } if (value) { if (!_refVoicePitch.Visible) { _refVoicePitch.Show(); } } else { if (_refVoicePitch.Visible) { _refVoicePitch.Hide(); } } break; case FormTag.YOUR_WAVE: if (_yourVoiceWave == null || _yourVoiceWave.IsDisposed) { _yourVoiceWave = new WaveViewerForm(tag); SetDataChart(tag); } if (value) { if (!_yourVoiceWave.Visible) { _yourVoiceWave.Show(); } } else { if (_yourVoiceWave.Visible) { _yourVoiceWave.Hide(); } } break; case FormTag.YOUR_FREQ: if (_yourVoiceFreq == null || _yourVoiceFreq.IsDisposed) { _yourVoiceFreq = new MfccChartForm(tag); SetDataChart(tag); } if (value) { if (!_yourVoiceFreq.Visible) { _yourVoiceFreq.Show(); } } else { if (_yourVoiceFreq.Visible) { _yourVoiceFreq.Hide(); } } break; case FormTag.YOUR_MFCC: if (_yourVoiceMfcc == null || _yourVoiceMfcc.IsDisposed) { _yourVoiceMfcc = new MfccChartForm(tag); SetDataChart(tag); } if (value) { if (!_yourVoiceMfcc.Visible) { _yourVoiceMfcc.Show(); } } else { if (_yourVoiceMfcc.Visible) { _yourVoiceMfcc.Hide(); } } break; case FormTag.YOUR_DOUBLE: if (_yourVoiceDouble == null || _yourVoiceDouble.IsDisposed) { _yourVoiceDouble = new MfccChartForm(tag); SetDataChart(tag); } if (value) { if (!_yourVoiceDouble.Visible) { _yourVoiceDouble.Show(); } } else { if (_yourVoiceDouble.Visible) { _yourVoiceDouble.Hide(); } } break; case FormTag.YOUR_DETAL: if (_yourVoiceDetal == null || _yourVoiceDetal.IsDisposed) { _yourVoiceDetal = new MfccChartForm(tag); SetDataChart(tag); _yourVoiceDetal.Text = string.Empty; } if (value) { if (!_yourVoiceDetal.Visible) { _yourVoiceDetal.Show(); } } else { if (_yourVoiceDetal.Visible) { _yourVoiceDetal.Hide(); } } break; case FormTag.YOUR_PITCH: if (_yourVoicePitch == null || _yourVoicePitch.IsDisposed) { _yourVoicePitch = new LineChartForm(tag); SetDataChart(tag); } if (value) { if (!_yourVoicePitch.Visible) { _yourVoicePitch.Show(); } } else { if (_yourVoicePitch.Visible) { _yourVoicePitch.Hide(); } } break; } } }