diff options
author | Graham Northup <grissess@nexusg.org> | 2019-02-12 23:34:38 -0500 |
---|---|---|
committer | Graham Northup <grissess@nexusg.org> | 2019-02-12 23:34:38 -0500 |
commit | 23c79cc00eb5d8e76148d79af83a9ab838e602f3 (patch) | |
tree | cb95ae3508d9a817cd9d828e5630325b5168745a | |
parent | 1b3b39e174e26871a0ddb613c80a8e987f6547e5 (diff) |
Pushing old workwork
-rw-r--r-- | gens/test.gen | 10 | ||||
-rw-r--r-- | gens/test_basic.gen | 2 | ||||
-rw-r--r-- | gens/test_voice.gen | 2 | ||||
-rwxr-xr-x | make_n_gen.sh | 14 | ||||
-rw-r--r-- | src/client.rs | 12 | ||||
-rw-r--r-- | src/lib.rs | 2 | ||||
-rw-r--r-- | src/proto.rs | 17 | ||||
-rw-r--r-- | src/seq/file/mod.rs | 2 |
8 files changed, 55 insertions, 6 deletions
diff --git a/gens/test.gen b/gens/test.gen index 4613c0c..e891ebe 100644 --- a/gens/test.gen +++ b/gens/test.gen @@ -19,5 +19,15 @@ #gens/test_basic.gen#, #gens/test_basic.gen#, #gens/test_basic.gen#, + #gens/test_basic.gen#, + #gens/test_basic.gen#, + #gens/test_basic.gen#, + #gens/test_basic.gen#, + #gens/test_basic.gen#, + #gens/test_basic.gen#, + #gens/test_basic.gen#, + #gens/test_basic.gen#, + #gens/test_basic.gen#, + #gens/test_basic.gen#, #gens/test_basic.gen# ] diff --git a/gens/test_basic.gen b/gens/test_basic.gen index cbbfbbc..50620f8 100644 --- a/gens/test_basic.gen +++ b/gens/test_basic.gen @@ -1 +1 @@ -lutgen(sine(lut_freq), 128, v_freq) * ifelse(v_frame < v_deadline, v_amp, 0) +lutgen(saw(lut_freq), 128, v_freq) * ifelse(v_frame < v_deadline, v_amp, 0) diff --git a/gens/test_voice.gen b/gens/test_voice.gen index 41684c1..d4ae66a 100644 --- a/gens/test_voice.gen +++ b/gens/test_voice.gen @@ -1 +1 @@ -(lutgen(sine(lut_freq), 128, v_freq) * controlrate(dahdsr(v_frame < v_deadline, 0, 4 / samplerate(), 0, 1, 1, 8 / samplerate()))) * v_amp +(lutgen(saw(lut_freq), 128, v_freq) * dahdsr(v_frame < v_deadline, 0, 8 / samplerate(), 0, 0, 1, 4 / samplerate())) * v_amp diff --git a/make_n_gen.sh b/make_n_gen.sh new file mode 100755 index 0000000..cebb165 --- /dev/null +++ b/make_n_gen.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +GEN="${2:-gens/test_basic.gen}" + +echo "[" +for i in $(seq $1); do + echo -ne "\t#${GEN}#" + if [ "$i" -eq "$1" ]; then + echo + else + echo "," + fi +done +echo "]" diff --git a/src/client.rs b/src/client.rs index b8518b3..5cf941a 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1,5 +1,5 @@ use std::net::{UdpSocket, SocketAddr}; -use std::{io, mem}; +use std::{io, mem, iter}; use synth::*; use proto::*; @@ -111,6 +111,16 @@ impl Client { self.socket.send_to(&reply_buffer, sender); }, Command::PCM{..} => { /* TODO */ }, + Command::PCMSyn{..} => { /* TODO */}, + Command::ArtParam{voice, index, value} => { + dprintln!("Articulation parameter voice {:?} index {} value {}", voice, index, value); + for vidx in match voice { + Some(vidx) => ((vidx as usize)..((vidx+1) as usize)), + None => (0..self.voices.len()), + } { + *self.voices[vidx].params.vars.entry(format!("artp{}", index)).or_insert_with(Default::default) = value; + } + }, Command::Unknown{data} => { dprintln!("Dropping packet: unknown data {:?}", (&data as &[u8])); }, @@ -1,5 +1,3 @@ -#![feature(unicode)] - extern crate byteorder; extern crate rand; extern crate unicode_xid; diff --git a/src/proto.rs b/src/proto.rs index 279cd3f..21e8903 100644 --- a/src/proto.rs +++ b/src/proto.rs @@ -14,6 +14,8 @@ pub enum Command { Play{sec: u32, usec: u32, freq: u32, amp: f32, voice: u32}, Caps{voices: u32, tp: [u8; 4], ident: [u8; 24]}, PCM{samples: [i16; 16]}, + PCMSyn{buffered: u32}, + ArtParam{voice: Option<u32>, index: u32, value: f32}, Unknown{data: [u8; Command::SIZE]}, } @@ -60,6 +62,13 @@ impl Command { NetworkEndian::write_u32(&mut ret[..4], 5); NetworkEndian::write_i16_into(&samples, &mut ret[4..]); }, + Command::PCMSyn{buffered} => { + NetworkEndian::write_u32_into(&[6u32, buffered], &mut ret[..8]); + }, + Command::ArtParam{voice, index, value} => { + NetworkEndian::write_u32_into(&[7u32, voice.unwrap_or(OBLIGATE_POLYPHONE), index], &mut ret[..12]); + NetworkEndian::write_f32(&mut ret[12..16], value); + }, Command::Unknown{data} => { ret.copy_from_slice(&data); }, @@ -79,6 +88,8 @@ impl fmt::Debug for Command { Command::Play{sec, usec, freq, amp, voice} => f.debug_struct("Play").field("sec", &sec).field("usec", &usec).field("freq", &freq).field("amp", &).field("voice", &voice).finish(), Command::Caps{voices, tp, ident} => f.debug_struct("Caps").field("voices", &voices).field("tp", &tp).field("ident", &ident).finish(), Command::PCM{samples} => f.debug_struct("PCM").field("samples", &samples).finish(), + Command::PCMSyn{buffered} => f.debug_struct("PCMSyn").field("buffered", &buffered).finish(), + Command::ArtParam{voice, index, value} => f.debug_struct("ArtParam").field("voice", &voice).field("index", &index).field("value", &value).finish(), Command::Unknown{data} => f.debug_struct("Unknown").field("data", &(&data as &[u8])).finish(), } } @@ -122,6 +133,12 @@ impl<'a> From<&'a [u8; Command::SIZE]> for Command { ::byteorder::LittleEndian::read_i16_into(&packet[4..], &mut samples); Command::PCM{samples: samples} }, + 6 => Command::PCMSyn{buffered: fields_u32[1]}, + 7 => Command::ArtParam { + voice: if fields_u32[1] == OBLIGATE_POLYPHONE { None } else { Some(fields_u32[1]) }, + index: fields_u32[2], + value: fields_f32[3], + }, _ => { let mut data: [u8; Command::SIZE] = unsafe { mem::uninitialized() }; data.copy_from_slice(packet); diff --git a/src/seq/file/mod.rs b/src/seq/file/mod.rs index 64c8212..12662f8 100644 --- a/src/seq/file/mod.rs +++ b/src/seq/file/mod.rs @@ -1,4 +1,4 @@ -pub mod iv; +//pub mod iv; //pub mod midi; use super::*; |