Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

wisecracker

macrumors newbie
Original poster
Sep 24, 2012
18
0
In front of my computer.
Hi all...

I am trying to create a shell project for this Macbook Pro.
I do NOT want to use SOX as the sampling _source_ but Quicktime
instead, the idea being that NO third party installs will be needed.

The code below works fine except the commented out Applescript line
does not do what it says on the tin...

I want to sample 1 second snatches of a signal without the small audio
recording image appearing on screen. In other words a pseudo-embedded
mode...

Does anyone know how this can be done?
If not then I can live with it during each snatch...

Ignore the lines below the asterisks they are for my test purposes only
and be aware of wordwrapping...

Any help would be greatly appreciated...

TIA.

Code:
#!/bin/bash
# qt.sh
cd /Users/barrywalker/Desktop/Audio
rm *.aifc >/dev/null 2>&1
sample()
{
osascript << APPLESCRIPT
	tell application "QuickTime Player"
		# set visible of process "QuickTime Player" to false
		set sample to (new audio recording)
		tell sample
			delay 1.5
			start
			delay 1.5
			stop
		end tell
		quit
	end tell
APPLESCRIPT
wait
}
sample
# *********************************************************
afconvert -f 'WAVE' -c 1 -d UI8@8000 "/Users/barrywalker/Desktop/Audio/Audio Recording.aifc" waveform.wav
ls -l waveform.wav
afplay -d waveform.wav
dd if=waveform.wav of=waveform.raw skip=4096 bs=1 count=8000
/Users/barrywalker/Downloads/sox-14.4.0/play -v 0.5 -r 8000 -b 8 -c 1 -e unsigned-integer /Users/barrywalker/Desktop/Audio/waveform.raw
 
I want to sample 1 second snatches of a signal without the small audio
recording image appearing on screen. In other words a pseudo-embedded
mode...

Does anyone know how this can be done?
If not then I can live with it during each snatch...

You need System Events for that but it doesn't work e.g.

Code:
tell application "System Events" to tell process "QuickTime Player" to set visible to false

However this seems to work :

Code:
tell application "QuickTime Player"
	activate
	set sample to (new audio recording)
	set visible of front window to false
	tell sample
		delay 1.5
		start
		delay 1.5
		stop
	end tell
	quit
end tell

Obviously the small audio recording image appears back on screen when you reach the quit statement asking you if you want to save the changes made to the document Untitled.

Note : Tested briefly on Mavericks 10.9.4 from AppleScript Editor. Scripting QuickTime Player is buggy. YMMV
 
Hi kryten2...

Thanks for the quick reply...
I forgot to mention OSX 10.7.5, default bash terminal...

You are a star.

Apart from the autosave anim this works wonders...
I can handle the anim...

Thanks a lot...

You will be mentioned as a thank you in the project when it proceeds.

Consider this thread solved...

Again thanks...

Bazza...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.