1515#include < QString>
1616#include " config.h"
1717#include " frametrimset.h"
18+ #include " lookup.h"
1819#include " pcmsamplepair.h"
1920#include " samples2audio.h"
2021#include " samples2wav.h"
@@ -48,7 +49,7 @@ class AudioProcessor : public QObject
4849 MIN_LONG_INVALID = 16 , // Minimum length of invalid region to be count as long.
4950 MAX_STRAY_LEN = 24 , // Maximum length of valid region to be count as stray.
5051 MIN_VALID_BEFORE = 3 , // Minimum number of valid data points to keep at the start of the buffer.
51- MAX_RAMP_DOWN = 128 , // Length of ramp-down to mute region (in data points).
52+ MAX_RAMP_DOWN = 192 , // Length of ramp-down to mute region (in data points).
5253 MAX_RAMP_UP = 32 , // Length of ramp-up from mute region (in data points).
5354 CHANNEL_CNT = PCMSamplePair::CH_MAX, // Number of channels for processing.
5455 };
@@ -75,21 +76,22 @@ class AudioProcessor : public QObject
7576private:
7677 SamplesToAudio sc_output; // Handler for soundcard operations.
7778 SamplesToWAV wav_output; // Handler for WAV-file operations.
78- QString file_path;
79- QString file_name;
8079 std::deque<PCMSamplePair> *in_samples; // Input sample pair queue (shared).
8180 QMutex *mtx_samples; // Mutex for input queue.
82- QTimer *tim_outflush;
81+ QTimer *tim_outflush; // Timer for dumping output from cache when input stalles.
82+ QTimer *tim_vu_fade; // Timer for VU levels drop off.
8383 std::deque<PCMSamplePair> prebuffer; // Buffer for input data.
8484 std::deque<PCMSample> channel_bufs[CHANNEL_CNT]; // Per-channel buffers for sample processing.
85- std::deque<CoordinatePair> long_bads[CHANNEL_CNT];
85+ std::deque<CoordinatePair> long_bads[CHANNEL_CNT]; // Per-channel buffers for regions of long invalid samples.
8686 uint8_t log_level; // Level of debug output.
8787 uint8_t mask_mode; // Mode of masking dropouts.
88- uint16_t min_valid_before;
89- uint16_t max_ramp_down;
90- uint16_t max_ramp_up;
88+ uint16_t min_valid_before; // Minimum number of valid data points at the front of the buffer.
89+ uint16_t max_ramp_down; // Length of ramp-down for interpolation from last valid sample into silence (inside invalid region).
90+ uint16_t max_ramp_up; // Length of ramp-up for interpolation from silence (inside invalid region) into first valid sample.
9191 uint64_t sample_index; // Master index for samples for the current file.
9292 uint16_t sample_rate; // Last sample rate.
93+ uint8_t vu_left; // VU-level for the left channel.
94+ uint8_t vu_right; // VU-level for the right channel.
9395 bool file_end; // Detected end of a file.
9496 bool unprocessed; // Are there unprocessed audio samples?
9597 bool remove_stray; // Invalidate stray VALID samples.
@@ -109,21 +111,25 @@ class AudioProcessor : public QObject
109111 uint16_t setInvalids (std::deque<PCMSample> *samples, CoordinatePair &range);
110112 void fixStraySamples (std::deque<PCMSample> *samples, std::deque<CoordinatePair> *regions);
111113 uint16_t clearInvalids (std::deque<PCMSample> *samples, CoordinatePair &range);
112- uint16_t performMute (std::deque<PCMSample> *samples, CoordinatePair &range);
113- uint16_t performLevelHold (std::deque<PCMSample> *samples, CoordinatePair &range);
114- uint16_t performLinearInterpolation (std::deque<PCMSample> *samples, CoordinatePair &range);
114+ uint16_t sampleMute (std::deque<PCMSample> *samples, int16_t offset);
115+ uint16_t rangeMute (std::deque<PCMSample> *samples, CoordinatePair &range);
116+ uint16_t rangeLevelHold (std::deque<PCMSample> *samples, CoordinatePair &range);
117+ uint16_t rangeLinearInterpolation (std::deque<PCMSample> *samples, CoordinatePair &range);
115118 void fixBadSamples (std::deque<PCMSample> *samples);
116119 void dumpPrebuffer ();
117120 void fillBufferForOutput ();
121+ void samplesToVU (PCMSamplePair *in_samples);
118122 void outputWordPair (PCMSamplePair *out_samples);
119123 void outputAudio ();
120124 bool scanBuffer ();
121125 void dumpBuffer ();
122126
123127private slots:
124- void restartFlushTimer ();
125- void actCloseOutput ();
128+ void restartFlushTimer (); // Stop and start flushing timer.
129+ void redirectError (QString); // Receive error message and redirect it.
130+ void actFlushOutput (); // Timer event for flushing buffer.
126131 void livePlayUpdate (bool ); // Emit [guiLivePB] signal to report live playback state.
132+ void updateVUMeters (); // Timer event for VU-meters updating and fading.
127133
128134public slots:
129135 void setLogLevel (uint8_t ); // Set logging level.
@@ -139,9 +145,11 @@ public slots:
139145signals:
140146 void guiAddMask (uint16_t ); // Report new masked samples.
141147 void guiLivePB (bool ); // Report live playback state.
148+ void mediaError (QString); // Error while processing audio.
142149 void newSource (); // Report about changed source.
143- void reqTimerRestart ();
150+ void reqTimerRestart (); // Deffered call for [restartFlushTimer()].
144151 void outSamples (PCMSamplePair); // Copy of outputting samples.
152+ void outVULevels (uint8_t , uint8_t ); // Report VU-meters.
145153 void stopOutput (); // Report about thread terminating.
146154 void finished ();
147155};
0 commit comments