private int _beatsPerBar; // Aantal beatnotes per maat. async public Task OpenFile(string fileName) { var sheetReaderFactory = new SheetReaderFactory(); var sheetWriterFactory = new SheetWriterFactory(); var sheetReader = sheetReaderFactory.GetReader(fileName); var converter = new SheetToWPFConverter(); var writer = sheetWriterFactory.GetWriter(".ly"); var sheet = await sheetReader.ReadFromFileAsync(); WPFStaffs.Clear(); WPFStaffs.AddRange(converter.ConvertSheet(sheet)); WPFStaffsChanged?.Invoke(this, new WPFStaffsEventArgs() { Symbols = WPFStaffs }); LilypondTextChanged?.Invoke(this, new LilypondEventArgs { LilypondText = await writer.WriteToString(sheet) }); MidiSequence = GetSequenceFromWPFStaffs(); MidiSequenceChanged?.Invoke(this, new MidiSequenceEventArgs() { MidiSequence = MidiSequence }); }
async public Task TextChanged(string lilypondText) { var sheetReaderFactory = new SheetReaderFactory(); var sheetReader = sheetReaderFactory.GetReader(".ly"); try { var sheet = await sheetReader.ReadFromStringAsync(lilypondText); var converter = new SheetToWPFConverter(); WPFStaffs.Clear(); WPFStaffs.AddRange(converter.ConvertSheet(sheet)); WPFStaffsChanged?.Invoke(this, new WPFStaffsEventArgs() { Symbols = WPFStaffs }); MidiSequence = GetSequenceFromWPFStaffs(); MidiSequenceChanged?.Invoke(this, new MidiSequenceEventArgs() { MidiSequence = MidiSequence }); } catch (Exception) { Messenger.Default.Send(new CurrentStateMessage() { State = "Error parsing lilypond" }); } }
public void LoadLilypond(string content) { WPFStaffs.Clear(); LilypondText = content.Length > 0 ? content : ""; var tokens = GetTokensFromLilypond(content); var staffCollection = new LilypondClient(tokens).Solve(); WPFStaffs.AddRange(staffCollection); WPFStaffsChanged?.Invoke(this, new WPFStaffsEventArgs() { Symbols = WPFStaffs, Message = "" }); MidiSequence = new StaffHandler().GetSequenceFromWPFStaffs(WPFStaffs); MidiSequenceChanged?.Invoke(this, new MidiSequenceEventArgs() { MidiSequence = MidiSequence }); }
public void LoadLilypond(string content) { LilypondText = content; content = content.Trim().ToLower().Replace("\r\n", " ").Replace("\n", " ").Replace(" ", " "); LinkedList <LilypondToken> tokens = GetTokensFromLilypond(content); WPFStaffs.Clear(); string message; WPFStaffs.AddRange(GetStaffsFromTokens(tokens, out message)); WPFStaffsChanged?.Invoke(this, new WPFStaffsEventArgs() { Symbols = WPFStaffs, Message = message }); MidiSequence = GetSequenceFromWPFStaffs(); MidiSequenceChanged?.Invoke(this, new MidiSequenceEventArgs() { MidiSequence = MidiSequence }); }
public void ShowStaff() { WPFStaffs.Clear(); WPFManager.getMusicSymbols(Staff, WPFStaffs); WPFStaffsChanged?.Invoke(this, new WPFStaffsEventArgs() { Symbols = WPFStaffs }); Lilypond lily = new Lilypond(""); LilypondText = lily.GetLilyFromStaff(Staff); Midi midi = new Midi(""); MidiSequence = midi.GetSequenceFromStaff(Staff); MidiSequenceChanged?.Invoke(this, new MidiSequenceEventArgs() { MidiSequence = MidiSequence }); }