Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PoroCYon
oidos
Commits
e139e659
Commit
e139e659
authored
Sep 16, 2017
by
Aske Simon Christensen
Browse files
Use safe float transmutations from Rust 1.20
parent
c5bc388b
Changes
3
Show whitespace changes
Inline
Side-by-side
reverb/src/lib.rs
View file @
e139e659
...
...
@@ -5,7 +5,6 @@
extern
crate
vst2
;
use
std
::
cmp
::
Ordering
;
use
std
::
mem
::
transmute
;
use
vst2
::
buffer
::
AudioBuffer
;
use
vst2
::
plugin
::{
Category
,
Info
,
Plugin
};
...
...
@@ -52,12 +51,12 @@ fn quantize(value: f32, level: f32) -> f32 {
let
bit
=
1
<<
((
level
*
31.0
)
.floor
()
as
i32
);
let
mask
=
!
bit
+
1
;
let
add
=
bit
>>
1
;
let
mut
bits
=
unsafe
{
transmute
::
<
f32
,
u32
>
(
value
)
}
;
bits
=
(
bits
+
add
)
&
mask
;
let
mut
bits
=
value
.to_bits
()
;
bits
=
bits
.wrapping_add
(
add
)
&
mask
;
if
bits
==
0x80000000
{
bits
=
0x00000000
;
}
unsafe
{
transmute
::
<
u32
,
f32
>
(
bits
)
}
f32
::
from_bits
(
bits
)
}
...
...
synth/src/oidos_generate.rs
View file @
e139e659
use
std
::{
f32
,
f64
};
use
std
::
mem
::
transmute
;
use
std
::
ops
::{
Index
};
#[cfg(test)]
use
std
::
collections
::
HashMap
;
...
...
@@ -85,12 +84,12 @@ fn quantize(value: f32, level: f32) -> f32 {
let
bit
=
1
<<
((
level
*
31.0
)
.floor
()
as
i32
);
let
mask
=
!
bit
+
1
;
let
add
=
bit
>>
1
;
let
mut
bits
=
unsafe
{
transmute
::
<
f32
,
u32
>
(
value
)
}
;
let
mut
bits
=
value
.to_bits
()
;
bits
=
bits
.wrapping_add
(
add
)
&
mask
;
if
bits
==
0x80000000
{
bits
=
0x00000000
;
}
unsafe
{
transmute
::
<
u32
,
f32
>
(
bits
)
}
f32
::
from_bits
(
bits
)
}
#[derive(Clone,
PartialEq)]
...
...
synth/src/synth.rs
View file @
e139e659
use
std
::
collections
::{
HashMap
,
VecDeque
};
use
std
::
marker
::
PhantomData
;
use
std
::
mem
::
transmute
;
use
std
::
sync
::
RwLock
;
use
vst2
::
api
::
Supported
;
...
...
@@ -333,7 +332,7 @@ impl<G: SoundGenerator, S: SynthInfo> SynthPlugin<G, S> {
}
fn
infinitesimal_change
(
value
:
f32
)
->
f32
{
let
mut
bits
=
unsafe
{
transmute
::
<
f32
,
u32
>
(
value
)
}
;
let
mut
bits
=
value
.to_bits
()
;
bits
+=
1
;
unsafe
{
transmute
::
<
u32
,
f32
>
(
bits
)
}
f32
::
from_bits
(
bits
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment