Search Results for

    Show / Hide Table of Contents

    Class CsvConverter

    Provides methods to convert MIDI objects to CSV representation and vice versa.
    Inheritance
    Object
    CsvConverter
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: Melanchall.DryWetMidi.Tools
    Assembly: Melanchall.DryWetMidi.dll
    Syntax
    public sealed class CsvConverter

    Methods

    ConvertCsvToMidiFile(Stream, MidiFileCsvConversionSettings)

    Converts CSV representation of a MIDI file to MidiFile reading CSV data from a stream.
    Declaration
    public MidiFile ConvertCsvToMidiFile(Stream stream, MidiFileCsvConversionSettings settings = null)
    Parameters
    Type Name Description
    Stream stream Stream to read MIDI file from.
    MidiFileCsvConversionSettings settings Settings according to which CSV data must be converted. Pass null to use default settings.
    Returns
    Type Description
    MidiFile An instance of the MidiFile representing a MIDI file written in CSV format.
    Exceptions
    Type Condition
    ArgumentNullException stream is null.
    ArgumentException stream doesn't support reading.
    IOException An I/O error occurred while reading from the stream.
    ObjectDisposedException stream is disposed.

    ConvertCsvToMidiFile(String, MidiFileCsvConversionSettings)

    Converts CSV representation of a MIDI file to MidiFile reading CSV data from a file.
    Declaration
    public MidiFile ConvertCsvToMidiFile(string filePath, MidiFileCsvConversionSettings settings = null)
    Parameters
    Type Name Description
    String filePath Path of the file with CSV representation of a MIDI file.
    MidiFileCsvConversionSettings settings Settings according to which CSV data must be converted. Pass null to use default settings.
    Returns
    Type Description
    MidiFile An instance of the MidiFile representing a MIDI file written in CSV format.
    Remarks
    Note that CSV representation of a MIDI file can be different. You can specify expected CSV layout via settings using CsvLayout property.
    Exceptions
    Type Condition
    ArgumentException filePath is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.
    ArgumentNullException filePath is null.
    PathTooLongException The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
    DirectoryNotFoundException The specified path is invalid, (for example, it is on an unmapped drive).
    IOException An I/O error occurred while reading the file.
    NotSupportedException filePath is in an invalid format.
    UnauthorizedAccessException

    One of the following errors occured:

    • This operation is not supported on the current platform.
    • filePath specified a directory.
    • The caller does not have the required permission.

    ConvertCsvToNotes(Stream, TempoMap, NoteCsvConversionSettings)

    Converts CSV representation of notes to collection of MidiFile reading CSV data from a stream.
    Declaration
    public IEnumerable<Note> ConvertCsvToNotes(Stream stream, TempoMap tempoMap, NoteCsvConversionSettings settings = null)
    Parameters
    Type Name Description
    Stream stream Stream to read notes from.
    TempoMap tempoMap Tempo map used to convert notes from CSV.
    NoteCsvConversionSettings settings Settings according to which CSV data must be converted. Pass null to use default settings.
    Returns
    Type Description
    IEnumerable<Note> Collection of Note representing notes written in CSV format.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occured:

    • stream is null.
    • tempoMap is null.
    ArgumentException stream doesn't support reading.
    IOException An I/O error occurred while reading from the stream.
    ObjectDisposedException stream is disposed.

    ConvertCsvToNotes(String, TempoMap, NoteCsvConversionSettings)

    Converts CSV representation of notes to collection of Note reading CSV data from a file.
    Declaration
    public IEnumerable<Note> ConvertCsvToNotes(string filePath, TempoMap tempoMap, NoteCsvConversionSettings settings = null)
    Parameters
    Type Name Description
    String filePath Path of the file with CSV representation of notes.
    TempoMap tempoMap Tempo map used to convert notes from CSV.
    NoteCsvConversionSettings settings Settings according to which CSV data must be converted. Pass null to use default settings.
    Returns
    Type Description
    IEnumerable<Note> Collection of Note representing notes written in CSV format.
    Exceptions
    Type Condition
    ArgumentException filePath is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.
    ArgumentNullException

    One of the following errors occured:

    • filePath is null.
    • tempoMap is null.
    PathTooLongException The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
    DirectoryNotFoundException The specified path is invalid, (for example, it is on an unmapped drive).
    IOException An I/O error occurred while reading the file.
    NotSupportedException filePath is in an invalid format.
    UnauthorizedAccessException

    One of the following errors occured:

    • This operation is not supported on the current platform.
    • filePath specified a directory.
    • The caller does not have the required permission.

    ConvertMidiFileToCsv(MidiFile, Stream, MidiFileCsvConversionSettings)

    Converts the specified MidiFile to CSV represenattion and writes it to a stream.
    Declaration
    public void ConvertMidiFileToCsv(MidiFile midiFile, Stream stream, MidiFileCsvConversionSettings settings = null)
    Parameters
    Type Name Description
    MidiFile midiFile MidiFile to convert to CSV.
    Stream stream Stream to write CSV representation to.
    MidiFileCsvConversionSettings settings Settings according to which midiFile must be converted. Pass null to use default settings.
    Remarks
    Note that MidiFile can be converted to different CSV representations. You can specify desired CSV layout via settings using CsvLayout property.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occured:

    • midiFile is null.
    • stream is null.
    ArgumentException stream doesn't support writing.
    IOException An I/O error occurred while writing to the stream.
    ObjectDisposedException stream is disposed.

    ConvertMidiFileToCsv(MidiFile, String, Boolean, MidiFileCsvConversionSettings)

    Converts the specified MidiFile to CSV represenattion and writes it to a file.
    Declaration
    public void ConvertMidiFileToCsv(MidiFile midiFile, string filePath, bool overwriteFile = false, MidiFileCsvConversionSettings settings = null)
    Parameters
    Type Name Description
    MidiFile midiFile MidiFile to convert to CSV.
    String filePath Path of the output CSV file.
    Boolean overwriteFile If true and file specified by filePath already exists it will be overwritten; if false and the file exists, exception will be thrown.
    MidiFileCsvConversionSettings settings Settings according to which midiFile must be converted. Pass null to use default settings.
    Remarks
    Note that MidiFile can be converted to different CSV representations. You can specify desired CSV layout via settings using CsvLayout property.
    Exceptions
    Type Condition
    ArgumentNullException midiFile is null.
    ArgumentException filePath is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.
    ArgumentNullException filePath is null.
    PathTooLongException The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
    DirectoryNotFoundException The specified path is invalid, (for example, it is on an unmapped drive).
    IOException An I/O error occurred while writing the file.
    NotSupportedException filePath is in an invalid format.
    UnauthorizedAccessException

    One of the following errors occured:

    • This operation is not supported on the current platform.
    • filePath specified a directory.
    • The caller does not have the required permission.

    ConvertNotesToCsv(IEnumerable<Note>, Stream, TempoMap, NoteCsvConversionSettings)

    Converts the specified collection of Note to CSV represenattion and writes it to a stream.
    Declaration
    public void ConvertNotesToCsv(IEnumerable<Note> notes, Stream stream, TempoMap tempoMap, NoteCsvConversionSettings settings = null)
    Parameters
    Type Name Description
    IEnumerable<Note> notes Collection of Note to convert to CSV.
    Stream stream Stream to write CSV representation to.
    TempoMap tempoMap Tempo map used to convert notes to CSV.
    NoteCsvConversionSettings settings Settings according to which notes must be converted. Pass null to use default settings.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occured:

    • notes is null.
    • stream is null.
    • tempoMap is null.
    ArgumentException stream doesn't support writing.
    IOException An I/O error occurred while writing to the stream.
    ObjectDisposedException stream is disposed.

    ConvertNotesToCsv(IEnumerable<Note>, String, TempoMap, Boolean, NoteCsvConversionSettings)

    Converts the specified collection of Note to CSV represenattion and writes it to a file.
    Declaration
    public void ConvertNotesToCsv(IEnumerable<Note> notes, string filePath, TempoMap tempoMap, bool overwriteFile = false, NoteCsvConversionSettings settings = null)
    Parameters
    Type Name Description
    IEnumerable<Note> notes Collection of Note to convert to CSV.
    String filePath Path of the output CSV file.
    TempoMap tempoMap Tempo map used to convert notes to CSV.
    Boolean overwriteFile If true and file specified by filePath already exists it will be overwritten; if false and the file exists, exception will be thrown.
    NoteCsvConversionSettings settings Settings according to which notes must be converted. Pass null to use default settings.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occured:

    • notes is null.
    • tempoMap is null.
    ArgumentException filePath is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.
    ArgumentNullException filePath is null.
    PathTooLongException The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
    DirectoryNotFoundException The specified path is invalid, (for example, it is on an unmapped drive).
    IOException An I/O error occurred while writing the file.
    NotSupportedException filePath is in an invalid format.
    UnauthorizedAccessException

    One of the following errors occured:

    • This operation is not supported on the current platform.
    • filePath specified a directory.
    • The caller does not have the required permission.
    In This Article
    Back to top 2022 / Generated by DocFX