首页 > 评测 > 让音乐播放更简单——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)
播放乐谱的函数
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原创,未经许可禁止转载!
网友评论
- 联系人:巧克力娃娃
- 邮箱:board@21ic.com
- 我要投稿
-
欢迎入驻,开放投稿
-
人均百万?英伟达中国员工收入曝光! 2024-08-29
-
《黑神话:悟空》玩家硬盘升级攻略:提升游戏体验,畅享3A大作 2024-08-29
-
数睿数据参加《系统与软件工程 低代码开发平台通用技术要求》国家标准编制 2024-08-29
- NRF52810蓝牙数字耳机找人定制
预算:¥30005天前
- 125KW模块式PCS软硬件外包开发
预算:¥1100000015小时前
- 12V汽车启动电源项目BMS设计
预算:¥50000023小时前
- 数据可视化软件 开发
预算:¥5000023小时前
- PLC项目调试修改
预算:¥100001天前
- 起动电机控制器开发
预算:¥1100001天前