Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Lichtsteuerung
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Leander Schulten
Lichtsteuerung
Commits
58332046
Commit
58332046
authored
5 years ago
by
Leander Schulten
Browse files
Options
Downloads
Patches
Plain Diff
simplify code for example
parent
63d4fba5
Loading
Loading
No related merge requests found
Checking pipeline status
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/audio/audiocapturemanager.cpp
+0
-7
0 additions, 7 deletions
src/audio/audiocapturemanager.cpp
src/gui/colorplot.cpp
+1
-1
1 addition, 1 deletion
src/gui/colorplot.cpp
src/gui/colorplot.h
+4
-45
4 additions, 45 deletions
src/gui/colorplot.h
with
5 additions
and
53 deletions
src/audio/audiocapturemanager.cpp
+
0
−
7
View file @
58332046
...
...
@@ -12,8 +12,6 @@ AudioCaptureManager::AudioCaptureManager():audiofft(sample.size())
void
AudioCaptureManager
::
initCallback
(
int
channels
){
this
->
channels
=
channels
;
if
(
GUI
::
Colorplot
::
getLast
())
GUI
::
Colorplot
::
getLast
()
->
setBlockSize
(
512
);
}
void
AudioCaptureManager
::
dataCallback
(
float
*
data
,
unsigned
int
frames
,
bool
*
done
){
...
...
@@ -42,11 +40,6 @@ void AudioCaptureManager::dataCallback(float* data, unsigned int frames, bool*do
if
(
GUI
::
Graph
::
getLast
())
GUI
::
Graph
::
getLast
()
->
showData
(
fftoutput
.
data
(),
fftoutput
.
size
());
if
(
GUI
::
Colorplot
::
getLast
()){
GUI
::
Colorplot
::
getLast
()
->
startBlock
();
for
(
int
i
=
0
;
i
<
512
;
++
i
)
{
GUI
::
Colorplot
::
getLast
()
->
pushDataToBlock
(
fftoutput
.
at
(
i
));
}
GUI
::
Colorplot
::
getLast
()
->
endBlock
();
}
if
(
GUI
::
Oscillogram
::
getLast
())
GUI
::
Oscillogram
::
getLast
()
->
showData
(
sample
.
data
(),
sample
.
size
());
...
...
This diff is collapsed.
Click to expand it.
src/gui/colorplot.cpp
+
1
−
1
View file @
58332046
...
...
@@ -5,7 +5,7 @@
namespace
GUI
{
Colorplot
::
Colorplot
()
:
haveNewData
(
false
)
Colorplot
::
Colorplot
()
{
setFlag
(
ItemHasContents
);
lastCreated
=
this
;
...
...
This diff is collapsed.
Click to expand it.
src/gui/colorplot.h
+
4
−
45
View file @
58332046
...
...
@@ -11,16 +11,12 @@ namespace GUI{
class
Colorplot
:
public
QQuickItem
{
Q_OBJECT
unsigned
int
blockSize
=
0
;
std
::
list
<
volatile
float
*>
dataBlocks
;
std
::
list
<
float
*>
freeBlocks
;
int
currentBlockCounter
=
-
1
;
unsigned
int
blockSize
=
512
;
QColor
lineColor
=
QColor
(
0
,
0
,
0
);
Q_PROPERTY
(
QColor
lineColor
READ
getLineColor
WRITE
setLineColor
NOTIFY
lineColorChanged
)
static
Colorplot
*
lastCreated
;
std
::
atomic_bool
haveNewData
;
const
static
unsigned
int
MAX_BLOCKS_COUNT
=
900
;
std
::
mutex
mutex
;
public:
Colorplot
();
...
...
@@ -28,45 +24,8 @@ public:
if
(
lastCreated
==
this
)
lastCreated
=
nullptr
;
}
static
Colorplot
*
getLast
(){
return
lastCreated
;}
void
startBlock
(){
mutex
.
lock
();
if
(
dataBlocks
.
size
()
>=
MAX_BLOCKS_COUNT
)
{
currentBlockCounter
=
0
;
auto
data
=
dataBlocks
.
front
();
dataBlocks
.
pop_front
();
dataBlocks
.
push_back
(
data
);
}
else
{
currentBlockCounter
=
0
;
auto
data
=
new
float
[
blockSize
];
memset
(
data
,
0
,
blockSize
*
sizeof
(
float
));
dataBlocks
.
push_back
(
data
);
}
}
void
endBlock
(){
mutex
.
unlock
();
}
void
pushDataToBlock
(
float
d
){
if
(
currentBlockCounter
>=
0
)
{
dataBlocks
.
back
()[
currentBlockCounter
]
=
d
;
//*0.4f;//std::pow(1+d*0.001,3)*20;
++
currentBlockCounter
;
if
(
currentBlockCounter
>=
static_cast
<
int
>
(
blockSize
))
currentBlockCounter
=-
1
;
}
else
qDebug
()
<<
"Error : currentBlockCounter less then 0"
;
}
void
setBlockSize
(
unsigned
int
size
){
if
(
size
!=
this
->
blockSize
){
for
(
const
auto
i
:
dataBlocks
)
delete
i
;
for
(
const
auto
i
:
freeBlocks
)
delete
i
;
dataBlocks
.
clear
();
freeBlocks
.
clear
();
currentBlockCounter
=
-
1
;
blockSize
=
size
;
}
}
static
Colorplot
*
getLast
(){
return
nullptr
;}
void
setLineColor
(
QColor
c
){
lineColor
=
c
;
update
();
lineColorChanged
();}
QColor
getLineColor
(){
return
lineColor
;}
...
...
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