Skip to content
This repository was archived by the owner on Feb 2, 2019. It is now read-only.

Commit cb03ddb

Browse files
committed
{ui, backend}: make Faded sliders, add fade master, other changes
- We now have a master fader, which we really should have had at the beginning. - We now use Serde 1.0, and MessagePack instead of JSON. The rationale for doing this is that JSON doesn't actually support -inf values, so it was secretly encoding all -infs as null and causing errors. MessagePack doesn't have this restriction. - We now use the fern logging framework in sqa-ui, and have nice semi- organised logging instead of the inconsistent chaos of println! that was there before. - Apply/Cancel/OK is completely gone - all UI elements make instantaneous changes, so there's no need for those. - You can actually manipulate fader sliders now, which are a thing.
1 parent 2a51ea6 commit cb03ddb

File tree

21 files changed

+390
-192
lines changed

21 files changed

+390
-192
lines changed

Cargo.lock

Lines changed: 61 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sqa-backend/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ authors = ["eeeeeta <eeeeeta@users.noreply.github.com>"]
66
[dependencies]
77
tokio-core = "0.1"
88
futures = "0.1"
9-
serde = "0.9"
10-
serde_derive = "0.9"
9+
serde = "1.0"
10+
rmp-serde = "0.13"
11+
serde_derive = "1.0"
1112
time = "0.1"
12-
uuid = { version = "0.4", features = ["v4", "serde"] }
13+
uuid = { version = "0.5", features = ["v4", "serde"] }
1314
sqa-engine = { path = "../sqa-engine" }
1415
sqa-ffmpeg = { path = "../sqa-ffmpeg" }
1516
rosc = { path = "../rosc" }
16-
serde_json = "0.9"
1717
error-chain = "0.10"
1818
chrono = { version = "0.3", features = ["serde"] }
1919
sqa-osc-custom-derive = { path = "../sqa-osc-custom-derive" }

sqa-backend/src/actions/fade.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ use std::default::Default;
1010

