Topic: macOS "Wake on MIDI" for appliance-style/headless use?

I'm using Pianoteq on a MacBook Air. I can sleep/wake the Mac and power on/off the MIDI device and everything works fine. However, I need to manually wake up the Mac by pressing a key on the Mac keyboard.

I'd like to be able to sit down, power on the MIDI keyboard, and play - without touching the computer. In a sense, I'd like the Mac to function like an appliance. Pianoteq is always running, but something needs to wake the machine up (like whenever a MIDI device is connected or a MIDI message arrives). If this worked, the Mac could even be headless.

Has anyone found a way to accomplish this, like a "Wake on MIDI" utility? Googling for that as a phrase didn't turn up anything. Thanks!

Re: macOS "Wake on MIDI" for appliance-style/headless use?

f6f6 wrote:

I'm using Pianoteq on a MacBook Air. I can sleep/wake the Mac and power on/off the MIDI device and everything works fine. However, I need to manually wake up the Mac by pressing a key on the Mac keyboard.

I'd like to be able to sit down, power on the MIDI keyboard, and play - without touching the computer. In a sense, I'd like the Mac to function like an appliance. Pianoteq is always running, but something needs to wake the machine up (like whenever a MIDI device is connected or a MIDI message arrives). If this worked, the Mac could even be headless.

Has anyone found a way to accomplish this, like a "Wake on MIDI" utility? Googling for that as a phrase didn't turn up anything. Thanks!

Uhm, are you aware you can't sleep when PianoTeq is running? All it does is to sleep the displays.
Cause PianoTeq is preventing sleep.
Run "pmset -g" to look it up.

To make things more complicated, you need to kill several services to truly sleep. Doublecheck with a Kill-A-Watt.
It's like 50 watt sleep vs 9 Watt after the command.

You may have to enter sleep manually. I did it like this.

killall "Amphetamine";killall "Audio Hijack"; killall "Calendar"; killall "Electron"; killall "Finder";killall "KeePassXC";killall "Mumble"; killall "Pianoteq 7";killall "Preview";killall "QuickTime Player";killall "Typora"; killall "Vivaldi";killall "java"; killall "prl_client_app";killall "thunderbird";pmset sleepnow

Other than that, you would have to map one of your MIDI piano keys as keyboard command with a third party tool.
But it may be possible that this very tool also PREVENTS the sleep, double check with "pmset -g"

Now that you know all of that, you may wonder if you can STOP PianoTeq when your Piano is not in use and START PianoTeq when your Piano has been activated.

You can do like this:

#!/bin/sh
if system_profiler SPUSBDataType | grep -c -i "Roland Digital Piano" | grep -q "1"; then
    if ps aux | grep -v grep | grep -c -i Pianoteq | grep -q "0"; then
        open "/Applications/Pianoteq 7/Pianoteq 7.app";
    fi
else
    if ps aux | grep -v grep | grep -c -i Pianoteq | grep -q "1"; then
        killall "Pianoteq 7" &>/dev/null;
    fi
fi

For translating midi keys to keys, you can use https://www.pgmusic.com/forums/ubbthrea...ber=430438 but ONLY if you are not using an M1 chip.

Re: macOS "Wake on MIDI" for appliance-style/headless use?

Defenz0r wrote:

Uhm, are you aware you can't sleep when PianoTeq is running? All it does is to sleep the displays.

Thanks for thinking about this. I don't know how "Asleep" it's becoming, but after a sleep-ish idle time, PianoTeq stops generating audio from MIDI events. That seems inconsistent with just sleeping the display. That is, my experience doesn't match your assertion.

And as soon as I press a key and wake it up, the existing PianoTeq instance resumes responding to MIDI events.

I don't know whether it's a "Power nap," sleep, or something else, though that seems a bit academic right now since there's no way to wake-on-MIDI from any of those states. The idea of mapping a piano key to a keyboard key is a good one; I'll check that out. Thanks!

Last edited by f6f6 (12-09-2021 11:44)

Re: macOS "Wake on MIDI" for appliance-style/headless use?

f6f6 wrote:
Defenz0r wrote:

Uhm, are you aware you can't sleep when PianoTeq is running? All it does is to sleep the displays.

Thanks for thinking about this. I don't know how "Asleep" it's becoming, but after a sleep-ish idle time, PianoTeq stops generating audio from MIDI events. That seems inconsistent with just sleeping the display. That is, my experience doesn't match your assertion.

And as soon as I press a key and wake it up, the existing PianoTeq instance resumes responding to MIDI events.

I don't know whether it's a "Power nap," sleep, or something else, though that seems a bit academic right now since there's no way to wake-on-MIDI from any of those states. The idea of mapping a piano key to a keyboard key is a good one; I'll check that out. Thanks!

I kinda don't understand your intention. On a "normal" computer, you would just take one of those external power buttons to resume from sleep.
But on a mac, it might be different.

You could grab something like this https://techkeys.us/products/onekeyboard
Get a long cable and put it somewhere on your instrument.