| 250 | } |
| 251 | |
| 252 | void audioMenu(float menuColumnWidth) { |
| 253 | ImGui::PushItemWidth(menuColumnWidth); |
| 254 | |
| 255 | if (streamNames.size() == 0) { |
| 256 | return; |
| 257 | } |
| 258 | |
| 259 | if (recording) { style::beginDisabled(); } |
| 260 | if (ImGui::Combo(CONCAT("##_recorder_strm_", name), &streamId, streamNamesTxt.c_str())) { |
| 261 | selectStream(streamNames[streamId]); |
| 262 | config.acquire(); |
| 263 | config.conf[name]["audioStream"] = streamNames[streamId]; |
| 264 | config.release(true); |
| 265 | } |
| 266 | if (recording) { style::endDisabled(); } |
| 267 | |
| 268 | double frameTime = 1.0 / ImGui::GetIO().Framerate; |
| 269 | lvlL = std::max<float>(lvlL - (frameTime * 50.0), -90); |
| 270 | lvlR = std::max<float>(lvlR - (frameTime * 50.0), -90); |
| 271 | |
| 272 | float _lvlL = meter.getLeftLevel(); |
| 273 | float _lvlR = meter.getRightLevel(); |
| 274 | if (_lvlL > lvlL) { lvlL = _lvlL; } |
| 275 | if (_lvlR > lvlR) { lvlR = _lvlR; } |
| 276 | ImGui::VolumeMeter(lvlL, lvlL, -60, 10); |
| 277 | ImGui::VolumeMeter(lvlR, lvlR, -60, 10); |
| 278 | |
| 279 | if (ImGui::SliderFloat(CONCAT("##_recorder_vol_", name), &audioVolume, 0, 1, "")) { |
| 280 | vol.setVolume(audioVolume); |
| 281 | } |
| 282 | ImGui::PopItemWidth(); |
| 283 | |
| 284 | if (!folderSelect.pathIsValid() || selectedStreamName == "") { style::beginDisabled(); } |
| 285 | if (!recording) { |
| 286 | if (ImGui::Button(CONCAT("Record##_recorder_rec_", name), ImVec2(menuColumnWidth, 0))) { |
| 287 | std::lock_guard lck(recMtx); |
| 288 | startRecording(); |
| 289 | } |
| 290 | ImGui::TextColored(ImGui::GetStyleColorVec4(ImGuiCol_Text), "Idle --:--:--"); |
| 291 | } |
| 292 | else { |
| 293 | if (ImGui::Button(CONCAT("Stop##_recorder_rec_", name), ImVec2(menuColumnWidth, 0))) { |
| 294 | std::lock_guard lck(recMtx); |
| 295 | stopRecording(); |
| 296 | } |
| 297 | uint64_t seconds = samplesWritten / (uint64_t)sampleRate; |
| 298 | time_t diff = seconds; |
| 299 | tm *dtm = gmtime(&diff); |
| 300 | ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "Recording %02d:%02d:%02d", dtm->tm_hour, dtm->tm_min, dtm->tm_sec); |
| 301 | } |
| 302 | if (!folderSelect.pathIsValid() || selectedStreamName == "") { style::endDisabled(); } |
| 303 | } |
| 304 | |
| 305 | static void _audioHandler(dsp::stereo_t *data, int count, void *ctx) { |
| 306 | RecorderModule* _this = (RecorderModule*)ctx; |
no test coverage detected