1
0
Fork 0

Use portable_simd from std instead of packed_simd

Since this seems to be the way forward and they encourage using the
feature flag instead of the using it as a separate crate.
This commit is contained in:
Robbert van der Helm 2022-03-01 20:59:31 +01:00
parent 8eafcebe62
commit 3f6f472a34
4 changed files with 12 additions and 29 deletions

17
Cargo.lock generated
View file

@ -281,7 +281,6 @@ name = "diopser"
version = "0.1.0"
dependencies = [
"nih_plug",
"packed_simd_2",
]
[[package]]
@ -465,12 +464,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "libm"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a"
[[package]]
name = "lock_api"
version = "0.4.6"
@ -644,16 +637,6 @@ dependencies = [
"ttf-parser",
]
[[package]]
name = "packed_simd_2"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "defdcfef86dcc44ad208f71d9ff4ce28df6537a4e0d6b0e8e845cb8ca10059a6"
dependencies = [
"cfg-if",
"libm",
]
[[package]]
name = "parking_lot"
version = "0.12.0"

View file

@ -10,10 +10,8 @@ crate-type = ["cdylib"]
[features]
default = ["simd"]
# Make it go fast, vroom
simd = ["packed_simd"]
# Make it go fast, vroom. Requires a nightly compiler.
simd = []
[dependencies]
nih_plug = { path = "../../", features = ["assert_process_allocs"] }
packed_simd = { version = "0.3.6", package = "packed_simd_2", optional = true }

View file

@ -18,7 +18,7 @@ use std::f32::consts;
use std::ops::{Add, Mul, Sub};
#[cfg(feature = "simd")]
use packed_simd::f32x2;
use std::simd::f32x2;
/// A simple biquad filter with functions for generating coefficients for an all-pass filter.
///

View file

@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#![cfg_attr(feature = "simd", feature(portable_simd))]
#[macro_use]
extern crate nih_plug;
@ -28,7 +30,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
#[cfg(feature = "simd")]
use packed_simd::f32x2;
use std::simd::f32x2;
mod filter;
@ -282,10 +284,10 @@ impl Plugin for Diopser {
// supports steroo audio.
#[cfg(feature = "simd")]
{
let mut samples =
f32x2::new(*unsafe { channel_samples.get_unchecked_mut(0) }, *unsafe {
channel_samples.get_unchecked_mut(1)
});
let mut samples = f32x2::from_array([
*unsafe { channel_samples.get_unchecked_mut(0) },
*unsafe { channel_samples.get_unchecked_mut(1) },
]);
for filter in self
.filters
@ -295,8 +297,8 @@ impl Plugin for Diopser {
samples = filter.process(samples);
}
*unsafe { channel_samples.get_unchecked_mut(0) } = samples.extract(0);
*unsafe { channel_samples.get_unchecked_mut(1) } = samples.extract(1);
*unsafe { channel_samples.get_unchecked_mut(0) } = samples.as_array()[0];
*unsafe { channel_samples.get_unchecked_mut(1) } = samples.as_array()[1];
}
#[cfg(not(feature = "simd"))]