11# MicroPython USB MIDI module
22# MIT license; Copyright (c) 2023 Angus Gratton, Paul Hamshere
33from micropython import const
4- import ustruct
4+ import struct
55
66from .device import USBInterface
77from .utils import endpoint_descriptor , EP_IN_FLAG
@@ -57,7 +57,7 @@ def get_itf_descriptor(self, num_eps, itf_idx, str_idx):
5757 desc , strs = super ().get_itf_descriptor (num_eps , itf_idx , str_idx )
5858
5959 # Append the class-specific AudioControl interface descriptor
60- desc += ustruct .pack (
60+ desc += struct .pack (
6161 "<BBBHHBB" ,
6262 9 , # bLength
6363 0x24 , # bDescriptorType CS_INTERFACE
@@ -124,7 +124,7 @@ def get_itf_descriptor(self, num_eps, itf_idx, str_idx):
124124 _JACK_OUT_DESC_LEN = const (9 )
125125
126126 # Midi Streaming interface descriptor
127- cs_ms_interface = ustruct .pack (
127+ cs_ms_interface = struct .pack (
128128 "<BBBHH" ,
129129 7 , # bLength
130130 0x24 , # bDescriptorType CS_INTERFACE
@@ -135,7 +135,7 @@ def get_itf_descriptor(self, num_eps, itf_idx, str_idx):
135135 )
136136
137137 def jack_in_desc (bJackType , bJackID ):
138- return ustruct .pack (
138+ return struct .pack (
139139 "<BBBBBB" ,
140140 _JACK_IN_DESC_LEN , # bLength
141141 0x24 , # bDescriptorType CS_INTERFACE
@@ -146,7 +146,7 @@ def jack_in_desc(bJackType, bJackID):
146146 )
147147
148148 def jack_out_desc (bJackType , bJackID , bSourceId , bSourcePin ):
149- return ustruct .pack (
149+ return struct .pack (
150150 "<BBBBBBBBB" ,
151151 _JACK_OUT_DESC_LEN , # bLength
152152 0x24 , # bDescriptorType CS_INTERFACE
@@ -250,7 +250,7 @@ def get_endpoint_descriptors(self, ep_addr, str_idx):
250250
251251 # rx side, USB "in" endpoint and embedded MIDI IN Jacks
252252 e_out = endpoint_descriptor (self .ep_in , "bulk" , 64 , 0 )
253- cs_out = ustruct .pack (
253+ cs_out = struct .pack (
254254 "<BBBB" + "B" * self ._num_rx ,
255255 4 + self ._num_rx , # bLength
256256 0x25 , # bDescriptorType CS_ENDPOINT
@@ -261,7 +261,7 @@ def get_endpoint_descriptors(self, ep_addr, str_idx):
261261
262262 # tx side, USB "out" endpoint and embedded MIDI OUT jacks
263263 e_in = endpoint_descriptor (self .ep_out , "bulk" , 64 , 0 )
264- cs_in = ustruct .pack (
264+ cs_in = struct .pack (
265265 "<BBBB" + "B" * self ._num_tx ,
266266 4 + self ._num_tx , # bLength
267267 0x25 , # bDescriptorType CS_ENDPOINT
@@ -282,11 +282,11 @@ def __init__(self):
282282 super ().__init__ ()
283283
284284 def note_on (self , channel , pitch , vel ):
285- obuf = ustruct .pack ("<BBBB" , 0x09 , 0x90 | channel , pitch , vel )
285+ obuf = struct .pack ("<BBBB" , 0x09 , 0x90 | channel , pitch , vel )
286286 super ().send_data (obuf )
287287
288288 def note_off (self , channel , pitch , vel ):
289- obuf = ustruct .pack ("<BBBB" , 0x08 , 0x80 | channel , pitch , vel )
289+ obuf = struct .pack ("<BBBB" , 0x08 , 0x80 | channel , pitch , vel )
290290 super ().send_data (obuf )
291291
292292 def start (self ):
0 commit comments