That makes sense, because NSSound has to go find the resource named "mySound.m4a", load it into memory, and then play it.

Have you tried preloading the sound, so that by the time you want to play it, it's already in memory?

Dave

On Nov 9, 2009, at 11:37 AM, Chunk 1978 wrote:

i'm using Cocoa's NSSound.  here's is how i play sounds:

-=-=-=-=-

if ([[soundRadioGroup cellWithTag:1] state] == NSOnState)

{

NSSound *theSound = [NSSound soundNamed:@"mySound.m4a"];

if ([theSound isPlaying])

[theSound stop];


[theSound play];

}

-=-=-=-=-


the first sound is always lagged. for example, if i press a button to play a sound, the button's pressed state will remain until the sound is loaded and played. after the first sound plays, all other sounds will play without
lag.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to