Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Premiere pro extend script set audio level of clip

Participant ,
May 16, 2023 May 16, 2023

Hi guys I am trying to descrease/increase level of clip's audio using extendScript, what can be the problem here?

 

function setAudioLevel(volume){
  var activeSequence = app.project.activeSequence;
  var track = activeSequence.audioTracks[0]
  for (var i = 0; i < track.clips.length; i++) {
    var prop = track.clips[i].components[0].properties[1]
        prop.setTimeVarying(false)
    var value = prop.getValue() // returns 0.17782793939114 while interface shows 0.0 
    track.clips[i].components[0].properties[1].setValue(volume)// if volume is -3 it will set to infinity 
    
  }

}

 

TOPICS
SDK
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , May 22, 2023 May 22, 2023

So the values are displayed in dB, but they are stored in float 0.0-1.0 scale. That's why:

 

negative infinity : 0

-2 : 0.14125375449657

-1 : 0.15848931670189

0 : 0.17782793939114

1 : 0.19952623546124

2 : 0.22387212514877

15 : 1

 

I'm unsure of the exact conversion, supposed to be Log10 for dB, but looks little different, maybe @Bruce Bullis could chime in.

Translate
Community Expert , May 22, 2023 May 22, 2023

Found it, there's just an offset of 15 so these formulas after the log10 * 20 for db Conversion, these seem to work well:


function dbToDec(x) {
  return Math.pow(10, (x - 15) / 20);
}

function decToDb(x) {
  return 20 * Math.log(x) * Math.LOG10E + 15;
}
Translate
Community Expert ,
May 22, 2023 May 22, 2023

So the values are displayed in dB, but they are stored in float 0.0-1.0 scale. That's why:

 

negative infinity : 0

-2 : 0.14125375449657

-1 : 0.15848931670189

0 : 0.17782793939114

1 : 0.19952623546124

2 : 0.22387212514877

15 : 1

 

I'm unsure of the exact conversion, supposed to be Log10 for dB, but looks little different, maybe @Bruce Bullis could chime in.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 22, 2023 May 22, 2023

Found it, there's just an offset of 15 so these formulas after the log10 * 20 for db Conversion, these seem to work well:


function dbToDec(x) {
  return Math.pow(10, (x - 15) / 20);
}

function decToDb(x) {
  return 20 * Math.log(x) * Math.LOG10E + 15;
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 22, 2025 May 22, 2025
LATEST
had an issues  0.17782793939114  showing -7.87740184193808e-8

this is a little fix
function decToDb(x) {
var result = 20 * Math.log(x) * Math.LOG10E + 15;

// Round very small values to 0 (handles floating-point precision)
if (Math.abs(result) < 1e-6) {
return 0;
}

// Round to reasonable precision (2 decimal places for dB)
return Math.round(result * 100) / 100;
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines