# Import and process MIDI data?

**URL:** <https://community.wolfram.com/t/import-and-process-midi-data/9901>\
**Category:** Questions\
**Tags:** audio-and-music, signal-processing, import-and-export\
**Created:** [January 18, 2017, 10:37pm UTC](https://community.wolfram.com/t/import-and-process-midi-data/9901 "2017-01-18T22:37:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeffjohncole](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@jeffjohncole](https://community.wolfram.com/u/jeffjohncole)\
**Post date:** [January 18, 2017, 10:37pm UTC](https://community.wolfram.com/t/import-and-process-midi-data/9901/1 "2017-01-18T22:37:12Z")

</div>

I’m trying to import MIDI data. As far as I can see, the import function is capable of importing a list of SoundNote[] functions.

```
sn = Import["Sing-joy.mid", "SoundNotes"]

```

The file I’m using as a sample at the moment is **attached**.

When you import the SoundNote list the time information part of each note is formatted as such: {starttime, endtime}

Here is an example of one of the SoundNotes:

```
SoundNote["E4", {0., 0.6}, "Piccolo", SoundVolume -> 0.862745]

```

My end goal format is { Time , ListOfNotes } with each note expressed as a number with 0 as middle c paired with a volume.

To make it fit properly I was planning to round all time values to multiples of 0.15

However I’m lost as to an efficient way of doing all this.

---

<div class="post-metadata">

**Author:** ![mhelmle](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@mhelmle](https://community.wolfram.com/u/mhelmle)\
**Post date:** [January 21, 2017, 10:00pm UTC](https://community.wolfram.com/t/import-and-process-midi-data/9901/2 "2017-01-21T22:00:55Z")

</div>

Hello Jeffery,  
this code should do approximately what you described.

```
toHalfTones[note_] := 
 Module[{octave = ToExpression[StringTake[note, -1]], 
   pitch = StringDrop[note, -1], 
   lst1 = {"C" -> 0, "C#" -> 1, "D" -> 2, "D#" -> 3, "E" -> 4, 
     "E#" -> 5, "F" -> 5, "F#" -> 6, "G" -> 7, "G#" -> 8, "A" -> 9, 
     "A#" -> 10, "B" -> 11, "B#" -> 12}},
  12 (octave - 4) + (pitch /. lst1)]

sn10 = Map[{Round[#[[2]], 0.15], {toHalfTones[#[[1]]], #[[4, 2]]}} &, 
  sn[[2]]]

```

Please check, I am not an expert on the proper notation of music
