Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GstLAL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lscsoft
GstLAL
Commits
3328b24c
Commit
3328b24c
authored
4 years ago
by
Patrick Godwin
Committed by
ChiWai Chan
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
gstlal_play: convert to stream API
parent
3ae34c5e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gstlal/bin/gstlal_play
+17
-42
17 additions, 42 deletions
gstlal/bin/gstlal_play
with
17 additions
and
42 deletions
gstlal/bin/gstlal_play
+
17
−
42
View file @
3328b24c
...
...
@@ -20,12 +20,6 @@
from
optparse
import
OptionParser
import
sys
import
gi
gi
.
require_version
(
'
Gst
'
,
'
1.0
'
)
from
gi.repository
import
GObject
,
Gst
GObject
.
threads_init
()
Gst
.
init
(
None
)
import
lal
from
ligo.lw
import
utils
as
ligolw_utils
...
...
@@ -34,6 +28,7 @@ from gstlal import multirate_datasource
from
gstlal
import
pipeparts
from
gstlal
import
simplehandler
from
gstlal.psd
import
read_psd
from
gstlal.stream
import
Stream
from
ligo.lw.utils
import
segments
as
ligolw_segments
from
ligo.lw
import
lsctables
,
ligolw
...
...
@@ -193,63 +188,43 @@ if options.veto_segments_file is not None:
else
:
veto_segments
=
None
# building the event loop and pipeline
mainloop
=
GObject
.
MainLoop
()
pipeline
=
Gst
.
Pipeline
(
"
gstlal_play
"
)
handler
=
simplehandler
.
Handler
(
mainloop
,
pipeline
)
#
# the pipeline
#
# A basic src
head
,
_
,
_
=
datasource
.
mkbasicsrc
(
pipeline
,
gw_data_source_info
,
instrument
,
verbose
=
options
.
verbose
)
stream
=
Stream
.
from_datasource
(
gw_data_source_info
,
instrument
,
verbose
=
options
.
verbose
)
# if whitening,
leverage mkwhitened_multirate_src() otherwise
just resample
# if
not
whitening, just resample
if
options
.
whiten
:
h
ea
d
=
multirate_datasource
.
mkwhitened_multirate_src
(
pipeline
,
head
,
[
options
.
rate
]
,
instrument
,
psd
,
track_psd
=
True
,
veto_segments
=
veto_segments
)
[
options
.
rate
]
str
ea
m
=
stream
.
condition
(
options
.
rate
,
instrument
,
psd
=
psd
,
track_psd
=
True
,
veto_segments
=
veto_segments
)
else
:
head
=
pipeparts
.
mkresample
(
pipeline
,
head
,
quality
=
9
)
head
=
pipeparts
.
mkcapsfilter
(
pipeline
,
head
,
"
audio/x-raw, rate=%d
"
%
options
.
rate
)
stream
=
stream
.
resample
(
quality
=
9
).
capsfilter
(
f
"
audio/x-raw, rate=
{
options
.
rate
:
d
}
"
)
# handle filtering
if
options
.
high_pass_filter
is
not
None
and
options
.
low_pass_filter
is
not
None
:
h
ea
d
=
pipeparts
.
mk
audiochebband
(
pipeline
,
head
,
lower_frequency
=
options
.
high_pass_filter
,
upper_frequency
=
options
.
low_pass_filter
)
str
ea
m
=
stream
.
audiochebband
(
lower_frequency
=
options
.
high_pass_filter
,
upper_frequency
=
options
.
low_pass_filter
)
elif
options
.
high_pass_filter
is
not
None
:
h
ea
d
=
pipeparts
.
mk
audiocheblimit
(
pipeline
,
head
,
cutoff
=
options
.
high_pass_filter
,
mode
=
"
high-pass
"
)
str
ea
m
=
stream
.
audiocheblimit
(
cutoff
=
options
.
high_pass_filter
,
mode
=
"
high-pass
"
)
elif
options
.
low_pass_filter
is
not
None
:
h
ea
d
=
pipeparts
.
mk
audiocheblimit
(
pipeline
,
head
,
cutoff
=
options
.
low_pass_filter
,
mode
=
"
low-pass
"
)
str
ea
m
=
stream
.
audiocheblimit
(
cutoff
=
options
.
low_pass_filter
,
mode
=
"
low-pass
"
)
# necessary audio convert and amplify
h
ea
d
=
pipeparts
.
mkaudioconvert
(
pipeline
,
pipeparts
.
mkaudioamplify
(
pipeline
,
head
,
options
.
amplification
))
str
ea
m
=
stream
.
audioamplify
(
options
.
amplification
)
.
audioconvert
(
)
if
options
.
sample_format
is
not
None
:
head
=
pipeparts
.
mkcapsfilter
(
pipeline
,
head
,
"
audio/x-raw, format=
%s
"
%
options
.
sample_format
)
stream
.
stream
.
capsfilter
(
f
"
audio/x-raw, format=
{
options
.
sample_format
}
"
)
if
options
.
output
is
None
:
pipeparts
.
mk
autoaudiosink
(
pipeline
,
head
)
stream
.
autoaudiosink
()
elif
options
.
output
.
endswith
(
"
.wav
"
):
pipeparts
.
mkfilesink
(
pipeline
,
pipeparts
.
mkwavenc
(
pipeline
,
head
),
options
.
output
)
stream
.
wavenc
().
filefink
(
options
.
output
)
elif
options
.
output
.
endswith
(
"
.flac
"
):
pipeparts
.
mkfilesink
(
pipeline
,
pipeparts
.
mkflacenc
(
pipeline
,
head
),
options
.
output
)
stream
.
flacenc
().
filefink
(
options
.
output
)
elif
options
.
output
.
endswith
(
"
.ogg
"
):
head
=
pipeparts
.
mkoggmux
(
pipeline
,
pipeparts
.
mkvorbisenc
(
pipeline
,
head
))
pipeparts
.
mkfilesink
(
pipeline
,
head
,
options
.
output
)
stream
.
vorbisenc
().
oggmux
().
filefink
(
options
.
output
)
elif
options
.
output
.
endswith
(
"
.txt
"
)
or
options
.
output
in
(
"
/dev/stdout
"
,
"
/dev/stderr
"
):
pipeparts
.
mknxydumpsink
(
pipeline
,
head
,
options
.
output
)
stream
.
nxydumpsink
(
options
.
output
)
else
:
raise
ValueError
(
"
unrecognized format for --output
"
)
# Allow Ctrl+C or sig term to gracefully shut down the program for online
# sources, otherwise it will just kill it
if
gw_data_source_info
.
data_source
in
(
"
lvshm
"
,
"
framexmit
"
):
# what about nds online?
simplehandler
.
OneTimeSignalHandler
(
pipeline
)
# Seek
if
pipeline
.
set_state
(
Gst
.
State
.
READY
)
==
Gst
.
StateChangeReturn
.
FAILURE
:
raise
RuntimeError
(
"
pipeline failed to enter READY state
"
)
if
gw_data_source_info
.
data_source
not
in
(
"
lvshm
"
,
"
framexmit
"
):
# what about nds online?
datasource
.
pipeline_seek_for_gps
(
pipeline
,
gw_data_source_info
.
seg
[
0
],
gw_data_source_info
.
seg
[
1
])
# run
if
pipeline
.
set_state
(
Gst
.
State
.
PLAYING
)
==
Gst
.
StateChangeReturn
.
FAILURE
:
raise
RuntimeError
(
"
pipeline failed to enter PLAYING state
"
)
mainloop
.
run
()
# play
stream
.
start
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment