robertsonics / WAV-Trigger-Arduino-Serial-Library

WAV Trigger Serial Control Arduino Library
27 stars 13 forks source link

Simple example for how to MIDI-control via an Arduino #25

Open baloe opened 1 year ago

baloe commented 1 year ago

I would like to simply play a note in MIDI mode.

I have done the following:

I have been playing around with a few arduino sketches, like the one below, but none of them ever produced a sound. Could anyone give me a hint on how to get this to work?

#include <MIDI.h>

// Create and bind the MIDI interface to the default hardware Serial port
//MIDI_CREATE_INSTANCE(HardwareSerial, Serial, MIDISerial);
MIDI_CREATE_DEFAULT_INSTANCE();

void setup()
{ 
    MIDI.begin();
}

void loop()
{
    for (int note = 0; note < 100; note++) {
      MIDI.sendNoteOn(note, 127, 1);
      delay(100);
      MIDI.sendNoteOff(note , 0, 1);
      delay(100);
    }
}

(I am also asking in the Midi library discussion group: https://github.com/FortySevenEffects/arduino_midi_library/discussions/313)

bazmonk commented 1 year ago

delay(100) is only a tenth of a second. Try making those longer, like a few thousand (which would be a few seconds).

How are you powering the Trigger?

Are you sure Tx on the Arduino isn't pin 1? On every Arduino I've seen, 0 is Serial1 Rx, and pin 1 is Tx (the one you want to connect to the Trigger's Rx).

I use Triggers in a project and much prefer talking to it via Serial instead of MIDI (even though, funnily enough, I'm using it in a MIDI instrument). I can absolutely give you an example of that, if you're willing to go that route (same wiring, just a more direct way of talking to the Trigger). Otherwise the rest looks good.

(I'm not associated with this project, just chiming in)