Send 1 Sysex message depending on momentary switch State

Status
Not open for further replies.
The inversion of D1 and D2 is due to your mapping only to 127 (and my not noticing).

That only impacts the least significant bit in the output.

You need to use the big number (and likely read all that other thread as that code was very specific to that person's situation).

Stability is a particularly a challenge when we scale upward as we can't just look for a change in output.

We need to smooth the signal somehow... (on which much digital ink has been spilled).

More on the rest later...

(OMG we're on page six!)
 
The inversion is already solved. As you can see on the post before yours i have changed to 16383.
The problem is that it sends the full data2 from the lower position to the middle. That is, i go from buttom to the rest position and it sends the 127 CC values. Obviously we needed it to send that but till the upper position not the middle.

Yeah, 6 Pages of me bugging you, sorry. :p :cool:
 
D'oh... I think that's the other code-breaking MIDI change made recently. It no longer takes positive only integers but rather it's zero centered with -8192 to 8192 as the full range. Try those in place of 0 and 16383 in the last two places in the map command

Code:
    pitch = map(pitchRaw, 0, 1023, -8192, 8192); // start with full range
    pitch = max(pitch, -8192); // limit to shift range minimum
    pitch = min(pitch, 8192); // ... and maximum

Also, what are the raw readings at the top, bottom and middle (after adjusting the screw you mention to get as close to 511-512 as you can).
 
Code:
    pitch = map(pitchRaw, 0, 1023, -8192, 8192); // start with full range
    pitch = max(pitch, -8192); // limit to shift range minimum
    pitch = min(pitch, 8192); // ... and maximum

That was something that was in my plan to try too

Also, what are the raw readings at the top, bottom and middle (after adjusting the screw you mention to get as close to 511-512 as you can).

I have to check it at the end of the day, oddson.
I'll let you know as soon as i have it.
 
Top: 1022 (8127-8143)
Down: 1 (8128-8176)
Middle: 505-512 (105-24)

I think i need to shorten the range just a bit.
 
Those aren't bad but the middle being soft isn't good for intonation (unless that's not critical to you... 'close enough for insert-genre-here').

Using ResponsiveAnalogRead() to smooth and stabilize the signal and then limit the update rate by polling before sending midi should give a usable MIDI stream.
 
Those aren't bad but the middle being soft isn't good for intonation (unless that's not critical to you... 'close enough for insert-genre-here').

Using ResponsiveAnalogRead() to smooth and stabilize the signal and then limit the update rate by polling before sending midi should give a usable MIDI stream.

The sketch already has


Code:
elapsedMillis pitchUpdate;

Code:
ResponsiveAnalogRead readPitch = {pitchPin, true};


And:

Code:
void getAnalogData() {
  readPitch.update();
  if (readPitch.hasChanged()) {
    pitchRaw = readPitch.getValue();
    Serial.println(pitchRaw);
    // remap to output data and send if changed and MIDIdelay has lapsed since last update for that parameter
    pitch = map(pitchRaw, 2, 1020, -8192, 8192);
    pitch = max(pitch, -8192); // need this now that the bottom isn't zero
    pitch = min(pitch, 8192); // cap to avoid overflow
    if (abs(pitch - pitchLag) > 0 && pitchUpdate > MIDIdelay ) {
      pitchLag = pitch;
      usbMIDI.sendPitchBend(pitch, channel);
      Serial.print("Joystick Pitchbend=");
      Serial.println(pitch);
      pitchUpdate = 0;
    }
  }

Do you think there is something more to smooth the signal?
 
...Do you think there is something more to smooth the signal?
The zero in the conditional (abs(pitch - pitchLag) > 0 should be more like 64 as we're in 14 bits here and only the first 10 have any data in them.

assuming your signal is solid except for the last bit (9 bits) then you'd need to allow for six bits of 'noise' ... I don't know if 64 is 'correct' but I think it would work IF you had a solid nine-bit signal.

The zero works when we have a good signal and we're reducing to 7-bit MIDI. Pitchbend is tricky because we could give 14 bits of data if we had them.

You should also use elapsedMillis to limit checking the conditional to some minimum after the last update.

There are lots of new issues with this stuff but I really think you're abusing this thread... no one else is ever going to find any of this stuff helpful because it's six pages into a thread about 'sysex' according to the name.

Please start new threads with each new issue and I'll be happy to help where I can.
 
Thank you oddson.
I tried to change the name if the thread but couldn't do it.
I thought this section was for full projects not each theme/issue its own thread.
 
Post here with any progress but I think you'll get better help by extracting out troubleshooting/technical support issues into separate sketches (as you have with the joystick) and seeking help separately in the technical support section.
 
Will do.
I'll "brake" the sketches into separate parts if needed any more help.
Anyway, when it is as i like i will post a new thread, connecting to this one and/or the other related ones eventually so that guys can see what were the rocks in my path.
 
Stabilizing a pot-read pitchbend is a topic unto itself unless you just mean to truncate to seven bits.

Getting it stable at 0 when not in contact is difficult if you want to use any of the LSB.

I don't have a ready-made solution for it so a new thread might garner some fresh ideas if that's what you're going for.
 
Status
Not open for further replies.
Back
Top