MCPcopy Create free account
hub / github.com/FastLED/FastLED / updateInternal

Method updateInternal

src/platforms/shared/ui/json/audio_internal.cpp.hpp:23–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23void JsonUiAudioInternal::updateInternal(const fl::json &value) FL_NOEXCEPT {
24 if (value.contains("audioData")) {
25 fl::json audioDataArray = value["audioData"];
26
27 if (audioDataArray.is_array()) {
28 for (size_t i = 0; i < audioDataArray.size(); ++i) {
29 fl::json bufferJson = audioDataArray[i];
30 if (bufferJson.is_object()) {
31 fl::vector<i16> samples;
32 u32 timestamp = bufferJson["timestamp"] | 0;
33
34 if (bufferJson.contains("samples") &&
35 bufferJson["samples"].is_array()) {
36 fl::json samplesArray = bufferJson["samples"];
37 for (size_t j = 0; j < samplesArray.size(); ++j) {
38 samples.push_back(samplesArray[j] | 0);
39 }
40 }
41 // Create AudioBuffer equivalent and process
42 // This part of the loop is now inside the if
43 // (bufferJson.is_object()) and directly uses 'samples' and
44 // 'timestamp'
45 const fl::vector<i16> &current_samples = samples;
46 u32 current_timestamp = timestamp;
47
48 if (!current_samples.empty()) {
49 audio::SampleImplPtr sample =
50 fl::make_shared<audio::SampleImpl>();
51 sample->assign(current_samples.begin(),
52 current_samples.end(),
53 current_timestamp);
54 mAudioSampleImpls.push_back(sample);
55
56 while (mAudioSampleImpls.size() > 10) {
57 mAudioSampleImpls.erase(mAudioSampleImpls.begin());
58 }
59 }
60 }
61 }
62 }
63 }
64}
65} // namespace fl

Callers 1

executeUiUpdatesMethod · 0.45

Calls 10

containsMethod · 0.45
is_arrayMethod · 0.45
sizeMethod · 0.45
is_objectMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45
assignMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected