PureBasic Forum

how to create midifile from text
Page 1 of 1

Author:  marcos.exe [ Tue Sep 08, 2020 4:47 pm ]
Post subject:  how to create midifile from text

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.


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á.

Author:  infratec [ Thu Sep 10, 2020 10:48 am ]
Post subject:  Re: how to create midifile from text

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


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.

Author:  marcos.exe [ Thu Sep 10, 2020 3:02 pm ]
Post subject:  Re: how to create midifile from text

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.

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.


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.

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.

Author:  Aleks_Longard [ Thu Sep 24, 2020 10:38 pm ]
Post subject:  Re: how to create midifile from text

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.

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group