I don't use the Apple Music service and have no connection to this app but just came across it and I figured it might be useful to some folks here...
github.com
GitHub - vincentneo/LosslessSwitcher: Automated Apple Music Lossless Sample Rate Switching for Audio Devices on Macs.
Automated Apple Music Lossless Sample Rate Switching for Audio Devices on Macs. - GitHub - vincentneo/LosslessSwitcher: Automated Apple Music Lossless Sample Rate Switching for Audio Devices on Macs.
andLosslessSwitcher for Apple Music on Mac
LosslessSwitcher switches your current audio device's sample rate to match the currently playing lossless song on your Apple Music app, automatically.
Let's say if the next song that you are playing, is a Hi-Res Lossless track with a sample rate of 192kHz, LosslessSwitcher will switch your device to that sample rate as soon as possible.
The opposite happens, when the next track happens to have a lower sample rate.
Why make this?
Ever since Apple Music Lossless launched along with macOS 11.4, the app would never switch the sample rates according to the song that was playing. A trip down to the Audio MIDI Setup app was required. This still happens today, with macOS 12.3.1, despite iOS's Music app having such an ability.