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

Re: NSSound truncates the beginnings of sounds


  • Subject: Re: NSSound truncates the beginnings of sounds
  • From: John Stiles <email@hidden>
  • Date: Thu, 18 Sep 2003 10:16:10 -0700

On Thursday, September 18, 2003, at 01:11 AM, Alastair J.Houghton wrote:

On Thursday, September 18, 2003, at 01:06 am, John Stiles wrote:

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.

Are you using a PowerBook, by any chance? Apple turn-off the sound hardware after a certain amount of time, and it doesn't come back to life immediately. You can tell if this is the problem, because the sound hardware only gets switched-off after a period of inactivity, so if this is what's giving you grief, you should find that if you play two sounds in succession, only the first one gets clipped. If this does turn out to be the problem, I imagine it's possible to make the sound hardware stay active somehow, although you'll have to search the docs.

Failing that, you could try using Core Audio instead, although that looks a bit more complicated.

Kind regards,

Alastair.

Nope, this is on a dual-G4 tower.

CoreAudio is a damn sight more complicated (trust me, I've been down that road) and I was really hoping to avoid it if at all possible :) But if NSSound is going to be a no-go then maybe I should investigate going back to the good ol' Sound Manager for this. Icky, but I know it will work.
_______________________________________________
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.
References: 
 >Re: NSSound truncates the beginnings of sounds (From: "Alastair J.Houghton" <email@hidden>)

  • Prev by Date: Sample code to rotate an NSImage
  • Next by Date: Re: where's xcode?
  • Previous by thread: Re: NSSound truncates the beginnings of sounds
  • Next by thread: Re: Newbie - Setting a window to a title other then document file name
  • Index(es):
    • Date
    • Thread