Need some debug help
http://www.box.net/shared/6ac37tfmk9
The initial 1 min and 3 minute timer works
But I can not change my mind and select a different time once one started. Also after hitting stop I can not restart
Any thoughts?
Don't mix the code and the behaviour of the xaudio2 object here
The basic code is correct. It changes 'TimerCheck' to the correct values. The problem is the way you use xa2. You order it to autoplay, that means it will use the next free channel to play whatever it needs to play, until the end of the soundfile is reached. This is not sufficient for your needs I think.
Instead, use xa2's 'Load file' to bind the soundfile to a specific channel, and use xa2's 'Play' to play the sound. When hitting the stop button you should then also stop the sound.
To reset the sound, just set the channel's position to zero.
You don't want to repeat an action every x milliseconds, you rather want to loop a timespan for a specific amount of time (until you hit stop) beginning with a button being pressed. I would recommend to use Timer and a global 'TimeStamp" for this task. With modulo you will get a loop over the allowed timespan. There's just one thing to pass attention to: Timer is an exact value, whereas your events are executed within a tick that may last for several milliseconds. That's why you can't directly compare to zero but a range. For most event sheets, one TimeDelta-range should be enough. TimeDelta is a fraction of a second, so multiply it by 1000 to get a milliseconds value to compare with. If your project grows and you happen to not hear the sound playing, just raise that value in TimeDelta steps (so the next range to compare with would be TimeDelta * 2000)
btw, you shouldn't raise the volume to 25db, or you will risk the ears of your users. For very quiet sounds setting the master volume to 6 or at maximum 12 db may be ok. On the other hand, there's always the limiter, if you didn't touch it, it will at least prevent distortion. Also, there is no way to restore to 0db right now.
Yeah, sounds more complicated than it is, really. Have a look at your reworked cap:
rwTimer.cap