2024-12-01 19:35:24 +00:00
|
|
|
//| Copyright: (C) 2020-2024 Kevin Larke <contact AT larke DOT org>
|
|
|
|
//| License: GNU GPL version 3.0 or above. See the accompanying LICENSE file.
|
2020-01-27 22:53:44 +00:00
|
|
|
#ifndef cwIo_h
|
|
|
|
#define cwIo_h
|
|
|
|
|
2020-03-23 17:14:42 +00:00
|
|
|
#include "cwTime.h"
|
|
|
|
#include "cwMidiDecls.h"
|
|
|
|
#include "cwSerialPortDecls.h"
|
|
|
|
#include "cwAudioDeviceDecls.h"
|
|
|
|
#include "cwSocketDecls.h"
|
2021-01-20 18:12:35 +00:00
|
|
|
#include "cwUiDecls.h"
|
2020-03-23 17:14:42 +00:00
|
|
|
|
2020-01-27 22:53:44 +00:00
|
|
|
namespace cw
|
|
|
|
{
|
|
|
|
namespace io
|
|
|
|
{
|
|
|
|
|
|
|
|
typedef handle<struct io_str> handle_t;
|
|
|
|
|
2021-01-22 14:49:57 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
kDisableFl = 0x00,
|
|
|
|
kEnableFl = 0x01,
|
|
|
|
kInFl = 0x02,
|
|
|
|
kOutFl = 0x04,
|
|
|
|
|
|
|
|
kMeterFl = 0x08
|
|
|
|
};
|
|
|
|
|
2020-01-27 22:53:44 +00:00
|
|
|
enum
|
|
|
|
{
|
2022-12-13 18:27:32 +00:00
|
|
|
kThreadTId,
|
2021-04-10 17:37:07 +00:00
|
|
|
kTimerTId,
|
|
|
|
kSerialTId,
|
|
|
|
kMidiTId,
|
|
|
|
kAudioTId,
|
|
|
|
kAudioMeterTId,
|
|
|
|
kSockTId,
|
|
|
|
kWebSockTId,
|
2022-12-12 17:20:59 +00:00
|
|
|
kUiTId,
|
2022-12-13 18:27:32 +00:00
|
|
|
kExecTId // callback from io::exec() which is inside the application main loop thread
|
2020-01-27 22:53:44 +00:00
|
|
|
};
|
|
|
|
|
2022-06-12 20:50:01 +00:00
|
|
|
typedef struct thread_msg_str
|
|
|
|
{
|
|
|
|
unsigned id;
|
|
|
|
void* arg;
|
|
|
|
} thread_msg_t;
|
|
|
|
|
2021-04-10 17:37:07 +00:00
|
|
|
typedef struct timer_msg_str
|
|
|
|
{
|
2023-05-09 11:29:43 +00:00
|
|
|
unsigned id; // timer id (as set in create)
|
|
|
|
unsigned index; // timer index as used by timer accessor functions
|
2021-04-10 17:37:07 +00:00
|
|
|
} timer_msg_t;
|
|
|
|
|
2020-01-27 22:53:44 +00:00
|
|
|
typedef struct serial_msg_str
|
|
|
|
{
|
2021-10-11 15:53:36 +00:00
|
|
|
const char* label; // label from cfg
|
|
|
|
unsigned userId; // defaults to index into internal serial cfg. array - reset vial serialDeviceSetId().
|
2020-01-27 22:53:44 +00:00
|
|
|
const void* dataA;
|
|
|
|
unsigned byteN;
|
|
|
|
} serial_msg_t;
|
|
|
|
|
|
|
|
typedef struct midi_msg_str
|
|
|
|
{
|
2021-04-10 17:37:07 +00:00
|
|
|
const midi::packet_t* pkt;
|
2020-01-27 22:53:44 +00:00
|
|
|
} midi_msg_t;
|
|
|
|
|
2020-03-23 17:14:42 +00:00
|
|
|
typedef audio::device::sample_t sample_t;
|
|
|
|
|
2021-01-20 18:12:35 +00:00
|
|
|
typedef struct audio_group_dev_str
|
|
|
|
{
|
2021-01-31 16:14:22 +00:00
|
|
|
const char* label; // User supplied label
|
|
|
|
unsigned userId; // User supplied id
|
2021-01-22 14:49:57 +00:00
|
|
|
const char* devName; // Audio device name
|
2021-01-20 18:12:35 +00:00
|
|
|
unsigned devIdx; // Audio device index
|
2021-01-22 14:49:57 +00:00
|
|
|
unsigned flags; // kInFl | kOutFl | kMeterFl
|
|
|
|
unsigned chIdx; // First channel of this device in i/oBufArray
|
|
|
|
unsigned chCnt; // Count of audio channels on this device
|
2021-01-20 18:12:35 +00:00
|
|
|
unsigned cbCnt; // Count of device driver callbacks
|
2021-01-22 14:49:57 +00:00
|
|
|
sample_t* meterA; // Meter values for this device.
|
|
|
|
|
2021-01-31 16:14:22 +00:00
|
|
|
std::atomic_uint readyCnt;// Used internally
|
2021-01-22 14:49:57 +00:00
|
|
|
|
2021-01-20 18:12:35 +00:00
|
|
|
struct audio_group_dev_str* link; //
|
|
|
|
} audio_group_dev_t;
|
|
|
|
|
2020-02-29 05:12:57 +00:00
|
|
|
typedef struct audio_msg_str
|
|
|
|
{
|
2021-01-22 14:49:57 +00:00
|
|
|
const char* label; // User provided label
|
2021-01-31 16:14:22 +00:00
|
|
|
unsigned groupIndex; // System supplied group index
|
|
|
|
unsigned userId; // User id
|
2021-01-20 18:12:35 +00:00
|
|
|
double srate; // Group sample rate.
|
|
|
|
unsigned dspFrameCnt; // Count of samples in each buffer pointed to by iBufArray[] and oBufArray[]
|
2020-03-23 17:14:42 +00:00
|
|
|
|
2021-12-11 20:14:27 +00:00
|
|
|
sample_t** iBufArray; // iBufArray[iBufChCnt] Array ptrs to buffers of size dspFrameCnt
|
2021-01-20 18:12:35 +00:00
|
|
|
unsigned iBufChCnt; // Count of elements in iBufArray[]
|
|
|
|
time::spec_t* iTimeStampPtr; //
|
|
|
|
audio_group_dev_t* iDevL; // Linked list of input devices which map directly to channels in iBufArray[]
|
|
|
|
|
2021-12-11 20:14:27 +00:00
|
|
|
sample_t** oBufArray; // oBufArray[oBufChCnt] Array of ptrs to buffers of size dspFrameCnt
|
2021-01-20 18:12:35 +00:00
|
|
|
unsigned oBufChCnt; //
|
|
|
|
time::spec_t* oTimeStampPtr; //
|
|
|
|
audio_group_dev_t* oDevL; // Linked list of output devices which map directly to channels in oBufArray[]
|
2020-03-23 17:14:42 +00:00
|
|
|
|
2020-02-29 05:12:57 +00:00
|
|
|
} audio_msg_t;
|
|
|
|
|
2020-03-23 17:14:42 +00:00
|
|
|
typedef struct socket_msg_str
|
|
|
|
{
|
2021-01-20 18:12:35 +00:00
|
|
|
sock::cbOpId_t cbId;
|
2021-01-31 16:14:22 +00:00
|
|
|
unsigned sockIdx;
|
2020-03-23 17:14:42 +00:00
|
|
|
unsigned userId;
|
|
|
|
unsigned connId;
|
|
|
|
const void* byteA;
|
|
|
|
unsigned byteN;
|
|
|
|
const struct sockaddr_in* srcAddr;
|
|
|
|
} socket_msg_t;
|
|
|
|
|
2021-01-20 18:12:35 +00:00
|
|
|
typedef struct ui_msg_str
|
|
|
|
{
|
|
|
|
ui::opId_t opId;
|
|
|
|
unsigned wsSessId;
|
|
|
|
unsigned parentAppId;
|
|
|
|
unsigned uuId;
|
|
|
|
unsigned appId;
|
2021-11-03 15:09:07 +00:00
|
|
|
unsigned chanId;
|
2021-01-20 18:12:35 +00:00
|
|
|
const ui::value_t* value;
|
|
|
|
} ui_msg_t;
|
|
|
|
|
2022-12-12 17:20:59 +00:00
|
|
|
typedef struct exec_msg_str
|
|
|
|
{
|
|
|
|
void* execArg;
|
|
|
|
} exec_msg_t;
|
|
|
|
|
2020-01-27 22:53:44 +00:00
|
|
|
typedef struct msg_str
|
|
|
|
{
|
|
|
|
unsigned tid;
|
2022-12-12 17:20:59 +00:00
|
|
|
bool asyncFl;
|
2020-01-27 22:53:44 +00:00
|
|
|
union
|
|
|
|
{
|
2022-06-12 20:50:01 +00:00
|
|
|
thread_msg_t* thread;
|
2021-04-10 17:37:07 +00:00
|
|
|
timer_msg_t* timer;
|
2021-01-22 14:49:57 +00:00
|
|
|
serial_msg_t* serial;
|
|
|
|
midi_msg_t* midi;
|
|
|
|
audio_msg_t* audio;
|
|
|
|
audio_group_dev_t* audioGroupDev; // audioMeterTId
|
|
|
|
socket_msg_t* sock;
|
|
|
|
ui_msg_t ui;
|
2022-12-12 17:20:59 +00:00
|
|
|
exec_msg_t exec;
|
2020-01-27 22:53:44 +00:00
|
|
|
} u;
|
|
|
|
} msg_t;
|
|
|
|
|
2021-01-20 18:12:35 +00:00
|
|
|
typedef rc_t (*cbFunc_t)( void* arg, const msg_t* m );
|
2020-01-27 22:53:44 +00:00
|
|
|
|
|
|
|
rc_t create(
|
2021-01-20 18:12:35 +00:00
|
|
|
handle_t& h,
|
|
|
|
const object_t* cfg, // configuration object
|
|
|
|
cbFunc_t cbFunc,
|
|
|
|
void* cbArg,
|
|
|
|
const ui::appIdMap_t* mapA = nullptr,
|
|
|
|
unsigned mapN = 0,
|
|
|
|
const char* cfgLabel = "io" );
|
2020-01-27 22:53:44 +00:00
|
|
|
|
|
|
|
rc_t destroy( handle_t& h );
|
|
|
|
|
|
|
|
rc_t start( handle_t h );
|
|
|
|
rc_t pause( handle_t h );
|
2021-01-20 18:12:35 +00:00
|
|
|
rc_t stop( handle_t h );
|
2024-03-28 23:48:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Note that this call blocks on the the UI websocket handle for up to 'timeOutMs'.
|
2024-01-06 13:43:42 +00:00
|
|
|
// See ui:ws:exec().
|
2024-03-28 23:48:46 +00:00
|
|
|
rc_t exec( handle_t h, unsigned timeOutMs, void* execCbArg=nullptr );
|
2024-01-06 13:43:42 +00:00
|
|
|
|
2021-01-20 18:12:35 +00:00
|
|
|
bool isShuttingDown( handle_t h );
|
2021-01-31 16:14:22 +00:00
|
|
|
void report( handle_t h );
|
2024-04-06 20:06:17 +00:00
|
|
|
void hardwareReport( handle_t h );
|
2023-02-15 01:55:03 +00:00
|
|
|
void realTimeReport( handle_t h );
|
2024-04-06 20:06:17 +00:00
|
|
|
|
2021-01-20 18:12:35 +00:00
|
|
|
|
2022-06-12 20:50:01 +00:00
|
|
|
//----------------------------------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Thread
|
|
|
|
//
|
2024-02-18 13:37:33 +00:00
|
|
|
rc_t threadCreate( handle_t h, unsigned id, bool asyncFl, void* arg, const char* label );
|
2021-04-10 17:37:07 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Timer
|
|
|
|
//
|
2023-06-27 21:24:12 +00:00
|
|
|
|
2022-12-12 17:20:59 +00:00
|
|
|
rc_t timerCreate( handle_t h, const char* label, unsigned id, unsigned periodMicroSec, bool asyncFl );
|
2021-04-10 17:37:07 +00:00
|
|
|
rc_t timerDestroy( handle_t h, unsigned timerIdx );
|
|
|
|
|
|
|
|
unsigned timerCount( handle_t h );
|
|
|
|
unsigned timerLabelToIndex( handle_t h, const char* label );
|
|
|
|
unsigned timerIdToIndex( handle_t h, unsigned timerId );
|
|
|
|
const char* timerLabel( handle_t h, unsigned timerIdx );
|
|
|
|
unsigned timerId( handle_t h, unsigned timerIdx );
|
|
|
|
unsigned timerPeriodMicroSec( handle_t h, unsigned timerIdx );
|
|
|
|
rc_t timerSetPeriodMicroSec( handle_t h, unsigned timerIdx, unsigned periodMicroSec );
|
2023-06-27 21:24:12 +00:00
|
|
|
|
|
|
|
// Set an explicit next time to trigger. The 'time' argument will over ride the next periodic callback.
|
|
|
|
// Note that the most reliable way to use this function is by calling it in the timer callback
|
|
|
|
// so that it will deterine the time of the following callback.
|
|
|
|
rc_t timerSetNextTime( handle_t h, unsigned timerIdx, const time::spec_t& time );
|
|
|
|
|
2021-04-10 17:37:07 +00:00
|
|
|
rc_t timerStart( handle_t h, unsigned timerIdx );
|
|
|
|
rc_t timerStop( handle_t h, unsigned timerIdx );
|
|
|
|
|
2021-01-20 18:12:35 +00:00
|
|
|
//----------------------------------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Serial
|
|
|
|
//
|
2020-01-27 22:53:44 +00:00
|
|
|
|
2024-06-10 20:34:52 +00:00
|
|
|
bool serialIsEnabled( handle_t h );
|
2020-01-27 22:53:44 +00:00
|
|
|
unsigned serialDeviceCount( handle_t h );
|
2021-01-31 16:14:22 +00:00
|
|
|
unsigned serialDeviceIndex( handle_t h, const char* label );
|
2021-10-11 15:53:36 +00:00
|
|
|
const char* serialDeviceLabel( handle_t h, unsigned devIdx );
|
2021-12-11 20:14:27 +00:00
|
|
|
unsigned serialDeviceId( handle_t h, unsigned devIdx ); // defaults to device index
|
2021-10-11 15:53:36 +00:00
|
|
|
void serialDeviceSetId( handle_t h, unsigned devIdx, unsigned id );
|
|
|
|
|
2020-01-27 22:53:44 +00:00
|
|
|
rc_t serialDeviceSend( handle_t h, unsigned devIdx, const void* byteA, unsigned byteN );
|
|
|
|
|
2021-01-20 18:12:35 +00:00
|
|
|
//----------------------------------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// MIDI
|
|
|
|
//
|
2024-06-10 20:34:52 +00:00
|
|
|
|
|
|
|
bool midiIsEnabled( handle_t h );
|
2020-01-27 22:53:44 +00:00
|
|
|
unsigned midiDeviceCount( handle_t h );
|
|
|
|
const char* midiDeviceName( handle_t h, unsigned devIdx );
|
|
|
|
unsigned midiDeviceIndex( handle_t h, const char* devName );
|
|
|
|
unsigned midiDevicePortCount( handle_t h, unsigned devIdx, bool inputFl );
|
|
|
|
const char* midiDevicePortName( handle_t h, unsigned devIdx, bool inputFl, unsigned portIdx );
|
|
|
|
unsigned midiDevicePortIndex( handle_t h, unsigned devIdx, bool inputFl, const char* portName );
|
2020-03-23 17:14:42 +00:00
|
|
|
rc_t midiDeviceSend( handle_t h, unsigned devIdx, unsigned portIdx, uint8_t status, uint8_t d0, uint8_t d1 );
|
2024-04-06 20:06:17 +00:00
|
|
|
|
|
|
|
unsigned midiDeviceMaxBufferMsgCount( handle_t h );
|
|
|
|
const midi::ch_msg_t* midiDeviceBuffer( handle_t h, unsigned& msgCntRef );
|
|
|
|
rc_t midiDeviceClearBuffer( handle_t h, unsigned msgCnt );
|
|
|
|
|
2024-02-21 12:50:52 +00:00
|
|
|
|
|
|
|
rc_t midiOpenMidiFile( handle_t h, unsigned devIdx, unsigned portIdx, const char* fname );
|
|
|
|
rc_t midiLoadMsgPacket( handle_t h, const midi::packet_t& pkt ); // Note: Set devIdx/portIdx via pkt.devIdx/pkt.portIdx
|
|
|
|
unsigned midiMsgCount( handle_t h, unsigned devIdx, unsigned portIdx );
|
|
|
|
rc_t midiSeekToMsg( handle_t h, unsigned devIdx, unsigned portIdx, unsigned msgIdx );
|
|
|
|
rc_t midiSetEndMsg( handle_t h, unsigned devIdx, unsigned portidx, unsigned msgIdx );
|
|
|
|
rc_t midiFileStart( handle_t h );
|
|
|
|
rc_t midiFileStop( handle_t h );
|
|
|
|
rc_t midiFilePause( handle_t h, bool pauseFl );
|
2020-03-23 17:14:42 +00:00
|
|
|
|
2020-02-13 16:30:46 +00:00
|
|
|
|
2021-01-20 18:12:35 +00:00
|
|
|
//----------------------------------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Audio
|
|
|
|
//
|
2023-12-29 18:43:08 +00:00
|
|
|
|
|
|
|
bool audioIsEnabled( handle_t h );
|
2021-01-22 14:49:57 +00:00
|
|
|
unsigned audioDeviceCount( handle_t h );
|
2023-12-29 18:43:08 +00:00
|
|
|
unsigned audioActiveDeviceCount( handle_t h );
|
2021-01-22 14:49:57 +00:00
|
|
|
unsigned audioDeviceLabelToIndex( handle_t h, const char* label );
|
2021-12-11 20:14:27 +00:00
|
|
|
const char* audioDeviceLabel( handle_t h, unsigned devIdx );
|
2021-01-31 16:14:22 +00:00
|
|
|
rc_t audioDeviceSetUserId( handle_t h, unsigned devIdx, unsigned userId );
|
2023-02-19 19:16:37 +00:00
|
|
|
bool audioDeviceIsActive( handle_t h, unsigned devIdx );
|
2021-01-22 14:49:57 +00:00
|
|
|
const char* audioDeviceName( handle_t h, unsigned devIdx );
|
2021-12-11 20:14:27 +00:00
|
|
|
unsigned audioDeviceUserId( handle_t h, unsigned devIdx );
|
2023-02-19 19:16:37 +00:00
|
|
|
rc_t audioDeviceEnable( handle_t h, unsigned devIdx, bool inputFl, bool enableFl );
|
|
|
|
rc_t audioDeviceSeek( handle_t h, unsigned devIdx, bool inputFl, unsigned frameOffset );
|
2021-01-22 14:49:57 +00:00
|
|
|
double audioDeviceSampleRate( handle_t h, unsigned devIdx );
|
|
|
|
unsigned audioDeviceFramesPerCycle( handle_t h, unsigned devIdx );
|
|
|
|
unsigned audioDeviceChannelCount( handle_t h, unsigned devIdx, unsigned inOrOutFlag );
|
|
|
|
rc_t audioDeviceEnableMeters( handle_t h, unsigned devIdx, unsigned inOutEnaFlags );
|
|
|
|
const sample_t* audioDeviceMeters( handle_t h, unsigned devIdx, unsigned& chCntRef, unsigned inOrOutFlag );
|
|
|
|
rc_t audioDeviceEnableTone( handle_t h, unsigned devidx, unsigned inOutEnaFlags );
|
|
|
|
rc_t audioDeviceToneFlags( handle_t h, unsigned devIdx, unsigned inOrOutFlag, bool* toneFlA, unsigned chCnt );
|
|
|
|
rc_t audioDeviceEnableMute( handle_t h, unsigned devidx, unsigned inOutEnaFlags );
|
|
|
|
rc_t audioDeviceMuteFlags( handle_t h, unsigned devIdx, unsigned inOrOutFlag, bool* muteFlA, unsigned chCnt );
|
2021-01-31 16:14:22 +00:00
|
|
|
rc_t audioDeviceSetGain( handle_t h, unsigned devIdx, unsigned inOrOutFlag, double gain );
|
|
|
|
rc_t audioDeviceGain( handle_t h, unsigned devIdx, unsigned inOrOutFlag, double* gainA, unsigned chCnt );
|
|
|
|
|
|
|
|
unsigned audioGroupCount( handle_t h );
|
|
|
|
unsigned audioGroupLabelToIndex( handle_t h, const char* label );
|
|
|
|
const char* audioGroupLabel( handle_t h, unsigned groupIdx );
|
|
|
|
bool audioGroupIsEnabled( handle_t h, unsigned groupIdx );
|
|
|
|
unsigned audioGroupUserId( handle_t h, unsigned groupIdx );
|
|
|
|
rc_t audioGroupSetUserId( handle_t h, unsigned groupIdx, unsigned userId );
|
|
|
|
double audioGroupSampleRate( handle_t h, unsigned groupIdx );
|
|
|
|
unsigned audioGroupDspFrameCount( handle_t h, unsigned groupIdx );
|
2024-06-11 00:38:44 +00:00
|
|
|
rc_t audioGroupReconfigure( handle_t h, unsigned groupIdx, double srate, unsigned dspFrameN );
|
2021-12-11 20:14:27 +00:00
|
|
|
|
|
|
|
// Get the count of in or out devices assigned to this group.
|
|
|
|
unsigned audioGroupDeviceCount( handle_t h, unsigned groupIdx, unsigned inOrOutFl );
|
|
|
|
|
|
|
|
// Get the device index of each of the devices assigned to this group
|
|
|
|
unsigned audioGroupDeviceIndex( handle_t h, unsigned groupIdx, unsigned inOrOutFl, unsigned groupDeviceIdx );
|
2021-01-20 18:12:35 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Socket
|
|
|
|
//
|
2024-06-10 20:34:52 +00:00
|
|
|
|
|
|
|
bool socketIsEnabled( handle_t h );
|
2021-01-31 16:14:22 +00:00
|
|
|
unsigned socketCount( handle_t h );
|
|
|
|
unsigned socketLabelToIndex( handle_t h, const char* label );
|
|
|
|
unsigned socketUserId( handle_t h, unsigned sockIdx );
|
|
|
|
rc_t socketSetUserId( handle_t h, unsigned sockIdx, unsigned userId );
|
|
|
|
const char* socketLabel( handle_t h, unsigned sockIdx );
|
|
|
|
const char* socketHostName( handle_t h, unsigned sockIdx );
|
|
|
|
const char* socketIpAddress( handle_t h, unsigned sockIdx );
|
|
|
|
unsigned socketInetAddress( handle_t h, unsigned sockIdx );
|
|
|
|
sock::portNumber_t socketPort( handle_t h, unsigned sockIdx );
|
|
|
|
rc_t socketPeername( handle_t h, unsigned sockIdx, struct sockaddr_in* addr );
|
2022-11-14 23:32:32 +00:00
|
|
|
|
|
|
|
bool socketIsConnected( handle_t h, unsigned sockIdx );
|
2020-02-13 16:30:46 +00:00
|
|
|
|
2021-01-20 18:12:35 +00:00
|
|
|
|
2020-03-23 17:14:42 +00:00
|
|
|
|
|
|
|
// Send to the remote endpoint represented by connId over a connected socket.
|
2021-01-31 16:14:22 +00:00
|
|
|
// 'connId' is an id, assigned by the framework, of a remote connected endpoint
|
|
|
|
// attached to a receiving local socket. It is passed to the application as part
|
|
|
|
// of the incoming data callback.
|
2020-03-23 17:14:42 +00:00
|
|
|
// If 'connId' is kInvalidId then this data is sent to all connected endpoints.
|
2021-01-31 16:14:22 +00:00
|
|
|
rc_t socketSend( handle_t h, unsigned sockIdx, unsigned connId, const void* data, unsigned dataByteCnt );
|
2020-03-23 17:14:42 +00:00
|
|
|
|
|
|
|
// Send a message to a specific remote node over an unconnected UDP socket.
|
|
|
|
// Use the function initAddr() to setup the 'sockaddr_in';
|
2021-01-31 16:14:22 +00:00
|
|
|
rc_t socketSend( handle_t h, unsigned sockIdx, const void* data, unsigned dataByteCnt, const struct sockaddr_in* remoteAddr );
|
|
|
|
rc_t socketSend( handle_t h, unsigned sockIdx, const void* data, unsigned dataByteCnt, const char* remoteAddr, sock::portNumber_t remotePort );
|
2020-03-23 17:14:42 +00:00
|
|
|
|
|
|
|
|
2021-01-20 18:12:35 +00:00
|
|
|
//----------------------------------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// UI
|
|
|
|
//
|
|
|
|
|
2024-06-10 20:34:52 +00:00
|
|
|
bool uiIsEnabled( handle_t h );
|
|
|
|
|
2021-01-20 18:12:35 +00:00
|
|
|
// Find id's associated with elements.
|
2021-11-06 02:21:44 +00:00
|
|
|
unsigned parentAndNameToAppId( handle_t h, unsigned parentAppId, const char* eleName );
|
|
|
|
unsigned parentAndNameToUuId( handle_t h, unsigned parentAppId, const char* eleName );
|
|
|
|
unsigned parentAndAppIdToUuId( handle_t h, unsigned parentAppId, unsigned appId );
|
|
|
|
const char* uiFindElementName( handle_t h, unsigned uuId );
|
|
|
|
unsigned uiFindElementAppId( handle_t h, unsigned uuId );
|
2021-01-20 18:12:35 +00:00
|
|
|
|
2021-01-31 16:14:22 +00:00
|
|
|
// Return the uuid of the first matching 'eleName' or 'appId'.
|
2021-11-06 02:21:44 +00:00
|
|
|
unsigned uiFindElementUuId( handle_t h, const char* eleName, unsigned chanId=kInvalidId );
|
|
|
|
unsigned uiFindElementUuId( handle_t h, unsigned appId, unsigned chanId=kInvalidId );
|
2021-01-20 18:12:35 +00:00
|
|
|
|
2021-11-06 02:21:44 +00:00
|
|
|
unsigned uiFindElementUuId( handle_t h, unsigned parentUuId, const char* eleName, unsigned chanId=kInvalidId );
|
|
|
|
unsigned uiFindElementUuId( handle_t h, unsigned parentUuId, unsigned appId, unsigned chanId=kInvalidId );
|
|
|
|
|
|
|
|
|
2021-11-03 15:09:07 +00:00
|
|
|
rc_t uiCreateFromObject( handle_t h, const object_t* o, unsigned parentUuId=kInvalidId, unsigned chanId=kInvalidId, const char* eleName=nullptr);
|
|
|
|
rc_t uiCreateFromFile( handle_t h, const char* fn, unsigned parentUuId=kInvalidId, unsigned chanId=kInvalidId );
|
|
|
|
rc_t uiCreateFromText( handle_t h, const char* text, unsigned parentUuId=kInvalidId, unsigned chanId=kInvalidId );
|
2022-12-13 21:53:31 +00:00
|
|
|
rc_t uiCreateFromRsrc( handle_t h, const char* label, unsigned parentUuId=kInvalidId, unsigned chanId=kInvalidId );
|
2021-11-03 15:09:07 +00:00
|
|
|
|
|
|
|
rc_t uiCreateDiv( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
|
|
|
rc_t uiCreateLabel( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
|
|
|
rc_t uiCreateButton( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
2021-01-20 18:12:35 +00:00
|
|
|
|
|
|
|
// Create check: w/o value. The value will be read from the engine via the UI 'echo' event.
|
|
|
|
// Create check: w/ value. The value will be sent to the engine as the new value of the associated varaible.
|
2021-11-03 15:09:07 +00:00
|
|
|
rc_t uiCreateCheck( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
|
|
|
rc_t uiCreateCheck( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title, bool value );
|
2021-01-20 18:12:35 +00:00
|
|
|
|
2021-11-03 15:09:07 +00:00
|
|
|
rc_t uiCreateSelect( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
|
|
|
rc_t uiCreateOption( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
2021-12-27 21:48:58 +00:00
|
|
|
|
|
|
|
rc_t uiCreateStrDisplay( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
|
|
|
rc_t uiCreateStrDisplay( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title, const char* value );
|
2021-01-20 18:12:35 +00:00
|
|
|
|
2021-11-03 15:09:07 +00:00
|
|
|
rc_t uiCreateStr( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
|
|
|
rc_t uiCreateStr( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title, const char* value );
|
2021-01-20 18:12:35 +00:00
|
|
|
|
2021-11-03 15:09:07 +00:00
|
|
|
rc_t uiCreateNumbDisplay(handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title, unsigned decPl );
|
|
|
|
rc_t uiCreateNumbDisplay(handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title, unsigned decPl, double value );
|
2021-01-20 18:12:35 +00:00
|
|
|
|
2021-11-03 15:09:07 +00:00
|
|
|
rc_t uiCreateNumb( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title, double minValue, double maxValue, double stepValue, unsigned decPl );
|
|
|
|
rc_t uiCreateNumb( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title, double minValue, double maxValue, double stepValue, unsigned decPl, double value );
|
2021-01-20 18:12:35 +00:00
|
|
|
|
2021-11-03 15:09:07 +00:00
|
|
|
rc_t uiCreateProg( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title, double minValue, double maxValue );
|
|
|
|
rc_t uiCreateProg( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title, double minValue, double maxValue, double value );
|
2021-01-20 18:12:35 +00:00
|
|
|
|
2021-11-03 15:09:07 +00:00
|
|
|
rc_t uiCreateLog( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
2021-01-20 18:12:35 +00:00
|
|
|
|
2024-10-12 19:25:03 +00:00
|
|
|
rc_t uiCreateVList( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
|
|
|
rc_t uiCreateHList( handle_t h, unsigned& uuIdRef, unsigned parentUuId, const char* eleName, unsigned appId, unsigned chanId, const char* clas, const char* title );
|
|
|
|
|
|
|
|
|
|
|
|
rc_t uiSetTitle( handle_t h, unsigned uuId, const char* title );
|
2021-10-12 20:52:08 +00:00
|
|
|
|
2021-11-03 15:09:07 +00:00
|
|
|
rc_t uiSetNumbRange( handle_t h, unsigned uuId, double minValue, double maxValue, double stepValue, unsigned decPl, double value );
|
|
|
|
rc_t uiSetProgRange( handle_t h, unsigned uuId, double minValue, double maxValue, double value );
|
2024-09-21 21:18:12 +00:00
|
|
|
rc_t uiSetLogLine( handle_t h, unsigned uuId, const char* text );
|
2024-10-19 16:36:38 +00:00
|
|
|
rc_t uiEmptyParent( handle_t h, unsigned uuId); // empty a list or selection menu of all children
|
2021-11-06 02:21:44 +00:00
|
|
|
|
|
|
|
rc_t uiSetClickable( handle_t h, unsigned uuId, bool clickableFl=true );
|
|
|
|
rc_t uiClearClickable( handle_t h, unsigned uuId );
|
|
|
|
bool uiIsClickable( handle_t h, unsigned uuId );
|
|
|
|
|
|
|
|
rc_t uiSetSelect( handle_t h, unsigned uuId, bool enableFl=true );
|
|
|
|
rc_t uiClearSelect( handle_t h, unsigned uuId );
|
|
|
|
bool uiIsSelected( handle_t h, unsigned uuId );
|
|
|
|
|
|
|
|
rc_t uiSetVisible( handle_t h, unsigned uuId, bool enableFl=true );
|
|
|
|
rc_t uiClearVisible( handle_t h, unsigned uuId );
|
|
|
|
bool uiIsVisible( handle_t h, unsigned uuId );
|
|
|
|
|
|
|
|
rc_t uiSetEnable( handle_t h, unsigned uuId, bool enableFl=true );
|
|
|
|
rc_t uiClearEnable( handle_t h, unsigned uuId );
|
|
|
|
bool uiIsEnabled( handle_t h, unsigned uuId );
|
2021-11-14 16:54:52 +00:00
|
|
|
|
|
|
|
rc_t uiSetOrderKey( handle_t h, unsigned uuId, int orderKey );
|
|
|
|
int uiGetOrderKey( handle_t h, unsigned uuId );
|
|
|
|
|
2024-05-11 16:10:21 +00:00
|
|
|
rc_t uiSetScrollTop( handle_t h, unsigned uuId );
|
2024-10-12 19:25:03 +00:00
|
|
|
|
|
|
|
// uiSetBlob() allocates internal memory and copies the contents of blob[blobByeN]
|
2021-11-14 16:54:52 +00:00
|
|
|
rc_t uiSetBlob( handle_t h, unsigned uuId, const void* blob, unsigned blobByteN );
|
|
|
|
const void* uiGetBlob( handle_t h, unsigned uuId, unsigned& blobByteN_Ref );
|
2024-10-12 19:25:03 +00:00
|
|
|
|
|
|
|
// On call bufByteN_Ref holds the size of buf in bytes, on return it is set to the count of bytes in buf[].
|
|
|
|
// If buf[] is not large enough to hold all bytes kBufTooSmallRC is returned.
|
|
|
|
rc_t uiGetBlob( handle_t h, unsigned uuId, void* buf, unsigned& bufByteN_Ref );
|
2021-11-14 16:54:52 +00:00
|
|
|
rc_t uiClearBlob( handle_t h, unsigned uuId );
|
2021-10-12 20:52:08 +00:00
|
|
|
|
2021-01-20 18:12:35 +00:00
|
|
|
// Register parent/child/name app id's
|
|
|
|
rc_t uiRegisterAppIdMap( handle_t h, const ui::appIdMap_t* map, unsigned mapN );
|
2021-11-14 16:54:52 +00:00
|
|
|
|
|
|
|
rc_t uiDestroyElement( handle_t h, unsigned uuId );
|
2021-01-20 18:12:35 +00:00
|
|
|
|
2021-01-22 14:49:57 +00:00
|
|
|
// Send a value from the application to the UI.
|
2021-04-10 17:37:07 +00:00
|
|
|
// Set wsSessId to kInvalidId to send to all sessions.
|
2021-11-03 15:09:07 +00:00
|
|
|
rc_t uiSendValue( handle_t h, unsigned uuId, bool value );
|
|
|
|
rc_t uiSendValue( handle_t h, unsigned uuId, int value );
|
|
|
|
rc_t uiSendValue( handle_t h, unsigned uuId, unsigned value );
|
|
|
|
rc_t uiSendValue( handle_t h, unsigned uuId, float value );
|
|
|
|
rc_t uiSendValue( handle_t h, unsigned uuId, double value );
|
|
|
|
rc_t uiSendValue( handle_t h, unsigned uuId, const char* value );
|
2021-01-22 14:49:57 +00:00
|
|
|
|
2023-12-29 18:43:08 +00:00
|
|
|
rc_t uiSendMsg( handle_t h, const char* msg );
|
|
|
|
|
2024-02-10 16:34:06 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
time::spec_t note_on_input_ts;
|
|
|
|
time::spec_t note_on_output_ts;
|
|
|
|
time::spec_t audio_in_ts;
|
|
|
|
time::spec_t audio_out_ts;
|
|
|
|
sample_t audio_in_rms_max;
|
|
|
|
sample_t audio_out_rms_max;
|
|
|
|
} latency_meas_result_t;
|
|
|
|
|
|
|
|
void latency_measure_setup(handle_t h);
|
|
|
|
latency_meas_result_t latency_measure_result(handle_t h);
|
|
|
|
void latency_measure_report(handle_t h);
|
|
|
|
|
2023-12-03 16:18:02 +00:00
|
|
|
void uiRealTimeReport( handle_t h );
|
2022-01-22 14:43:01 +00:00
|
|
|
void uiReport( handle_t h );
|
2020-01-27 22:53:44 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|