Welcome, Guest. Please login or register.

Login with username, password and session length
 

News:



Author Topic: Starting a tool with Applescript  (Read 5480 times)

0 Members and 1 Guest are viewing this topic.

pjotr

  • Newbie
  • *
  • Posts: 1
    • View Profile
Starting a tool with Applescript
« on: July 26, 2009, 09:21:21 PM »
Cheers,

I am trying to automate a few measurements, for now specifically i want to plot THD+N and THD vs. frequency.

I can create a signal generator tool with

Code: [Select]
set siggen to make new signal generator tool with properties {id:"siggen"}
and then set the properties I need and enable the signal I need, but when i try to start the tool with

Code: [Select]
tell siggen to start
it appears started, but does not output a signal.

If I manually stop and start it on the generator window, then it begins to output my signal.  The documentation in applescript specifically states:

Quote
running (boolean) : Specifies whether the tool is currently running (sending or receiving data). Setting this value to 'true' (or using the start command on this object) does not start the selected device.

but I cannot see how I could actually start the output.  I have the same issue trying to start the FFT analyzer.

any ideas?
-pjotr


FaberAST

  • Administrator
  • Sr. Member
  • *****
  • Posts: 319
    • View Profile
    • www.FaberAcoustical.com
Re: Starting a tool with Applescript
« Reply #1 on: July 27, 2009, 09:44:43 AM »
Just as you quoted from the documentation, starting a tool does not start the selected output device, so you need to tell the appropriate device to start.

Here's a sample script that picks the first available output device on the system, and outputs a 1 kHz tone on that device:

Code: [Select]
tell application "Electroacoustics Toolbox"
activate
create new project
set devList to name of devices

-- make sure there is at least one device connected to the system
if (count of devList) is greater than 1 then
-- make sure there is at least one device with output channels connected to the system
-- pick the first output device found
set foundOutputDevice to false
repeat with i from 1 to count of devList
set dev to device (item i of devList)
if (count of output channels of dev) is greater than 0 then
set foundOutputDevice to true
exit repeat
end if
end repeat

if foundOutputDevice then
set sigGen to make new signal generator tool with properties {id:"siggen"}
tell sigGen
set selected device to dev
set periodic signal A enabled to true
end tell
tell dev to start
tell sigGen to start
else
display dialog "There are no devices with output channels available on your system. Please connect an audio output device and try again."
end if
else
display dialog "There are no devices available on your system. Please connect an audio device and try again."
end if
end tell