Go Down

Topic: Library for playing MIDI files from the Arduino (Read 7816 times) previous topic - next topic

marco_c

Code: [Select]
#define  LCD_D4    4
#define  LCD_D5    (LCD_D4+1)
#define  LCD_D6    (LCD_D4+2)
#define  LCD_D7    (LCD_D4+3)


D5 = D4 + 1 ==> 5. Similarly for the other 6,  7.

You need to check the code for the values that are used to separate the buttons and substitute your values for those in the code.

Looks like you are close!
Arduino Libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com

Code: [Select]
// LCD pin definitions ---------
// These need to be modified for the LCD hardware setup
#define  LCD_RS    12
#define  LCD_ENA   11
#define  LCD_D4    5
#define  LCD_D5    4
#define  LCD_D6    3
#define  LCD_D7    2

so i have the LCD working. it reads Midi Player on bootup, but then nothing happens.

this is fun i am learning i learned how to use the analogreadserial function on A0 for my momentary switches

Code: [Select]
const TKEYDEF keyDefTable[] =
{
  {   0, 10, 'R' }, // Right
  { 150, 15, 'U' }, // Up
  { 349, 15, 'D' }, // Down
  { 516, 15, 'L' }, // Left
  { 758, 15, 'S' } // Select
};


i now have these values in the left column added, did i add these correctly? Also I am almost positive i shouldn't need to change anything in the sketch for the seeed SD shield...??? When i ran SD cardinfo all seemed well.... I know i am really close now that i can read Midi Player

marco_c

Quote
Also I am almost positive i shouldn't need to change anything in the sketch for the seeed SD shield...???

As for the other parts, you need to check that the interface pins in the software setup match the hardware. Try running one of the examples from the SD/SDFat library (whichever you are using) to make sure the SD card interface works.

Quote
i now have these values in the left column added, did i add these correctly?

Looks like it - does it work?

Quote
it reads Midi Player on bootup, but then nothing happens.

Do you mean it displays "MIDI Player"? If nothing else is happening then probably your SD card pins setup is not right. See above.

Arduino Libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com

Quote
Try running one of the examples from the SD/SDFat library (whichever you are using) to make sure the SD card interface works.


Ok so i tried a few incarnations of this adding and subtracting libraries and it seems like i am able to read the SD just fine pin select 10 is working fine in every example.

Quote
Do you mean it displays "MIDI Player"? If nothing else is happening then probably your SD card pins setup is not right. See above.


I am able to get "Midi Player" but then it just gets stuck. I t also seems that there is a blank text document showing up on the SD card after each attempt...

marco_c

Are there any music files on the SD card? You should use the MIDI examples that are with the library and copy them to the SD card.
Arduino Libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com

no music files i have only been trying midi type zero files in all different orders of; in a folder or separate now i have just been testing  with your files assuming they are all type0. I have tried in all arrangements of the library of the SdFat. Not sure what the best next step should be...?

Really appreciate this library and your help so far i am very excited to build with this!  :D

haha silly of me to think i could use enable on the LCD and RS over the SPI ports. Thanks again for all the help. I have a large amount of midi files i am going to be trying with is there anything to look out for that you would like me to report back on?

Thook

#37
Apr 23, 2014, 12:46 pm Last Edit: Apr 23, 2014, 02:16 pm by Thook Reason: 1
Hello guys, as I am REALLY new arduino (like 2 days) and without any experience in C++ but some in C,
I've been trying to understand the library with a bit of difficulty.
I gave myself an easy task: create a little drum sequencer of 12 buttons.
I would like to stock the midi files, read from the SD card in an array, but I don't know how to get the data, you'll see the missing line... I don't understand well the role of "getNextEvent" function and if this is what I need to use.

Do you see anything else I should know before I get embroiled ?
Thank you !

Code: [Select]

void  setup(void)
{
 int      err;
 int      track = 0;
 byte     array[12][128];
for (uint8_t i=0; i<ARRAY_SIZE(array); i++) //gets size of array to ignore the rest of tunelist, if > 12;
{
 SMF.setFilename(tuneList[i]);
 err = SMF.load();
 if (err == -2) // File doesn't exist or isn't properly formatted;
         ;// fill array[data] with notes Off;
 else
 {
               byte  data = 0;
smf.setTempo(100);
               while (!SMF.isEOF() || data < 128)
                   array[track][data++] = // ?
               while (data < 128)
                  array[track][data++] = 0x80; // only if the MIDI file is too short, fills with NoteOff;
               track++;
SMF.close();
midiSilence();
delay(WAIT_DELAY);
 }
}
}

yair

im having an issue with the library
any input midi file i introduce will play at double speed.
and the  time segment value is set to 2/0
when i enable dump in the header i get

the code is vannila loop example.

Code: [Select]


[MidiFile Looper]
File Name:
File format: 0
Tracks: 0
Time division: 48
Tempo: 120
Microsec/tick: 10416
Time Signature: 4/4
getTempo(): 1

-- [1] TRK 0
dT: 0 + 1 [META] Type: 0x58 Len: 4 SET TIME SIGNATURE to 2/0
-- TRK 1
dT: 0 + 1 [MID1] Ch: 0 Data: C0 7
-- TRK
-- [1] TRK 0
dT: 0 + 2 [META] Type: 0x51 Len: 3 SET TEMPO to 405 us/tick or 77 beats/min
-- TRK 1
-- [14] TRK 0
dT: 0 + 16 [META] Type: 0x2F Len: 0 END OF TRACK - OUT OF TRACK
-- TRK 1








im posting here in hopes the orgial thread owner will see.

marco_c

Can you please send me the midi file (or a link) via PM?
Arduino Libraries http://arduinocode.codeplex.com
Parola for Arduino http://parola.codeplex.com

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy