Skip to content

Commit

Permalink
[tinyPy] Rename method to set audio gain to stay compatible with scri…
Browse files Browse the repository at this point in the history
…pts created by older versions
  • Loading branch information
eumagga0x2a committed Aug 29, 2018
1 parent c6400a8 commit 78c3ef4
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ int pyGetNormalizeLevel(IEditor *editor);
void pySetNormalizeMode(IEditor *editor, int mode);
void pySetNormalizeValue(IEditor *editor, int value);
void pySetNormalizeLevel(IEditor *editor, int level);
int pySetNormalize(IEditor *, int track, int mode, int gain100, int maxlevel);
int pySetNormalize(IEditor *, int track, int mode, int gain100);
int pySetNormalize2(IEditor *, int track, int mode, int gain100, int maxlevel);
int pySetFilm2Pal(IEditor *,int track,int onoff);
int pySetPal2Film(IEditor *,int track,int onoff);
/* Info */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ int pyGetNormalizeLevel(IEditor *editor,int dex)
\brief
*/

int pySetNormalize(IEditor *editor, int dex, int mode, int value, int level)
int pySetNormalize2(IEditor *editor, int dex, int mode, int value, int level)
{
ADM_GAINMode m;
int32_t gain, max;
Expand All @@ -223,7 +223,15 @@ int pySetNormalize(IEditor *editor, int dex, int mode, int value, int level)
max = (int32_t)level;
return editor->setAudioFilterNormalise(dex,m,gain,max);
}
/**
\fn pySetNormalize
\brief preserve compatibility to project scripts created by older versions
*/

int pySetNormalize(IEditor *editor, int dex, int mode, int value)
{
return pySetNormalize2(editor, dex, mode, value, -30);
}
/**
\fn
\brief
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void PythonScriptWriter::loadVideo(const char* path)

void PythonScriptWriter::setAudioGain(int trackIndex, ADM_GAINMode gainMode, int32_t gainValue, int32_t maxLevel)
{
*(this->_stream) << "adm.audioSetNormalize(" << trackIndex << ", " << gainMode << ", " << gainValue << ", " << maxLevel << ")" << std::endl;
*(this->_stream) << "adm.audioSetNormalize2(" << trackIndex << ", " << gainMode << ", " << gainValue << ", " << maxLevel << ")" << std::endl;
}

void PythonScriptWriter::setAudioMixer(int trackIndex, CHANNEL_CONF mixer)
Expand All @@ -109,7 +109,7 @@ void PythonScriptWriter::setAudioDrc(int trackIndex, bool active)
}
void PythonScriptWriter::setAudioShift(int trackIndex, bool active,int32_t value)
{
*(this->_stream) << "adm.audioSetShift(" << trackIndex << ", " << active << "," << value << ")" << std::endl;
*(this->_stream) << "adm.audioSetShift(" << trackIndex << ", " << active << ", " << value << ")" << std::endl;
}


Expand Down
25 changes: 23 additions & 2 deletions avidemux_plugins/ADM_scriptEngines/tinyPy/src/adm_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,24 @@ static tp_obj zzpy_appendVideo(TP)
int r = editor->appendFile(p0);
return tp_number(r);
}
// audioSetNormalize -> int pySetNormalize (IEditor int int int int)
// audioSetNormalize -> int pySetNormalize (IEditor int int int)
static tp_obj zzpy_audioSetNormalize(TP)
{
tp_obj self = tp_getraw(tp);
IScriptEngine *engine = (IScriptEngine*)tp_get(tp, tp->builtins, tp_string("userdata")).data.val;
IEditor *editor = engine->editor();
TinyParams pm(tp);
void *me = (void *)pm.asThis(&self, ADM_PYID_AVIDEMUX);

IEditor *p0 = editor;
int p1 = pm.asInt();
int p2 = pm.asInt();
int p3 = pm.asInt();
int r = pySetNormalize(p0,p1,p2,p3);
return tp_number(r);
}
// audioSetNormalize2 -> int pySetNormalize2 (IEditor int int int int)
static tp_obj zzpy_audioSetNormalize2(TP)
{
tp_obj self = tp_getraw(tp);
IScriptEngine *engine = (IScriptEngine*)tp_get(tp, tp->builtins, tp_string("userdata")).data.val;
Expand All @@ -428,7 +444,7 @@ static tp_obj zzpy_audioSetNormalize(TP)
int p2 = pm.asInt();
int p3 = pm.asInt();
int p4 = pm.asInt();
int r = pySetNormalize(p0,p1,p2,p3,p4);
int r = pySetNormalize2(p0,p1,p2,p3,p4);
return tp_number(r);
}
// audioSetDrc -> int pySetDrc (IEditor int int )
Expand Down Expand Up @@ -699,6 +715,10 @@ tp_obj zzpy__pyAdm_get(tp_vm *vm)
{
return tp_method(vm, self, zzpy_audioSetNormalize);
}
if (!strcmp(key, "audioSetNormalize2"))
{
return tp_method(vm, self, zzpy_audioSetNormalize2);
}
if (!strcmp(key, "audioSetDrc"))
{
return tp_method(vm, self, zzpy_audioSetDrc);
Expand Down Expand Up @@ -809,6 +829,7 @@ static tp_obj zzpy__pyAdm_help(TP)
engine->callEventHandlers(IScriptEngine::Information, NULL, -1, "audioEncoding(IEditor, int)\n");
engine->callEventHandlers(IScriptEngine::Information, NULL, -1, "appendVideo(str)\n");
engine->callEventHandlers(IScriptEngine::Information, NULL, -1, "audioSetNormalize(IEditor,int,int,int)\n");
engine->callEventHandlers(IScriptEngine::Information, NULL, -1, "audioSetNormalize2(IEditor,int,int,int,int)\n");
engine->callEventHandlers(IScriptEngine::Information, NULL, -1, "audioSetDrc(IEditor,int,int)\n");
engine->callEventHandlers(IScriptEngine::Information, NULL, -1, "videoCodec(str, couples)\n");
engine->callEventHandlers(IScriptEngine::Information, NULL, -1, "audioSetMixer(int,str)\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
/* METHOD */ int pySetPal2Film:audioSetPal2Film(int,int)
/* METHOD */ int pySetFilm2Pal:audioSetFilm2Pal(int,int)
/* METHOD */ int pySetNormalize:audioSetNormalize(int,int,int)
/* METHOD */ int pySetNormalize:audioSetNormalize2(int,int,int,int)
/* METHOD */ int pySetDrc:audioSetDrc(int,int)
/* METHOD */ int pySetAudioShift:audioSetShift(int,int,int)
#
Expand Down

0 comments on commit 78c3ef4

Please sign in to comment.