首页 > 评测 > 让音乐播放更简单——Adafruit Music Maker FeatherWing和Audio FX Sound Board评测

让音乐播放更简单——Adafruit Music Maker FeatherWing和Audio FX Sound Board评测

Adafruit    Audio   音频    Feather    MP3    OGG    播放器    解码   
  • 作者:邵楠
  • 来源:21ic
  • [导读]
  • 本文介绍的两款模块都很小巧,但功能强大,一款是高集成度的OGG播放器方案,另一款是大家都熟悉MP3解码方案。此次评测的是Adafruit的两块板子:Audio FX Sound Board & Music Maker FeatherWing w/Amp

播放一串变化的音符(Adafruit演示程序)

def test_play_loop( ser, looptime ):

print("===Music Start===")

while looptime>0:

i=60

while i<69:

midiNoteOn(ser,0, i, 127);

time.sleep(0.1)

midiNoteOff(ser,0, i, 127);

i=i+1

time.sleep(1)

looptime=looptime-1

ser.close()

print("===Music End ===")

以下为实现播放《献给爱丽丝》的代码:

定义音符

A2=0 #220Hz

B2 = 1

H2 = 2

C2 = 3

Cis2= 4

D2 = 5

Dis2 = 6

E2 =7

F2 =8

Fis2 =9

G2 =10

Gis2 = 11

A3 =12 #440Hz

B3 =13

H3 =14

C3 =15

Cis3 = 16

D3 =17

Dis3 = 18

E3 =19

F3 =20

Fis3 =21

G3 =22

Gis3 = 23

A4 =24 #880Hz

B4 =25

H4 =26

C4 =27

Cis4 = 28

D4 =29

Dis4 = 30

E4 =31

F4 =32

Fis4 =33

G4 =34

Gis4 = 35

A5 =36 #1760Hz

B5 =37

H5 =38

C5 =39

Cis5 = 40

D5 =41

Dis5 = 42

E5 =43

F5 =44

Fis5 =45

G5 =46

Gis5 = 47

A6 =48 #3520Hz

B6 =49

H6 =50

C6 =51

Cis6 = 52

D6 =53

Dis6 = 54

E6 =55

EoS = 255 #End of score

en =128 #End of line flag

  • 本文系21ic原创,未经许可禁止转载!

网友评论