Esempio n. 1
0
    def draw(self):
        ol.loadIdentity3()
        ol.loadIdentity()

        # Grab the raw audio buffers
        newbuffer = audio_engine.mono_buffer()

        # Make sure they aren't empty!!
        if (len(newbuffer) == 0):
            return
        else:
            self.mono = newbuffer

        # Openlase can only draw 30000 points in one cycle (less that
        # that, actually!).  Clear the audio buffer and try again!
        if self.mono.shape[0] > 10000:
            audio_engine.clear_all()

        ol.loadIdentity3()
        ol.color3(*(self.color_cycle()))

        ol.begin(ol.POINTS)
        for i in range(0, self.mono.shape[0]-1, self.SUBSAMP):

            val = tanh(self.mono[i] * self.BOOST)
            val = val * 0.5 + 0.5
            val = val * (self.MAX_SIZE - self.MIN_SIZE) + self.MIN_SIZE
            
            ol.vertex3((cos(self.pos) * val, sin(self.pos) * val, -1))
            
            self.pos = self.pos + self.W / 30000.0;
            while(self.pos >= 2*pi):
                self.pos = self.pos -2*pi
        ol.end()
Esempio n. 2
0
    def draw(self):
        ol.loadIdentity3()
        ol.loadIdentity()

        # Grab the raw audio buffers
        mono = audio_engine.mono_buffer()

        # Make sure they aren't empty!!
        if (mono.shape[0] == 0):
            return

        # Openlase can only draw 30000 points in one cycle (less that
        # that, actually!).  Clear the audio buffer and try again!
        if mono.shape[0] > 10000:
            audio_engine.clear_all()
            return

        ol.loadIdentity3()
        ol.color3(*(self.color_cycle()))

        ol.begin(ol.POINTS)
        for i in range(0, mono.shape[0]-1, self.subsamp):
            scale_factor = pow(0.9-abs(self.x_coord),0.5)
            if (mono[i] <= -1.0):
                mono[i] = 1.0
            ol.vertex3((self.x_coord, tanh(mono[i]*scale_factor), -1))
#            ol.vertex3((self.x_coord, log(mono[i]*scale_factor+1.0), -1))
            self.x_coord = self.x_coord + self.step
            if (self.x_coord > 0.9) : self.x_coord = -0.9
        ol.end()
Esempio n. 3
0
    def draw(self):
        ol.loadIdentity()
        ol.rotate(lux.time / 10)

        # Grab the raw audio buffer
        mono = audio_engine.mono_buffer()

        # Make sure it ain't empty!!
        if mono.shape[0] == 0:
            return

        # Openlase can only draw 30000 points in one cycle (less that
        # that, actually!).  Clear the audio buffer and try again!
        if mono.shape[0] > 10000:
            audio_engine.clear_all()

        ol.color3(*(self.color_cycle()))
        ol.perspective(60, 1, 1, 100)
        ol.translate3((0, 0, -3))

        if (lux.time > self.nextSnapshot):
            #print "snapshot"
            self.nextSnapshot = lux.time + self.interval
            self.currentWave = self.nextWave
            self.nextWave = zeros(shape=(self.renderPointCount))
            # load in new values
            for i in range(int(self.renderPointCount - 1)):
                self.nextWave[i] = mono[i * self.skip] * 2

        # draw shape
        fracIntervalComplete = (
            lux.time - (self.nextSnapshot - self.interval)) / self.interval
        #        print '%f %f %f' % (lux.time,fracIntervalComplete, self.nextSnapshot)
        coordsToRender = zeros(shape=(self.renderPointCount, 2))
        firstVal = None
        for i in range(int(self.renderPointCount - 1)):
            val = ((self.nextWave[i] - self.currentWave[i]) *
                   fracIntervalComplete) + self.currentWave[i]
            if (firstVal is None): firstVal = val
            #print "next: %f  curr:  %f   frac: %f" % (self.nextWave[i], self.currentWave[i], fracIntervalComplete)
            (x, y) = self.doTheTrigStuff(
                val, (float(i) / float(self.renderPointCount)), firstVal)
            coordsToRender[i][0] = x
            coordsToRender[i][1] = y
        coordsToRender[self.renderPointCount - 1] = coordsToRender[0]

        # render shape
        ol.begin(ol.LINESTRIP)
        for i in range(0, int(self.renderPointCount), 1):
            #            print '%f: %f,%f' % (i,coordsToRender[i][0], coordsToRender[i][1])
            ol.vertex((coordsToRender[i][0], coordsToRender[i][1]))
        ol.end()
        ol.vertex((coordsToRender[0][0], coordsToRender[0][1]))
