2010-12-17 38 views
12

給定一個MP3我想從文件中提取波形圖像(.png)如何在Linux中創建MP3的波形圖像?

有沒有可以做我需要的軟件包?

+2

是的,有一個工具,它正是這麼做的:http://www.tuned-project.org/audio-tools – 2012-02-18 10:41:47

+0

@ user1217953 - 調整後的音頻工具鏈接是死的,它似乎在https://launchpad.net/tuned-audio-tools/+download(注意,你需要'libgee'和'gstreamer-1.0'來構建);另請參閱https://github.com/limikael/rendersound(注意,您需要一個相對較新的'libavcodec'來構建它);另請參見[wav2png](http://stackoverflow.com/a/11067909/277826) – sdaau 2015-01-04 21:29:48

回答

2

如果您有GUI環境,則可以使用audacity音頻編輯器加載mp3,然後使用print命令生成波形的pdf。然後將PDF轉換爲PNG。

+0

該問題發佈在Stack Overflow上。所以我認爲這是一個編程問題。你所提供的是一種解決方法,只有當你有一個_user_手動執行每個文件時才能完成。沒有-1因爲我lold)) – Septagram 2010-12-17 08:41:04

+3

我真誠地嘗試有幫助(並驚訝大膽可以打印)。此外,這:http://forum.audacityteam.org/viewtopic.php?f=15&t=38341 – Lifeguard 2010-12-17 22:46:28

+0

感謝您的幫助:)雖然正在尋找自動創建一個聲譜圖(圖像)和音頻文件(MP3 )。您發送的鏈接看起來非常有用。謝謝 – 2010-12-19 05:27:30

2

我會做這樣的事情:

  • 找到一種工具,MP3轉換爲PCM,一個8位或16位值 每個樣本即二進制數據。我想的mplayer能做到這一點

  • 管的結果到公用二進制數據轉換爲數字的ASCII表示 十進制格式

  • 使用的gnuplot到的值該列表轉換成PNG圖形。

而瞧,unix工具之間的管道的力量。現在,如果gnuplot能夠從二進制格式讀取數據,此列表中的第2步可能是optionnal。

+0

聽起來像一個真正的好主意。會給這個鏡頭,讓你知道它是怎麼回事。 是的,gnuplot確實接受一個二進制數據文件作爲其數據源。 謝謝 – 2010-12-19 05:28:09

3

這是SOX標準功能(聲音命令行工具時,Windows & Linux)的 檢查http://sox.sourceforge.net/sox.html

「的譜圖在便攜式網絡圖形(PNG)文件呈現的「頻譜」的功能,並在X軸上顯示時間,在Y軸上顯示頻率和在Z軸上顯示音頻信號的大小。Z軸值由XY平面中像素的顏色(或可選強度)表示。音頻信號包含多個通道,然後從通道1(這是立體聲音頻的左聲道)開始,從上到下顯示這些通道。「

+5

光譜圖不是波形... – sdaau 2015-01-04 03:29:39

12

使用soxgnuplot您可以創建基本的波形圖像:

sox audio.mp3 audio.dat #create plaintext file of amplitude values 
tail -n+3 audio.dat > audio_only.dat #remove comments 

# write script file for gnuplot 
echo set term png size 320,180 > audio.gpi #set output format 
echo set output \"audio.png\" >> audio.gpi #set output file 
echo plot \"audio_only.dat\" with lines >> audio.gpi #plot data 

gnuplot audio.gpi #run script 

enter image description here

要創建簡單的東西/漂亮,使用下面的GNU繪圖文件作爲模板(保存爲音頻。 GPI):

#set output format and size 
set term png size 320,180 

#set output file 
set output "audio.png" 

# set y range 
set yr [-1:1] 

# we want just the data 
unset key 
unset tics 
unset border 
set lmargin 0    
set rmargin 0 
set tmargin 0 
set bmargin 0 

# draw rectangle to change background color 
set obj 1 rectangle behind from screen 0,0 to screen 1,1 
set obj 1 fillstyle solid 1.0 fillcolor rgbcolor "#222222" 

# draw data with foreground color 
plot "audio_only.dat" with lines lt rgb 'white' 

,只是運行:

sox audio.mp3 audio.dat #create plaintext file of amplitude values 
tail -n+3 audio.dat > audio_only.dat #remove comments 

gnuplot audio.gpi #run script 

enter image description here

基於this answer到類似的問題是更普遍的關於文件格式,但在使用有關軟件少將軍。

0

你可能想考慮BBC的audiowaveform。

audiowaveform是一個C++命令行應用程序,可以從MP3,WAV或FLAC格式的音頻文件中生成波形數據。波形數據可用於生成音頻的視覺渲染,外觀與音頻編輯應用程序類似。

波形數據文件以二進制格式(.dat)或JSON(.json)保存。給定輸入波形數據文件,audiowaveform還可以在給定的時間偏移和縮放級別將音頻波形呈現爲PNG圖像。

通過首先組合左聲道和右聲道產生單聲道信號,從輸入立體聲音頻信號產生波形數據。下一階段是計算N個輸入樣本組的最小和最大樣本值(其中N由--zoom命令行選項控制),使得每個N個輸入樣本產生一組最小點和最大點輸出。

https://github.com/bbcrd/audiowaveform