2021-05-10 12:37:29 +00:00
|
|
|
#ifndef cwIoMidiRecordPlay_h
|
|
|
|
#define cwIoMidiRecordPlay_h
|
|
|
|
|
|
|
|
|
|
|
|
namespace cw
|
|
|
|
{
|
|
|
|
namespace midi_record_play
|
|
|
|
{
|
|
|
|
typedef handle< struct midi_record_play_str > handle_t;
|
2021-11-01 14:13:48 +00:00
|
|
|
|
|
|
|
typedef struct midi_msg_str
|
|
|
|
{
|
|
|
|
unsigned id;
|
|
|
|
time::spec_t timestamp;
|
2022-05-06 20:03:43 +00:00
|
|
|
unsigned loc;
|
2021-11-01 14:13:48 +00:00
|
|
|
uint8_t ch;
|
|
|
|
uint8_t status;
|
|
|
|
uint8_t d0;
|
2022-05-06 20:03:43 +00:00
|
|
|
uint8_t d1;
|
2021-11-01 14:13:48 +00:00
|
|
|
} midi_msg_t;
|
|
|
|
|
2022-05-21 13:26:23 +00:00
|
|
|
enum {
|
|
|
|
kMidiEventActionId,
|
|
|
|
kPlayerStoppedActionId
|
|
|
|
};
|
2021-11-01 14:13:48 +00:00
|
|
|
|
2022-05-21 13:26:23 +00:00
|
|
|
typedef void (*event_callback_t)( void* arg, unsigned actionId, unsigned id, const time::spec_t timestamp, unsigned loc, uint8_t ch, uint8_t status, uint8_t d0, uint8_t d1 );
|
2021-05-10 12:37:29 +00:00
|
|
|
|
2023-03-17 22:16:25 +00:00
|
|
|
enum
|
|
|
|
{
|
2023-03-20 12:54:11 +00:00
|
|
|
kSampler_MRP_DevIdx = 0,
|
|
|
|
kPiano_MRP_DevIdx = 1
|
2023-03-17 22:16:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-05-10 12:37:29 +00:00
|
|
|
|
2023-03-20 12:54:11 +00:00
|
|
|
rc_t create( handle_t& hRef,
|
|
|
|
io::handle_t ioH,
|
|
|
|
const object_t& cfg,
|
|
|
|
const char* velTableFname=nullptr,
|
|
|
|
event_callback_t cb=nullptr,
|
|
|
|
void* cb_arg=nullptr );
|
|
|
|
|
2021-11-01 14:13:48 +00:00
|
|
|
rc_t destroy( handle_t& hRef );
|
|
|
|
|
|
|
|
// Set rewindFl to play from start, otherwise play from current output location.
|
2021-11-14 16:52:24 +00:00
|
|
|
rc_t start( handle_t h, bool rewindFl=true, const time::spec_t* end_play_event_timestamp=nullptr );
|
2021-05-10 12:37:29 +00:00
|
|
|
rc_t stop( handle_t h );
|
|
|
|
bool is_started( handle_t h );
|
|
|
|
|
|
|
|
rc_t rewind( handle_t h );
|
|
|
|
rc_t clear( handle_t h );
|
|
|
|
rc_t set_record_state( handle_t h, bool record_fl );
|
|
|
|
bool record_state( handle_t h );
|
|
|
|
|
2022-11-11 19:03:22 +00:00
|
|
|
rc_t set_mute_state( handle_t h, bool record_fl );
|
|
|
|
bool mute_state( handle_t h );
|
|
|
|
|
2021-05-10 12:37:29 +00:00
|
|
|
rc_t set_thru_state( handle_t h, bool record_thru );
|
|
|
|
bool thru_state( handle_t h );
|
|
|
|
|
|
|
|
rc_t save( handle_t h, const char* fn );
|
2022-03-20 14:27:46 +00:00
|
|
|
rc_t save_csv( handle_t h, const char* fn );
|
2023-05-25 20:02:51 +00:00
|
|
|
rc_t save_synced_csv( handle_t h, const char* fn, const score_follower::ssf_note_on_t* syncA, unsigned syncN );
|
|
|
|
|
2023-05-21 16:40:23 +00:00
|
|
|
rc_t write_svg( handle_t h, const char* fn );
|
2022-03-20 14:27:46 +00:00
|
|
|
|
2021-05-10 12:37:29 +00:00
|
|
|
rc_t open( handle_t h, const char* fn );
|
2022-01-22 14:42:21 +00:00
|
|
|
|
|
|
|
// Load the playback buffer with messages to output.
|
2021-11-01 14:13:48 +00:00
|
|
|
rc_t load( handle_t h, const midi_msg_t* msg, unsigned msg_count );
|
|
|
|
|
|
|
|
rc_t seek( handle_t h, time::spec_t timestamp );
|
2023-02-26 18:40:49 +00:00
|
|
|
|
|
|
|
unsigned elapsed_micros( handle_t h );
|
2022-05-14 14:22:29 +00:00
|
|
|
|
|
|
|
unsigned event_count( handle_t h ); // Current count of stored messages.
|
|
|
|
unsigned event_index( handle_t h ); // record mode: index of next event to store play mode:index of next event to play
|
|
|
|
unsigned event_loc( handle_t h ); // play mode: loc of next event to play record mode:kInvalidId
|
2023-05-25 20:02:51 +00:00
|
|
|
|
|
|
|
unsigned last_store_index( handle_t h );
|
|
|
|
|
2021-11-01 14:13:48 +00:00
|
|
|
|
2021-05-10 12:37:29 +00:00
|
|
|
rc_t exec( handle_t h, const io::msg_t& msg );
|
2021-08-15 20:02:45 +00:00
|
|
|
|
2023-06-27 21:44:23 +00:00
|
|
|
unsigned label_to_device_index( handle_t h, const char* devLabel );
|
|
|
|
const char* device_index_to_label( handle_t h, unsigned devIdx );
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-22 14:42:21 +00:00
|
|
|
unsigned device_count( handle_t h );
|
|
|
|
bool is_device_enabled( handle_t h, unsigned devIdx );
|
|
|
|
void enable_device( handle_t h, unsigned devIdx, bool enableFl );
|
2022-10-26 12:47:54 +00:00
|
|
|
rc_t send_midi_msg( handle_t h, unsigned devIdx, uint8_t ch, uint8_t status, uint8_t d0, uint8_t d1 );
|
2022-01-22 14:42:21 +00:00
|
|
|
|
2022-03-20 14:27:46 +00:00
|
|
|
void half_pedal_params( handle_t h, unsigned noteDelayMs, unsigned pitch, unsigned vel, unsigned pedal_vel, unsigned noteDurMs, unsigned downDelayMs );
|
|
|
|
|
2021-11-01 14:13:48 +00:00
|
|
|
// Convert an audio-midi file to a MIDI file
|
2021-08-15 20:02:45 +00:00
|
|
|
rc_t am_to_midi_file( const char* am_filename, const char* midi_filename );
|
|
|
|
rc_t am_to_midi_dir( const char* inDir );
|
|
|
|
rc_t am_to_midi_file( const object_t* cfg );
|
2022-10-15 19:07:06 +00:00
|
|
|
|
2023-03-17 22:16:25 +00:00
|
|
|
unsigned dev_count( handle_t h );
|
2023-06-27 21:44:23 +00:00
|
|
|
|
|
|
|
// Set devIdx to kInvalididx to disable vel tables on all devices
|
|
|
|
rc_t vel_table_disable( handle_t h, unsigned devIdx=kInvalidIdx );
|
2023-03-17 22:16:25 +00:00
|
|
|
|
|
|
|
unsigned vel_table_count( handle_t h, unsigned devIdx );
|
|
|
|
const uint8_t* vel_table( handle_t h, unsigned devIdx );
|
|
|
|
rc_t vel_table_set( handle_t h, unsigned devIdx, const uint8_t* tbl, unsigned tblN );
|
|
|
|
|
2022-10-15 19:07:06 +00:00
|
|
|
void report( handle_t h );
|
2023-03-17 22:16:25 +00:00
|
|
|
|
|
|
|
|
2021-05-10 12:37:29 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|