def test1(n=10): source = Noise() c = [] for i in range(n): c.append(Identity()) save = SaveRaw() source.plugs_into(c[0]) for i in range(n - 1): c[i].plugs_into(c[i + 1]) c[-1].plugs_into(save) main()
def test2(n=1): source = Noise(frames_per_buffer=128) c = [] for i in range(n): c.append(Identity()) save = SaveRaw() source.plugs_into(c[0]) for i in range(n - 1): c[i].plugs_into(c[i + 1]) c[-1].plugs_into(save) main()
def run(threshold=0.003, nchannels=500, vmax=2000., scale=5400., runtime=None, outfile=None, log=True, do_plot=True, input_device_name="", inputfile=None, realtime=True, fitpulse=False, fit_threshold=0.95): if inputfile is not None: source = FileReplay(filename=inputfile, realtime=realtime) else: source = SoundCard(input_device_name=input_device_name) convert = Raw2Float() if fitpulse: detect = FittedPulseDetection(threshold=threshold, fit_threshold=fit_threshold) else: detect = PulseDetection(threshold=threshold) count = Count(outfile=None) calibrate = Scale(scale=scale) histogram = AggregateHistogram(nchannels=int(nchannels * vmax / 1000.), vmin=0, vmax=vmax, outfile=outfile) source.plugs_into(convert) convert.plugs_into(detect) detect.plugs_into(count) detect.plugs_into(calibrate) calibrate.plugs_into(histogram) if do_plot: plothistogram = PlotHistogram(xmin=0, xmax=vmax, outfile=outfile, log=log) histogram.plugs_into(plothistogram) main(runtime)
def run(input_device_name="", runtime=None, list_input_devices=False): if list_input_devices: for name, id_ in SoundCard.devices().items(): print("{0}: {1}".format(name, id_)) exit(0) source = SoundCard(input_device_name=input_device_name) monitor = Monitor() convert = Raw2Float() downsample = DownSampleMaxed(factor=16) source.plugs_into(convert) convert.plugs_into(downsample) downsample.plugs_into(monitor) main(runtime)
from gammalab.transform import Raw2Float, DownSampleMaxed, Scale from gammalab.analysis import PulseDetection from gammalab.analysis import AggregateHistogram from gammalab.analysis import Count from gammalab.backend import Playback, PlotHistogram source = SoundCard() monitor = Monitor(vmin=-0.01, vmax=0.1) convert = Raw2Float() downsample = DownSampleMaxed(factor=8) detect = PulseDetection(threshold=0.003) count = Count() playback = Playback() calibrate = Scale(scale=5400.) histogram = AggregateHistogram(nchannels=5000, vmax=5400) plothistogram = PlotHistogram(xmin=0, xmax=2000, log=False) source.plugs_into(playback) source.plugs_into(convert) convert.plugs_into(detect) detect.plugs_into(count) detect.plugs_into(calibrate) calibrate.plugs_into(histogram) histogram.plugs_into(plothistogram) convert.plugs_into(downsample) downsample.plugs_into(monitor) main(100)
from gammalab import main from gammalab.acquisition import PyAudio from gammalab.backend import SaveWav soundcard=PyAudio(sample_format="int16") save=SaveWav() soundcard.plugs_into(save) main(10)
from gammalab import main from gammalab.acquisition import PyAudio, SoundCard from gammalab.backend import PyAudioPlay, SoundCardPlay soundcard = SoundCard() playback = SoundCardPlay() soundcard.plugs_into(playback) main()