mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-02-03 09:44:26 -05:00
Staggered tile updates and moving texture window to eliminate constant memmove() for animation
This commit is contained in:
parent
1e50f13c1b
commit
6d0fc54400
@ -398,7 +398,6 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
|
||||
// spectrumCanvas->setData(iqData);
|
||||
waterfallCanvas->setData(iqData);
|
||||
demodWaterfallCanvas->setData(iqData);
|
||||
delete iqData;
|
||||
} else {
|
||||
std::cout << "Incoming IQ data empty?" << std::endl;
|
||||
}
|
||||
@ -419,8 +418,6 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
|
||||
}
|
||||
|
||||
scopeCanvas->setStereo(demodAudioData->channels == 2);
|
||||
|
||||
delete demodAudioData;
|
||||
} else {
|
||||
std::cout << "Incoming Demodulator data empty?" << std::endl;
|
||||
}
|
||||
|
@ -90,6 +90,9 @@ void DemodulatorThread::threadMain() {
|
||||
iqAutoGain = agc_crcf_create();
|
||||
agc_crcf_set_bandwidth(iqAutoGain, 0.9);
|
||||
|
||||
AudioThreadInput *ati_vis = new AudioThreadInput;
|
||||
ati_vis->data.reserve(DEMOD_VIS_SIZE);
|
||||
|
||||
std::cout << "Demodulator thread started.." << std::endl;
|
||||
|
||||
terminated = false;
|
||||
@ -294,7 +297,6 @@ void DemodulatorThread::threadMain() {
|
||||
}
|
||||
|
||||
if (ati && audioVisOutputQueue != NULL && audioVisOutputQueue->empty()) {
|
||||
AudioThreadInput *ati_vis = new AudioThreadInput;
|
||||
|
||||
int num_vis = DEMOD_VIS_SIZE;
|
||||
if (stereo) {
|
||||
@ -303,6 +305,7 @@ void DemodulatorThread::threadMain() {
|
||||
if (stereoSize > DEMOD_VIS_SIZE) {
|
||||
stereoSize = DEMOD_VIS_SIZE;
|
||||
}
|
||||
|
||||
ati_vis->data.resize(stereoSize);
|
||||
|
||||
for (int i = 0; i < stereoSize / 2; i++) {
|
||||
@ -406,6 +409,8 @@ void DemodulatorThread::threadMain() {
|
||||
delete audioDataDel;
|
||||
}
|
||||
|
||||
delete ati_vis;
|
||||
|
||||
DemodulatorThreadCommand tCmd(DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_TERMINATED);
|
||||
tCmd.context = this;
|
||||
threadQueueNotify->push(tCmd);
|
||||
|
@ -55,6 +55,8 @@ void SDRPostThread::threadMain() {
|
||||
|
||||
dcFilter = iirfilt_crcf_create_dc_blocker(0.0005);
|
||||
|
||||
DemodulatorThreadIQData *visualDataOut = new DemodulatorThreadIQData;
|
||||
|
||||
std::cout << "SDR post-processing thread started.." << std::endl;
|
||||
|
||||
std::deque<DemodulatorThreadIQData *> buffers;
|
||||
@ -96,7 +98,13 @@ void SDRPostThread::threadMain() {
|
||||
}
|
||||
|
||||
if (iqVisualQueue != NULL && iqVisualQueue.load()->empty()) {
|
||||
DemodulatorThreadIQData *visualDataOut = new DemodulatorThreadIQData;
|
||||
if (visualDataOut->data.size() < num_vis_samples) {
|
||||
if (visualDataOut->data.capacity() < num_vis_samples) {
|
||||
visualDataOut->data.reserve(num_vis_samples);
|
||||
}
|
||||
visualDataOut->data.resize(num_vis_samples);
|
||||
}
|
||||
|
||||
visualDataOut->frequency = data_in->frequency;
|
||||
visualDataOut->sampleRate = data_in->sampleRate;
|
||||
visualDataOut->data.assign(dataOut.begin(), dataOut.begin() + num_vis_samples);
|
||||
@ -201,6 +209,8 @@ void SDRPostThread::threadMain() {
|
||||
// delete demodDataDel;
|
||||
}
|
||||
|
||||
delete visualDataOut;
|
||||
|
||||
std::cout << "SDR post-processing thread done." << std::endl;
|
||||
}
|
||||
|
||||
|
@ -25,9 +25,12 @@ void WaterfallContext::Setup(int fft_size_in, int num_waterfall_lines_in) {
|
||||
delete waterfall_tex[i];
|
||||
}
|
||||
|
||||
waterfall_tex[i] = new unsigned char[half_fft_size * waterfall_lines];
|
||||
memset(waterfall_tex[i], 0, half_fft_size * waterfall_lines);
|
||||
waterfall_tex[i] = new unsigned char[half_fft_size * waterfall_lines * 2];
|
||||
memset(waterfall_tex[i], 0, half_fft_size * waterfall_lines * 2);
|
||||
}
|
||||
// Stagger memory updates at half intervals for tiles
|
||||
waterfall_ofs[0] = waterfall_lines;
|
||||
waterfall_ofs[1] = waterfall_lines - waterfall_lines / 8;
|
||||
}
|
||||
|
||||
void WaterfallContext::refreshTheme() {
|
||||
@ -71,51 +74,70 @@ void WaterfallContext::Draw(std::vector<float> &points) {
|
||||
|
||||
if (points.size()) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
memmove(waterfall_tex[j] + half_fft_size, waterfall_tex[j], (waterfall_lines - 1) * half_fft_size);
|
||||
|
||||
int ofs = waterfall_ofs[j];
|
||||
for (int i = 0, iMax = half_fft_size; i < iMax; i++) {
|
||||
float v = points[(j * half_fft_size + i) * 2 + 1];
|
||||
|
||||
float wv = v;
|
||||
if (wv < 0.0)
|
||||
wv = 0.0;
|
||||
if (wv > 0.99)
|
||||
wv = 0.99;
|
||||
waterfall_tex[j][i] = (unsigned char) floor(wv * 255.0);
|
||||
float wv = v < 0 ? 0 : (v > 0.99 ? 0.99 : v);
|
||||
|
||||
waterfall_tex[j][i + ofs * half_fft_size] = (unsigned char) floor(wv * 255.0);
|
||||
}
|
||||
|
||||
int quarter_lines = (waterfall_lines / 4);
|
||||
int k = 4;
|
||||
while (k--) {
|
||||
if (waterfall_ofs[j] == quarter_lines * k) {
|
||||
memcpy(waterfall_tex[j] + (waterfall_lines * half_fft_size) + (quarter_lines * k * half_fft_size),
|
||||
waterfall_tex[j] + (quarter_lines * k * half_fft_size), quarter_lines * half_fft_size);
|
||||
}
|
||||
}
|
||||
|
||||
if (waterfall_ofs[j] == 0) {
|
||||
waterfall_ofs[j] = waterfall_lines;
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, waterfall[j]);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, half_fft_size, waterfall_lines, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE,
|
||||
(GLvoid *) (waterfall_tex[j] + (half_fft_size * (waterfall_ofs[j]))));
|
||||
|
||||
waterfall_ofs[j]--;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
glBindTexture(GL_TEXTURE_2D, waterfall[i]);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, half_fft_size, waterfall_lines, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, (GLvoid *) waterfall_tex[i]);
|
||||
}
|
||||
|
||||
glColor3f(1.0, 1.0, 1.0);
|
||||
|
||||
GLint vp[4];
|
||||
glGetIntegerv( GL_VIEWPORT, vp);
|
||||
|
||||
float viewWidth = (float) vp[2];
|
||||
|
||||
// some bias to prevent seams at odd scales
|
||||
float half_pixel = 1.0 / (float) viewWidth;
|
||||
float half_texel = 1.0 / (float) half_fft_size;
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, waterfall[0]);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0, 1.0);
|
||||
glTexCoord2f(0.0 + half_texel, 1.0 - half_texel);
|
||||
glVertex3f(-1.0, -1.0, 0.0);
|
||||
glTexCoord2f(1.0, 1.0);
|
||||
glVertex3f(0.0, -1.0, 0.0);
|
||||
glTexCoord2f(1.0, 0.0);
|
||||
glVertex3f(0.0, 1.0, 0.0);
|
||||
glTexCoord2f(0.0, 0.0);
|
||||
glTexCoord2f(1.0 - half_texel, 1.0 - half_texel);
|
||||
glVertex3f(0.0 + half_pixel, -1.0, 0.0);
|
||||
glTexCoord2f(1.0 - half_texel, 0.0 + half_texel);
|
||||
glVertex3f(0.0 + half_pixel, 1.0, 0.0);
|
||||
glTexCoord2f(0.0 + half_texel, 0.0 + half_texel);
|
||||
glVertex3f(-1.0, 1.0, 0.0);
|
||||
glEnd();
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, waterfall[1]);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0, 1.0);
|
||||
glVertex3f(0.0, -1.0, 0.0);
|
||||
glTexCoord2f(1.0, 1.0);
|
||||
glTexCoord2f(0.0 + half_texel, 1.0 - half_texel);
|
||||
glVertex3f(0.0 - half_pixel, -1.0, 0.0);
|
||||
glTexCoord2f(1.0 - half_texel, 1.0 - half_texel);
|
||||
glVertex3f(1.0, -1.0, 0.0);
|
||||
glTexCoord2f(1.0, 0.0);
|
||||
glTexCoord2f(1.0 - half_texel, 0.0 + half_texel);
|
||||
glVertex3f(1.0, 1.0, 0.0);
|
||||
glTexCoord2f(0.0, 0.0);
|
||||
glVertex3f(0.0, 1.0, 0.0);
|
||||
glTexCoord2f(0.0 + half_texel, 0.0 + half_texel);
|
||||
glVertex3f(0.0 - half_pixel, 1.0, 0.0);
|
||||
glEnd();
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
@ -17,6 +17,7 @@ public:
|
||||
private:
|
||||
GLuint waterfall[2];
|
||||
unsigned char *waterfall_tex[2];
|
||||
int waterfall_ofs[2];
|
||||
int fft_size;
|
||||
int waterfall_lines;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user