| 100 | } |
| 101 | |
| 102 | void flushDebugBuffer(char const* const wavFilePath) |
| 103 | { |
| 104 | if (!debugBufferIndex || !wavFilePath) |
| 105 | return; |
| 106 | |
| 107 | nqr::AudioData fileData; |
| 108 | fileData.samples.resize(debugBufferIndex + 32); |
| 109 | fileData.channelCount = 1; |
| 110 | float* dst = fileData.samples.data(); |
| 111 | memcpy(dst, debugBuffer.data(), sizeof(float) * debugBufferIndex); |
| 112 | fileData.sampleRate = static_cast<int>(44100); |
| 113 | fileData.sourceFormat = nqr::PCM_FLT; |
| 114 | nqr::EncoderParams params = { 1, nqr::PCM_FLT, nqr::DITHER_NONE }; |
| 115 | int err = nqr::encode_wav_to_disk(params, &fileData, wavFilePath); |
| 116 | debugBufferIndex = 0; |
| 117 | } |
| 118 | }; |
| 119 | |
| 120 | void AudioContext::appendDebugBuffer(AudioBus* bus, int channel, int count) |