Vibrato - Using software on a MIDI Note


Active member
Hi All

I'm creating a midi project and Id like to add vibrato (modulation) to a note automatically via the code. For various reasons, I don't have the option of using a bite sensor like you would see on an EWI which measures the bite sensor with an analog input and this variation in analog signal is mapped to CC1 Modulation.

I'm wondering is it possible to add modulation automatically with code without any analog input, or alternatively providing a signal from the DAC or PWM channel and feeding it into an analog channel to simulate modulation?

I should mention, I am using a Teensy 3.2

Can the Teensy Audio Library do this?

all comments are welcome, thanks in advance for any support.

Do you mean vibrato (pitch modulation) or tremolo (volume modulation)?
Yes its easy to generate low frequency modulation signals with the various oscillator (waveform) classes.
There is the modulated waveform class, AudioSynthWaveformModulated, that you can frequency modulate.
Amplitude modulation would be done with AudioEffectMultiply
Hi MarkT

Its pitch modulation I want to do and I'm wondering if I can add it to a velocity command as well. Could you elaborate a little more on "There is the modulated waveform class, AudioSynthWaveformModulated, that you can frequency modulate.
Amplitude modulation would be done with AudioEffectMultiply".

Perhaps you could drop me a code example?
There's a whole slew of docs for the audio library, and a video, and it comes with lots of examples.
The video seems to be about manipulating an mp3 file, but I wont to basically know how I can use the pitch bend midi command with velocity to create vibrato.....

Maybe you can point me to the documentation please...
You can use pitch bend to generate vibrato but you have to generate every pitch bend message yourself.
This demo code sends a MIDI note on and then generates pitch bend messages based on sine wave for two seconds. Then it resets pitch bend to zero, let's the note play one more second and then turns the note off.
It sends MIDI messages to both a MIDI device (e.g. keyboard) on Serial1 and also through USB to the PC.
DEMO by Pete (El_Supremo)
  Play MIDI Note On followed by modulated pitchbend
  messages to cause vibrato.
  To play this through MIDI-OX to the MS GS Wavetable Synth
  on the PC, in MIDI-Ox set
  Options|Midi Devices
    Select Teensy MIDI as the input
    Select MS GS Wavetable Synth as the output
    Click on OK
  In theory, that is all that is needed but if it fails
  try turning on the Keyboard as well:
    Turn on Keyboard
#if !defined(USB_MIDI) && !defined(USB_MIDI_SERIAL)
#error Must set as Tools|USB Type "MIDI" or "Serial + MIDI"

#define ACTIVE_LED_PIN 27

#include <MIDI.h>
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);

// Toggle the LED whenever Active Sense is received
uint8_t ledbit = 0;
void get_active_sense(void)
  ledbit ^= 1;

void setup()

  Serial.println("MIDI Modulation test");

  // LED is toggled when an Active Sense MIDI message is
  // received (from SY77).

// Start the serial MIDI interface to the SY77

  // The SY77 sends Active Sense. The flashing LED will
  // give a positive indication that the keyboard is on
  // and being seen by the Teensy

  uint8_t note = 60;
  Serial.println("Send Note On");
  MIDI.sendNoteOn(note, 100, 1);
  usbMIDI.sendNoteOn(note, 100, 1);

  // Send pitch bend messages at the specified sample rate
  // Pitchbend varies from -8192 to +8191
  // Amplitude of the "bend"  +/-amp
  float amp = 3000;
  // phase varies from zero to one and is converted
  // to a fraction of zero to TWO_PI when calling
  // the sin function
  float phase = 0.0;
  // Pitch bend rate
  float freq = 8;
  // sampling frequency 
  float sampling_freq = 50.;

  // Play for 2 seconds
  for(int i = 0; i < 2*sampling_freq; i++) {
    int pitch = (int) (amp*sin(phase*TWO_PI));
    // Increment the phase
    phase += freq/sampling_freq;
    // If phase is at least 1, reduce it by 1.
    if(phase >= 1) phase -= 1;
  // Turn pitchbend off and play for one more second

  Serial.println("Send Note Off");
  // Turn off the note
  MIDI.sendNoteOff(note, 0, 1);
  usbMIDI.sendNoteOff(note, 0, 1);

void loop()