problem with MIDI volume data

Hello everyone,
i've been messing around with MIDI for quite a few weeks now and everything works perfectly. I built a tiny keyboard with 22 keys and 2 pots, also an LCD screen for debugging and effects. On the side there's a midi-out socket and the USB to program my Mega 2560. I also successfully flashed the 8u2 with some midi firmware to try to make it an HID midi device and that worked too.

The one pot sends modulation data and the other should be used for volume control. Everything works perfectly, even the modulation pot is working fine. For your info, i'm not using the USB firmware but the original, using a Steinberg Midex 3 to convert the midi data to usb. Then using FM8 to play/test. The problem is, both pots are working fine, sending correct data 0-1023 range to arduino, But the volume control change data sent through the midi is (maybe) messed up.

I use this code to send the modulation data (midi channel 1):

     Serial1.write(176);            // Control change (channel1)
     Serial1.write(1);               // Volume command
     Serial1.write(newModVal);  // Volume 0-127

(after some threshold and mapping stuff)
and this code for the volume data.

     Serial1.write(176);            // Control change (channel1)
     Serial1.write(7);           // Volume command
     Serial1.write(volMapped & 0x7F);  // Volume 0-127

i've tried both (volMapped & 0x7F) or just (volMapped) for the last line but it acts the same.
my Midex3 only seems to show midi-in activity when the volume pot is around 85%.

Does anyone know what might be happening?

Thank you for your time!

Maybe you aren't mapping the pot value 0-1023 down to the volume 0-127 correctly?

Pete

thanks a lot but i'm already doing that :slight_smile:

newVolVal=analogRead(volPotPin);
  newVolVal = map(newVolVal, 0, 1023, 0, 127); // Map the value to 0-127

even printing the mapped value over serial shows correct 0-127 values... maybe my midex is somehow twitchy? it's strange that everything else works perfectly... :slight_smile:

thanks for your reply anyway

You haven't got a consistent name. In your first post you used volMapped and now you're using newVolVal.

Pete

Yes well noticed, sorry for this i've been changing things around in a few tries to make it work. But all variables are updated, besides they're correctly printed over serial monitor too.

See: Specs

Isn't 7 the MSB and 39 the LSB?

Yes it is, i tried even that but nothing changed, my midi volume seems to be on at 20-25%, then around 60% and then somewhere at 85%... like a strange division happening...?

Also, in all the examples i saw about volume data all over google, nobody used the LSB, only the 7 for MSB.
But thank you for your ideas :slight_smile:

Can you post your entire current sketch please? In code tags.

I tried another midi input device last night and it worked perfectly, it turned out a problem on my midex midi-usb converter...! Really strange

Anyway, thank you very much all for your useful info! This is going to be used in a small concert tomorrow night, even after 10 hours of continuous work it's running smoothly with no problems :slight_smile:

Thank you again!