I am currently implementing my latest project as a student in software development for music. I am making software that plays a midi track that is generated earlier in the process.
There is a play button and a stop button in my interface. When I press "play", a loop is called that plays this track. In this loop, I call a function from an instance of another class.
What I would like is that when the user presses "pause", the cycle stops temporarily, and when he presses "pause" again, he returns to exactly where he was in the cycle.
While I press the play button, the track plays back what I want, but I cannot use any other element of my window until the loop is fully processed.
Here is my code.
private void playStopButton_Click(object sender, RoutedEventArgs e)
{
outDevice.Send(new ChannelMessage(ChannelCommand.ProgramChange, information.bassChannel, information.bassSound));
outDevice.Send(new ChannelMessage(ChannelCommand.ProgramChange, information.guitarChannel, information.guitarSound));
for (int barNum = 0; barNum < Globals.numberOfBars; barNum++)
{
rythmicPattern.play(0, ref outDevice, information, Globals.chordProgression.Bars[barNum].Chord);
rythmicPattern.play(1, ref outDevice, information, Globals.chordProgression.Bars[barNum].Chord);
rythmicPattern.play(2, ref outDevice, information, Globals.chordProgression.Bars[barNum].Chord);
rythmicPattern.play(3, ref outDevice, information, Globals.chordProgression.Bars[barNum].Chord);
}
}
private void playPauseButton_Click(object sender, RoutedEventArgs e)
{
if (isPlaying)
rythmicPattern.Pause();
else
rythmicPattern.PlayAfterPause(beatNumber);
}
Thank you for your help. Greg
source
share