text
stringlengths 1
93.6k
|
|---|
if self.ratio:
|
data = data / sum(C)
|
self.bars.setOpts(height=data)
|
#self.widget.setData(input_items[0])
|
self.widget.update()
|
def widget(self):
|
return self.plot
|
class UDPSource(Block):
|
channel1 = Output()
|
def init(self):
|
self.channel1.sample_rate = 250.0
|
self.channel1.color = 'orange'
|
self.gr_block = blocks.udp_source(gr.sizeof_float*1, "127.0.0.1", 9999, 1472, True)
|
#class FloatToShort(InOutBlock):
|
# def init(self):
|
# self.gr_block =
|
class AudioSink(Block):
|
input = Input()
|
def init(self):
|
self.gr_block = audio.sink(int(self.input.sample_rate), "", True)
|
import OSC
|
# TODO: Make an OSC Connection class that makes send objects
|
class OSCSend(Block):
|
input = Input()
|
def init(self, address, send_period=0.05):
|
self.samples = int(send_period * self.input.sample_rate)
|
self.client = OSC.OSCClient()
|
self.client.connect(('127.0.0.1', 5510)) # connect to Faust
|
self.address = address
|
self.gr_block.set_history(self.samples)
|
def general_work(self, input_items, output_items):
|
print ('OSCSend work', len(input_items[0]), output_items, input_items[0])
|
self.gr_block.consume_each(self.samples)
|
oscmsg = OSC.OSCMessage()
|
oscmsg.setAddress(self.address)
|
val = input_items[0][self.samples-1]
|
val = val / 6 * 200
|
oscmsg.append(val)
|
self.client.send(oscmsg)
|
return 0
|
class Stream2Vector(Block):
|
input = Input()
|
output = Output(type=(np.float32, 256))
|
def init(self, bins=256, framerate=2):
|
self.num_samples = int(self.input.sample_rate / framerate)
|
self.gr_block.set_history(bins)
|
self.bins = bins
|
def general_work(self, input_items, output_items):
|
self.gr_block.consume_each(self.num_samples)
|
print 'Stream2Vector work', len(input_items[0])
|
#output_items[0][:self.bins] = input_items[0][-self.bins:]
|
output_items[0][0] = input_items[0][-self.bins:]
|
#self.gr_block.produce(0, self.bins)
|
self.gr_block.produce(0, 1)
|
return 0
|
class FFT(Block):
|
input = Input()
|
bins = Output()
|
def init(self, bins=256):
|
self.gr_block = fft.fft_vfc(256, forward=True, window=fft.window.blackmanharris(bins))
|
from blocks import Threshold
|
class top_block(gr.top_block, Qt.QWidget):
|
def __init__(self):
|
gr.top_block.__init__(self, "Top Block")
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.