Preconfigure ambience sound

I am trying to preconfigure tone settings in a personal .ambience file, and want to use some original jolla tones but don’t understand how.
I know I can set personal tones added in a sounds directory, like this…

"ringerToneFile"            : { "file": "eson-ringtone.wav",	    "enabled": 1 },

…but what if I want to set an already installed original jolla tone, e.g jolla-messagetone?

I can find the actual audio files in usr/share/sounds/jolla-ringtones/stereo but they are .ogg.
I also found this index file but don’t understand how to use the info in my .ambience file.
Please help!

stereo.index
"translationCatalog" : "jolla-ringtones",
"files" : [
    {
        "displayName"   : "jolla-ringtones-ringtone",
        "fileName"      : "jolla-ringtone.ogg",
        "category"      : "Ringtone",
        "aliases"       : [ "jolla-ringtone.wav" ]
    }, {
        "displayName"   : "jolla-ringtones-tone-1",
        "fileName"      : "jolla-messagetone.ogg",
        "category"      : "Default",
        "aliases"       : [ "jolla-messagetone.wav" ]
    }, {
        "displayName"   : "jolla-ringtones-tone-2",
        "fileName"      : "jolla-imtone.ogg",
        "category"      : "Default",
        "aliases"       : [ "jolla-imtone.wav" ]
    }, {
        "displayName"   : "jolla-ringtones-tone-3",
        "fileName"      : "jolla-emailtone.ogg",
        "category"      : "Default",
        "aliases"       : [ "jolla-emailtone.wav" ]
    }, {
        "displayName"   : "jolla-ringtones-alert-1",
        "fileName"      : "jolla-alarm.ogg",
        "category"      : "Default",
        "aliases"       : [ "jolla-alarm.wav" ]
    }, {
        "displayName"   : "jolla-ringtones-alert-2",
        "fileName"      : "jolla-calendar-alarm.ogg",
        "category"      : "Default",
        "aliases"       : [ "jolla-calendar-alarm.wav" ]
    }, {
        "displayName"   : "jolla-ringtones-ringtone-remix",
        "fileName"      : "jolla-ringtone-remix2014.ogg",
        "category"      : "Ringtone"
    }, {
        "displayName"   : "jolla-ringtones-aloe-ringtone",
        "fileName"      : "aloe-ringtone.ogg",
        "category"      : "Ringtone"
    }, {
        "displayName"   : "jolla-ringtones-aloe-tone-1",
        "fileName"      : "aloe-tone-1.ogg"
    }, {
        "displayName"   : "jolla-ringtones-aloe-tone-2",
        "fileName"      : "aloe-tone-2.ogg"
    }, {
        "displayName"   : "jolla-ringtones-aloe-tone-3",
        "fileName"      : "aloe-tone-3.ogg"
    }, {
        "displayName"   : "jolla-ringtones-aloe-alert-1",
        "fileName"      : "aloe-alert-1.ogg"
    }, {
        "displayName"   : "jolla-ringtones-aloe-alert-2",
        "fileName"      : "aloe-alert-2.ogg"
    }, {
        "displayName"   : "jolla-ringtones-keira-black-ringtone",
        "fileName"      : "keira-black-ringtone.ogg",
        "category"      : "Ringtone"
    }, {
        "displayName"   : "jolla-ringtones-keira-black-tone-1",
        "fileName"      : "keira-black-tone-1.ogg"
    }, {
        "displayName"   : "jolla-ringtones-keira-black-tone-2",
        "fileName"      : "keira-black-tone-2.ogg"
    }, {
        "displayName"   : "jolla-ringtones-keira-black-tone-3",
        "fileName"      : "keira-black-tone-3.ogg"
    }, {
        "displayName"   : "jolla-ringtones-keira-black-alert-1",
        "fileName"      : "keira-black-alert-1.ogg"
    }, {
        "displayName"   : "jolla-ringtones-keira-black-alert-2",
        "fileName"      : "keira-black-alert-2.ogg"
    }, {
        "displayName"   : "jolla-ringtones-lime-ringtone",
        "fileName"      : "lime-ringtone.ogg",
        "category"      : "Ringtone"
    }, {
        "displayName"   : "jolla-ringtones-lime-tone-1",
        "fileName"      : "lime-tone-1.ogg"
    }, {
        "displayName"   : "jolla-ringtones-lime-tone-2",
        "fileName"      : "lime-tone-2.ogg"
    }, {
        "displayName"   : "jolla-ringtones-lime-tone-3",
        "fileName"      : "lime-tone-3.ogg"
    }, {
        "displayName"   : "jolla-ringtones-lime-alert-1",
        "fileName"      : "lime-alert-1.ogg"
    }, {
        "displayName"   : "jolla-ringtones-lime-alert-2",
        "fileName"      : "lime-alert-2.ogg"
    }, {
        "displayName"   : "jolla-ringtones-nadeshiko-pink-ringtone",
        "fileName"      : "nadeshiko-pink-ringtone.ogg",
        "category"      : "Ringtone"
    }, {
        "displayName"   : "jolla-ringtones-nadeshiko-pink-tone-1",
        "fileName"      : "nadeshiko-pink-tone-1.ogg"
    }, {
        "displayName"   : "jolla-ringtones-nadeshiko-pink-tone-2",
        "fileName"      : "nadeshiko-pink-tone-2.ogg"
    }, {
        "displayName"   : "jolla-ringtones-nadeshiko-pink-tone-3",
        "fileName"      : "nadeshiko-pink-tone-3.ogg"
    }, {
        "displayName"   : "jolla-ringtones-nadeshiko-pink-alert-1",
        "fileName"      : "nadeshiko-pink-alert-1.ogg"
    }, {
        "displayName"   : "jolla-ringtones-nadeshiko-pink-alert-2",
        "fileName"      : "nadeshiko-pink-alert-2.ogg"
    }, {
        "displayName"   : "jolla-ringtones-poppy-red-ringtone",
        "fileName"      : "poppy-red-ringtone.ogg",
        "category"      : "Ringtone"
    }, {
        "displayName"   : "jolla-ringtones-poppy-red-tone-1",
        "fileName"      : "poppy-red-tone-1.ogg"
    }, {
        "displayName"   : "jolla-ringtones-poppy-red-tone-2",
        "fileName"      : "poppy-red-tone-2.ogg"
    }, {
        "displayName"   : "jolla-ringtones-poppy-red-tone-3",
        "fileName"      : "poppy-red-tone-3.ogg"
    }, {
        "displayName"   : "jolla-ringtones-poppy-red-alert-1",
        "fileName"      : "poppy-red-alert-1.ogg"
    }, {
        "displayName"   : "jolla-ringtones-poppy-red-alert-2",
        "fileName"      : "poppy-red-alert-2.ogg"
    }, {
        "displayName"   : "jolla-ringtones-the-first-one-ringtone",
        "fileName"      : "the-first-one-ringtone.ogg",
        "category"      : "Ringtone"
    }, {
        "displayName"   : "jolla-ringtones-the-first-one-tone-1",
        "fileName"      : "the-first-one-tone-1.ogg"
    }, {
        "displayName"   : "jolla-ringtones-the-first-one-tone-2",
        "fileName"      : "the-first-one-tone-2.ogg"
    }, {
        "displayName"   : "jolla-ringtones-the-first-one-tone-3",
        "fileName"      : "the-first-one-tone-3.ogg"
    }, {
        "displayName"   : "jolla-ringtones-the-first-one-alert-1",
        "fileName"      : "the-first-one-alert-1.ogg"
    }, {
        "displayName"   : "jolla-ringtones-the-first-one-alert-2",
        "fileName"      : "the-first-one-alert-2.ogg"
    }
]

}

