Ejemplo n.º 1
0
def main(argv):
    mainloop = gobject.MainLoop()

    window = gtk.Window()
    hbox = gtk.HBox()

    source = audio.source.Tone(emit=True)
    pad = audio.tool.Pad()
    hbox.pack_start(pad)
    if '--analyzer' in argv:
        visualizer = audio.visual.Analyzer()
        source.connect('new-data', new_data_cb, visualizer)
        hbox.pack_start(visualizer)
        window.set_default_size(500, 200)

    window.connect('delete-event', delete_cb, source, mainloop)
    pad.connect('delete-event', delete_cb, source, mainloop)
    pad.connect('end-dnd', end_dnd_cb, source)
    pad.connect('start-dnd', start_dnd_cb, source)
    pad.connect('dnd-value', dnd_value_cb, source)

    window.add(hbox)
    window.show_all()

    gobject.threads_init()
    mainloop.run()

    return 0
Ejemplo n.º 2
0
def main(argv):
    if len(argv) < 2:
        print "Usage: {0} <source> [<options> ..]".format(sys.argv[0])
        return 1

    loop = gobject.MainLoop()
    window = gtk.Window()

    if "--analyzer" in argv:
        visualizer = audio.visual.Analyzer()
    else:
        visualizer = audio.visual.Oscilloscope("--fill" in argv)

    if argv[1] == "mic":
        source = audio.source.Microphone(emit=True)
    elif argv[1] == "tone":
        source = audio.source.Tone(emit=True)
    else:
        location = argv[1]
        if not location.startswith("/"):
            location = os.path.join(os.getcwd(), location)
        source = audio.source.AudioFile(location, emit=True)

    window.connect("delete-event", delete_cb, source, loop)
    source.connect("new-data", new_data_cb, visualizer)

    window.add(visualizer)
    window.show_all()

    source.start()

    gobject.threads_init()
    loop.run()

    return 0