简谱知识
首先了解简谱基础知识
表示音的高低的基本符号,用七个阿拉伯数字标记。
它们的写法和读法如下:
- 写法: 1 2 3 4 5 6 7
- 读法: Do Re Mi Fa Sol La Si
1
˙
\dot{1}
1˙ 表示高音Do
1
1
1 表示中音Do
1
.
\mathop{1}\limits_{.}
.1 表示低音Do
音符名称 | 写法 | 时值 |
---|---|---|
全音符 | X − − − X--- X−−− | 四拍 |
二分音符 | X − X- X− | 二拍 |
四分音符 | X X X | 一拍 |
八分音符 | X ‾ \underline{X} X | 半拍 |
十六分音符 | X ‾ ‾ \underline{\underline{X}} X | 四分之一拍 |
三十二分音符 | X ‾ ‾ ‾ \underline{\underline{\underline{X}}} X | 八分之一拍 |
附点音符 | . | 前面音符时值的一半 |
休止符 | 0 | 一拍 |
MATLAB变量表示
音符变量以三部分表示
- l / m / h / o l/m/h/o l/m/h/o:低音/中音/高音/休止符
- 1 / 2 / 3 / 4 / 5 / 6 / 7 1/2/3/4/5/6/7 1/2/3/4/5/6/7:Do/Re/Mi/Fa/Sol/La/Si
- 1 / 2 / 4 / 8 / 16 1/2/4/8/16 1/2/4/8/16:全音符/二分音符/四分音符/八分音符/十六分音符
以下面简谱为例
则应表示为:
m
68
,
m
616
,
m
616
,
m
62
,
m
616
,
m
316
,
m
616
,
m
716
m68,m616,m616,m62,m616,m316,m616,m716
m68,m616,m616,m62,m616,m316,m616,m716
h
18
,
h
116
,
h
116
,
h
12
,
h
18
,
h
28
h18,h116,h116,h12,h18,h28
h18,h116,h116,h12,h18,h28
基础代码
key.m
function g=key(p, n, fs)
t=0 : 1/fs : 3/n;
g=sin(2*pi* fre(p) *t);
fre.m
function f = fre(p)
f=440*2^((p-9)/12);
song.m
clear;
clc;
fs = 44100; % 频率
%% 定义音节
m21 = key(2, 1, fs); % 中音re全音符
% 低音
l12 = key(-12, 2, fs); %低音do二分音符
l22 = key(-10, 2, fs);
l32 = key(-8, 2, fs);
l42 = key(-7, 2, fs);
l52 = key(-5, 2, fs);
l62 = key(-3, 2, fs);
l72 = key(-1, 2, fs);
% 中音
m12 = key(0, 2, fs);
m22 = key(2, 2, fs);
m32 = key(4, 2, fs);
m42 = key(5, 2, fs);
m52 = key(7, 2, fs);
m62 = key(9, 2, fs);
m72 = key(11, 2, fs);
% 高音
h12 = key(12, 2, fs);
h22 = key(14, 2, fs);
h32 = key(16, 2, fs);
h42 = key(17, 2, fs);
h52 = key(19, 2, fs);
h62 = key(21, 2, fs);
h72 = key(23, 2, fs);
% 低音
l14 = key(-12, 4,
l24 = key(-10, 4, fs);
l34 = key(-8, 4, fs);
l44 = key(-7, 4, fs);
l54 = key(-5, 4, fs);
l64 = key(-3, 4, fs);
l74 = key(-1, 4, fs);
% 中音
m14 = key(0, 4, fs);
m24 = key(2, 4, fs);
m34 = key(4, 4, fs);
m44 = key(5, 4, fs);
m54 = key(7, 4, fs);
m64 = key(9, 4, fs);
m74 = key(11, 4, fs);
% 高音
h14 = key(12, 4, fs);
h24 = key(14, 4, fs);
h34 = key(16, 4, fs);
h44 = key(17, 4, fs);
h54 = key(19, 4, fs);
h64 = key(21, 4, fs);
h74 = key(23, 4, fs);
% 低音
l18 = key(-12, 8, fs);
l28 = key(-10, 8, fs);
l38 = key(-8, 8, fs);
l48 = key(-7, 8, fs);
l58 = key(-5, 8, fs);
l68 = key(-3, 8, fs);
l78 = key(-1, 8, fs);
% 中音
m18 = key(0, 8, fs);
m28 = key(2, 8, fs);
m38 = key(4, 8, fs);
m48 = key(5, 8, fs);
m58 = key(7, 8, fs);
m68 = key(9, 8, fs);
m78 = key(11, 8, fs);
% 高音
h18 = key(12, 8, fs);
h28 = key(14, 8, fs);
h38 = key(16, 8, fs);
h48 = key(17, 8, fs);
h58 = key(19, 8, fs);
h68 = key(21, 8, fs);
h78 = key(23, 8, fs);
% 低音
l116 = key(-12, 16, fs);
l216 = key(-10, 16, fs);
l316 = key(-8, 16, fs);
l416 = key(-7, 16, fs);
l516 = key(-5, 16, fs);
l616 = key(-3, 16, fs);
l716 = key(-1, 16, fs);
% 中音
m116 = key(0, 16, fs);
m216 = key(2, 16, fs);
m316 = key(4, 16, fs);
m416 = key(5, 16, fs);
m516 = key(7, 16, fs);
m616 = key(9, 16, fs);
m716 = key(11, 16, fs);
% 高音
h116 = key(12, 16, fs);
h216 = key(14, 16, fs);
h316 = key(16, 16, fs);
h416 = key(17, 16, fs);
h516 = key(19, 16, fs);
h616 = key(21, 16, fs);
h716 = key(23, 16, fs);
% 休止符
o2 = key(-inf, 2, fs);
o4 = key(-inf, 4, fs);
o8 = key(-inf, 8, fs);
part1 = [m68 m616 m616 m62 m616 m316 m616 m716 h18 h116 h116 h12 h18 h28 m52 m44 m34 m21 o4];
sound(part1, fs)