Comments (8)
Hi,
Thank you for using the library.
DryWetMIDI is just a .NET library, it's not about UI. It provides features to work with MIDI files and devices. You can use it in any .NET Framework application: console or GUI, WinForms or WPF.
Please tell me, what's the problem you've encountered?
If you want to use MIDI file splitting features, please read the article in the library Wiki: MIDI file splitter. You need add using Melanchall.DryWetMidi.Tools
to access tools.
If you want to draw content of a MIDI file, it's up to you. DryWetMIDI is not about visual representation of MIDI entities.
from drywetmidi.
Thanks for your very quick reply @melanchall
I have read the article MIDI file splitter but do not understand how to implement in WinForms.
Problem: I cannot see DryWetMIDI methods in Intellisense with a basic WinForms app. I have downloaded the Nuget package but I have obviously misunderstood something.
`using Melanchall.DryWetMidi;
using Melanchall.DryWetMidi.MusicTheory;
using Melanchall.DryWetMidi.Tools;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string midiPath = @"myMidiFile.mid";
// Failed to see lib
//Melanchall.DryWetMidi.Common.Read(string filePath, ReadingSettings settings = null)
//BuildMoonlightSonata();
//dry-wet
}
}
}`
from drywetmidi.
Melanchall.DryWetMidi.Common.Read
Where did you see that? :) Please take a look at the library README:
To read a MIDI file you have to use
Read
static method of theMidiFile
:
var midiFile = MidiFile.Read("Some Great Song.mid");
Also please tell me what does it mean?
I have downloaded the Nuget package
You need to install package via NuGet Package Manager inside Visual Studio.
from drywetmidi.
Sorry man for my ignorance, I am obviously very stupid basic and do not understand classes. I tried random things from here https://github.com/melanchall/drywetmidi/wiki/Reading-a-MIDI-file
You can see I here have errors
from drywetmidi.
You need add
using Melanchall.DryWetMidi.Smf;
Please take a look at this symbol in Visual Studio from your screenshot:
If you click this dropdown, VS will suggest you to add missed using automatically.
from drywetmidi.
Thanks @melanchall
I can read/write the midi file now. I was very stupid and did not read carefully enough.
Can I ask some more questions please?
1: CsvConvertor - I have using Tools but I get an error message
2: Can I split a midi file into channels and save separate midi files? I have tried many methods (please see my ignorant code below) and I can't find a way to get even basic event information. What I want to do is split a midi file into tracks and then split the tracks into bars or using a grid. I would greatly appreciate if you could suggest to me how I might do this.
Thanks for your time.
Horrible code failures:
`
foreach (var trackChunk in midiFile.GetTrackChunks())
{
Console.WriteLine("Track Chunk ID: " + trackChunk.ChunkId.ToString());
using (var manager = new TimedEventsManager(trackChunk.Events))
{
TimedEventsCollection timedEvents = manager.Events;
TimedEvent firstEvent = timedEvents.First();
Console.WriteLine("First Event Delta Time: " + firstEvent.Event.DeltaTime.ToString());
//firstEvent.Time = 123;
//timedEvents.Add(new TimedEvent(new InstrumentNameEvent("Guitar"), 456));
}
//using (var notesManager = trackChunk.ManageNotes())
//{
// //notesManager.Notes.RemoveAll(n => n.NoteName == NoteName.CSharp);
// //Console.WriteLine("Notes: " + notesManager.Notes.);
//}
}
//foreach (var midiEvent in midiFile.GetTrackChunks().Select(c => c.Events))
//{
// Console.WriteLine("Event: " + midiEvent.ToString());
//}
//var trackChunks = midiFile.GetTrackChunks();
//using (var notesManager = new NotesManager(trackChunk.Events))
//{
// NotesCollection notes = notesManager.Notes;
//}
//using (var chordsManager = new ChordsManager(trackChunk.Events))
//{
// ChordsCollection chords = chordsManager.Chords;
//}
using (var notesManager = midiFile.GetTrackChunks().First().ManageNotes())
{
NotesCollection notes = notesManager.Notes;
// Get all C# notes
//IEnumerable<Note> cSharpNotes = notes.Where(n => n.NoteName == NoteName.CSharp);
// Reduce length of all C# notes by 100
foreach (var note in notes)
{
Console.WriteLine("Note length: " + note.Length);
}
//var notesEndedAt20Seconds = notesManager.Notes.EndAtTime(new MetricTimeSpan(0, 0, 20), tempoMap);
//var firstNoteLength = notesEndedAt20Seconds.First().LengthAs<MetricTimeSpan>(tempoMap);
}`
from drywetmidi.
1
var csvConverter = new CsvConverter();
csvConverter.ConvertMidiFileToCsv(midiFile, "D:\taiko.csv", true, null);
2
// Split by channel
var midiFilesByChannels = midiFile.SplitByChannel();
// Split each new file by grid with step of 1 bar and save each 1-bar file
var grid = new SteppedGrid(new BarBeatTimeSpan(1, 0));
foreach (var midiFileByChannel in midiFilesByChannels)
{
var channel = midiFileByChannel.GetTimedEvents().Select(e => e.Event).OfType<ChannelEvent>().First().Channel;
var oneBarFiles = midiFileByChannel.SplitByGrid(grid);
var i = 0;
foreach (var oneBarFile in oneBarFiles)
{
oneBarFile.Write($"File_{channel}_{i++}.mid");
}
}
from drywetmidi.
This is incredible! Thank you so much :)
Cheers
from drywetmidi.
Related Issues (20)
- HELP !!! Notes in panel to midi file?? HOT 9
- please help a noob HOT 6
- Remove all notes example from the README not working HOT 9
- Using wetdrymidi in C# project causes error CS0009
- InputDevice event listening crash HOT 2
- Crash when running in Unity on M2 MacBook HOT 3
- MidiDeviceException Internal error HOT 9
- Android Support
- Unity cannot exit after use HOT 10
- MidiClock sync problem HOT 6
- MIDI Tempo changes count returns 1 but the song has 6 tempo changes. HOT 1
- add il2cpp mode HOT 5
- CustomChunk no mididata throw error HOT 4
- CSharp Code Error HOT 2
- MIDI File returns error: InvalidMetaEventParameterValueException HOT 1
- Unable to send Note-On event to device HOT 8
- Cannot get track name to change HOT 10
- How to use DryWetMidi in Visual Basic (VS 2022) ? HOT 20
- Plans for MIDI 2.0 Support? HOT 2
- Skipping notes HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drywetmidi.