>>>>> "cybolic" == <[EMAIL PROTECTED]> writes:
>>> cache[track][note][(tick/250)*250][tick]
>>>
>>> I hope you can follow me and would be most gratefull for a
>>> reply.
>> I'm not sure about the (tick/250)*250 part, since it seems to
>> be redundant with indexing by tick.
cybolic> It is used since the tick is a dictionary and not a list,
cybolic> so I have to home in on what notes are displayed on
cybolic> screen by 250, and then iterate through them checking if
cybolic> they exist in the dictionary (by using try: [...] except
cybolic> KeyError: pass).
cybolic> This apears smarter (in my head) that getting the
cybolic> midi-tick of the start of the display, and then iterating
cybolic> through all midi-tick that are displayable on screen,
cybolic> checking if there's a note with cache.index(tick),
cybolic> because since the program can zoom, thousands of
cybolic> midi-ticks can be displayed on screen.
I don't know anything about midi, and don't fully understand what you
are trying to do, but some of what you are writing about appears
similar to some issues I had with a plotting library with pan and zoom
features. My data sets are quite large, and only a small subset are
plotted to the screen at once. The x and y data are stored in numeric
arrays. I keep track of whether the x data is sorted (it almost
always in my app) because then I can use a binary search algorithm to
select the data in the viewport.
After each zoom or pan event, I decide which data points are in the
viewport using the Numeric search routines, which are implemented in
C. If the x data is sorted, searchsorted is extremely fast
# xmin and xmax are the viewport bounds
if self._xsorted:
inds = numpy.searchsorted(
self._x, numpy.array([self._xmin, self._xmax]))
indx = numpy.arange(inds[0], inds[1])
else:
indx = numpy.nonzero(
numpy.logical_and( self._x>=self._xmin,
self._x<=self._xmax ))
self._xc = numpy.take(self._x, indx)
self._yc = numpy.take(self._y, indx)
JDH
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/