@@ -187,21 +187,22 @@ public override int Execute(CommandContext context, Settings settings)
187
187
188
188
if ( settings . Midi2 )
189
189
{
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 ) ;
191
192
192
193
var noteOnMessage = MidiMessageBuilder . BuildMidi2ChannelVoiceMessage (
193
194
MidiClock . TimestampConstantSendImmediately ,
194
195
group ,
195
196
Midi2ChannelVoiceMessageStatus . NoteOn ,
196
197
channel ,
197
- ( ushort ) settings . NoteIndexes ! [ noteArrayIndex ] ,
198
+ note ,
198
199
velocity ) ;
199
200
200
201
noteOnSendResult = connection . SendSingleMessagePacket ( noteOnMessage ) ;
201
202
}
202
203
else
203
204
{
204
- byte velocity = ( byte ) settings . Velocity ;
205
+ byte velocity = ( byte ) ( ( float ) ( settings . Velocity / 100.0 ) * 127 ) ;
205
206
206
207
var noteOnMessage = MidiMessageBuilder . BuildMidi1ChannelVoiceMessage (
207
208
MidiClock . TimestampConstantSendImmediately ,
@@ -231,21 +232,22 @@ public override int Execute(CommandContext context, Settings settings)
231
232
232
233
if ( settings . Midi2 )
233
234
{
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 ) ;
235
237
236
238
var noteOffMessage = MidiMessageBuilder . BuildMidi2ChannelVoiceMessage (
237
239
MidiClock . TimestampConstantSendImmediately ,
238
240
group ,
239
241
Midi2ChannelVoiceMessageStatus . NoteOff ,
240
242
channel ,
241
- ( ushort ) settings . NoteIndexes ! [ noteArrayIndex ] ,
243
+ note ,
242
244
velocity ) ;
243
245
244
246
noteOffSendResult = connection . SendSingleMessagePacket ( noteOffMessage ) ;
245
247
}
246
248
else
247
249
{
248
- byte velocity = ( byte ) settings . Velocity ;
250
+ byte velocity = ( byte ) ( ( float ) ( settings . Velocity / 100.0 ) * 127 ) ;
249
251
250
252
var noteOffMessage = MidiMessageBuilder . BuildMidi1ChannelVoiceMessage (
251
253
MidiClock . TimestampConstantSendImmediately ,
0 commit comments