rate=1000000), PARSE=WAVParser(), ENC=Carousel(lambda meta: WAVWriter(**meta)), WRITE=SimpleFileWriter("test.wav"), linkages={ ("READ", "outbox"): ("PARSE", "inbox"), ("PARSE", "outbox"): ("ENC", "inbox"), ("PARSE", "all_meta"): ("ENC", "next"), ("ENC", "outbox"): ("WRITE", "inbox"), ("READ", "signal"): ("PARSE", "control"), ("PARSE", "signal"): ("ENC", "control"), ("ENC", "signal"): ("WRITE", "control"), }, ).run() print("Reading in test.wav and playing it back ...") Graphline(SRC=RateControlledFileReader("test.wav", readmode="bytes", rate=44100 * 4), WAV=WAVParser(), DST=Carousel(lambda meta: Output(sample_rate=meta['sample_rate'], format=meta['sample_format'], channels=meta['channels'])), linkages={ ("SRC", "outbox"): ("WAV", "inbox"), ("SRC", "signal"): ("WAV", "control"), ("WAV", "outbox"): ("DST", "inbox"), ("WAV", "signal"): ("DST", "control"), ("WAV", "all_meta"): ("DST", "next"), }).run()
" -f yuv4mpegpipe -y vidpipe.yuv -f wav -y audpipe.wav", outpipes={ "vidpipe.yuv": "video", "audpipe.wav": "audio" }, buffersize=131072, ), VIDEO=Pipeline( 1, YUV4MPEGToFrame(), FrameRateLimitedPlayback(VideoOverlay()), ), AUDIO=Graphline( PARSE=WAVParser(), OUT=Carousel(lambda format: Output(format['sample_rate'], format['channels'], format['sample_format'], maximumLag=0.5)), linkages={ ("", "inbox"): ("PARSE", "inbox"), ("PARSE", "outbox"): ("OUT", "inbox"), ("PARSE", "all_meta"): ("OUT", "next"), ("", "control"): ("PARSE", "control"), ("PARSE", "signal"): ("OUT", "control"), ("OUT", "signal"): ("", "signal"), }, boxsizes={ ("PARSE", "inbox"): 5, }, ), DEBUG=ConsoleEchoer(), linkages={
def makeAudioOutput(metadata): return Output(metadata["sample_rate"], metadata["channels"], metadata["format"])
def convertback(data): output = [] for sample in data: sample = int(sample) output.append(chr(sample & 255) + chr((sample >> 8) & 255)) return "".join(output) __kamaelia_components__ = (LPF, ) if __name__ == "__main__": import sys from Kamaelia.Chassis.Pipeline import Pipeline from Kamaelia.Audio.PyMedia.Input import Input from Kamaelia.Audio.PyMedia.Output import Output from Kamaelia.Codec.Speex import SpeexEncode, SpeexDecode from Kamaelia.Audio.RawAudioMixer import RawAudioMixer sys.path.append("../../Tools/Whiteboard/Whiteboard") from Entuple import Entuple Pipeline( Input(sample_rate=8000, channels=1, format="S16_LE"), LPF(), SpeexEncode(3), SpeexDecode(3), Entuple(prefix=["A"], postfix=[]), # added to provide some bufering RawAudioMixer(), # Output(sample_rate=8000, channels=1, format="S16_LE"), ).run()