@@ -336,6 +336,9 @@ void RecordNode::setParameter(int parameterIndex, float newValue)
336336 std::cout << " Num Recording Processors: " << procInfo.size () << std::endl;
337337 int numRecordedChannels = channelMap.size ();
338338
339+ m_validBlocks.clear ();
340+ m_validBlocks.insertMultiple (0 , false , numRecordedChannels);
341+
339342 // WARNING: If at some point we record at more that one recordEngine at once, we should change this, as using OwnedArrays only works for the first
340343 EVERY_ENGINE->setChannelMapping (channelMap, chanProcessorMap, chanOrderinProc, procInfo);
341344 m_recordThread->setChannelMap (channelMap);
@@ -485,14 +488,34 @@ void RecordNode::process(AudioSampleBuffer& buffer)
485488 int realChan = channelMap[chan];
486489 int nSamples = getNumSamples (realChan);
487490 int timestamp = getTimestamp (realChan);
488- m_dataQueue->writeChannel (buffer, chan, realChan, nSamples, timestamp);
491+ bool shouldWrite = m_validBlocks[chan];
492+ if (!shouldWrite && nSamples > 0 )
493+ {
494+ shouldWrite = true ;
495+ m_validBlocks.set (chan, true );
496+ }
497+
498+ if (shouldWrite)
499+ m_dataQueue->writeChannel (buffer, chan, realChan, nSamples, timestamp);
489500 }
490501
491502 // std::cout << nSamples << " " << samplesWritten << " " << blockIndex << std::endl;
492503 if (!setFirstBlock)
493504 {
494- m_recordThread->setFirstBlockFlag (true );
495- setFirstBlock = true ;
505+ bool shouldSetFlag = true ;
506+ for (int chan = 0 ; chan < recordChans; ++chan)
507+ {
508+ if (!m_validBlocks[chan])
509+ {
510+ shouldSetFlag = false ;
511+ break ;
512+ }
513+ }
514+ if (shouldSetFlag)
515+ {
516+ m_recordThread->setFirstBlockFlag (true );
517+ setFirstBlock = true ;
518+ }
496519 }
497520
498521 }
0 commit comments