• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Best drawing technology for audio waveforms, envelopes, etc.?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best drawing technology for audio waveforms, envelopes, etc.?


  • Subject: Re: Best drawing technology for audio waveforms, envelopes, etc.?
  • From: Alastair Houghton <email@hidden>
  • Date: Sun, 24 Jun 2007 19:20:35 +0100

On 24 Jun 2007, at 18:44, Hans Kuder wrote:

On 6/23/07, Alastair Houghton <email@hidden> wrote:
Each of your layer objects (in your "layers" NSArray, which should be
a member variable) can then implement a -draw method to render
whatever data it pleases.  If a layer is particularly expensive to
render, you could make it draw its content to an image or a CGLayer,
then have the -draw method just render that.

This seems like a pretty reasonable way to go about it. As for the drawing operation itself, how well would a NSBezierPath handle the hundreds of segments required to draw a waveform? At least when zoomed out, it seems a bit overkill to have a "line" between every next pixel on the screen when it's pretty much guaranteed that the user will only see the join points between lines rather than the lines themselves. Is there a more efficient way to do this?

Generally it isn't recommended to draw large numbers of line segments in a single NSBezierPath (we've been told the reason is that NSBezierPath [or, presumably, Quartz 2D] finds self-intersections in order to render semi-transparent paths correctly, which is a relatively expensive operation). You might therefore find that you need to break the drawing up in order to get good performance if you're using NSBezierPath. Of course, if you do that, then drawing using a transparent colour will create artefacts whenever the segments overlap (a workaround would be to draw using an opaque colour into an NSImage or a CGLayer and then composite the NSImage or CGLayer to get the transparency).


I think the best advice is to start with simple drawing code, and optimise it as and when you find that it's a problem. Otherwise you can very easily end up with a lot of complicated code that you really didn't need.

For the very best performance, you'd probably need to render the waveform directly yourself into a bitmap, but I wouldn't start off doing that since it's a fair bit of effort and you might find NSBezierPath acceptable for your application. (Or, you could render with OpenGL, but as I think I may have mentioned, that will create other problems for you, I think.)

Kind regards,

Alastair.

--
http://alastairs-place.net


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Best drawing technology for audio waveforms, envelopes, etc.?
      • From: Wade Tregaskis <email@hidden>
References: 
 >Best drawing technology for audio waveforms, envelopes, etc.? (From: "Hans Kuder" <email@hidden>)
 >Re: Best drawing technology for audio waveforms, envelopes, etc.? (From: Alastair Houghton <email@hidden>)
 >Re: Best drawing technology for audio waveforms, envelopes, etc.? (From: "Hans Kuder" <email@hidden>)

  • Prev by Date: Re: Best drawing technology for audio waveforms, envelopes, etc.?
  • Next by Date: Re: ObjC 3D engine
  • Previous by thread: Re: Best drawing technology for audio waveforms, envelopes, etc.?
  • Next by thread: Re: Best drawing technology for audio waveforms, envelopes, etc.?
  • Index(es):
    • Date
    • Thread