logo

Example Scripts

Here we provide a number of example scripts that will help you get started with scripting FuzzMeasure.

To run the below scripts, copy the below text into Script Editor or a text file with the .applescript file extension.

Importing Impulse Responses

The below script will prompt the user to import one or more impulse response files, and adds a 1/12th octave smoothed frequency response graph to the document.

set theSelection to ¬
	choose file with prompt ¬
		"Choose your impulse responses:" with multiple selections allowed

tell application "FuzzMeasure"
	make new document
	tell first document
		repeat with theResult in theSelection
			set newIR to import impulse response named theResult
		end repeat

		set frGraph to make new frequency response graph
		tell frGraph
			set smoothing fraction to one_12th
		end tell
	end tell
end tell

Exporting Graph Data

This script prompts the user for an output folder, and then exports 1/6th octave smoothed frequency response data for the selected measurements.

-- Select the destination folder in which to store the graph data
set selectedFolder to ¬
	choose folder with prompt "Choose folder to store graph data"

tell application "FuzzMeasure"
	-- In the frontmost document
	tell document 1
		-- Create a frequency response graph if one does not already exist
		set frCount to count of frequency response graphs
		if frCount is 0 then
			set newGraph to make new frequency response graph
		else
			set newGraph to first frequency response graph
		end if

		-- Set the desired smoothing amount on the data
		tell newGraph to set smoothing fraction to one_6th

		-- Filter and set the document selection to only the measurement
		-- records that we wish to export
		set measurementList to measurements whose title contains "Mic"
		set selected measurements to measurementList

		-- Grab the title of the graph to help setting the output filename
		set measurementTitle to title of newGraph

		-- Note that a POSIX file type must be passed in to the export function,
		-- or else you will encounter sandboxing issues with the export.
		tell newGraph to export graph data to POSIX file ¬
			((POSIX path of selectedFolder) & measurementTitle & ".csv")
	end tell
end tell