Skip to content

Commit 50b79cc

Browse files
committed
Updates to console to increase buffer sizes
1 parent 5e9cf29 commit 50b79cc

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/user-tools/midi-console/Midi/Commands/Endpoint/EndpointMonitorCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ internal class EndpointMonitorCommand : Command<EndpointMonitorCommand.Settings>
3434
{
3535
// we have this struct so we can separate the relatively fast received processing
3636
// and its calculations from the comparatively slow displays processing
37-
private Queue<ReceivedMidiMessage> m_receivedMessagesQueue = new Queue<ReceivedMidiMessage>(2000);
38-
private Queue<ReceivedMidiMessage> m_displayMessageQueue = new Queue<ReceivedMidiMessage>(1000);
37+
private Queue<ReceivedMidiMessage> m_receivedMessagesQueue = new Queue<ReceivedMidiMessage>(4000);
38+
private Queue<ReceivedMidiMessage> m_displayMessageQueue = new Queue<ReceivedMidiMessage>(2000);
3939
private Queue<ReceivedMidiMessage> m_fileWriterMessagesQueue = new Queue<ReceivedMidiMessage>(1000);
4040

4141

src/user-tools/midi-console/Midi/Commands/Endpoint/EndpointPlayNotesCommand.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,21 +187,22 @@ public override int Execute(CommandContext context, Settings settings)
187187

188188
if (settings.Midi2)
189189
{
190-
UInt32 velocity = (UInt32)(settings.Velocity / 100.0) * UInt32.MaxValue;
190+
UInt32 velocity = (UInt32)(((float)settings.Velocity / 100.0) * UInt16.MaxValue) << 16;
191+
UInt16 note = (UInt16)((UInt16)settings.NoteIndexes![noteArrayIndex] << 8);
191192

192193
var noteOnMessage = MidiMessageBuilder.BuildMidi2ChannelVoiceMessage(
193194
MidiClock.TimestampConstantSendImmediately,
194195
group,
195196
Midi2ChannelVoiceMessageStatus.NoteOn,
196197
channel,
197-
(ushort)settings.NoteIndexes![noteArrayIndex],
198+
note,
198199
velocity);
199200

200201
noteOnSendResult = connection.SendSingleMessagePacket(noteOnMessage);
201202
}
202203
else
203204
{
204-
byte velocity = (byte)settings.Velocity;
205+
byte velocity = (byte)((float)(settings.Velocity / 100.0) * 127);
205206

206207
var noteOnMessage = MidiMessageBuilder.BuildMidi1ChannelVoiceMessage(
207208
MidiClock.TimestampConstantSendImmediately,
@@ -231,21 +232,22 @@ public override int Execute(CommandContext context, Settings settings)
231232

232233
if (settings.Midi2)
233234
{
234-
UInt32 velocity = (UInt32)(settings.Velocity / 100.0) * UInt32.MaxValue;
235+
UInt32 velocity = (UInt32)((float)(settings.Velocity / 100.0) * UInt16.MaxValue) << 16;
236+
UInt16 note = (UInt16)((UInt16)settings.NoteIndexes![noteArrayIndex] << 8);
235237

236238
var noteOffMessage = MidiMessageBuilder.BuildMidi2ChannelVoiceMessage(
237239
MidiClock.TimestampConstantSendImmediately,
238240
group,
239241
Midi2ChannelVoiceMessageStatus.NoteOff,
240242
channel,
241-
(ushort)settings.NoteIndexes![noteArrayIndex],
243+
note,
242244
velocity);
243245

244246
noteOffSendResult = connection.SendSingleMessagePacket(noteOffMessage);
245247
}
246248
else
247249
{
248-
byte velocity = (byte)settings.Velocity;
250+
byte velocity = (byte)((float)(settings.Velocity / 100.0) * 127);
249251

250252
var noteOffMessage = MidiMessageBuilder.BuildMidi1ChannelVoiceMessage(
251253
MidiClock.TimestampConstantSendImmediately,

0 commit comments

Comments
 (0)