Warning, /multimedia/kid3/src/qml/script/ReplayGain2SoundCheck.qml is written in an unsupported language. File is not indexed.
0001 /** 0002 * \file ReplayGain2SoundCheck.qml 0003 * Create iTunNORM SoundCheck information from replay gain frames. 0004 * Replay gain tags can be generated e.g. using "mp3gain -s i". 0005 * 0006 * \b Project: Kid3 0007 * \author Urs Fleisch 0008 * \date 28 Feb 2015 0009 * 0010 * Copyright (C) 2015-2017 Urs Fleisch 0011 * 0012 * This program is free software; you can redistribute it and/or modify 0013 * it under the terms of the GNU Lesser General Public License as published by 0014 * the Free Software Foundation; version 3. 0015 * 0016 * This program is distributed in the hope that it will be useful, 0017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0019 * GNU Lesser General Public License for more details. 0020 * 0021 * You should have received a copy of the GNU Lesser General Public License 0022 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0023 */ 0024 0025 import Kid3 1.1 0026 0027 Kid3Script { 0028 onRun: { 0029 function doWork() { 0030 if (app.selectionInfo.tag(Frame.Tag_2).tagFormat) { 0031 var rgStr = app.getFrame(tagv2, "replaygain_track_gain") 0032 if (rgStr) { 0033 var rg = parseFloat(rgStr) 0034 if (!isNaN(rg)) { 0035 // Calculate SoundCheck value and insert a sequence of 10 0036 // hex zero-padded to 8 digits values into the iTunNORM frame. 0037 var scVal = parseInt(Math.pow(10, -rg / 10) * 1000).toString(16) 0038 var pad = "00000000" 0039 scVal = " " + (pad + scVal).slice(-pad.length) 0040 var sc = new Array(11).join(scVal) 0041 console.log("Set iTunNORM to %1 in %2". 0042 arg(sc).arg(app.selectionInfo.fileName)) 0043 app.setFrame(tagv2, "iTunNORM", sc) 0044 } else { 0045 console.log("Value %1 is not a float in %2". 0046 arg(rgStr).arg(app.selectionInfo.fileName)) 0047 } 0048 } 0049 } 0050 if (!nextFile()) { 0051 if (isStandalone()) { 0052 // Save the changes if the script is started stand-alone, not from Kid3. 0053 app.saveDirectory() 0054 } 0055 Qt.quit() 0056 } else { 0057 setTimeout(doWork, 1) 0058 } 0059 } 0060 0061 firstFile() 0062 doWork() 0063 } 0064 }