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
7eaad3ab
Commit
7eaad3ab
authored
9 years ago
by
Septen
Browse files
Options
Downloads
Patches
Plain Diff
CAR: refactoring and stylystic fixes.
parent
9c6fecbd
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
+34
-38
34 additions, 38 deletions
Source/Plugins/CAR/CAR.cpp
Source/Plugins/CAR/CAR.h
+9
-19
9 additions, 19 deletions
Source/Plugins/CAR/CAR.h
with
43 additions
and
57 deletions
Source/Plugins/CAR/CAR.cpp
+
34
−
38
View file @
7eaad3ab
...
...
@@ -22,73 +22,69 @@
*/
#include
<stdio.h>
#include
"CAR.h"
CAR
::
CAR
()
:
GenericProcessor
(
"Common Avg Ref"
)
//, threshold(200.0), state(true)
{
parameters
.
add
(
Parameter
(
"Gain (%)"
,
0.0
,
100.0
,
100.0
,
0
));
parameters
.
add
(
Parameter
(
"Gain (%)"
,
0.0
,
100.0
,
100.0
,
0
));
avgBuffer
=
AudioSampleBuffer
(
1
,
10000
);
// 1-dimensional buffer to hold the avg
avgBuffer
=
AudioSampleBuffer
(
1
,
10000
);
// 1-dimensional buffer to hold the avg
}
CAR
::~
CAR
()
{
}
void
CAR
::
setParameter
(
int
parameterIndex
,
float
newValue
)
void
CAR
::
setParameter
(
int
parameterIndex
,
float
newValue
)
{
editor
->
updateParameterButtons
(
parameterIndex
);
editor
->
updateParameterButtons
(
parameterIndex
);
// std::cout << "Setting CAR Gain" << std::endl;
if
(
currentChannel
>=
0
)
{
Parameter
&
p
=
parameters
.
getReference
(
parameterIndex
);
p
.
setValue
(
newValue
,
currentChannel
);
Parameter
&
p
=
parameters
.
getReference
(
parameterIndex
);
p
.
setValue
(
newValue
,
currentChannel
);
}
}
void
CAR
::
process
(
AudioSampleBuffer
&
buffer
,
MidiBuffer
&
events
)
void
CAR
::
process
(
AudioSampleBuffer
&
buffer
,
MidiBuffer
&
events
)
{
int
nChannels
=
buffer
.
getNumChannels
();
const
int
nChannels
=
buffer
.
getNumChannels
();
const
int
numSamples
=
buffer
.
getNumSamples
();
float
gain
=
-
1.0
f
*
float
(
getParameterVar
(
0
,
0
))
/
100.0
f
;
// just use channel 0, since we can't have individual channel settings at the moment
// 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
;
avgBuffer
.
clear
();
for
(
int
j
=
0
;
j
<
nChannels
;
j
++
)
{
avgBuffer
.
addFrom
(
0
,
// destChannel
0
,
// destStartSample
buffer
,
// source
j
,
// sourceChannel
0
,
// sourceStartSample
buffer
.
getNumSamples
(),
// numSamples
1.0
f
);
// gain to apply
}
for
(
int
channel
=
0
;
channel
<
nChannels
;
++
channel
)
{
avgBuffer
.
addFrom
(
0
,
// destChannel
0
,
// destStartSample
buffer
,
// source
channel
,
// sourceChannel
0
,
// sourceStartSample
numSamples
,
// numSamples
1.0
f
);
// gain to apply
}
avgBuffer
.
applyGain
(
1.0
f
/
float
(
nChannels
));
avgBuffer
.
applyGain
(
1.0
f
/
float
(
nChannels
));
for
(
int
j
=
0
;
j
<
nChannels
;
j
++
)
for
(
int
channel
=
0
;
channel
<
nChannels
;
++
channel
)
{
buffer
.
addFrom
(
j
,
// destChannel
0
,
// destStartSample
avgBuffer
,
// source
0
,
// sourceChannel
0
,
// sourceStartSample
buffer
.
getN
umSamples
(),
// numSamples
gain
);
// gain to apply
buffer
.
addFrom
(
channel
,
// destChannel
0
,
// destStartSample
avgBuffer
,
// source
0
,
// sourceChannel
0
,
// sourceStartSample
n
umSamples
,
// numSamples
gain
);
// gain to apply
}
}
This diff is collapsed.
Click to expand it.
Source/Plugins/CAR/CAR.h
+
9
−
19
View file @
7eaad3ab
...
...
@@ -36,18 +36,16 @@
This is a simple filter that subtracts the average of all other channels from
each channel. The gain parameter allows you to subtract a percentage of the total avg.
See Ludwig et al. 2009 Using a common average reference to improve cortical
neuron recordings from microelectrode arrays. J. Neurophys, 2009 for a detailed
discussion
See Ludwig et al. 2009 Using a common average reference to improve cortical
neuron recordings from microelectrode arrays. J. Neurophys, 2009 for a detailed
discussion
*/
class
CAR
:
public
GenericProcessor
{
public:
/** The class constructor, used to initialize any members. */
CAR
();
...
...
@@ -55,16 +53,10 @@ public:
~
CAR
();
/** Determines whether the processor is treated as a source. */
bool
isSource
()
{
return
false
;
}
bool
isSource
()
override
{
return
false
;
}
/** Determines whether the processor is treated as a sink. */
bool
isSink
()
{
return
false
;
}
bool
isSink
()
override
{
return
false
;
}
/** Defines the functionality of the processor.
...
...
@@ -78,22 +70,20 @@ public:
number of continous samples in the current buffer (which may differ from the
size of the buffer).
*/
void
process
(
AudioSampleBuffer
&
buffer
,
MidiBuffer
&
events
);
void
process
(
AudioSampleBuffer
&
buffer
,
MidiBuffer
&
events
)
override
;
/** Any variables used by the "process" function _must_ be modified only through
this method while data acquisition is active. If they are modified in any
other way, the application will crash. */
void
setParameter
(
int
parameterIndex
,
float
newValue
);
void
setParameter
(
int
parameterIndex
,
float
newValue
)
override
;
AudioSampleBuffer
avgBuffer
;
private
:
AudioSampleBuffer
avgBuffer
;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR
(
CAR
);
};
#endif // CAR_H_INCLUDED
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