How to play system sounds, like notification pings?

Does JUCE have a way to play system sounds like notification pings, failure tones, etc.

We’d like to play these tones in our app to aid with accessibility but it’s not something I’ve ever looked at before.

To answer my own question, my colleague pointed me to juce::LookAndFeel::playAlertSound().

https://docs.juce.com/master/classLookAndFeel.html#ac8619d01580cde12075b229490ab2f97

Doesn’t look like I can customise exactly which tone though, which would be nice. Looks like the native APIs do have a few different ones to select from, but maybe there’s not enough overlap to be able to do it in a cross-platform way from JUCE’s side.

on windows these sounds are all stored in some specific media folder. you could just look it up and access these wav files with the typical juce methods for doing so

I think we’d want to do it cross-platform or not at all - maybe mac has an equivalent somewhere so we could roll our own implementation, but that’d be very much a last resort solution!

I think Juce has classes for creating actual push notifications… I’m not too familiar with them, but I seem to recall “alert sound” being an option…

You’re right, there’s this: JUCE: PushNotifications::Notification Struct Reference

Not sure how well supported it is on Windows however - the docs seem to only mention OSX, iOS, and android!

Just making notes for prosperity…

On windows there’s the PlaySound function that you can either pass something like SND_ALIAS_SYSTEMEXCLAMATION, or simply the name of one of the audio files from C:\Windows\Media.

PlaySound (TEXT("tada.wav"), NULL, SND_FILENAME);

https://docs.microsoft.com/en-us/previous-versions/dd743680(v=vs.85)


On mac there’s AudioServicesPlayAlertSound which takes an ID for the sound to play, seems like there’s very few built-in sounds available though (searching at the k_SystemSoundID_ in AudioToolbox/AudioServices.h shows only a few choices).