private void transcribe_Completed(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e) { MusicMakerSheet r = new MusicMakerSheet(); TrasncriptionResult result = ((TrasncriptionResult)e.Result); string[] midiNotes = new string[result.Notes.Length]; int[] noteOctaves = new int[result.Notes.Length]; string outputNotes = ""; r.ButtomMeasure = 4; r.TopMeasure = 4; const int numOfNotesInLine = 29; for (int i = 0; i < result.Notes.Length; i++) { midiNotes[i] = PitchToNoteConverter.GetNoteName((int)PitchToNoteConverter.PitchToMidiNote(result.Notes[i].Frequency), !isFlat, false, out noteOctaves[i]); midiNotes[i] += Transcription.OctaveLetter(noteOctaves[i]); midiNotes[i] += Transcription.DurationLetter(result.Notes[i].Duration); if (result.Notes[i].Frequency <= 0) { midiNotes[i] = ""; } } int count = 0; for (int i = 0; i < midiNotes.Length; i++) { if (result.Notes[i].Frequency <= 0) { continue; } outputNotes += midiNotes[i]; outputNotes += " "; count++; if (count % numOfNotesInLine == 0 && count != 0) { outputNotes = outputNotes.Trim(); // remove last " " r.paintByString(outputNotes); outputNotes = ""; } } outputNotes = outputNotes.Trim(); // remove last " " r.paintByString(outputNotes); r.Show(); AMBox.Visible = false; if (bpmAutoDetectionCheckBox.Checked) { System.Windows.Forms.MessageBox.Show("BPM detected = " + result.BPM); } BtnTranscribe.Enabled = true; progressBar.Value = 0; }
private void transcribeBtn_Click(object sender, EventArgs e) { if (chosenInstrument == 0) { System.Windows.Forms.MessageBox.Show("Please choose instrument."); } else if (fileTextBox.Text.Trim() == "") { System.Windows.Forms.MessageBox.Show("File missing."); } else if (isBPMValid && isWindowValid && isHopValid && isThresholdValid) { AMBox.Visible = true; BtnTranscribe.Enabled = false; Transcription.Initialize(windowSizeInMs, hopSizeInMs, threshold, BPM, wavFilePath, bpmAutoDetectionCheckBox.Checked, chosenInstrument, CompletedThreadsHandler, isDFT); transcribeWorker.RunWorkerAsync(); } else { System.Windows.Forms.MessageBox.Show("Some of the parameters are inavlid.\nPlease change them and try again."); } }