Go Down

Topic: Fastled setBrightness not smooth (Read 721 times) previous topic - next topic

nathaimu

Hi !
I am a musician and producer, and I am working on a project where a small array of LED's need to sync up with audio. Not too complicated.

My problem is that I am controlling general brightness of all the array with FastLED.setBrightness(), and it works but not smoothly.
I can go all on, and all off, and jump to values in between, but when I sweep through all the values of brightness say for 1 second, brightness starts at 0, then climbs up and jumps erratically.
(I am controlling brightness through a MIDI signal coming from a software through Hairless)

Can anyone point me in the good direction ?

Here is part of the code :

Code: [Select]
int type, note, velocity, channel, d1, d2, ProgramChange, PitchBend, PitchRange;
  if (MIDI.read()) {                         // Is there a MIDI message incoming ?
    switch (MIDI.getType())                // What type of message is incoming ?
    {
      case midi::PitchBend: {               // If the type of message is PitchBend, then set the brightness to the value of PitchBend
          d1 = MIDI.getData1();
          d2 = MIDI.getData2();
          channel = MIDI.getChannel();
          delay(5);
          FastLED.setBrightness (d2);
          break;
        }

      case midi::ProgramChange: {
          d1 = MIDI.getData1();
          d2 = MIDI.getData2();
          channel = MIDI.getChannel();

          if (0 < d1 <= 127) {
            currentEffect = (d1);
          }

          else {
            currentEffect = 0;
          }
          break;
        default:
          break;
        }

    }

  }

Grumpy_Mike

#1
Jan 23, 2018, 02:23 pm Last Edit: Jan 23, 2018, 02:28 pm by Grumpy_Mike
Quote
Can anyone point me in the good direction ?
I refer you to the answer you got here

https://forum.arduino.cc/index.php?topic=524386.msg0#new

About using unassigned variables.

Where you also said:-
Quote
but I learn fast.
Learn not to cross post. You might not think you are cross posting but you are, don't do it.
Also please read this:-
How to use this forum


Also note that pitch bend has a 14 bit number, reconstruct the whole number from d1 and d2, then scale it it an 8 bit range for the brightness.

nathaimu

Thank you.
Indeed I did not think I was crossing posts.

Sorry about that, and thank you for your help. I didn't know PitchBend was a 14bit number.




Go Up