安裝作業系統
要安裝這個版本,不然 kernel 會出事。幹試了超久
Configuration:
1-wire要關掉
1-wire要關掉
1-wire要關掉
啟動 SSH 免密登入
#Client
ssh-keygen
#Server
mkdir ~/.ssh
cat id_rsa.pub >> ~/.ssh/authorized_keys
安裝 Seeed Voicecard
https://wiki.seeedstudio.com/ReSpeaker_6-Mic_Circular_Array_kit_for_Raspberry_Pi/#hardware
sudo apt-get update
sudo apt-get upgrade
git clone <https://github.com/respeaker/seeed-voicecard.git>
cd seeed-voicecard
sudo ./install.sh
sudo reboot
#Check
arecord -L
aplay -L
#LED Rings (Device test)
git clone --depth 1 <https://github.com/respeaker/pixel_ring.git>
cd pixel_ring
pip install -U -e .
python examples/respeaker_4mic_array.py
portaudio
sudo apt-get install libasound-dev
sudo apt install portaudio19-dev
Debug:若出現以下錯誤訊息
ALSA lib pcm.c:8424:(snd_pcm_recover) underrun occurred
Expression 'err' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 3355
Expression 'ContinuePoll( self, StreamDirection_In, &pollTimeout, &pollCapture )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 3907
Expression 'PaAlsaStream_WaitForFrames( stream, &framesAvail, &xrun )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 428
做這個
#1.Disable pulseaudio
systemctl --user disable pulseaudio.socket
systemctl --user disable pulseaudio.service
systemctl --user status pulseaudio
#2.Set defult audio device(建議每次開機都做)
sudo raspi-config
>System Options
>Audio
>音效卡
#Or: remove pulseaudio
sudo apt-get remove --purge pulseaudio
可以看這個範例:
GNU Scientific Library
https://www.gnu.org/software/gsl/
依照官網安裝(皆使用預設)
#若 gcc 找不到動態函式庫,執行這個
sudo ldconfig /usr/local/lib
執行看看:
//gsl example
#include <stdio.h>
#include <gsl/gsl_sf_bessel.h>
int
main (void){
double x = 5.0;
double y = gsl_sf_bessel_J0 (x);
printf ("J0(%g) = %.18e\\n", x, y);
return 0;
}
#Compile and link
gcc -Wall filename.c -lgsl -lgslcblas -lm
一些矩陣處理可以看 gsl_matrix process
一些矩陣運算可以看 gsl_matrix calculate
FFTW
相較於gsl的傅利葉轉換,fftw的傅利葉轉換更好處理 用 FFTW3 來做傅利葉轉換 。
今天(20230108)發現GSL的FFT函式庫好像有問題,沒有訊號輸入的時候值會非常大。此外,因為 Beamforming 有經過反矩陣運算,所以在輸入訊號為雜訊時,Autocorrelation 矩陣會趨近於零,再做反矩陣就會趨近無無窮大。當相目前想到的解法有幾個
使用SNR偵測訊號,若有訊號時才放大增益值:稍微有效,但不盡滿意
Real-time Beamforming with SNR Detect Using Portaudio, FFTW And gsl_lib
抑制反矩陣的數值:有效,且解決程式不穩定會當機的問題
Stable Ver. of Real-time Beamforming with SNR feedback control
換用FFWT做看看:無效,但增加程式執行的效率
CBLAS
效率較高且快速
//TODO
Beamforming
DOA (Direction of arrival)
本來是用 MUSIC 但後來考量到即時性,直接使用 Beamforming 的能量譜進行 DOA Search.
//TODO
gcc-phat or MUSIC?
Denoise
用 Matlab 實作
實驗:結合 Portaudio 即時將音訊傅利葉轉換後再轉回來,並輸出到耳機
Real-time fft And ifft Using Portaudio And gsl_lib
實驗:第一階段 Real-time Beamforming
Real-time Beamforming Using Portaudio And gsl_lib
實驗:Real-time Beamforming with SNR feedback control
Real-time Beamforming with SNR Detect Using Portaudio, FFTW And gsl_lib