Scripting Apple Music on macOS for chorus repetition practice

This is an update to my previous post on automating iTunes on macOS to support chorus repetition practice. You can read the original post for the theory behind the idea; but in short, one way of developing prosody and quality pronunciation in a foreign language is to do mass repetitions in chorus with a recording of a native speaker.

Because in macOS 10.15, iTunes is no more, I’ve updated the script to work with the new Music app. It turns out that it’s a lot simpler. No need to dive into the application classes.

--
--	Created by: Alan Duncan
--	Created on: 2020-07-04
--
--	Copyright (c) 2020 OjisanSeiuchu
--	All Rights Reserved
--

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

property trackDuration : 1
property minimumVolume : 10

--	initial volume, set by user
global volume0, trackRepeatMode0

on run
	
	tell application "Music"
		-- save original settings
		set trackRepeatMode0 to song repeat
		set song repeat to one
		set volume0 to sound volume
		
		play
		
		--	calculate the delay between fades
		set fadeDelay to (trackDuration * 60) / (volume0 - minimumVolume)
		repeat with i from minimumVolume to volume0
			delay fadeDelay
			set sound volume to sound volume - 1
		end repeat
		
		pause
		-- restore original settings
		set song repeat to trackRepeatMode0
		set sound volume to volume0
	end tell
	
end run

Wednesday, June 24, 2020

  • The EU is planning to exclude Americans from entry into its member countries when its updated guidelines on travel in the coronavirus era are put in place on July 1. “Citing failures,” the title says. How about gross incompetence, American stupidity, and Americans’ preference to live in a world of fantasy? - NYT, Tuesday, June 23, 2020
  • Steve Schmidt, John McCain’s 2008 campaign manager with a brutal commentary on Trump:video or transcript: Political Wire, Tuesday, June 23, 2020.

“When you listen to the President, these are the musings of an imbecile. An idiot. And I don’t use those words to name call. I use them because they are the precise words of the English language to describe his behavior. His comportment. His actions. We’ve never seen a level of incompetence, a level of ineptitude so staggering on a daily basis by anybody in the history of the country whose ever been charged with substantial responsibilities.”_

A meritocracy reading list

Meritocracy has been on everyone’s minds lately, it seems. Reading Daniel Markovits’ “The Meritocracy Trap,” I was fully ready to condemn the concept completely. I may be still; but I need to take a moment to think about it more fully.

Here’s the problem with condemning meritocracy outright: if we look at ability on a case-by-case basis, would you rather a well-trained, accomplished pilot or a mediocre one? Would you rather go to a concert performed by a scratchy third-rate violinist or someone whose pedigree includes Juilliard, Curtis, or the like? Maybe the problem with meritocracy is simply that it doesn’t scale well in capitalist markets. (Don’t hold me to that idea; I’m not quite ready to embrace it fully.) In the process of scaling to the level of a large society, does any inherent rightness of merit confer a right to so distort the economic life of a country that only narrower and narrower slices of it garner larger and larger portions of the economic output?

A folder-based image gallery for Hugo

Hugo is the platform I use to publish this weblog. Occasionally I have the need to include a collection of images in a post. Mostly this comes up on other sites that I publish. Fancybox can do this; but it wasn’t immediately clear how to direct Fancybox to create a gallery of images in a page based on images in a directory. Previously, I’ve solved this in different ways, but I was anxious to find a simple shortcode-based method.

An alternative method for keyboard input switching on macOS

macOS offers a variety of virtual keyboard layouts which are accessible through System Preferences > Keyboard > Input Sources. Because I spend about half of my time writing in Russian and half in English, rapid switching between keyboard layouts is important. Optionally in the Input Sources preference pane, you can choose to use the Caps lock key to toggle between sources. This almost always works well with the exception of Anki. Presumably Anki’s non-standard text management system thwarts the built-in Caps Lock/toggle mechanism for reasons that are not clear to me. Equally unclear is why this worked previously but now does not. I’ve not updated either Anki or the system software. It’s a mystery. Nonetheless, began to search for an alternative method for switching between keyboard layout switching. What I developed relies on several tools: