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
5390df8c
Commit
5390df8c
authored
10 years ago
by
jsiegle
Browse files
Options
Downloads
Patches
Plain Diff
Update MidiBuffer code to handle spike events
parent
354dd8e9
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp
+30
-8
30 additions, 8 deletions
...ryCode/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp
with
30 additions
and
8 deletions
JuceLibraryCode/modules/juce_audio_basics/midi/juce_MidiBuffer.cpp
+
30
−
8
View file @
5390df8c
...
...
@@ -114,20 +114,42 @@ void MidiBuffer::addEvent (const MidiMessage& m, const int sampleNumber)
void
MidiBuffer
::
addEvent
(
const
void
*
const
newData
,
const
int
maxBytes
,
const
int
sampleNumber
)
{
const
int
numBytes
=
MidiBufferHelpers
::
findActualEventLength
(
static_cast
<
const
uint8
*>
(
newData
),
maxBytes
);
const
int
numBytes
=
maxBytes
;
if
(
numBytes
>
0
)
{
const
size_t
newItemSize
=
(
size_t
)
numBytes
+
sizeof
(
int32
)
+
sizeof
(
uint16
);
const
int
offset
=
(
int
)
(
MidiBufferHelpers
::
findEventAfter
(
data
.
begin
(),
data
.
end
(),
sampleNumber
)
-
data
.
begin
());
int
spaceNeeded
=
bytesUsed
+
numBytes
+
sizeof
(
int
)
+
sizeof
(
uint16
);
// factor in timestamp and size indicator
data
.
ensureSize
((
spaceNeeded
+
spaceNeeded
/
2
+
8
)
&
~
7
);
// make sure there's enough size in the MemoryBlock
uint8
*
d
=
getData
()
+
bytesUsed
;
data
.
insertMultiple
(
offset
,
0
,
(
int
)
newItemSize
);
*
reinterpret_cast
<
int
*>
(
d
)
=
sampleNumber
;
d
+=
sizeof
(
int
);
*
reinterpret_cast
<
uint16
*>
(
d
)
=
(
uint16
)
numBytes
;
d
+=
sizeof
(
uint16
);
uint8
*
const
d
=
data
.
begin
()
+
offset
;
*
reinterpret_cast
<
int32
*>
(
d
)
=
sampleNumber
;
*
reinterpret_cast
<
uint16
*>
(
d
+
4
)
=
(
uint16
)
numBytes
;
memcpy
(
d
+
6
,
newData
,
(
size_t
)
numBytes
);
memcpy
(
d
,
newData
,
numBytes
);
bytesUsed
+=
numBytes
+
sizeof
(
int
)
+
sizeof
(
uint16
);
}
// Original JUCE library code:
//
// const int numBytes = MidiBufferHelpers::findActualEventLength (static_cast<const uint8*> (newData), maxBytes);
// if (numBytes > 0)
// {
// const size_t newItemSize = (size_t) numBytes + sizeof (int32) + sizeof (uint16);
// const int offset = (int) (MidiBufferHelpers::findEventAfter (data.begin(), data.end(), sampleNumber) - data.begin());
// data.insertMultiple (offset, 0, (int) newItemSize);
// uint8* const d = data.begin() + offset;
// *reinterpret_cast<int32*> (d) = sampleNumber;
// *reinterpret_cast<uint16*> (d + 4) = (uint16) numBytes;
// memcpy (d + 6, newData, (size_t) numBytes);
// }
}
void
MidiBuffer
::
addEvents
(
const
MidiBuffer
&
otherBuffer
,
...
...
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