https://harmonyos.51cto.com/#zz
直接上学习链接:https://mp.weixin.qq.com/s/32KI7H_ASYNOwH-P7FjbRA
https://harmonyos.51cto.com/posts/1511
综合以上2个链接和这个图来改的新年好,(这个图对我帮助很大,我不懂音乐,按照这图改的频率)大家想改其他音乐,建议首先看看开头的2个链接的文章!
感觉还是不太完美。下面吧源码共享出来。大家可以完善完善。。
钢琴上88按键的频率如下表所示:
然后对应到代码中:
- float pitch_names_frequency[] = {
- //0--A0
- 27.50/*A0*/,29.14/*A#0*/,30.87/*B0*/,
- //3--C1
- 32.70/*C1*/,34.65/*C#1*/,36.71/*D1*/,38.89/*D#1*/,41.20/*E1*/,43.65/*F1*/,46.25/*F#1*/,49.00/*G1*/,51.91/*G#1*/,55.00/*A1*/,58.27/*A#1*/,61.74/*B1*/,
- //15--C2
- 65.41/*C2*/,69.30/*C#2*/,73.42/*D2*/,77.78/*D#2*/,82.41/*E2*/,87.31/*F2*/,92.5/*F#2*/,98.00/*G2*/,103.8/*G#2*/,110.0/*A2*/,116.5/*A#2*/,123.5/*B2*/,
- //27--C3
- 130.8/*C3*/,138.6/*C#3*/,146.8/*D3*/,155.6/*D#3*/,164.8/*E3*/,174.6/*F3*/,185.0/*F#3*/,196.0/*G3*/,207.6/*G#3*/,220.0/*A3*/,233.1/*A#3*/,246.9/*B3*/,
- //39--C4
- 261.6/*C4*/,277.2/*C#4*/,293.7/*D4*/,311.1/*D#4*/,329.6/*E4*/,349.2/*F4*/,370.0/*F#4*/,392.0/*G4*/,415.3/*G#4*/,440.0/*A4*/,466.2/*A#4*/,493.9/*B4*/,
- //51--C5
- 523.2/*C5*/,554.4/*C#5*/,587.3/*D5*/, 622.2/*D#5*/,659.3/*E5*/,698.5/*F5*/,740.0/*F#5*/,784.0/*G5*/,830.6/*G#5*/,880.0/*A5*/,932.3/*A#5*/,987.8/*B5*/,
- //63--C6
- 1046/*C6*/,1109/*C#6*/,1175/*D6*/,1245/*D#6*/,1319/*E6*/,1397/*F6*/,1480/*F#6*/,1568/*G6*/,1661/*G#6*/,1760/*A6*/,1865/*A#6*/,1976/*B6*/,
- //75--C7
- 2093/*C7*/,2217/*C#7*/,2349/*D7*/,2489/*D#7*/,2637/*E7*/,2794/*F7*/,2960/*F#7*/,3136/*G7*/,3322/*G#7*/,3520/*A7*/,3729/*A#7*/,3951/*B7*/,
- //87
- 4186/*C8*/
- };
接着找出每个音的频率
- #define L_B 51
- #define N_B 63
- #define H_B 75
- unsigned char ai_ruo_liu_li[] = {
- N_B+0,N_B+0,N_B+0,N_B+7, N_B+4,N_B+4,N_B+4,N_B+0,
- N_B+0,N_B+4,N_B+9,N_B+9, N_B+5,N_B+4,N_B+2,
- N_B+2,N_B+4,N_B+5,N_B+5, N_B+4,N_B+2,N_B+4,N_B+0,
- N_B+0, N_B+4,N_B+2,N_B+0, L_B+11,N_B+2,N_B+0,
- };
然后根据简谱确定时长:
- unsigned char music[]={
- 2,2,4,4, 2,2,4,4,
- 2,2,4,4, 2,2,8,
- 2,2,4,4, 2,2,4,4,
- 2,2,4,4, 2,2,8,
- };
第一句最后一个5.的音,换了好几个频率。总感觉不太对劲
我写的还是不太对,多有不足。请大家指正!
视频稍后传到极客Show
祝鸿蒙越来越好!祝正在学习的我们,学习进步!
视频链接:https://harmonyos.51cto.com/show/2355
https://harmonyos.51cto.com/#zz