| 72 | } |
| 73 | |
| 74 | void Vocoder::Process(double time) |
| 75 | { |
| 76 | PROFILER(Vocoder); |
| 77 | |
| 78 | IAudioReceiver* target = GetTarget(); |
| 79 | |
| 80 | if (target == nullptr) |
| 81 | return; |
| 82 | |
| 83 | SyncBuffers(); |
| 84 | |
| 85 | if (!mEnabled) |
| 86 | { |
| 87 | for (int ch = 0; ch < GetBuffer()->NumActiveChannels(); ++ch) |
| 88 | { |
| 89 | Add(target->GetBuffer()->GetChannel(ch), GetBuffer()->GetChannel(ch), GetBuffer()->BufferSize()); |
| 90 | GetVizBuffer()->WriteChunk(GetBuffer()->GetChannel(ch), GetBuffer()->BufferSize(), ch); |
| 91 | } |
| 92 | |
| 93 | GetBuffer()->Reset(); |
| 94 | return; |
| 95 | } |
| 96 | |
| 97 | ComputeSliders(0); |
| 98 | |
| 99 | float inputPreampSq = mInputPreamp * mInputPreamp; |
| 100 | float carrierPreampSq = mCarrierPreamp * mCarrierPreamp; |
| 101 | float volSq = mVolume * mVolume; |
| 102 | |
| 103 | int bufferSize = GetBuffer()->BufferSize(); |
| 104 | |
| 105 | int zerox = 0; //count up zero crossings |
| 106 | bool positive = true; |
| 107 | for (int i = 0; i < bufferSize; ++i) |
| 108 | { |
| 109 | if ((GetBuffer()->GetChannel(0)[i] < 0 && positive) || |
| 110 | (GetBuffer()->GetChannel(0)[i] > 0 && !positive)) |
| 111 | { |
| 112 | ++zerox; |
| 113 | positive = !positive; |
| 114 | } |
| 115 | } |
| 116 | bool fricative = zerox > (bufferSize * mFricativeThresh); //if a % of the samples are zero crossings, this is a fricative |
| 117 | if (fricative) |
| 118 | mFricDetected = true; //draw that we detected a fricative |
| 119 | |
| 120 | mGate.ProcessAudio(time, GetBuffer()); |
| 121 | |
| 122 | mRollingInputBuffer.WriteChunk(GetBuffer()->GetChannel(0), bufferSize, 0); |
| 123 | |
| 124 | //copy rolling input buffer into working buffer and window it |
| 125 | mRollingInputBuffer.ReadChunk(mFFTData.mTimeDomain, VOCODER_WINDOW_SIZE, 0, 0); |
| 126 | Mult(mFFTData.mTimeDomain, mWindower, VOCODER_WINDOW_SIZE); |
| 127 | Mult(mFFTData.mTimeDomain, inputPreampSq, VOCODER_WINDOW_SIZE); |
| 128 | |
| 129 | mFFT.Forward(mFFTData.mTimeDomain, |
| 130 | mFFTData.mRealValues, |
| 131 | mFFTData.mImaginaryValues); |
nothing calls this directly
no test coverage detected