private void Button_Click(object sender, RoutedEventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "MusicXml (*.xml)|*.xml"; Score score = null; string scoreXml; if (dialog.ShowDialog().Value) { System.IO.Stream fileStream = dialog.File.OpenRead(); using (System.IO.StreamReader reader = new System.IO.StreamReader(fileStream)) { scoreXml = reader.ReadToEnd(); } fileStream.Close(); score = scoreXml.ToScore(); noteViewer1.ScoreSource = score; noteViewer3.ScoreSource = scoreXml.ToScore(); //MusicXmlNormalizer normalizer = new MusicXmlNormalizer() { NormalizeSpaceBeforeFirstNotesOfMeasures = true }; //noteViewer2.XmlTransformations = new[] { normalizer }; //noteViewer2.XmlSource = scoreXml; MelodicContourDigestParser digestParser = new MelodicContourDigestParser(); int[] results = digestParser.ParseBack(score); LyricsDigestParser lyricsParser = new LyricsDigestParser(); string lyrics = lyricsParser.ParseBack(score); //MessageBox.Show(string.Join(", ", results)); } }
private async Task LoadFilesAsync() { FileOpenPicker dialog = new FileOpenPicker(); dialog.ViewMode = PickerViewMode.Thumbnail; dialog.FileTypeFilter.Add(".xml"); Score score = null; string scoreXml; var result = await dialog.PickSingleFileAsync(); using (Stream fileStream = (await result.OpenAsync(Windows.Storage.FileAccessMode.Read)).AsStreamForRead()) { using (StreamReader reader = new StreamReader(fileStream)) { scoreXml = reader.ReadToEnd(); } score = scoreXml.ToScore(); noteViewer1.ScoreSource = score; var player = new MidiTaskScorePlayer(score, noteViewer1.Dispatcher); var devices = await player.GetDeviceNamesAsync(); await player.InitializeAsync(devices[0]); var vm = new TestViewModel() { Player = player }; DataContext = vm; //noteViewer3.ScoreSource = score; MusicXmlNormalizer normalizer = new MusicXmlNormalizer() { NormalizeSpaceBeforeFirstNotesOfMeasures = true }; noteViewer2.XmlTransformations = new[] { normalizer }; noteViewer2.XmlSource = scoreXml; MelodicContourDigestParser digestParser = new MelodicContourDigestParser(); int[] results = digestParser.ParseBack(score); LyricsDigestParser lyricsParser = new LyricsDigestParser(); string lyrics = lyricsParser.ParseBack(score); //MessageBox.Show(string.Join(", ", results)); } }
/// <summary> /// Returns lyrics digest obtained by LyricsDigestParser /// </summary> /// <param name="score"></param> /// <returns></returns> public static string ToLyricsDigest(this Score score) { LyricsDigestParser parser = new LyricsDigestParser(); return(parser.ParseBack(score)); }