1111
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
1212
pub struct FadeParams {
13-
target: Option<Uuid>,
14-
fades: Vec<Option<f32>>,
15-
dur: Duration
13+
pub target: Option<Uuid>,
14+
pub fades: Vec<Option<f32>>,
15+
pub fade_master: Option<f32>,
16+
pub dur: Duration
1617
}
1718
#[derive(Default)]
1819
pub struct Controller {
@@ -30,6 +31,7 @@ impl EditableAction for Controller {
3031
&self.params
3132
}
3233
fn set_params(&mut self, params: FadeParams, _: &mut Context) {
34+
println!("pars: {:?}", params);
3335
self.params = params;
3436
}
3537
}
@@ -80,6 +82,17 @@ impl ActionController for Controller {
8082
ActionType::Audio(ref mut t) => t,
8183
_ => bail!("Action was wrong type")
8284
};
85+
if let Some(fade) = self.params.fade_master {
86+
if let Some(sdr) = tgt.senders.get_mut(0) {
87+
let mut fd = FadeDetails::new(sdr.volume().get(0), fade);
88+
fd.set_start_time(time);
89+
let secs_component = self.params.dur.as_secs() * ::sqa_engine::ONE_SECOND_IN_NANOSECONDS;
90+
let subsec_component = self.params.dur.subsec_nanos() as u64;
91+
fd.set_duration(secs_component + subsec_component);
92+
fd.set_active(true);
93+
sdr.set_master_volume(Box::new(Parameter::LinearFade(fd)));
94+
}
95+
}
8396
for (i, fade) in self.params.fades.iter().enumerate() {
8497
if let Some(fade) = *fade {
8598
if let Some(sdr) = tgt.senders.get_mut(i) {

sqa-backend/src/actions/mod.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use state::IntSender;
1212
use errors::*;
1313
use serde::{Serialize, Deserialize};
1414
use std::fmt::Debug;
15-
use serde_json;
1615
use std::time::Duration;
1716

1817
pub mod audio;
@@ -43,7 +42,7 @@ pub trait OscEditable {
4342
fn edit(&mut self, path: &str, args: Vec<OscType>) -> BackendResult<()>;
4443
}
4544
pub trait EditableAction {
46-
type Parameters: Serialize + Deserialize + Clone + Debug + Default;
45+
type Parameters: Serialize + for<'de> Deserialize<'de> + Clone + Debug + Default;
4746

4847
fn get_params(&self) -> &Self::Parameters;
4948
fn set_params(&mut self, Self::Parameters, ctx: &mut Context);
@@ -240,7 +239,15 @@ impl Action {
240239
bail!("wrong type of action parameters");
241240
}
242241
},
243-
_ => unimplemented!()
242+
ActionType::Fade(ref mut a) => {
243+
if let ActionParameters::Fade(d) = data {
244+
a.set_params(d, ctx);
245+
Ok(())
246+
}
247+
else {
248+
bail!("wrong type of action parameters");
249+
}
250+
}
244251
}
245252
}
246253
pub fn message(&mut self, msg: Box<Any>) -> Result<(), Box<Error>> {

sqa-backend/src/codec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use rosc::{decoder, encoder, OscMessage, OscPacket, OscType};
44
use errors::*;
55
use mixer::MixerConf;
66
use errors::BackendErrorKind::*;
7-
use serde_json;
87
use actions::{ActionParameters, OpaqueAction};
98
use std::collections::HashMap;
109
use uuid::Uuid;
@@ -160,6 +159,7 @@ impl UdpCodec for SqaWireCodec {
160159
type In = RecvMessage;
161160
type Out = SendMessage;
162161
fn decode(&mut self, src: &SocketAddr, buf: &[u8]) -> ::std::io::Result<Self::In> {
162+
println!("{:?}", buf);
163163
let pkt = match decoder::decode(buf) {
164164
Ok(pkt) => {
165165
match pkt {

sqa-backend/src/errors.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ error_chain! {
88
Jack(::sqa_engine::sqa_jack::errors::Error, ::sqa_engine::sqa_jack::errors::ErrorKind);
99
}
1010
foreign_links {
11-
Serde(::serde_json::Error);
11+
RmpDecode(::rmp_serde::decode::Error);
12+
RmpEncode(::rmp_serde::encode::Error);
1213
Io(::std::io::Error);
1314
StrParse(::std::string::ParseError);
1415
}

sqa-backend/src/handlers.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use tokio_core::reactor::Remote;
88
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
99
use time::{Duration, SteadyTime};
1010
use serde::Serialize;
11-
use serde_json;
1211
use rosc::{OscType, OscMessage};
1312
use codec::Reply;
1413
use errors::*;
@@ -50,16 +49,6 @@ impl<M> ConnData<M> {
5049
self.framed.start_send(self.addr.msg_to(msg.into()))?;
5150
Ok(())
5251
}
53-
pub fn reply<T>(&mut self, data: T) -> IoResult<()> where T: Serialize {
54-
let j = serde_json::to_string(&data).unwrap(); // FIXME FIXME FIXME
55-
let mut path = String::from("/reply");
56-
path.push_str(&self.path);
57-
self.framed.start_send(self.addr.msg_to(OscMessage {
58-
addr: path,
59-
args: Some(vec![OscType::String(j)])
60-
}))?;
61-
Ok(())
62-
}
6352
pub fn subscribe(&mut self) {
6453
let a = self.addr.clone();
6554
self.parties.retain(|party| {

sqa-backend/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ extern crate tokio_core;
55
extern crate serde;
66
#[macro_use]
77
extern crate serde_derive;
8-
#[macro_use]
9-
extern crate serde_json;
8+
extern crate rmp_serde;
109
extern crate time;
1110
extern crate uuid;
1211
extern crate sqa_engine;

sqa-backend/src/state.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ impl ConnHandler for Context {
117117
d.respond(ActionInfoRetrieved { uuid, res })?;
118118
},
119119
UpdateActionParams { uuid, params } => {
120+
println!("uap: {:?}", params);
120121
let res = do_with_ctx!(self, &uuid, |a: &mut Action| {
121122
let ret = a.set_params(params, self).map_err(|e| e.to_string());
122123
self.on_action_changed(d, a);

sqa-osc-custom-derive/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ fn tokens_from_message(name: Ident, Message { path, substs, sers, ident, verbs,
5050
IdentType::Ser => quote! {
5151
let #tok;
5252
if args.len() < 1 {
53-
bail!(OSCWrongArgs("string"))
53+
bail!(OSCWrongArgs("blob"))
5454
}
55-
if let Some(x) = args.remove(0).string() {
56-
#tok2 = serde_json::from_str(&x)?;
55+
if let Some(x) = args.remove(0).blob() {
56+
#tok2 = ::rmp_serde::from_slice(&x)?;
5757
}
5858
else {
59-
bail!(OSCWrongArgs("string"))
59+
bail!(OSCWrongArgs("blob"))
6060
}
6161
},
6262
IdentType::Verb(ref id) => quote! {
@@ -90,8 +90,8 @@ fn tokens_from_message(name: Ident, Message { path, substs, sers, ident, verbs,
9090
let path = format!(#path #(,#substs2=#substs)*);
9191
let mut args = vec![
9292
#(
93-
OscType::String(
94-
serde_json::to_string(&#sers)
93+
OscType::Blob(
94+
::rmp_serde::to_vec(&#sers)
9595
.unwrap()
9696
)
9797
),*

0 commit comments

Comments
 (0)