• 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: At my wits end with NSSound!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: At my wits end with NSSound!


  • Subject: Re: At my wits end with NSSound!
  • From: John Pannell <email@hidden>
  • Date: Tue, 10 Feb 2004 22:01:50 -0700

Hi Mike-

I have also been bothered by the delay; here's what I did to clear it
up:

1. Make a "silent" sound. You can download mine (30K) at:
http://www.positivespinmedia.com/silent.aiff

2. Add it to the "Resources" folder of your project by selecting the
folder in XCode/PB and choosing "Add Files..." from the Project menu.

3. In some early method of your app, add a line to play the silent
sound. I used my controller object, which is a delegate for NSApp, and
added this line to the applicationDidFinishLaunching:
method, which is called when the application did finish launching
(hence the name :-)

// wake up the sound system
[[NSSound soundNamed:@"silent"] play];

Since adding this to the app (about five minutes ago) I have noticed
that the bothersome delay at the beginning of my game (a minesweeper
clone) is now gone. Yay! I'm glad you brought this up... I had seen
complaints at mamasam of this issue and recalled one person suggesting
the playing of a silent sound to "wake up" the sound output and
eliminate the delay. It seems to work.

Hope this helps!

john



On Feb 10, 2004, at 8:54 PM, Mike Brinkman wrote:

> I've tried everything I can think of and I still can't get the first
> sound
> in my program to play without a delay. A search of the mailing list
> archive
> turns up nothing of value.
>
> I've tried:
>
> mySound = [[NSSound soundNamed:@"aSound"] retain];
>
> Then
>
> [mySound play];
>
> I've also tried to create a bundle, and init a sound with a path for a
> resource:
>
> mainBundle = [NSBundle mainBundle];
> NSString *aSound = [mainBundle pathForResource:@"aSound"
> ofType:@"wav"];
> mySound = [[NSSound alloc] initWithContentsOfFile:aSound
> byReference:NO];
>
> Somebody here told me that the problem was that my sound was a .wav
> file, so
> I converted it to .aiff using Quicktime, still to no avail.
>
> I tried loading the sounds into an NSDictionary and then playing them
> as
> such because somebody else here told me this would force them to be
> loaded:
>
> [[sounds objectForKey:@"mySound"] play];
>
> I'm using 10.2.8 & Project Builder v. 2.0.1 w/the August 2003 &
> October 2003
> patches.
>
> Sorry for the rant, but I've been trying to figure this out off and on
> for a
> few weeks now, and it is extremely frustrating. Is there something I'm
> doing
> wrong, or is there some sort of glitch with NSSound.
>
> I was planning on doing a write-up for iDevGames about my experience
> developing my first Cocoa game program, is there at least some
> explanation
> for why there is a delay for the first time sounds are played?
> _______________________________________________
> 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.
_______________________________________________
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: 
 >At my wits end with NSSound! (From: Mike Brinkman <email@hidden>)

  • Prev by Date: Re: Making the correct button the default button?
  • Next by Date: Re: Getting an NSString out of an NSTextView;
  • Previous by thread: At my wits end with NSSound!
  • Next by thread: Re: At my wits end with NSSound!
  • Index(es):
    • Date
    • Thread