[futurebasic] Re: [FB] SOUND question

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : August 2012 : Group Archive : Group : All Groups

From: Robert Covington <artlythere@...>
Date: Sat, 4 Aug 2012 12:27:55 -0400
On Aug 4, 2012, at 12:06 PM, Walter Lenk wrote:

>  Robert made a suggestion to periodically make a silent sound to keep the audio awake. A good idea - I had thought of it, but I was loath to implement it in my already fairly complicated application.

I agree it's an icky solution, but until Apple fixes it, if ever...it seems to be a really common complaint, and has affected my own apps. Imagine a MIDI app needing to play a metronome, but the sound is lost first second or so? Won't do.


Silent sound wake-it-up might can be done via the following... 

1) On Timer FB option...(see docs) if not being used already, is the easiest.

on timer(interval) fn userFunction

So:

on timer (3600) Fn SilentSoundPlay

Easy. But you may already have a vector for On Timer...so can....


2) Make your own if you have HandleEvents loop....with 
Poke Long Event -8,2 // 2 ticks , 30 times a second generally...

then could set a global long var, gTimeTicks

// Possible approach

// Possible approach

Begin Globals
dim gTimeTicks as long
End Globals

_TimerIncrement = 120 // two seconds, DEMO only
// 10800 for every 3 minutes for instance, or shorter if needed to prevent delays, longer if works, try 5 minutes

Local Fn SilentSoundPlay
// Play Silent Sound
beep // for demo only
End Fn

Local Fn AudioWake

long if ((Fn TickCount-gTimeTicks) >= _TimerIncrement)
Fn SilentSoundPlay
gTimeTicks = Fn TickCount // reset timer var
end if

End fn

gTimeTicks = Fn Tickcount
Poke Long Event -8,2 // add polling to otherwise quiet run loop

do
HandleEvents
Fn AudioWake
until gFBQuit