Hi walter, the problem is that mouseMoveCircle is called only when the mouse is moved....that is a drawback of the Set(gcf...) command...maybe I should use something else? Jan, persistent might make sense, I ll try it out....for now I guess using different forms of the get, set commands might do the trick??
How to read mouse position in figure when mouse is static/not moving
2 views (last 30 days)
Show older comments
I am currently using the function: set (gcf, 'WindowButtonMotionFcn', @mouseMoveCircle); where mouseMoveCircle is a custom code which spits out tones/sound based on mouse position in figure. However, if the mouse is not moved, then I want the last played (based on mouse location) to continue playing till mouse is moved again. However, I am unable to figure out now how to figure out if the mouse has been static... Any help will be appreciated...
0 Comments
Accepted Answer
More Answers (2)
Walter Roberson
on 14 Apr 2012
In your mouseMoveCircle, increment a shared variable each time it is called. Then in your other code, if the shared variable is the same as it was last time you checked, then the pointer is static.
3 Comments
Walter Roberson
on 2 May 2012
Blocking play is not going to pay attention to mouse interrupts until the sound ends.
You should be periodically queuing a set of samples for the player, and (if possible) play the sound non-blocking; near the end of each set you would queue more samples based upon the current state. MATLAB does not provide good facilities for this with the standard windows sound device.
In order to do this kind of work you are much better off using a D/A convertor that you can queue samples for, such as via the Data Acquisition toolbox.
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!