Re: Playing Music in Objective C
Re: Playing Music in Objective C
- Subject: Re: Playing Music in Objective C
- From: John Pannell <email@hidden>
- Date: Mon, 13 Feb 2012 09:28:16 -0700
Hi all-
Another tidbit on NSSound (or perhaps sound in general)… laptops will sleep the sound hardware when possible, and there is a brief delay when waking things back up. I have found that the playing of a silent sound at the launch of my app is helpful to wake things up and avoid the delay (sound delay, no app freeze or the like) associated with the wake up caused by your first app-related sound.
Just FYI!
John
John Pannell
http://www.positivespinmedia.com
On Feb 13, 2012, at 8:30 AM, Jim McGowan wrote:
>
> On 13 February, 2012 4:38, Jens Alfke <email@hidden> wrote:
>>
>> On Feb 12, 2012, at 10:35 AM, Conrad Shultz wrote:
>>
>>> The simplest (and therefore least customizable) approach would be to use NSSound. But I think it will do everything you stipulate.
>>
>> A minor issue with NSSound in games is that, the first time you play a particular sound, it’ll first hang for a fraction of a second while it loads the file. I’ve found this to be annoyingly distracting since it also freezes animations. To work around this, at startup create the NSSound object, set its volume to 0 and play it once. That will pre-load the samples into memory.
>
> Actually I found that there is no need to play the NSSound at 0 volume to load the data into RAM, simply instantiating the NSSound ahead of time (with +soundNamed:) is enough. I looked into using NSSound for simple game sounds in a blog post a while back: http://bleepsandpops.com/post/1431403685/using-nssound-for-simple-game-sounds-in-cocoa
>
> As the OP was creating a simple puzzle game I think NSSound is a reasonable way to go for the sound effects. Might even be reasonable for the music too, if it is just a looping MP3.
>
> Jim
_______________________________________________
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