public void CtorTest1(string filename) { var inputFilepath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "midi", filename); var sequence = new Sequence(inputFilepath); Assert.That(sequence.EventCount, Is.GreaterThan(0)); Assert.That(sequence.Format, Is.EqualTo(0).Or.EqualTo(1)); Assert.That(sequence.LoopBeginTick, Is.GreaterThanOrEqualTo(0)); Assert.That(sequence.MaxTick, Is.GreaterThanOrEqualTo(0).And.GreaterThanOrEqualTo(sequence.LoopBeginTick)); Assert.That(sequence.Resolution, Is.GreaterThan(0)); Assert.That(sequence.Tracks, Is.Not.Null); }
public void CtorTest(string filename) { var inputFilepath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "midi", filename); var sequence = new Sequence(inputFilepath); var sequencer = new Sequencer(sequence); Assert.That(sequencer.Interval, Is.GreaterThan(0)); Assert.That(sequencer.LoopBeginTick, Is.GreaterThanOrEqualTo(0)); Assert.That(sequencer.Sequence, Is.EqualTo(sequence)); Assert.That(sequencer.Tempo, Is.Not.Negative); Assert.That(sequencer.TempoFactor, Is.GreaterThanOrEqualTo(0)); }
public bool Load(string path, Guid device) { try { _seq = new Sequence(path); _sr = new Sequencer(_seq); _lastPath = path; _sr.OnTrackEvent += sr_OnTrackEvent; _sr.SequenceEnd += sr_SequenceEnd; _sr.TempoChanged += sr_TempoChanged; return true; } catch (Exception e) { #if DEBUG throw (e); #endif Console.WriteLine(e); return false; } }
public void Unload() { _seq = null; if (_sr != null) { _sr.OnTrackEvent -= sr_OnTrackEvent; _sr.SequenceEnd -= sr_SequenceEnd; _sr.TempoChanged -= sr_TempoChanged; _sr.Stop(); _sr = null; } if (_midi != null) { _midi.Close(); _midi = null; } }
/// <summary> /// シーケンスを指定して新しい <see cref="Sequencer"/> クラスのインスタンスを初期化します。 /// </summary> /// <param name="sequence">一連のイベントが格納されたシーケンス。</param> public Sequencer(Sequence sequence) { if (sequence == null) throw new ArgumentNullException(); Sequence = sequence; eventList = new List<Event>(sequence.Tracks.SelectMany(t => t.Events).OrderBy(e => e.Tick)); endOfTick = sequence.MaxTick; tick = -(long)(sequence.Resolution * 1.0); loopBeginTick = sequence.LoopBeginTick; RecalcTickTime(); }
/// <summary> /// シーケンスを指定して新しい Sequencer クラスのインスタンスを初期化します。 /// </summary> /// <param name="sequence">一連のイベントが格納されたシーケンス。</param> public Sequencer(Sequence sequence) { if (sequence == null) throw new ArgumentNullException(); Sequence = sequence; events = sequence.Events; endOfTick = sequence.MaxTick; tick = -(long)(sequence.Resolution * 1.0); loopBeginTick = sequence.LoopBeginTick; RecalcTickTime(); }