Unix/Linux Go Back    

OSX Sierra transparent shell audio sampler.

OS X (Apple)

Kindly Note - This is a Single User Post by Forum Member wisecracker Regarding:
OSX Sierra transparent shell audio sampler..
Please Follow The Primary Link Above to View the Full Discussion.

Old Unix and Linux 11-13-2016   -   Original Discussion by wisecracker
wisecracker's Unix or Linux Image
wisecracker wisecracker is offline
Registered User
Join Date: Jan 2013
Last Activity: 13 November 2017, 2:52 PM EST
Location: Loughborough
Posts: 1,224
Thanks: 367
Thanked 323 Times in 253 Posts
OSX Sierra transparent shell audio sampler.

Well after the transparent QuickTime Player means of capture for OSX 10.7.x became broken in at least Yosemite I decided to persevere with a version of command line capture for OSX 10.12.x.

A derivative of this DEMO is now inside AudioScope.sh to give my MBP and iMac a means of capturing an audio signal using a virgin Sierra install.

As I run my machines as a standard non-admin user then the following occurs...
On the very first run only you will get Untitled1.jpg followed by an admin and admin password window finally followed Untitled2.jpg.

It is obvious what you need to do but you will not need it again once set.

The DEMO code has NO error correction so beware. If you want to test it then use the internal mic as the source. Make sure you set up the mic levels to suit your needs.

# ./sample.sh <number_of_seconds>
# This DEMO shell script uses a virgin OSX Sierra install only, nothing else is required.
# The conversion for this DEMO is mono, 8 bit, unsigned integer at 48000 sps but it is
# easy to convert to just about anything, 'man afconvert'...
# This saves a sample '/tmp/Untitled.m4a' and is converted to '/tmp/Untitled.wav' file.
# './sample.sh 6' allows for 1 second startup and 5 seconds of recording.
# Use the internal microphone as a test.
osascript << AppleSampler
tell application "QuickTime Player"
	close (every document whose name contains "Untitled") saving no
	set savePath to "Macintosh HD:tmp:" & "Untitled.m4a"
	set recording to new audio recording
	set visible of front window to false
	start recording
	delay "$seconds"
	stop recording
	export document "Untitled" in file savePath using settings preset "Audio Only"
	close (every document whose name contains "Untitled") saving no
	tell application "System Events" to click menu item "Hide Export Progress" of menu "Window" of menu bar 1 of process "QuickTime Player"
end tell
# Example of conversion to WAVE file.
afconvert -f 'WAVE' -c 1 -d UI8@48000 /tmp/Untitled.m4a /tmp/Untitled.wav
ls -l /tmp/Untitled.*
# Playback both files.
afplay /tmp/Untitled.m4a
sleep 1
afplay /tmp/Untitled.wav
exit 0

Attached Thumbnails
OSX Sierra transparent shell audio sampler.-untitled1-jpg   OSX Sierra transparent shell audio sampler.-untitled2-jpg  
The Following User Says Thank You to wisecracker For This Useful Post:
Neo (01-01-2017)