Note:getAttributes() doesn't work properly for alt and dur when values are at defaults (Lua)

When scripting in Lua:

  • An empty table is returned from Note:getAttributes() for alt and dur when all the values are at default. It should instead return a table filled with default values. It works correctly if any of the values are not default.

  • Edge case - the above also works properly for cases where the values have been changed and then returned back to default values. But I suspect that’s because setting alt and dur to default values stores the actual value, instead of setting the value to null.

  • Note:getPhonemes() returns an empty string instead of a space delimited string of phonemes.

  • Note Properties panel is not refreshed after script completes. It should refresh to show the new values for the currently selected note, if they have been changed.

  • When changing Lyrics, the prior alt and dur values are retained. The alt and dur values should be reset back to default values.


It’s been over 2 years, and the function Note:getPhonemes() is still broken.

However, the function does work… if the phonemes don’t match the default dictionary value.

For example, if the phonemes are /k ae t/ for “cat”, the function will return an empty string.

But if the phonemes are /k aa t/ for “cat” (not the default dictionary value), it will return the phonemes.

Since there’s no way to call the dictionary to find the what the phonemes are in the default case, that means for 90%+ of the time the function is worthless.

1 Like

In my experience the only reliable way to get phonemes for a note is as follows:

  1. Get an array of all phonemes for the group with SV:getPhonemesForGroup
  2. Find the index of the desired note in its group with Note: getIndexInParent
  3. Use the note’s index to get the phonemes from the array returned by step 1

It still doesn’t indicate whether the phonemes are default, from a user dictionary, or manually set, but you at least always get a result. I suppose you could infer manual settings by whether Note:getPhonemes is null, but ideally we would also be able to check if a user dictionary is selected and if a word is present in that dictionary…

I really hope Dreamtonics revisits the scripting API at some point though… it almost feels as if they’ve forgotten about it.

This is a simple (JS) example of the process above: svstudio-scripts/CopyPhonemes.js at main · claire-west/svstudio-scripts · GitHub


Good to know! I hadn’t realized that function existed.

I see that internally SV:getPhonemesForGroup() may be may end up making a call to the dictionary routine, so it has to be treated as an asynchronous call. :roll_eyes:

Still, better than not having any option! :+1: