how to create midifile from text

Windows specific forum
marcos.exe
User
User
Posts: 20
Joined: Fri Jan 17, 2020 8:20 pm

how to create midifile from text

Post by marcos.exe »

I would like to be able to create a music editing program for the blind, as what exists is very complex and inaccessible.
I already have libraries, and even scripts that don't need a library to play instruments in real time.
I created a structure to play notes on the respective channels, with their instruments.
No intention of using vst's or plugins, as this would require a learning time that I don't have at the moment. And even ... One step at a time.
But I need to export these variables and expressions to a mid file.
I searched here on the forum, but I couldn't find something that works as I need it.
Would anyone know how to do this?
I am grateful now.

Original

Gostaria de poder criar programa de edição de músicas para cegos, pois o que existem são muito complexos e inacessíveis.
Já tenho bibliotecas, e até scripts que não precisam de biblioteca para executar instrumentos em tempo real.
criei estrutura para tocar notas em respectivos canais, com seus instrumentos.
Sem pretenção de usar vst's ou plugins, pois isso demandaria um tempo de aprendizado que não tenho no momento. E até... Um passo de cada vez.
Mas preciso exportar essas variáveis e expressões para um arquivo mid.
Pesquisei aqui no forum, mas não consegui encontrar algo que funcione como eu preciso.
Alguém saberia como fazer isso?
Fico grato desde já.
When our generation/OS updates, we either update ourselves, or we are removed.
But we are never fully uninstalled.
infratec
Always Here
Always Here
Posts: 6867
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: how to create midifile from text

Post by infratec »

Hi Marcos,

I think you asked in the wrong category.
You should ask such questions in 'Coding questions'.

In general the format of the midi file format is created of at least 2 parts.
A header and one or multiple tracks.

The easisest way is a file with one track (0) or with synchronous tracks (1)

The header looks always like

4D 54 68 64 00 00 00 06 ff ff nn nn dd dd

With

ff ff : Fileformat 0 one track, 1 synchronous tracks, 2 asynchronous tracks
nn nn : count of the tracks
dd dd : delta time ticks per quarter note

This is followed by the track(s)

They always starts with
4D 54 72 6B xx xx xx xx

xx xx xx xx : length of the following track data
followed by the midi commands.
But in front of each midi command is a delta time which tells after how many delta ticks the command is executed.
This delta time is length encoded and can be up to 4 bytes. The highest bit tells if an other byte is following.
So there are only 7 databits for the length.

It really depends on your data which you want to save as midi.
marcos.exe
User
User
Posts: 20
Joined: Fri Jan 17, 2020 8:20 pm

Re: how to create midifile from text

Post by marcos.exe »

I downloaded a PDF that has this information, but I didn't understand it. I am studying more deeply.
But from what you wrote, I see that I am on the right track.
However, I'm not sure how to write this in a midi file.

I found in another basic language, a creation of a simple midi file, and I'm trying to transcribe it to PureBasic.
https://mojolabs.nz/codearcs.php?code=1742

Language works very similar to PB, except for a few small details.
But before I continue, I need to know if I need to delete the post here, and ask the question again in the appropriate place.
And right now, sorry for the confusion, because for not speaking English well, I misinterpreted the place of posting.


original

Eu baixei um PDF que tem essas informações, mas não compreendi. Estou estudando mais profundamente.
Mas pelo que você escreveu, vejo que estou no caminho certo.
Porém, não sei bem como escrever isso em um arquivo midi.

Eu encontrei em uma outra linguagem basic, uma criação de um arquivo midi simples, e estou tentando transcrever para o PureBasic.
https://mojolabs.nz/codearcs.php?code=1742

Funciona naquela linguagem bem parecida com PB, exceto por alguns pequenos detalhes.
Mas antes de continuar, preciso saber se é necessário que eu apague a postagem aqui, e refaça a pergunta no local adequado.
E desde já, desculpe a confusão, pois por não falar bem o inglês, interpretei errado o local de postagem.
When our generation/OS updates, we either update ourselves, or we are removed.
But we are never fully uninstalled.
Aleks_Longard
User
User
Posts: 59
Joined: Mon Dec 24, 2012 9:07 am
Location: Germany, Munich

Re: how to create midifile from text

Post by Aleks_Longard »

Hello Marcos
You can find in google qws, it's midi editor special for the blind.
Or use Cockos Reaper DAW with plugin Osara.

In this forum you can search midi library with all midi parse commands.
Cheers!
Sory my bad english
Post Reply