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
65abad33
Commit
65abad33
authored
10 years ago
by
Ryan Maloney
Browse files
Options
Downloads
Patches
Plain Diff
Actually adding processors...
parent
ad949e74
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Source/Processors/CAR/CAR.cpp
+81
-0
81 additions, 0 deletions
Source/Processors/CAR/CAR.cpp
Source/Processors/CAR/CAR.h
+98
-0
98 additions, 0 deletions
Source/Processors/CAR/CAR.h
with
179 additions
and
0 deletions
Source/Processors/CAR/CAR.cpp
0 → 100644
+
81
−
0
View file @
65abad33
/*
------------------------------------------------------------------
This file is part of the Open Ephys GUI
Copyright (C) 2014 Open Ephys
------------------------------------------------------------------
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#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
));
}
CAR
::~
CAR
()
{
}
void
CAR
::
setParameter
(
int
parameterIndex
,
float
newValue
)
{
editor
->
updateParameterButtons
(
parameterIndex
);
// std::cout << "Setting CAR Gain" << std::endl;
if
(
currentChannel
>=
0
)
{
Parameter
&
p
=
parameters
.
getReference
(
parameterIndex
);
p
.
setValue
(
newValue
,
currentChannel
);
}
}
void
CAR
::
process
(
AudioSampleBuffer
&
buffer
,
MidiBuffer
&
events
,
int
&
nSamples
)
{
int
nChannels
=
buffer
.
getNumChannels
();
for
(
int
i
=
0
;
i
<
nSamples
;
i
++
)
{
float
average
=
0
;
for
(
int
j
=
0
;
j
<
(
nChannels
);
j
++
)
{
average
=
average
+
buffer
.
getSample
(
j
,
i
);
}
average
=
average
/
nChannels
;
for
(
int
j
=
0
;
j
<
nChannels
;
j
++
)
{
float
gain
=
getParameterVar
(
0
,
j
);
// Subtract from sample
float
subtracted
=
(
buffer
.
getSample
(
j
,
i
)
*
(
1
+
(
1
/
nChannels
*
gain
/
100
))
-
average
*
gain
/
100
);
buffer
.
setSample
(
j
,
i
,
subtracted
);
}
}
}
This diff is collapsed.
Click to expand it.
Source/Processors/CAR/CAR.h
0 → 100644
+
98
−
0
View file @
65abad33
/*
------------------------------------------------------------------
This file is part of the Open Ephys GUI
Copyright (C) 2014 Open Ephys
------------------------------------------------------------------
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CAR_H_INCLUDED
#define CAR_H_INCLUDED
#ifdef _WIN32
#include
<Windows.h>
#endif
#include
"../../JuceLibraryCode/JuceHeader.h"
#include
"../GenericProcessor/GenericProcessor.h"
/**
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
*/
class
CAR
:
public
GenericProcessor
{
public:
/** The class constructor, used to initialize any members. */
CAR
();
/** The class destructor, used to deallocate memory */
~
CAR
();
/** Determines whether the processor is treated as a source. */
bool
isSource
()
{
return
false
;
}
/** Determines whether the processor is treated as a sink. */
bool
isSink
()
{
return
false
;
}
/** Defines the functionality of the processor.
The process method is called every time a new data buffer is available.
Processors can either use this method to add new data, manipulate existing
data, or send data to an external target (such as a display or other hardware).
Continuous signals arrive in the "buffer" variable, event data (such as TTLs
and spikes) is contained in the "events" variable, and "nSamples" holds the
number of continous samples in the current buffer (which may differ from the
size of the buffer).
*/
void
process
(
AudioSampleBuffer
&
buffer
,
MidiBuffer
&
events
,
int
&
nSamples
);
/** 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
);
private
:
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