void VoiceHandler::process() { global_router_.process(); int polyphony = static_cast<int>(input(kPolyphony)->at(0)); setPolyphony(utils::iclamp(polyphony, 1, polyphony)); for (int i = 0; i < numOutputs(); ++i) { int buffer_size = voice_outputs_[i]->owner->getBufferSize(); memset(output(i)->buffer, 0, buffer_size * sizeof(mopo_float)); } std::list<Voice*>::iterator iter = active_voices_.begin(); while (iter != active_voices_.end()) { Voice* voice = *iter; prepareVoiceTriggers(voice); processVoice(voice); // Remove voice if the right processor has a full silent buffer. if (voice_killer_ && voice->state().event != kVoiceOn && utils::isSilent(voice_killer_->buffer, buffer_size_)) { free_voices_.push_back(voice); iter = active_voices_.erase(iter); } else iter++; } }
void VoiceHandler::processVoice(Voice* voice) { voice->processor()->process(); for (int out = 0; out < numOutputs(); ++out) { int buffer_size = voice_outputs_[out]->owner->getBufferSize(); for (int i = 0; i < buffer_size; ++i) output(out)->buffer[i] += voice_outputs_[out]->buffer[i]; } }
OsStatus MpResource::getCurrentLatency(int &latency, int input, int output) const { if ( input >= 0 && input < numInputs() && output >= 0 && output < numOutputs()) { latency = 0; return OS_SUCCESS; } return OS_NOT_FOUND; }
void BypassRouter::process() { mopo_float should_process = input(kOn)->at(0); if (should_process) ProcessorRouter::process(); else { for (int i = 0; i < numOutputs(); ++i) { memcpy(output(i)->buffer, input(kAudio)->source->buffer, buffer_size_ * sizeof(mopo_float)); } } }
TInt COpenMAXALTestModule::al_audioiodevcapitf_GetDefaultAudioDevices( CStifItemParser& aItem ) { TInt status(KErrNone); XAresult res; TUint deviceId(0); TInt sizeArr(0); XAuint32 devId(0); XAint32 numOutputs(0); XAuint32 deviceIdArr[2]; status = aItem.GetNextInt(deviceId, EHex); if(!status) { devId = deviceId; status = aItem.GetNextInt(sizeArr); if(!status) { numOutputs = sizeArr; if(m_AIODevCapItf) { res = (*m_AIODevCapItf)->GetDefaultAudioDevices( m_AIODevCapItf, devId, &numOutputs, deviceIdArr); status = res; } else { status = KErrNotFound; } } else { if(m_AIODevCapItf) { res = (*m_AIODevCapItf)->GetDefaultAudioDevices( m_AIODevCapItf, devId,&numOutputs, NULL); status = res; } else { status = KErrNotFound; } } } else { status = KErrGeneral; } return status; }
UtlBoolean MprRecorder::doProcessFrame(MpBufPtr inBufs[], MpBufPtr outBufs[], int inBufsSize, int outBufsSize, UtlBoolean isEnabled, int samplesPerFrame, int samplesPerSecond) { int numBytes = 0; int numSamples = 0; MpBufPtr in = NULL; Sample* input; // Lock so that mFileDescriptor and file contents cannot be changed out // from under us while we are updating the file. OsLock lock(mMutex); //try to pass along first input if (inBufsSize > 0) { in = *inBufs; } if (numOutputs() > 0) { if (inBufsSize > 0) *inBufs = NULL; *outBufs = in; } if (!isEnabled) { return TRUE; } if (mFileDescriptor < 0) { OsSysLog::add(FAC_MP, PRI_DEBUG, "MprRecorder::doProcessFrame to disable recording because mFileDescriptor=%d, mStatus=%d", mFileDescriptor, mStatus); disable(RECORD_STOPPED); // just in case... } if (inBufsSize == 0) { // no input buffers, indicate config error disable(INVALID_SETUP); return TRUE; } // maximum record time reached or final silence timeout. if ((0 >= mFramesToRecord--) || (mSilenceLength <= mConsecutiveInactive)) { // Get previous MinVoiceEnergy for debug printouts, and reset it to MIN_SPEECH_ENERGY_THRESHOLD. unsigned long prevValue = MpBuf_setMVE(MIN_SPEECH_ENERGY_THRESHOLD); OsSysLog::add(FAC_MP, PRI_INFO, "MprRecorder::doProcessFrame to disable recording because" " mFramesToRecord=%d, mStatus=%d mSilenceLength=%d," " mConsecutiveInactive=%d, MinVoiceEnergy=%lu", mFramesToRecord, mStatus, mSilenceLength, mConsecutiveInactive, prevValue); disable(RECORD_FINISHED); } else { int bytesWritten = 0; //now write the buffer out if (NULL == in) { in = MpBuf_getFgSilence(); } else { MpBuf_addRef(in); } if (MpBuf_isActiveAudio(in)) { mConsecutiveInactive = 0; } else { mConsecutiveInactive++; } input = MpBuf_getSamples(in); numSamples = MpBuf_getNumSamples(in); numBytes = numSamples * sizeof(Sample); if (mFileDescriptor > -1) { #ifdef __BIG_ENDIAN__ //We are running on a big endian processor - 16-bit samples are in the big endian //byte order - convert them to little endian before writing them to the file. unsigned short *pData; int index; for ( index = 0, pData = (unsigned short *)input; index < numSamples; index++, pData++ ) *pData = htoles(*pData); #endif bytesWritten = write(mFileDescriptor, (char *)input, numBytes); #ifdef __BIG_ENDIAN__ if (numOutputs() > 1) { //There is more than one output - convert the samples back to big endian for ( index = 0, pData = (unsigned short *)input; index < numSamples; index++, pData++ ) *pData = letohs(*pData); } #endif } if (bytesWritten != numBytes) { disable(WRITE_ERROR); } else { mTotalBytesWritten += numBytes; mTotalSamplesWritten += samplesPerFrame; } MpBuf_delRef(in); } return TRUE; }