So, if you have a full ambience, including custom sounds, the directory /usr/share/ambience/myambience should have the following structure:

 images/
    myambience.png
 sounds/
    myambience_agenda.ogg
    myambience_alarm.ogg
    myambience_email.ogg
    myambience_im.ogg
    myambience_ringtone.ogg
    myambience_sms.ogg
 myambience.ambience
 sounds.index

With the myambience.ambience looking like this:


{
    "translationCatalog"        : "ambience-myambience",
    "displayName"               : "myambience",
    "ringerToneFile"            : { "file": "myambience_ringtone.ogg", "enabled": 1 },
    "messageToneFile"           : { "file": "myambience_sms.ogg",      "enabled": 1 },
    "mailToneFile"              : { "file": "", "enabled": 0 },
    "internetCallToneFile"      : { "file": "myambience_ringtone.ogg",       "enabled": 1 },
    "chatToneFile"              : { "file": "myambience_im.ogg",       "enabled": 1 },
    "calendarToneFile"          : { "file": "myambience_agenda.ogg", "enabled": 1 },
    "clockAlarmToneFile"        : { "file": "myambience_alarm.ogg",    "enabled": 1 },
    "version"                   : 2,
    "wallpaper"                 : "ambience-myambience.png",
    "highlightColor"            : "#ff80ff80",
    "secondaryHighlightColor"   : "#ff66cc66",
    "primaryColor"              : "#ffffffff",
    "secondaryColor"            : "#b0ffffff",
    "favorite"                  : true
}

