本文整理汇总了C#中Sequence.LoadAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Sequence.LoadAsync方法的具体用法?C# Sequence.LoadAsync怎么用?C# Sequence.LoadAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sequence
的用法示例。
在下文中一共展示了Sequence.LoadAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
private void Load()
{
Loading = 0;
outDevice = new OutputDevice(0);
sequencer = new Sequencer();
sequence = new Sequence();
sequencer.ChannelMessagePlayed += delegate (object o, ChannelMessageEventArgs args)
{
ChannelCommand cmd = args.Message.Command;
int channel = args.Message.MidiChannel;
int data1 = args.Message.Data1;
int data2 = args.Message.Data2;
if (cmd == ChannelCommand.NoteOff || data2 == 0)
{
if (lastPlayed[channel, data1] != null)
{
Note n = lastPlayed[channel, data1];
n.Playing = false;
}
}
else if (cmd == ChannelCommand.NoteOn)
{
Note n = new Note()
{
Key = data1,
Length = 0,
Playing = true,
Position = 0,
Time = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond,
Channel = channel,
Velocity = data2
};
lock (notes)
notes.Add(n);
if (lastPlayed[channel, data1] != null)
lastPlayed[channel, data1].Playing = false;
lastPlayed[channel, data1] = n;
}
lock (backlog)
{
backlog.Enqueue(new Event(delegate
{
outDevice.Send(args.Message);
if (cmd == ChannelCommand.NoteOff || data2 == 0)
if (Keyboard.KeyPressed[data1] > 0)
Keyboard.KeyPressed[data1]--;
else if (cmd == ChannelCommand.NoteOn)
Keyboard.KeyPressed[data1]++;
else if (cmd == ChannelCommand.Controller)
if (data1 == 0x07)
Keyboard.ChannelVolume[channel] = data2;
else if (cmd == ChannelCommand.PitchWheel)
{
int pitchValue = Get14BitValue(data1, data2);
Keyboard.Pitchwheel[channel] = pitchValue;
}
}, Delay));
}
};
sequencer.SysExMessagePlayed += delegate (object o, SysExMessageEventArgs args)
{
lock (backlog)
backlog.Enqueue(new Event(() => outDevice.Send(args.Message), Delay));
};
sequencer.Chased += delegate (object o, ChasedEventArgs args)
{
foreach (ChannelMessage message in args.Messages)
lock (backlog)
backlog.Enqueue(new Event(() => outDevice.Send(message), Delay));
};
sequencer.Stopped += delegate (object o, StoppedEventArgs args)
{
foreach (ChannelMessage message in args.Messages)
lock (backlog)
backlog.Enqueue(new Event(() => outDevice.Send(message), Delay));
};
sequence.LoadCompleted += delegate (object o, AsyncCompletedEventArgs args)
{
Loading = -1;
sequencer.Sequence = sequence;
sequencer.Start();
};
sequence.LoadProgressChanged += delegate (object sender, ProgressChangedEventArgs args)
{
Loading = args.ProgressPercentage;
};
sequence.LoadAsync(MIDIFile);
}