1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| public partial class MIDITest : Form
{
OutputDevice outStream;
ChannelMessageBuilder builder;
ChannelMessage on;
ChannelMessage off;
List<Notes> notes;
Thread threadPlay;
private delegate void ChangeListBox();
public MIDITest()
{
InitializeComponent();
threadPlay = new Thread(new ThreadStart(threadPlayMethod));
[...]
}
private void button1_Click(object sender, EventArgs e)
{
threadPlay.Start();
}
private void threadPlayMethod()
{
this.Invoke(new ChangeListBox(PlayMethod));
}
private void PlayMethod()
{
int i = 0;
foreach (Notes n in notes)
{
listBox1.SelectedIndex = i;
i++;
n.Play(outStream, Convert.ToInt32(NUDtempo.Value));
}
listBox1.SelectedIndex = -1;
} |
Partager