• 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: Double Beep
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Double Beep


  • Subject: Re: Double Beep
  • From: Dave <email@hidden>
  • Date: Thu, 14 Aug 2003 21:53:25 -0400

How do I make a double system beep.

Two NSBeep()'s don't work since it only plays one beep.

Thanx.
SD.
_______________________________________________
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.

Hello,

One way to do it would be to use an NSTimer. In this example, beepTimer is an instance variable.

-----

- (void)awakeFromNib
{

beepTimer = [[NSTimer scheduledTimerWithTimeInterval: 0.2 target: self selector: @selector(beepTwice) userInfo: nil repeats: YES] retain];

}

- (void)beepTwice
{

static int numberOfBeeps = 0;

NSBeep();

if (++numberOfBeeps == 2)
{

[beepTimer invalidate];

[beepTimer release];

}

}

-----

Note that this example will work differently with different alert sounds (set in the System Prefs, Sound panel). A safe delay for the NSTimer would be about half a second, but this may sound too long for other alert sounds (such as Funk, whereas half a second is good for Blow). You may just want to settle with 0.3, 0.35, or 0.4.

Dave
_______________________________________________
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: Double Beep
      • From: email@hidden
References: 
 >Double Beep (From: email@hidden)

  • Prev by Date: Re: CFSocketCallBack
  • Next by Date: Misunderstanding re -[NSMatrix selectedCells]??
  • Previous by thread: Double Beep
  • Next by thread: Re: Double Beep
  • Index(es):
    • Date
    • Thread