• 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: Design issue related to my problem with NSSound -isPlaying
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Design issue related to my problem with NSSound -isPlaying


  • Subject: Re: Design issue related to my problem with NSSound -isPlaying
  • From: Kyle Sluder <email@hidden>
  • Date: Mon, 23 Jul 2012 07:53:53 -0700

On Jul 23, 2012, at 3:10 AM, Jay Reynolds Freeman <email@hidden> wrote:

>
> The issue is synching animations -- visual ones -- with sounds.  Think of it as lip-synching.  You will recall that what I wanted to do was have a cat-face appear, open its mouth, say (play sound) "meow", then close its mouth and go away.  For this little effect to look best, the open-mouth animation should end just as the sound begins, and the close-mouth animation should start just as the sound ends.  I know I can't count on that happening if I the user has too many processes running and the underlying Unix scheduler decides to swap at just the wrong time, but let's assume that my App is getting plenty of cycles.
>
> There is no problem issuing [meow play] as the next instruction after the end of the open-mouth animation; the issue is doing the best job of making the close-mouth animation start just as the sound ends.  The problem with a call-back method, like the NSSound delegate method "didFinishPlaying:" is that that method evidently works by posting an event of some sort to the main event loop, or perhaps in a dispatch queue somewhere, and if there are other events preceding it in either the event loop or the dispatch queue, the operation of "didFinishPlaying:" may be delayed.  (My app is a Lisp REPL, it occasionally does some big chunks of work; fractional-second delays do happen, and a few of those in the queue would noticeably mess up the timing of the animation.)

NSSound is not the appropriate API for this. It makes no guarantees about its responsiveness. Look into AVFoundation.

--Kyle Sluder
_______________________________________________

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: Design issue related to my problem with NSSound -isPlaying
      • From: Jens Alfke <email@hidden>
References: 
 >Design issue related to my problem with NSSound -isPlaying (From: Jay Reynolds Freeman <email@hidden>)

  • Prev by Date: Re: ARC Extending Lifetime of Objects
  • Next by Date: NSDocument -canCloseDocumentWithDelegate::: not called when terminating
  • Previous by thread: Re: Design issue related to my problem with NSSound -isPlaying
  • Next by thread: Re: Design issue related to my problem with NSSound -isPlaying
  • Index(es):
    • Date
    • Thread