def gapped_complex_test_src(pipeline, buffer_length=1.0, rate=2048, width=64, test_duration=10.0, wave=5, freq=0, gap_frequency=None, gap_threshold=None, control_dump_filename=None, tags=None, is_live=False, verbose=True): src = complex_test_src(pipeline, buffer_length=buffer_length, rate=rate, width=width, test_duration=test_duration, wave=wave, freq=freq, is_live=is_live, verbose=verbose) if tags is not None: src = pipeparts.mktaginject(pipeline, src, tags) if gap_frequency is None: return src control = pipeparts.mkcapsfilter( pipeline, pipeparts.mkaudiotestsrc(pipeline, wave=0, freq=gap_frequency, blocksize=8 * int(buffer_length * rate), volume=1, num_buffers=int(test_duration / buffer_length)), "audio/x-raw, format=F32%s, rate=%d, channels=1" % (BYTE_ORDER, rate)) if control_dump_filename is not None: control = pipeparts.mknxydumpsinktee( pipeline, pipeparts.mkqueue(pipeline, control), control_dump_filename) control = pipeparts.mkqueue(pipeline, control) return pipeparts.mktogglecomplex( pipeline, pipeparts.mkgate(pipeline, pipeparts.mktogglecomplex(pipeline, src), control=control, threshold=gap_threshold))
hc = handlerClass() mux_sink = mux.get_pad(options.instrument + ':' + options.channel_name) mux_sink.add_buffer_probe(hc.earlyBufferHandler) # Final destination. if options.output_type == "files": try: os.makedirs(options.output_path) except Exception as e: print "Failed with %s" % e # Inject tags. The framecpp_filesink element uses the tags to figure # out the output filename. print "Setting tag instrument: %s" % options.instrument tagInj = pipeparts.mktaginject( pipeline, mux, "instrument=%s,channel-name=%s" % (options.instrument, options.channel_name)) path = options.output_path if path: fs = pipeparts.mkframecppfilesink(pipeline, tagInj, frame_type=options.frame_type, path=options.output_path) else: fs = pipeparts.mkframecppfilesink(pipeline, mux, frame_type=options.frame_type) elif options.output_type == "tcp": # NB: like the appsrc, the tcp client sink does not use the 'blocksize' property. # It is just hanging around because it is inherited
# XXX Hacking. Attach probe to the muxer. hc = handlerClass() mux_sink = mux.get_pad(options.instrument + ':' + options.channel_name) mux_sink.add_buffer_probe(hc.earlyBufferHandler) # Final destination. if options.output_type == "files": try: os.makedirs(options.output_path) except Exception as e: print "Failed with %s" % e # Inject tags. The framecpp_filesink element uses the tags to figure # out the output filename. print "Setting tag instrument: %s" % options.instrument tagInj = pipeparts.mktaginject(pipeline, mux, "instrument=%s,channel-name=%s" % (options.instrument, options.channel_name)) path = options.output_path if path: fs = pipeparts.mkframecppfilesink(pipeline, tagInj, frame_type = options.frame_type, path = options.output_path) else: fs = pipeparts.mkframecppfilesink(pipeline, mux, frame_type = options.frame_type) elif options.output_type == "tcp": # NB: like the appsrc, the tcp client sink does not use the 'blocksize' property. # It is just hanging around because it is inherited # gstdataprotocol serializes and sends the caps first. Then serializes and # sends the buffers. Less work for us. # XXX Sadness. The capsfilter is not "gap-aware". So the gap flag will be unset.
port=options.multicast_port, sync=False) if options.verbose: gst.debug_set_threshold_for_name('gds_framexmitsink', gst.LEVEL_LOG) fx_pad = fx.get_pad("sink") fx_pad.add_event_probe(probeEventHandler) fx_pad.add_buffer_probe(probeBufferHandler) elif options.output_type == "files": try: os.makedirs(options.output_path) except Exception as e: print "Failed with %s" % e # Inject tags. The framecpp_filesink element uses the tags to figure # out the output filename. src = pipeparts.mktaginject(pipeline, src, "instrument=%s" % options.instrument) path = options.output_path if path: fs = pipeparts.mkframecppfilesink(pipeline, src, frame_type=options.frame_type, path=options.output_path) else: fs = pipeparts.mkframecppfilesink(pipeline, src, frame_type=options.frame_type) path = options.output_path if path: fs = pipeparts.mkframecppfilesink(pipeline,
def peak_test_01a(pipeline, name, handler): # # try changing these. test should still work! # initial_channels = 2 rate = 2048 #Hz width = 32 sine_frequency = 1 gap_frequency = 0.1 # Hz gap_threshold = 0.7 # of 1 buffer_length = 1.0 # seconds test_duration = 10.0 # seconds peak_window = 2048 # samples wave = 0 # # build pipeline # head = test_common.gapped_test_src( pipeline, buffer_length=buffer_length, rate=rate, width=width, channels=initial_channels, test_duration=test_duration, gap_frequency=gap_frequency, gap_threshold=gap_threshold, control_dump_filename="%s_control.dump" % name) head = pipeparts.mktogglecomplex(pipeline, head) head = pipeparts.mktaginject( pipeline, head, "instrument=H1,channel-name=LSC-STRAIN,units=strain") #head = test_common.gapped_complex_test_src(pipeline, buffer_length = buffer_length, rate = in_rate, test_duration = test_duration, wave = wave, freq = sine_frequency, gap_frequency = gap_frequency, gap_threshold = gap_threshold, control_dump_filename = "itac_test_01a_control.dump", tags = "instrument=H1,channel-name=LSC-STRAIN,units=strain") #head = tee = pipeparts.mktee(pipeline, head) #pipeparts.mktrigger(pipeline, head, peak_window, "test_bank.xml") # Does not recieve EOS, hangs #pipeparts.mktrigger(pipeline, head, peak_window,autocorrelation_matrix = numpy.ones((1,21), dtype=numpy.complex)) #head = pipeparts.mkqueue(pipeline, pipeparts.mkitac(pipeline, head, peak_window, "test_bank.xml", autocorrelation_matrix = numpy.array([[0+0.j, 0+0.j, 1+1.j, 0+0.j, 0+0.j]]))) #head = pipeparts.mkprogressreport(pipeline, head, "test") # # output the before and after # #pipeparts.mknxydumpsink(pipeline, pipeparts.mkqueue(pipeline, head), "%s_out.dump" % name) #pipeparts.mkfakesink(pipeline, head) #a = pipeparts.mkappsink(pipeline, pipeparts.mkqueue(pipeline, head)) head = pipeparts.mkgeneric(pipeline, head, "lal_nxydump") sink = pipeparts.mkappsink(pipeline, head, max_buffers=1, sync=False) sink.connect("new-sample", handler.bufhandler) sink.connect("new-preroll", handler.prehandler) #outfile = open("itac_test_01a_out.dump", "w") #def dump_triggers(elem, output = outfile): # for row in SnglInspiralTable.from_buffer(elem.emit("pull-buffer")): # print >>outfile, row.end_time + row.end_time_ns*1e-9, row.snr, row.chisq, row.chisq_dof #a.connect_after("new-buffer", dump_triggers) #pipeparts.mknxydumpsink(pipeline, pipeparts.mktogglecomplex(pipeline, pipeparts.mkqueue(pipeline, tee)), "itac_test_01a_in.dump") # # done # #if "GST_DEBUG_DUMP_DOT_DIR" in os.environ: # gst.DEBUG_BIN_TO_DOT_FILE(pipeline, gst.DEBUG_GRAPH_SHOW_ALL, "peak_test_01a") return pipeline
# Final destination. if options.output_type == "fake": fakesink = pipeparts.mkfakesink(pipeline, src) fs_pad = fakesink.get_pad("sink") fs_pad.add_event_probe(probeEventHandler) fs_pad.add_buffer_probe(probeBufferHandler) elif options.output_type == "files": try: os.makedirs(options.output_path) except Exception as e: print "Failed with %s" % e # Inject tags. The framecpp_filesink element uses the tags to figure # out the output filename. src = pipeparts.mktaginject(pipeline, src, "instrument=%s" % options.instrument) path = options.output_path if path: fs = pipeparts.mkframecppfilesink(pipeline, src, frame_type = options.frame_type, path = options.output_path) else: fs = pipeparts.mkframecppfilesink(pipeline, src, frame_type = options.frame_type) else: raise ValueError("Invalid output type.") # # Start the thing going. #