Midi file conversion to Arduino Sketch

Hello there.

I am trying to implement an idea which requires that I take an existing MIDI note file and convert it so that each track can be assigned to a specific pin out on the Arduino.

I have found a few examples of this online but the one which seems to suggest it can do what I want to do is not compiling properly. I have tried opening it up in various versions of the IDE but although there are some improvements such as the compiler gets beyond previous issues it still refuses to compile.

This is the source code generator page

http://moddersandrockers.com/littlebits/midi/1.php

and I will attach a simple midi file that I have been using in case anyone is able to help me.

Cheers.

r.

PS I was unable to attach the MIDI file as it is not accepted on the forum for some reason.

Having now read the “How to use this forum” page I will give some particulars about my problem. Sorry I didn’t get it right the first time !

I am currently using an Arduino Uno and running a MacBook Pro OS 10.12.5. I have tried compiling on versions 1.0.5, 1.5, 1.6 (java 7) and 1.81 all with various errors.

Below is the code I am using as well as attachments for extra related files. I believe the included avr library is standard so I have not attached any such libraries.

// Midi to Arduino by Peter Churchyard (@codewizard58)
// this file was generated from http://moddersandrockers.com/littlebits/midi


#include <avr/pgmspace.h>
#include "play.h"
#include "miditune.h"

// The following are generated by midi.js
int format = 2;
#define FORMAT_MIDI 1
unsigned long tempo_us = 500000;
int ppqn = 480;

// 1 - Oscillator on A5
// 2 - Oscillator on A9
// 3 - Send keycodes
// 4 - Send Midi on D1
//

int outopts[] = {
  1 ,
  0
};


const unsigned char PROGMEM tune_1[] = {
  // Pin 1
  //
  T0(0), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  T1(131, 17), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  T1(131, 17), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  T1(134, 113), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  T1(131, 17), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  T1(131, 17), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  // Pin 2
  //
  T0(120), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  T1(131, 17), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  T1(131, 17), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  T1(134, 113), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  T1(131, 17), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  T1(131, 17), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  // Pin 3
  //
  T1(129, 112), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  T1(131, 17), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  T1(131, 17), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  T1(134, 113), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  T1(131, 17), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  T1(131, 17), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  // Pin 4
  //
  T1(131, 16), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  T1(131, 17), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  T1(131, 17), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  T1(134, 113), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  T1(131, 17), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  T1(131, 17), NOTE_ON(N_C(4), 98, 0),
  T0(79), NOTE_OFF(N_C(4), 64, 0),
  // end of tune
  0, 0
};

I am unsure as to what is happening. I could post a list of errors but they vary from IDE to IDE version.
So perhaps it is easiest if someone who is willing to help can attempt to compile and let me know of the results. I realize this may be counter intuitive but I think it would be economical time wise ? BTW The code is exactly as it was generated by the site I listed in my first post.

Cheers and thanks for any assistance you may be able to provide.

play.h (1 KB)

miditune.h (752 Bytes)

play.ino (3.99 KB)