* @brief Builds an audio-specific Quick Plot frame with FFT configuration. */
| 1747 | * @brief Builds an audio-specific Quick Plot frame with FFT configuration. |
| 1748 | */ |
| 1749 | void DataModel::FrameBuilder::buildQuickPlotAudioFrame(const QStringList& channels) |
| 1750 | { |
| 1751 | Q_ASSERT(!channels.isEmpty()); |
| 1752 | Q_ASSERT(AppState::instance().operationMode() == SerialStudio::QuickPlot); |
| 1753 | |
| 1754 | #ifdef BUILD_COMMERCIAL |
| 1755 | const auto* audioPtr = IO::ConnectionManager::instance().audio(); |
| 1756 | if (!audioPtr) |
| 1757 | return; |
| 1758 | |
| 1759 | const auto& audio = *audioPtr; |
| 1760 | const auto format = audio.config().capture.format; |
| 1761 | const auto sampleRate = audio.config().sampleRate; |
| 1762 | |
| 1763 | double maxValue = 1.0; |
| 1764 | double minValue = 0.0; |
| 1765 | switch (format) { |
| 1766 | case ma_format_u8: |
| 1767 | maxValue = 255; |
| 1768 | minValue = 0; |
| 1769 | break; |
| 1770 | case ma_format_s16: |
| 1771 | maxValue = 32767; |
| 1772 | minValue = -32768; |
| 1773 | break; |
| 1774 | case ma_format_s24: |
| 1775 | maxValue = 8388607; |
| 1776 | minValue = -8388608; |
| 1777 | break; |
| 1778 | case ma_format_s32: |
| 1779 | maxValue = 2147483647; |
| 1780 | minValue = -2147483648; |
| 1781 | break; |
| 1782 | case ma_format_f32: |
| 1783 | maxValue = 1.0; |
| 1784 | minValue = -1.0; |
| 1785 | break; |
| 1786 | default: |
| 1787 | break; |
| 1788 | } |
| 1789 | |
| 1790 | const int targetSamples = static_cast<int>(sampleRate * 0.05); |
| 1791 | int fftSamples = 256; |
| 1792 | while (fftSamples < targetSamples && fftSamples < 8192) |
| 1793 | fftSamples *= 2; |
| 1794 | |
| 1795 | const bool multipleChannels = channels.count() > 1; |
| 1796 | int index = 1; |
| 1797 | std::vector<DataModel::Dataset> datasets; |
| 1798 | datasets.reserve(channels.count()); |
| 1799 | for (const auto& channel : std::as_const(channels)) { |
| 1800 | DataModel::Dataset dataset; |
| 1801 | dataset.fft = true; |
| 1802 | dataset.plt = !multipleChannels; |
| 1803 | dataset.groupId = 0; |
| 1804 | dataset.datasetId = index - 1; |
| 1805 | dataset.uniqueId = dataset_unique_id(0, 0, index - 1); |
| 1806 | dataset.index = index; |
nothing calls this directly
no test coverage detected