MCPcopy Create free account
hub / github.com/bbc/audiowaveform / run

Method run

src/VectorAudioFileReader.cpp:64–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62//------------------------------------------------------------------------------
63
64bool VectorAudioFileReader::run(AudioProcessor& processor)
65{
66 ProgressReporter progress_reporter;
67
68 const size_t BUFFER_SIZE = 16384;
69
70 const size_t total_frames = samples_.size() / channels_;
71 size_t frames_to_read = total_frames;
72 size_t index = 0;
73 size_t total_frames_read = 0;
74
75 bool success = processor.init(sample_rate_, channels_, total_frames, BUFFER_SIZE);
76
77 if (success && processor.shouldContinue()) {
78 progress_reporter.update(0.0, 0, total_frames);
79
80 while (success && frames_to_read > 0) {
81 size_t max_frames = BUFFER_SIZE / channels_;
82 size_t frames = frames_to_read > max_frames ? max_frames : frames_to_read;
83
84 success = processor.process(
85 &samples_[index],
86 static_cast<int>(frames)
87 );
88
89 total_frames_read += frames;
90 index += frames * channels_;
91 frames_to_read -= frames;
92
93 double seconds = static_cast<double>(total_frames_read) / static_cast<double>(sample_rate_);
94
95 progress_reporter.update(seconds, total_frames_read, total_frames);
96 }
97
98 log(Info) << '\n';
99
100 processor.done();
101 }
102
103 close();
104
105 return success;
106}
107
108//------------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 5

updateMethod · 0.80
initMethod · 0.45
shouldContinueMethod · 0.45
processMethod · 0.45
doneMethod · 0.45

Tested by

no test coverage detected