diff --git a/Cargo.lock b/Cargo.lock index d1a4b6e..679d06d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -838,12 +838,6 @@ dependencies = [ "libc", ] -[[package]] -name = "core_detect" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" - [[package]] name = "core_maths" version = "0.1.1" @@ -1072,20 +1066,6 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" -[[package]] -name = "encoding_rs" -version = "0.8.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e985e0451871ad22fb8d2b6b076e2028a502a0d3950998c2c5c0a4f9b5d9679" -dependencies = [ - "cfg-if", - "core_detect", - "multiversion_no_op", - "rustversion", - "scopeguard", - "simdutf8", -] - [[package]] name = "endi" version = "1.1.1" @@ -1825,9 +1805,9 @@ dependencies = [ [[package]] name = "iced_drop" -version = "0.2.53" +version = "0.2.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a83a84bafcdc9b7db7419734babd0e48397c0e307e375ded755cf746c7e6f21" +checksum = "5459a21e5793a18bc40756f2872590bbfd2ba5ab4e528658e4b6ffcbc5c9b8bf" dependencies = [ "iced", "iced_core", @@ -2548,12 +2528,12 @@ checksum = "0806877c16abfdc601427c661ac1afbe142c0f77701debe586997911af2f25fe" [[package]] name = "maolan-editor" -version = "0.1.4" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc33537a863a890bffd1c54e12e249fe2f83fbc39be801d7eff06da3299718e6" +checksum = "538ad062373e4e615f6ff9e8bc7933d51df785b100d07f092b75735519e20f6e" dependencies = [ "maolan-widgets", - "rfd", + "rfd 0.18.0", "rubato", "serde", "serde_json", @@ -2585,12 +2565,12 @@ dependencies = [ "rand 0.10.3", "raw-window-handle", "rayon", - "rfd", + "rfd 0.17.2", "rustfft", "serde", "serde_json", "sha2", - "symphonia 0.6.1", + "symphonia", "thiserror 2.0.21", "tracing", "ureq", @@ -2600,16 +2580,18 @@ dependencies = [ [[package]] name = "maolan-widgets" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3191c14ec75e04d40fc622d6f15f81f8c637fe41df51e5c8bfbf9cbe2fa447af" +checksum = "b93e91ffe56a67ea22d8b5851439545a6398919802b635793ccd673cdb2bf360" dependencies = [ + "bytemuck", "iced", "iced_aw", "iced_drop", "iced_fonts", + "iced_wgpu", "serde", - "symphonia 0.5.5", + "symphonia", ] [[package]] @@ -2691,12 +2673,6 @@ dependencies = [ "pxfm", ] -[[package]] -name = "multiversion_no_op" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d" - [[package]] name = "mundy" version = "0.2.3" @@ -2994,6 +2970,7 @@ dependencies = [ "objc2-core-video", "objc2-foundation 0.3.2", "objc2-quartz-core 0.3.2", + "objc2-uniform-type-identifiers 0.3.2", ] [[package]] @@ -3256,7 +3233,7 @@ dependencies = [ "objc2-link-presentation", "objc2-quartz-core 0.2.2", "objc2-symbols", - "objc2-uniform-type-identifiers", + "objc2-uniform-type-identifiers 0.2.2", "objc2-user-notifications", ] @@ -3271,6 +3248,16 @@ dependencies = [ "objc2-foundation 0.2.2", ] +[[package]] +name = "objc2-uniform-type-identifiers" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7902ac02859fc1f7045f8b598c63f1ae0cc7efeaa06a9bc9f3d9a3c955974fa4" +dependencies = [ + "objc2 0.6.5", + "objc2-foundation 0.3.2", +] + [[package]] name = "objc2-user-notifications" version = "0.2.2" @@ -3564,6 +3551,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f3a9f18d041e6d0e102a0a46750538147e5e8992d3b4873aaafee2520b00ce3" +[[package]] +name = "pollster" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c2c80c4e3afbec8224b9d3e641fbf3a5690cc7595b887b0a27a926bb357ed5c" + [[package]] name = "portable-atomic" version = "1.15.0" @@ -3997,7 +3990,35 @@ dependencies = [ "objc2-core-foundation", "objc2-foundation 0.3.2", "percent-encoding", - "pollster", + "pollster 0.4.0", + "raw-window-handle", + "wasm-bindgen", + "wasm-bindgen-futures", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "web-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rfd" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4b9d4857b10297ffb0f64cae711e983a7aeaee561848d56d429d3858bd8ed93" +dependencies = [ + "block2 0.6.2", + "dispatch2", + "js-sys", + "libc", + "log", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "objc2-uniform-type-identifiers 0.3.2", + "percent-encoding", + "pollster 1.0.2", "raw-window-handle", "wasm-bindgen", "wasm-bindgen-futures", @@ -4036,9 +4057,9 @@ checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" [[package]] name = "rubato" -version = "5.0.1" +version = "5.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc1e951b9f5432ec1422f4dcfa5733fc501265902612edf5ef8bd8ecdd960930" +checksum = "6b4da228e06632d025557f798114057cf27a4c6a71d40024c84d6db82fa5ef4a" dependencies = [ "audioadapter", "audioadapter-buffers", @@ -4254,9 +4275,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e7523beb55eece201a2356bee0bbca0d1ab466c14c07703b2e0ee6d42cb0c2c" +checksum = "9c187e0a369471c550af028cba56d4f4fa2a489ad28151ae95a4d340a2a8b782" dependencies = [ "serde_core", ] @@ -4519,24 +4540,6 @@ dependencies = [ "zeno", ] -[[package]] -name = "symphonia" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5773a4c030a19d9bfaa090f49746ff35c75dfddfa700df7a5939d5e076a57039" -dependencies = [ - "lazy_static", - "symphonia-bundle-flac 0.5.5", - "symphonia-codec-adpcm 0.5.5", - "symphonia-codec-pcm 0.5.5", - "symphonia-codec-vorbis 0.5.5", - "symphonia-core 0.5.5", - "symphonia-format-mkv 0.5.5", - "symphonia-format-ogg 0.5.5", - "symphonia-format-riff 0.5.5", - "symphonia-metadata 0.5.5", -] - [[package]] name = "symphonia" version = "0.6.1" @@ -4544,31 +4547,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7edef6a96b696d4e0cab5ee9ebb7ca155ed95f30a6b45bbb8b97d2727f02424" dependencies = [ "lazy_static", - "symphonia-bundle-flac 0.6.1", + "symphonia-bundle-flac", "symphonia-bundle-mp3", "symphonia-codec-aac", - "symphonia-codec-adpcm 0.6.1", + "symphonia-codec-adpcm", "symphonia-codec-alac", - "symphonia-codec-pcm 0.6.1", - "symphonia-codec-vorbis 0.6.1", - "symphonia-core 0.6.1", + "symphonia-codec-pcm", + "symphonia-codec-vorbis", + "symphonia-core", "symphonia-format-isomp4", - "symphonia-format-mkv 0.6.1", - "symphonia-format-ogg 0.6.1", - "symphonia-format-riff 0.6.1", - "symphonia-metadata 0.6.1", -] - -[[package]] -name = "symphonia-bundle-flac" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c91565e180aea25d9b80a910c546802526ffd0072d0b8974e3ebe59b686c9976" -dependencies = [ - "log", - "symphonia-core 0.5.5", - "symphonia-metadata 0.5.5", - "symphonia-utils-xiph", + "symphonia-format-mkv", + "symphonia-format-ogg", + "symphonia-format-riff", + "symphonia-metadata", ] [[package]] @@ -4579,8 +4570,8 @@ checksum = "6405d5c34ff6f8f7ca08a4101efe66d21e180f7322ef9359900a0e55698a7892" dependencies = [ "log", "symphonia-common", - "symphonia-core 0.6.1", - "symphonia-metadata 0.6.1", + "symphonia-core", + "symphonia-metadata", ] [[package]] @@ -4591,7 +4582,7 @@ checksum = "98ea5ffc8716bff677dfb3b01b420c7b758de901a72b8c330bf2040ab74b4add" dependencies = [ "lazy_static", "log", - "symphonia-core 0.6.1", + "symphonia-core", ] [[package]] @@ -4603,17 +4594,7 @@ dependencies = [ "lazy_static", "log", "symphonia-common", - "symphonia-core 0.6.1", -] - -[[package]] -name = "symphonia-codec-adpcm" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dddc50e2bbea4cfe027441eece77c46b9f319748605ab8f3443350129ddd07f" -dependencies = [ - "log", - "symphonia-core 0.5.5", + "symphonia-core", ] [[package]] @@ -4623,7 +4604,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "445932ecb0c59362fde9c082dd63a75380650c5077fdb8b80b8cac850442a74c" dependencies = [ "log", - "symphonia-core 0.6.1", + "symphonia-core", ] [[package]] @@ -4634,17 +4615,7 @@ checksum = "920a78f96f3cf62932d0c497959c0cc2100ef36b03c7ca1417b260f432a482d8" dependencies = [ "log", "symphonia-common", - "symphonia-core 0.6.1", -] - -[[package]] -name = "symphonia-codec-pcm" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e89d716c01541ad3ebe7c91ce4c8d38a7cf266a3f7b2f090b108fb0cb031d95" -dependencies = [ - "log", - "symphonia-core 0.5.5", + "symphonia-core", ] [[package]] @@ -4654,18 +4625,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e04ba75686acbe43542fdd374571195f0530c0b7785ca25cc6840e9c6c4b6eea" dependencies = [ "log", - "symphonia-core 0.6.1", -] - -[[package]] -name = "symphonia-codec-vorbis" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f025837c309cd69ffef572750b4a2257b59552c5399a5e49707cc5b1b85d1c73" -dependencies = [ - "log", - "symphonia-core 0.5.5", - "symphonia-utils-xiph", + "symphonia-core", ] [[package]] @@ -4676,7 +4636,7 @@ checksum = "73d90b4fcf796137cc683c538282804ff9629f8ad9dbfd881fcbba331ac4e986" dependencies = [ "log", "symphonia-common", - "symphonia-core 0.6.1", + "symphonia-core", ] [[package]] @@ -4686,21 +4646,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2acc3fcc18ec9b8cdd48614e259c4cf0d27b71d41e5d9b120b42c5adab12d7c4" dependencies = [ "log", - "symphonia-core 0.6.1", - "symphonia-metadata 0.6.1", -] - -[[package]] -name = "symphonia-core" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea00cc4f79b7f6bb7ff87eddc065a1066f3a43fe1875979056672c9ef948c2af" -dependencies = [ - "arrayvec", - "bitflags 1.3.2", - "bytemuck", - "lazy_static", - "log", + "symphonia-core", + "symphonia-metadata", ] [[package]] @@ -4726,21 +4673,8 @@ checksum = "0e681a70e1870d34e02abf1dbc51e4267c3f1827801474e8870be8c689fc4dc3" dependencies = [ "log", "symphonia-common", - "symphonia-core 0.6.1", - "symphonia-metadata 0.6.1", -] - -[[package]] -name = "symphonia-format-mkv" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "122d786d2c43a49beb6f397551b4a050d8229eaa54c7ddf9ee4b98899b8742d0" -dependencies = [ - "lazy_static", - "log", - "symphonia-core 0.5.5", - "symphonia-metadata 0.5.5", - "symphonia-utils-xiph", + "symphonia-core", + "symphonia-metadata", ] [[package]] @@ -4752,19 +4686,7 @@ dependencies = [ "lazy_static", "log", "symphonia-common", - "symphonia-core 0.6.1", -] - -[[package]] -name = "symphonia-format-ogg" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b4955c67c1ed3aa8ae8428d04ca8397fbef6a19b2b051e73b5da8b1435639cb" -dependencies = [ - "log", - "symphonia-core 0.5.5", - "symphonia-metadata 0.5.5", - "symphonia-utils-xiph", + "symphonia-core", ] [[package]] @@ -4775,20 +4697,8 @@ checksum = "0b5495e7f7e3c7035328d82b6d6e377eef289bb0c4105bdeb557fc93a833f994" dependencies = [ "log", "symphonia-common", - "symphonia-core 0.6.1", - "symphonia-metadata 0.6.1", -] - -[[package]] -name = "symphonia-format-riff" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2d7c3df0e7d94efb68401d81906eae73c02b40d5ec1a141962c592d0f11a96f" -dependencies = [ - "extended", - "log", - "symphonia-core 0.5.5", - "symphonia-metadata 0.5.5", + "symphonia-core", + "symphonia-metadata", ] [[package]] @@ -4799,20 +4709,8 @@ checksum = "1ff70929083a8c1a5f6cd7c904b6071c7914ad04739b510c2f7239dfc9b7dabe" dependencies = [ "extended", "log", - "symphonia-core 0.6.1", - "symphonia-metadata 0.6.1", -] - -[[package]] -name = "symphonia-metadata" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36306ff42b9ffe6e5afc99d49e121e0bd62fe79b9db7b9681d48e29fa19e6b16" -dependencies = [ - "encoding_rs", - "lazy_static", - "log", - "symphonia-core 0.5.5", + "symphonia-core", + "symphonia-metadata", ] [[package]] @@ -4825,17 +4723,7 @@ dependencies = [ "log", "regex-lite", "smallvec", - "symphonia-core 0.6.1", -] - -[[package]] -name = "symphonia-utils-xiph" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee27c85ab799a338446b68eec77abf42e1a6f1bb490656e121c6e27bfbab9f16" -dependencies = [ - "symphonia-core 0.5.5", - "symphonia-metadata 0.5.5", + "symphonia-core", ] [[package]] @@ -5051,9 +4939,9 @@ dependencies = [ [[package]] name = "toml" -version = "1.1.8+spec-1.1.0" +version = "1.2.1+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20489e00e4d8741d6be680764cc12e270655e375a20d1011e844a9c3379e678d" +checksum = "d5755c51863cdac711f1956baf8eb9588e060755f7d3c4c979e70ea1e1f32cd7" dependencies = [ "indexmap", "serde_core", @@ -5066,9 +4954,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "1.1.2+spec-1.1.0" +version = "1.1.3+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b86d767906c6c42421dcba507eb9d203e779497710a47782a224bb871653053" +checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49" dependencies = [ "serde_core", ] @@ -5096,9 +4984,9 @@ dependencies = [ [[package]] name = "toml_writer" -version = "1.1.3+spec-1.1.0" +version = "1.2.0+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06bdbd8cfc056b8d2e2e85f29b56a3bdbecb527cef81eb39e3e7b98af4652770" +checksum = "009dbb7700f11c55ef83aebbe4c0e9cf1f1ac0844bd8d6f00dc38f302026e13a" [[package]] name = "tracing" diff --git a/Cargo.toml b/Cargo.toml index 3f921ed..a2d6f5f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ oxideav-flac = "0.0.12" pitch-detection = "0.3.0" symphonia = { version = "0.6.1", features = ["aac", "alac", "flac", "isomp4", "mp3", "ogg", "vorbis", "wav"] } maolan-baseview = { version = "0.1.1", features = ["canvas"] } -maolan-editor = { version = "0.1.4", default-features = false } +maolan-editor = { version = "0.1.6", default-features = false, features = ["embedded"] } maolan-widgets = "0.1.3" parking_lot = "0.13.0" portable-atomic = { version = "1.15.0", features = ["float"] } diff --git a/src/sampler/dsp/zone.rs b/src/sampler/dsp/zone.rs index 56e6ee1..212f120 100644 --- a/src/sampler/dsp/zone.rs +++ b/src/sampler/dsp/zone.rs @@ -188,6 +188,16 @@ impl SampleEditState { gain *= 10.0f32.powf(delta_db / 20.0); } } + AudioEditAction::Normalize { + start_sample, + length_samples, + peak, + } => { + let end = start_sample.saturating_add(length_samples).min(frames); + if frame >= start_sample && frame < end && peak.is_finite() && peak > 0.0 { + gain *= (1.0 / peak).min(64.0); + } + } AudioEditAction::ReplaceWithSilence { start_sample, length_samples, diff --git a/src/sampler/gui.rs b/src/sampler/gui.rs index eeaac11..2362b69 100644 --- a/src/sampler/gui.rs +++ b/src/sampler/gui.rs @@ -236,6 +236,7 @@ pub enum ZoneEditField { StartOffset, OffsetRandom, EndOffset, + DelayRandom, SeqLength, SeqPosition, OffBy, @@ -2029,6 +2030,9 @@ fn update(state: &mut State, message: Message) -> Task { ZoneEditField::EndOffset => { zone.end_offset = value.max(0.0).round() as usize; } + ZoneEditField::DelayRandom => { + zone.delay_random = value.clamp(0.0, 0.999999); + } ZoneEditField::SeqLength => { zone.seq_length = value.max(0.0).round() as u32; } @@ -4691,6 +4695,27 @@ fn zone_knob<'a>( knob_field(label, knob, value_text) } +fn delay_random_to_knob(value: f32) -> f32 { + ((value.clamp(0.0, 0.999999) / 0.999999 * (9.0_f32.exp() - 1.0) + 1.0).ln() / 9.0) + .clamp(0.0, 1.0) +} + +fn delay_random_from_knob(position: f32) -> f32 { + (((9.0 * position.clamp(0.0, 1.0)).exp() - 1.0) / (9.0_f32.exp() - 1.0)) * 0.999999 +} + +fn delay_random_knob(value: f32) -> Element<'static, Message> { + let knob = ArchSlider::new(0.0..=1.0, delay_random_to_knob(value), |position| { + Message::SetEditingZoneValue(ZoneEditField::DelayRandom, delay_random_from_knob(position)) + }) + .step(0.001) + .width(Length::Fixed(41.0)) + .height(Length::Fixed(41.0)) + .fill_from_start(); + + knob_field("Delay", knob, format!("{:.3}", value * 1000.0)) +} + fn zone_range_knob<'a>( label: &'static str, low: f32, @@ -5084,6 +5109,7 @@ fn editing_zone_controls<'a>( ZoneEditField::OffsetRandom, zone.offset_random.to_string(), ); + let delay_random = delay_random_knob(zone.delay_random); let end = zone_knob( "End", zone.end_offset as f32, @@ -5096,17 +5122,12 @@ fn editing_zone_controls<'a>( zone.end_offset.to_string() }, ); - let trigger = row![ - labeled_toggler( - "Trigger", - ZonePlayModeOption::all().to_vec(), - play_mode, - Message::SetEditingZonePlayMode, - ), - reverse_toggler(zone.reverse), - ] - .spacing(8) - .align_y(Alignment::Center); + let trigger = labeled_toggler( + "Trigger", + ZonePlayModeOption::all().to_vec(), + play_mode, + Message::SetEditingZonePlayMode, + ); let fades = row![ zone_range_knob( @@ -5225,17 +5246,20 @@ fn editing_zone_controls<'a>( ] .spacing(8) .align_y(Alignment::Start), - row![{ - let names = state.shared.output_names.load(); - let options = output_bus_options(&names, zone.output); - let selected = options - .iter() - .find(|option| option.index == zone.output as usize) - .cloned(); - output_bus_picker("Output", options, selected, |option| { - Message::SetEditingZoneValue(ZoneEditField::Output, option.index as f32) - }) - }] + row![ + { + let names = state.shared.output_names.load(); + let options = output_bus_options(&names, zone.output); + let selected = options + .iter() + .find(|option| option.index == zone.output as usize) + .cloned(); + output_bus_picker("Output", options, selected, |option| { + Message::SetEditingZoneValue(ZoneEditField::Output, option.index as f32) + }) + }, + trigger, + ] .spacing(8) .align_y(Alignment::Start), ] @@ -5290,7 +5314,7 @@ fn editing_zone_controls<'a>( row![amp_key, vel_track, tune, offset] .spacing(8) .align_y(Alignment::Start), - row![offset_r, end, trigger] + row![offset_r, end, delay_random, reverse_toggler(zone.reverse)] .spacing(8) .align_y(Alignment::Start), ]