Note that there are some explanatory texts on larger screens.

plurals
  1. POVS2010 C# function using a loop
    text
    copied!<p>I am currently implementing my final year project as a Music Software Development student. I am making a software that plays a midi track that is generated earlier in the process.</p> <p>In my interface, there is a button "play" and a button "stop". When I click "play", a loop is called that plays this track. In this loop, I call a function from an instance of an other class.</p> <p>What I would like is that when the user press "pause", the loop is temporary stopped, and when he press "pause" again, it goes back exactly where it was in the loop.</p> <p>So far, when I press play, the track plays exactly how I want to, but I can't use any other element of my window until the loop is not completly processed.</p> <p>Here is my code.</p> <pre><code>private void playStopButton_Click(object sender, RoutedEventArgs e) { // Initialising my output midi devices outDevice.Send(new ChannelMessage(ChannelCommand.ProgramChange, information.bassChannel, information.bassSound));//bass outDevice.Send(new ChannelMessage(ChannelCommand.ProgramChange, information.guitarChannel, information.guitarSound));//guitar for (int barNum = 0; barNum &lt; Globals.numberOfBars; barNum++) { // playing the first beat rythmicPattern.play(0, ref outDevice, information, Globals.chordProgression.Bars[barNum].Chord); //second beat rythmicPattern.play(1, ref outDevice, information, Globals.chordProgression.Bars[barNum].Chord); //thrid beat rythmicPattern.play(2, ref outDevice, information, Globals.chordProgression.Bars[barNum].Chord); //fourth beat rythmicPattern.play(3, ref outDevice, information, Globals.chordProgression.Bars[barNum].Chord); } } private void playPauseButton_Click(object sender, RoutedEventArgs e) { // test if the track is being played if (isPlaying) rythmicPattern.Pause(); else // if it was already paused, playing back from where I stopped rythmicPattern.PlayAfterPause(beatNumber); } </code></pre> <p>Thank you for your help. Greg</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload