cmAudioSys.c,cmAudioSysMsg.h,cmMsgProtocol.h: Removed cmAudioSys.c dependency on cmDspValue().
Removed cmAudioSys.c dependency on cmDspValue.h by changing the host to audio system message format from cmDspUiHdr_t to cmAudioSysMstr_t. All audio system message records are now isolated in cmAudioSysMsg.h which cmMsgProtocol directly includes.
This commit is contained in:
parent
7cf517ce44
commit
2bc819afb9
30
cmAudioSys.c
30
cmAudioSys.c
@ -9,15 +9,11 @@
|
|||||||
#include "cmAudioPort.h"
|
#include "cmAudioPort.h"
|
||||||
#include "cmAudioPortFile.h"
|
#include "cmAudioPortFile.h"
|
||||||
#include "cmApBuf.h"
|
#include "cmApBuf.h"
|
||||||
|
#include "cmJson.h"
|
||||||
#include "cmJson.h" // these files are
|
|
||||||
#include "dsp/cmDspValue.h" // only required for
|
|
||||||
#include "dsp/cmDspUi.h" // UI building
|
|
||||||
|
|
||||||
#include "cmThread.h"
|
#include "cmThread.h"
|
||||||
#include "cmUdpPort.h"
|
#include "cmUdpPort.h"
|
||||||
#include "cmUdpNet.h"
|
#include "cmUdpNet.h"
|
||||||
#include "cmMsgProtocol.h"
|
#include "cmAudioSysMsg.h"
|
||||||
#include "cmAudioSys.h"
|
#include "cmAudioSys.h"
|
||||||
#include "cmMidi.h"
|
#include "cmMidi.h"
|
||||||
#include "cmMidiPort.h"
|
#include "cmMidiPort.h"
|
||||||
@ -155,10 +151,10 @@ cmAsRC_t _cmAsHostInitNotify( cmAs_t* p )
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmAsRC_t _cmAsDispatchNonSubSysMsg( cmAs_t* p, const void* msg, unsigned msgByteCnt )
|
cmAsRC_t _cmAsParseNonSubSysMsg( cmAs_t* p, const void* msg, unsigned msgByteCnt )
|
||||||
{
|
{
|
||||||
cmAsRC_t rc = kOkAsRC;
|
cmAsRC_t rc = kOkAsRC;
|
||||||
cmDspUiHdr_t* h = (cmDspUiHdr_t*)msg;
|
cmAudioSysMstr_t* h = (cmAudioSysMstr_t*)msg;
|
||||||
unsigned devIdx = cmAudioSysUiInstIdToDevIndex(h->instId);
|
unsigned devIdx = cmAudioSysUiInstIdToDevIndex(h->instId);
|
||||||
unsigned chIdx = cmAudioSysUiInstIdToChIndex(h->instId);
|
unsigned chIdx = cmAudioSysUiInstIdToChIndex(h->instId);
|
||||||
unsigned inFl = cmAudioSysUiInstIdToInFlag(h->instId);
|
unsigned inFl = cmAudioSysUiInstIdToInFlag(h->instId);
|
||||||
@ -166,8 +162,8 @@ cmAsRC_t _cmAsDispatchNonSubSysMsg( cmAs_t* p, const void* msg, unsigned msgBy
|
|||||||
|
|
||||||
// if the valuu associated with this msg is a mtx then set
|
// if the valuu associated with this msg is a mtx then set
|
||||||
// its mtx data area pointer to just after the msg header.
|
// its mtx data area pointer to just after the msg header.
|
||||||
if( cmDsvIsMtx(&h->value) )
|
//if( cmDsvIsMtx(&h->value) )
|
||||||
h->value.u.m.u.vp = ((char*)msg) + sizeof(cmDspUiHdr_t);
|
// h->value.u.m.u.vp = ((char*)msg) + sizeof(cmDspUiHdr_t);
|
||||||
|
|
||||||
unsigned flags = inFl ? kInApFl : kOutApFl;
|
unsigned flags = inFl ? kInApFl : kOutApFl;
|
||||||
|
|
||||||
@ -175,24 +171,24 @@ cmAsRC_t _cmAsDispatchNonSubSysMsg( cmAs_t* p, const void* msg, unsigned msgBy
|
|||||||
{
|
{
|
||||||
|
|
||||||
case kSliderUiAsId: // slider
|
case kSliderUiAsId: // slider
|
||||||
cmApBufSetGain(devIdx,chIdx, flags, cmDsvGetDouble(&h->value));
|
cmApBufSetGain(devIdx,chIdx, flags, h->value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kMeterUiAsId: // meter
|
case kMeterUiAsId: // meter
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kMuteUiAsId: // mute
|
case kMuteUiAsId: // mute
|
||||||
flags += cmDsvGetDouble(&h->value) == 0 ? kEnableApFl : 0;
|
flags += h->value == 0 ? kEnableApFl : 0;
|
||||||
cmApBufEnableChannel(devIdx,chIdx,flags);
|
cmApBufEnableChannel(devIdx,chIdx,flags);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kToneUiAsId: // tone
|
case kToneUiAsId: // tone
|
||||||
flags += cmDsvGetDouble(&h->value) > 0 ? kEnableApFl : 0;
|
flags += h->value > 0 ? kEnableApFl : 0;
|
||||||
cmApBufEnableTone(devIdx,chIdx,flags);
|
cmApBufEnableTone(devIdx,chIdx,flags);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kPassUiAsId: // pass
|
case kPassUiAsId: // pass
|
||||||
flags += cmDsvGetDouble(&h->value) > 0 ? kEnableApFl : 0;
|
flags += h->value > 0 ? kEnableApFl : 0;
|
||||||
cmApBufEnablePass(devIdx,chIdx,flags);
|
cmApBufEnablePass(devIdx,chIdx,flags);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -210,7 +206,7 @@ cmAsRC_t _cmAsHandleNonSubSysMsg( cmAs_t* p, const void* msgDataPtrArray[], un
|
|||||||
|
|
||||||
// if the message is contained in a single segment it can be dispatched immediately ...
|
// if the message is contained in a single segment it can be dispatched immediately ...
|
||||||
if( msgSegCnt == 1 )
|
if( msgSegCnt == 1 )
|
||||||
rc = _cmAsDispatchNonSubSysMsg(p,msgDataPtrArray[0],msgByteCntArray[0]);
|
rc = _cmAsParseNonSubSysMsg(p,msgDataPtrArray[0],msgByteCntArray[0]);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// ... otherwise deserialize the message into contiguous memory ....
|
// ... otherwise deserialize the message into contiguous memory ....
|
||||||
@ -228,7 +224,7 @@ cmAsRC_t _cmAsHandleNonSubSysMsg( cmAs_t* p, const void* msgDataPtrArray[], un
|
|||||||
b += msgByteCntArray[i];
|
b += msgByteCntArray[i];
|
||||||
}
|
}
|
||||||
// ... and then dispatch it
|
// ... and then dispatch it
|
||||||
rc = _cmAsDispatchNonSubSysMsg(p,buf,byteCnt);
|
rc = _cmAsParseNonSubSysMsg(p,buf,byteCnt);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -970,7 +966,7 @@ cmAsRC_t cmAudioSysDeliverSegMsg( cmAudioSysH_t h, const void* msgDataPtrArray
|
|||||||
|
|
||||||
// BUG BUG BUG - there is no reason that both the asSubIdx and the selId must
|
// BUG BUG BUG - there is no reason that both the asSubIdx and the selId must
|
||||||
// be in the first segment but it would be nice.
|
// be in the first segment but it would be nice.
|
||||||
assert( msgByteCntArray[0] >= 2*sizeof(unsigned) );
|
assert( msgByteCntArray[0] >= 2*sizeof(unsigned) || (msgSegCnt>1 && msgByteCntArray[0]==sizeof(unsigned) && msgByteCntArray[1]>=sizeof(unsigned)) );
|
||||||
|
|
||||||
// The audio sub-system index is always the first field of the msg
|
// The audio sub-system index is always the first field of the msg
|
||||||
// and the msg selector id is always the second field
|
// and the msg selector id is always the second field
|
||||||
|
113
cmAudioSysMsg.h
Normal file
113
cmAudioSysMsg.h
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
#ifndef cmAudioSysMsg_h
|
||||||
|
#define cmAudioSysMsg_h
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// Reserved DSP message selector id's (second field of all host<->audio system messages)
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
kMidiMsgArraySelAsId = 1000,
|
||||||
|
kMidiSysExSelAsId,
|
||||||
|
kUiSelAsId, // indicates a cmDspUiHdr_t msg
|
||||||
|
kUiMstrSelAsId, // indicates a cmDspUiHdr_t msg containing master control information for the audio system
|
||||||
|
kSsInitSelAsId, // indicates the msg is of type cmAudioSysSsInitMsg_t
|
||||||
|
kStatusSelAsId, // indicates the msg is of type cmAudioSysStatus_t
|
||||||
|
kNetSyncSelAsId, // sent with a cmDspNetMsg_t object
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// All of the UI messages that create a UI control contain an array of integers
|
||||||
|
// as in the 'value' field. The array contains the id's associated with
|
||||||
|
// the different programmable paramters which are part of the control.
|
||||||
|
// For example a slider control has minimum,maximum, step size, and value
|
||||||
|
// parameters. The location in the array is hard coded according to the
|
||||||
|
// parameters meaning but the actual value of the id is left up to the
|
||||||
|
// engine. This allows the engine to use whatever values work best for
|
||||||
|
// it on a per instance basis.
|
||||||
|
|
||||||
|
|
||||||
|
// Header record for all messages between the host and the DSP controllers.
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
unsigned asSubIdx; // the audio sub-system this UI belongs to
|
||||||
|
unsigned uiId; // msg type kXXXAsId
|
||||||
|
unsigned selId; // action to perform see above
|
||||||
|
unsigned flags; //
|
||||||
|
unsigned instId; // DSP instance id
|
||||||
|
unsigned instVarId; // DSP instance var id
|
||||||
|
unsigned rsrvd;
|
||||||
|
double value;
|
||||||
|
} cmAudioSysMstr_t;
|
||||||
|
|
||||||
|
|
||||||
|
/// The cmDspUiHdr_t.instId of UI control messages associated with master
|
||||||
|
/// control encode the device,channel,in/out, and control type. These macros
|
||||||
|
/// should be used for encoding and decoding.
|
||||||
|
#define cmAudioSysFormUiInstId(dev,ch,ifl,ctl) (((dev)<<16) + ((ch)<<4) + ((ifl)<<3) + (ctl))
|
||||||
|
#define cmAudioSysUiInstIdToDevIndex(instId) ( (instId) >> 16)
|
||||||
|
#define cmAudioSysUiInstIdToChIndex(instId) (((instId) & 0x0000ffff) >> 4)
|
||||||
|
#define cmAudioSysUiInstIdToInFlag(instId) ( (instId) & 0x08)
|
||||||
|
#define cmAudioSysUiInstIdToCtlId(instId) ( (instId) & 0x07)
|
||||||
|
|
||||||
|
/// Control id's used to identify the control type of master contols.
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
kSliderUiAsId = 0,
|
||||||
|
kMeterUiAsId = 1,
|
||||||
|
kMuteUiAsId = 2,
|
||||||
|
kToneUiAsId = 3,
|
||||||
|
kPassUiAsId = 4
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/// This message is transmitted to the host application just prior to returning
|
||||||
|
/// from cmAudioSysInitialize().
|
||||||
|
/// When transmitted to the host this record acts as a message header.
|
||||||
|
/// This header is followed by two zero terminated char arrays containing the device
|
||||||
|
/// labels associated with the input and output devices.
|
||||||
|
/// Message Layout: [ cmAudioSysInitMsg_t "In Device Label" "Out Device Label"]
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
unsigned asSubIdx; ///< asSubIdx of this sub-system
|
||||||
|
unsigned selId; ///< always kSsInitAsId
|
||||||
|
unsigned asSubCnt; ///< count of sub-systems
|
||||||
|
unsigned inDevIdx; ///< input device index
|
||||||
|
unsigned outDevIdx; ///< output device index
|
||||||
|
unsigned inChCnt; ///< input device channel count
|
||||||
|
unsigned outChCnt; ///< outut device channel count
|
||||||
|
} cmAudioSysSsInitMsg_t;
|
||||||
|
|
||||||
|
/// Audio sub-system status record - this message can be transmitted to the host at
|
||||||
|
/// periodic intervals. See cmAudioSysStatusNotifyEnable().
|
||||||
|
/// When transmitted to the host this record acts as the message header.
|
||||||
|
/// This header is followed by two arrays of doubles containing the input and output meter values
|
||||||
|
/// associated with the input and output audio devices.
|
||||||
|
/// Message Layout: [ asSubIdx kStatusSelId cmAudioSysStatus_t iMeterArray[iMeterCnt] oMeterArray[oMeterCnt] ]
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
unsigned asSubIdx; ///< originating audio sub-system
|
||||||
|
|
||||||
|
unsigned updateCnt; ///< count of callbacks from the audio devices.
|
||||||
|
unsigned wakeupCnt; ///< count of times the audio system thread has woken up after the cond. var has been signaled by the audio update thread.
|
||||||
|
unsigned msgCbCnt; ///< count of msgs delivered via cmAsCallback() .
|
||||||
|
unsigned audioCbCnt; ///< count of times the DSP execution was requested via cmAsCallback().
|
||||||
|
|
||||||
|
unsigned iDevIdx; ///< Input device index
|
||||||
|
unsigned oDevIdx; ///< Output device index
|
||||||
|
|
||||||
|
unsigned overflowCnt; ///< count of times the audio input buffers overflowed
|
||||||
|
unsigned underflowCnt; ///< count of times the audio output buffers underflowed
|
||||||
|
unsigned iMeterCnt; ///< count of input meter channels
|
||||||
|
unsigned oMeterCnt; ///< count of output meter channels
|
||||||
|
|
||||||
|
} cmAudioSysStatus_t;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef cmMsgProtocol_h
|
#ifndef cmMsgProtocol_h
|
||||||
#define cmMsgProtocol_h
|
#define cmMsgProtocol_h
|
||||||
|
|
||||||
|
#include "cmAudioSysMsg.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -8,19 +10,6 @@ extern "C" {
|
|||||||
#define cmAudDspSys_FILENAME "aud_dsp.js"
|
#define cmAudDspSys_FILENAME "aud_dsp.js"
|
||||||
|
|
||||||
|
|
||||||
/// Reserved DSP message selector id's (second field of all host<->audio system messages)
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
kMidiMsgArraySelAsId = 1000,
|
|
||||||
kMidiSysExSelAsId,
|
|
||||||
kUiSelAsId, // indicates a cmDspUiHdr_t msg
|
|
||||||
kUiMstrSelAsId, // indicates a cmDspUiHdr_t msg containing master control information for the audio system
|
|
||||||
kSsInitSelAsId, // indicates the msg is of type cmAudioSysSsInitMsg_t
|
|
||||||
kStatusSelAsId, // indicates the msg is of type cmAudioSysStatus_t
|
|
||||||
kNetSyncSelAsId, // sent with a cmDspNetMsg_t object
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// UI seletor id's used in the cmDspUiHdr_t selId field
|
// UI seletor id's used in the cmDspUiHdr_t selId field
|
||||||
enum
|
enum
|
||||||
@ -84,78 +73,6 @@ extern "C" {
|
|||||||
cmDspValue_t value; // Data value associated with this msg.
|
cmDspValue_t value; // Data value associated with this msg.
|
||||||
} cmDspUiHdr_t;
|
} cmDspUiHdr_t;
|
||||||
|
|
||||||
// All of the UI messages that create a UI control contain an array of integers
|
|
||||||
// as in the 'value' field. The array contains the id's associated with
|
|
||||||
// the different programmable paramters which are part of the control.
|
|
||||||
// For example a slider control has minimum,maximum, step size, and value
|
|
||||||
// parameters. The location in the array is hard coded according to the
|
|
||||||
// parameters meaning but the actual value of the id is left up to the
|
|
||||||
// engine. This allows the engine to use whatever values work best for
|
|
||||||
// it on a per instance basis.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// The cmDspUiHdr_t.instId of UI control messages associated with master
|
|
||||||
/// control encode the device,channel,in/out, and control type. These macros
|
|
||||||
/// should be used for encoding and decoding.
|
|
||||||
#define cmAudioSysFormUiInstId(dev,ch,ifl,ctl) (((dev)<<16) + ((ch)<<4) + ((ifl)<<3) + (ctl))
|
|
||||||
#define cmAudioSysUiInstIdToDevIndex(instId) ( (instId) >> 16)
|
|
||||||
#define cmAudioSysUiInstIdToChIndex(instId) (((instId) & 0x0000ffff) >> 4)
|
|
||||||
#define cmAudioSysUiInstIdToInFlag(instId) ( (instId) & 0x08)
|
|
||||||
#define cmAudioSysUiInstIdToCtlId(instId) ( (instId) & 0x07)
|
|
||||||
|
|
||||||
/// Control id's used to identify the control type of master contols.
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
kSliderUiAsId = 0,
|
|
||||||
kMeterUiAsId = 1,
|
|
||||||
kMuteUiAsId = 2,
|
|
||||||
kToneUiAsId = 3,
|
|
||||||
kPassUiAsId = 4
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/// This message is transmitted to the host application just prior to returning
|
|
||||||
/// from cmAudioSysInitialize().
|
|
||||||
/// When transmitted to the host this record acts as a message header.
|
|
||||||
/// This header is followed by two zero terminated char arrays containing the device
|
|
||||||
/// labels associated with the input and output devices.
|
|
||||||
/// Message Layout: [ cmAudioSysInitMsg_t "In Device Label" "Out Device Label"]
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned asSubIdx; ///< asSubIdx of this sub-system
|
|
||||||
unsigned selId; ///< always kSsInitAsId
|
|
||||||
unsigned asSubCnt; ///< count of sub-systems
|
|
||||||
unsigned inDevIdx; ///< input device index
|
|
||||||
unsigned outDevIdx; ///< output device index
|
|
||||||
unsigned inChCnt; ///< input device channel count
|
|
||||||
unsigned outChCnt; ///< outut device channel count
|
|
||||||
} cmAudioSysSsInitMsg_t;
|
|
||||||
|
|
||||||
/// Audio sub-system status record - this message can be transmitted to the host at
|
|
||||||
/// periodic intervals. See cmAudioSysStatusNotifyEnable().
|
|
||||||
/// When transmitted to the host this record acts as the message header.
|
|
||||||
/// This header is followed by two arrays of doubles containing the input and output meter values
|
|
||||||
/// associated with the input and output audio devices.
|
|
||||||
/// Message Layout: [ asSubIdx kStatusSelId cmAudioSysStatus_t iMeterArray[iMeterCnt] oMeterArray[oMeterCnt] ]
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
unsigned asSubIdx; ///< originating audio sub-system
|
|
||||||
|
|
||||||
unsigned updateCnt; ///< count of callbacks from the audio devices.
|
|
||||||
unsigned wakeupCnt; ///< count of times the audio system thread has woken up after the cond. var has been signaled by the audio update thread.
|
|
||||||
unsigned msgCbCnt; ///< count of msgs delivered via cmAsCallback() .
|
|
||||||
unsigned audioCbCnt; ///< count of times the DSP execution was requested via cmAsCallback().
|
|
||||||
|
|
||||||
unsigned iDevIdx; ///< Input device index
|
|
||||||
unsigned oDevIdx; ///< Output device index
|
|
||||||
|
|
||||||
unsigned overflowCnt; ///< count of times the audio input buffers overflowed
|
|
||||||
unsigned underflowCnt; ///< count of times the audio output buffers underflowed
|
|
||||||
unsigned iMeterCnt; ///< count of input meter channels
|
|
||||||
unsigned oMeterCnt; ///< count of output meter channels
|
|
||||||
|
|
||||||
} cmAudioSysStatus_t;
|
|
||||||
|
|
||||||
// cmDspNetMsg_t sub-selector id's
|
// cmDspNetMsg_t sub-selector id's
|
||||||
enum {
|
enum {
|
||||||
|
Loading…
Reference in New Issue
Block a user