Why bother with a timer loop to animate the wiper when that functionality is 
built-in through CoreAnimation?
Especially since you are using an image as the wave background.

CoreAnimation will move the wiper smoothly and accurately. All you have to do 
is provide the distance it must travel and the amount of time it should take to 
travel. You get these values from the start or click point.

I know this works well since I use it in an app which also draws audio 
waveforms and moves the wiper. 

Rob

> On Mar 15, 2015, at 4:22 AM, Patrick J. Collins 
> <patr...@collinatorstudios.com> wrote:
> 
>> A fairly simple way to implement a selection rectangle is to use
>> CALayer, but that only gives you the visual aspect. What does it
>> select? Answer that question first and that will tend to lead you to
>> the appropriate way to implement it.
> 
> This NSView is of an audio waveform.  I currently have my drawRect:
> method draw the lines of my waveform, but as soon as I added a timer
> loop to move my playhead over the waveform as it plays, I found that
> this was not the right approach, as everytime the playhead moved, the
> parent (waveform view) would have to redraw itself, and this result in
> the playhead moving in an extremely choppy fashion.
> Why 
> My next approach was to save my drawn waveform to an NSImage and use
> that as a background for my view...  If you have a better suggestion for
> how I could handle this, I'd love to hear it.
> 
> And to answer your question, the selection would be selecting frames of
> audio, so that when it is played, the playhead starts there and ends at
> the end of the rectangle.
> 
> Patrick J. Collins
> http://collinatorstudios.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to