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
|
|
|
|
{
|
|
|
|
kSerialTId,
|
|
|
|
kMidiTId,
|
|
|
|
kAudioTId,
|
2021-01-22 14:49:57 +00:00
|
|
|
kAudioMeterTId,
|
2021-01-31 16:14:22 +00:00
|
|
|
kSockTId,
|
2021-01-20 18:12:35 +00:00
|
|
|
kWebSockTId,
|
|
|
|
kUiTId
|
2020-01-27 22:53:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct serial_msg_str
|
|
|
|
{
|
|
|
|
unsigned devId;
|
|
|
|
const void* dataA;
|
|
|
|
unsigned byteN;
|
|
|
|
} serial_msg_t;
|
|
|
|
|
|
|
|
typedef struct midi_msg_str
|
|
|
|
{
|
|
|
|
midi::packet_t* pkt;
|
|
|
|
} 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-01-22 14:49:57 +00:00
|
|
|
sample_t** iBufArray; // Array of iBufChCnt ptrs to buffers of size bufSmpCnt
|
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[]
|
|
|
|
|
|
|
|
sample_t** oBufArray; //
|
|
|
|
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;
|
|
|
|
const ui::value_t* value;
|
|
|
|
} ui_msg_t;
|
|
|
|
|
2020-01-27 22:53:44 +00:00
|
|
|
typedef struct msg_str
|
|
|
|
{
|
|
|
|
unsigned tid;
|
|
|
|
union
|
|
|
|
{
|
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;
|
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 );
|
|
|
|
rc_t exec( handle_t h );
|
|
|
|
bool isShuttingDown( handle_t h );
|
2021-01-31 16:14:22 +00:00
|
|
|
void report( handle_t h );
|
2021-01-20 18:12:35 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Serial
|
|
|
|
//
|
2020-01-27 22:53:44 +00:00
|
|
|
|
|
|
|
unsigned serialDeviceCount( handle_t h );
|
2021-01-31 16:14:22 +00:00
|
|
|
const char* serialDeviceLabel( handle_t h, unsigned devIdx );
|
|
|
|
unsigned serialDeviceIndex( handle_t h, const char* label );
|
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
|
|
|
|
//
|
|
|
|
|
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 );
|
|
|
|
|
2020-02-13 16:30:46 +00:00
|
|
|
|
2021-01-20 18:12:35 +00:00
|
|
|
//----------------------------------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Audio
|
|
|
|
//
|
|
|
|
|
2021-01-22 14:49:57 +00:00
|
|
|
unsigned audioDeviceCount( handle_t h );
|
|
|
|
unsigned audioDeviceLabelToIndex( handle_t h, const char* label );
|
2021-01-31 16:14:22 +00:00
|
|
|
rc_t audioDeviceSetUserId( handle_t h, unsigned devIdx, unsigned userId );
|
|
|
|
bool audioDeviceIsEnabled( handle_t h, unsigned devIdx );
|
2021-01-22 14:49:57 +00:00
|
|
|
const char* audioDeviceName( handle_t h, unsigned devIdx );
|
|
|
|
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 );
|
2021-01-20 18:12:35 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Socket
|
|
|
|
//
|
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 );
|
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
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
// Find id's associated with elements.
|
|
|
|
unsigned uiFindElementAppId( handle_t h, unsigned parentUuId, const char* eleName );
|
|
|
|
unsigned uiFindElementUuId( handle_t h, unsigned parentUuId, const char* eleName );
|
|
|
|
unsigned uiFindElementUuId( handle_t h, unsigned parentUuId, unsigned appId );
|
|
|
|
const char* uiFindElementName( handle_t h, unsigned uuId );
|
|
|
|
unsigned uiFindElementAppId( handle_t h, unsigned uuId );
|
|
|
|
|
2021-01-31 16:14:22 +00:00
|
|
|
// Return the uuid of the first matching 'eleName' or 'appId'.
|
2021-01-20 18:12:35 +00:00
|
|
|
unsigned uiFindElementUuId( handle_t h, const char* eleName );
|
2021-01-22 14:49:57 +00:00
|
|
|
unsigned uiFindElementUuId( handle_t h, unsigned appId );
|
2021-01-20 18:12:35 +00:00
|
|
|
|
|
|
|
rc_t uiCreateFromObject( handle_t h, const object_t* o, unsigned wsSessId, unsigned parentUuId=kInvalidId, const char* eleName=nullptr);
|
|
|
|
rc_t uiCreateFromFile( handle_t h, const char* fn, unsigned wsSessId, unsigned parentUuId=kInvalidId);
|
|
|
|
rc_t uiCreateFromText( handle_t h, const char* text, unsigned wsSessId, unsigned parentUuId=kInvalidId);
|
|
|
|
rc_t uiCreateDiv( handle_t h, unsigned& uuIdRef, unsigned wsSessId, unsigned parentUuId, const char* eleName, unsigned appId, const char* clas, const char* title );
|
|
|
|
rc_t uiCreateTitle( handle_t h, unsigned& uuIdRef, unsigned wsSessId, unsigned parentUuId, const char* eleName, unsigned appId, const char* clas, const char* title );
|
|
|
|
rc_t uiCreateButton( handle_t h, unsigned& uuIdRef, unsigned wsSessId, unsigned parentUuId, const char* eleName, unsigned appId, const char* clas, const char* title );
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
rc_t uiCreateCheck( handle_t h, unsigned& uuIdRef, unsigned wsSessId, unsigned parentUuId, const char* eleName, unsigned appId, const char* clas, const char* title );
|
|
|
|
rc_t uiCreateCheck( handle_t h, unsigned& uuIdRef, unsigned wsSessId, unsigned parentUuId, const char* eleName, unsigned appId, const char* clas, const char* title, bool value );
|
|
|
|
|
|
|
|
rc_t uiCreateSelect( handle_t h, unsigned& uuIdRef, unsigned wsSessId, unsigned parentUuId, const char* eleName, unsigned appId, const char* clas, const char* title );
|
|
|
|
rc_t uiCreateOption( handle_t h, unsigned& uuIdRef, unsigned wsSessId, unsigned parentUuId, const char* eleName, unsigned appId, const char* clas, const char* title );
|
|
|
|
|
|
|
|
rc_t uiCreateStr( handle_t h, unsigned& uuIdRef, unsigned wsSessId, unsigned parentUuId, const char* eleName, unsigned appId, const char* clas, const char* title );
|
|
|
|
rc_t uiCreateStr( handle_t h, unsigned& uuIdRef, unsigned wsSessId, unsigned parentUuId, const char* eleName, unsigned appId, const char* clas, const char* title, const char* value );
|
|
|
|
|
|
|
|
rc_t uiCreateNumbDisplay(handle_t h, unsigned& uuIdRef, unsigned wsSessId, unsigned parentUuId, const char* eleName, unsigned appId, const char* clas, const char* title, unsigned decPl );
|
|
|
|
rc_t uiCreateNumbDisplay(handle_t h, unsigned& uuIdRef, unsigned wsSessId, unsigned parentUuId, const char* eleName, unsigned appId, const char* clas, const char* title, unsigned decPl, double value );
|
|
|
|
|
|
|
|
rc_t uiCreateNumb( handle_t h, unsigned& uuIdRef, unsigned wsSessId, unsigned parentUuId, const char* eleName, unsigned appId, const char* clas, const char* title, double minValue, double maxValue, double stepValue, unsigned decPl );
|
|
|
|
rc_t uiCreateNumb( handle_t h, unsigned& uuIdRef, unsigned wsSessId, unsigned parentUuId, const char* eleName, unsigned appId, const char* clas, const char* title, double minValue, double maxValue, double stepValue, unsigned decPl, double value );
|
|
|
|
|
|
|
|
rc_t uiCreateProg( handle_t h, unsigned& uuIdRef, unsigned wsSessId, unsigned parentUuId, const char* eleName, unsigned appId, const char* clas, const char* title, double minValue, double maxValue );
|
|
|
|
rc_t uiCreateProg( handle_t h, unsigned& uuIdRef, unsigned wsSessId, unsigned parentUuId, const char* eleName, unsigned appId, const char* clas, const char* title, double minValue, double maxValue, double value );
|
|
|
|
|
|
|
|
rc_t uiCreateText( handle_t h, unsigned& uuIdRef, unsigned wsSessId, unsigned parentUuId, const char* eleName, unsigned appId, const char* clas, const char* title );
|
|
|
|
|
|
|
|
// Register parent/child/name app id's
|
|
|
|
rc_t uiRegisterAppIdMap( handle_t h, const ui::appIdMap_t* map, unsigned mapN );
|
|
|
|
|
2021-01-22 14:49:57 +00:00
|
|
|
// Send a value from the application to the UI.
|
|
|
|
rc_t uiSendValue( handle_t h, unsigned wsSessId, unsigned uuId, bool value );
|
|
|
|
rc_t uiSendValue( handle_t h, unsigned wsSessId, unsigned uuId, int value );
|
|
|
|
rc_t uiSendValue( handle_t h, unsigned wsSessId, unsigned uuId, unsigned value );
|
|
|
|
rc_t uiSendValue( handle_t h, unsigned wsSessId, unsigned uuId, float value );
|
|
|
|
rc_t uiSendValue( handle_t h, unsigned wsSessId, unsigned uuId, double value );
|
|
|
|
rc_t uiSendValue( handle_t h, unsigned wsSessId, unsigned uuId, const char* value );
|
|
|
|
|
2020-03-23 17:14:42 +00:00
|
|
|
|
2020-01-27 22:53:44 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|