populate lineshape display
This commit is contained in:
parent
17cd2f28da
commit
1e84520a5f
42
main.cpp
42
main.cpp
|
@ -97,6 +97,31 @@ static void poh_thread()
|
|||
}
|
||||
}
|
||||
|
||||
static std::atomic<bool> ls_accept_input;
|
||||
static std::binary_semaphore ls_input_ready{0};
|
||||
static std::complex<float> ls_input_block[block_len];
|
||||
static std::mutex wf_ls_mutex;
|
||||
static unsigned int wf_ls[wf_width*wf_height];
|
||||
|
||||
static void ls_thread()
|
||||
{
|
||||
std::vector<float> block_mag(block_len);
|
||||
|
||||
while(!shutdown_threads) {
|
||||
ls_accept_input = true;
|
||||
ls_input_ready.acquire();
|
||||
fft_mag(ls_input_block, block_mag.data(), block_len);
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(wf_ls_mutex);
|
||||
std::memmove(&wf_ls[wf_width], &wf_ls[0], sizeof(int)*wf_width*(wf_height - 1));
|
||||
for(int i=0;i<wf_width;i++) {
|
||||
int j = i*block_len/wf_width;
|
||||
wf_ls[i] = 0xff000000 | 0x010101*std::min(int(block_mag[j]/900.0f), 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static std::atomic<int> frames_processed;
|
||||
static std::atomic<int> frames_dropped;
|
||||
|
||||
|
@ -107,15 +132,16 @@ static int brf_frames_dropped_cnt = 0;
|
|||
static void* brf_dispatch(struct bladerf* dev, struct bladerf_stream* stream,
|
||||
struct bladerf_metadata* meta, void* samples_v, size_t num_samples, void* user_data)
|
||||
{
|
||||
if(poh_accept_input) {
|
||||
if(poh_accept_input && ls_accept_input) {
|
||||
std::complex<int16_t>* samples = (std::complex<int16_t>*)samples_v;
|
||||
|
||||
for(size_t i=0;i<block_len;i++) {
|
||||
poh_input_block[i] = samples[2*i];
|
||||
ls_input_block[i] = samples[2*i+1];
|
||||
}
|
||||
|
||||
poh_accept_input = false;
|
||||
poh_input_ready.release();
|
||||
ls_accept_input = false;
|
||||
ls_input_ready.release();
|
||||
brf_frames_processed_cnt++;
|
||||
} else
|
||||
brf_frames_dropped_cnt++;
|
||||
|
@ -261,6 +287,12 @@ int main(int argc, char* argv[])
|
|||
};
|
||||
std::atexit(JoinPOH);
|
||||
|
||||
static std::thread ls_thread_h = std::thread(ls_thread);
|
||||
static auto JoinLS = []() {
|
||||
ls_thread_h.join();
|
||||
};
|
||||
std::atexit(JoinLS);
|
||||
|
||||
static std::thread tec_thread_h = std::thread(tec_thread);
|
||||
static auto JoinTEC = []() {
|
||||
tec_thread_h.join();
|
||||
|
@ -294,8 +326,8 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
glBindTexture(GL_TEXTURE_2D, wftex[1]);
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(wf_poh_mutex);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, wf_width, wf_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, wf_poh);
|
||||
std::lock_guard<std::mutex> guard(wf_ls_mutex);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, wf_width, wf_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, wf_ls);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue