Added the correct capacitors (see diagram below, P9 of the datasheet) for running the AS5048A at 3.3V, which may have made it a little smoother. I was able to pull back the filter range to 3 without getting any noticeable noise. You can still hear the steps at low speeds but should be good enough for fast scratching and jogging.
I also adjusted the pwm_min and pwm_max values from 0 - 1000 to 3 - 910, because in the serial debug I have never seen values outside those limits. This eliminated the âjumpâ that could be heard in the first video using Virtual DJ as the values cross the 0/max point.
Final code (AS5048_PWM_simpleMIDI04):
//http://www.benripley.com/diy/arduino/three-ways-to-read-a-pwm-signal-with-arduino/
#include <C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\MIDI\MIDI.h>
#include <midi_Defs.h>
#include <midi_Message.h>
#include <midi_Namespace.h>
#include <midi_Settings.h>
int pwm_value; //current pwm reading
int pwm_prev; //previous pwm_value
int changerange = 3; //the amount the pwm_value must change before moving onto parse and data send
int pwm_max = 910; //max of pwm range
int pwm_min = 3; //min of pwm range
int PWM_PIN = 3; //pwm input pin
int midimax = 127; //max of MIDI range
int ccval; //value for MIDI control change
const int MIDI_CHAN = 1; //set MIDI channel
byte MIDI_CTRL = 9; //MIDI control number (decimal converted from hex), in this case 9 = 0x09
void setup() {
 pinMode(PWM_PIN, INPUT);
 Serial.begin(9600);
}
void loop(){
 pwmread();
 if(pwm_value >= ((pwm_prev - changerange)) && (pwm_value <= (pwm_prev + changerange))){
  //filter: checks pwm_value is within the changerange of the previous measurement
  //doesn't work when crossing 0 (min-max or vice versa) - but still stable enough
 } //if so, do nothing
 else{ //if outside the range, send data
  pwmparse();
  datasend();
  pwm_prev = pwm_value; //save pwm_value for comparison on the next loop Â
 }
}
void pwmread() { //read pwm value from PWM_PIN
 pwm_value = pulseIn(PWM_PIN, HIGH);
}
void pwmparse() { //convert the pwm_value to a range that fits with MIDI
 ccval = map(pwm_value, pwm_min, pwm_max, 0, midimax); //map(value, fromLow, fromHigh, toLow, toHigh)
}
void datasend(){ //send MIDI data and print serial for debug
 usbMIDI.sendControlChange(MIDI_CTRL, ccval, MIDI_CHAN); //(control, value, channel)
 Serial.print("MIDI ");
 Serial.print(MIDI_CTRL,HEX);
 Serial.print(" ");
 Serial.print(ccval);
 Serial.print(" ");
 Serial.print(MIDI_CHAN);
 Serial.print(" PWM ");
 Serial.println(pwm_value);
}