首頁 > 評測 > 讓音樂播放更簡單——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 ===")

以下為實現(xiàn)播放《獻給愛麗絲》的代碼:

定義音符

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原創(chuàng),未經(jīng)許可禁止轉(zhuǎn)載!

網(wǎng)友評論