Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sendControlChange(); generating NoteOn messages #41

Closed
IainD92 opened this issue Apr 9, 2016 · 5 comments
Closed

sendControlChange(); generating NoteOn messages #41

IainD92 opened this issue Apr 9, 2016 · 5 comments
Assignees
Labels
Milestone

Comments

@IainD92
Copy link

IainD92 commented Apr 9, 2016

Hey, I'm trying to use an Arduino Uno to create a device to do all sorts of MIDI manipulation, including turning PitchBend messages into CC messages (I have a sequencer that doesn't accept pitch bend, but uses a CC value for pitch shifting).

For some reason, in this particular project, when I use MIDI.sendControlChange, I get a load of NoteOn messages:
Link to screenshot on imgur

Here's a simplified version of part of a sketch I've written. I've not mentioned NoteOn at all here - any ideas of what could be happening? Thanks in advance!

#include <MIDI.h>

//constants
#define PITCHBENDMAX 8191
#define PITCHBENDMIN -8192

//variables
int CCPitch = 64;

MIDI_CREATE_DEFAULT_INSTANCE();

void setup()
{  
  MIDI.begin(MIDI_CHANNEL_OMNI);
  MIDI.setHandlePitchBend(TranslatePitchBend);
  MIDI.turnThruOff();
}

void loop()
{
  MIDI.read();
}

void TranslatePitchBend(byte channel, int bend)
{
  CCPitch = 1+ 127* float(
            (bend - PITCHBENDMIN)/
                float(PITCHBENDMAX-PITCHBENDMIN));

  MIDI.sendControlChange(80, CCPitch, channel);
}
@franky47
Copy link
Member

franky47 commented Apr 9, 2016

You're not the only one with this kind of issue, I'll have a look and see if I can find and resolve this bug.

Thanks for reporting !

@franky47 franky47 self-assigned this Apr 9, 2016
@franky47 franky47 added the bug label Apr 9, 2016
@franky47 franky47 added this to the 4.3 milestone Apr 9, 2016
@franky47
Copy link
Member

franky47 commented Apr 9, 2016

I wasn't able to reproduce this (although I use a Leonardo, but I don't think it matters):
midi-issue-41

However, I'm considering implementing feature request #40, which would let you remap PitchBend messages to CC80 without losing thru for all other messages.

@IainD92
Copy link
Author

IainD92 commented Apr 9, 2016

That would be very useful! Very much looking forward to 4.3

Thanks for trying - in the meantime I've opted to send the 3 bytes like this and everything works as long as I don't use thru:

void TranslatePitchBend(byte channel, int bend)
{
  CCPitch = 1+ 127* float(
            (bend - PITCHBENDMIN)/
                float(PITCHBENDMAX-PITCHBENDMIN));

 // MIDI.sendControlChange(80, CCPitch, channel);
  Serial.write(byte(175+channel));
  Serial.write(byte (80));
  Serial.write(byte(CCPitch));
}

If I enable thru, PitchBend and any pots that send CC seem to be sending NoteON instead of PitchBend or CC. Setting static const bool UseRunningStatus = false; fixes the issue

@franky47
Copy link
Member

franky47 commented Oct 6, 2016

It could be that your receiving device simply does not handle Running Status.

What hardware were you using to capture the MIDI stream coming out of the Arduino ?

@franky47
Copy link
Member

franky47 commented Oct 17, 2016

There are many possible explanations for your NoteOn issues, one of which (after your driver not supporting Running Status) being that the stream started before the driver was ready, hence causing it to not receive the first status byte, but only data bytes. Interpreting them as NoteOn could be a default value for the Running Status implementation of the driver.

I'm closing this for now as I was not able to reproduce it on my tests (sendControlChange sends correct ControlChange messages).

franky47 pushed a commit that referenced this issue Oct 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants