Mittwoch, 23. November 2011

Arduino - Music - MIDI - Fluxamasynth: My current project

I was just ordering a shield which seems to have the same power as my old Roland D-110: Fluxamasynth (see http://wiki.moderndevice.com/pmwiki.php?n=MD.Fluxamasynth). There is a library for the shield which plays sound via MIDI (pin 1/2) and there is a port of the library which uses NewSoftSerial so you can use other pins than 1/2 (and you can use 1/2 for debugging output).

I also adopted the MIDI library to use NewSoftSerial as backend (instead of Hardware Serial) but until now I had no time to test this. I hope I can do this when I get my Fluxamasynth shield.

Actually I have written a simple sketch which uses both libraries to get midi data from an external keyboard and sends it to the Fluxamasynth shield:

#include <NewSoftMIDI.h>
#include <Fluxamasynth_NSS.h>
#include <NewSoftSerial.h>

Fluxamasynth synth; // uses pin4 for midi-in and no pin for midi-out
NewSoftMIDI midi(7,255); // uses pin 7 for midi-in and no out pin 

void HandleNoteOn(byte channel, byte pitch, byte velocity)
{
  if (velocity == 0)
  {
    HandleNoteOff(channel,pitch,velocity);
  }
  else
  {
    synth.noteOn(channel,pitch,velocity);
  }
}

void HandleNoteOff(byte channel, byte pitch, byte velocity)
{
  synth.noteOff(channel,pitch);
}

void setup()
{
  synth.programChange(0, 0, 40);
  midi.begin(MIDI_CHANNEL_OMNI);    
  midi.setHandleNoteOn(HandleNoteOn);  
  midi.setHandleNoteOff(HandleNoteOff);  
}

void loop()
{
  midi.read();    
}
Note: This is currently untested!

If someone likes to test the NewSoftMIDI library, please contact me!

Keine Kommentare:

Kommentar veröffentlichen