diff options
author | Vivia Nikolaidou <vivia@ahiru.eu> | 2022-08-18 15:04:15 +0300 |
---|---|---|
committer | Vivia Nikolaidou <vivia@ahiru.eu> | 2022-08-22 17:58:43 +0300 |
commit | 560611134588f63270a569e92160ecac5ceabc37 (patch) | |
tree | ac5f4447c55c1e5dd4d8f15f92c335c36aa5bab8 /audio | |
parent | 84f6484140098826b3f074d806e0eb052198df43 (diff) |
plugins: Simplify code using ParamSpecBuilder
Diffstat (limited to 'audio')
-rw-r--r-- | audio/audiofx/src/audioecho/imp.rs | 64 | ||||
-rw-r--r-- | audio/audiofx/src/audioloudnorm/imp.rs | 68 | ||||
-rw-r--r-- | audio/audiofx/src/ebur128level/imp.rs | 43 | ||||
-rw-r--r-- | audio/audiofx/src/hrtfrender/imp.rs | 83 | ||||
-rw-r--r-- | audio/csound/src/filter/imp.rs | 57 | ||||
-rw-r--r-- | audio/spotify/src/spotifyaudiosrc/imp.rs | 78 |
6 files changed, 180 insertions, 213 deletions
diff --git a/audio/audiofx/src/audioecho/imp.rs b/audio/audiofx/src/audioecho/imp.rs index 0d076e768..ef606257b 100644 --- a/audio/audiofx/src/audioecho/imp.rs +++ b/audio/audiofx/src/audioecho/imp.rs @@ -96,40 +96,36 @@ impl ObjectImpl for AudioEcho { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { vec![ - glib::ParamSpecUInt64::new("max-delay", - "Maximum Delay", - "Maximum delay of the echo in nanoseconds (can't be changed in PLAYING or PAUSED state)", - 0, u64::MAX - 1, - DEFAULT_MAX_DELAY.nseconds(), - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - glib::ParamSpecUInt64::new( - "delay", - "Delay", - "Delay of the echo in nanoseconds", - 0, - u64::MAX - 1, - DEFAULT_DELAY.nseconds(), - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING, - ), - glib::ParamSpecDouble::new( - "intensity", - "Intensity", - "Intensity of the echo", - 0.0, - 1.0, - DEFAULT_INTENSITY, - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING, - ), - glib::ParamSpecDouble::new( - "feedback", - "Feedback", - "Amount of feedback", - 0.0, - 1.0, - DEFAULT_FEEDBACK, - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING, - ), + glib::ParamSpecUInt64::builder("max-delay") + .nick("Maximum Delay") + .blurb("Maximum delay of the echo in nanoseconds (can't be changed in PLAYING or PAUSED state)") + .maximum(u64::MAX - 1) + .default_value(DEFAULT_MAX_DELAY.nseconds()) + .mutable_ready() + .build(), + glib::ParamSpecUInt64::builder("delay") + .nick("Delay") + .blurb("Delay of the echo in nanoseconds") + .maximum(u64::MAX - 1) + .default_value(DEFAULT_DELAY.nseconds()) + .mutable_ready() + .build(), + glib::ParamSpecDouble::builder("intensity") + .nick("Intensity") + .blurb("Intensity of the echo") + .minimum(0.0) + .maximum(1.0) + .default_value(DEFAULT_INTENSITY) + .mutable_ready() + .build(), + glib::ParamSpecDouble::builder("feedback") + .nick("Feedback") + .blurb("Amount of feedback") + .minimum(0.0) + .maximum(1.0) + .default_value(DEFAULT_FEEDBACK) + .mutable_ready() + .build(), ] }); diff --git a/audio/audiofx/src/audioloudnorm/imp.rs b/audio/audiofx/src/audioloudnorm/imp.rs index ae3279e19..91e472d92 100644 --- a/audio/audiofx/src/audioloudnorm/imp.rs +++ b/audio/audiofx/src/audioloudnorm/imp.rs @@ -1762,42 +1762,38 @@ impl ObjectImpl for AudioLoudNorm { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { vec![ - glib::ParamSpecDouble::new( - "loudness-target", - "Loudness Target", - "Loudness target in LUFS", - -70.0, - -5.0, - DEFAULT_LOUDNESS_TARGET, - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - glib::ParamSpecDouble::new( - "loudness-range-target", - "Loudness Range Target", - "Loudness range target in LU", - 1.0, - 20.0, - DEFAULT_LOUDNESS_RANGE_TARGET, - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - glib::ParamSpecDouble::new( - "max-true-peak", - "Maximum True Peak", - "Maximum True Peak in dbTP", - -9.0, - 0.0, - DEFAULT_MAX_TRUE_PEAK, - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - glib::ParamSpecDouble::new( - "offset", - "Offset Gain", - "Offset Gain in LU", - -99.0, - 99.0, - DEFAULT_OFFSET, - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), + glib::ParamSpecDouble::builder("loudness-target") + .nick("Loudness Target") + .blurb("Loudness target in LUFS") + .minimum(-70.0) + .maximum(-5.0) + .default_value(DEFAULT_LOUDNESS_TARGET) + .mutable_ready() + .build(), + glib::ParamSpecDouble::builder("loudness-range-target") + .nick("Loudness Range Target") + .blurb("Loudness range target in LU") + .minimum(1.0) + .maximum(20.0) + .default_value(DEFAULT_LOUDNESS_RANGE_TARGET) + .mutable_ready() + .build(), + glib::ParamSpecDouble::builder("max-true-peak") + .nick("Maximum True Peak") + .blurb("Maximum True Peak in dbTP") + .minimum(-9.0) + .maximum(0.0) + .default_value(DEFAULT_MAX_TRUE_PEAK) + .mutable_ready() + .build(), + glib::ParamSpecDouble::builder("offset") + .nick("Offset Gain") + .blurb("Offset Gain in LU") + .minimum(-99.0) + .maximum(99.0) + .default_value(DEFAULT_OFFSET) + .mutable_ready() + .build(), ] }); diff --git a/audio/audiofx/src/ebur128level/imp.rs b/audio/audiofx/src/ebur128level/imp.rs index 989c5f7bc..71c3811da 100644 --- a/audio/audiofx/src/ebur128level/imp.rs +++ b/audio/audiofx/src/ebur128level/imp.rs @@ -144,30 +144,25 @@ impl ObjectImpl for EbuR128Level { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { vec![ - glib::ParamSpecFlags::new( - "mode", - "Mode", - "Selection of metrics to calculate", - Mode::static_type(), - DEFAULT_MODE.bits() as u32, - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - glib::ParamSpecBoolean::new( - "post-messages", - "Post Messages", - "Whether to post messages on the bus for each interval", - DEFAULT_POST_MESSAGES, - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING, - ), - glib::ParamSpecUInt64::new( - "interval", - "Interval", - "Interval in nanoseconds for posting messages", - 0, - u64::MAX - 1, - DEFAULT_INTERVAL.nseconds(), - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), + glib::ParamSpecFlags::builder("mode", Mode::static_type()) + .nick("Mode") + .blurb("Selection of metrics to calculate") + .default_value(DEFAULT_MODE.bits() as u32) + .mutable_ready() + .build(), + glib::ParamSpecBoolean::builder("post-messages") + .nick("Post Messages") + .blurb("Whether to post messages on the bus for each interval") + .default_value(DEFAULT_POST_MESSAGES) + .mutable_playing() + .build(), + glib::ParamSpecUInt64::builder("interval") + .nick("Interval") + .blurb("Interval in nanoseconds for posting messages") + .maximum(u64::MAX - 1) + .default_value(DEFAULT_INTERVAL.nseconds()) + .mutable_ready() + .build(), ] }); diff --git a/audio/audiofx/src/hrtfrender/imp.rs b/audio/audiofx/src/hrtfrender/imp.rs index a0294b12d..fc949f7e7 100644 --- a/audio/audiofx/src/hrtfrender/imp.rs +++ b/audio/audiofx/src/hrtfrender/imp.rs @@ -404,51 +404,44 @@ impl ObjectImpl for HrtfRender { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { vec![ - glib::ParamSpecBoxed::new( - "hrir-raw", - "Head Transform Impulse Response", - "Head Transform Impulse Response raw bytes", - glib::Bytes::static_type(), - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - glib::ParamSpecString::new( - "hrir-file", - "Head Transform Impulse Response", - "Head Transform Impulse Response file location to read from", - None, - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - glib::ParamSpecUInt64::new( - "interpolation-steps", - "Interpolation Steps", - "Interpolation Steps is the amount of slices to cut source to", - 0, - u64::MAX - 1, - DEFAULT_INTERPOLATION_STEPS, - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - glib::ParamSpecUInt64::new( - "block-length", - "Block Length", - "Block Length is the length of each slice", - 0, - u64::MAX - 1, - DEFAULT_BLOCK_LENGTH, - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - gst::ParamSpecArray::new( - "spatial-objects", - "Spatial Objects", - "Spatial object Metadata to apply on input channels", - Some(&glib::ParamSpecBoxed::new( - "spatial-object", - "Spatial Object", - "Spatial Object Metadata", - gst::Structure::static_type(), - glib::ParamFlags::READWRITE, - )), - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING, - ), + glib::ParamSpecBoxed::builder("hrir-raw", glib::Bytes::static_type()) + .nick("Head Transform Impulse Response") + .blurb("Head Transform Impulse Response raw bytes") + .mutable_ready() + .build(), + glib::ParamSpecString::builder("hrir-file") + .nick("Head Transform Impulse Response") + .blurb("Head Transform Impulse Response file location to read from") + .mutable_ready() + .build(), + glib::ParamSpecUInt64::builder("interpolation-steps") + .nick("Interpolation Steps") + .blurb("Interpolation Steps is the amount of slices to cut source to") + .maximum(u64::MAX - 1) + .default_value(DEFAULT_INTERPOLATION_STEPS) + .mutable_ready() + .build(), + glib::ParamSpecUInt64::builder("block-length") + .nick("Block Length") + .blurb("Block Length is the length of each slice") + .maximum(u64::MAX - 1) + .default_value(DEFAULT_BLOCK_LENGTH) + .mutable_ready() + .build(), + gst::ParamSpecArray::builder("spatial-objects") + .element_spec( + &glib::ParamSpecBoxed::builder( + "spatial-object", + gst::Structure::static_type(), + ) + .nick("Spatial Object") + .blurb("Spatial Object Metadata") + .build(), + ) + .nick("Spatial Objects") + .blurb("Spatial object Metadata to apply on input channels") + .mutable_playing() + .build(), ] }); diff --git a/audio/csound/src/filter/imp.rs b/audio/csound/src/filter/imp.rs index acf795643..502ebf33b 100644 --- a/audio/csound/src/filter/imp.rs +++ b/audio/csound/src/filter/imp.rs @@ -336,38 +336,31 @@ impl ObjectImpl for CsoundFilter { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { vec![ - glib::ParamSpecBoolean::new( - "loop", - "Loop", - "loop over the score (can be changed in PLAYING or PAUSED state)", - DEFAULT_LOOP, - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING, - ), - glib::ParamSpecString::new( - "location", - "Location", - "Location of the csd file to be used by csound. - Use either location or CSD-text but not both at the same time, if so and error would be triggered", - None, - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - glib::ParamSpecString::new( - "csd-text", - "CSD-text", - "The content of a csd file passed as a String. - Use either location or csd-text but not both at the same time, if so and error would be triggered", - None, - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - glib::ParamSpecDouble::new( - "score-offset", - "Score Offset", - "Score offset in seconds to start the performance", - 0.0, - f64::MAX, - SCORE_OFFSET_DEFAULT, - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), + glib::ParamSpecBoolean::builder("loop") + .nick("Loop") + .blurb("loop over the score (can be changed in PLAYING or PAUSED state)") + .default_value(DEFAULT_LOOP) + .mutable_playing() + .build(), + glib::ParamSpecString::builder("location") + .nick("Location") + .blurb("Location of the csd file to be used by csound. + Use either location or CSD-text but not both at the same time, if so and error would be triggered") + .mutable_ready() + .build(), + glib::ParamSpecString::builder("csd-text") + .nick("CSD-text") + .blurb("The content of a csd file passed as a String. + Use either location or csd-text but not both at the same time, if so and error would be triggered") + .mutable_ready() + .build(), + glib::ParamSpecDouble::builder("score-offset") + .nick("Score Offset") + .blurb("Score offset in seconds to start the performance") + .minimum(0.0) + .default_value(SCORE_OFFSET_DEFAULT) + .mutable_ready() + .build(), ] }); diff --git a/audio/spotify/src/spotifyaudiosrc/imp.rs b/audio/spotify/src/spotifyaudiosrc/imp.rs index 402af8ad2..93d1ba94a 100644 --- a/audio/spotify/src/spotifyaudiosrc/imp.rs +++ b/audio/spotify/src/spotifyaudiosrc/imp.rs @@ -88,48 +88,42 @@ impl ObjectSubclass for SpotifyAudioSrc { impl ObjectImpl for SpotifyAudioSrc { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { - vec![glib::ParamSpecString::new( - "username", - "Username", - "Spotify device username from https://www.spotify.com/us/account/set-device-password/", - Some(""), - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - glib::ParamSpecString::new( - "password", - "Password", - "Spotify device password from https://www.spotify.com/us/account/set-device-password/", - Some(""), - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - glib::ParamSpecString::new( - "cache-credentials", - "Credentials cache", - "Directory where to cache Spotify credentials", - Some(""), - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - glib::ParamSpecString::new( - "cache-files", - "Files cache", - "Directory where to cache downloaded files from Spotify", - Some(""), - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - glib::ParamSpecUInt64::new( - "cache-max-size", - "Cache max size", - "The max allowed size of the cache, in bytes, or 0 to disable the cache limit", - 0, u64::MAX, 0, - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - glib::ParamSpecString::new( - "track", - "Spotify URI", - "Spotify track URI, in the form 'spotify:track:$SPOTIFY_ID'", - Some(""), - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), + vec![glib::ParamSpecString::builder("username") + .nick("Username") + .blurb("Spotify device username from https://www.spotify.com/us/account/set-device-password/") + .default_value(Some("")) + .mutable_ready() + .build(), + glib::ParamSpecString::builder("password") + .nick("Password") + .blurb("Spotify device password from https://www.spotify.com/us/account/set-device-password/") + .default_value(Some("")) + .mutable_ready() + .build(), + glib::ParamSpecString::builder("cache-credentials") + .nick("Credentials cache") + .blurb("Directory where to cache Spotify credentials") + .default_value(Some("")) + .mutable_ready() + .build(), + glib::ParamSpecString::builder("cache-files") + .nick("Files cache") + .blurb("Directory where to cache downloaded files from Spotify") + .default_value(Some("")) + .mutable_ready() + .build(), + glib::ParamSpecUInt64::builder("cache-max-size") + .nick("Cache max size") + .blurb("The max allowed size of the cache, in bytes, or 0 to disable the cache limit") + .default_value(0) + .mutable_ready() + .build(), + glib::ParamSpecString::builder("track") + .nick("Spotify URI") + .blurb("Spotify track URI, in the form 'spotify:track:$SPOTIFY_ID'") + .default_value(Some("")) + .mutable_ready() + .build(), ] }); |