猫のお留守番ではタイマー録音開始前と終了後にAppleScriptを実行する機能があ ります。paramにはタイマー予約で設定された文字列が引き渡されます。
on pre_recoding(param) -- 録音開始前の処理 end pre_recoding on post_recoding(param) -- 録音終了後の処理 end post_recoding
以下のスクリプトを別ファイルで作り実際のファイルを読み込んでテストする事が 出来ます。
set scriptObj to load script file "HD:Users:hiroki:Documents:sample.scpt" tell scriptObj to pre_recoding("param")
録音ファイルの保存先のフォルダーで一番新しいファイルをiTunesに登録しています。
on pre_recoding(param) end pre_recoding on post_recoding(param) set aFol to "SSD2:AirCheck" -- 録音ファイル保存フォルダ set miniDiff to 0 -- 録音ファイル保存フォルダで一番新しいファイルを捜す tell application "Finder" tell folder aFol set indList to a reference to (every file whose kind is "MPEG-4 オーディオ") end tell set nameList to name of indList repeat with theItem in nameList set aFile to aFol & ":" & theItem as alias set modTIme to modification date of aFile set timeDiff to (current date) - modTIme if miniDiff = 0 then set miniDiff to timeDiff set miniNmae to theItem else if miniDiff > timeDiff then set miniDiff to timeDiff set miniNmae to theItem end if end repeat end tell -- 見つかったファイルをiTunesに登録 tell application "iTunes" set aFile to aFol & ":" & miniNmae as alias set added_track to add aFile end tell end post_recoding
追加時に独自のプレーリストに追加しようとしたのですが、iTunesの設定で 「ライブラリの追加時にファイルを"iTunes Media"フォルダにコピーする」の 設定により挙動が変わってしまいあきらめました。 プレーリストの「最近追加した項目」には追加されていて、このプレーリストを iPhoneの同期対象にしておくと最近エアーチェックしたものが自動的にコピーされて 大変便利です。
アルマジロのお使いで、 赤外線リモコンで録音前にPT-D4Wの接続されたチューナの電源を入れて、録音後に 電源を切るスクリプト。
on pre_recoding(param) tell application "Armadillo" --usedevice "Crossam2" usedevice "PC-OP-RS1" -- not define ftdi device name on apprication program --usedevice "FTDI" commandsend "A ON" end tell end pre_recoding on post_recoding(param) tell application "Armadillo" --usedevice "Crossam2" usedevice "PC-OP-RS1" -- not define ftdi device name on apprication program --usedevice "FTDI" commandsend "A OFF" end tell end post_recoding
ノイズの削減に効果があるかはわからないが、録音開始時にWIFIをオフにして 録音終了後にオンにするスクリプト。インターフェース(en1)は自分の環境に 合わせてください。
on pre_recoding(param) do shell script "networksetup -setairportpower en1 off" end pre_recoding on post_recoding(param) do shell script "networksetup -setairportpower en1 on" end post_recoding
録音終了後にiTunesの同期など60秒以上かかる処理があり、アプリケーションの スリープではなく、スクリプトでスリープする方法。
on pre_recoding(param) end pre_recoding on post_recoding(param) -- do something tell application "System Events" to sleep end post_recoding
録音開始前にntpで時間を設定する。事前に「日付と時間」のパネルを開いて おく必要があります。
on pre_recoding(param) tell application "System Preferences" activate set current pane to pane "com.apple.preference.datetime" end tell quit application "System Preferences" end pre_recoding