Esempio n. 4
0
    def draw(self):
        ol.loadIdentity()

        ol.rotate(lux.time / 10)

        # Grab the raw audio buffer
        mono = audio_engine.mono_buffer()

        # Make sure it ain't empty!!
        if mono.shape[0] == 0:
            return

        # Openlase can only draw 30000 points in one cycle (less that
        # that, actually!).  Clear the audio buffer and try again!
        if mono.shape[0] > 10000:
            audio_engine.clear_all()
            return

        ol.color3(*(self.color_cycle()))
        ol.perspective(60, 1, 1, 100)
        ol.translate3((0, 0, -3))

        if lux.time > self.nextSnapshot:
            # print "snapshot"
            self.nextSnapshot = lux.time + self.interval
            self.currentWave = self.nextWave
            self.nextWave = zeros(shape=(self.renderPointCount))
            # load in new values
            for i in range(self.renderPointCount - 1):
                self.nextWave[i] = mono[i * self.skip]

        # draw shape
        fracIntervalComplete = (lux.time - (self.nextSnapshot - self.interval)) / self.interval
        #        print '%f %f %f' % (lux.time,fracIntervalComplete, self.nextSnapshot)
        coordsToRender = zeros(shape=(self.renderPointCount, 2))
        firstVal = None
        for i in range(self.renderPointCount - 1):
            val = ((self.nextWave[i] - self.currentWave[i]) * fracIntervalComplete) + self.currentWave[i]
            if firstVal is None:
                firstVal = val
            # print "next: %f  curr:  %f   frac: %f" % (self.nextWave[i], self.currentWave[i], fracIntervalComplete)
            (x, y) = self.doTheTrigStuff(val, (float(i) / float(self.renderPointCount)), firstVal)
            coordsToRender[i][0] = x
            coordsToRender[i][1] = y
        coordsToRender[self.renderPointCount - 1] = coordsToRender[0]

        # render shape
        ol.begin(ol.LINESTRIP)
        for i in range(self.renderPointCount):
            #            print '%f: %f,%f' % (i,coordsToRender[i][0], coordsToRender[i][1])
            ol.vertex((coordsToRender[i][0], coordsToRender[i][1]))
        ol.end()
Esempio n. 5
0
    def get_audio(self):
        # Grab the raw audio buffers
        left = audio_engine.left_buffer()
        right = audio_engine.right_buffer()
        mono = audio_engine.mono_buffer()
        #print mono.shape[0]

        # Make sure they aren't empty!!
        if (mono.shape[0] == 0 or left.shape[0] == 0 or right.shape[0] == 0):
            return

        # Openlase can only draw 30000 points in one cycle (less that
        # that, actually!).  Clear the audio buffer and try again!
        if left.shape[0] > 10000:
            print "too many audio samples"
            audio_engine.clear_all()

        if left.shape[0] != right.shape[0]:
            print "unequal number of samples left/right"
            audio_engine.clear_all()
        return (left, right, mono)
Esempio n. 6
0
    def get_audio(self):
        # Grab the raw audio buffers
        left = audio_engine.left_buffer()
        right = audio_engine.right_buffer()
        mono = audio_engine.mono_buffer()
        #print mono.shape[0]

        # Make sure they aren't empty!!
        if (mono.shape[0] == 0 or left.shape[0] == 0 or right.shape[0] == 0):
            return

        # Openlase can only draw 30000 points in one cycle (less that
        # that, actually!).  Clear the audio buffer and try again!
        if left.shape[0] > 10000:
            print "too many audio samples"
            audio_engine.clear_all()

        if left.shape[0] != right.shape[0]:
            print "unequal number of samples left/right"
            audio_engine.clear_all()
        return (left, right, mono)