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
e4a51f92
Commit
e4a51f92
authored
Sep 02, 2018
by
Aske Simon Christensen
Browse files
No lock on cache, as it is local to the processing thread.
parent
4e55936e
Changes
1
Hide whitespace changes
Inline
Side-by-side
synth/src/synth.rs
View file @
e4a51f92
...
@@ -125,9 +125,10 @@ pub struct SynthPlugin<G: SoundGenerator, S: SynthInfo> {
...
@@ -125,9 +125,10 @@ pub struct SynthPlugin<G: SoundGenerator, S: SynthInfo> {
time
:
usize
,
time
:
usize
,
notes
:
Vec
<
Note
>
,
notes
:
Vec
<
Note
>
,
events
:
VecDeque
<
TimedMidiCommand
>
,
events
:
VecDeque
<
TimedMidiCommand
>
,
cache
:
RwLock
<
Vec
<
SoundCache
<
G
>>>
,
cache
:
Vec
<
SoundCache
<
G
>>
,
cached_sound_params
:
G
::
Parameters
,
cached_sound_params
:
G
::
Parameters
,
param_values
:
Vec
<
f32
>
,
param_values
:
Vec
<
f32
>
,
params
:
RwLock
<
SynthPluginParameters
<
G
>>
,
params
:
RwLock
<
SynthPluginParameters
<
G
>>
,
...
@@ -172,7 +173,7 @@ impl<G: SoundGenerator, S: SynthInfo> Default for SynthPlugin<G, S> {
...
@@ -172,7 +173,7 @@ impl<G: SoundGenerator, S: SynthInfo> Default for SynthPlugin<G, S> {
time
:
0
,
time
:
0
,
notes
:
Vec
::
new
(),
notes
:
Vec
::
new
(),
events
:
VecDeque
::
new
(),
events
:
VecDeque
::
new
(),
cache
:
RwLock
::
new
(
cache
)
,
cache
:
cache
,
cached_sound_params
:
sound_params
,
cached_sound_params
:
sound_params
,
param_values
:
param_values
,
param_values
:
param_values
,
...
@@ -232,9 +233,8 @@ impl<G: SoundGenerator, S: SynthInfo> Plugin for SynthPlugin<G, S> {
...
@@ -232,9 +233,8 @@ impl<G: SoundGenerator, S: SynthInfo> Plugin for SynthPlugin<G, S> {
{
{
let
params
:
&
SynthPluginParameters
<
G
>
=
&
self
.params
.read
()
.unwrap
();
let
params
:
&
SynthPluginParameters
<
G
>
=
&
self
.params
.read
()
.unwrap
();
if
params
.sound_params
!=
self
.cached_sound_params
{
if
params
.sound_params
!=
self
.cached_sound_params
{
let
cache
:
&
mut
Vec
<
SoundCache
<
G
>>
=
&
mut
self
.cache
.write
()
.unwrap
();
self
.cached_sound_params
=
params
.sound_params
.clone
();
self
.cached_sound_params
=
params
.sound_params
.clone
();
for
c
in
cache
{
for
c
in
&
mut
self
.
cache
{
c
.invalidate
();
c
.invalidate
();
}
}
}
}
...
@@ -325,11 +325,10 @@ impl<G: SoundGenerator, S: SynthInfo> SynthPlugin<G, S> {
...
@@ -325,11 +325,10 @@ impl<G: SoundGenerator, S: SynthInfo> SynthPlugin<G, S> {
}
}
fn
produce_sample
(
&
mut
self
)
->
Sample
{
fn
produce_sample
(
&
mut
self
)
->
Sample
{
let
cache
:
&
mut
Vec
<
SoundCache
<
G
>>
=
&
mut
self
.cache
.write
()
.unwrap
();
let
mut
sample
:
Sample
=
Sample
::
from
(
0.0
);
let
mut
sample
:
Sample
=
Sample
::
from
(
0.0
);
for
i
in
(
0
..
self
.notes
.len
())
.rev
()
{
for
i
in
(
0
..
self
.notes
.len
())
.rev
()
{
if
self
.notes
[
i
]
.is_alive
()
{
if
self
.notes
[
i
]
.is_alive
()
{
sample
+=
self
.notes
[
i
]
.produce_sample
(
cache
,
&
self
.cached_sound_params
,
&
self
.global
);
sample
+=
self
.notes
[
i
]
.produce_sample
(
&
mut
self
.
cache
,
&
self
.cached_sound_params
,
&
self
.global
);
}
else
{
}
else
{
self
.notes
.remove
(
i
);
self
.notes
.remove
(
i
);
}
}
...
...
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