Pages: [1]   Go Down
Author Topic: beginner question: timestamping incoming midi data  (Read 499 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi there,

I want to timestamp incoming midi data that I will read into Arduino using this midi interface and this midi library. My plan is to wait until there is data available at the serial connection, read it in and then immediately after generate a timestamp using micros(). Then I want to send the event and the timestamp over serial usb to a host. Does anything here raise a red flag with anyone? In particular, is there anything that might cause the timestamp to be inaccurate? Thanks!
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 640
Posts: 50331
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
My plan is to wait until there is data available at the serial connection, read it in and then immediately after generate a timestamp using micros().
What are you expecting to get from the serial port? How will you know when a packet is complete?

Quote
Then I want to send the event and the timestamp over serial usb to a host.
The same serial port that you just read from? What does this have to do with MIDI?

Quote
In particular, is there anything that might cause the timestamp to be inaccurate?
The fact that micros() only updates every 4 microseconds.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the quick reply!

A microsecond granularity is fine with me, but that's good to know about. I want to send the data over usb to a host running Matlab where I collect the midi note data, along with some other sensors that are connected to the Arduino.

As for knowing when the packet is complete, I had assumed that the midi library would handle that.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 640
Posts: 50331
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you look at the picture in your first link, the MIDI device is connected to the serial port. You can't also use the serial port to send data to the PC.

Using that library on a Mega with multiple hardware serial ports looks possible. Using it with SoftwareSerial and any other pins looks a bit more challenging.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is valuable information. Just to clarify, even though I plan to use only the Rx port I can't use the Tx port to transmit to host?
« Last Edit: July 23, 2012, 05:20:33 pm by brownerthanu » Logged

Pages: [1]   Go Up
Jump to: