private static void ReadWriteFileTest(String input, String output) { MidiFile mf = new MidiFile(); mf.Import(input); mf.Export(output); }
private static void CreateFileTest(String pathAndFilename) { MidiFile myFile = new MidiFile(); myFile.Header.FormatType = TrackFormatType.Single; myFile.Header.NumberOfTracks = 1; myFile.Header.PulsesPerQuarterNote = 960; TrackChunk tc1 = new TrackChunk(); tc1.File = myFile; myFile.Tracks.Add(tc1); tc1.File = myFile; tc1.SequenceNumber = new SequenceNumberEvent(0, 0); tc1.Comments = new TextEvent("Comments"); tc1.CopyrightNotice = new CopyrightNoticeEvent("CopyrightNotice"); tc1.TrackName = new TrackNameEvent("TrackName"); tc1.InstrumentName = new InstrumentNameEvent("InstrumentName"); tc1.Lyrics = new LyricsEvent("Lyrics"); tc1.Marker = new MarkerEvent("Marker"); tc1.CuePoint = new CuePointEvent("CuePoint"); tc1.DeviceName = new DeviceNameEvent("DeviceName"); tc1.Channel = new MidiChannelEvent(3); tc1.Port = new MidiPortEvent(6); tc1.TimeSignature = new TimeSignatureEvent(4, 4, 24, 8); tc1.Tempo = new TempoEvent(130.0); //tc1.SMPTEOffSet = new SMPTEOffSetEvent(); tc1.KeySignature = new KeySignatureEvent(0, 1); tc1.ChannelEvents.Add(ChannelMidiEvent.CreateNoteOnChannelMidiEvent(0, 64, 100, 0)); tc1.ChannelEvents.Add(ChannelMidiEvent.CreateNoteOffChannelMidiEvent(0, 64, 960)); tc1.ChannelEvents.Add(ChannelMidiEvent.CreateNoteOnChannelMidiEvent(0, 63, 90, 0)); tc1.ChannelEvents.Add(ChannelMidiEvent.CreateNoteOffChannelMidiEvent(0, 63, 960)); myFile.Export(pathAndFilename); }