readMidi: Read a MIDI file

Description Usage Arguments Value Note Author(s) References See Also Examples

View source: R/readMidi.R

Description

A MIDI file is read and returned in form of a structured data frame containing most event information (minus some meta events and minus all system events). For details about the represented information see the reference given below.

Usage

1

Arguments

file

Filename of MIDI file.

Value

A data frame consisting of columns

time

Time or delta-time of the events, depending on the MIDI format.

event

A factor indicating the event.

type

An integer indicating the type of a “meta event”, otherwise NA.

channel

The channel number or NA if not applicable.

parameter1

First parameter of an event, e.g. a representation for a note in a “note event”.

parameter2

Second parameter of an event.

parameterMetaSystem

Information in a “meta event”, currently all meta events are converted to a character representation (of hex, if all fails), but future versions may have more appropriate representations.

track

The track number.

Please see the given reference about the MIDI file format about details.

Note

The data structure may be changed or extended in future versions.

Author(s)

Uwe Ligges and Johanna Mielke

References

A good reference about the Midi file format can be found at http://www.music.mcgill.ca/~ich/classes/mumt306/StandardMIDIfileformat.html.

See Also

The function getMidiNotes extracts a more readable representation of note events only.

You may also want to read Wave (readWave) or MP3 (readMP3).

Examples

1
2
3
content <- readMidi(system.file("example_files", "Bass_sample.mid", package="tuneR"))
str(content)
content

Example output

'data.frame':	35 obs. of  8 variables:
 $ time               : num  0 0 0 0 0 0 0 129 360 480 ...
 $ event              : Factor w/ 27 levels "Note Off","Note On",..: 25 23 24 22 5 4 2 1 2 2 ...
 $ type               : chr  "58" "51" "54" "2f" ...
 $ channel            : num  NA NA NA NA 0 0 0 0 0 0 ...
 $ parameter1         : int  NA NA NA NA 33 7 45 45 48 50 ...
 $ parameter2         : int  NA NA NA NA NA 127 78 64 81 79 ...
 $ parameterMetaSystem: chr  "4/4, 24 clocks/tick, 8 1/32 notes / 24 clocks" "434464" "40 x 00 x 00 x 00 x 00" "" ...
 $ track              : int  1 1 1 1 2 2 2 2 2 2 ...
   time          event type channel parameter1 parameter2
1     0 Time Signature   58      NA         NA         NA
2     0      Set Tempo   51      NA         NA         NA
3     0   SMPTE Offset   54      NA         NA         NA
4     0   End of Track   2f      NA         NA         NA
5     0 Program Change <NA>       0         33         NA
6     0     Controller <NA>       0          7        127
7     0        Note On <NA>       0         45         78
8   129       Note Off <NA>       0         45         64
9   360        Note On <NA>       0         48         81
10  480        Note On <NA>       0         50         79
11  483       Note Off <NA>       0         48         64
12  600        Note On <NA>       0         52         68
13  609       Note Off <NA>       0         50         64
14  664       Note Off <NA>       0         52         64
15  840        Note On <NA>       0         45         82
16 1192       Note Off <NA>       0         45         64
17 1200        Note On <NA>       0         43         62
18 1430       Note Off <NA>       0         43         64
19 1440        Note On <NA>       0         45         80
20 1575       Note Off <NA>       0         45         64
21 1920        Note On <NA>       0         45         88
22 1997       Note Off <NA>       0         45         64
23 2280        Note On <NA>       0         48         77
24 2357       Note Off <NA>       0         48         64
25 2400        Note On <NA>       0         50         90
26 2520        Note On <NA>       0         52         75
27 2522       Note Off <NA>       0         50         64
28 2617       Note Off <NA>       0         52         64
29 2760        Note On <NA>       0         45         75
30 3120        Note On <NA>       0         48         77
31 3125       Note Off <NA>       0         45         64
32 3350       Note Off <NA>       0         48         64
33 3360        Note On <NA>       0         45         78
34 3450       Note Off <NA>       0         45         64
35 3839   End of Track   2f      NA         NA         NA
                             parameterMetaSystem track
1  4/4, 24 clocks/tick, 8 1/32 notes / 24 clocks     1
2                                         434464     1
3                         40 x 00 x 00 x 00 x 00     1
4                                                    1
5                                           <NA>     2
6                                           <NA>     2
7                                           <NA>     2
8                                           <NA>     2
9                                           <NA>     2
10                                          <NA>     2
11                                          <NA>     2
12                                          <NA>     2
13                                          <NA>     2
14                                          <NA>     2
15                                          <NA>     2
16                                          <NA>     2
17                                          <NA>     2
18                                          <NA>     2
19                                          <NA>     2
20                                          <NA>     2
21                                          <NA>     2
22                                          <NA>     2
23                                          <NA>     2
24                                          <NA>     2
25                                          <NA>     2
26                                          <NA>     2
27                                          <NA>     2
28                                          <NA>     2
29                                          <NA>     2
30                                          <NA>     2
31                                          <NA>     2
32                                          <NA>     2
33                                          <NA>     2
34                                          <NA>     2
35                                                   2

tuneR documentation built on July 10, 2018, 1:02 a.m.