Convert csv to midi

Convert CSV to MIDI

Convert musical note tables or MIDICSV event files into editable Standard MIDI Files.

Convert CSV files online

We don’t have a dedicated online converter for CSV to MIDI yet, but you can convert CSV files online to these and more formats:

How to convert csv to midi file

A spreadsheet, analysis program, or custom composition tool may export note data as CSV while a sequencer, notation program, or MIDI hardware requires a Standard MIDI File. Conversion turns tabular musical events into an editable sequence instead of audio.

What CSV is

CSV (comma-separated values) is plain text organized into rows and columns. Composers, music researchers, spreadsheet users, DAWs, and custom scripts may use it for pitches, start times, durations, velocities, channels, controllers, or tempo data.

CSV has no universal musical schema. One file may contain columns such as pitch,start,duration; another may use note names, seconds, ticks, or one row for each MIDI event. The delimiter may be a comma, semicolon, or tab, and quoted fields may contain delimiters. Identify the column meanings, time units, encoding, and header structure before converting.

What MIDI is

A Standard MIDI File (.mid or .midi) stores timed musical instructions, including note, velocity, channel, program-change, controller, pitch-bend, tempo, meter, and key-signature events. It does not contain recorded sound; a synthesizer, virtual instrument, or hardware device generates the audio.

MIDI files are normally much smaller than audio files and allow notes, timing, velocity, instruments, tempo, and arrangement data to be edited independently. They can be opened by MuseScore Studio, Cubase, Logic Pro, Ableton Live, REAPER, and hardware sequencers, although playback sounds depend on the destination instruments.

Use MIDICSV for an existing MIDI event schema

The open-source MIDICSV utilities are the most direct option when the CSV follows the MIDICSV event format. They are not generic spreadsheet converters: midicsv exports a MIDI file into a defined CSV representation, and csvmidi converts that representation back into a MIDI file.

  1. Install the MIDICSV package for your operating system from its documented source.
  2. Export a MIDI file with midicsv input.mid events.csv.
  3. Edit events.csv without changing its required track, time, event-type, and parameter fields. Preserve numeric ranges and the required header or event syntax.
  4. Compile it with csvmidi events.csv output.mid.
  5. Open output.mid in a MIDI editor and check timing, instruments, controllers, and track structure.

A spreadsheet containing arbitrary columns such as start_beat, duration_beat, and pitch is not automatically compatible with csvmidi. Use a custom parser for that layout.

Convert a note-per-row CSV with Python

For a note table, use Python with the open-source mido library. Prepare notes.csv with one note per row and these columns: start_beat, duration_beat, pitch, velocity, and channel. Use MIDI pitches from 0 to 127, velocities from 1 to 127, channels from 0 to 15, and beats relative to a quarter note.

  1. Install the dependency with python -m pip install mido.
  2. Save this script as csv_to_midi.py beside notes.csv:
import csv
from mido import MidiFile, MidiTrack, Message, MetaMessage, bpm2tempo

bpm = 120
midi = MidiFile(ticks_per_beat=480)
track = MidiTrack()
midi.tracks.append(track)
events = [(0, 0, MetaMessage('set_tempo', tempo=bpm2tempo(bpm)))]

with open('notes.csv', newline='', encoding='utf-8-sig') as f:
    for row in csv.DictReader(f):
        start = float(row['start_beat'])
        duration = float(row['duration_beat'])
        pitch = int(row['pitch'])
        velocity = max(1, min(127, int(row.get('velocity') or 80)))
        channel = int(row.get('channel') or 0)
        if duration < 0 or not 0 <= pitch <= 127 or not 0 <= channel <= 15:
            raise ValueError('invalid duration, pitch, or channel')
        start_tick = round(start * midi.ticks_per_beat)
        end_tick = round((start + duration) * midi.ticks_per_beat)
        events.append((start_tick, 1, Message('note_on', note=pitch, velocity=velocity, channel=channel)))
        events.append((end_tick, 0, Message('note_off', note=pitch, velocity=0, channel=channel)))

events.sort(key=lambda item: (item[0], item[1]))
previous = 0
for tick, _, message in events:
    message.time = tick - previous
    track.append(message)
    previous = tick
midi.save('notes.mid')
  1. Run python csv_to_midi.py. The result is notes.mid, with 480 ticks per quarter note and a fixed tempo of 120 BPM.
  2. Open the file in MuseScore Studio through File → Open, or import it using a DAW's MIDI import command. Add instruments, tempo changes, meter, key signatures, or other musical data that the CSV did not contain.

If the source times are in seconds, convert them to beats using beats = seconds * bpm / 60. If they are MIDI ticks, divide by the source file's ticks-per-beat value. Seconds, beats, and ticks are not interchangeable. If the CSV contains event rows rather than note rows, write a parser that maps each event type to the corresponding MIDI message instead of using the note-table script.

Quality and compatibility limits

The result can preserve only data represented by the source schema and conversion method. The example preserves pitch, start time, duration, velocity, and channel, but not lyrics, sustain pedal, controller automation, program changes, tempo changes, meter, key signatures, articulations, or multiple tracks.

Overlapping notes are supported, but overlapping notes with the same pitch and channel can be ambiguous for some instruments. MIDI program numbers, drum-channel behavior, tuning, controller responses, and instrument sounds vary between applications and hardware. Inspect the imported file in a piano-roll or event editor and listen for incorrect tempo, missing notes, channel collisions, and shortened durations.

Online services are suitable only when they document the exact CSV layout they accept. Generic file converters cannot infer whether a column contains MIDI ticks, seconds, beats, note names, or event types. For custom compositions or private material, local conversion with MIDICSV or Python avoids uploading data and provides reproducible settings.

CSV vs MIDI: format comparison

How the CSV and MIDI formats compare on the properties that matter most for this conversion.

Comparison of the CSV and MIDI file formats
Property .CSV Comma-Separated Values .MIDI MIDI Standard File
Open standard Yes Yes
Compression Uncompressed Uncompressed
Typical file size Small Very small
Opens in a web browser Yes, natively No
Further editing Easy Easy
Metadata support Basic Basic
Plain-text readable Yes No
Best used for Data exchange Music
Introduced — 1983
Developer — MIDI Manufacturers Association / MIDI Association
MIME type text/csv audio/midi