cwIoAudioMidiApp,cwIoAudioRecordPlay,cwIoMidiRecordPlay : Add 'mute' feature
This commit is contained in:
parent
4b65621c68
commit
7edcb3309d
@ -35,9 +35,11 @@ namespace cw
|
|||||||
kMidiThruCheckId,
|
kMidiThruCheckId,
|
||||||
kCurMidiEvtCntId,
|
kCurMidiEvtCntId,
|
||||||
kTotalMidiEvtCntId,
|
kTotalMidiEvtCntId,
|
||||||
|
kMidiMuteCheckId,
|
||||||
|
|
||||||
kCurAudioSecsId,
|
kCurAudioSecsId,
|
||||||
kTotalAudioSecsId,
|
kTotalAudioSecsId,
|
||||||
|
kAudioMuteCheckId,
|
||||||
|
|
||||||
kSaveBtnId,
|
kSaveBtnId,
|
||||||
kOpenBtnId,
|
kOpenBtnId,
|
||||||
@ -66,10 +68,11 @@ namespace cw
|
|||||||
{ kPanelDivId, kMidiThruCheckId, "midiThruCheckId" },
|
{ kPanelDivId, kMidiThruCheckId, "midiThruCheckId" },
|
||||||
{ kPanelDivId, kCurMidiEvtCntId, "curMidiEvtCntId" },
|
{ kPanelDivId, kCurMidiEvtCntId, "curMidiEvtCntId" },
|
||||||
{ kPanelDivId, kTotalMidiEvtCntId, "totalMidiEvtCntId" },
|
{ kPanelDivId, kTotalMidiEvtCntId, "totalMidiEvtCntId" },
|
||||||
|
{ kPanelDivId, kMidiMuteCheckId, "midiMuteCheckId" },
|
||||||
|
|
||||||
{ kPanelDivId, kCurAudioSecsId, "curAudioSecsId" },
|
{ kPanelDivId, kCurAudioSecsId, "curAudioSecsId" },
|
||||||
{ kPanelDivId, kTotalAudioSecsId, "totalAudioSecsId" },
|
{ kPanelDivId, kTotalAudioSecsId, "totalAudioSecsId" },
|
||||||
|
{ kPanelDivId, kAudioMuteCheckId, "audioMuteCheckId" },
|
||||||
|
|
||||||
{ kPanelDivId, kSaveBtnId, "saveBtnId" },
|
{ kPanelDivId, kSaveBtnId, "saveBtnId" },
|
||||||
{ kPanelDivId, kOpenBtnId, "openBtnId" },
|
{ kPanelDivId, kOpenBtnId, "openBtnId" },
|
||||||
@ -388,6 +391,14 @@ namespace cw
|
|||||||
cwLogInfo("MIDI thru:%i",m.value->u.b);
|
cwLogInfo("MIDI thru:%i",m.value->u.b);
|
||||||
_set_midi_thru_state(app, m.value->u.b);
|
_set_midi_thru_state(app, m.value->u.b);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case kMidiMuteCheckId:
|
||||||
|
midi_record_play::set_mute_state(app->mrpH,m.value->u.b);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case kAudioMuteCheckId:
|
||||||
|
audio_record_play::set_mute_state(app->arpH,m.value->u.b);
|
||||||
|
break;
|
||||||
|
|
||||||
case kStartBtnId:
|
case kStartBtnId:
|
||||||
_on_ui_start(app);
|
_on_ui_start(app);
|
||||||
|
@ -39,6 +39,8 @@ namespace cw
|
|||||||
unsigned curFrameIdx;
|
unsigned curFrameIdx;
|
||||||
bool recordFl;
|
bool recordFl;
|
||||||
bool startedFl;
|
bool startedFl;
|
||||||
|
|
||||||
|
bool mute_fl;
|
||||||
|
|
||||||
unsigned* audioInChMapA;
|
unsigned* audioInChMapA;
|
||||||
unsigned audioInChMapN;
|
unsigned audioInChMapN;
|
||||||
@ -169,8 +171,11 @@ namespace cw
|
|||||||
for(unsigned chIdx=0; chIdx<chCnt; ++chIdx)
|
for(unsigned chIdx=0; chIdx<chCnt; ++chIdx)
|
||||||
{
|
{
|
||||||
unsigned srcChIdx = p->audioInChMapA == nullptr ? chIdx : p->audioInChMapA[chIdx];
|
unsigned srcChIdx = p->audioInChMapA == nullptr ? chIdx : p->audioInChMapA[chIdx];
|
||||||
|
|
||||||
memcpy(a->audioBuf + chIdx*asrc.dspFrameCnt, asrc.iBufArray[ srcChIdx ], asrc.dspFrameCnt * sizeof(sample_t));
|
if( srcChIdx >= asrc.iBufChCnt )
|
||||||
|
cwLogError(kInvalidArgRC,"Invalid input channel map index:%i >= %i.",srcChIdx,asrc.iBufChCnt);
|
||||||
|
else
|
||||||
|
memcpy(a->audioBuf + chIdx*asrc.dspFrameCnt, asrc.iBufArray[ srcChIdx ], asrc.dspFrameCnt * sizeof(sample_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
a->chCnt = chCnt;
|
a->chCnt = chCnt;
|
||||||
@ -197,31 +202,34 @@ namespace cw
|
|||||||
void _audio_play( audio_record_play_t* p, io::audio_msg_t& adst )
|
void _audio_play( audio_record_play_t* p, io::audio_msg_t& adst )
|
||||||
{
|
{
|
||||||
unsigned adst_idx = 0;
|
unsigned adst_idx = 0;
|
||||||
|
|
||||||
while(adst_idx < adst.dspFrameCnt)
|
if( !p->mute_fl )
|
||||||
{
|
{
|
||||||
am_audio_t* a;
|
while(adst_idx < adst.dspFrameCnt)
|
||||||
unsigned sample_offs = 0;
|
|
||||||
if((a = _am_audio_from_sample_index(p, p->curFrameIdx, sample_offs )) == nullptr )
|
|
||||||
break;
|
|
||||||
|
|
||||||
unsigned n = std::min(a->dspFrameCnt - sample_offs, adst.dspFrameCnt );
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: Verify that this is correct - it looks like sample_offs should have to be incremented
|
|
||||||
|
|
||||||
for(unsigned i=0; i<a->chCnt; ++i)
|
|
||||||
{
|
{
|
||||||
unsigned dstChIdx = p->audioOutChMapA != nullptr && i < p->audioOutChMapN ? p->audioOutChMapA[i] : i;
|
am_audio_t* a;
|
||||||
|
unsigned sample_offs = 0;
|
||||||
|
if((a = _am_audio_from_sample_index(p, p->curFrameIdx, sample_offs )) == nullptr )
|
||||||
|
break;
|
||||||
|
|
||||||
if( dstChIdx < adst.oBufChCnt )
|
unsigned n = std::min(a->dspFrameCnt - sample_offs, adst.dspFrameCnt );
|
||||||
memcpy( adst.oBufArray[ dstChIdx ] + adst_idx, a->audioBuf + sample_offs, n * sizeof(sample_t));
|
|
||||||
|
|
||||||
|
// TODO: Verify that this is correct - it looks like sample_offs should have to be incremented
|
||||||
|
|
||||||
|
for(unsigned i=0; i<a->chCnt; ++i)
|
||||||
|
{
|
||||||
|
unsigned dstChIdx = p->audioOutChMapA != nullptr && i < p->audioOutChMapN ? p->audioOutChMapA[i] : i;
|
||||||
|
|
||||||
|
if( dstChIdx < adst.oBufChCnt )
|
||||||
|
memcpy( adst.oBufArray[ dstChIdx ] + adst_idx, a->audioBuf + sample_offs, n * sizeof(sample_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
p->curFrameIdx += n;
|
||||||
|
adst_idx += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
p->curFrameIdx += n;
|
|
||||||
adst_idx += n;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: zero unused channels
|
// TODO: zero unused channels
|
||||||
|
|
||||||
if( adst_idx < adst.dspFrameCnt )
|
if( adst_idx < adst.dspFrameCnt )
|
||||||
@ -415,9 +423,16 @@ namespace cw
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( m.oBufChCnt > 0 )
|
if( m.oBufChCnt > 0 )
|
||||||
|
{
|
||||||
_audio_play(p,m);
|
_audio_play(p,m);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(unsigned i=0; i<m.oBufChCnt; ++i)
|
||||||
|
memset( m.oBufArray[i], 0, m.dspFrameCnt * sizeof(sample_t));
|
||||||
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -522,6 +537,22 @@ bool cw::audio_record_play::record_state( handle_t h )
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cw::rc_t cw::audio_record_play::set_mute_state( handle_t h, bool mute_fl )
|
||||||
|
{
|
||||||
|
rc_t rc = kOkRC;
|
||||||
|
audio_record_play_t* p = _handleToPtr(h);
|
||||||
|
p->mute_fl = true;
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cw::audio_record_play::mute_state( handle_t h )
|
||||||
|
{
|
||||||
|
rc_t rc = kOkRC;
|
||||||
|
audio_record_play_t* p = _handleToPtr(h);
|
||||||
|
return p->mute_fl;
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
cw::rc_t cw::audio_record_play::save( handle_t h, const char* fn )
|
cw::rc_t cw::audio_record_play::save( handle_t h, const char* fn )
|
||||||
{
|
{
|
||||||
audio_record_play_t* p = _handleToPtr(h);
|
audio_record_play_t* p = _handleToPtr(h);
|
||||||
|
@ -17,6 +17,8 @@ namespace cw
|
|||||||
rc_t clear( handle_t h );
|
rc_t clear( handle_t h );
|
||||||
rc_t set_record_state( handle_t h, bool record_fl );
|
rc_t set_record_state( handle_t h, bool record_fl );
|
||||||
bool record_state( handle_t h );
|
bool record_state( handle_t h );
|
||||||
|
rc_t set_mute_state( handle_t h, bool mute_fl );
|
||||||
|
bool mute_state( handle_t h );
|
||||||
rc_t save( handle_t h, const char* fn );
|
rc_t save( handle_t h, const char* fn );
|
||||||
rc_t open( handle_t h, const char* fn );
|
rc_t open( handle_t h, const char* fn );
|
||||||
double duration_seconds( handle_t h );
|
double duration_seconds( handle_t h );
|
||||||
|
@ -41,6 +41,9 @@ namespace cw
|
|||||||
rc_t set_record_state( handle_t h, bool record_fl );
|
rc_t set_record_state( handle_t h, bool record_fl );
|
||||||
bool record_state( handle_t h );
|
bool record_state( handle_t h );
|
||||||
|
|
||||||
|
rc_t set_mute_state( handle_t h, bool record_fl );
|
||||||
|
bool mute_state( handle_t h );
|
||||||
|
|
||||||
rc_t set_thru_state( handle_t h, bool record_thru );
|
rc_t set_thru_state( handle_t h, bool record_thru );
|
||||||
bool thru_state( handle_t h );
|
bool thru_state( handle_t h );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user