예제 #1
0
 public MidiTimeSignature(long startTime, string metrum, string clocksPerCklicks, string thirtySecondNotesPerBeat, TempoMap tempoMap)
 {
     this.time                     = new MidiTime(startTime, tempoMap);
     this.metrum                   = metrum;
     this.clocksPerCklicks         = clocksPerCklicks;
     this.thirtySecondNotesPerBeat = thirtySecondNotesPerBeat;
 }
예제 #2
0
 public MidiEventsTimeline(string eventName, MidiPitchBend pb)
 {
     this.eventName = eventName;
     this.time      = pb.time.midi;
     this.note      = null;
     this.pb        = pb;
     this.ts        = null;
     this.midiTime  = pb.time;
 }
예제 #3
0
 public MidiEventsTimeline(string eventName, MidiTimeSignature ts)
 {
     this.eventName = eventName;
     this.time      = ts.time.midi;
     this.note      = null;
     this.pb        = null;
     this.ts        = ts;
     this.midiTime  = ts.time;
 }
예제 #4
0
 public MidiEventsTimeline(string eventName, MidiNote note)
 {
     this.eventName = eventName;
     this.time      = note.time.midi;
     this.note      = note;
     this.pb        = null;
     this.ts        = null;
     this.midiTime  = note.time;
 }
예제 #5
0
 public MidiNote(string name, int octave, MidiTime time, MidiTime length, int velocity, int velocityOff, int midiNumber)
 {
     if (name.Length > 1)
     {
         this.name = name.First().ToString() + "#";
     }
     else
     {
         this.name = name;
     }
     this.octave      = octave;
     this.time        = time;
     this.length      = length;
     this.velocity    = velocity;
     this.velocityOff = velocityOff;
     this.midiNumber  = midiNumber;
     this.frequency   = MidiComposition.getFrequency(midiNumber);
 }
예제 #6
0
 private void parseNotes(IEnumerable <Note> noteList, TempoMap tempoMap)
 {
     foreach (var note in noteList)
     {
         int nr = Int32.Parse(note.Channel.ToString());
         if (nr == instrument.channel)
         {
             string   name        = note.NoteName.ToString();
             int      octave      = note.Octave;
             MidiTime time        = new MidiTime(note.Time, tempoMap);
             MidiTime length      = new MidiTime(note.Length, tempoMap);
             int      velocity    = Int32.Parse(note.Velocity.ToString());
             int      velocityOff = Int32.Parse(note.OffVelocity.ToString());
             int      noteNr      = Int32.Parse(note.NoteNumber.ToString());
             MidiNote midiNote    = new MidiNote(name, octave, time, length, velocity, velocityOff, noteNr);
             this.notes.Add(midiNote);
         }
     }
 }
예제 #7
0
        public MidiComposition(string filePath)
        {
            MidiFile midiFile = MidiFile.Read(filePath);

            if (midiFile.OriginalFormat != MidiFileFormat.MultiTrack)
            {
                midiFile.Write(filePath, format: MidiFileFormat.MultiTrack, overwriteFile: true);
                midiFile = MidiFile.Read(filePath);
            }
            this.midiFormat     = midiFile.OriginalFormat.ToString();
            this.file           = midiFile;
            this.title          = "";
            this.timeDivision   = midiFile.TimeDivision.ToString();
            this.duration       = new MidiTime(midiFile.GetDuration(TimeSpanType.Midi).ToString(), midiFile.GetTempoMap());
            this.tracks         = new List <MidiTrack>();
            this.timeSignatures = new List <MidiTimeSignature>();
            this.tempo          = new List <MidiTempo>();
            initFrequencies(440);
            parseTracks(midiFile);
            initTimeSignatures();
        }
예제 #8
0
        public MidiComposition(string filePath, string mode)
        {
            CsvConverter csv = new CsvConverter();
            MidiFileCsvConversionSettings setting = new MidiFileCsvConversionSettings
            {
                TimeType         = TimeSpanType.Midi,
                NoteLengthType   = TimeSpanType.Musical,
                NoteFormat       = NoteFormat.Note,
                NoteNumberFormat = NoteNumberFormat.Letter
            };
            MidiFile midiFile = csv.ConvertCsvToMidiFile(filePath, setting);

            this.file           = midiFile;
            this.title          = "";
            this.midiFormat     = midiFile.OriginalFormat.ToString();
            this.timeDivision   = midiFile.TimeDivision.ToString();
            this.duration       = new MidiTime(midiFile.GetDuration(TimeSpanType.Midi).ToString(), midiFile.GetTempoMap());
            this.tracks         = new List <MidiTrack>();
            this.timeSignatures = new List <MidiTimeSignature>();
            this.tempo          = new List <MidiTempo>();
            initFrequencies(440);
            parseTracks(midiFile);
            initTimeSignatures();
        }
예제 #9
0
 public MidiTempo(long startTime, long value, TempoMap tempoMap)
 {
     this.time      = new MidiTime(startTime, tempoMap);
     this.midiValue = value;
     this.bpm       = Convert.ToInt32(60000000 / value);
 }
예제 #10
0
 public MidiPitchBend(long startTime, int value, TempoMap tempoMap)
 {
     this.time  = new MidiTime(startTime, tempoMap);;
     this.value = value;
 }