def draw(self): ol.loadIdentity3() ol.loadIdentity() # Grab the raw audio buffers mono = audio_engine.left_buffer() # mono = np.zeros(512) # 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.LINESTRIP) for i in range(0, mono.shape[0]-1, self.subsamp): scale_factor = pow(0.9-abs(self.x_coord),0.5)*2 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()
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)
def draw(self): ol.loadIdentity3() ol.loadIdentity() # Grab the raw audio buffers mono = audio_engine.left_buffer() # mono = np.zeros(512) # 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() ol.loadIdentity3() ol.color3(*(self.color_cycle())) count = 0 while count < mono.shape[0]: ol.begin(ol.LINESTRIP) while self.x_coord < 1.0 and count < mono.shape[0]: scale_factor = pow(1.0 - abs(self.x_coord), 0.5) * 2 #ol.vertex3((self.x_coord, mono[count]*scale_factor, -1)) # Linear ol.vertex3((self.x_coord, tanh(mono[count] * scale_factor), -1)) # Tanh #ol.vertex3((self.x_coord, log(mono[count]*scale_factor+1.0), -1)) # Sigmoid self.x_coord += self.step count = count + self.subsamp ol.end() if self.x_coord >= 1.0: self.x_coord = -1.0 ol.end()
def draw(self): ol.loadIdentity3() ol.loadIdentity() # Grab the raw audio buffers mono = audio_engine.left_buffer() # mono = np.zeros(512) # 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() ol.loadIdentity3() ol.color3(*(self.color_cycle())) count = 0 while count < mono.shape[0]: ol.begin(ol.LINESTRIP) while self.x_coord < 1.0 and count < mono.shape[0]: scale_factor = pow(1.0-abs(self.x_coord),0.5)*2 #ol.vertex3((self.x_coord, mono[count]*scale_factor, -1)) # Linear ol.vertex3((self.x_coord, tanh(mono[count]*scale_factor), -1)) # Tanh #ol.vertex3((self.x_coord, log(mono[count]*scale_factor+1.0), -1)) # Sigmoid self.x_coord += self.step count = count + self.subsamp ol.end() if self.x_coord >= 1.0: self.x_coord = -1.0 ol.end()