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
6d195da5
Commit
6d195da5
authored
8 years ago
by
Aaron Cuevas Lopez
Browse files
Options
Downloads
Patches
Plain Diff
Update network events processor
parent
eb92e31a
No related branches found
No related tags found
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Source/Plugins/NetworkEvents/NetworkEvents.cpp
+19
-35
19 additions, 35 deletions
Source/Plugins/NetworkEvents/NetworkEvents.cpp
Source/Plugins/NetworkEvents/NetworkEvents.h
+6
-6
6 additions, 6 deletions
Source/Plugins/NetworkEvents/NetworkEvents.h
with
25 additions
and
41 deletions
Source/Plugins/NetworkEvents/NetworkEvents.cpp
+
19
−
35
View file @
6d195da5
...
...
@@ -224,15 +224,16 @@ bool NetworkEvents::closesocket()
}
int
NetworkEvents
::
getNum
EventChannels
()
const
void
NetworkEvents
::
create
EventChannels
()
{
return
1
;
}
void
NetworkEvents
::
updateSettings
()
{
eventChannels
[
0
]
->
type
=
MESSAGE_CHANNEL
;
// so it's ignored by LFP Viewer
EventChannel
*
chan
=
new
EventChannel
(
EventChannel
::
TEXT
,
1
,
MAX_MESSAGE_LENGTH
,
CoreServices
::
getGlobalSampleRate
(),
this
);
chan
->
setName
(
"Network messages"
);
chan
->
setDescription
(
"Messages received through the network events module"
);
chan
->
setDescriptor
(
"genericevent.network"
);
chan
->
addEventMetaData
(
new
MetaDataDescriptor
(
MetaDataDescriptor
::
INT64
,
1
,
"Software timestamp"
,
"OS high resolution timer count when the event was received"
,
"timestamp.software"
));
eventChannelArray
.
add
(
chan
);
messageChannel
=
chan
;
}
...
...
@@ -272,7 +273,7 @@ void NetworkEvents::initSimulation()
}
void
NetworkEvents
::
simulateDesignAndTrials
(
juce
::
MidiBuffer
&
events
)
void
NetworkEvents
::
simulateDesignAndTrials
()
{
Time
t
;
while
(
simulation
.
size
()
>
0
)
...
...
@@ -284,7 +285,7 @@ void NetworkEvents::simulateDesignAndTrials (juce::MidiBuffer& events)
// handle special messages
handleSpecialMessages
(
S
);
postTimestamppedStringToMidiBuffer
(
S
,
events
);
postTimestamppedStringToMidiBuffer
(
S
);
//getUIComponent()->getLogWindow()->addLineToLog(S.getString());
simulation
.
pop
();
}
...
...
@@ -296,27 +297,12 @@ void NetworkEvents::simulateDesignAndTrials (juce::MidiBuffer& events)
}
void
NetworkEvents
::
handleEvent
(
int
eventType
,
juce
::
MidiMessage
&
event
,
int
samplePosition
)
void
NetworkEvents
::
postTimestamppedStringToMidiBuffer
(
StringTS
s
)
{
}
void
NetworkEvents
::
postTimestamppedStringToMidiBuffer
(
StringTS
s
,
MidiBuffer
&
events
)
{
uint8
*
msg_with_ts
=
new
uint8
[
s
.
len
+
1
];
//+8]; // for the two timestamps
memcpy
(
msg_with_ts
,
s
.
str
,
s
.
len
);
*
(
msg_with_ts
+
s
.
len
)
=
'\0'
;
addEvent
(
events
,
(
uint8
)
MESSAGE
,
0
,
1
,
0
,
(
uint8
)
s
.
len
+
1
,
//+8,
msg_with_ts
);
delete
[]
msg_with_ts
;
MetaDataValueArray
md
;
md
.
add
(
new
MetaDataValue
(
MetaDataDescriptor
::
INT64
,
1
,
&
s
.
timestamp
));
TextEventPtr
event
=
TextEvent
::
createTextEvent
(
messageChannel
,
CoreServices
::
getGlobalTimestamp
(),
String
::
fromUTF8
(
reinterpret_cast
<
const
char
*>
(
s
.
str
),
s
.
len
),
md
);
addEvent
(
messageChannel
,
event
,
0
);
}
...
...
@@ -537,17 +523,15 @@ String NetworkEvents::handleSpecialMessages (StringTS msg)
}
void
NetworkEvents
::
process
(
AudioSampleBuffer
&
buffer
,
MidiBuffer
&
events
)
void
NetworkEvents
::
process
(
AudioSampleBuffer
&
buffer
)
{
setTimestamp
(
events
,
CoreServices
::
getGlobalTimestamp
());
checkForEvents
(
events
);
//simulateDesignAndTrials(events);
setTimestampAndSamples
(
CoreServices
::
getGlobalTimestamp
(),
0
);
lock
.
enter
();
while
(
!
networkMessagesQueue
.
empty
())
{
StringTS
msg
=
networkMessagesQueue
.
front
();
postTimestamppedStringToMidiBuffer
(
msg
,
events
);
postTimestamppedStringToMidiBuffer
(
msg
);
CoreServices
::
sendStatusMessage
(
(
"Network event received: "
+
msg
.
getString
()).
toRawUTF8
());
networkMessagesQueue
.
pop
();
}
...
...
This diff is collapsed.
Click to expand it.
Source/Plugins/NetworkEvents/NetworkEvents.h
+
6
−
6
View file @
6d195da5
...
...
@@ -78,11 +78,11 @@ public:
// =========================================================================
AudioProcessorEditor
*
createEditor
()
override
;
void
process
(
AudioSampleBuffer
&
buffer
,
MidiBuffer
&
midiMessages
)
override
;
void
process
(
AudioSampleBuffer
&
buffer
)
override
;
void
setParameter
(
int
parameterIndex
,
float
newValue
)
override
;
void
updateSetting
s
()
override
;
void
createEventChannel
s
()
override
;
void
setEnabledState
(
bool
newState
)
override
;
...
...
@@ -94,7 +94,6 @@ public:
float
getDefaultSampleRate
()
const
override
;
float
getDefaultBitVolts
()
const
override
;
int
getNumEventChannels
()
const
override
;
// =========================================================================
int
getDefaultNumOutputs
()
const
;
...
...
@@ -105,7 +104,7 @@ public:
std
::
vector
<
String
>
splitString
(
String
S
,
char
sep
);
void
initSimulation
();
void
simulateDesignAndTrials
(
juce
::
MidiBuffer
&
events
);
void
simulateDesignAndTrials
();
void
simulateSingleTrial
();
void
simulateStartRecord
();
void
simulateStopRecord
();
...
...
@@ -113,7 +112,7 @@ public:
void
opensocket
();
bool
closesocket
();
void
postTimestamppedStringToMidiBuffer
(
StringTS
s
,
MidiBuffer
&
events
);
void
postTimestamppedStringToMidiBuffer
(
StringTS
s
);
void
setNewListeningPort
(
int
port
);
int
urlport
;
...
...
@@ -122,7 +121,6 @@ public:
private:
void
handleEvent
(
int
eventType
,
MidiMessage
&
event
,
int
samplePos
)
override
;
void
createZmqContext
();
//* Split network message into name/value pairs (name1=val1 name2=val2 etc) */
...
...
@@ -148,6 +146,8 @@ private:
CriticalSection
lock
;
int64
simulationStartTime
;
const
EventChannel
*
messageChannel
{
nullptr
};
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR
(
NetworkEvents
);
};
...
...
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