read midi files/control arduino servo's

nedhallett's icon

hello I've been doing allot of googling on the above subject but failed to find anything that answers a few specific questions.

1) can midi files be stored and read in max.

2)can whole midi files stored on the arduino sd card be sent to max.

A little background I'm currently working (for part of my final project at uni) on an Arduino web application that aims to offer the user live music on demand.

what Ive got at the moment is basically a way for users to control the Arduino in a few simple ways , turning lights on and off ect.

what I am trying to achieve is to have a library of midi files of well known song stored on either the arduino sd card or in max which when read will prompt my servos (which will be equipped with beaters and suspended above a xylophone) to play the corresponding melody.

Ive found resources on how to send simples messages and commands to max and I think that I'd be able to create a patch that controlled my servos corresponding with note values (in the manner described above)

what I can't find is a resource telling me how to either store and read midi files in max or send them to max from Arduino to be read. I'm very new to max but I'd imagine if the files were stored in max Id be able to set up a prompt from the arduino to begin playing them and thus controlling the servos.

any help would be really appreciated as I'm pretty clueless when it comes to max and sorry If anything Ive said demonstrates a severe lack of knowledge

cheers

sam

pdelges's icon

Everything is possible ;-)

It is easy to store MIDI files and play them with Max to an arduino over the serial port. This can also be done in real time.
I worked on a project where a musician can write a MIDI score in GarageBand, which is played to a Max patch that controls a arduino driving 16 relays. The score is then stored in the arduino (not as a MIDI file, but in a array) and can then be replayed without the need of a computer.

If you store the score in the arduino's flash memory rather than in SRAM, it can be quite big (especially of you need only on/off states). But it could be stored on a SD card too (I may work on this soon).

I never tried to use MIDI files on the arduino but it should be possible (I think there are even some libraries for that). You should find plenty of informations on arduino.cc

You don't need Max for your project, but it may be easier. Check the seq object to play files. Sending datas to the arduino depends on the way you want to communicate.
If you use a MIDI shield with the arduino, you could just send MIDI notes from Max (or whatever sequencer) to the arduino (but maybe a MIDI shield will interfere with your servo shield).
If you don't, you can send datas over USB from the Mac to the arduino (see the serial object, and the examples in the arduino's IDE), but you'll need to define a communication protocol.

nedhallett's icon

Thanks patrick I just got a copy of max today so will be trying stuff out. I had the idea that actually I wouldn't need to send midi to arduino at all as I could control the servo's in max so
arduino prompts max to read the mdid file then depending on the time/noteons max sends serial back to the arduino that controls the servos? I don't know , will have a try and see what works, I do have a mdid shield though.

cheers for the advice
ned