Dienstag, 13. Dezember 2011

Now I have my Fluxamasynth shield!

I just wrote a very simple program which uses NewSoftSerial for the MIDI communication towards the Fluxamasynth shield on pin 4. This small program runs through the 256 sounds of the shield (on MIDI channel 1) and plays a chord (randomized start note).



The source code should be easy to understand:

#include <fluxamasynth_nss.h>
#include <newsoftserial.h>

Fluxamasynth synth;

#define c3 48          // define our notes to their midi values
#define e3 52
#define g3 55
#define c4 60

void setup()
{
  Serial.begin(9600);
  synth.setMasterVolume(100);
}

void loop()
{
  byte i=0,n=0,z=0;

  for (n=0;n<=1;n++)
  {
    for(i=0;i<=127;i++)
    {
      synth.programChange(n*127,0, i);

      Serial.print("Bank: ");
      Serial.print(n,DEC);
      Serial.print(" Sound: ");
      Serial.println(i,DEC);

      z=random(0,12);

      synth.noteOn(0, c3+z, 107);
      delay(100);
      synth.noteOn(0, e3+z, 107);
      delay(100);
      synth.noteOn(0, g3+z, 107);
      delay(100);
      synth.noteOn(0, c4+z, 107);

      delay(200);
      synth.noteOff(0, c3+z);
      synth.noteOff(0, e3+z);
      synth.noteOff(0, g3+z);
      synth.noteOff(0, c4+z);
      delay(200);
    }
  }
}

You also need the NewSoftSerial library from http://arduiniana.org/libraries/newsoftserial/ and the Fluxamasynth library from http://wiki.moderndevice.com/pmwiki.php?n=MD.Fluxamasynth.

The next step is to try how to play MIDI songs. The Fluxmasynth shield can play up to 8 voices and a drumset!

Keine Kommentare:

Kommentar veröffentlichen