mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
rename midi write()/read() to stream_write() stream_read()
also add deprecated for warning and rename hint
This commit is contained in:
parent
99b78e62f2
commit
da59c4ad44
@ -186,10 +186,12 @@ void midi_task(void)
|
||||
if (previous < 0) previous = sizeof(note_sequence) - 1;
|
||||
|
||||
// Send Note On for current position at full velocity (127) on channel 1.
|
||||
tud_midi_write24(cable_num, 0x90 | channel, note_sequence[note_pos], 127);
|
||||
uint8_t note_on[3] = { 0x90 | channel, note_sequence[note_pos], 127 };
|
||||
tud_midi_stream_write(cable_num, note_on, 3);
|
||||
|
||||
// Send Note Off for previous note.
|
||||
tud_midi_write24(cable_num, 0x80 | channel, note_sequence[previous], 0);
|
||||
uint8_t note_off[3] = { 0x80 | channel, note_sequence[previous], 0};
|
||||
tud_midi_stream_write(cable_num, note_off, 3);
|
||||
|
||||
// Increment position
|
||||
note_pos++;
|
||||
|
@ -147,11 +147,11 @@ void midi_task(void)
|
||||
|
||||
// Send Note On for current position at full velocity (127) on channel 1.
|
||||
uint8_t note_on[3] = { 0x90 | channel, note_sequence[note_pos], 127 };
|
||||
tud_midi_write(cable_num, note_on, 3);
|
||||
tud_midi_stream_write(cable_num, note_on, 3);
|
||||
|
||||
// Send Note Off for previous note.
|
||||
uint8_t note_off[3] = { 0x80 | channel, note_sequence[previous], 0};
|
||||
tud_midi_write(cable_num, note_off, 3);
|
||||
tud_midi_stream_write(cable_num, note_off, 3);
|
||||
|
||||
// Increment position
|
||||
note_pos++;
|
||||
|
@ -127,7 +127,7 @@ uint32_t tud_midi_n_available(uint8_t itf, uint8_t cable_num)
|
||||
return tu_fifo_count(&_midid_itf[itf].rx_ff);
|
||||
}
|
||||
|
||||
uint32_t tud_midi_n_read(uint8_t itf, uint8_t cable_num, void* buffer, uint32_t bufsize)
|
||||
uint32_t tud_midi_n_stream_read(uint8_t itf, uint8_t cable_num, void* buffer, uint32_t bufsize)
|
||||
{
|
||||
(void) cable_num;
|
||||
midid_interface_t* midi = &_midid_itf[itf];
|
||||
@ -220,7 +220,7 @@ static uint32_t write_flush(midid_interface_t* midi)
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t tud_midi_n_write(uint8_t itf, uint8_t cable_num, uint8_t const* buffer, uint32_t bufsize)
|
||||
uint32_t tud_midi_n_stream_write(uint8_t itf, uint8_t cable_num, uint8_t const* buffer, uint32_t bufsize)
|
||||
{
|
||||
midid_interface_t* midi = &_midid_itf[itf];
|
||||
TU_VERIFY(midi->itf_num, 0);
|
||||
|
@ -61,36 +61,51 @@
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Check if midi interface is mounted
|
||||
bool tud_midi_n_mounted (uint8_t itf);
|
||||
bool tud_midi_n_mounted (uint8_t itf);
|
||||
|
||||
// Get the number of bytes available for reading
|
||||
uint32_t tud_midi_n_available (uint8_t itf, uint8_t cable_num);
|
||||
uint32_t tud_midi_n_available (uint8_t itf, uint8_t cable_num);
|
||||
|
||||
// Read byte stream (legacy)
|
||||
uint32_t tud_midi_n_read (uint8_t itf, uint8_t cable_num, void* buffer, uint32_t bufsize);
|
||||
// Read byte stream (legacy)
|
||||
uint32_t tud_midi_n_stream_read (uint8_t itf, uint8_t cable_num, void* buffer, uint32_t bufsize);
|
||||
|
||||
// Write byte Stream (legacy)
|
||||
uint32_t tud_midi_n_write (uint8_t itf, uint8_t cable_num, uint8_t const* buffer, uint32_t bufsize);
|
||||
// Write byte Stream (legacy)
|
||||
uint32_t tud_midi_n_stream_write (uint8_t itf, uint8_t cable_num, uint8_t const* buffer, uint32_t bufsize);
|
||||
|
||||
// Read event packet (4 bytes)
|
||||
bool tud_midi_n_packet_read (uint8_t itf, uint8_t packet[4]);
|
||||
// Read event packet (4 bytes)
|
||||
bool tud_midi_n_packet_read (uint8_t itf, uint8_t packet[4]);
|
||||
|
||||
// Write event packet (4 bytes)
|
||||
bool tud_midi_n_packet_write (uint8_t itf, uint8_t const packet[4]);
|
||||
// Write event packet (4 bytes)
|
||||
bool tud_midi_n_packet_write (uint8_t itf, uint8_t const packet[4]);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Application API (Single Interface)
|
||||
//--------------------------------------------------------------------+
|
||||
static inline bool tud_midi_mounted (void);
|
||||
static inline uint32_t tud_midi_available (void);
|
||||
static inline bool tud_midi_mounted (void);
|
||||
static inline uint32_t tud_midi_available (void);
|
||||
|
||||
static inline uint32_t tud_midi_read (void* buffer, uint32_t bufsize);
|
||||
static inline uint32_t tud_midi_write (uint8_t cable_num, uint8_t const* buffer, uint32_t bufsize);
|
||||
static inline uint32_t tud_midi_stream_read (void* buffer, uint32_t bufsize);
|
||||
static inline uint32_t tud_midi_stream_write (uint8_t cable_num, uint8_t const* buffer, uint32_t bufsize);
|
||||
|
||||
static inline bool tud_midi_packet_read (uint8_t packet[4]);
|
||||
static inline bool tud_midi_packet_write(uint8_t const packet[4]);
|
||||
static inline bool tud_midi_packet_read (uint8_t packet[4]);
|
||||
static inline bool tud_midi_packet_write (uint8_t const packet[4]);
|
||||
|
||||
//------------- Deprecated API name -------------//
|
||||
// TODO remove after 0.10.0 release
|
||||
|
||||
TU_ATTR_DEPRECATED("tud_midi_read() is renamed to tud_midi_stream_read()")
|
||||
static inline uint32_t tud_midi_read (void* buffer, uint32_t bufsize)
|
||||
{
|
||||
return tud_midi_stream_read(buffer, bufsize);
|
||||
}
|
||||
|
||||
TU_ATTR_DEPRECATED("tud_midi_write() is renamed to tud_midi_stream_write()")
|
||||
static inline uint32_t tud_midi_write(uint8_t cable_num, uint8_t const* buffer, uint32_t bufsize)
|
||||
{
|
||||
return tud_midi_stream_write(cable_num, buffer, bufsize);
|
||||
}
|
||||
|
||||
|
||||
TU_ATTR_DEPRECATED("tud_midi_send() is renamed to tud_midi_packet_write()")
|
||||
static inline bool tud_midi_send(uint8_t packet[4])
|
||||
{
|
||||
@ -122,14 +137,14 @@ static inline uint32_t tud_midi_available (void)
|
||||
return tud_midi_n_available(0, 0);
|
||||
}
|
||||
|
||||
static inline uint32_t tud_midi_read (void* buffer, uint32_t bufsize)
|
||||
static inline uint32_t tud_midi_stream_read (void* buffer, uint32_t bufsize)
|
||||
{
|
||||
return tud_midi_n_read(0, 0, buffer, bufsize);
|
||||
return tud_midi_n_stream_read(0, 0, buffer, bufsize);
|
||||
}
|
||||
|
||||
static inline uint32_t tud_midi_write (uint8_t cable_num, uint8_t const* buffer, uint32_t bufsize)
|
||||
static inline uint32_t tud_midi_stream_write (uint8_t cable_num, uint8_t const* buffer, uint32_t bufsize)
|
||||
{
|
||||
return tud_midi_n_write(0, cable_num, buffer, bufsize);
|
||||
return tud_midi_n_stream_write(0, cable_num, buffer, bufsize);
|
||||
}
|
||||
|
||||
static inline bool tud_midi_packet_read (uint8_t packet[4])
|
||||
|
Loading…
x
Reference in New Issue
Block a user