question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HELP !!! Notes in panel to midi file??

See original GitHub issue

Hi at everybody! I m stuck in a very tiny question of sintax I have done an example to see the midi notes from a file into a panel. Ok!

But now just want to export the notes located in the panel to an archive.mid In a word to make the reverse function!




using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;
using System.Linq;
using System.Xml.Linq;
using System.Threading.Tasks;

using Melanchall.DryWetMidi.Devices;
using Melanchall.DryWetMidi.Common;
using Melanchall.DryWetMidi.Interaction;
using Melanchall.DryWetMidi.Core;
using [Melanchall.DryWetMidi.MusicTheory]

namespace panel_basic
{

	public partial class Form1 : Form

	{
		

		public Form1()

		{
			InitializeComponent();
		}

		private const int ALTURA_NOTA = 3;
		private const int ANCHO_NOTA = 6;

		private void Form1_Load(object sender, EventArgs e)
		{

			if (System.IO.File.Exists( "01.mid"))
			{
				Cargar_Notas( "01.mid");
			}
			else
			{
				MessageBox.Show("Not found 01.mid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
			}

		}

		private object Cargar_Notas(string file)
		{

			NoScrollPanel1.Controls.Clear();

			MidiFile midiFile = MidiFile.Read(file);
			var notes = midiFile.GetNotes();

			foreach (var note in midiFile.GetNotes())
			{

				var x = (note.Time * ANCHO_NOTA ) + 127 ;
				var y = 480 - (note.NoteNumber) * ALTURA_NOTA ;
				var width = note.Length * ANCHO_NOTA;
				var height = ANCHO_NOTA;

				Panel rectangulo = new Panel();
				rectangulo.Location = new Point((int)(x / 10), y);
				rectangulo.Size = new Size((int)(width / 10), height);
				rectangulo.BackColor = Color.Cyan;			
				NoScrollPanel1. Controls.Add(rectangulo);

			}
			
			return null;
		}

	}

}

Issue Analytics

  • State:closed
  • Created 5 months ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
CIRCE-EYEScommented, May 1, 2023

Yeah! Now IT runs good, but needs to replace the ppq to 960. I use your : TicksPerQuarterNoteTimeDivision in the write function. And the result its very good. Thanks a lot. I Will post the final result as a very aceptable semi-piano roll viewer and editor notes here in Github

1reaction
melanchallcommented, May 1, 2023

Also length should be the second argument in the constructor, not the third one. And this also is specified in the documentation:

public Note(SevenBitNumber noteNumber, long length, long time)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Entering Notes with from a MIDI file
Click on the Read File Button and select the Midi file from the Open Panel. Play the quantized version of the MIDI file...
Read more >
Need help setting staves for imported MIDI file
When I import a MIDI file of a solo piano performance, the display of notes looks crazy. It starts with two bass staves,...
Read more >
MIDI import
A MIDI Import Panel appears at the bottom of the screen, showing a list of tracks (only tracks with note events are shown)...
Read more >
Help with MIDI file? [Archive]
Drums are usually on midi channel 10. So open it in reapers midi editor, select all notes and set them to channel 10...
Read more >
10. Editing MIDI Notes and Velocities
To bring up the MIDI Note Editor, double-click a MIDI clip to open the Clip View. You can then choose from any of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found