• 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
NSSound truncates the beginnings of sounds
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSSound truncates the beginnings of sounds


  • Subject: NSSound truncates the beginnings of sounds
  • From: John Stiles <email@hidden>
  • Date: Wed, 17 Sep 2003 17:06:45 -0700

I've begun to notice that NSSound will often drop the beginning of a sound effect.
Imagine a user in my app clicks a button which is supposed to play a noise and simultaneously make a sheet drop down. Here's an example of what I'm trying to do with NSSound:

static NSSound *mySoundEffect = [[NSSound alloc] initWithContentsOfFile:@"sound.wav" byReference:NO];
[mySoundEffect play];
[NSApp beginSheet:_mySheet modalForWindow:_myWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:NULL];
Imagine the sheet-dropping takes 3/4s of a second; in that case, the first 3/4ths of a second worth of sound will not be played.

And it's not just sheets; it's anything that takes CPU. When I do simple things like:

[myView drawNewImage:myImage]; // this is my custom view object that will have work to do when Cocoa asks it to redraw, next time through the event loop
[mySoundEffect play];

If the drawRect method of myView takes a tenth of a second, then I end up losing the first 1/10th of a second of sound.

What should I do about this? I considered doing a performSelectorOnMainThread running under the theory that this will delay the sound playback until after the event loop is running calmly, but that seems like a wrong sort of answer because it has the potential to introduce a noticeable delay, and although it would probably solve the first problem, it might not do anything to the second one.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Re: NSSound truncates the beginnings of sounds
      • From: "Alastair J.Houghton" <email@hidden>
References: 
 >Re: Newbie - Setting a window to a title other then document file name (From: Georg Tuparev <email@hidden>)

  • Prev by Date: Re: NSComboBox - Not Drawing the List
  • Next by Date: Installing Plugins on Build
  • Previous by thread: Re: Newbie - Setting a window to a title other then document file name
  • Next by thread: Re: NSSound truncates the beginnings of sounds
  • Index(es):
    • Date
    • Thread