Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
plugin-GUI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
yehaojie
plugin-GUI
Commits
53ee2286
Commit
53ee2286
authored
9 years ago
by
Septen
Browse files
Options
Downloads
Patches
Plain Diff
CAR processor: added feature to use custom reference and affected channels combinations.
parent
7eaad3ab
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Source/Plugins/CAR/CAR.cpp
+49
-25
49 additions, 25 deletions
Source/Plugins/CAR/CAR.cpp
Source/Plugins/CAR/CAR.h
+23
-2
23 additions, 2 deletions
Source/Plugins/CAR/CAR.h
with
72 additions
and
27 deletions
Source/Plugins/CAR/CAR.cpp
+
49
−
25
View file @
53ee2286
...
...
@@ -27,12 +27,11 @@
CAR
::
CAR
()
:
GenericProcessor
(
"Common Avg Ref"
)
//, threshold(200.0), state(true)
:
GenericProcessor
(
"Common Avg Ref"
)
//, threshold(200.0), state(true)
{
parameters
.
add
(
Parameter
(
"Gain (%)"
,
0.0
,
100.0
,
100.0
,
0
));
avgBuffer
=
AudioSampleBuffer
(
1
,
10000
);
// 1-dimensional buffer to hold the avg
m_
avgBuffer
=
AudioSampleBuffer
(
1
,
10000
);
// 1-dimensional buffer to hold the avg
}
...
...
@@ -56,35 +55,60 @@ void CAR::setParameter (int parameterIndex, float newValue)
void
CAR
::
process
(
AudioSampleBuffer
&
buffer
,
MidiBuffer
&
events
)
{
const
int
nChannels
=
buffer
.
getNumChannels
();
const
int
numSamples
=
buffer
.
getNumSamples
();
const
int
numSamples
=
buffer
.
getNumSamples
();
const
int
numReferenceChannels
=
m_referenceChannels
.
size
();
const
int
numAffectedChannels
=
m_affectedChannels
.
size
();
// just use channel 0, since we can't have individual channel settings at the moment
const
float
gain
=
-
1.0
f
*
float
(
getParameterVar
(
0
,
0
))
/
100.0
f
;
// There are no sense to do any processing if either number of reference or affected channels is zero.
if
(
!
numReferenceChannels
||
!
numAffectedChannels
)
{
return
;
}
avgBuffer
.
clear
();
m_
avgBuffer
.
clear
();
for
(
int
channel
=
0
;
channel
<
n
Channels
;
++
channel
)
for
(
int
i
=
0
;
i
<
numReference
Channels
;
++
i
)
{
avgBuffer
.
addFrom
(
0
,
// destChannel
0
,
// destStartSample
buffer
,
// source
channel
,
// sourceChannel
0
,
// sourceStartSample
numSamples
,
// numSamples
1.0
f
);
// gain to apply
m_
avgBuffer
.
addFrom
(
0
,
// destChannel
0
,
// destStartSample
buffer
,
// source
m_referenceChannels
[
i
],
// sourceChannel
0
,
// sourceStartSample
numSamples
,
// numSamples
1.0
f
);
// gain to apply
}
avgBuffer
.
applyGain
(
1.0
f
/
float
(
nChannels
));
m_
avgBuffer
.
applyGain
(
1.0
f
/
float
(
n
umReference
Channels
));
for
(
int
channel
=
0
;
channel
<
nChannels
;
++
channel
)
// just use channel 0, since we can't have individual channel settings at the moment
const
float
gain
=
-
1.0
f
*
float
(
getParameterVar
(
0
,
0
))
/
100.0
f
;
for
(
int
i
=
0
;
i
<
numAffectedChannels
;
++
i
)
{
buffer
.
addFrom
(
channel
,
// destChannel
0
,
// destStartSample
avgBuffer
,
// source
0
,
// sourceChannel
0
,
// sourceStartSample
numSamples
,
// numSamples
gain
);
// gain to apply
buffer
.
addFrom
(
m_affectedChannels
[
i
],
// destChannel
0
,
// destStartSample
m_
avgBuffer
,
// source
0
,
// sourceChannel
0
,
// sourceStartSample
numSamples
,
// numSamples
gain
);
// gain to apply
}
}
void
CAR
::
setReferenceChannels
(
const
Array
<
int
>
newReferenceChannels
)
{
const
ScopedLock
myScopedLock
(
objectLock
);
m_referenceChannels
=
Array
(
newReferenceChannels
);
}
void
CAR
::
setAffectedChannels
(
const
Array
<
int
>
newAffectedChannels
)
{
const
ScopedLock
myScopedLock
(
objectLock
);
m_affectedChannels
=
Array
(
newAffectedChannels
);
}
This diff is collapsed.
Click to expand it.
Source/Plugins/CAR/CAR.h
+
23
−
2
View file @
53ee2286
...
...
@@ -77,11 +77,32 @@ public:
other way, the application will crash. */
void
setParameter
(
int
parameterIndex
,
float
newValue
)
override
;
Array
<
int
>
getReferenceChannels
()
const
{
return
m_referenceChannels
;
}
Array
<
int
>
getAffectedChannels
()
const
{
return
m_affectedChannels
;
}
void
setReferenceChannels
(
const
Array
<
int
>&
newReferenceChannels
);
void
setAffectedChannels
(
const
Array
<
int
>&
newAffectedChannels
);
private
:
AudioSampleBuffer
avgBuffer
;
AudioSampleBuffer
m_avgBuffer
;
/** We should add this for safety to prevent any app crashes or invalid data processing.
Since we use m_referenceChannels and m_affectedChannels arrays in the process() function,
which works in audioThread, we may stumble upon the situation when we start changing
either reference or affected channels by copying array and in the middle of copying process
we will be interrupted by audioThread. So it most probably will lead to app crash or
processing incorrect channels.
*/
CriticalSection
objectLock
;
/** Array of channels which will be used to calculate mean signal. */
Array
<
int
>
m_referenceChannels
;
/** Array of channels that will be affected by adding/substracting of mean signal of reference channels */
Array
<
int
>
m_affectedChannels
;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR
(
CAR
);
// ==================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR
(
CAR
);
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment