一般的原聲原影 KTV 檔案,播放時有個最大的問題,
就是每一首歌的音平水準不同,導致歌語歌之間的
音量差距很大,要一直調整擴大機的音量.
MP3 也會有類似的問題, ReplayGain 就是用來解決
這種問題. 所使用的原理, 就是算出整首歌音量的"能量",
然後算出每首歌,要達到標準音量能量的話,需要調大聲
或調小聲多少分貝(dB).
所以如果要調整 KTV 音量, 讓每首歌播出時的音量
感覺都差不多, 可以利用 ReplayGain 的方法, 算出每一首
歌曲的音量能量, 再得到需要調整的增益(分貝)值, 就可以拿來
設定給點歌軟體, 讓每首歌的預設音量都根據 ReplayGain
算出來的分貝值調整, 就可以讓每首歌音量差不多.
ffmpeg 是一個功能強大的影音處理程式, 裏頭也有包括
計算影音檔中, 各個音軌的 replaygain 的值. 事實上 ffmpeg
可以計算音軌的 RMS 及 replaygain, 兩者都是計算音量的能量,
但是 replaygain 還有根據頻率不同給予不同的能量加權,
也就是高音與低音給人的音量能量感受,有不同的感受.
利用 ffmpeg 計算出來的 replaygain 分貝值,就是該首歌曲
需要調整的音量相對值. 公式則為 :
音量調整值 = 10^(分貝值/20)
例如算出來的分貝值是 +1.38dB 的話,則表示音量調整值是
10^(1.38/20) = 10^(0.069)=1.17
如果算出來的分貝值是 -2.15dB 的話, 則音量調整值是
10^(-2.15/20) = 10^(-0.1075) = 0.78
因為音量有可能需要調大聲,也可能調小,所以假設
點歌軟體每首歌的預設音量是設定在 40(0最小, 100 最大值),
則往上調大聲最多可以調整 2.5 倍, 調小聲基本上比較沒限制,
所以上面例子中, +1.38dB 的歌曲, 設定給點歌軟體的預設音量值
就是 40*1.17 = 46.8 = 47
另一個 -2.15dB 的歌曲, 設定給點歌軟體的預設音量值為
40*0.78 = 31.2
所以每首歌算出 replaygain 的增益值之後, 就可以設定
點歌軟體資料庫中, 每首歌曲的預設音量值, 在每首歌曲播出時,
由於預設音量的調整, 讓每首歌聽起來的音量大小都差不多.
至於預設音量的標準值, 我目前建議是設定在 40, 這樣可以讓
歌曲往上調整音量的空間, 最大有 2.5 倍(大約增益值是 +8dB),
往下調整的解析度也還足夠. 如果實際處理的歌曲, 很多都太小聲,
增益值都超過 +8dB 的話, 在考慮把標準音量從 40 往下調整.
基本上點歌軟體的標準音量往下調整的話, 實際從 PC 輸出的音量
也會比較小, 需要靠擴大機端調大輸出音量來補償.
目前我會利用 ffmpeg, 把每首歌曲的 replaygain 增益值算出來,
然後把預設音量值直接算好後, 把每首歌曲檔名修改為類似 :
Selina_vL_gn46.mpg
ALin_vR_gn37.mpg
然後再利用程式,掃描點歌軟體的資料庫檔案, 把預設音量的欄位
靠 "_gn" 後面的數值設定進去, 就可以讓每首歌曲的預設音量
根據 replaygain 調整.
至於左右聲道的判斷, 還有增益值的可信度, 會再另外一篇文章再
討論.
2015年8月4日 星期二
2015年7月27日 星期一
Use Access expression builder to calculate field data from another field
1. after the database file is opened, select 查詢設計
2. select the database table which will be used in the query
3. select the any data field to display for index in the final query table
4. keep the focus(cursor) on the new display field to input expression
5. press on the expression builder to help to construct the expression
6. input the expression to generate the new field data
8. in the query result, you may mark the whole column, then copy/paste to overwrite the original database table
instead of using expression builder in step 6, it is more convenient to
copy/paste the existing expression directly to the field definition in step 7.
Expr1: IIf(InStr(1,[ktv_Song]![Song_FileName],"_gn")=0,40,Val(Mid([ktv_Song]![Song_FileName],InStr(1,[ktv_Song]![Song_FileName],"_gn")+3,2)))
2015年6月5日 星期五
audio filter path of ffmpeg
To use ffmpeg to calculate the audio power,
including "volumedetect" and "replaygain" filter,
there is some trick to apply the filter path.
The target is to calculate the audio power for
the left/right audio channels in the mpeg I stream.
The audio filter path will be composed of 3 parts :
1. select channel by "pan" filter, [0:a] for the input audio stream,
c0=c0 to select left channel, and c0=c1 for right channel
2. specify the audio channel number by "aformat"
which is necessary for volumedetect filter afterwards
3. "volumedetect" or "replaygain" filter
For example :
ffmpeg -i vcd.mpg -filter_complex "[0:a]pan=1c|c0=c0[middle];[middle]aformat=channel_layouts=mono[final];[final]volumedetect" -f null NUL
replacing "c0=c0" by "c0=c1" for right channel(mono),
or "volumedetect" by "replaygain" for RMS or replaygain statistics.
including "volumedetect" and "replaygain" filter,
there is some trick to apply the filter path.
The target is to calculate the audio power for
the left/right audio channels in the mpeg I stream.
The audio filter path will be composed of 3 parts :
1. select channel by "pan" filter, [0:a] for the input audio stream,
c0=c0 to select left channel, and c0=c1 for right channel
2. specify the audio channel number by "aformat"
which is necessary for volumedetect filter afterwards
3. "volumedetect" or "replaygain" filter
For example :
ffmpeg -i vcd.mpg -filter_complex "[0:a]pan=1c|c0=c0[middle];[middle]aformat=channel_layouts=mono[final];[final]volumedetect" -f null NUL
replacing "c0=c0" by "c0=c1" for right channel(mono),
or "volumedetect" by "replaygain" for RMS or replaygain statistics.
2014年1月3日 星期五
Realtek 8168b under Ubuntu
之前遇到 Ubuntu 機器上, Realtek 8168b 網卡不能上 Gigabit 速度,因為 r8169 driver 不適用,所以用底下的方法,改編 r8168 driver 就好了. 只是這個 driver 本身沒辦法驅動 r8169.
sudo apt-get install --reinstall linux-headers-$(uname -r) linux-headers-generic build-essential dkms wget http://media.cdn.ubuntu-de.org/forum/attachments/14/31/3005217-r8168-dkms-8.036.00.tar.gz sudo tar xvf 3005217-r8168-dkms-8.036.00.tar.gz -C /usr/src sudo dkms add -m r8168-dkms -v 8.036.00 sudo dkms build -m r8168-dkms -v 8.036.00 sudo dkms install -m r8168-dkms -v 8.036.00 echo "blacklist r8169" | sudo tee -a /etc/modprobe.d/blacklist.conf
做完之後,還要再 update 一下
~$ update-initramfs -u
2013年11月12日 星期二
mount a HDD image under Linux
(1). determine the offset of the partition
# fdisk -l 3.4.61.img
Disk linaro-quantal-developer-20130422-342-A20-3.4.61.img: 944 MB, 944766976 bytes
58 heads, 20 sectors/track, 1590 cylinders, total 1845248 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
3.4.61.img 1 2048 1845247 921600 83 Linux
# fdisk -l 3.4.61.img
Disk linaro-quantal-developer-20130422-342-A20-3.4.61.img: 944 MB, 944766976 bytes
58 heads, 20 sectors/track, 1590 cylinders, total 1845248 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
3.4.61.img 1 2048 1845247 921600 83 Linux
From the example, the offset of the only partition is
2048*512=1048576
(2). setup the loopback device
# losetup -o 1048576 /dev/loop0 3.4.61.img
(3). mount the partition
# mount /dev/loop0 /mnt/temp
(4). umount the partition and detach the loopback device
# umount /mnt/temp
# losetup -d /dev/loop0
2013年11月6日 星期三
Android build system trace
整個 Android build 的主體,都放在
build 底下, 開始的第一個指令
source build/envsetup.sh
會"建立"幾個 shell 的 function,
在 shell 底下下 set 指令就會印出來,
之後就可以下 lunch, cgrep, godir 等"指令".
build 底下, 開始的第一個指令
source build/envsetup.sh
會"建立"幾個 shell 的 function,
在 shell 底下下 set 指令就會印出來,
之後就可以下 lunch, cgrep, godir 等"指令".
2013年10月23日 星期三
Beagle board uboot compilation
- 先在 /opt/toolchains 底下安裝 linaro 的 toolchain
- uboot source code 中, edit Makefile, 修改底下的 CROSS_COMPILE 變數,反映實際toolchain路徑
CROSS_COMPILE = /opt/toolchains/gcc-linaro-arm-linux-gnueabihf-4.8-2013.07-1_linux/bin/arm-linux-gnueabihf-
- make ARCH=arm omap3_beagle_config
- make ARCH=arm all -j 8
訂閱:
文章 (Atom)







