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

Re: stopping sound


  • Subject: Re: stopping sound
  • From: Roland Silver <email@hidden>
  • Date: Fri, 4 Apr 2008 19:30:56 -0600

William,
I want the sound to stop when I press the "Stop Sound" button in the window.
I followed (what I think was) your suggestion, moving the function containing the pieceDone function to the main thread, but that doesn't solve my problem.

When I press the "Stop" button, my calls to NSLog tell me:
2008-04-04 19:20:05.890 AttonalComposer[1178:10b] stopButtonAction invoked
2008-04-04 19:20:05.892 AttonalComposer[1178:10b] pieceDone invoked

When I press the "Play Sine" button, my calls to NSLog tell me:
2008-04-04 19:16:42.838 AttonalComposer[1173:10b] playSineButtonAction invoked
2008-04-04 19:16:42.840 AttonalComposer[1173:10b] playSine called
2008-04-04 19:16:43.006 AttonalComposer[1173:b903] playSineLoop. start

and the 440 "A" begins to sound. But if I THEN press the "Stop" button, my calls to NSLog tell me (by omission) that neither stopButtonAction nor pieceDone is invoked.

Question: Why does pressing "Stop" invoke the functions before I do anything else, but when the second thread is running, pressing "Stop" doesn't do anything?

This Sine business is just a test. When my program is doing its real stuff, playing a piece of music, I want to be able to stop it manually rather than having it time out.
Roland Silver
email@hidden
------------------------------------------------------
William, you said:

That CFRun loop call is pretty unusual and mainly an artifact of the  
demo program being a single, interface-less command-line main. Without  
the delay, the sound would cut off when the main exited.
Usually you run start and stop a sound from your main program loop,  
which has a window with buttons, etc.
To run a sound 2 seconds, a simple way is to: create a structure (call  
the pointer to it _p_) that holds the necessary audio variables; start  
the sound; and then set an EventTimerLoop to fire in two seconds and  
pass p as the userData paramenter to the event fire proc, when can  
then turn off the sound using the p->whatever paremeters. There are  
other ways but that's simplest, I think.



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Meta Parameters
  • Next by Date: Re: stopping sound
  • Previous by thread: Re: stopping sound
  • Next by thread: Re: stopping sound
  • Index(es):
    • Date
    • Thread