731|0

1万

帖子

14

资源

版主

无线 midi 控制 [复制链接]

本帖最后由 dcexpert 于 2021-6-7 22:06 编辑

基于 nRF52840 和circuitpython的无线midi控制。

 

image.png

需要安装的库

  • adafruit_ble
  • adafruit_ble_midi.mpy
  • adafruit_midi


参考代码

import time

# Midi
import adafruit_midi
from adafruit_midi.note_off import NoteOff
from adafruit_midi.note_on import NoteOn

# BLE Midi
import adafruit_ble
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
import adafruit_ble_midi

# Setup BLE Midi
midi_service = adafruit_ble_midi.MIDIService()
advertisement = ProvideServicesAdvertisement(midi_service)
midi = adafruit_midi.MIDI(midi_out=midi_service, out_channel=0)
ble = adafruit_ble.BLERadio()

# Make BLE Device visible
print("Waiting for BLE MIDI connection")
ble.start_advertising(advertisement)
while True:
    # If not connected, don't execute the rest of the code
    while not ble.connected:
        pass

    print("Connected")
    while ble.connected:
        midi.send(NoteOn(70, 127))
        print("NOTE ON")
        time.sleep(1)
        midi.send(NoteOff(0, 0))
        print("NOTE OFF")
        time.sleep(1)

    # If disconnect, wait for reconnection
    print("Disconnected")
    print("Advertising BLE")
    ble.start_advertising(advertisement)

https://www.electromaker.io/project/view/circuit-python-ble-midi-on-windows


回复
您需要登录后才可以回帖 登录 | 注册

查找数据手册?

EEWorld Datasheet 技术支持

最新文章 更多>>
    关闭
    站长推荐上一条 1/8 下一条

    About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

    站点相关: 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

    北京市海淀区知春路23号集成电路设计园量子银座1305 电话:(010)82350740 邮编:100191

    电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2022 EEWORLD.com.cn, Inc. All rights reserved
    快速回复 返回顶部 返回列表