Where the line

    "messageToneFile"           : { "file": "myambience_sms.ogg",      "enabled": 1 },

means that for this Ambience, the tone for messages is set to use myambience_sms.ogg, and that this tone is “enabled”.

In the example above, you also have a disabled entry, the one for email. That means the ambience will not have it associated to the Email notification tone, BUT it will be available for selection for a tone.

Then we have the sounds.index file. This maps the file name to a “display name”, so in the selection list you will not see myambience_sms.ogg but something prettier.

{
    "translationCatalog" : "ambience-myambience",
    "files" : [
        { "displayName" : "My Ambience Ringtone"          , "fileName" : "myambience_ringtone.ogg" },
        { "displayName" : "My Ambience IM"            , "fileName" : "myambience_im.ogg" },
        { "displayName" : "My Ambience Email"         , "fileName" : "myambience_email.ogg" },
        { "displayName" : "My Ambience Message"       , "fileName" : "myambience_sms.ogg" },
        { "displayName" : "My Ambience Agenda"            , "fileName" : "myambience_agenda.ogg" },
        { "displayName" : "My Ambience Alarm"             , "fileName" : "myambience_alarm.ogg" }
    ]
}

NOTE: actually, displayName corresponds to a Qt translation Id. If you have a Qt .qm file with the names, you can have translationCatalog have its name, and displayName the translation Ids within.
But most users will not have that, and the string will be used as fallback.

1 Like

But wait! That doesn’t actually answer the original question!

Well, the second option you have is using a pre-installed “sound” theme.

These are in /usr/share/sounds/. Per default you will find jolla-ringtones/ and freedesktop/ there. (There’s also jolla-ambient/ but those are not ambience tones despite the name.). You might have installed some additional sound themes in which case you will see more than just the default.

These directories also have stereo.index files.

e.g. /usr/share/sounds/jolla-ringtones/stereo.index

{
    "translationCatalog" : "jolla-ringtones",
    "files" : [
        {
            "displayName"   : "jolla-ringtones-ringtone",
            "fileName"      : "jolla-ringtone.ogg",
            "category"      : "Ringtone",
            "aliases"       : [ "jolla-ringtone.wav" ]
        }, {
            "displayName"   : "jolla-ringtones-tone-1",
            "fileName"      : "jolla-messagetone.ogg",
            "category"      : "Default",
            "aliases"       : [ "jolla-messagetone.wav" ]
        }, {
            "displayName"   : "jolla-ringtones-tone-2",
            "fileName"      : "jolla-imtone.ogg",
            "category"      : "Default",
            "aliases"       : [ "jolla-imtone.wav" ]
        }, {
            "displayName"   : "jolla-ringtones-tone-3",
            "fileName"      : "jolla-emailtone.ogg",
            "category"      : "Default",
            "aliases"       : [ "jolla-emailtone.wav" ]
        },
[...]
}

You can use either “fileName”, "displayName, or “alias” attributes as the value to the “fileName” property in the original .ambience file.

So e.g.:

  "chatToneFile":  "fileName": "jolla-ringtone.wav",  "enabled": 1}

NOTE: The attribute you have to use in the .ambience file is fileName for these, not file!

1 Like

Thanks for explain! As you already found out, I know the structure of ambience file, so the magic word I was looking for is “fileName”. :wink:
I will try that asap. Thanks again!

1 Like

You can open your soundfiles with Audacity and then do: menu bar / files / export / export as ogg.
Give them easy filenames, avoiding non ascii char’s.
This way you can use all your existing soundfiles easily with the SailfishOS phone.

Thanks, But that isn’t really what I am trying to do.

The file encoding shouldn’t matter (much). wav, vorbis, and mp3 should all work fine. Not too sure about FLAC, but who uses flac for SMS tones.

1 Like

One more question…
Can I use the aliases e.g. jolla-messagetone.wav instead of the actual jolla-messagetone.ogg?

Thanks again, it worked perfect. All my personal ambiences is preconfigured for future reflash. :+1:

1 Like

According to my tests you can, yes.

1 Like