diff --git a/src/roland/layers/mod.rs b/src/roland/layers/mod.rs index 96dcbcb..b2d987f 100644 --- a/src/roland/layers/mod.rs +++ b/src/roland/layers/mod.rs @@ -20,8 +20,8 @@ pub struct LogicalLayer { pub external: ExternalLayer, pub tone: ToneLayer, pub piano: PianoLayer, - pub e_piano: EPianoLayer, - pub tone_wheel: ToneWheelLayer + pub unused_e_piano: EPianoLayer, + pub unused_tone_wheel: ToneWheelLayer } impl LogicalLayer { @@ -39,8 +39,8 @@ impl LogicalLayer { external: ext.remove(0), tone: tone.remove(0), piano: pno.remove(0), - e_piano: ep.remove(0), - tone_wheel: tw.remove(0), + unused_e_piano: ep.remove(0), + unused_tone_wheel: tw.remove(0), }); } Box::new(layers.try_into().unwrap()) diff --git a/src/roland/live_set/common.rs b/src/roland/live_set/common.rs index 1ab3762..fac7d66 100644 --- a/src/roland/live_set/common.rs +++ b/src/roland/live_set/common.rs @@ -26,7 +26,7 @@ pub struct Common { s2_assign: ButtonFunction, // 0-17 s1_state: bool, s2_state: bool, - eq_settings: Bits<68>, + unused_eq_settings: Bits<68>, key_touch_velocity: KeyTouchVelocity, key_touch_curve_type: KeyTouchCurveType, key_touch_curve_offset: OffsetU8<10>, // 0-19 (-10 - +9) @@ -39,8 +39,8 @@ pub struct Common { split_switch_internal: bool, split_switch_external: bool, #[serde(with = "serialize_map_keys_in_order")] - harmonic_bar_assign: HashMap>, // index=(LOWER2:ON, LOWER2:OFF, LOWER1:ON, LOWER1:OFF, UPPER2:ON, UPPER2:OFF, UPPER1:ON, UPPER1:OFF) - mfx_control_destination: Layer, + unused_harmonic_bar_assign: HashMap>, // index=(LOWER2:ON, LOWER2:OFF, LOWER1:ON, LOWER1:OFF, UPPER2:ON, UPPER2:OFF, UPPER1:ON, UPPER1:OFF) + unused_mfx_control_destination: Layer, #[serde(skip_serializing_if="Bits::is_zero", default="Bits::zero")] unused: Bits<7> } @@ -68,7 +68,7 @@ impl Bytes<56> for Common { bits.set_u8::<5>(self.s2_assign.into(), 0, 17)?; bits.set_bool(self.s1_state); bits.set_bool(self.s2_state); - bits.set_bits(&self.eq_settings); + bits.set_bits(&self.unused_eq_settings); bits.set_u8::<7>(self.key_touch_velocity.into(), 0, 127)?; bits.set_u8::<3>(self.key_touch_curve_type.into(), 1, 5)?; bits.set_u8::<5>(self.key_touch_curve_offset.into(), 0, 19)?; @@ -82,11 +82,11 @@ impl Bytes<56> for Common { bits.set_bool(self.split_switch_internal); bits.set_bool(self.split_switch_external); for layer in Layer::iter().rev() { - let state_map = self.harmonic_bar_assign.get(&layer).unwrap(); + let state_map = self.unused_harmonic_bar_assign.get(&layer).unwrap(); bits.set_u8::<4>(state_map.on.into(), 1, 9)?; bits.set_u8::<4>(state_map.off.into(), 1, 9)?; } - bits.set_u8::<2>(self.mfx_control_destination.into(), 0, 3)?; + bits.set_u8::<2>(self.unused_mfx_control_destination.into(), 0, 3)?; bits.set_bits(&self.unused); Ok(()) }) @@ -149,7 +149,7 @@ impl Bytes<56> for Common { s2_assign, s1_state, s2_state, - eq_settings, + unused_eq_settings: eq_settings, key_touch_velocity, key_touch_curve_type, key_touch_curve_offset, @@ -160,8 +160,8 @@ impl Bytes<56> for Common { slider_assign, split_switch_internal, split_switch_external, - harmonic_bar_assign, - mfx_control_destination: data.get_u8::<2>(0, 3)?.into(), + unused_harmonic_bar_assign: harmonic_bar_assign, + unused_mfx_control_destination: data.get_u8::<2>(0, 3)?.into(), unused: data.get_bits() }) }) diff --git a/src/roland/live_set/mod.rs b/src/roland/live_set/mod.rs index 9484713..20936f6 100644 --- a/src/roland/live_set/mod.rs +++ b/src/roland/live_set/mod.rs @@ -18,17 +18,17 @@ mod song_rhythm; mod mfx; mod resonance; -//TODO (LAST) modify live set to separate real and unused layers/parameters in 300nx vs 700nx - #[derive(Serialize, Deserialize, Debug)] pub struct LiveSet { common: Common, // 56 bytes song_rhythm: SongRhythm, // 6 bytes chorus: Chorus, // 42 bytes reverb: Reverb, // 42 bytes - mfx: Box<[Mfx; 8]>, // 608 bytes - resonance: Resonance, // 76 bytes - layers: Box<[LogicalLayer; 4]>, // 332*4=1328 bytes + mfx: Mfx, // 76 bytes + unused_mfx: Box<[Mfx; 7]>, // 532 bytes + unused_resonance: Resonance, // 76 bytes + layers: Box<[LogicalLayer; 3]>, // 332*3=996 bytes + unused_layer: LogicalLayer, // 332 bytes #[serde(skip_serializing_if="Bits::is_unit", default="Bits::unit")] padding: Bits<8>, // 1 byte // checksum: 1 byte @@ -47,15 +47,30 @@ impl Bytes<2160> for LiveSet { let song_rhythm = SongRhythm::from_bytes(data.get_bytes())?; let chorus = Chorus::from_bytes(data.get_bytes())?; let reverb = Reverb::from_bytes(data.get_bytes())?; - let mfx = Mfx::array_from_bytes(data)?; - let resonance = Resonance::from_bytes(data.get_bytes())?; + let mfx = Mfx::from_bytes(data.get_bytes())?; + let unused_mfx = Mfx::array_from_bytes(data)?; + let unused_resonance = Resonance::from_bytes(data.get_bytes())?; let internal_layers = InternalLayer::array_from_bytes(data)?; + let unused_internal_layer = InternalLayer::from_bytes(data.get_bytes())?; let external_layers = ExternalLayer::array_from_bytes(data)?; + let unused_external_layer = ExternalLayer::from_bytes(data.get_bytes())?; let tone_layers = ToneLayer::array_from_bytes(data)?; + let unused_tone_layer = ToneLayer::from_bytes(data.get_bytes())?; let piano_layers = PianoLayer::array_from_bytes(data)?; + let unused_piano_layer = PianoLayer::from_bytes(data.get_bytes())?; let e_piano_layers = EPianoLayer::array_from_bytes(data)?; + let unused_e_piano_layer = EPianoLayer::from_bytes(data.get_bytes())?; let tone_wheel_layers = ToneWheelLayer::array_from_bytes(data)?; + let unused_tone_wheel_layer = ToneWheelLayer::from_bytes(data.get_bytes())?; let layers = LogicalLayer::from_layers(internal_layers, external_layers, tone_layers, piano_layers, e_piano_layers, tone_wheel_layers); + let unused_layer = LogicalLayer { + internal: unused_internal_layer, + external: unused_external_layer, + tone: unused_tone_layer, + piano: unused_piano_layer, + unused_e_piano: unused_e_piano_layer, + unused_tone_wheel: unused_tone_wheel_layer, + }; let padding = data.get_bits(); let expected_sum_to_zero = sum_to_zero(data.sum_previous_bytes()); let found_sum_to_zero = data.get_full_u8(); @@ -71,8 +86,10 @@ impl Bytes<2160> for LiveSet { chorus, reverb, mfx, - resonance, + unused_mfx, + unused_resonance, layers, + unused_layer, padding }) }) @@ -84,28 +101,35 @@ impl Bytes<2160> for LiveSet { bs.set_bytes(self.song_rhythm.to_bytes()?); bs.set_bytes(self.chorus.to_bytes()?); bs.set_bytes(self.reverb.to_bytes()?); - for mfx in self.mfx.iter() { + bs.set_bytes(self.mfx.to_bytes()?); + for mfx in self.unused_mfx.iter() { bs.set_bytes(mfx.to_bytes()?); } - bs.set_bytes(self.resonance.to_bytes()?); + bs.set_bytes(self.unused_resonance.to_bytes()?); for layer in self.layers.iter() { bs.set_bytes(layer.internal.to_bytes()?); } + bs.set_bytes(self.unused_layer.internal.to_bytes()?); for layer in self.layers.iter() { bs.set_bytes(layer.external.to_bytes()?); } + bs.set_bytes(self.unused_layer.external.to_bytes()?); for layer in self.layers.iter() { bs.set_bytes(layer.tone.to_bytes()?); } + bs.set_bytes(self.unused_layer.tone.to_bytes()?); for layer in self.layers.iter() { bs.set_bytes(layer.piano.to_bytes()?); } + bs.set_bytes(self.unused_layer.piano.to_bytes()?); for layer in self.layers.iter() { - bs.set_bytes(layer.e_piano.to_bytes()?); + bs.set_bytes(layer.unused_e_piano.to_bytes()?); } + bs.set_bytes(self.unused_layer.unused_e_piano.to_bytes()?); for layer in self.layers.iter() { - bs.set_bytes(layer.tone_wheel.to_bytes()?); + bs.set_bytes(layer.unused_tone_wheel.to_bytes()?); } + bs.set_bytes(self.unused_layer.unused_tone_wheel.to_bytes()?); bs.set_bits(&self.padding); let sum_to_zero = sum_to_zero(bs.sum_previous_bytes()); bs.set_full_u8(sum_to_zero); @@ -124,9 +148,11 @@ impl Json for LiveSet { ("song_rhythm".to_string(), self.song_rhythm.to_structured_json()), ("chorus".to_string(), self.chorus.to_structured_json()), ("reverb".to_string(), self.reverb.to_structured_json()), - ("mfx".to_string(), StructuredJson::from_collection(self.mfx.as_slice(), |_| None)), - ("resonance".to_string(), self.resonance.to_structured_json()), - ("layers".to_string(), StructuredJson::from_collection(self.layers.as_slice(), |l| Some(l.tone.tone_name()))) + ("mfx".to_string(), self.mfx.to_structured_json()), + ("unused_mfx".to_string(), StructuredJson::from_collection(self.unused_mfx.as_slice(), |_| None)), + ("unused_resonance".to_string(), self.unused_resonance.to_structured_json()), + ("layers".to_string(), StructuredJson::from_collection(self.layers.as_slice(), |l| Some(l.tone.tone_name()))), + ("unused_layer".to_string(), self.unused_layer.to_structured_json()) ]) } @@ -135,9 +161,11 @@ impl Json for LiveSet { let song_rhythm = structured_json.extract("song_rhythm")?.to()?; let chorus = structured_json.extract("chorus")?.to()?; let reverb = structured_json.extract("reverb")?.to()?; - let mfx = structured_json.extract("mfx")?.to_array()?; - let resonance = structured_json.extract("resonance")?.to()?; + let mfx = structured_json.extract("mfx")?.to()?; + let unused_mfx = structured_json.extract("unused_mfx")?.to_array()?; + let unused_resonance = structured_json.extract("unused_resonance")?.to()?; let layers = structured_json.extract("layers")?.to_array()?; + let unused_layer = structured_json.extract("unused_layer")?.to()?; structured_json.done()?; Ok(Self { common, @@ -145,8 +173,10 @@ impl Json for LiveSet { chorus, reverb, mfx, - resonance, + unused_mfx, + unused_resonance, layers, + unused_layer, padding: Bits::unit() }) } diff --git a/src/roland/system/favorites.rs b/src/roland/system/favorites.rs index 205b331..79dac07 100644 --- a/src/roland/system/favorites.rs +++ b/src/roland/system/favorites.rs @@ -7,8 +7,10 @@ use crate::roland::types::numeric::{OneIndexedU16, OneIndexedU8}; #[derive(Serialize, Deserialize, Debug)] pub struct Favorites { - one_touch_piano_current_number: [OneIndexedU8; 3], - one_touch_e_piano_current_number: [OneIndexedU8; 3], + one_touch_piano_current_number: OneIndexedU8, + unused_one_touch_piano_current_number: [OneIndexedU8; 2], + one_touch_e_piano_current_number: OneIndexedU8, + unused_one_touch_e_piano_current_number: [OneIndexedU8; 2], bank_a: Bank, bank_b: Bank, bank_c: Bank, @@ -31,10 +33,12 @@ impl Favorites { impl Bytes<76> for Favorites { fn to_bytes(&self) -> Result, BytesError> { BitStream::write_fixed(|bits| { - for value in self.one_touch_piano_current_number { + bits.set_u8::<7>(self.one_touch_piano_current_number.into(), 0, 127)?; + for value in self.unused_one_touch_piano_current_number { bits.set_u8::<7>(value.into(), 0, 127)?; } - for value in self.one_touch_e_piano_current_number { + bits.set_u8::<7>(self.one_touch_e_piano_current_number.into(), 0, 127)?; + for value in self.unused_one_touch_e_piano_current_number { bits.set_u8::<7>(value.into(), 0, 127)?; } for bank in self.all_banks() { @@ -46,13 +50,15 @@ impl Bytes<76> for Favorites { fn from_bytes(bytes: Box<[u8; Self::BYTE_SIZE]>) -> Result where Self: Sized { BitStream::read_fixed(bytes, |bs| { - let mut one_touch_piano_current_number = [OneIndexedU8::default(); 3]; - for i in 0..one_touch_piano_current_number.len() { - one_touch_piano_current_number[i] = bs.get_u8::<7>(0, 127)?.into(); + let one_touch_piano_current_number = bs.get_u8::<7>(0, 127)?.into(); + let mut unused_one_touch_piano_current_number = [OneIndexedU8::default(); 2]; + for i in 0..unused_one_touch_piano_current_number.len() { + unused_one_touch_piano_current_number[i] = bs.get_u8::<7>(0, 127)?.into(); } - let mut one_touch_e_piano_current_number = [OneIndexedU8::default(); 3]; - for i in 0..one_touch_e_piano_current_number.len() { - one_touch_e_piano_current_number[i] = bs.get_u8::<7>(0, 127)?.into(); + let one_touch_e_piano_current_number = bs.get_u8::<7>(0, 127)?.into(); + let mut unused_one_touch_e_piano_current_number = [OneIndexedU8::default(); 2]; + for i in 0..unused_one_touch_e_piano_current_number.len() { + unused_one_touch_e_piano_current_number[i] = bs.get_u8::<7>(0, 127)?.into(); } let bank_a = Bank::from_bits(bs.get_bits())?; let bank_b = Bank::from_bits(bs.get_bits())?; @@ -60,7 +66,9 @@ impl Bytes<76> for Favorites { let bank_d = Bank::from_bits(bs.get_bits())?; Ok(Self { one_touch_piano_current_number, + unused_one_touch_piano_current_number, one_touch_e_piano_current_number, + unused_one_touch_e_piano_current_number, bank_a, bank_b, bank_c, @@ -90,17 +98,24 @@ impl Json for Favorites { } #[derive(Serialize, Deserialize, Debug)] -pub struct Bank([Favorite; Self::FAVORITES_PER_BANK]); +pub struct Bank { + favorites: [Favorite; Self::USED_FAVORITES], + unused_favorites: [Favorite; Self::FAVORITES_PER_BANK - Self::USED_FAVORITES] +} impl Bank { + const USED_FAVORITES: usize = 6; const FAVORITES_PER_BANK: usize = 10; const BITS_SIZE: usize = Favorite::BITS_SIZE * Self::FAVORITES_PER_BANK; fn to_bits(&self) -> Result, BytesError> { BitStream::write_fixed_bits(|bits| { - for favorite in &self.0 { + for favorite in &self.favorites { bits.set_bits(&favorite.to_bits()?); } + for unused_favorite in &self.unused_favorites { + bits.set_bits(&unused_favorite.to_bits()?); + } Ok(()) }) } @@ -108,10 +123,17 @@ impl Bank { fn from_bits(bits: Bits<{Self::BITS_SIZE}>) -> Result where Self: Sized { BitStream::read_fixed_bits(bits, |data| { let mut favorites = Vec::new(); - for _ in 0..Self::FAVORITES_PER_BANK { + for _ in 0..Self::USED_FAVORITES { favorites.push(Favorite::from_bits(data.get_bits())?); } - Ok(Self(favorites.try_into().unwrap())) + let mut unused_favorites = Vec::new(); + for _ in 0..Self::FAVORITES_PER_BANK - Self::USED_FAVORITES { + unused_favorites.push(Favorite::from_bits(data.get_bits())?); + } + Ok(Self { + favorites: favorites.try_into().unwrap(), + unused_favorites: unused_favorites.try_into().unwrap() + }) }) } } diff --git a/src/roland/types/enums.rs b/src/roland/types/enums.rs index 4f3213a..d05d8cf 100644 --- a/src/roland/types/enums.rs +++ b/src/roland/types/enums.rs @@ -234,7 +234,7 @@ pub enum Layer { // 0-3 Upper1, Upper2, Lower1, - Lower2 + UnusedLower2 } impl From for Layer { @@ -457,7 +457,7 @@ impl Default for ReverbType { pub enum SoundFocusType { // 0-31 PianoType1, PianoType2, - EPianoType, // RD700NX only + UnusedEPianoType, // RD700NX only SoundLift, Enhancer, MidBoost, @@ -570,13 +570,13 @@ pub enum MfxType { // 0-255 ChorusDelay, FlangerDelay, ChorusFlanger, - VrChorus, //RD700NX only - VrTremolo, //RD700NX only - VrAutoWah, //RD700NX only - VrPhaser, //RD700NX only - OrganMulti, //RD700NX only - Linedrive, //RD700NX only - SmallPhaser, //RD700NX only + UnusedVrChorus, //RD700NX only + UnusedVrTremolo, //RD700NX only + UnusedVrAutoWah, //RD700NX only + UnusedVrPhaser, //RD700NX only + UnusedOrganMulti, //RD700NX only + UnusedLinedrive, //RD700NX only + UnusedSmallPhaser, //RD700NX only SympatheticResonance, //RD300NX only Other(u8) } @@ -794,7 +794,7 @@ pub enum ButtonFunction { // 0-20 SongBackward, SongForward, Mfx1Switch, - Mfx2Switch, + UnusedMfx2Switch, RotarySpeed, LiveSetUp, // system only LiveSetDown, // system only @@ -834,7 +834,7 @@ pub enum PedalFunction { // 0-146 (OFF, CC00 - CC127, BEND-UP, BEND-DOWN, AFTERT SongPlayStop, SongReset, Mfx1Switch, - Mfx2Switch, + UnusedMfx2Switch, RotarySpeed, SoundFocusValue, LiveSetUp, // system only @@ -878,7 +878,7 @@ pub enum SliderFunction { // 0-133 (OFF, CC00 - CC127, BEND-UP, BEND-DOWN, AFTER BendDown, AfterTouch, Mfx1Control, - Mfx2Control + UnusedMfx2Control } impl From for SliderFunction {