mirror of
https://github.com/markqvist/LXST.git
synced 2026-04-27 14:20:39 +00:00
Public repo init
This commit is contained in:
commit
36246afe8c
64 changed files with 14604 additions and 0 deletions
51
examples/mixer.py
Normal file
51
examples/mixer.py
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import RNS
|
||||
import LXST
|
||||
import sys
|
||||
import time
|
||||
RNS.loglevel = RNS.LOG_DEBUG
|
||||
|
||||
target_frame_ms = 20
|
||||
pipelined_output = True
|
||||
raw = LXST.Codecs.Raw()
|
||||
|
||||
# Pipelined mixer example
|
||||
if pipelined_output:
|
||||
opus = LXST.Codecs.Opus(profile=LXST.Codecs.Opus.PROFILE_AUDIO_HIGH)
|
||||
codec2 = LXST.Codecs.Codec2(mode=LXST.Codecs.Codec2.CODEC2_3200)
|
||||
line_sink = LXST.Sinks.LineSink()
|
||||
mixer = LXST.Mixer(target_frame_ms=target_frame_ms)
|
||||
loopback = LXST.Sources.Loopback()
|
||||
|
||||
codec = opus
|
||||
|
||||
file_source1 = LXST.Sources.OpusFileSource("./docs/speech_stereo.opus", codec=raw, sink=mixer, loop=True, target_frame_ms=target_frame_ms)
|
||||
file_source2 = LXST.Sources.OpusFileSource("./docs/podcast.opus", codec=raw, sink=mixer, loop=True, target_frame_ms=target_frame_ms)
|
||||
line_source = LXST.Sources.LineSource(target_frame_ms=target_frame_ms, codec=raw, sink=mixer)
|
||||
|
||||
input_pipeline = LXST.Pipeline(source=mixer, codec=codec, sink=loopback)
|
||||
output_pipeline = LXST.Pipeline(source=loopback, codec=codec, sink=line_sink)
|
||||
input_pipeline.start(); output_pipeline.start()
|
||||
|
||||
# Simple mixer example with output directly to sink
|
||||
else:
|
||||
line_sink = LXST.Sinks.LineSink()
|
||||
mixer = LXST.Mixer(target_frame_ms=target_frame_ms, sink=line_sink)
|
||||
file_source1 = LXST.Sources.OpusFileSource("./docs/speech_stereo.opus", codec=raw, sink=mixer, loop=True, target_frame_ms=target_frame_ms)
|
||||
file_source2 = LXST.Sources.OpusFileSource("./docs/podcast.opus", codec=raw, sink=mixer, loop=True, target_frame_ms=target_frame_ms)
|
||||
line_source = LXST.Sources.LineSource(target_frame_ms=target_frame_ms, codec=raw, sink=mixer)
|
||||
|
||||
mixer.start()
|
||||
line_source.start()
|
||||
print("Hit enter to add another source"); input()
|
||||
|
||||
file_source1.start()
|
||||
print("Hit enter to add another source"); input()
|
||||
|
||||
file_source2.start()
|
||||
print("Hit enter to stop all sources"); input()
|
||||
|
||||
file_source1.stop()
|
||||
file_source2.stop()
|
||||
line_source.stop()
|
||||
|
||||
time.sleep(0.5)
|
||||
48
examples/pipelines.py
Normal file
48
examples/pipelines.py
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import RNS
|
||||
import LXST
|
||||
import sys
|
||||
import time
|
||||
RNS.loglevel = RNS.LOG_DEBUG
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print("No codec specified")
|
||||
sys.exit(0)
|
||||
else:
|
||||
selected_codec = sys.argv[1]
|
||||
|
||||
if len(sys.argv) >= 4:
|
||||
target_frame_ms = int(sys.argv[3])
|
||||
else:
|
||||
target_frame_ms = 40
|
||||
|
||||
if len(sys.argv) >= 3 and sys.argv[2].lower() == "file":
|
||||
selected_source = LXST.Sources.OpusFileSource("./docs/speech_stereo.opus", loop=True, target_frame_ms=target_frame_ms)
|
||||
# selected_source = LXST.Sources.OpusFileSource("./docs/music_stereo.opus", loop=True, target_frame_ms=target_frame_ms)
|
||||
# selected_source = LXST.Sources.OpusFileSource("./docs/podcast.opus", loop=True, target_frame_ms=target_frame_ms)
|
||||
else:
|
||||
selected_source = LXST.Sources.LineSource(target_frame_ms=target_frame_ms)
|
||||
|
||||
line_sink = LXST.Sinks.LineSink()
|
||||
loopback = LXST.Sources.Loopback()
|
||||
|
||||
if selected_codec.lower() == "raw":
|
||||
raw = LXST.Codecs.Raw()
|
||||
input_pipeline = LXST.Pipeline(source=selected_source, codec=raw, sink=loopback)
|
||||
output_pipeline = LXST.Pipeline(source=loopback, codec=raw, sink=line_sink)
|
||||
elif selected_codec.lower() == "codec2":
|
||||
codec2 = LXST.Codecs.Codec2(mode=LXST.Codecs.Codec2.CODEC2_1600)
|
||||
input_pipeline = LXST.Pipeline(source=selected_source, codec=codec2, sink=loopback)
|
||||
output_pipeline = LXST.Pipeline(source=loopback, codec=codec2, sink=line_sink)
|
||||
elif selected_codec.lower() == "opus":
|
||||
opus = LXST.Codecs.Opus(profile=LXST.Codecs.Opus.PROFILE_VOICE_LOW)
|
||||
input_pipeline = LXST.Pipeline(source=selected_source, codec=opus, sink=loopback)
|
||||
output_pipeline = LXST.Pipeline(source=loopback, codec=opus, sink=line_sink)
|
||||
else:
|
||||
print("No valid codec selected")
|
||||
sys.exit(0)
|
||||
|
||||
input_pipeline.start(); output_pipeline.start()
|
||||
input()
|
||||
input_pipeline.stop()
|
||||
|
||||
time.sleep(1)
|
||||
15
examples/tone_generator.py
Normal file
15
examples/tone_generator.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import RNS
|
||||
import LXST
|
||||
import sys
|
||||
import time
|
||||
RNS.loglevel = RNS.LOG_DEBUG
|
||||
|
||||
target_frame_ms = 40
|
||||
tone = LXST.Generators.ToneSource(frequency=388, ease_time_ms=3.14159, target_frame_ms=target_frame_ms)
|
||||
line_sink = LXST.Sinks.LineSink()
|
||||
output_pipeline = LXST.Pipeline(source=tone, codec=LXST.Codecs.Null(), sink=line_sink)
|
||||
|
||||
output_pipeline.start(); input()
|
||||
tone.stop()
|
||||
|
||||
time.sleep(1)
|
||||
Loading…
Add table
Add a link
Reference in a new issue