Sponsored Content
Operating Systems OS X (Apple) OSX Sierra transparent shell audio sampler. Post 302985644 by wisecracker on Sunday 13th of November 2016 04:28:36 PM
Old 11-13-2016
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.
Code:
#!/bin/sh
# ./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.
seconds="$1"
osascript << AppleSampler
tell application "QuickTime Player"
	activate
	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"
	quit
end tell
AppleSampler
# 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

OSX Sierra transparent shell audio sampler.-untitled1jpg
OSX Sierra transparent shell audio sampler.-untitled2jpg
This User Gave Thanks to wisecracker For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

#!/bin/bash and #1bin/sh command not found error on mac osx terminal/shell script

i am having a weird error on mac os x running some shell scripts. i am a complete newbie at this and this question concerns 2 scripts. one of which a friend of mine wrote (videochecker.sh) a couple weeks ago and it's been running fine on another machine. then last week i wrote capture.sh and it... (2 Replies)
Discussion started by: danpaluska
2 Replies

2. Shell Programming and Scripting

Need help with a shell script:Config Transparent Proxy using Shell

I want to config Transparent Proxy using Shell Script. I have more questions<exercise of me :D>: + Check that the squid is installed or not install and version is installed +Allows users to choose to run a transparent proxy or not +Perform configuration and turn on service in accordance... (0 Replies)
Discussion started by: kaka287
0 Replies

3. OS X (Apple)

Creating Shell Script for STIG Checklist MAC OSX 10.6

Hello, I am new to Mac OSX and shell scripting all together. I was wondering if anyone could help get me started in a few scenarios so that I would be able to automate checking a system against a STIG checklist. A STIG Checklist is a DoD Guideline for securing systems. Here is the first... (3 Replies)
Discussion started by: john3j04
3 Replies

4. Slackware

Problems with audio recording in Audacity 2.0.5. Slackware64 14.1; Intel HD Audio.

I'm trying to record audio using Audacity 2.0.5 installed from SlackBuilds. My system is 64-bit Slackware 14.1 and a sound card is Intel HD Audio. I didn't change my sound system to OSS. (Default sound system in Slackware 14.1 is ALSA, isn't it?) First, I set Internal Microphone slider in KMix... (2 Replies)
Discussion started by: qzxcvbnm
2 Replies

5. Shell Programming and Scripting

Generate 10000 unique audio file of 2MB each using shell script.

Hi, I want 10000+ unique Audio file of approx 2MB each. How can i generate numerous audio files using shell script. Any tool, command or suggestions are welcome. If i give one audio seed file then can we create numerous unique files with same seed file? Any help is highly appreciable.... (11 Replies)
Discussion started by: sushil.kumar
11 Replies

6. OS X (Apple)

OSX afplay command line audio player _manual_.

Hi everyone... I don't know if this is the correct forum but it is Apple OSX specific. It is a proper pseudo-man page for the sparse official one... This is as thorough as experimentation can get... Command line afplay, August 2016. --------------------------------- afplay -h ... (0 Replies)
Discussion started by: wisecracker
0 Replies

7. Shell Programming and Scripting

The Start Of A Simple Audio Scope Shell Script...

This is a DEMO shell script to generate a simple graticule and plot inside it... Apologies for any typos... it is another building block along with my other two shell uploads recently to start a semi_serious project of an Terminal_AudioScope... The fist upload I posted recently was to show... (83 Replies)
Discussion started by: wisecracker
83 Replies

8. UNIX for Beginners Questions & Answers

Capture power button press on MacOs High Sierra?

Hello everyone! I'm developing a MacOs Application in python and I'm having some issues trying to find information related to the power button pressed event. I know that in Ubuntu 14.04 you can find information about it on the acpi folders, but I realized that here in Mac that process is... (0 Replies)
Discussion started by: xedge
0 Replies

9. Shell Programming and Scripting

Issue with shutdown command in script (MacOS High Sierra)

Hello, I have a backup script that runs an rsync backup to an external drive. I use the script frequently on Windows and Linux and have installed it on a Mac. The script has an option to run shutdown after the backup has completed. Since backup can take hours to run, this is an option that is... (10 Replies)
Discussion started by: LMHmedchem
10 Replies
All times are GMT -4. The time now is 09:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy