Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void SynthezzitoSource::Execute(AkAudioBuffer* out_pBuffer)
- {
- m_durationHandler.SetDuration(m_pParams->RTPC.fDuration);
- m_durationHandler.ProduceBuffer(out_pBuffer);
- const AkUInt32 uNumChannels = out_pBuffer->NumChannels();
- AkUInt16 uFramesProduced;
- //CUSTOM CODE---------------------------------------------------------------
- static float phase = 0.0f; // Phase of the sine wave, static to maintain value between calls
- float twoPi = 2.0f * 3.1415f; // Constant for 2*pi
- float freq = 440.0f;
- float sampleRate = 48000;
- for (AkUInt32 i = 0; i < uNumChannels; ++i)
- {
- AkReal32* AK_RESTRICT pBuf = (AkReal32* AK_RESTRICT)out_pBuffer->GetChannel(i);
- uFramesProduced = 0;
- while (uFramesProduced < out_pBuffer->uValidFrames)
- {
- // Generate output here
- *pBuf++ = 0.7f * sin(phase);
- phase += twoPi * freq / sampleRate;
- // Wrap the phase to avoid precision issues
- if (phase > twoPi)
- {
- phase -= twoPi;
- }
- ++uFramesProduced;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement