Skip to content

Instantly share code, notes, and snippets.

@HsuChiChen
Created July 23, 2022 05:11
Show Gist options
  • Save HsuChiChen/0a4febbba04cef17d6b201e21f631e0a to your computer and use it in GitHub Desktop.
Save HsuChiChen/0a4febbba04cef17d6b201e21f631e0a to your computer and use it in GitHub Desktop.
模擬電話撥號音,可自行用手機測試。一般的電話鍵,在按下的時候會產生一個聲音,基本上每個聲音由兩種主要的音頻合成,稱為雙音多頻(Dual Tone Multi Frequency)。
% dial
N = 8192*0.5;
n = 0:N-1;
x = 0.5*n/N;
y1 = sin(2*pi*697*x)+sin(2*pi*1209*x);
y2 = sin(2*pi*697*x)+sin(2*pi*1336*x);
y3 = sin(2*pi*697*x)+sin(2*pi*1477*x);
y4 = sin(2*pi*770*x)+sin(2*pi*1209*x);
y5 = sin(2*pi*770*x)+sin(2*pi*1336*x);
y6 = sin(2*pi*770*x)+sin(2*pi*1477*x);
y7 = sin(2*pi*697*x)+sin(2*pi*1209*x);
y8 = sin(2*pi*941*x)+sin(2*pi*1336*x);
y9 = sin(2*pi*697*x)+sin(2*pi*1477*x);
y0 = sin(2*pi*941*x)+sin(2*pi*1336*x);
z = zeros(1,512); % space
sound([y5 z y0 z y1 z y2 z y0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment