[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9016 - in gnuradio/branches/features/experimental-gui
From: |
jblum |
Subject: |
[Commit-gnuradio] r9016 - in gnuradio/branches/features/experimental-gui: . plotter |
Date: |
Fri, 25 Jul 2008 15:09:40 -0600 (MDT) |
Author: jblum
Date: 2008-07-25 15:09:39 -0600 (Fri, 25 Jul 2008)
New Revision: 9016
Modified:
gnuradio/branches/features/experimental-gui/plotter/waterfall_plotter.py
gnuradio/branches/features/experimental-gui/waterfall_window.py
Log:
waterfall plotter less trouble
Modified:
gnuradio/branches/features/experimental-gui/plotter/waterfall_plotter.py
===================================================================
--- gnuradio/branches/features/experimental-gui/plotter/waterfall_plotter.py
2008-07-25 19:36:24 UTC (rev 9015)
+++ gnuradio/branches/features/experimental-gui/plotter/waterfall_plotter.py
2008-07-25 21:09:39 UTC (rev 9016)
@@ -44,14 +44,15 @@
self._num_frames = 256
self._frame_ptr = 0
self._buffer_init = False
+ self._waterfall_buffer_top = GLuint(0)
+ self._waterfall_buffer_bottom = GLuint(0)
+ self._data_queue = list()
def _gl_init(self):
"""!
Run gl initialization tasks.
"""
self._grid_compiled_list_id = glGenLists(1)
- self._waterfall_buffer_top = GLuint(0)
- self._waterfall_buffer_bottom = GLuint(0)
glGenBuffers(1, self._waterfall_buffer_top)
glGenBuffers(1, self._waterfall_buffer_bottom)
self._buffer_init = True
@@ -90,6 +91,7 @@
Draw the waterfall display using pixels from the PBO.
The pixels will be scaled to fit within the grid area.
"""
+ self._update_data()
if self._fft_size is None: return
#pixel zoom
x_zoom =
float(self.width-self.padding_left-self.padding_right)/self._fft_size
@@ -105,53 +107,60 @@
glDrawPixels(self._fft_size, self._frame_ptr, GL_RGBA,
GL_UNSIGNED_BYTE, None)
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0) #unbind
- def plot_samples(self, samples, min, max):
+ def _update_data(self):
"""!
- Plot the samples onto a time slice of the waterfall.
- Create or recreate the PBO when the fft size or number of
frames changes.
- Convert the samples to color data.
- @param samples the array of floats
- @param min the minimum value to scale
- @param max the maximum value to scale
+ Set all of the samples in the data queue to pixel buffer.
"""
- self.semaphore.acquire(True)
- #init or reinit the pixel buffer
- if self._buffer_init and len(samples) != self._fft_size:
- self._fft_size = len(samples)
- #initial data
- data = numpy.zeros(self._fft_size*self._num_frames*4,
numpy.uint8).tostring()
+ while self._data_queue:
+ data = self._data_queue.pop(0)
+ #init or reinit the pixel buffer
+ if self._buffer_init and len(data)/4 != self._fft_size:
+ self._fft_size = len(data)/4
+ #initial data
+ init_data =
numpy.zeros(self._fft_size*self._num_frames*4, numpy.uint8).tostring()
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB,
self._waterfall_buffer_top)
+ glBufferData(
+ GL_PIXEL_UNPACK_BUFFER_ARB,
+ len(init_data), init_data,
+ GL_STATIC_DRAW,
+ )
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB,
self._waterfall_buffer_bottom)
+ glBufferData(
+ GL_PIXEL_UNPACK_BUFFER_ARB,
+ len(init_data), init_data,
+ GL_STATIC_DRAW,
+ )
+ #load the color data into the pixel buffers
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB,
self._waterfall_buffer_top)
- glBufferData(
+ glBufferSubData(
GL_PIXEL_UNPACK_BUFFER_ARB,
+
(self._num_frames-self._frame_ptr-1)*self._fft_size*4,
len(data), data,
- GL_STATIC_DRAW,
)
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB,
self._waterfall_buffer_bottom)
- glBufferData(
+ glBufferSubData(
GL_PIXEL_UNPACK_BUFFER_ARB,
+ self._frame_ptr*self._fft_size*4,
len(data), data,
- GL_STATIC_DRAW,
)
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0) #unbind
+ #increment the pointer
+ self._frame_ptr = (self._frame_ptr + 1)%self._num_frames
+
+ def set_samples(self, samples, min, max):
+ """!
+ Set the samples to the waterfall.
+ Convert the samples to color data.
+ @param samples the array of floats
+ @param min the minimum value to scale
+ @param max the maximum value to scale
+ """
+ self.semaphore.acquire(True)
#normalize the samples to min/max
samples = (samples - min)*float(255/(max-min))
samples = numpy.minimum(samples, 255) #clip
samples = numpy.maximum(samples, 0) #clip
samples = numpy.array(samples, numpy.uint8)
data = numpy.array([RGBA_ARRAY[sample] for sample in
samples]).tostring()
- #load the color data into the pixel buffers
- glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB,
self._waterfall_buffer_top)
- glBufferSubData(
- GL_PIXEL_UNPACK_BUFFER_ARB,
- (self._num_frames-self._frame_ptr-1)*self._fft_size*4,
- len(data), data,
- )
- glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB,
self._waterfall_buffer_bottom)
- glBufferSubData(
- GL_PIXEL_UNPACK_BUFFER_ARB,
- self._frame_ptr*self._fft_size*4,
- len(data), data,
- )
- glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0) #unbind
- #increment the pointer
- self._frame_ptr = (self._frame_ptr + 1)%self._num_frames
+ self._data_queue.append(data)
self.semaphore.release()
Modified: gnuradio/branches/features/experimental-gui/waterfall_window.py
===================================================================
--- gnuradio/branches/features/experimental-gui/waterfall_window.py
2008-07-25 19:36:24 UTC (rev 9015)
+++ gnuradio/branches/features/experimental-gui/waterfall_window.py
2008-07-25 21:09:39 UTC (rev 9016)
@@ -192,7 +192,7 @@
if self.real: samples = samples[:num_samps/2]
else: samples = numpy.concatenate((samples[num_samps/2+1:],
samples[:num_samps/2]))
#plot the fft
- self.plotter.plot_samples(
+ self.plotter.set_samples(
samples, self.controller[REF_LEVEL_KEY],
self.controller[Y_PER_DIV_KEY]*self.controller[Y_DIVS_KEY] +
self.controller[REF_LEVEL_KEY],
)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9016 - in gnuradio/branches/features/experimental-gui: . plotter,
jblum <=