首頁 > 評測 > 讓音樂播放更簡單——Adafruit Music Maker FeatherWing和Audio FX Sound Board評測
讓音樂播放更簡單——Adafruit Music Maker FeatherWing和Audio FX Sound Board評測
- [導讀]
- 本文介紹的兩款模塊都很小巧,但功能強大,一款是高集成度的OGG播放器方案,另一款是大家都熟悉MP3解碼方案。此次評測的是Adafruit的兩塊板子:Audio FX Sound Board & Music Maker FeatherWing w/Amp
單個音符播放和停止:
def note_on( ser,key,chan ):
realkey = (key&0x7F)+40
print("key on: %u "% realkey )
midiNoteOn(ser,chan, realkey, 127);
def note_off( ser,key,chan ):
realkey = (key&0x7F)+40
print("key off: %u "% realkey )
midiNoteOff(ser,chan, realkey, 127);
def note_all_off( ser ):
print("key off" )
midiNoteAllOff(ser,0)
播放樂譜的函數(shù)
def play_tone( ser,tone ):
name = input("Push Enter to play!")
print("Song Start")
score_idx = 0
s = 0
sleeptime0 = 0
sleeptime1 = 0
sleeptime = 0
tickcount = 0
chan = 0
while score_idx < len(tone):
sleeptime0 = (tone[score_idx]+tone[score_idx+1]*256)*8/1000
sleeptime = sleeptime0-sleeptime1
sleeptime1 = sleeptime0
print("sleep: %5.2f"%sleeptime)
time.sleep(sleeptime)
note_all_off(ser)
score_idx = score_idx+2
always = 1
while always == 1:
s = tone[score_idx]
score_idx = score_idx+1
if s== EoS:
print("Song End")
return
else:
note_on(ser,s,chan)
if (s&en)!=0:
if tickcount<7:
tickcount=tickcount+1;
else:
tickcount = 0
if chan==0:
chan=1
else:
chan = 0
break;
測試程序
ser = vs1053_midi.vs1053_midi_setup("com5")
#vs1053_midi.test_play_loop(ser,5)
vs1053_midi.play_tone(ser,vs1053_midi.tone)
程序運行如下:
- 本文系21ic原創(chuàng),未經(jīng)許可禁止轉(zhuǎn)載!
網(wǎng)友評論
- 聯(lián)系人:巧克力娃娃
- 郵箱:board@21ic.com
- 我要投稿
-
歡迎入駐,開放投稿
-
人均百萬?英偉達中國員工收入曝光! 2024-08-29
-
《黑神話:悟空》玩家硬盤升級攻略:提升游戲體驗,暢享3A大作 2024-08-29
-
數(shù)睿數(shù)據(jù)參加《系統(tǒng)與軟件工程 低代碼開發(fā)平臺通用技術要求》國家標準編制 2024-08-29
- NRF52810藍牙數(shù)字耳機找人定制
預算:¥30005天前
- 125KW模塊式PCS軟硬件外包開發(fā)
預算:¥1100000015小時前
- 12V汽車啟動電源項目BMS設計
預算:¥50000023小時前
- 數(shù)據(jù)可視化軟件 開發(fā)
預算:¥5000023小時前
- PLC項目調(diào)試修改
預算:¥100001天前
- 起動電機控制器開發(fā)
預算:¥1100001天前