Wake display with a sound, any sound.

Got a spare iMac G4 and Iwould like to use it as a Digital Photo Frame (not only but that would be the most evident function).
Savescreen is already OK for the photo Display but…it seem not too smart leave the screen running 7/24 so… how can I use the integrated microphone for to wake the screen any time a nois is detected and keep it on until a no noise is detected for a certain amount od time?

Nota Bene: the mac by itself it is up 7/24 I just feel more correct to have the screen go sleeping if nobody is there.

What can I do?

Thanks in advance,

Paolo

Model: iMac G4
Browser: Firefox 1.0.6
Operating System: Mac OS X (10.4)

There may be a better way to do this, but the first thing that came to my mind was VOX voice-activated recording apps. The one I test here is the shareware Audiocorder 4.5 [USD$20] you can download a demo here:
http://www.versiontracker.com/dyn/moreinfo/macosx/10417

All I did was save the following code as a ‘stay-open application’ with Script Editor, and then left it running while Audiocorder was set to ‘VOX’ mode. The moment the VOX audio threshold was exceeded it created a new audio file, which the script detected immediately and woke the display.

Please note that this script assumes that you’ve enabled access for assistive devices on the universal access pane of system preferences, and that you’ve selected require password to wake this computer from sleep or screen saver on the security pane of system preferences.

property old_count : integer
set the old_count to the new_count()

on idle
	if the new_count() is greater than the old_count then
		set the old_count to the new_count()
		tell application "System Events"
			key code 53
			delay 3
			key code 53
		end tell
	end if
	return 0.5
end idle

on new_count()
	tell application "Finder" to count (path to application "Audiocorder OSX")'s container's items
end new_count

Thanks, but it seem a little convoluted for something that should run 7/24.

There’s no way to trap the interrupt made by a sound in the microphone and use that to launch a script?

In short, no. Not in plain AppleScript. AppleScript is, after all, a scripting language, so one shouldn’t expect to find too many fancy features built into the language itself. Instead we must look to scriptable applications to provide the functionality we desire.

When I wrote that script I was originally querying the state of the Audicorder’s UI. What I discovered, however, is that the UI isn’t available and/or accurate when the display is asleep. Looking at the finished script now, it occurs to me that it would be much simpler to write the script as a folder action. This way the script will only run when needed:

on adding folder items to this_folder after receiving these_items
	tell application "System Events"
		key code 53
		delay 3
		key code 53
	end tell
end adding folder items to

As for other approaches to the problem, you’re going to have to look elsewhere for other scriptable applications, or perhaps a command line utility. If you know your way around software development you might try your hand at writing a custom scripting addition or scriptable faceless background application.

Unfortunately, it is years now that the only langage for which I develop is SQL.

On the other side I like the folder action idea; I will try it and I’ll tell you how it went.

:slight_smile: audicoder ask money if you want to get rid of a massage in front of your registration. Not that I care…
The folder action works well!

Now I need to costumize the script for

  1. delete the iff files.
  2. check if the screen is asleep
  3. wake it up
  4. activate the save screen

I don’t know if I have to keep the audicoder running or if I can stop it and link an action to the screen halting for reactivate it.

All in all it seem to be the right path!

Thanks!

Paolo

This is where I am at the moment, but it is not yet working, expecially when the screen is sleeping.

I need to add pauses somewhere? Did keystroke (ASCII character 32) stop the screen saver?

on adding folder items to this_folder after receiving these_items
tell application “Finder”
delete (every file whose name contains “Recording”) of folder “Audiocorder OSX Æ’” of startup disk
end tell
tell application “System Events”
if exists process “ScreenSaverEngine” then keystroke (ASCII character 32)
if not (exists process “ScreenSaverEngine”) then tell application “ScreenSaverEngine” to activate
end tell
end adding folder items to

Thanks!

P.S. as the system will work a lot I was thinking about to use a Ram Disk (and put also the HD to sleep), that is simple for Audiocoder but it becomes a little more difficoult for the screen saver!