| 51 | } |
| 52 | |
| 53 | void Metronome::Process(double time) |
| 54 | { |
| 55 | PROFILER(Metronome); |
| 56 | |
| 57 | IAudioReceiver* target = GetTarget(); |
| 58 | |
| 59 | if (!mEnabled || target == nullptr) |
| 60 | return; |
| 61 | |
| 62 | int bufferSize = target->GetBuffer()->BufferSize(); |
| 63 | float* out = target->GetBuffer()->GetChannel(0); |
| 64 | assert(bufferSize == gBufferSize); |
| 65 | |
| 66 | for (int i = 0; i < bufferSize; ++i) |
| 67 | { |
| 68 | float sample = mOsc.Audio(time, mPhase) * mVolume / 10; |
| 69 | out[i] += sample; |
| 70 | GetVizBuffer()->Write(sample, 0); |
| 71 | |
| 72 | mPhase += mPhaseInc; |
| 73 | while (mPhase > FTWO_PI) |
| 74 | { |
| 75 | mPhase -= FTWO_PI; |
| 76 | } |
| 77 | |
| 78 | time += gInvSampleRateMs; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | void Metronome::OnTimeEvent(double time) |
| 83 | { |
nothing calls this directly
no test coverage detected